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/othemebase.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/othemebase.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/styles/theme/othemebase.h | 739 |
1 files changed, 739 insertions, 0 deletions
diff --git a/noncore/styles/theme/othemebase.h b/noncore/styles/theme/othemebase.h new file mode 100644 index 0000000..e691692 --- a/dev/null +++ b/noncore/styles/theme/othemebase.h | |||
@@ -0,0 +1,739 @@ | |||
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 __OTHEMEBASE_H | ||
19 | #define __OTHEMEBASE_H | ||
20 | |||
21 | #include <qdatetime.h> | ||
22 | #include <qtimer.h> | ||
23 | #include <qwindowsstyle.h> | ||
24 | #include <qpixmap.h> | ||
25 | #include <qpe/config.h> | ||
26 | #include <qimage.h> | ||
27 | #include <qintcache.h> | ||
28 | #include <qstring.h> | ||
29 | #include <qpalette.h> | ||
30 | |||
31 | #define WIDGETS 54 | ||
32 | |||
33 | /** | ||
34 | * This class adds simple time management to QPixmap for use in flushing | ||
35 | * OThemeCache. | ||
36 | * | ||
37 | * @author Daniel M. Duley <mosfet@kde.org> | ||
38 | */ | ||
39 | class OThemePixmap : public QPixmap | ||
40 | { | ||
41 | public: | ||
42 | enum BorderType{Top = 0, Bottom, Left, Right, TopLeft, TopRight, BottomLeft, | ||
43 | BottomRight}; | ||
44 | |||
45 | OThemePixmap( bool timer = true ); | ||
46 | OThemePixmap( const OThemePixmap &p ); | ||
47 | ~OThemePixmap(); | ||
48 | QPixmap* border( BorderType type ); | ||
49 | void setBorder( BorderType type, const QPixmap &p ); | ||
50 | void updateAccessed(); | ||
51 | bool isOld(); | ||
52 | protected: | ||
53 | QTime *t; | ||
54 | QPixmap *b[ 8 ]; | ||
55 | |||
56 | private: | ||
57 | class OThemePixmapPrivate; | ||
58 | OThemePixmapPrivate *d; | ||
59 | }; | ||
60 | |||
61 | inline QPixmap* OThemePixmap::border( BorderType type ) | ||
62 | { | ||
63 | return ( b[ type ] ); | ||
64 | } | ||
65 | |||
66 | inline void OThemePixmap::setBorder( BorderType type, const QPixmap &p ) | ||
67 | { | ||
68 | if ( b[ type ] ) { | ||
69 | qWarning( "OThemePixmap: Overwriting existing border!" ); | ||
70 | delete( b[ type ] ); | ||
71 | } | ||
72 | b[ type ] = new QPixmap( p ); | ||
73 | } | ||
74 | |||
75 | inline void OThemePixmap::updateAccessed() | ||
76 | { | ||
77 | if (t) | ||
78 | t->start(); | ||
79 | } | ||
80 | |||
81 | inline bool OThemePixmap::isOld() | ||
82 | { | ||
83 | return ( t ? t->elapsed() >= 300000 : false ); | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * A very simple pixmap cache for theme plugins. QPixmapCache is not used | ||
88 | * since it uses QString keys which are not needed. All the information we | ||
89 | * need can be encoded in a numeric key. Using QIntCache instead allows us to | ||
90 | * skip the string operations. | ||
91 | * | ||
92 | * This class is mostly just inline methods that do bit operations on a key | ||
93 | * composed of the widget ID, width and/or height, and then calls | ||
94 | * QIntCache::find(). | ||
95 | * | ||
96 | * One other thing to note is that full, horizontal, and vertically scaled | ||
97 | * pixmaps are not used interchangeably. For example, if you insert a fully | ||
98 | * scaled pixmap that is 32x32 then request a horizontally scaled pixmap with | ||
99 | * a width of 32, they will not match. This is because a pixmap that has been | ||
100 | * inserted into the cache has already been scaled at some point and it is | ||
101 | * very likely the vertical height was not originally 32. Thus the pixmap | ||
102 | * will be wrong when drawn, even though the horizontal width matches. | ||
103 | * | ||
104 | * @author Daniel M. Duley <mosfet@kde.org> | ||
105 | * | ||
106 | */ | ||
107 | class OThemeCache : public QObject | ||
108 | { | ||
109 | Q_OBJECT | ||
110 | public: | ||
111 | /** | ||
112 | * The scale hints supported by the cache. Note that Tiled is not here | ||
113 | * since tiled pixmaps are kept only once in OThemeBase. | ||
114 | */ | ||
115 | enum ScaleHint{FullScale, HorizontalScale, VerticalScale}; | ||
116 | /** | ||
117 | * The constructor. | ||
118 | * | ||
119 | * @param maxSize The maximum size of the cache in kilobytes. | ||
120 | */ | ||
121 | OThemeCache( int maxSize, QObject *parent = 0, const char *name = 0 ); | ||
122 | /** | ||
123 | * Inserts a new pixmap into the cache. | ||
124 | * | ||
125 | * @param pixmap The pixmap to insert. | ||
126 | * @param scale The scaling type of the pixmap. | ||
127 | * @param widgetID The widget ID of the pixmap, usually from OThemeBase's | ||
128 | * WidgetType enum. | ||
129 | * | ||
130 | * @return True if the insert was successful, false otherwise. | ||
131 | */ | ||
132 | bool insert( OThemePixmap *pixmap, ScaleHint scale, int widgetID, | ||
133 | bool border = false, bool mask = false ); | ||
134 | /** | ||
135 | * Returns a fully scaled pixmap. | ||
136 | * | ||
137 | * @param w The pixmap width to search for. | ||
138 | * @param h The pixmap height to search for. | ||
139 | * @param widgetID The widget ID to search for. | ||
140 | * | ||
141 | * @return True if a pixmap matching the width, height, and widget ID of | ||
142 | * the pixmap exists, NULL otherwise. | ||
143 | */ | ||
144 | OThemePixmap* pixmap( int w, int h, int widgetID, bool border = false, | ||
145 | bool mask = false ); | ||
146 | /** | ||
147 | * Returns a horizontally scaled pixmap. | ||
148 | * | ||
149 | * @param w The pixmap width to search for. | ||
150 | * @param widgetID The widget ID to search for. | ||
151 | * | ||
152 | * @return True if a pixmap matching the width and widget ID of | ||
153 | * the pixmap exists, NULL otherwise. | ||
154 | */ | ||
155 | OThemePixmap* horizontalPixmap( int w, int widgetID ); | ||
156 | /** | ||
157 | * Returns a vertically scaled pixmap. | ||
158 | * | ||
159 | * @param h The pixmap height to search for. | ||
160 | * @param widgetID The widget ID to search for. | ||
161 | * | ||
162 | * @return True if a pixmap matching the height and widget ID of | ||
163 | * the pixmap exists, NULL otherwise. | ||
164 | */ | ||
165 | OThemePixmap* verticalPixmap( int h, int widgetID ); | ||
166 | protected slots: | ||
167 | void flushTimeout(); | ||
168 | protected: | ||
169 | QIntCache<OThemePixmap> cache; | ||
170 | QTimer flushTimer; | ||
171 | |||
172 | private: | ||
173 | class OThemeCachePrivate; | ||
174 | OThemeCachePrivate *d; | ||
175 | }; | ||
176 | |||
177 | |||
178 | /** | ||
179 | * This is a base class for KDE themed styles. It implements a cache, | ||
180 | * configuration file parsing, pixmap scaling, gradients, and a lot | ||
181 | * of inline methods for accessing user specified parameters. | ||
182 | * | ||
183 | * Note that this class *does not* actually implement any themes. It just | ||
184 | * provides the groundwork for doing so. The only reason to use this class | ||
185 | * directly is if you plan to reimplement all of the widgets. Otherwise, | ||
186 | * refer to OThemeStyle for a fully themed style you can derive from. | ||
187 | * | ||
188 | * @author Daniel M. Duley <mosfet@kde.org> | ||
189 | */ | ||
190 | class OThemeBase: public QWindowsStyle | ||
191 | { | ||
192 | Q_OBJECT | ||
193 | public: | ||
194 | /** | ||
195 | * Constructs a new OThemeBase object. | ||
196 | */ | ||
197 | OThemeBase( const QString &configFile ); | ||
198 | ~OThemeBase(); | ||
199 | /** | ||
200 | * Describes if a pixmap should be scaled fully, horizontally, vertically, | ||
201 | * or not at all and tiled. | ||
202 | */ | ||
203 | enum ScaleHint{FullScale, HorizontalScale, VerticalScale, TileScale}; | ||
204 | /** | ||
205 | * The default arrow types. | ||
206 | */ | ||
207 | enum ArrowStyle{MotifArrow, LargeArrow, SmallArrow}; | ||
208 | /** | ||
209 | * The default frame shading styles. | ||
210 | */ | ||
211 | enum ShadeStyle{Motif, Windows, Next, KDE}; | ||
212 | /** | ||
213 | * The default scrollbar button layout. BottomLeft is like what Next | ||
214 | * uses, BottomRight is like Platinum, and Opposite it like Windows and | ||
215 | * Motif. | ||
216 | */ | ||
217 | enum SButton{SBBottomLeft, SBBottomRight, SBOpposite}; | ||
218 | /** | ||
219 | * The gradient types. Horizontal is left to right, Vertical is top to | ||
220 | * bottom, and diagonal is upper-left to bottom-right. | ||
221 | */ | ||
222 | enum Gradient{GrNone, GrHorizontal, GrVertical, GrDiagonal, GrPyramid, | ||
223 | GrRectangle, GrElliptic, GrReverseBevel}; | ||
224 | /** | ||
225 | * This provides a list of widget types that OThemeBase recognizes. | ||
226 | */ | ||
227 | /* Internal note: The order here is important. Some widgets inherit | ||
228 | * properties. This is usually for when you have two settings for the | ||
229 | * same widget, ie: on(sunken), and off. The on settings will inherit | ||
230 | * the properties of the off one when nothing is specified in the config. | ||
231 | * | ||
232 | * In order to be able to handle this while still having everything in | ||
233 | * one group that is easy to loop from we have the following order: | ||
234 | * unsunked(off) items, sunken(on)items, and then the ones that don't | ||
235 | * matter. INHERIT_ITEMS define the number of widgets that have inheritence | ||
236 | * so if 0 == PushButtonOff then INHERIT_ITEMS should == PushButtonOn | ||
237 | * and so on. WIDGETS define the total number of widgets. | ||
238 | */ | ||
239 | enum WidgetType{ | ||
240 | // Off (unsunken widgets) | ||
241 | PushButton = 0, ComboBox, HScrollBarSlider, VScrollBarSlider, Bevel, | ||
242 | ToolButton, ScrollButton, HScrollDeco, VScrollDeco, | ||
243 | ComboDeco, MenuItem, InactiveTab, ArrowUp, ArrowDown, ArrowLeft, | ||
244 | ArrowRight, | ||
245 | // On (sunken widgets) | ||
246 | PushButtonDown, ComboBoxDown, HScrollBarSliderDown, | ||
247 | VScrollBarSliderDown, BevelDown, ToolButtonDown, ScrollButtonDown, | ||
248 | HScrollDecoDown, VScrollDecoDown, ComboDecoDown, MenuItemDown, | ||
249 | ActiveTab, SunkenArrowUp, SunkenArrowDown, SunkenArrowLeft, | ||
250 | SunkenArrowRight, | ||
251 | // Everything else (indicators must have separate settings) | ||
252 | HScrollGroove, VScrollGroove, Slider, SliderGroove, IndicatorOn, | ||
253 | IndicatorOff, ExIndicatorOn, ExIndicatorOff, HBarHandle, VBarHandle, | ||
254 | ToolBar, Splitter, CheckMark, MenuBar, DisArrowUp, DisArrowDown, | ||
255 | DisArrowLeft, DisArrowRight, ProgressBar, ProgressBg, MenuBarItem, | ||
256 | Background}; | ||
257 | |||
258 | /** | ||
259 | * The scaling type specified by the Config file. | ||
260 | * | ||
261 | * @param widget A Widgets enum value. | ||
262 | * | ||
263 | * @return A ScaleHint enum value. | ||
264 | */ | ||
265 | ScaleHint scaleHint( WidgetType widget ) const; | ||
266 | /** | ||
267 | * The gradient type specified by the KConfig file. | ||
268 | * | ||
269 | * @param widget A Widgets enum value. | ||
270 | * | ||
271 | * @return A Gradient enum value. | ||
272 | */ | ||
273 | Gradient gradientHint( WidgetType widget ) const; | ||
274 | /** | ||
275 | * The color group specified for a given widget. | ||
276 | * If a color group is set in the theme configuration | ||
277 | * that is used, otherwise defaultColor is returned. | ||
278 | * | ||
279 | * @param defaultColor The colorGroup to set if one is available. | ||
280 | * | ||
281 | * @param widget The widget whose color group to retrieve. | ||
282 | * | ||
283 | */ | ||
284 | const QColorGroup* colorGroup( const QColorGroup &defaultGroup, | ||
285 | WidgetType widget ) const; | ||
286 | |||
287 | QBrush pixmapBrush( const QColorGroup &group, QColorGroup::ColorRole role, | ||
288 | int w, int h, WidgetType widget ); | ||
289 | /** | ||
290 | * True if the widget has a pixmap or gradient specified. | ||
291 | */ | ||
292 | bool isPixmap( WidgetType widget ) const; | ||
293 | /** | ||
294 | * True if the widget has a color group specified. | ||
295 | */ | ||
296 | bool isColor( WidgetType widget ) const; | ||
297 | /** | ||
298 | * True if the user specified a 3D focus rectangle | ||
299 | */ | ||
300 | bool is3DFocus() const; | ||
301 | /** | ||
302 | * If the user specified a 3D focus rectangle, they may also specify an | ||
303 | * offset from the default rectangle to use when drawing it. This returns | ||
304 | * the specified offset. | ||
305 | */ | ||
306 | int focusOffset() const; | ||
307 | /** | ||
308 | * The border width of the specified widget. | ||
309 | */ | ||
310 | int borderWidth( WidgetType widget ) const; | ||
311 | /** | ||
312 | * Pixmap border width of the specified widget. | ||
313 | */ | ||
314 | int pixBorderWidth( WidgetType widget ) const; | ||
315 | /** | ||
316 | * Returns the border pixmap if enabled for the specified widget. This | ||
317 | * will contain the originial pixmap, plus the edges separated in | ||
318 | * OThemePixmap::border() if valid. If invalid it will return NULL. | ||
319 | */ | ||
320 | OThemePixmap* borderPixmap( WidgetType widget ); | ||
321 | /** | ||
322 | * The highlight width of the specified widget. | ||
323 | */ | ||
324 | int highlightWidth( WidgetType widget ) const; | ||
325 | /** | ||
326 | * The border plus highlight width of the widget. | ||
327 | */ | ||
328 | int decoWidth( WidgetType widget ) const; | ||
329 | /** | ||
330 | * The extent (width for vertical, height for horizontal) requested | ||
331 | * for the scrollbars. | ||
332 | */ | ||
333 | int getSBExtent() const; | ||
334 | /** | ||
335 | * The scrollbar button layout. | ||
336 | */ | ||
337 | SButton scrollBarLayout() const; | ||
338 | /** | ||
339 | * The arrow type. | ||
340 | */ | ||
341 | ArrowStyle arrowType() const; | ||
342 | /** | ||
343 | * The shading type. | ||
344 | */ | ||
345 | ShadeStyle shade() const; | ||
346 | /** | ||
347 | * The frame width. | ||
348 | */ | ||
349 | int frameWidth() const; | ||
350 | /** | ||
351 | * The splitter width. | ||
352 | */ | ||
353 | int splitWidth() const; | ||
354 | /** | ||
355 | * The contrast for some bevel effects such as reverse gradient. | ||
356 | */ | ||
357 | int bevelContrast( WidgetType widget ) const; | ||
358 | /** | ||
359 | * The button text X shift. | ||
360 | */ | ||
361 | int buttonXShift() const; | ||
362 | /** | ||
363 | * The button text Y shift. | ||
364 | */ | ||
365 | int buttonYShift() const; | ||
366 | /** | ||
367 | * Returns either the slider length of the slider pixmap if available, | ||
368 | * otherwise the length specified in the config file. | ||
369 | */ | ||
370 | int sliderButtonLength() const; | ||
371 | /** | ||
372 | * True if rounded buttons are requested. | ||
373 | */ | ||
374 | bool roundButton() const; | ||
375 | /** | ||
376 | * True if rounded comboboxes are requested. | ||
377 | */ | ||
378 | bool roundComboBox() const; | ||
379 | /** | ||
380 | * True if rounded slider grooves are requested. | ||
381 | */ | ||
382 | bool roundSlider() const; | ||
383 | /** | ||
384 | * True if a line should be drawn on the bottom of active tabs. | ||
385 | */ | ||
386 | bool activeTabLine() const; | ||
387 | /** | ||
388 | * True if a line should be drawn on the bottom of inactive tabs. | ||
389 | */ | ||
390 | bool inactiveTabLine() const; | ||
391 | /** | ||
392 | * Returns the current uncached pixmap for the given widget. This will | ||
393 | * usually be either the last scaled or gradient pixmap if those have | ||
394 | * been specified in the config file, the original pixmap if not, or NULL | ||
395 | * if no pixmap has been specified. | ||
396 | */ | ||
397 | OThemePixmap* uncached( WidgetType widget ) const; | ||
398 | /** | ||
399 | * Returns the pixmap for the given widget at the specified width and | ||
400 | * height. This will return NULL if no pixmap or gradient is specified. | ||
401 | * It may also return a different sized pixmap if the scaling | ||
402 | * is set to Tiled. When using this method, you should call it using | ||
403 | * the needed width and height then use QPainter::drawTiledPixmap to | ||
404 | * paint it. Doing this, if the pixmap is scaled it will be the proper | ||
405 | * size, otherwise it will be tiled. | ||
406 | * | ||
407 | * @param w Requested width. | ||
408 | * @param h Requested height. | ||
409 | * @param widget Widget type. | ||
410 | * @return The pixmap or NULL if one is not specified. | ||
411 | */ | ||
412 | virtual OThemePixmap *scalePixmap( int w, int h, WidgetType widget ); | ||
413 | /** | ||
414 | * This method reads a configuration file and applies it to the user's | ||
415 | * kstylerc file. It does not signal applications to reload via the | ||
416 | * KDEChangeGeneral atom, if you want to do this you must do so yourself. | ||
417 | * See kcmdisplay's general.cpp for an example. | ||
418 | * | ||
419 | * @param file The configuration file to apply. | ||
420 | */ | ||
421 | static void applyConfigFile( const QString &file ); | ||
422 | protected: | ||
423 | /** | ||
424 | * Returns a QImage for the given widget if the widget is scaled, NULL | ||
425 | * otherwise. QImages of the original pixmap are stored for scaled | ||
426 | * widgets in order to facilitate fast and accurate smooth-scaling. This | ||
427 | * also saves us a conversion from a pixmap to an image then back again. | ||
428 | */ | ||
429 | QImage* image( WidgetType widget ) const; | ||
430 | /** | ||
431 | * Returns the gradient high color if one is specified, NULL otherwise. | ||
432 | */ | ||
433 | QColor* gradientHigh( WidgetType widget ) const; | ||
434 | /** | ||
435 | * Returns the gradient low color if one is specified, NULL otherwise. | ||
436 | */ | ||
437 | QColor* gradientLow( WidgetType widget ) const; | ||
438 | /** | ||
439 | * Reads in all the configuration file entries supported. | ||
440 | * | ||
441 | * @param colorStyle The style for the color groups. In KDE, colors were | ||
442 | * calculated a little differently for Motif vs Windows styles. This | ||
443 | * is obsolete. | ||
444 | */ | ||
445 | void readConfig( Qt::GUIStyle colorStyle = Qt::WindowsStyle ); | ||
446 | void readWidgetConfig( int i, Config *config, QString *pixnames, | ||
447 | QString *brdnames, bool *loadArray ); | ||
448 | void copyWidgetConfig( int sourceID, int destID, QString *pixnames, | ||
449 | QString *brdnames ); | ||
450 | /** | ||
451 | * Makes a full color group based on the given foreground and background | ||
452 | * colors. This is the same code used by KDE (kapp.cpp) in previous | ||
453 | * versions. | ||
454 | */ | ||
455 | QColorGroup* makeColorGroup( QColor &fg, QColor &bg, | ||
456 | Qt::GUIStyle style = Qt::WindowsStyle ); | ||
457 | OThemePixmap* scale( int w, int h, WidgetType widget ); | ||
458 | OThemePixmap* scaleBorder( int w, int h, WidgetType type ); | ||
459 | OThemePixmap* gradient( int w, int h, WidgetType widget ); | ||
460 | OThemePixmap* blend( WidgetType widget ); | ||
461 | void generateBorderPix( int i ); | ||
462 | void applyResourceGroup( Config *config, int i, QString *copyfrom, QString *pixnames, QString *brdnames ); | ||
463 | void applyMiscResourceGroup( Config *config ); | ||
464 | void readResourceGroup( int i, QString *copyfrom, QString *pixnames, QString *brdnames, | ||
465 | bool *loadArray ); | ||
466 | void readMiscResourceGroup(); | ||
467 | /** | ||
468 | * Attempts to load a pixmap from the default OThemeBase locations. | ||
469 | */ | ||
470 | OThemePixmap* loadPixmap( QString &name ); | ||
471 | /** | ||
472 | * Attempts to load a image from the default OThemeBase locations. | ||
473 | */ | ||
474 | QImage* loadImage( QString &name ); | ||
475 | private: | ||
476 | SButton sbPlacement; | ||
477 | ArrowStyle arrowStyle; | ||
478 | ShadeStyle shading; | ||
479 | int defaultFrame; | ||
480 | int btnXShift, btnYShift; | ||
481 | int sliderLen; | ||
482 | int splitterWidth; | ||
483 | int focus3DOffset; | ||
484 | int sbExtent; | ||
485 | bool smallGroove; | ||
486 | bool roundedButton, roundedCombo, roundedSlider; | ||
487 | bool aTabLine, iTabLine; | ||
488 | bool focus3D; | ||
489 | OThemeCache *cache; | ||
490 | int cacheSize; | ||
491 | QString configFileName; | ||
492 | QString configFilePath; | ||
493 | |||
494 | protected: | ||
495 | QColor fgcolor, bgcolor, selfgcolor, selbgcolor, winfgcolor, winbgcolor; | ||
496 | |||
497 | private: | ||
498 | /** | ||
499 | * The theme pixmaps. Many of these may be NULL if no pixmap is specified. | ||
500 | * There may also be duplicate pixmap pointers if more than one widget | ||
501 | * uses the same tiled pixmap. If a pixmap is tiled, it is kept here and | ||
502 | * this acts as a cache. Otherwise this will hold whatever the last scaled | ||
503 | * pixmap was. | ||
504 | */ | ||
505 | OThemePixmap *pixmaps[ WIDGETS ]; | ||
506 | /** | ||
507 | * The theme images. These are for scaled images and are kept in order | ||
508 | * to maintain fast smoothscaling. | ||
509 | */ | ||
510 | QImage *images[ WIDGETS ]; | ||
511 | /** | ||
512 | * The border widths | ||
513 | */ | ||
514 | unsigned char borders[ WIDGETS ]; | ||
515 | /** | ||
516 | * The highlight widths | ||
517 | */ | ||
518 | unsigned char highlights[ WIDGETS ]; | ||
519 | /** | ||
520 | * The scale hints for pixmaps and gradients. | ||
521 | */ | ||
522 | ScaleHint scaleHints[ WIDGETS ]; | ||
523 | /** | ||
524 | * All the color groups. | ||
525 | */ | ||
526 | QColorGroup *colors[ WIDGETS ]; | ||
527 | /** | ||
528 | * Gradient low colors (or blend background). | ||
529 | */ | ||
530 | QColor *grLowColors[ WIDGETS ]; | ||
531 | /** | ||
532 | * Gradient high colors. | ||
533 | */ | ||
534 | QColor *grHighColors[ WIDGETS ]; | ||
535 | /** | ||
536 | * Gradient types. | ||
537 | */ | ||
538 | Gradient gradients[ WIDGETS ]; | ||
539 | /** | ||
540 | * Blend intensity factors | ||
541 | */ | ||
542 | float blends[ WIDGETS ]; | ||
543 | /** | ||
544 | * Bevel contrasts | ||
545 | */ | ||
546 | unsigned char bContrasts[ WIDGETS ]; | ||
547 | /** | ||
548 | * Duplicate pixmap entries (used during destruction). | ||
549 | */ | ||
550 | bool duplicate[ WIDGETS ]; | ||
551 | /** | ||
552 | * Pixmapped border widths | ||
553 | */ | ||
554 | int pbWidth[ WIDGETS ]; | ||
555 | /** | ||
556 | * Pixmapped borders | ||
557 | */ | ||
558 | OThemePixmap *pbPixmaps[ WIDGETS ]; | ||
559 | /** | ||
560 | * Duplicate border pixmapped border entries | ||
561 | */ | ||
562 | bool pbDuplicate[ WIDGETS ]; | ||
563 | |||
564 | private: | ||
565 | class OThemeBasePrivate; | ||
566 | OThemeBasePrivate *d; | ||
567 | |||
568 | }; | ||
569 | |||
570 | inline bool OThemeBase::isPixmap( WidgetType widget ) const | ||
571 | { | ||
572 | return ( pixmaps[ widget ] != NULL || gradients[ widget ] != GrNone ); | ||
573 | } | ||
574 | |||
575 | inline bool OThemeBase::isColor( WidgetType widget ) const | ||
576 | { | ||
577 | return ( colors[ widget ] != NULL ); | ||
578 | } | ||
579 | |||
580 | inline bool OThemeBase::is3DFocus() const | ||
581 | { | ||
582 | return ( focus3D ); | ||
583 | } | ||
584 | |||
585 | inline int OThemeBase::focusOffset() const | ||
586 | { | ||
587 | return ( focus3DOffset ); | ||
588 | } | ||
589 | |||
590 | inline int OThemeBase::bevelContrast( WidgetType widget ) const | ||
591 | { | ||
592 | return ( bContrasts[ widget ] ); | ||
593 | } | ||
594 | |||
595 | inline OThemeBase::ScaleHint OThemeBase::scaleHint( WidgetType widget ) const | ||
596 | { | ||
597 | return ( ( widget < WIDGETS ) ? scaleHints[ widget ] : TileScale ); | ||
598 | } | ||
599 | |||
600 | inline OThemeBase::Gradient OThemeBase::gradientHint( WidgetType widget ) const | ||
601 | { | ||
602 | return ( ( widget < WIDGETS ) ? gradients[ widget ] : GrNone ); | ||
603 | } | ||
604 | |||
605 | inline OThemePixmap* OThemeBase::uncached( WidgetType widget ) const | ||
606 | { | ||
607 | return ( pixmaps[ widget ] ); | ||
608 | } | ||
609 | |||
610 | inline QBrush OThemeBase::pixmapBrush( const QColorGroup &group, | ||
611 | QColorGroup::ColorRole role, | ||
612 | int w, int h, WidgetType widget ) | ||
613 | { | ||
614 | if ( pixmaps[ widget ] || images[ widget ] ) | ||
615 | return ( QBrush( group.color( role ), *scalePixmap( w, h, widget ) ) ); | ||
616 | else | ||
617 | return ( group.color( role ) ); | ||
618 | } | ||
619 | |||
620 | inline const QColorGroup* OThemeBase::colorGroup( const QColorGroup &defaultGroup, | ||
621 | WidgetType widget ) const | ||
622 | { | ||
623 | return ( ( colors[ widget ] ) ? colors[ widget ] : &defaultGroup ); | ||
624 | } | ||
625 | |||
626 | inline int OThemeBase::borderWidth( WidgetType widget ) const | ||
627 | { | ||
628 | return ( pbWidth[ widget ] ? pbWidth[ widget ] : borders[ widget ] ); | ||
629 | } | ||
630 | |||
631 | inline int OThemeBase::pixBorderWidth( WidgetType widget ) const | ||
632 | { | ||
633 | return ( pbWidth[ widget ] ); | ||
634 | } | ||
635 | |||
636 | inline int OThemeBase::highlightWidth( WidgetType widget ) const | ||
637 | { | ||
638 | return ( pbWidth[ widget ] ? 0 : highlights[ widget ] ); | ||
639 | } | ||
640 | |||
641 | inline int OThemeBase::decoWidth( WidgetType widget ) const | ||
642 | { | ||
643 | return ( pbWidth[ widget ] ? pbWidth[ widget ] : borders[ widget ] + highlights[ widget ] ); | ||
644 | } | ||
645 | |||
646 | inline QColor* OThemeBase::gradientHigh( WidgetType widget ) const | ||
647 | { | ||
648 | return ( grHighColors[ widget ] ); | ||
649 | } | ||
650 | |||
651 | inline QColor* OThemeBase::gradientLow( WidgetType widget ) const | ||
652 | { | ||
653 | return ( grLowColors[ widget ] ); | ||
654 | } | ||
655 | |||
656 | inline QImage* OThemeBase::image( WidgetType widget ) const | ||
657 | { | ||
658 | return ( images[ widget ] ); | ||
659 | } | ||
660 | |||
661 | inline OThemeBase::SButton OThemeBase::scrollBarLayout() const | ||
662 | { | ||
663 | return ( sbPlacement ); | ||
664 | } | ||
665 | |||
666 | inline OThemeBase::ArrowStyle OThemeBase::arrowType() const | ||
667 | { | ||
668 | return ( arrowStyle ); | ||
669 | } | ||
670 | |||
671 | inline OThemeBase::ShadeStyle OThemeBase::shade() const | ||
672 | { | ||
673 | return ( shading ); | ||
674 | } | ||
675 | |||
676 | inline int OThemeBase::frameWidth() const | ||
677 | { | ||
678 | return ( defaultFrame ); | ||
679 | } | ||
680 | |||
681 | inline int OThemeBase::buttonXShift() const | ||
682 | { | ||
683 | return ( btnXShift ); | ||
684 | } | ||
685 | |||
686 | inline int OThemeBase::splitWidth() const | ||
687 | { | ||
688 | return ( splitterWidth ); | ||
689 | } | ||
690 | |||
691 | inline int OThemeBase::buttonYShift() const | ||
692 | { | ||
693 | return ( btnYShift ); | ||
694 | } | ||
695 | |||
696 | inline int OThemeBase::sliderButtonLength() const | ||
697 | { | ||
698 | if ( isPixmap( Slider ) ) | ||
699 | return ( uncached( Slider ) ->width() ); | ||
700 | else | ||
701 | return ( sliderLen ); | ||
702 | } | ||
703 | |||
704 | inline bool OThemeBase::roundButton() const | ||
705 | { | ||
706 | return ( roundedButton ); | ||
707 | } | ||
708 | |||
709 | inline bool OThemeBase::roundComboBox() const | ||
710 | { | ||
711 | return ( roundedCombo ); | ||
712 | } | ||
713 | |||
714 | inline bool OThemeBase::roundSlider() const | ||
715 | { | ||
716 | return ( roundedSlider ); | ||
717 | } | ||
718 | |||
719 | inline bool OThemeBase::activeTabLine() const | ||
720 | { | ||
721 | return ( aTabLine ); | ||
722 | } | ||
723 | |||
724 | inline bool OThemeBase::inactiveTabLine() const | ||
725 | { | ||
726 | return ( iTabLine ); | ||
727 | } | ||
728 | |||
729 | inline int OThemeBase::getSBExtent() const | ||
730 | { | ||
731 | return ( sbExtent ); | ||
732 | } | ||
733 | |||
734 | inline OThemePixmap* OThemeBase::borderPixmap( WidgetType widget ) | ||
735 | { | ||
736 | return ( pbPixmaps[ widget ] ); | ||
737 | } | ||
738 | |||
739 | #endif | ||