Framework for looking up contacts directly in nepomuk in addition to going through...
[kdepim.git] / messageviewer / csshelperbase.h
blob9e6dd0a3221d2c27e59d007690900070892c029d
1 /* -*- c++ -*-
2 csshelper.h
4 This file is part of KMail, the KDE mail client.
5 Copyright (c) 2003 Marc Mutz <mutz@kde.org>
7 KMail is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License, version 2, as
9 published by the Free Software Foundation.
11 KMail is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 In addition, as a special exception, the copyright holders give
21 permission to link the code of this program with any edition of
22 the Qt library by Trolltech AS, Norway (or with modified versions
23 of Qt that use the same license as Qt), and distribute linked
24 combinations including the two. You must obey the GNU General
25 Public License in all respects for all of the code used other than
26 Qt. If you modify this file, you may extend this exception to
27 your version of the file, but you are not obligated to do so. If
28 you do not wish to do so, delete this exception statement from
29 your version.
32 #ifndef MESSAGEVIEWER_CSSHELPERBASE_H
33 #define MESSAGEVIEWER_CSSHELPERBASE_H
35 #include "messageviewer_export.h"
36 #include <QColor>
37 #include <QFont>
39 class QString;
40 class QPaintDevice;
42 namespace MessageViewer {
44 class MESSAGEVIEWER_EXPORT CSSHelperBase {
45 public:
46 /** Construct a CSSHelper object and set its font and color settings to
47 default values.
48 Sub-Classes should put their config loading here.
50 CSSHelperBase( const QPaintDevice *pd );
52 /** @return HTML head including style sheet definitions and the
53 &gt;body&lt; tag */
54 QString htmlHead( bool fixedFont = false ) const;
56 /** @return The collected CSS definitions as a string */
57 QString cssDefinitions( bool fixedFont = false ) const;
59 /** @return a &lt;div&gt; start tag with embedded style
60 information suitable for quoted text with quote level @p level */
61 QString quoteFontTag( int level ) const;
62 /** @return a &lt;div&gt; start tag with embedded style
63 information suitable for non-quoted text */
64 QString nonQuotedFontTag() const;
66 QFont bodyFont( bool fixedFont = false, bool printing = false ) const;
68 void setBodyFont( const QFont& font );
69 void setPrintFont( const QFont& font );
71 /** @return the quote color for the given level, where level ranges from 0 to 2 **/
72 QColor quoteColor( int level );
74 QColor pgpWarnColor() const;
76 protected:
77 /** Recalculate PGP frame and body colors (should be called after changing
78 color settings) */
79 void recalculatePGPColors();
81 protected:
82 QFont mBodyFont, mPrintFont, mFixedFont, mFixedPrintFont;
83 QFont mQuoteFont[3];
84 QColor mQuoteColor[3];
85 bool mRecycleQuoteColors;
86 bool mBackingPixmapOn;
87 bool mShrinkQuotes;
88 QString mBackingPixmapStr;
89 QColor mForegroundColor, mLinkColor, mVisitedLinkColor, mBackgroundColor;
90 // colors for PGP (Frame, Header, Body)
91 QColor cPgpOk1F, cPgpOk1H, cPgpOk1B,
92 cPgpOk0F, cPgpOk0H, cPgpOk0B,
93 cPgpWarnF, cPgpWarnH, cPgpWarnB,
94 cPgpErrF, cPgpErrH, cPgpErrB,
95 cPgpEncrF, cPgpEncrH, cPgpEncrB;
96 // color of frame of warning preceding the source of HTML messages
97 QColor cHtmlWarning;
99 private:
100 int fontSize( bool fixed, bool print = false ) const;
101 // returns CSS rules specific to the print media type
102 QString printCssDefinitions( bool fixed ) const;
103 // returns CSS rules specific to the screen media type
104 QString screenCssDefinitions( const CSSHelperBase * helper, bool fixed ) const;
105 // returns CSS rules common to both screen and print media types
106 QString commonCssDefinitions() const;
108 private:
109 const QPaintDevice *mPaintDevice;
115 #endif