kaddressbook

kabentrypainter.h
00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of TQt, and distribute the resulting executable,
00021     without including the source code for TQt in the source distribution.
00022 */
00023 
00024 #ifndef KABENTRYPAINTER_H
00025 #define KABENTRYPAINTER_H
00026 
00027 #include <kabc/addressbook.h>
00028 
00029 #include <tqcolor.h>
00030 #include <tqfont.h>
00031 #include <tqrect.h>
00032 #include <tqvaluelist.h>
00033 
00034 typedef TQValueList<TQRect> TQRectList;
00035 
00036 class KABEntryPainter
00037 {
00038   public:
00039     KABEntryPainter();
00040     ~KABEntryPainter();
00041 
00061     bool printAddressee( const KABC::Addressee &addr, const TQRect &window,
00062                          TQPainter *p, int top = 0, bool fake = false,
00063                          TQRect *rect = 0 );
00064 
00065     void setForegroundColor( const TQColor &color = TQt::black );
00066     void setBackgroundColor( const TQColor &color = TQt::black );
00067     void setHeaderColor( const TQColor &color = TQt::white );
00068 
00069     void setHeaderFont( const TQFont &font = TQFont( "Helvetica", 12, TQFont::Normal, true ) );
00070     void setHeadLineFont( const TQFont &font = TQFont( "Helvetica", 12, TQFont::Normal, true ) );
00071     void setBodyFont( const TQFont &font = TQFont( "Helvetica", 12, TQFont::Normal, true ) );
00072     void setFixedFont( const TQFont &font = TQFont( "Courier", 12, TQFont::Normal, true ) );
00073     void setCommentFont( const TQFont &font = TQFont( "Helvetica", 10, TQFont::Normal, true ) );
00074 
00075     void setUseHeaderColor( bool value = true );
00076 
00077     void setShowAddresses( bool value = true );
00078     void setShowEmails( bool value = true );
00079     void setShowPhones( bool value = true );
00080     void setShowURLs( bool value = true );
00081 
00088     int hitsEmail( const TQPoint &p );
00089 
00094     int hitsPhone( const TQPoint &p );
00095 
00100     int hitsTalk( const TQPoint &p );
00101 
00106     int hitsURL( const TQPoint &p );
00107 
00108   private:
00109     int hits( const TQRectList& rects, const TQPoint &p );
00110 
00111     TQColor mForegroundColor;
00112     TQColor mBackgroundColor;
00113     TQColor mHeaderColor;
00114 
00115     TQFont mHeaderFont;
00116     TQFont mHeadLineFont;
00117     TQFont mBodyFont;
00118     TQFont mFixedFont;
00119     TQFont mCommentFont;
00120 
00121     bool mUseHeaderColor;
00122     bool mShowAddresses;
00123     bool mShowEmails;
00124     bool mShowPhones;
00125     bool mShowURLs;
00126 
00127     TQRectList mEmailRects;
00128     TQRectList mPhoneRects;
00129     TQRectList mURLRects;
00130     TQRectList mTalkRects;
00131 };
00132 
00133 #endif