Diffstat (limited to 'noncore/styles/flat/flat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/styles/flat/flat.cpp | 128 |
1 files changed, 99 insertions, 29 deletions
diff --git a/noncore/styles/flat/flat.cpp b/noncore/styles/flat/flat.cpp index b6635c5..24366f6 100644 --- a/noncore/styles/flat/flat.cpp +++ b/noncore/styles/flat/flat.cpp | |||
@@ -1,381 +1,443 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "flat.h" | 21 | #include <qtopia/qpeapplication.h> |
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
24 | #include <qtoolbutton.h> | 23 | #include <qtoolbutton.h> |
25 | #include <qpainter.h> | 24 | #include <qpainter.h> |
26 | #include <qfontmetrics.h> | 25 | #include <qfontmetrics.h> |
27 | #include <qpalette.h> | 26 | #include <qpalette.h> |
28 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
29 | #include <qscrollbar.h> | 28 | #include <qscrollbar.h> |
30 | #include <qbutton.h> | 29 | #include <qbutton.h> |
31 | #include <qframe.h> | 30 | #include <qframe.h> |
32 | #include <qtabbar.h> | 31 | #include <qtabbar.h> |
33 | #include <qspinbox.h> | 32 | #include <qspinbox.h> |
34 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qmap.h> | ||
35 | 35 | ||
36 | #define INCLUDE_MENUITEM_DEF | 36 | #define INCLUDE_MENUITEM_DEF |
37 | #include <qmenudata.h> | 37 | #include <qmenudata.h> |
38 | #include <qpopupmenu.h> | ||
39 | |||
40 | #include "flat.h" | ||
38 | 41 | ||
39 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 42 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
40 | 43 | ||
41 | class SpinBoxHack : public QSpinBox | 44 | class SpinBoxHack : public QSpinBox |
42 | { | 45 | { |
43 | public: | 46 | public: |
44 | void setFlatButtons( bool f ) { | 47 | void setFlatButtons( bool f ) { |
45 | upButton()->setFlat( f ); | 48 | upButton()->setFlat( f ); |
46 | downButton()->setFlat( f ); | 49 | downButton()->setFlat( f ); |
47 | } | 50 | } |
48 | }; | 51 | }; |
49 | 52 | ||
50 | class FlatStylePrivate : public QObject | 53 | class FlatStylePrivate : public QObject |
51 | { | 54 | { |
52 | Q_OBJECT | 55 | Q_OBJECT |
53 | public: | 56 | public: |
54 | FlatStylePrivate() : QObject() {} | 57 | FlatStylePrivate() : QObject() {} |
55 | 58 | ||
56 | bool eventFilter( QObject *o, QEvent *e ) { | 59 | bool eventFilter( QObject *o, QEvent *e ) { |
57 | if ( e->type() == QEvent::ParentPaletteChange && o->inherits( "QMenuBar" ) ) { | 60 | if ( e->type() == QEvent::ParentPaletteChange ) { |
58 | QWidget *w = (QWidget *)o; | 61 | if ( o->inherits( "QMenuBar" ) ) { |
59 | if ( w->parentWidget() ) { | 62 | QWidget *w = (QWidget *)o; |
60 | QPalette p = w->parentWidget()->palette(); | 63 | if ( w->parentWidget() ) { |
61 | QColorGroup a = p.active(); | 64 | QPalette p = w->parentWidget()->palette(); |
62 | a.setColor( QColorGroup::Light, a.foreground() ); | 65 | QColorGroup a = p.active(); |
63 | a.setColor( QColorGroup::Dark, a.foreground() ); | 66 | a.setColor( QColorGroup::Light, a.foreground() ); |
64 | p.setActive( a ); | 67 | a.setColor( QColorGroup::Dark, a.foreground() ); |
65 | p.setInactive( a ); | 68 | p.setActive( a ); |
66 | w->setPalette( p ); | 69 | p.setInactive( a ); |
70 | w->setPalette( p ); | ||
71 | } | ||
72 | } else if ( o->inherits( "QHeader" ) ) { | ||
73 | QWidget *w = (QWidget *)o; | ||
74 | if ( w->parentWidget() ) { | ||
75 | QPalette p = w->parentWidget()->palette(); | ||
76 | QColorGroup a = p.active(); | ||
77 | a.setColor( QColorGroup::Light, a.button() ); | ||
78 | p.setActive( a ); | ||
79 | p.setInactive( a ); | ||
80 | w->setPalette( p ); | ||
81 | } | ||
67 | } | 82 | } |
68 | } | 83 | } |
69 | return FALSE; | 84 | return FALSE; |
70 | } | 85 | } |
86 | |||
87 | QMap<QFrame *,int> frameStyles; | ||
71 | }; | 88 | }; |
72 | 89 | ||
73 | FlatStyle::FlatStyle() : revItem(FALSE) | 90 | FlatStyle::FlatStyle() : revItem(FALSE), fillBtnBorder(FALSE) |
74 | { | 91 | { |
75 | setButtonMargin(3); | 92 | setButtonMargin(3); |
76 | setScrollBarExtent(13,13); | 93 | setScrollBarExtent(13,13); |
77 | setButtonDefaultIndicatorWidth(0); | 94 | setButtonDefaultIndicatorWidth(0); |
78 | d = new FlatStylePrivate; | 95 | d = new FlatStylePrivate; |
79 | } | 96 | } |
80 | 97 | ||
81 | FlatStyle::~FlatStyle() | 98 | FlatStyle::~FlatStyle() |
82 | { | 99 | { |
83 | delete d; | 100 | delete d; |
84 | } | 101 | } |
85 | 102 | ||
86 | int FlatStyle::buttonMargin() const | 103 | int FlatStyle::buttonMargin() const |
87 | { | 104 | { |
88 | return 3; | 105 | return 3; |
89 | } | 106 | } |
90 | 107 | ||
91 | QSize FlatStyle::scrollBarExtent() const | 108 | QSize FlatStyle::scrollBarExtent() const |
92 | { | 109 | { |
93 | return QSize(13,13); | 110 | return QSize(13,13); |
94 | } | 111 | } |
95 | 112 | ||
96 | void FlatStyle::polish ( QPalette & ) | 113 | void FlatStyle::polish ( QPalette & ) |
97 | { | 114 | { |
98 | } | 115 | } |
99 | 116 | ||
100 | void FlatStyle::polish( QWidget *w ) | 117 | void FlatStyle::polish( QWidget *w ) |
101 | { | 118 | { |
102 | if ( w->inherits( "QFrame" ) ) { | 119 | if ( w->inherits( "QFrame" ) ) { |
103 | QFrame *f = (QFrame *)w; | 120 | QFrame *f = (QFrame *)w; |
104 | if ( f->frameShape() != QFrame::NoFrame ) | 121 | if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) |
122 | f->setFrameShadow( QFrame::Plain ); | ||
123 | else if ( f->frameShape() != QFrame::NoFrame ) | ||
105 | f->setFrameShape( QFrame::StyledPanel ); | 124 | f->setFrameShape( QFrame::StyledPanel ); |
106 | f->setLineWidth( 1 ); | 125 | f->setLineWidth( 1 ); |
107 | } | 126 | } |
108 | if ( w->inherits( "QSpinBox" ) ) | 127 | if ( w->inherits( "QSpinBox" ) ) |
109 | ((SpinBoxHack*)w)->setFlatButtons( TRUE ); | 128 | ((SpinBoxHack*)w)->setFlatButtons( TRUE ); |
110 | if ( w->inherits( "QMenuBar" ) ) { | 129 | if ( w->inherits( "QMenuBar" ) ) { |
111 | // make selected item look flat | 130 | // make selected item look flat |
112 | QPalette p = w->palette(); | 131 | QPalette p = w->palette(); |
113 | QColorGroup a = p.active(); | 132 | QColorGroup a = p.active(); |
114 | a.setColor( QColorGroup::Light, a.foreground() ); | 133 | a.setColor( QColorGroup::Light, a.foreground() ); |
115 | a.setColor( QColorGroup::Dark, a.foreground() ); | 134 | a.setColor( QColorGroup::Dark, a.foreground() ); |
116 | p.setActive( a ); | 135 | p.setActive( a ); |
117 | p.setInactive( a ); | 136 | p.setInactive( a ); |
118 | w->setPalette( p ); | 137 | w->setPalette( p ); |
119 | w->installEventFilter( d ); | 138 | w->installEventFilter( d ); |
139 | } else if ( w->inherits( "QHeader" ) ) { | ||
140 | // make headers look flat | ||
141 | QPalette p = w->palette(); | ||
142 | QColorGroup a = p.active(); | ||
143 | a.setColor( QColorGroup::Light, a.button() ); | ||
144 | p.setActive( a ); | ||
145 | p.setInactive( a ); | ||
146 | w->setPalette( p ); | ||
147 | w->installEventFilter( d ); | ||
120 | } | 148 | } |
121 | } | 149 | } |
122 | 150 | ||
123 | void FlatStyle::unPolish( QWidget *w ) | 151 | void FlatStyle::unPolish( QWidget *w ) |
124 | { | 152 | { |
125 | if ( w->inherits( "QFrame" ) ) { | 153 | if ( w->inherits("QFrame") ) { |
126 | QFrame *f = (QFrame *)w; | 154 | QFrame *f = (QFrame *)w; |
127 | if ( f->frameShape() != QFrame::NoFrame ) | 155 | if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) { |
156 | f->setFrameShadow( QFrame::Sunken ); | ||
157 | } else if ( f->frameShape() != QFrame::NoFrame ) { | ||
128 | f->setFrameShape( QFrame::StyledPanel ); | 158 | f->setFrameShape( QFrame::StyledPanel ); |
129 | f->setLineWidth( 2 ); | 159 | f->setLineWidth( 2 ); |
160 | } | ||
130 | } | 161 | } |
131 | if ( w->inherits( "QSpinBox" ) ) | 162 | if ( w->inherits("QSpinBox") ) |
132 | ((SpinBoxHack*)w)->setFlatButtons( FALSE ); | 163 | ((SpinBoxHack*)w)->setFlatButtons( FALSE ); |
133 | if ( w->inherits( "QMenuBar" ) ) { | 164 | if ( w->inherits("QMenuBar") || w->inherits("QHeader") ) { |
134 | w->unsetPalette(); | 165 | w->unsetPalette(); |
135 | w->removeEventFilter( d ); | 166 | w->removeEventFilter( d ); |
136 | } | 167 | } |
137 | } | 168 | } |
138 | 169 | ||
139 | int FlatStyle::defaultFrameWidth() const | 170 | int FlatStyle::defaultFrameWidth() const |
140 | { | 171 | { |
141 | return 1; | 172 | return 2; |
142 | } | 173 | } |
143 | 174 | ||
144 | void FlatStyle::drawItem( QPainter *p, int x, int y, int w, int h, | 175 | void FlatStyle::drawItem( QPainter *p, int x, int y, int w, int h, |
145 | int flags, const QColorGroup &g, bool enabled, | 176 | int flags, const QColorGroup &g, bool enabled, |
146 | const QPixmap *pixmap, const QString& text, int len, | 177 | const QPixmap *pixmap, const QString& text, int len, |
147 | const QColor* penColor ) | 178 | const QColor* penColor ) |
148 | { | 179 | { |
149 | QColor pc( penColor ? *penColor : g.foreground() ); | 180 | QColor pc( penColor ? *penColor : g.foreground() ); |
150 | QColorGroup cg( g ); | 181 | QColorGroup cg( g ); |
151 | if ( !enabled ) | 182 | if ( !enabled ) |
152 | cg.setColor( QColorGroup::Light, cg.background() ); | 183 | cg.setColor( QColorGroup::Light, cg.background() ); |
153 | if ( revItem ) { | 184 | if ( revItem ) { |
154 | pc = cg.button(); | 185 | pc = cg.button(); |
155 | revItem = FALSE; | 186 | revItem = FALSE; |
156 | } | 187 | } |
157 | QWindowsStyle::drawItem( p, x, y, w, h, flags, cg, enabled, pixmap, text, len, &pc ); | 188 | QWindowsStyle::drawItem( p, x, y, w, h, flags, cg, enabled, pixmap, text, len, &pc ); |
158 | } | 189 | } |
159 | 190 | ||
160 | void FlatStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, | 191 | void FlatStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, |
161 | const QColorGroup &g, bool /*sunken*/, int lineWidth, const QBrush * fill ) | 192 | const QColorGroup &g, bool /*sunken*/, int lineWidth, const QBrush * fill ) |
162 | { | 193 | { |
163 | if ( fill ) | 194 | if ( fill ) |
164 | p->setBrush( *fill ); | 195 | p->setBrush( *fill ); |
165 | p->setPen( QPen(g.foreground(), lineWidth) ); | 196 | p->setPen( QPen(g.foreground(), lineWidth) ); |
166 | p->drawRect( x, y, w, h ); | 197 | p->drawRect( x, y, w, h ); |
167 | } | 198 | } |
168 | 199 | ||
169 | void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h, | 200 | void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h, |
170 | const QColorGroup &cg, bool /*sunken*/, const QBrush* fill ) | 201 | const QColorGroup &cg, bool /*sunken*/, const QBrush* fill ) |
171 | { | 202 | { |
172 | QPen oldPen = p->pen(); | 203 | QPen oldPen = p->pen(); |
173 | 204 | ||
205 | int x2 = x+w-1; | ||
206 | int y2 = y+h-1; | ||
207 | |||
208 | if ( fillBtnBorder && btnBg != cg.color(QColorGroup::Button) ) { | ||
209 | p->setPen( btnBg ); | ||
210 | p->drawLine( x, y, x2, y ); | ||
211 | p->drawLine( x, y2, x2, y2 ); | ||
212 | p->drawLine( x, y+1, x, y2-1 ); | ||
213 | p->drawLine( x2, y+1, x2, y2-1 ); | ||
214 | p->fillRect( x+1, y+1, 3, 3, btnBg ); | ||
215 | p->fillRect( x+1, y2-3, 3, 3, btnBg ); | ||
216 | p->fillRect( x2-3, y2-3, 3, 3, btnBg ); | ||
217 | p->fillRect( x2-3, y+1, 3, 3, btnBg ); | ||
218 | p->fillRect( x+2, y+2, w-4, h-4, fill?(*fill):cg.brush(QColorGroup::Button) ); | ||
219 | } else { | ||
220 | p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) ); | ||
221 | } | ||
222 | |||
174 | if ( h >= 10 ) { | 223 | if ( h >= 10 ) { |
175 | x++; y++; | 224 | x++; y++; |
225 | x2--; y2--; | ||
176 | w -= 2; h -= 2; | 226 | w -= 2; h -= 2; |
177 | } | 227 | } |
178 | 228 | ||
179 | p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) ); | ||
180 | |||
181 | int x2 = x+w-1; | ||
182 | int y2 = y+h-1; | ||
183 | |||
184 | p->setPen( cg.foreground() ); | 229 | p->setPen( cg.foreground() ); |
185 | 230 | ||
186 | if ( h < 10 ) { | 231 | if ( h < 10 ) { |
187 | p->setBrush( NoBrush ); | 232 | p->setBrush( NoBrush ); |
188 | p->drawRect( x, y, w, h ); | 233 | p->drawRect( x, y, w, h ); |
189 | } else { | 234 | } else { |
190 | p->drawLine( x+3, y, x2-3, y ); | 235 | p->drawLine( x+3, y, x2-3, y ); |
191 | p->drawLine( x+3, y2, x2-3, y2 ); | 236 | p->drawLine( x+3, y2, x2-3, y2 ); |
192 | p->drawLine( x, y+3, x, y2-3 ); | 237 | p->drawLine( x, y+3, x, y2-3 ); |
193 | p->drawLine( x2, y+3, x2, y2-3 ); | 238 | p->drawLine( x2, y+3, x2, y2-3 ); |
194 | 239 | ||
195 | p->drawLine( x+1, y+1, x+2, y+1 ); | 240 | p->drawLine( x+1, y+1, x+2, y+1 ); |
196 | p->drawPoint( x+1, y+2 ); | 241 | p->drawPoint( x+1, y+2 ); |
197 | p->drawLine( x2-2, y+1, x2-1, y+1 ); | 242 | p->drawLine( x2-2, y+1, x2-1, y+1 ); |
198 | p->drawPoint( x2-1, y+2 ); | 243 | p->drawPoint( x2-1, y+2 ); |
199 | 244 | ||
200 | p->drawLine( x+1, y2-1, x+2, y2-1 ); | 245 | p->drawLine( x+1, y2-1, x+2, y2-1 ); |
201 | p->drawPoint( x+1, y2-2 ); | 246 | p->drawPoint( x+1, y2-2 ); |
202 | p->drawLine( x2-2, y2-1, x2-1, y2-1 ); | 247 | p->drawLine( x2-2, y2-1, x2-1, y2-1 ); |
203 | p->drawPoint( x2-1, y2-2 ); | 248 | p->drawPoint( x2-1, y2-2 ); |
204 | } | 249 | } |
205 | 250 | ||
206 | p->setPen( oldPen ); | 251 | p->setPen( oldPen ); |
207 | } | 252 | } |
208 | 253 | ||
209 | void FlatStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h ) | 254 | void FlatStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h ) |
210 | { | 255 | { |
211 | x++; y++; | 256 | x++; y++; |
212 | x-=2; y-=2; | 257 | x-=2; y-=2; |
213 | p->fillRect( x, y, w, h, color1 ); | 258 | p->fillRect( x, y, w, h, color1 ); |
214 | } | 259 | } |
215 | 260 | ||
216 | void FlatStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, | 261 | void FlatStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, |
217 | const QColorGroup &g, bool /*sunken*/, const QBrush* fill ) | 262 | const QColorGroup &g, bool /*sunken*/, const QBrush* fill ) |
218 | { | 263 | { |
219 | p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) ); | 264 | p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) ); |
220 | p->setPen( g.foreground() ); | 265 | p->setPen( g.foreground() ); |
221 | p->setBrush( NoBrush ); | 266 | p->setBrush( NoBrush ); |
222 | p->drawRect( x, y, w, h ); | 267 | p->drawRect( x, y, w, h ); |
223 | } | 268 | } |
224 | 269 | ||
225 | void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, | 270 | void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, |
226 | const QColorGroup &g, bool sunken, const QBrush* fill ) | 271 | const QColorGroup &g, bool sunken, const QBrush* fill ) |
227 | { | 272 | { |
273 | if ( p->device()->devType() == QInternal::Widget ) { | ||
274 | QWidget *w = (QWidget *)p->device(); | ||
275 | if ( w->isA("QToolButton") ) { | ||
276 | QToolButton *btn = (QToolButton *)w; | ||
277 | if ( btn->parentWidget() ) { | ||
278 | btnBg = btn->parentWidget()->backgroundColor(); | ||
279 | fillBtnBorder = TRUE; | ||
280 | } | ||
281 | } | ||
282 | } | ||
228 | QBrush fb( fill ? *fill : g.button() ); | 283 | QBrush fb( fill ? *fill : g.button() ); |
229 | if ( sunken && fb == g.brush( QColorGroup::Button ) ) { | 284 | if ( sunken && fb == g.brush( QColorGroup::Button ) ) { |
230 | fb = g.buttonText(); | 285 | fb = g.buttonText(); |
231 | revItem = TRUE;// ugh | 286 | revItem = TRUE;// ugh |
232 | } | 287 | } |
233 | drawButton( p, x, y, w, h, g, sunken, &fb ); | 288 | drawButton( p, x, y, w, h, g, sunken, &fb ); |
289 | fillBtnBorder = FALSE; | ||
234 | } | 290 | } |
235 | 291 | ||
236 | void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p ) | 292 | void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p ) |
237 | { | 293 | { |
238 | QColorGroup g = btn->colorGroup(); | 294 | QColorGroup g = btn->colorGroup(); |
239 | int x1, y1, x2, y2; | 295 | int x1, y1, x2, y2; |
240 | 296 | ||
241 | btn->rect().coords( &x1, &y1, &x2, &y2 );// get coordinates | 297 | btn->rect().coords( &x1, &y1, &x2, &y2 );// get coordinates |
242 | 298 | ||
243 | p->setPen( g.foreground() ); | 299 | p->setPen( g.foreground() ); |
244 | p->setBrush( QBrush(g.button(),NoBrush) ); | 300 | p->setBrush( QBrush(g.button(),NoBrush) ); |
245 | 301 | ||
246 | // int diw = buttonDefaultIndicatorWidth(); | 302 | // int diw = buttonDefaultIndicatorWidth(); |
247 | /* | 303 | /* |
248 | if ( btn->isDefault() || btn->autoDefault() ) { | 304 | if ( btn->isDefault() || btn->autoDefault() ) { |
249 | if ( btn->isDefault() ) { | 305 | if ( btn->isDefault() ) { |
250 | p->setPen( g.shadow() ); | 306 | p->setPen( g.shadow() ); |
251 | p->drawRect( x1, y1, x2-x1+1, y2-y1+1 ); | 307 | p->drawRect( x1, y1, x2-x1+1, y2-y1+1 ); |
252 | } | 308 | } |
253 | x1 += diw; | 309 | x1 += diw; |
254 | y1 += diw; | 310 | y1 += diw; |
255 | x2 -= diw; | 311 | x2 -= diw; |
256 | y2 -= diw; | 312 | y2 -= diw; |
257 | } | 313 | } |
258 | */ | 314 | */ |
259 | 315 | ||
316 | if ( btn->parentWidget() ) { | ||
317 | btnBg = btn->parentWidget()->backgroundColor(); | ||
318 | fillBtnBorder = TRUE; | ||
319 | } | ||
320 | |||
260 | bool clearButton = TRUE; | 321 | bool clearButton = TRUE; |
261 | if ( btn->isDown() ) { | 322 | if ( btn->isDown() ) { |
262 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, | 323 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, |
263 | &g.brush( QColorGroup::Text ) ); | 324 | &g.brush( QColorGroup::Text ) ); |
264 | } else { | 325 | } else { |
265 | if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) { | 326 | if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) { |
266 | QBrush fill(g.light(), Dense4Pattern ); | 327 | QBrush fill(g.light(), Dense4Pattern ); |
267 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill ); | 328 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill ); |
268 | clearButton = FALSE; | 329 | clearButton = FALSE; |
269 | } else { | 330 | } else { |
270 | if ( !btn->isFlat() ) | 331 | if ( !btn->isFlat() ) |
271 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(), | 332 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(), |
272 | &g.brush( QColorGroup::Button ) ); | 333 | &g.brush( QColorGroup::Button ) ); |
273 | } | 334 | } |
274 | } | 335 | } |
275 | /* | 336 | /* |
276 | if ( clearButton ) { | 337 | if ( clearButton ) { |
277 | if (btn->isDown()) | 338 | if (btn->isDown()) |
278 | p->setBrushOrigin(p->brushOrigin() + QPoint(1,1)); | 339 | p->setBrushOrigin(p->brushOrigin() + QPoint(1,1)); |
279 | p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3, | 340 | p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3, |
280 | g.brush( QColorGroup::Button ) ); | 341 | g.brush( QColorGroup::Button ) ); |
281 | if (btn->isDown()) | 342 | if (btn->isDown()) |
282 | p->setBrushOrigin(p->brushOrigin() - QPoint(1,1)); | 343 | p->setBrushOrigin(p->brushOrigin() - QPoint(1,1)); |
283 | } | 344 | } |
284 | */ | 345 | */ |
285 | 346 | ||
347 | fillBtnBorder = FALSE; | ||
286 | if ( p->brush().style() != NoBrush ) | 348 | if ( p->brush().style() != NoBrush ) |
287 | p->setBrush( NoBrush ); | 349 | p->setBrush( NoBrush ); |
288 | } | 350 | } |
289 | 351 | ||
290 | void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) | 352 | void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) |
291 | { | 353 | { |
292 | QRect r = pushButtonContentsRect( btn ); | 354 | QRect r = pushButtonContentsRect( btn ); |
293 | int x, y, w, h; | 355 | int x, y, w, h; |
294 | r.rect( &x, &y, &w, &h ); | 356 | r.rect( &x, &y, &w, &h ); |
295 | QColorGroup cg = btn->colorGroup(); | 357 | QColorGroup cg = btn->colorGroup(); |
296 | if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() && !btn->isDown() ) | 358 | if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() && !btn->isDown() ) |
297 | cg.setColor( QColorGroup::ButtonText, btn->colorGroup().text() ); | 359 | cg.setColor( QColorGroup::ButtonText, btn->colorGroup().text() ); |
298 | else if ( btn->isDown() || btn->isOn() ) | 360 | else if ( btn->isDown() || btn->isOn() ) |
299 | cg.setColor( QColorGroup::ButtonText, btn->colorGroup().button() ); | 361 | cg.setColor( QColorGroup::ButtonText, btn->colorGroup().button() ); |
300 | if ( btn->isMenuButton() ) { | 362 | if ( btn->isMenuButton() ) { |
301 | int dx = menuButtonIndicatorWidth( btn->height() ); | 363 | int dx = menuButtonIndicatorWidth( btn->height() ); |
302 | drawArrow( p, DownArrow, FALSE, | 364 | drawArrow( p, DownArrow, FALSE, |
303 | x+w-dx, y+2, dx-4, h-4, | 365 | x+w-dx, y+2, dx-4, h-4, |
304 | cg, | 366 | cg, |
305 | btn->isEnabled() ); | 367 | btn->isEnabled() ); |
306 | w -= dx; | 368 | w -= dx; |
307 | } | 369 | } |
308 | 370 | ||
309 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) { | 371 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) { |
310 | QIconSet::Mode mode = btn->isEnabled() | 372 | QIconSet::Mode mode = btn->isEnabled() |
311 | ? QIconSet::Normal : QIconSet::Disabled; | 373 | ? QIconSet::Normal : QIconSet::Disabled; |
312 | if ( mode == QIconSet::Normal && btn->hasFocus() ) | 374 | if ( mode == QIconSet::Normal && btn->hasFocus() ) |
313 | mode = QIconSet::Active; | 375 | mode = QIconSet::Active; |
314 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); | 376 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); |
315 | int pixw = pixmap.width(); | 377 | int pixw = pixmap.width(); |
316 | int pixh = pixmap.height(); | 378 | int pixh = pixmap.height(); |
317 | p->drawPixmap( x+2, y+h/2-pixh/2, pixmap ); | 379 | p->drawPixmap( x+2, y+h/2-pixh/2, pixmap ); |
318 | x += pixw + 4; | 380 | x += pixw + 4; |
319 | w -= pixw + 4; | 381 | w -= pixw + 4; |
320 | } | 382 | } |
321 | drawItem( p, x, y, w, h, | 383 | drawItem( p, x, y, w, h, |
322 | AlignCenter | ShowPrefix, | 384 | AlignCenter | ShowPrefix, |
323 | cg, btn->isEnabled(), | 385 | cg, btn->isEnabled(), |
324 | btn->pixmap(), btn->text(), -1, &cg.buttonText() ); | 386 | btn->pixmap(), btn->text(), -1, &cg.buttonText() ); |
325 | 387 | ||
326 | } | 388 | } |
327 | 389 | ||
328 | QRect FlatStyle::comboButtonRect( int x, int y, int w, int h) | 390 | QRect FlatStyle::comboButtonRect( int x, int y, int w, int h) |
329 | { | 391 | { |
330 | return QRect(x+2, y+2, w-4-13, h-4); | 392 | return QRect(x+2, y+2, w-4-13, h-4); |
331 | } | 393 | } |
332 | 394 | ||
333 | 395 | ||
334 | QRect FlatStyle::comboButtonFocusRect( int x, int y, int w, int h) | 396 | QRect FlatStyle::comboButtonFocusRect( int x, int y, int w, int h) |
335 | { | 397 | { |
336 | return QRect(x+2, y+2, w-4-14, h-4); | 398 | return QRect(x+2, y+2, w-4-14, h-4); |
337 | } | 399 | } |
338 | 400 | ||
339 | void FlatStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, | 401 | void FlatStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, |
340 | const QColorGroup &g, bool sunken, | 402 | const QColorGroup &g, bool sunken, |
341 | bool /*editable*/, | 403 | bool /*editable*/, |
342 | bool enabled, | 404 | bool enabled, |
343 | const QBrush * /*fill*/ ) | 405 | const QBrush * /*fill*/ ) |
344 | { | 406 | { |
345 | x++; y++; | 407 | x++; y++; |
346 | w-=2; h-=2; | 408 | w-=2; h-=2; |
347 | p->setPen( g.foreground() ); | 409 | p->setPen( g.foreground() ); |
348 | p->setBrush( QBrush(NoBrush) ); | 410 | p->setBrush( QBrush(NoBrush) ); |
349 | p->drawRect( x, y, w, h ); | 411 | p->drawRect( x, y, w, h ); |
350 | p->setPen( g.background() ); | 412 | p->setPen( g.background() ); |
351 | p->drawRect( x+1, y+1, w-14, h-2 ); | 413 | p->drawRect( x+1, y+1, w-14, h-2 ); |
352 | p->fillRect( x+2, y+2, w-16, h-4, g.brush( QColorGroup::Base ) ); | 414 | p->fillRect( x+2, y+2, w-16, h-4, g.brush( QColorGroup::Base ) ); |
353 | QColorGroup cg( g ); | 415 | QColorGroup cg( g ); |
354 | if ( sunken ) { | 416 | if ( sunken ) { |
355 | cg.setColor( QColorGroup::ButtonText, g.button() ); | 417 | cg.setColor( QColorGroup::ButtonText, g.button() ); |
356 | cg.setColor( QColorGroup::Button, g.buttonText() ); | 418 | cg.setColor( QColorGroup::Button, g.buttonText() ); |
357 | } | 419 | } |
358 | drawArrow( p, QStyle::DownArrow, FALSE, | 420 | drawArrow( p, QStyle::DownArrow, FALSE, |
359 | x+w-13, y+1, 12, h-2, cg, enabled, | 421 | x+w-13, y+1, 12, h-2, cg, enabled, |
360 | &cg.brush( QColorGroup::Button ) ); | 422 | &cg.brush( QColorGroup::Button ) ); |
361 | 423 | ||
362 | } | 424 | } |
363 | 425 | ||
364 | 426 | ||
365 | void FlatStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, | 427 | void FlatStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, |
366 | int h, const QColorGroup &cg, bool on, bool down, bool enabled ) | 428 | int h, const QColorGroup &cg, bool on, bool down, bool enabled ) |
367 | { | 429 | { |
368 | static const QCOORD pts1[] = { // dark lines | 430 | static const QCOORD pts1[] = { // dark lines |
369 | 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; | 431 | 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; |
370 | static const QCOORD pts4[] = { // white lines | 432 | static const QCOORD pts4[] = { // white lines |
371 | 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, | 433 | 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, |
372 | 11,4, 10,3, 10,2 }; | 434 | 11,4, 10,3, 10,2 }; |
373 | static const QCOORD pts5[] = { // inner fill | 435 | static const QCOORD pts5[] = { // inner fill |
374 | 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; | 436 | 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; |
375 | 437 | ||
376 | p->eraseRect( x, y, w, h ); | 438 | p->eraseRect( x, y, w, h ); |
377 | QPointArray a( QCOORDARRLEN(pts1), pts4 ); | 439 | QPointArray a( QCOORDARRLEN(pts1), pts4 ); |
378 | a.translate( x, y ); | 440 | a.translate( x, y ); |
379 | p->setPen( cg.foreground() ); | 441 | p->setPen( cg.foreground() ); |
380 | p->drawPolyline( a ); | 442 | p->drawPolyline( a ); |
381 | a.setPoints( QCOORDARRLEN(pts4), pts1 ); | 443 | a.setPoints( QCOORDARRLEN(pts4), pts1 ); |
@@ -496,193 +558,194 @@ QStyle::ScrollControl FlatStyle::scrollBarPointOver( const QScrollBar* sb, int s | |||
496 | } | 558 | } |
497 | 559 | ||
498 | /*! \reimp */ | 560 | /*! \reimp */ |
499 | 561 | ||
500 | void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl ) | 562 | void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl ) |
501 | { | 563 | { |
502 | #define ADD_LINE_ACTIVE ( activeControl == AddLine ) | 564 | #define ADD_LINE_ACTIVE ( activeControl == AddLine ) |
503 | #define SUB_LINE_ACTIVE ( activeControl == SubLine ) | 565 | #define SUB_LINE_ACTIVE ( activeControl == SubLine ) |
504 | QColorGroup g = sb->colorGroup(); | 566 | QColorGroup g = sb->colorGroup(); |
505 | 567 | ||
506 | int sliderMin, sliderMax, sliderLength, buttonDim; | 568 | int sliderMin, sliderMax, sliderLength, buttonDim; |
507 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 569 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
508 | 570 | ||
509 | if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) { | 571 | if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) { |
510 | p->setPen( g.foreground() ); | 572 | p->setPen( g.foreground() ); |
511 | p->setBrush( g.brush( QColorGroup::Mid ) ); | 573 | p->setBrush( g.brush( QColorGroup::Mid ) ); |
512 | p->drawRect( 0, 0, sb->width(), sb->height() ); | 574 | p->drawRect( 0, 0, sb->width(), sb->height() ); |
513 | } | 575 | } |
514 | 576 | ||
515 | if (sliderStart > sliderMax) { // sanity check | 577 | if (sliderStart > sliderMax) { // sanity check |
516 | sliderStart = sliderMax; | 578 | sliderStart = sliderMax; |
517 | } | 579 | } |
518 | 580 | ||
519 | int dimB = buttonDim; | 581 | int dimB = buttonDim; |
520 | QRect addB; | 582 | QRect addB; |
521 | QRect subB; | 583 | QRect subB; |
522 | QRect addPageR; | 584 | QRect addPageR; |
523 | QRect subPageR; | 585 | QRect subPageR; |
524 | QRect sliderR; | 586 | QRect sliderR; |
525 | int addX, addY, subX, subY; | 587 | int addX, addY, subX, subY; |
526 | int length = HORIZONTAL ? sb->width() : sb->height(); | 588 | int length = HORIZONTAL ? sb->width() : sb->height(); |
527 | int extent = HORIZONTAL ? sb->height() : sb->width(); | 589 | int extent = HORIZONTAL ? sb->height() : sb->width(); |
528 | 590 | ||
529 | if ( HORIZONTAL ) { | 591 | if ( HORIZONTAL ) { |
530 | subY = addY = ( extent - dimB ) / 2; | 592 | subY = addY = ( extent - dimB ) / 2; |
531 | subX = length - dimB - dimB + 1; | 593 | subX = length - dimB - dimB + 1; |
532 | addX = length - dimB; | 594 | addX = length - dimB; |
533 | } else { | 595 | } else { |
534 | subX = addX = ( extent - dimB ) / 2; | 596 | subX = addX = ( extent - dimB ) / 2; |
535 | subY = length - dimB - dimB + 1; | 597 | subY = length - dimB - dimB + 1; |
536 | addY = length - dimB; | 598 | addY = length - dimB; |
537 | } | 599 | } |
538 | 600 | ||
539 | int sliderEnd = sliderStart + sliderLength; | 601 | int sliderEnd = sliderStart + sliderLength; |
540 | int sliderW = extent; | 602 | int sliderW = extent; |
541 | if ( HORIZONTAL ) { | 603 | if ( HORIZONTAL ) { |
542 | subB.setRect( subX,subY,dimB,dimB ); | 604 | subB.setRect( subX,subY,dimB,dimB ); |
543 | addB.setRect( addX,addY,dimB,dimB ); | 605 | addB.setRect( addX,addY,dimB,dimB ); |
544 | subPageR.setRect( 0, 0, sliderStart+1, sliderW ); | 606 | subPageR.setRect( 0, 0, sliderStart+1, sliderW ); |
545 | addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+2, sliderW ); | 607 | addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+2, sliderW ); |
546 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); | 608 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); |
547 | 609 | ||
548 | } else { | 610 | } else { |
549 | subB.setRect( subX,subY,dimB,dimB ); | 611 | subB.setRect( subX,subY,dimB,dimB ); |
550 | addB.setRect( addX,addY,dimB,dimB ); | 612 | addB.setRect( addX,addY,dimB,dimB ); |
551 | subPageR.setRect( 0, 0, sliderW, sliderStart+1 ); | 613 | subPageR.setRect( 0, 0, sliderW, sliderStart+1 ); |
552 | addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+2 ); | 614 | addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+2 ); |
553 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); | 615 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); |
554 | } | 616 | } |
555 | 617 | ||
556 | bool maxedOut = (sb->maxValue() == sb->minValue()); | 618 | bool maxedOut = (sb->maxValue() == sb->minValue()); |
557 | p->setPen( g.foreground() ); | 619 | p->setPen( g.foreground() ); |
558 | if ( controls & AddLine ) { | 620 | if ( controls & AddLine ) { |
559 | p->setBrush( ADD_LINE_ACTIVE ? g.foreground() : g.button() ); | 621 | p->setBrush( ADD_LINE_ACTIVE ? g.foreground() : g.button() ); |
560 | p->drawRect( addB.x(), addB.y(), addB.width(), addB.height() ); | 622 | p->drawRect( addB.x(), addB.y(), addB.width(), addB.height() ); |
561 | p->setPen( ADD_LINE_ACTIVE ? g.button() : g.foreground() ); | 623 | p->setPen( ADD_LINE_ACTIVE ? g.button() : g.foreground() ); |
562 | QColorGroup cg( g ); | 624 | QColorGroup cg( g ); |
563 | if ( maxedOut ) | 625 | if ( maxedOut ) |
564 | cg.setColor( QColorGroup::ButtonText, g.mid() ); | 626 | cg.setColor( QColorGroup::ButtonText, g.mid() ); |
565 | else if ( ADD_LINE_ACTIVE ) | 627 | else if ( ADD_LINE_ACTIVE ) |
566 | cg.setColor( QColorGroup::ButtonText, g.button() ); | 628 | cg.setColor( QColorGroup::ButtonText, g.button() ); |
567 | int xo = VERTICAL ? 1 : 0; | 629 | int xo = VERTICAL ? 1 : 0; |
568 | drawArrow( p, VERTICAL ? DownArrow : RightArrow, FALSE, | 630 | drawArrow( p, VERTICAL ? DownArrow : RightArrow, FALSE, |
569 | addB.x()+2+xo, addB.y()+2, addB.width()-4-xo, addB.height()-4, | 631 | addB.x()+2+xo, addB.y()+2, addB.width()-4-xo, addB.height()-4, |
570 | cg, TRUE, &p->brush() ); | 632 | cg, TRUE, &p->brush() ); |
571 | } | 633 | } |
572 | if ( controls & SubLine ) { | 634 | if ( controls & SubLine ) { |
573 | p->setBrush( SUB_LINE_ACTIVE ? g.foreground() : g.button() ); | 635 | p->setBrush( SUB_LINE_ACTIVE ? g.foreground() : g.button() ); |
574 | p->drawRect( subB.x(), subB.y(), subB.width(), subB.height() ); | 636 | p->drawRect( subB.x(), subB.y(), subB.width(), subB.height() ); |
575 | p->setPen( SUB_LINE_ACTIVE ? g.button() : g.foreground() ); | 637 | p->setPen( SUB_LINE_ACTIVE ? g.button() : g.foreground() ); |
576 | QColorGroup cg( g ); | 638 | QColorGroup cg( g ); |
577 | if ( maxedOut ) | 639 | if ( maxedOut ) |
578 | cg.setColor( QColorGroup::ButtonText, g.mid() ); | 640 | cg.setColor( QColorGroup::ButtonText, g.mid() ); |
579 | else if ( SUB_LINE_ACTIVE ) | 641 | else if ( SUB_LINE_ACTIVE ) |
580 | cg.setColor( QColorGroup::ButtonText, g.button() ); | 642 | cg.setColor( QColorGroup::ButtonText, g.button() ); |
581 | int xo = VERTICAL ? 1 : 0; | 643 | int xo = VERTICAL ? 1 : 0; |
582 | drawArrow( p, VERTICAL ? UpArrow : LeftArrow, FALSE, | 644 | drawArrow( p, VERTICAL ? UpArrow : LeftArrow, FALSE, |
583 | subB.x()+2+xo, subB.y()+2, subB.width()-4-xo, subB.height()-4, | 645 | subB.x()+2+xo, subB.y()+2, subB.width()-4-xo, subB.height()-4, |
584 | cg, TRUE, &p->brush() ); | 646 | cg, TRUE, &p->brush() ); |
585 | } | 647 | } |
586 | 648 | ||
587 | 649 | ||
588 | p->setPen( g.foreground() ); | 650 | p->setPen( g.foreground() ); |
589 | p->setBrush( g.brush( QColorGroup::Mid ) ); | 651 | p->setBrush( g.brush( QColorGroup::Mid ) ); |
590 | if ( controls & SubPage ) | 652 | if ( controls & SubPage ) |
591 | p->drawRect( subPageR.x(), subPageR.y(), subPageR.width(), subPageR.height() ); | 653 | p->drawRect( subPageR.x(), subPageR.y(), subPageR.width(), subPageR.height() ); |
592 | if ( controls & AddPage && addPageR.y() < addPageR.bottom() ) | 654 | if ( controls & AddPage && addPageR.y() < addPageR.bottom() && |
655 | addPageR.x() < addPageR.right() ) | ||
593 | p->drawRect( addPageR.x(), addPageR.y(), addPageR.width(), addPageR.height() ); | 656 | p->drawRect( addPageR.x(), addPageR.y(), addPageR.width(), addPageR.height() ); |
594 | if ( controls & Slider ) { | 657 | if ( controls & Slider ) { |
595 | QPoint bo = p->brushOrigin(); | 658 | QPoint bo = p->brushOrigin(); |
596 | p->setBrushOrigin(sliderR.topLeft()); | 659 | p->setBrushOrigin(sliderR.topLeft()); |
597 | p->setPen( g.foreground() ); | 660 | p->setPen( g.foreground() ); |
598 | p->setBrush( g.button() ); | 661 | p->setBrush( g.button() ); |
599 | p->drawRect( sliderR.x(), sliderR.y(), sliderR.width(), sliderR.height() ); | 662 | p->drawRect( sliderR.x(), sliderR.y(), sliderR.width(), sliderR.height() ); |
600 | p->setBrushOrigin(bo); | 663 | p->setBrushOrigin(bo); |
601 | QColorGroup cg( g ); | 664 | QColorGroup cg( g ); |
602 | if ( maxedOut ) | 665 | if ( maxedOut ) |
603 | cg.setColor( QColorGroup::ButtonText, g.mid() ); | 666 | cg.setColor( QColorGroup::ButtonText, g.mid() ); |
604 | drawRiffles( p, sliderR.x(), sliderR.y(), | 667 | drawRiffles( p, sliderR.x(), sliderR.y(), |
605 | sliderR.width(), sliderR.height(), cg, HORIZONTAL ); | 668 | sliderR.width(), sliderR.height(), cg, HORIZONTAL ); |
606 | } | 669 | } |
607 | 670 | ||
608 | // ### perhaps this should not be able to accept focus if maxedOut? | 671 | // ### perhaps this should not be able to accept focus if maxedOut? |
609 | if ( sb->hasFocus() && (controls & Slider) ) | 672 | if ( sb->hasFocus() && (controls & Slider) ) |
610 | p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2, | 673 | p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2, |
611 | sliderR.width()-5, sliderR.height()-5, | 674 | sliderR.width()-5, sliderR.height()-5, |
612 | sb->backgroundColor() ); | 675 | sb->backgroundColor() ); |
613 | 676 | ||
614 | } | 677 | } |
615 | 678 | ||
616 | void FlatStyle::drawRiffles( QPainter* p, int x, int y, int w, int h, | 679 | void FlatStyle::drawRiffles( QPainter* p, int x, int y, int w, int h, |
617 | const QColorGroup &g, bool horizontal ) | 680 | const QColorGroup &g, bool horizontal ) |
618 | { | 681 | { |
619 | if (!horizontal) { | 682 | if (!horizontal) { |
620 | if (h > 20) { | 683 | if (h > 20) { |
621 | y += (h-20)/2 ; | 684 | y += (h-20)/2 ; |
622 | h = 20; | 685 | h = 20; |
623 | } | 686 | } |
624 | if (h > 12) { | 687 | if (h > 12) { |
625 | int n = 3; | 688 | int n = 3; |
626 | int my = y+h/2-2; | 689 | int my = y+h/2-2; |
627 | int i ; | 690 | int i ; |
628 | p->setPen(g.buttonText()); | 691 | p->setPen(g.buttonText()); |
629 | for (i=0; i<n; i++) { | 692 | for (i=0; i<n; i++) { |
630 | p->drawLine(x+4, my+3*i, x+w-5, my+3*i); | 693 | p->drawLine(x+4, my+3*i, x+w-5, my+3*i); |
631 | } | 694 | } |
632 | } | 695 | } |
633 | } else { | 696 | } else { |
634 | if (w > 20) { | 697 | if (w > 20) { |
635 | x += (w-20)/2 ; | 698 | x += (w-20)/2 ; |
636 | w = 20; | 699 | w = 20; |
637 | } | 700 | } |
638 | if (w > 12) { | 701 | if (w > 12) { |
639 | int n = 3; | 702 | int n = 3; |
640 | int mx = x+w/2-4; | 703 | int mx = x+w/2-4; |
641 | int i ; | 704 | int i ; |
642 | p->setPen(g.buttonText()); | 705 | p->setPen(g.buttonText()); |
643 | for (i=0; i<n; i++) { | 706 | for (i=0; i<n; i++) { |
644 | p->drawLine(mx+3*i, y+4, mx + 3*i, y+h-5); | 707 | p->drawLine(mx+3*i, y+4, mx + 3*i, y+h-5); |
645 | } | 708 | } |
646 | } | 709 | } |
647 | } | 710 | } |
648 | } | 711 | } |
649 | 712 | ||
650 | int FlatStyle::sliderLength() const | 713 | int FlatStyle::sliderLength() const |
651 | { | 714 | { |
652 | return 12; | 715 | return 12; |
653 | } | 716 | } |
654 | 717 | ||
655 | void FlatStyle::drawSlider( QPainter *p, int x, int y, int w, int h, | 718 | void FlatStyle::drawSlider( QPainter *p, int x, int y, int w, int h, |
656 | const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow ) | 719 | const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow ) |
657 | { | 720 | { |
658 | int a = tickAbove ? 3 : 0; | 721 | int a = tickAbove ? 3 : 0; |
659 | int b = tickBelow ? 3 : 0; | 722 | int b = tickBelow ? 3 : 0; |
660 | 723 | ||
661 | p->setPen( g.foreground() ); | 724 | p->setPen( g.foreground() ); |
662 | p->setBrush( g.button() ); | 725 | p->setBrush( g.button() ); |
663 | if ( o == Horizontal ) { | 726 | if ( o == Horizontal ) { |
664 | p->drawRect( x, y+a, w, h-a-b ); | 727 | p->drawRect( x, y+a, w, h-a-b ); |
665 | int xp = x + w/2; | 728 | int xp = x + w/2; |
666 | p->drawLine( xp-1, y+a+3, xp-1, y+h-b-4 ); | 729 | p->drawLine( xp-1, y+a+3, xp-1, y+h-b-4 ); |
667 | p->drawLine( xp, y+a+3, xp, y+h-b-4 ); | 730 | p->drawLine( xp, y+a+3, xp, y+h-b-4 ); |
668 | } else { | 731 | } else { |
669 | p->drawRect( x+a, y, w-a-b, h ); | 732 | p->drawRect( x+a, y, w-a-b, h ); |
670 | int yp = y + h/2; | 733 | int yp = y + h/2; |
671 | p->drawLine( x+a+3, yp-1, x+w-b-4, yp-1 ); | 734 | p->drawLine( x+a+3, yp-1, x+w-b-4, yp-1 ); |
672 | p->drawLine( x+a+3, yp, x+w-b-4, yp ); | 735 | p->drawLine( x+a+3, yp, x+w-b-4, yp ); |
673 | } | 736 | } |
674 | } | 737 | } |
675 | 738 | ||
676 | void FlatStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h, | 739 | void FlatStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h, |
677 | Orientation o, bool tickAbove, bool tickBelow ) | 740 | Orientation o, bool tickAbove, bool tickBelow ) |
678 | { | 741 | { |
679 | int a = tickAbove ? 3 : 0; | 742 | int a = tickAbove ? 3 : 0; |
680 | int b = tickBelow ? 3 : 0; | 743 | int b = tickBelow ? 3 : 0; |
681 | if ( o == Horizontal ) | 744 | if ( o == Horizontal ) |
682 | p->fillRect( x, y+a, w, h-a-b, color1 ); | 745 | p->fillRect( x, y+a, w, h-a-b, color1 ); |
683 | else | 746 | else |
684 | p->fillRect( x+a, y, w-a-b, h, color1 ); | 747 | p->fillRect( x+a, y, w-a-b, h, color1 ); |
685 | } | 748 | } |
686 | 749 | ||
687 | /*!\reimp | 750 | /*!\reimp |
688 | */ | 751 | */ |
@@ -691,192 +754,198 @@ void FlatStyle::drawSliderGrooveMask( QPainter *p, | |||
691 | const QColorGroup& , QCOORD c, | 754 | const QColorGroup& , QCOORD c, |
692 | Orientation orient ) | 755 | Orientation orient ) |
693 | { | 756 | { |
694 | if ( orient == Horizontal ) | 757 | if ( orient == Horizontal ) |
695 | p->fillRect( x, y + c - 2, w, 4, color1 ); | 758 | p->fillRect( x, y + c - 2, w, 4, color1 ); |
696 | else | 759 | else |
697 | p->fillRect( x + c - 2, y, 4, h, color1 ); | 760 | p->fillRect( x + c - 2, y, 4, h, color1 ); |
698 | } | 761 | } |
699 | 762 | ||
700 | void FlatStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, QCOORD c, Orientation orient ) | 763 | void FlatStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, QCOORD c, Orientation orient ) |
701 | { | 764 | { |
702 | if ( orient == Horizontal ) | 765 | if ( orient == Horizontal ) |
703 | p->fillRect( x, y + c - 2, w, 4, g.foreground() ); | 766 | p->fillRect( x, y + c - 2, w, 4, g.foreground() ); |
704 | else | 767 | else |
705 | p->fillRect( x + c - 2, y, 4, h, g.foreground() ); | 768 | p->fillRect( x + c - 2, y, 4, h, g.foreground() ); |
706 | } | 769 | } |
707 | 770 | ||
708 | void FlatStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) | 771 | void FlatStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) |
709 | { | 772 | { |
710 | QRect r( t->rect() ); | 773 | QRect r( t->rect() ); |
711 | if ( tb->shape() == QTabBar::RoundedAbove ) { | 774 | if ( tb->shape() == QTabBar::RoundedAbove ) { |
712 | p->setPen( tb->colorGroup().foreground() ); | 775 | p->setPen( tb->colorGroup().foreground() ); |
713 | p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); | 776 | p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); |
714 | if ( r.left() == 0 ) | 777 | if ( r.left() == 0 ) |
715 | p->drawPoint( tb->rect().bottomLeft() ); | 778 | p->drawPoint( tb->rect().bottomLeft() ); |
716 | else | 779 | else |
717 | p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); | 780 | p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); |
718 | 781 | ||
719 | if ( selected ) { | 782 | if ( selected ) { |
720 | p->setPen( tb->colorGroup().background() ); | 783 | p->setPen( tb->colorGroup().background() ); |
721 | p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); | 784 | p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); |
722 | p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), | 785 | p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), |
723 | tb->colorGroup().brush( QColorGroup::Background )); | 786 | tb->colorGroup().brush( QColorGroup::Background )); |
724 | } else { | 787 | } else { |
725 | r.setRect( r.left() + 2, r.top() + 2, | 788 | r.setRect( r.left() + 2, r.top() + 2, |
726 | r.width() - 4, r.height() - 2 ); | 789 | r.width() - 4, r.height() - 2 ); |
727 | p->setPen( tb->colorGroup().button() ); | 790 | p->setPen( tb->colorGroup().button() ); |
728 | p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); | 791 | p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); |
729 | p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), | 792 | p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), |
730 | tb->colorGroup().brush( QColorGroup::Button )); | 793 | tb->colorGroup().brush( QColorGroup::Button )); |
731 | } | 794 | } |
732 | 795 | ||
733 | p->setPen( tb->colorGroup().foreground() ); | 796 | p->setPen( tb->colorGroup().foreground() ); |
734 | p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); | 797 | p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); |
735 | p->drawPoint( r.left()+1, r.top() + 1 ); | 798 | p->drawPoint( r.left()+1, r.top() + 1 ); |
736 | p->drawLine( r.left()+2, r.top(), | 799 | p->drawLine( r.left()+2, r.top(), |
737 | r.right() - 2, r.top() ); | 800 | r.right() - 2, r.top() ); |
738 | 801 | ||
739 | p->drawPoint( r.right() - 1, r.top() + 1 ); | 802 | p->drawPoint( r.right() - 1, r.top() + 1 ); |
740 | p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); | 803 | p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); |
741 | } else if ( tb->shape() == QTabBar::RoundedBelow ) { | 804 | } else if ( tb->shape() == QTabBar::RoundedBelow ) { |
742 | if ( selected ) { | 805 | if ( selected ) { |
743 | p->setPen( tb->colorGroup().background() ); | 806 | p->setPen( tb->colorGroup().background() ); |
744 | p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); | 807 | p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); |
745 | p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), | 808 | p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), |
746 | tb->palette().normal().brush( QColorGroup::Background )); | 809 | tb->palette().normal().brush( QColorGroup::Background )); |
747 | } else { | 810 | } else { |
748 | p->setPen( tb->colorGroup().foreground() ); | 811 | p->setPen( tb->colorGroup().foreground() ); |
749 | p->drawLine( r.left(), r.top(), | 812 | p->drawLine( r.left(), r.top(), |
750 | r.right(), r.top() ); | 813 | r.right(), r.top() ); |
751 | r.setRect( r.left() + 2, r.top(), | 814 | r.setRect( r.left() + 2, r.top(), |
752 | r.width() - 4, r.height() - 2 ); | 815 | r.width() - 4, r.height() - 2 ); |
753 | p->setPen( tb->colorGroup().button() ); | 816 | p->setPen( tb->colorGroup().button() ); |
754 | p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); | 817 | p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); |
755 | p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), | 818 | p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), |
756 | tb->palette().normal().brush( QColorGroup::Button )); | 819 | tb->palette().normal().brush( QColorGroup::Button )); |
757 | } | 820 | } |
758 | 821 | ||
759 | p->setPen( tb->colorGroup().foreground() ); | 822 | p->setPen( tb->colorGroup().foreground() ); |
760 | p->drawLine( r.right(), r.top(), | 823 | p->drawLine( r.right(), r.top(), |
761 | r.right(), r.bottom() - 2 ); | 824 | r.right(), r.bottom() - 2 ); |
762 | p->drawPoint( r.right() - 1, r.bottom() - 1 ); | 825 | p->drawPoint( r.right() - 1, r.bottom() - 1 ); |
763 | p->drawLine( r.right() - 2, r.bottom(), | 826 | p->drawLine( r.right() - 2, r.bottom(), |
764 | r.left() + 2, r.bottom() ); | 827 | r.left() + 2, r.bottom() ); |
765 | 828 | ||
766 | p->drawLine( r.left(), r.top()+1, | 829 | p->drawLine( r.left(), r.top()+1, |
767 | r.left(), r.bottom() - 2 ); | 830 | r.left(), r.bottom() - 2 ); |
768 | p->drawPoint( r.left() + 1, r.bottom() - 1 ); | 831 | p->drawPoint( r.left() + 1, r.bottom() - 1 ); |
769 | if ( r.left() == 0 ) | 832 | if ( r.left() == 0 ) |
770 | p->drawPoint( tb->rect().topLeft() ); | 833 | p->drawPoint( tb->rect().topLeft() ); |
771 | 834 | ||
772 | } else { | 835 | } else { |
773 | QCommonStyle::drawTab( p, tb, t, selected ); | 836 | QCommonStyle::drawTab( p, tb, t, selected ); |
774 | } | 837 | } |
775 | } | 838 | } |
776 | 839 | ||
777 | static const int motifItemFrame = 0;// menu item frame width | 840 | static const int motifItemFrame = 0;// menu item frame width |
778 | static const int motifSepHeight = 2;// separator item height | 841 | static const int motifSepHeight = 2;// separator item height |
779 | static const int motifItemHMargin = 1;// menu item hor text margin | 842 | static const int motifItemHMargin = 1;// menu item hor text margin |
780 | static const int motifItemVMargin = 2;// menu item ver text margin | 843 | static const int motifItemVMargin = 2;// menu item ver text margin |
781 | static const int motifArrowHMargin = 0;// arrow horizontal margin | 844 | static const int motifArrowHMargin = 0;// arrow horizontal margin |
782 | static const int motifTabSpacing = 12;// space between text and tab | 845 | static const int motifTabSpacing = 12;// space between text and tab |
783 | static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark | 846 | static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark |
784 | static const int windowsRightBorder= 8; // right border on windows | 847 | static const int windowsRightBorder= 8; // right border on windows |
785 | static const int windowsCheckMarkWidth = 2; // checkmarks width on windows | 848 | static const int windowsCheckMarkWidth = 2; // checkmarks width on windows |
786 | 849 | ||
850 | void FlatStyle::polishPopupMenu ( QPopupMenu *m ) | ||
851 | { | ||
852 | QWindowsStyle::polishPopupMenu( m ); | ||
853 | m->setLineWidth( 1 ); | ||
854 | } | ||
855 | |||
787 | /*! \reimp | 856 | /*! \reimp |
788 | */ | 857 | */ |
789 | int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ ) | 858 | int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ ) |
790 | { | 859 | { |
791 | #ifndef QT_NO_MENUDATA | 860 | #ifndef QT_NO_MENUDATA |
792 | int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm | 861 | int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm |
793 | 862 | ||
794 | if ( mi->isSeparator() ) | 863 | if ( mi->isSeparator() ) |
795 | return 10; // arbitrary | 864 | return 10; // arbitrary |
796 | else if ( mi->pixmap() ) | 865 | else if ( mi->pixmap() ) |
797 | w += mi->pixmap()->width();// pixmap only | 866 | w += mi->pixmap()->width();// pixmap only |
798 | 867 | ||
799 | if ( !mi->text().isNull() ) { | 868 | if ( !mi->text().isNull() ) { |
800 | if ( mi->text().find('\t') >= 0 )// string contains tab | 869 | if ( mi->text().find('\t') >= 0 )// string contains tab |
801 | w += motifTabSpacing; | 870 | w += motifTabSpacing; |
802 | } | 871 | } |
803 | 872 | ||
804 | if ( maxpmw ) { // we have iconsets | 873 | if ( maxpmw ) { // we have iconsets |
805 | w += maxpmw; | 874 | w += maxpmw; |
806 | w += 6; // add a little extra border around the iconset | 875 | w += 6; // add a little extra border around the iconset |
807 | } | 876 | } |
808 | 877 | ||
809 | if ( checkable && maxpmw < windowsCheckMarkWidth ) { | 878 | if ( checkable && maxpmw < windowsCheckMarkWidth ) { |
810 | w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks | 879 | w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks |
811 | } | 880 | } |
812 | 881 | ||
813 | if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks) | 882 | if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks) |
814 | w += motifCheckMarkHMargin; // add space to separate the columns | 883 | w += motifCheckMarkHMargin; // add space to separate the columns |
815 | 884 | ||
816 | w += windowsRightBorder; // windows has a strange wide border on the right side | 885 | w += windowsRightBorder; // windows has a strange wide border on the right side |
817 | 886 | ||
818 | return w; | 887 | return w; |
819 | #endif | 888 | #endif |
820 | } | 889 | } |
821 | 890 | ||
822 | /*! \reimp | 891 | /*! \reimp |
823 | */ | 892 | */ |
824 | int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) | 893 | int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) |
825 | { | 894 | { |
826 | #ifndef QT_NO_MENUDATA | 895 | #ifndef QT_NO_MENUDATA |
827 | int h = 0; | 896 | int h = 0; |
828 | if ( mi->isSeparator() ) // separator height | 897 | if ( mi->isSeparator() ) // separator height |
829 | h = motifSepHeight; | 898 | h = motifSepHeight; |
830 | else if ( mi->pixmap() ) // pixmap height | 899 | else if ( mi->pixmap() ) // pixmap height |
831 | h = mi->pixmap()->height() + 2*motifItemFrame; | 900 | h = mi->pixmap()->height() + 2*motifItemFrame; |
832 | else // text height | 901 | else // text height |
833 | h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; | 902 | h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; |
834 | 903 | ||
835 | if ( !mi->isSeparator() && mi->iconSet() != 0 ) { | 904 | if ( !mi->isSeparator() && mi->iconSet() != 0 ) { |
836 | h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); | 905 | h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); |
837 | } | 906 | } |
838 | if ( mi->custom() ) | 907 | if ( mi->custom() ) |
839 | h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; | 908 | h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; |
840 | return h; | 909 | return h; |
841 | #endif | 910 | #endif |
842 | } | 911 | } |
843 | 912 | ||
844 | void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, | 913 | void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, |
845 | const QPalette& pal, | 914 | const QPalette& pal, |
846 | bool act, bool enabled, int x, int y, int w, int h) | 915 | bool act, bool enabled, int x, int y, int w, int h) |
847 | { | 916 | { |
848 | #ifndef QT_NO_MENUDATA | 917 | #ifndef QT_NO_MENUDATA |
849 | const QColorGroup & g = pal.active(); | 918 | const QColorGroup & g = pal.active(); |
850 | bool dis = !enabled; | 919 | bool dis = !enabled; |
851 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); | 920 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); |
852 | 921 | ||
853 | if ( checkable ) | 922 | if ( checkable ) |
854 | maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks | 923 | maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks |
855 | 924 | ||
856 | int checkcol = maxpmw; | 925 | int checkcol = maxpmw; |
857 | 926 | ||
858 | if ( mi && mi->isSeparator() ) { // draw separator | 927 | if ( mi && mi->isSeparator() ) { // draw separator |
859 | p->setPen( g.dark() ); | 928 | p->setPen( g.dark() ); |
860 | p->drawLine( x, y, x+w, y ); | 929 | p->drawLine( x, y, x+w, y ); |
861 | return; | 930 | return; |
862 | } | 931 | } |
863 | 932 | ||
864 | QBrush fill = act? g.brush( QColorGroup::Highlight ) : | 933 | QBrush fill = act? g.brush( QColorGroup::Highlight ) : |
865 | g.brush( QColorGroup::Button ); | 934 | g.brush( QColorGroup::Button ); |
866 | p->fillRect( x, y, w, h, fill); | 935 | p->fillRect( x, y, w, h, fill); |
867 | 936 | ||
868 | if ( !mi ) | 937 | if ( !mi ) |
869 | return; | 938 | return; |
870 | 939 | ||
871 | if ( mi->isChecked() ) { | 940 | if ( mi->isChecked() ) { |
872 | if ( act && !dis ) { | 941 | if ( act && !dis ) { |
873 | qDrawShadePanel( p, x, y, checkcol, h, | 942 | qDrawShadePanel( p, x, y, checkcol, h, |
874 | g, TRUE, 1, &g.brush( QColorGroup::Button ) ); | 943 | g, TRUE, 1, &g.brush( QColorGroup::Button ) ); |
875 | } else { | 944 | } else { |
876 | qDrawShadePanel( p, x, y, checkcol, h, | 945 | qDrawShadePanel( p, x, y, checkcol, h, |
877 | g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); | 946 | g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); |
878 | } | 947 | } |
879 | } else if ( !act ) { | 948 | } else if ( !act ) { |
880 | p->fillRect(x, y, checkcol , h, | 949 | p->fillRect(x, y, checkcol , h, |
881 | g.brush( QColorGroup::Button )); | 950 | g.brush( QColorGroup::Button )); |
882 | } | 951 | } |
@@ -915,118 +984,119 @@ void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int | |||
915 | QColor discol; | 984 | QColor discol; |
916 | if ( dis ) { | 985 | if ( dis ) { |
917 | discol = itemg.text(); | 986 | discol = itemg.text(); |
918 | p->setPen( discol ); | 987 | p->setPen( discol ); |
919 | } | 988 | } |
920 | 989 | ||
921 | int xm = motifItemFrame + checkcol + motifItemHMargin; | 990 | int xm = motifItemFrame + checkcol + motifItemHMargin; |
922 | 991 | ||
923 | if ( mi->custom() ) { | 992 | if ( mi->custom() ) { |
924 | int m = motifItemVMargin; | 993 | int m = motifItemVMargin; |
925 | p->save(); | 994 | p->save(); |
926 | if ( dis && !act ) { | 995 | if ( dis && !act ) { |
927 | p->setPen( g.light() ); | 996 | p->setPen( g.light() ); |
928 | mi->custom()->paint( p, itemg, act, enabled, | 997 | mi->custom()->paint( p, itemg, act, enabled, |
929 | x+xm+1, y+m+1, w-xm-tab+1, h-2*m ); | 998 | x+xm+1, y+m+1, w-xm-tab+1, h-2*m ); |
930 | p->setPen( discol ); | 999 | p->setPen( discol ); |
931 | } | 1000 | } |
932 | mi->custom()->paint( p, itemg, act, enabled, | 1001 | mi->custom()->paint( p, itemg, act, enabled, |
933 | x+xm, y+m, w-xm-tab+1, h-2*m ); | 1002 | x+xm, y+m, w-xm-tab+1, h-2*m ); |
934 | p->restore(); | 1003 | p->restore(); |
935 | } | 1004 | } |
936 | QString s = mi->text(); | 1005 | QString s = mi->text(); |
937 | if ( !s.isNull() ) { // draw text | 1006 | if ( !s.isNull() ) { // draw text |
938 | int t = s.find( '\t' ); | 1007 | int t = s.find( '\t' ); |
939 | int m = motifItemVMargin; | 1008 | int m = motifItemVMargin; |
940 | const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; | 1009 | const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; |
941 | if ( t >= 0 ) { // draw tab text | 1010 | if ( t >= 0 ) { // draw tab text |
942 | if ( dis && !act ) { | 1011 | if ( dis && !act ) { |
943 | p->setPen( g.light() ); | 1012 | p->setPen( g.light() ); |
944 | p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, | 1013 | p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, |
945 | y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); | 1014 | y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); |
946 | p->setPen( discol ); | 1015 | p->setPen( discol ); |
947 | } | 1016 | } |
948 | p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame, | 1017 | p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame, |
949 | y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); | 1018 | y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); |
950 | } | 1019 | } |
951 | if ( dis && !act ) | 1020 | if ( dis && !act ) |
952 | p->setPen( discol ); | 1021 | p->setPen( discol ); |
953 | p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t ); | 1022 | p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t ); |
954 | } else if ( mi->pixmap() ) { // draw pixmap | 1023 | } else if ( mi->pixmap() ) { // draw pixmap |
955 | QPixmap *pixmap = mi->pixmap(); | 1024 | QPixmap *pixmap = mi->pixmap(); |
956 | if ( pixmap->depth() == 1 ) | 1025 | if ( pixmap->depth() == 1 ) |
957 | p->setBackgroundMode( OpaqueMode ); | 1026 | p->setBackgroundMode( OpaqueMode ); |
958 | p->drawPixmap( x+xm, y+motifItemFrame, *pixmap ); | 1027 | p->drawPixmap( x+xm, y+motifItemFrame, *pixmap ); |
959 | if ( pixmap->depth() == 1 ) | 1028 | if ( pixmap->depth() == 1 ) |
960 | p->setBackgroundMode( TransparentMode ); | 1029 | p->setBackgroundMode( TransparentMode ); |
961 | } | 1030 | } |
962 | if ( mi->popup() ) { // draw sub menu arrow | 1031 | if ( mi->popup() ) { // draw sub menu arrow |
963 | int dim = (h-2*motifItemFrame) / 2; | 1032 | int dim = (h-2*motifItemFrame) / 2; |
964 | if ( act ) { | 1033 | if ( act ) { |
965 | if ( !dis ) | 1034 | if ( !dis ) |
966 | discol = white; | 1035 | discol = white; |
967 | QColorGroup g2( discol, g.highlight(), | 1036 | QColorGroup g2( discol, g.highlight(), |
968 | white, white, | 1037 | white, white, |
969 | dis ? discol : white, | 1038 | dis ? discol : white, |
970 | discol, white ); | 1039 | discol, white ); |
971 | drawArrow( p, RightArrow, FALSE, | 1040 | drawArrow( p, RightArrow, FALSE, |
972 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, | 1041 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, |
973 | dim, dim, g2, TRUE ); | 1042 | dim, dim, g2, TRUE ); |
974 | } else { | 1043 | } else { |
975 | drawArrow( p, RightArrow, | 1044 | drawArrow( p, RightArrow, |
976 | FALSE, | 1045 | FALSE, |
977 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, | 1046 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, |
978 | dim, dim, g, mi->isEnabled() ); | 1047 | dim, dim, g, mi->isEnabled() ); |
979 | } | 1048 | } |
980 | } | 1049 | } |
981 | #endif | 1050 | #endif |
982 | } | 1051 | } |
983 | 1052 | ||
984 | void FlatStyle::getButtonShift( int &x, int &y ) | 1053 | void FlatStyle::getButtonShift( int &x, int &y ) |
985 | { | 1054 | { |
986 | x = 0; y = 0; | 1055 | x = 0; y = 0; |
987 | } | 1056 | } |
988 | 1057 | ||
989 | //=========================================================================== | 1058 | //=========================================================================== |
990 | 1059 | ||
991 | FlatStyleImpl::FlatStyleImpl() | 1060 | FlatStyleImpl::FlatStyleImpl() |
992 | : flat(0), ref(0) | 1061 | : flat(0), ref(0) |
993 | { | 1062 | { |
994 | } | 1063 | } |
995 | 1064 | ||
996 | FlatStyleImpl::~FlatStyleImpl() | 1065 | FlatStyleImpl::~FlatStyleImpl() |
997 | { | 1066 | { |
998 | // We do not delete the style because Qt does that when a new style | 1067 | // We do not delete the style because Qt does that when a new style |
999 | // is set. | 1068 | // is set. |
1000 | } | 1069 | } |
1001 | 1070 | ||
1002 | QStyle *FlatStyleImpl::style() | 1071 | QStyle *FlatStyleImpl::style() |
1003 | { | 1072 | { |
1004 | if ( !flat ) | 1073 | if ( !flat ) |
1005 | flat = new FlatStyle(); | 1074 | flat = new FlatStyle(); |
1006 | return flat; | 1075 | return flat; |
1007 | } | 1076 | } |
1008 | 1077 | ||
1009 | QString FlatStyleImpl::name() const | 1078 | QString FlatStyleImpl::name() const |
1010 | { | 1079 | { |
1011 | return QString("Flat"); | 1080 | return qApp->translate("FlatStyle", "Flat", "Name of the style Flat"); |
1012 | } | 1081 | } |
1013 | 1082 | ||
1014 | QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 1083 | QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
1015 | { | 1084 | { |
1016 | *iface = 0; | 1085 | *iface = 0; |
1017 | if ( uuid == IID_QUnknown ) | 1086 | if ( uuid == IID_QUnknown ) |
1018 | *iface = this; | 1087 | *iface = this; |
1019 | else if ( uuid == IID_Style ) | 1088 | else if ( uuid == IID_Style ) |
1020 | *iface = this; | 1089 | *iface = this; |
1090 | else | ||
1091 | return QS_FALSE; | ||
1021 | 1092 | ||
1022 | if ( *iface ) | 1093 | (*iface)->addRef(); |
1023 | (*iface)->addRef(); | ||
1024 | return QS_OK; | 1094 | return QS_OK; |
1025 | } | 1095 | } |
1026 | 1096 | ||
1027 | Q_EXPORT_INTERFACE() | 1097 | Q_EXPORT_INTERFACE() |
1028 | { | 1098 | { |
1029 | Q_CREATE_INSTANCE( FlatStyleImpl ) | 1099 | Q_CREATE_INSTANCE( FlatStyleImpl ) |
1030 | } | 1100 | } |
1031 | 1101 | ||
1032 | #include "flat.moc" | 1102 | #include "flat.moc" |