summaryrefslogtreecommitdiff
path: root/library/lightstyle.cpp
Unidiff
Diffstat (limited to 'library/lightstyle.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/lightstyle.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/library/lightstyle.cpp b/library/lightstyle.cpp
index f18bdca..3bd1623 100644
--- a/library/lightstyle.cpp
+++ b/library/lightstyle.cpp
@@ -1,46 +1,46 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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#include "lightstyle.h" 20#include "lightstyle.h"
21 21
22#if QT_VERSION < 300 22#if QT_VERSION < 0x030000
23 23
24#define INCLUDE_MENUITEM_DEF 24#define INCLUDE_MENUITEM_DEF
25#include "qmenubar.h" 25#include "qmenubar.h"
26#include "qapplication.h" 26#include "qapplication.h"
27#include "qpainter.h" 27#include "qpainter.h"
28#include "qpalette.h" 28#include "qpalette.h"
29#include "qframe.h" 29#include "qframe.h"
30#include "qpushbutton.h" 30#include "qpushbutton.h"
31#include "qdrawutil.h" 31#include "qdrawutil.h"
32#include "qscrollbar.h" 32#include "qscrollbar.h"
33#include "qtabbar.h" 33#include "qtabbar.h"
34#include "qguardedptr.h" 34#include "qguardedptr.h"
35#include "qlayout.h" 35#include "qlayout.h"
36#include "qlineedit.h" 36#include "qlineedit.h"
37 37
38 38
39class LightStylePrivate 39class LightStylePrivate
40{ 40{
41public: 41public:
42 LightStylePrivate() 42 LightStylePrivate()
43 : hoverWidget(0), ref(1), savePalette(0) 43 : hoverWidget(0), ref(1), savePalette(0)
44 { 44 {
45 } 45 }
46 46
@@ -138,66 +138,66 @@ int LightStyle::buttonMargin() const
138 138
139QSize LightStyle::exclusiveIndicatorSize() const 139QSize LightStyle::exclusiveIndicatorSize() const
140{ 140{
141 return QSize(13, 13); 141 return QSize(13, 13);
142} 142}
143 143
144 144
145int LightStyle::defaultFrameWidth() const 145int LightStyle::defaultFrameWidth() const
146{ 146{
147 return 2; 147 return 2;
148} 148}
149 149
150 150
151QSize LightStyle::indicatorSize() const 151QSize LightStyle::indicatorSize() const
152{ 152{
153 return QSize(13, 13); 153 return QSize(13, 13);
154} 154}
155 155
156 156
157void LightStyle::polish(QWidget *widget) 157void LightStyle::polish(QWidget *widget)
158{ 158{
159 if (widget->inherits("QPushButton")) 159 if (widget->inherits("QPushButton"))
160 widget->installEventFilter(this); 160 widget->installEventFilter(this);
161 161
162#if QT_VERSION >= 300 162#if QT_VERSION >= 0x030000
163 if (widget->inherits("QLineEdit")) { 163 if (widget->inherits("QLineEdit")) {
164 QLineEdit *lineedit = (QLineEdit *) widget; 164 QLineEdit *lineedit = (QLineEdit *) widget;
165 lineedit->setFrameShape(QFrame::StyledPanel); 165 lineedit->setFrameShape(QFrame::StyledPanel);
166 lineedit->setLineWidth(2); 166 lineedit->setLineWidth(2);
167 } 167 }
168#endif 168#endif
169 169
170 QWindowsStyle::polish(widget); 170 QWindowsStyle::polish(widget);
171} 171}
172 172
173 173
174void LightStyle::unPolish(QWidget *widget) 174void LightStyle::unPolish(QWidget *widget)
175{ 175{
176 if (widget->inherits("QPushButton")) 176 if (widget->inherits("QPushButton"))
177 widget->removeEventFilter(this); 177 widget->removeEventFilter(this);
178 178
179#if QT_VERSION >= 300 179#if QT_VERSION >= 0x030000
180 if (widget->inherits("QLineEdit")) { 180 if (widget->inherits("QLineEdit")) {
181 QLineEdit *lineedit = (QLineEdit *) widget; 181 QLineEdit *lineedit = (QLineEdit *) widget;
182 lineedit->setLineWidth(1); 182 lineedit->setLineWidth(1);
183 lineedit->setFrameShape(QFrame::WinPanel); 183 lineedit->setFrameShape(QFrame::WinPanel);
184 } 184 }
185#endif 185#endif
186 186
187 QWindowsStyle::unPolish(widget); 187 QWindowsStyle::unPolish(widget);
188} 188}
189 189
190 190
191void LightStyle::polish(QApplication *app) 191void LightStyle::polish(QApplication *app)
192{ 192{
193 QPalette pal = app->palette(); 193 QPalette pal = app->palette();
194 194
195 QColorGroup active(pal.color(QPalette::Active, 195 QColorGroup active(pal.color(QPalette::Active,
196 QColorGroup::Foreground), // foreground 196 QColorGroup::Foreground), // foreground
197 pal.color(QPalette::Active, 197 pal.color(QPalette::Active,
198 QColorGroup::Button), // button 198 QColorGroup::Button), // button
199 pal.color(QPalette::Active, 199 pal.color(QPalette::Active,
200 QColorGroup::Background).light(), // light 200 QColorGroup::Background).light(), // light
201 pal.color(QPalette::Active, 201 pal.color(QPalette::Active,
202 QColorGroup::Background).dark(175), // dark 202 QColorGroup::Background).dark(175), // dark
203 pal.color(QPalette::Active, 203 pal.color(QPalette::Active,
@@ -393,66 +393,66 @@ void LightStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
393void LightStyle::getButtonShift(int &x, int &y) const 393void LightStyle::getButtonShift(int &x, int &y) const
394{ 394{
395 x = y = 0; 395 x = y = 0;
396} 396}
397 397
398 398
399void LightStyle::drawComboButton(QPainter *p, int x, int y, int w, int h, 399void LightStyle::drawComboButton(QPainter *p, int x, int y, int w, int h,
400 const QColorGroup &g, bool, 400 const QColorGroup &g, bool,
401 bool editable, bool, 401 bool editable, bool,
402 const QBrush *fill) 402 const QBrush *fill)
403{ 403{
404 drawButton(p, x, y, w, h, g, FALSE, fill); 404 drawButton(p, x, y, w, h, g, FALSE, fill);
405 405
406 if (editable) { 406 if (editable) {
407 QRect r = comboButtonRect(x, y, w, h); 407 QRect r = comboButtonRect(x, y, w, h);
408 qDrawShadePanel(p, r.x() - 1, r.y() - 1, 408 qDrawShadePanel(p, r.x() - 1, r.y() - 1,
409 r.width() + defaultFrameWidth(), 409 r.width() + defaultFrameWidth(),
410 r.height() + defaultFrameWidth(), 410 r.height() + defaultFrameWidth(),
411 g, TRUE); 411 g, TRUE);
412 } 412 }
413 413
414 int indent = ((y + h) / 2) - 3; 414 int indent = ((y + h) / 2) - 3;
415 int xpos = x; 415 int xpos = x;
416 416
417#if QT_VERSION >= 300 417#if QT_VERSION >= 0x030000
418 if( QApplication::reverseLayout() ) 418 if( QApplication::reverseLayout() )
419 xpos += indent; 419 xpos += indent;
420 else 420 else
421#endif 421#endif
422 xpos += w - indent - 5; 422 xpos += w - indent - 5;
423 423
424 drawArrow(p, Qt::DownArrow, TRUE, xpos, indent, 5, 5, g, TRUE, fill); 424 drawArrow(p, Qt::DownArrow, TRUE, xpos, indent, 5, 5, g, TRUE, fill);
425} 425}
426 426
427 427
428QRect LightStyle::comboButtonRect( int x, int y, int w, int h ) const 428QRect LightStyle::comboButtonRect( int x, int y, int w, int h ) const
429{ 429{
430 QRect r(x + 3, y + 3, w - 6, h - 6); 430 QRect r(x + 3, y + 3, w - 6, h - 6);
431 int indent = ((y + h) / 2) - 3; 431 int indent = ((y + h) / 2) - 3;
432 r.setRight(r.right() - indent - 10); 432 r.setRight(r.right() - indent - 10);
433 433
434#if QT_VERSION >= 300 434#if QT_VERSION >= 0x030000
435 if( QApplication::reverseLayout() ) 435 if( QApplication::reverseLayout() )
436 r.moveBy( indent + 10, 0 ); 436 r.moveBy( indent + 10, 0 );
437#endif 437#endif
438 438
439 return r; 439 return r;
440} 440}
441 441
442 442
443QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h ) const 443QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h ) const
444{ 444{
445 return comboButtonRect(x, y, w, h); 445 return comboButtonRect(x, y, w, h);
446} 446}
447 447
448 448
449void LightStyle::drawPanel(QPainter *p, int x, int y, int w, int h, 449void LightStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
450 const QColorGroup &g, bool sunken, 450 const QColorGroup &g, bool sunken,
451 int lw, const QBrush *fill) 451 int lw, const QBrush *fill)
452{ 452{
453 if (lw >= 2) { 453 if (lw >= 2) {
454 if ( fill ) 454 if ( fill )
455 p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill); 455 p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill);
456 456
457 QPen oldpen = p->pen(); 457 QPen oldpen = p->pen();
458 458