1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
/*
$Id$
This file is part of the KDE libraries
Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
KDE3 port (C) 2001-2002 Maksim Orlovich <mo002j@mail.rochester.edu>
Port version 0.9.7
Includes code portions from the dotNET style, and the KDE HighColor style.
dotNET Style
Copyright (C) 2001, Chris Lee <lee@azsites.com>
Carsten Pfeiffer <pfeiffer@kde.org>
KDE3 HighColor Style
Copyright (C) 2001 Karol Szwed <gallium@kde.org>
(C) 2001 Fredrik H�glund <fredrik@kde.org>
Drawing routines adapted from the KDE2 HCStyle,
Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
(C) 2000 Dirk Mueller <mueller@kde.org>
(C) 2001 Martijn Klingens <klingens@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KTHEMESTYLE_H
#define KTHEMESTYLE_H
#include <tqglobal.h>
#include "kthemebase.h"
#include <tqwindowdefs.h>
#include <tqobject.h>
#include <tqbutton.h>
#include <tqpushbutton.h>
#include <tqscrollbar.h>
#include <tqtabbar.h>
#include <tqstring.h>
#include <tqintdict.h>
#include <tqmap.h>
/**
* KDE themed styles.
*
* It provides methods for
* drawing most widgets with user-specified borders, highlights, pixmaps,
* etc. It also handles various other settings such as scrollbar types,
* rounded buttons, and shading types. For a full list of parameters this
* class handles refer to the KDE theme configuration documentation.
*
*/
class KThemeStyle: public KThemeBase
{
Q_OBJECT
public:
/**
* Constructs a new KThemeStyle object.
*
* @param configDir The directory which has the KConfig file.
* @param configFile A KConfig file to use as the theme configuration.
* Defaults to ~/.kderc.
*/
KThemeStyle( const TQString& configDir, const TQString &configFile = TQString::null );
~KThemeStyle();
virtual int pixelMetric ( PixelMetric metric, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget * widget = 0 ) const;
virtual void drawPrimitive ( PrimitiveElement pe, TQPainter * p, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQRect & r, const TQColorGroup & cg,
SFlags flags = Style_Default,
const TQStyleOption& = TQStyleOption::Default ) const;
virtual void drawControl( ControlElement element,
TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags how = Style_Default,
const TQStyleOption& = TQStyleOption::Default,
const TQWidget *widget = 0 ) const;
virtual void drawControlMask( ControlElement element,
TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQStyleOption& = TQStyleOption::Default,
const TQWidget *widget = 0 ) const;
virtual void drawComplexControl( TQ_ComplexControl control,
TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags = Style_Default,
SCFlags controls = SC_All,
SCFlags active = SC_None,
const TQStyleOption& = TQStyleOption::Default,
const TQWidget* widget = 0 ) const;
virtual void drawKStylePrimitive( KStylePrimitive kpe,
TQPainter* p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags = Style_Default,
const TQStyleOption& = TQStyleOption::Default,
const TQWidget* widget = 0 ) const;
virtual int styleHint( StyleHint sh,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQStyleOption& = TQStyleOption::Default,
TQStyleHintReturn* returnData = 0,
const TQWidget *widget = 0 ) const;
virtual TQSize sizeFromContents( ContentsType contents,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQSize &contentsSize,
const TQStyleOption& = TQStyleOption::Default,
const TQWidget *widget = 0 ) const;
virtual TQRect subRect(SubRect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *) const;
virtual void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
virtual void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
/**
* By default this just sets the background brushes to the pixmapped
* background.
*/
virtual void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
virtual void applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
/** \internal */
// to make it possible for derived classes to overload this function
virtual void polish( TQPalette& pal );
/**
* This is a convenience method for drawing widgets with
* borders, highlights, pixmaps, colors, etc...
* You specify the widget type and it will draw it according to the
* config file settings.
*
* @param x The x coordinate of the button's upper left hand corner.
* @param y The y coordinate of the buttons' upper left hand corner.
* @param w The button width.
* @param h The button height.
* @param p The TQPainter to draw on.
* @param g The color group to use.
* @param sunken The button is drawn with a sunken style if @p true
* @param rounded @p true if the widget is rounded, @p false if rectangular.
* @param type The widget type to paint.
*/
virtual void drawBaseButton( TQPainter *p, int x, int y, int w, int h,
const TQColorGroup &g, bool sunken = false,
bool rounded = false, WidgetType type = Bevel ) const;
/**
* Draw a mask with for widgets that may be rounded.
*
*Currently used
* by pushbuttons and comboboxes.
*
* @param p The TQPainter to draw on.
* @param x The x coordinate of the widget's upper left hand corner.
* @param y The y coordinate of the widget's upper left hand corner.
* @param w The widget width.
* @param h The widget height.
* @param rounded @p true if the widget is rounded, @p false if rectangular.
*/
virtual void drawBaseMask( TQPainter *p, int x, int y, int w, int h,
bool rounded ) const;
/**
* Draw a shaded rectangle using the given style.
*
* @param p The painter to draw on.
* @param g The color group to use.
* @param x The x coordinate of the rectangle's upper left hand corner.
* @param y The y coordinate of the rectangle's upper left hand corner.
* @param w The rectangle width.
* @param h The rectangle height.
* @param sunken Draws a sunken style if @p true.
* @param rounded Draws a rounded shape if @p true. Requires bWidth to be
* at least 1.
* @param hWidth The highlight width.
* @param bWidth The border width.
* @param style The shading style to use.
*/
virtual void drawShade( TQPainter *p, int x, int y, int w, int h,
const TQColorGroup &g, bool sunken, bool rounded,
int hWidth, int bWidth, ShadeStyle style ) const;
int popupMenuItemHeight( bool checkable, TQMenuItem *mi,
const TQFontMetrics &fm );
protected:
TQPalette oldPalette, popupPalette, indiPalette, exIndiPalette;
bool paletteSaved;
bool polishLock;
TQStyle *mtfstyle;
TQPixmap* makeMenuBarCache(int w, int h) const;
mutable TQPixmap* menuCache;
mutable TQPixmap* vsliderCache;
Qt::HANDLE brushHandle;
bool brushHandleSet;
bool kickerMode;
protected slots:
void paletteChanged();
};
#endif
|