TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kthemestyle.h 9.9KB

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