summaryrefslogtreecommitdiff
authorleseb <leseb>2002-07-02 21:23:40 (UTC)
committer leseb <leseb>2002-07-02 21:23:40 (UTC)
commitd83f58a1a4a314a3ef8b25dd78432488922a9e31 (patch) (unidiff)
tree353b815ff13bb34594fa8db4d15233ed6b8c27e4
parent2481ac4013794f95c53580f99b4b761142e4ee8f (diff)
downloadopie-d83f58a1a4a314a3ef8b25dd78432488922a9e31.zip
opie-d83f58a1a4a314a3ef8b25dd78432488922a9e31.tar.gz
opie-d83f58a1a4a314a3ef8b25dd78432488922a9e31.tar.bz2
Fix QToolButton drawing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/theme/othemestyle.cpp8
-rw-r--r--noncore/styles/theme/othemestyle.h6
2 files changed, 14 insertions, 0 deletions
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp
index 61127b8..d97b026 100644
--- a/noncore/styles/theme/othemestyle.cpp
+++ b/noncore/styles/theme/othemestyle.cpp
@@ -264,96 +264,104 @@ void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h,
264 p->setPen( color1 ); 264 p->setPen( color1 );
265 if ( round && w > 19 && h > 19 ) { 265 if ( round && w > 19 && h > 19 ) {
266 int x2 = x + w - 1; 266 int x2 = x + w - 1;
267 int y2 = y + h - 1; 267 int y2 = y + h - 1;
268 QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill ); 268 QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill );
269 a.translate( 1, 1 ); 269 a.translate( 1, 1 );
270 p->drawPoints( a ); 270 p->drawPoints( a );
271 a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill ); 271 a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill );
272 a.translate( 1, h - 6 ); 272 a.translate( 1, h - 6 );
273 p->drawPoints( a ); 273 p->drawPoints( a );
274 a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill ); 274 a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill );
275 a.translate( w - 6, 1 ); 275 a.translate( w - 6, 1 );
276 p->drawPoints( a ); 276 p->drawPoints( a );
277 a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill ); 277 a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill );
278 a.translate( w - 6, h - 6 ); 278 a.translate( w - 6, h - 6 );
279 p->drawPoints( a ); 279 p->drawPoints( a );
280 280
281 p->fillRect( x + 6, y, w - 12, h, fillBrush ); 281 p->fillRect( x + 6, y, w - 12, h, fillBrush );
282 p->fillRect( x, y + 6, x + 6, h - 12, fillBrush ); 282 p->fillRect( x, y + 6, x + 6, h - 12, fillBrush );
283 p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush ); 283 p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush );
284 p->drawLine( x + 6, y, x2 - 6, y ); 284 p->drawLine( x + 6, y, x2 - 6, y );
285 p->drawLine( x + 6, y2, x2 - 6, y2 ); 285 p->drawLine( x + 6, y2, x2 - 6, y2 );
286 p->drawLine( x, y + 6, x, y2 - 6 ); 286 p->drawLine( x, y + 6, x, y2 - 6 );
287 p->drawLine( x2, y + 6, x2, y2 - 6 ); 287 p->drawLine( x2, y + 6, x2, y2 - 6 );
288 288
289 } 289 }
290 else 290 else
291 p->fillRect( x, y, w, h, fillBrush ); 291 p->fillRect( x, y, w, h, fillBrush );
292} 292}
293 293
294void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h ) 294void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h )
295{ 295{
296 drawBaseMask( p, x, y, w, h, roundButton() ); 296 drawBaseMask( p, x, y, w, h, roundButton() );
297} 297}
298 298
299void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h ) 299void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h )
300{ 300{
301 drawBaseMask( p, x, y, w, h, roundComboBox() ); 301 drawBaseMask( p, x, y, w, h, roundComboBox() );
302} 302}
303 303
304void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, 304void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
305 const QColorGroup &g, bool sunken, 305 const QColorGroup &g, bool sunken,
306 const QBrush * ) 306 const QBrush * )
307{ 307{
308 WidgetType type = sunken ? BevelDown : Bevel; 308 WidgetType type = sunken ? BevelDown : Bevel;
309 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); 309 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type );
310} 310}
311 311
312void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h,
313 const QColorGroup &g, bool sunken,
314 const QBrush * )
315{
316 WidgetType type = sunken ? ToolButtonDown : ToolButton;
317 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type );
318}
319
312#if 0 320#if 0
313void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h, 321void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h,
314 const QColorGroup &g, bool sunken, 322 const QColorGroup &g, bool sunken,
315 bool raised, bool enabled, bool popup, 323 bool raised, bool enabled, bool popup,
316 KToolButtonType type, const QString &btext, 324 KToolButtonType type, const QString &btext,
317 const QPixmap *pixmap, QFont *font, 325 const QPixmap *pixmap, QFont *font,
318 QWidget * ) 326 QWidget * )
319{ 327{
320 QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 ); 328 QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 );
321 if ( font ) 329 if ( font )
322 tmp_font = *font; 330 tmp_font = *font;
323 QFontMetrics fm( tmp_font ); 331 QFontMetrics fm( tmp_font );
324 WidgetType widget = sunken ? ToolButtonDown : ToolButton; 332 WidgetType widget = sunken ? ToolButtonDown : ToolButton;
325 333
326 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false, 334 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false,
327 widget ); 335 widget );
328 int dx, dy; 336 int dx, dy;
329 if ( type == Icon ) { // icon only 337 if ( type == Icon ) { // icon only
330 if ( pixmap ) { 338 if ( pixmap ) {
331 dx = ( w - pixmap->width() ) / 2; 339 dx = ( w - pixmap->width() ) / 2;
332 dy = ( h - pixmap->height() ) / 2; 340 dy = ( h - pixmap->height() ) / 2;
333 if ( sunken ) { 341 if ( sunken ) {
334 ++dx; 342 ++dx;
335 ++dy; 343 ++dy;
336 } 344 }
337 p->drawPixmap( x + dx, y + dy, *pixmap ); 345 p->drawPixmap( x + dx, y + dy, *pixmap );
338 } 346 }
339 } 347 }
340 else if ( type == IconTextRight ) { // icon and text (if any) 348 else if ( type == IconTextRight ) { // icon and text (if any)
341 if ( pixmap ) { 349 if ( pixmap ) {
342 dx = 4; 350 dx = 4;
343 dy = ( h - pixmap->height() ) / 2; 351 dy = ( h - pixmap->height() ) / 2;
344 if ( sunken ) { 352 if ( sunken ) {
345 ++dx; 353 ++dx;
346 ++dy; 354 ++dy;
347 } 355 }
348 p->drawPixmap( x + dx, y + dy, *pixmap ); 356 p->drawPixmap( x + dx, y + dy, *pixmap );
349 } 357 }
350 if ( !btext.isNull() ) { 358 if ( !btext.isNull() ) {
351 int tf = AlignVCenter | AlignLeft; 359 int tf = AlignVCenter | AlignLeft;
352 if ( pixmap ) 360 if ( pixmap )
353 dx = 4 + pixmap->width() + 2; 361 dx = 4 + pixmap->width() + 2;
354 else 362 else
355 dx = 4; 363 dx = 4;
356 dy = 0; 364 dy = 0;
357 if ( sunken ) { 365 if ( sunken ) {
358 ++dx; 366 ++dx;
359 ++dy; 367 ++dy;
diff --git a/noncore/styles/theme/othemestyle.h b/noncore/styles/theme/othemestyle.h
index 02bec78..52445c4 100644
--- a/noncore/styles/theme/othemestyle.h
+++ b/noncore/styles/theme/othemestyle.h
@@ -64,96 +64,102 @@ public:
64 virtual void polish( QPalette& pal ); 64 virtual void polish( QPalette& pal );
65 65
66 /** 66 /**
67 * This is a convenience method for drawing widgets with 67 * This is a convenience method for drawing widgets with
68 * borders, highlights, pixmaps, colors, etc... 68 * borders, highlights, pixmaps, colors, etc...
69 * You specify the widget type and it will draw it according to the 69 * You specify the widget type and it will draw it according to the
70 * config file settings. 70 * config file settings.
71 * 71 *
72 * @param p The QPainter to draw on. 72 * @param p The QPainter to draw on.
73 * @param g The color group to use. 73 * @param g The color group to use.
74 * @param rounded @p true if the widget is rounded, @p false if rectangular. 74 * @param rounded @p true if the widget is rounded, @p false if rectangular.
75 * @param type The widget type to paint. 75 * @param type The widget type to paint.
76 * @param fill An optional fill brush. Currently ignored (the config file 76 * @param fill An optional fill brush. Currently ignored (the config file
77 * is used instead). 77 * is used instead).
78 */ 78 */
79 virtual void drawBaseButton( QPainter *p, int x, int y, int w, int h, 79 virtual void drawBaseButton( QPainter *p, int x, int y, int w, int h,
80 const QColorGroup &g, bool sunken = FALSE, 80 const QColorGroup &g, bool sunken = FALSE,
81 bool rounded = FALSE, WidgetType type = Bevel, 81 bool rounded = FALSE, WidgetType type = Bevel,
82 const QBrush *fill = 0 ); 82 const QBrush *fill = 0 );
83 /** 83 /**
84 * Draw a mask with for widgets that may be rounded. 84 * Draw a mask with for widgets that may be rounded.
85 * 85 *
86 *Currently used 86 *Currently used
87 * by pushbuttons and comboboxes. 87 * by pushbuttons and comboboxes.
88 * 88 *
89 * @param p The QPainter to draw on. 89 * @param p The QPainter to draw on.
90 * @param rounded @p true if the widget is rounded, @p false if rectangular. 90 * @param rounded @p true if the widget is rounded, @p false if rectangular.
91 */ 91 */
92 virtual void drawBaseMask( QPainter *p, int x, int y, int w, int h, 92 virtual void drawBaseMask( QPainter *p, int x, int y, int w, int h,
93 bool rounded ); 93 bool rounded );
94 /** 94 /**
95 * Draw a pushbutton. 95 * Draw a pushbutton.
96 * 96 *
97 * This calls @ref drawBaseButton() with @p PushButton as the 97 * This calls @ref drawBaseButton() with @p PushButton as the
98 * widget type. 98 * widget type.
99 */ 99 */
100 virtual void drawButton( QPainter *p, int x, int y, int w, int h, 100 virtual void drawButton( QPainter *p, int x, int y, int w, int h,
101 const QColorGroup &g, bool sunken = FALSE, 101 const QColorGroup &g, bool sunken = FALSE,
102 const QBrush *fill = 0 ); 102 const QBrush *fill = 0 );
103 /** 103 /**
104 * Draw a bevel button. 104 * Draw a bevel button.
105 * 105 *
106 * This calls @ref drawBaseButton() with Bevel as the 106 * This calls @ref drawBaseButton() with Bevel as the
107 * widget type. 107 * widget type.
108 */ 108 */
109 virtual void drawBevelButton( QPainter *p, int x, int y, int w, int h, 109 virtual void drawBevelButton( QPainter *p, int x, int y, int w, int h,
110 const QColorGroup &g, bool sunken = FALSE, 110 const QColorGroup &g, bool sunken = FALSE,
111 const QBrush *fill = 0 ); 111 const QBrush *fill = 0 );
112 /**
113 * Draw a toolbar button.
114 */
115 virtual void drawToolButton ( QPainter *p, int x, int y, int w, int h,
116 const QColorGroup &g, bool sunken = FALSE,
117 const QBrush *fill = 0 );
112#if 0 118#if 0
113 /** 119 /**
114 * Draw a toolbar button. 120 * Draw a toolbar button.
115 */ 121 */
116 virtual void drawKToolBarButton( QPainter *p, int x, int y, int w, int h, 122 virtual void drawKToolBarButton( QPainter *p, int x, int y, int w, int h,
117 const QColorGroup &g, bool sunken = false, 123 const QColorGroup &g, bool sunken = false,
118 bool raised = true, bool enabled = true, 124 bool raised = true, bool enabled = true,
119 bool popup = false, KToolButtonType type = Icon, 125 bool popup = false, KToolButtonType type = Icon,
120 const QString &btext = QString::null, 126 const QString &btext = QString::null,
121 const QPixmap *icon = NULL, 127 const QPixmap *icon = NULL,
122 QFont *font = NULL, QWidget *btn = NULL ); 128 QFont *font = NULL, QWidget *btn = NULL );
123 /** 129 /**
124 * Draw the handle used in toolbars. 130 * Draw the handle used in toolbars.
125 */ 131 */
126 void drawKBarHandle( QPainter *p, int x, int y, int w, int h, 132 void drawKBarHandle( QPainter *p, int x, int y, int w, int h,
127 const QColorGroup &g, 133 const QColorGroup &g,
128 KToolBarPos type, QBrush *fill = NULL ); 134 KToolBarPos type, QBrush *fill = NULL );
129 135
130 /** 136 /**
131 * Draw a toolbar. 137 * Draw a toolbar.
132 */ 138 */
133 void drawKToolBar( QPainter *p, int x, int y, int w, int h, 139 void drawKToolBar( QPainter *p, int x, int y, int w, int h,
134 const QColorGroup &g, KToolBarPos type, 140 const QColorGroup &g, KToolBarPos type,
135 QBrush *fill = NULL ); 141 QBrush *fill = NULL );
136#endif 142#endif
137 /** 143 /**
138 * Return the space available in a pushbutton, taking configurable 144 * Return the space available in a pushbutton, taking configurable
139 * borders and highlights into account. 145 * borders and highlights into account.
140 */ 146 */
141 virtual QRect buttonRect( int x, int y, int w, int h ); 147 virtual QRect buttonRect( int x, int y, int w, int h );
142 /** 148 /**
143 * Draw an arrow in the style specified by the config file. 149 * Draw an arrow in the style specified by the config file.
144 */ 150 */
145 virtual void drawArrow( QPainter *p, Qt::ArrowType type, bool down, 151 virtual void drawArrow( QPainter *p, Qt::ArrowType type, bool down,
146 int x, int y, int w, int h, const QColorGroup &g, 152 int x, int y, int w, int h, const QColorGroup &g,
147 bool enabled = true, const QBrush *fill = 0 ); 153 bool enabled = true, const QBrush *fill = 0 );
148 /** 154 /**
149 * Return the size of the exclusive indicator pixmap if one is specified 155 * 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. 156 * in the config file, otherwise it uses the base style's size.
151 */ 157 */
152 virtual QSize exclusiveIndicatorSize() const; 158 virtual QSize exclusiveIndicatorSize() const;
153 /** 159 /**
154 * Draw an exclusive indicator widget. 160 * Draw an exclusive indicator widget.
155 * 161 *
156 * If a pixmap is specified in the 162 * If a pixmap is specified in the
157 * config file that is used, otherwise the base style's widget is drawn. 163 * config file that is used, otherwise the base style's widget is drawn.
158 */ 164 */
159 virtual void drawExclusiveIndicator( QPainter* p, int x, int y, int w, 165 virtual void drawExclusiveIndicator( QPainter* p, int x, int y, int w,