author | sandman <sandman> | 2002-06-29 23:45:19 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-29 23:45:19 (UTC) |
commit | 769df90a59d6aa840b8d6568287001e66e263f01 (patch) (unidiff) | |
tree | 415c7e4ff70a9b035c31b28971a568bc2827ae34 /noncore/styles/theme/othemestyle.h | |
parent | 0f179c0cc471b659b30dec4762c9c36678063f31 (diff) | |
download | opie-769df90a59d6aa840b8d6568287001e66e263f01.zip opie-769df90a59d6aa840b8d6568287001e66e263f01.tar.gz opie-769df90a59d6aa840b8d6568287001e66e263f01.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'noncore/styles/theme/othemestyle.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/styles/theme/othemestyle.h | 365 |
1 files changed, 365 insertions, 0 deletions
diff --git a/noncore/styles/theme/othemestyle.h b/noncore/styles/theme/othemestyle.h new file mode 100644 index 0000000..02bec78 --- a/dev/null +++ b/noncore/styles/theme/othemestyle.h | |||
@@ -0,0 +1,365 @@ | |||
1 | /* This file is part of the KDE libraries | ||
2 | Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License version 2 as published by the Free Software Foundation. | ||
7 | |||
8 | This library is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | Library General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU Library General Public License | ||
14 | along with this library; see the file COPYING.LIB. If not, write to | ||
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
16 | Boston, MA 02111-1307, USA. | ||
17 | */ | ||
18 | #ifndef __KTHEMESTYLE_H | ||
19 | #define __KTHEMESTYLE_H | ||
20 | |||
21 | #include "othemebase.h" | ||
22 | #include <qwindowdefs.h> | ||
23 | #include <qobject.h> | ||
24 | #include <qbutton.h> | ||
25 | #include <qpushbutton.h> | ||
26 | #include <qscrollbar.h> | ||
27 | #include <qstring.h> | ||
28 | |||
29 | |||
30 | /** | ||
31 | * KDE themed styles. | ||
32 | * | ||
33 | * It provides methods for | ||
34 | * drawing most widgets with user-specified borders, highlights, pixmaps, | ||
35 | * etc. It also handles various other settings such as scrollbar types, | ||
36 | * rounded buttons, and shading types. For a full list of parameters this | ||
37 | * class handles refer to the KDE theme configuration documentation. | ||
38 | * | ||
39 | */ | ||
40 | |||
41 | class OThemeStyle: public OThemeBase | ||
42 | { | ||
43 | Q_OBJECT | ||
44 | public: | ||
45 | /** | ||
46 | * Construct a new @ref OThemeStyle object. | ||
47 | * | ||
48 | * @param configFile A KConfig file to use as the theme configuration. | ||
49 | * Defaults to ~/.kderc. | ||
50 | */ | ||
51 | OThemeStyle( const QString &configFile = QString::null ); | ||
52 | ~OThemeStyle(); | ||
53 | virtual void polish( QWidget* ); | ||
54 | virtual void unPolish( QWidget* ); | ||
55 | /** | ||
56 | * By default this just sets the background brushes to the pixmapped | ||
57 | * background. | ||
58 | */ | ||
59 | virtual void polish( QApplication *app ); | ||
60 | virtual void unPolish( QApplication* ); | ||
61 | |||
62 | /// @internal | ||
63 | // to make it possible for derived classes to overload this function | ||
64 | virtual void polish( QPalette& pal ); | ||
65 | |||
66 | /** | ||
67 | * This is a convenience method for drawing widgets with | ||
68 | * borders, highlights, pixmaps, colors, etc... | ||
69 | * You specify the widget type and it will draw it according to the | ||
70 | * config file settings. | ||
71 | * | ||
72 | * @param p The QPainter to draw on. | ||
73 | * @param g The color group to use. | ||
74 | * @param rounded @p true if the widget is rounded, @p false if rectangular. | ||
75 | * @param type The widget type to paint. | ||
76 | * @param fill An optional fill brush. Currently ignored (the config file | ||
77 | * is used instead). | ||
78 | */ | ||
79 | virtual void drawBaseButton( QPainter *p, int x, int y, int w, int h, | ||
80 | const QColorGroup &g, bool sunken = FALSE, | ||
81 | bool rounded = FALSE, WidgetType type = Bevel, | ||
82 | const QBrush *fill = 0 ); | ||
83 | /** | ||
84 | * Draw a mask with for widgets that may be rounded. | ||
85 | * | ||
86 | *Currently used | ||
87 | * by pushbuttons and comboboxes. | ||
88 | * | ||
89 | * @param p The QPainter to draw on. | ||
90 | * @param rounded @p true if the widget is rounded, @p false if rectangular. | ||
91 | */ | ||
92 | virtual void drawBaseMask( QPainter *p, int x, int y, int w, int h, | ||
93 | bool rounded ); | ||
94 | /** | ||
95 | * Draw a pushbutton. | ||
96 | * | ||
97 | * This calls @ref drawBaseButton() with @p PushButton as the | ||
98 | * widget type. | ||
99 | */ | ||
100 | virtual void drawButton( QPainter *p, int x, int y, int w, int h, | ||
101 | const QColorGroup &g, bool sunken = FALSE, | ||
102 | const QBrush *fill = 0 ); | ||
103 | /** | ||
104 | * Draw a bevel button. | ||
105 | * | ||
106 | * This calls @ref drawBaseButton() with Bevel as the | ||
107 | * widget type. | ||
108 | */ | ||
109 | virtual void drawBevelButton( QPainter *p, int x, int y, int w, int h, | ||
110 | const QColorGroup &g, bool sunken = FALSE, | ||
111 | const QBrush *fill = 0 ); | ||
112 | #if 0 | ||
113 | /** | ||
114 | * Draw a toolbar button. | ||
115 | */ | ||
116 | virtual void drawKToolBarButton( QPainter *p, int x, int y, int w, int h, | ||
117 | const QColorGroup &g, bool sunken = false, | ||
118 | bool raised = true, bool enabled = true, | ||
119 | bool popup = false, KToolButtonType type = Icon, | ||
120 | const QString &btext = QString::null, | ||
121 | const QPixmap *icon = NULL, | ||
122 | QFont *font = NULL, QWidget *btn = NULL ); | ||
123 | /** | ||
124 | * Draw the handle used in toolbars. | ||
125 | */ | ||
126 | void drawKBarHandle( QPainter *p, int x, int y, int w, int h, | ||
127 | const QColorGroup &g, | ||
128 | KToolBarPos type, QBrush *fill = NULL ); | ||
129 | |||
130 | /** | ||
131 | * Draw a toolbar. | ||
132 | */ | ||
133 | void drawKToolBar( QPainter *p, int x, int y, int w, int h, | ||
134 | const QColorGroup &g, KToolBarPos type, | ||
135 | QBrush *fill = NULL ); | ||
136 | #endif | ||
137 | /** | ||
138 | * Return the space available in a pushbutton, taking configurable | ||
139 | * borders and highlights into account. | ||
140 | */ | ||
141 | virtual QRect buttonRect( int x, int y, int w, int h ); | ||
142 | /** | ||
143 | * Draw an arrow in the style specified by the config file. | ||
144 | */ | ||
145 | virtual void drawArrow( QPainter *p, Qt::ArrowType type, bool down, | ||
146 | int x, int y, int w, int h, const QColorGroup &g, | ||
147 | bool enabled = true, const QBrush *fill = 0 ); | ||
148 | /** | ||
149 | * Return the size of the exclusive indicator pixmap if one is specified | ||
150 | * in the config file, otherwise it uses the base style's size. | ||
151 | */ | ||
152 | virtual QSize exclusiveIndicatorSize() const; | ||
153 | /** | ||
154 | * Draw an exclusive indicator widget. | ||
155 | * | ||
156 | * If a pixmap is specified in the | ||
157 | * config file that is used, otherwise the base style's widget is drawn. | ||
158 | */ | ||
159 | virtual void drawExclusiveIndicator( QPainter* p, int x, int y, int w, | ||
160 | int h, const QColorGroup &g, bool on, | ||
161 | bool down = FALSE, | ||
162 | bool enabled = TRUE ); | ||
163 | /** | ||
164 | * Set the mask of an exclusive indicator widget. | ||
165 | * | ||
166 | * If a pixmap is specified | ||
167 | * it is masked according to it's transparent pixels, otherwise the | ||
168 | * base style's mask is used. | ||
169 | */ | ||
170 | virtual void drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, | ||
171 | int h, bool on ); | ||
172 | /** | ||
173 | * Set the mask of an indicator widget. | ||
174 | * | ||
175 | * If a pixmap is specified | ||
176 | * it is masked according to it's transparent pixels, otherwise the | ||
177 | * base style's mask is used. | ||
178 | */ | ||
179 | virtual void drawIndicatorMask( QPainter *p, int x, int y, int w, int h, | ||
180 | int state ); | ||
181 | /** | ||
182 | * Set the mask for pushbuttons. | ||
183 | */ | ||
184 | virtual void drawButtonMask( QPainter *p, int x, int y, int w, int h ); | ||
185 | /** | ||
186 | * Set the mask for combo boxes. | ||
187 | */ | ||
188 | virtual void drawComboButtonMask( QPainter *p, int x, int y, int w, int h ); | ||
189 | /** | ||
190 | * Return the size of the indicator pixmap if one is specified | ||
191 | * in the config file, otherwise it uses the base style's size. | ||
192 | */ | ||
193 | virtual QSize indicatorSize() const; | ||
194 | /** | ||
195 | * Draw an indicator widget. | ||
196 | * | ||
197 | * If a pixmap is specified in the | ||
198 | * config file that is used, otherwise the base style's widget is drawn. | ||
199 | */ | ||
200 | virtual void drawIndicator( QPainter* p, int x, int y, int w, int h, | ||
201 | const QColorGroup &g, int state, | ||
202 | bool down = FALSE, bool enabled = TRUE ); | ||
203 | /** | ||
204 | * Draw a combobox. | ||
205 | */ | ||
206 | virtual void drawComboButton( QPainter *p, int x, int y, int w, int h, | ||
207 | const QColorGroup &g, bool sunken = FALSE, | ||
208 | bool editable = FALSE, bool enabled = TRUE, | ||
209 | const QBrush *fill = 0 ); | ||
210 | /** | ||
211 | * Draw a pushbutton. | ||
212 | */ | ||
213 | virtual void drawPushButton( QPushButton* btn, QPainter *p ); | ||
214 | /** | ||
215 | * Return the amount of button content displacement specified by the | ||
216 | * config file. | ||
217 | */ | ||
218 | virtual void getButtonShift( int &x, int &y ); | ||
219 | /** | ||
220 | * Return the frame width. | ||
221 | */ | ||
222 | virtual int defaultFrameWidth() const; | ||
223 | /** | ||
224 | * Calculate the metrics of the scrollbar controls according to the | ||
225 | * layout specified by the config file. | ||
226 | */ | ||
227 | virtual void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int& ); | ||
228 | /** | ||
229 | * Draw a themed scrollbar. | ||
230 | */ | ||
231 | virtual void drawScrollBarControls( QPainter*, const QScrollBar*, | ||
232 | int sliderStart, uint controls, | ||
233 | uint activeControl ); | ||
234 | /** | ||
235 | * Return the control that the given point is over according to the | ||
236 | * layout in the config file. | ||
237 | */ | ||
238 | virtual ScrollControl scrollBarPointOver( const QScrollBar*, | ||
239 | int sliderStart, const QPoint& ); | ||
240 | /** | ||
241 | * Return the configurable default slider length. | ||
242 | */ | ||
243 | virtual int sliderLength() const; | ||
244 | /** | ||
245 | * Draw a slider control. | ||
246 | */ | ||
247 | virtual void drawSlider( QPainter *p, int x, int y, int w, int h, | ||
248 | const QColorGroup &g, Orientation, bool tickAbove, | ||
249 | bool tickBelow ); | ||
250 | /** | ||
251 | * Draw a slider groove. | ||
252 | */ | ||
253 | void drawSliderGroove( QPainter *p, int x, int y, int w, int h, | ||
254 | const QColorGroup& g, QCOORD c, | ||
255 | Orientation ); | ||
256 | /** | ||
257 | * Draw the mask for a slider (both the control and groove. | ||
258 | */ | ||
259 | virtual void drawSliderMask( QPainter *p, int x, int y, int w, int h, | ||
260 | Orientation, bool tickAbove, bool tickBelow ); | ||
261 | // void drawSliderGrooveMask(QPainter *p,int x, int y, int w, int h, | ||
262 | // QCOORD c, Orientation ); | ||
263 | /** | ||
264 | * Convience method for drawing themed scrollbar grooves. | ||
265 | * | ||
266 | * Since the | ||
267 | * grooves may be a scaled pixmap you cannot just bitblt the pixmap at | ||
268 | * any offset. This generates a cached pixmap at full size if needed and | ||
269 | * then copies the requested area. | ||
270 | * | ||
271 | * @param p The painter to draw on. | ||
272 | * @param sb The scrollbar (usually given by drawScrollBarControls). | ||
273 | * @param horizontal Is the scrollBar horizontal? | ||
274 | * @param r The rectangle to fill. | ||
275 | * @param g The color group to use. | ||
276 | */ | ||
277 | virtual void drawScrollBarGroove( QPainter *p, const QScrollBar *sb, | ||
278 | bool horizontal, QRect r, QColorGroup g ); | ||
279 | /** | ||
280 | * Draw a shaded rectangle using the given style. | ||
281 | * | ||
282 | * @param p The painter to draw on. | ||
283 | * @param g The color group to use. | ||
284 | * @param rounded Draws a rounded shape if true. Requires bWidth to be | ||
285 | * at least 1. | ||
286 | * @param hWidth The highlight width. | ||
287 | * @param bWidth The border width. | ||
288 | * @param style The shading style to use. | ||
289 | */ | ||
290 | virtual void drawShade( QPainter *p, int x, int y, int w, int h, | ||
291 | const QColorGroup &g, bool sunken, bool rounded, | ||
292 | int hWidth, int bWidth, ShadeStyle style ); | ||
293 | /** | ||
294 | * Draw the text for a pushbutton. | ||
295 | */ | ||
296 | virtual void drawPushButtonLabel( QPushButton *btn, QPainter *p ); | ||
297 | /** | ||
298 | * Draw a menubar. | ||
299 | */ | ||
300 | #if 0 | ||
301 | |||
302 | void drawKMenuBar( QPainter *p, int x, int y, int w, int h, | ||
303 | const QColorGroup &g, bool macMode, | ||
304 | QBrush *fill = NULL ); | ||
305 | #endif | ||
306 | /** | ||
307 | * Draw a menubar item. | ||
308 | */ | ||
309 | #if 0 | ||
310 | |||
311 | virtual void drawKMenuItem( QPainter *p, int x, int y, int w, int h, | ||
312 | const QColorGroup &g, bool active, | ||
313 | QMenuItem *item, QBrush *fill = NULL ); | ||
314 | #endif | ||
315 | /** | ||
316 | * Return the width of the splitter as specified in the config file. | ||
317 | */ | ||
318 | virtual int splitterWidth() const; | ||
319 | /** | ||
320 | * Draw a splitter widget. | ||
321 | */ | ||
322 | virtual void drawSplitter( QPainter *p, int x, int y, int w, int h, | ||
323 | const QColorGroup &g, Orientation ); | ||
324 | /** | ||
325 | * Draw a checkmark. | ||
326 | */ | ||
327 | virtual void drawCheckMark( QPainter *p, int x, int y, int w, int h, | ||
328 | const QColorGroup &g, bool act, bool dis ); | ||
329 | /** | ||
330 | * Draw a menu item. | ||
331 | * | ||
332 | * Note: This method manually handles applying | ||
333 | * inactive menu backgrounds to the entire widget. | ||
334 | */ | ||
335 | virtual void drawPopupMenuItem( QPainter *p, bool checkable, int maxpmw, | ||
336 | int tab, QMenuItem *mi, const QPalette &pal, | ||
337 | bool act, bool enabled, int x, int y, int w, | ||
338 | int h ); | ||
339 | int popupMenuItemHeight( bool checkable, QMenuItem *mi, | ||
340 | const QFontMetrics &fm ); | ||
341 | /** | ||
342 | * Draw the focus rectangle. | ||
343 | */ | ||
344 | void drawFocusRect( QPainter *p, const QRect &r, const QColorGroup &g, | ||
345 | const QColor *c = 0, bool atBorder = false ); | ||
346 | /** | ||
347 | * Draw a @ref KProgess bar. | ||
348 | */ | ||
349 | // virtual void drawKProgressBlock(QPainter *p, int x, int y, int w, int h, | ||
350 | // const QColorGroup &g, QBrush *fill); | ||
351 | /** | ||
352 | * Return the background for @ref KProgress. | ||
353 | */ | ||
354 | // virtual void getKProgressBackground(const QColorGroup &g, QBrush &bg); | ||
355 | virtual void tabbarMetrics( const QTabBar*, int&, int&, int& ); | ||
356 | virtual void drawTab( QPainter*, const QTabBar*, QTab*, bool selected ); | ||
357 | virtual void drawTabMask( QPainter*, const QTabBar*, QTab*, bool selected ); | ||
358 | protected: | ||
359 | QPalette oldPalette, popupPalette, indiPalette, exIndiPalette; | ||
360 | |||
361 | class OThemeStylePrivate; | ||
362 | OThemeStylePrivate *d; | ||
363 | }; | ||
364 | |||
365 | #endif | ||