author | kergoth <kergoth> | 2003-08-09 17:14:54 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 17:14:54 (UTC) |
commit | a7e015198a8c5ad3b6e144a9032b059086253e00 (patch) (unidiff) | |
tree | b712b6f11310d88744fe393a92b3160b741a7efe /noncore/styles/flat/flat.cpp | |
parent | beba0e73306815337bf04dee39502233595e9739 (diff) | |
download | opie-a7e015198a8c5ad3b6e144a9032b059086253e00.zip opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.gz opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.bz2 |
Merge from BRANCH_1_0
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 | |||
@@ -20,4 +20,3 @@ | |||
20 | 20 | ||
21 | #include "flat.h" | 21 | #include <qtopia/qpeapplication.h> |
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
@@ -34,2 +33,3 @@ | |||
34 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qmap.h> | ||
35 | 35 | ||
@@ -37,2 +37,5 @@ | |||
37 | #include <qmenudata.h> | 37 | #include <qmenudata.h> |
38 | #include <qpopupmenu.h> | ||
39 | |||
40 | #include "flat.h" | ||
38 | 41 | ||
@@ -56,12 +59,24 @@ public: | |||
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 | } |
@@ -70,5 +85,7 @@ public: | |||
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 | { |
@@ -103,3 +120,5 @@ void FlatStyle::polish( QWidget *w ) | |||
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 ); |
@@ -119,2 +138,11 @@ void FlatStyle::polish( QWidget *w ) | |||
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 | } |
@@ -124,11 +152,14 @@ 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(); |
@@ -140,3 +171,3 @@ int FlatStyle::defaultFrameWidth() const | |||
140 | { | 171 | { |
141 | return 1; | 172 | return 2; |
142 | } | 173 | } |
@@ -173,4 +204,23 @@ void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h, | |||
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; |
@@ -178,7 +228,2 @@ void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h, | |||
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() ); |
@@ -227,2 +272,12 @@ void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, | |||
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() ); |
@@ -233,2 +288,3 @@ void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, | |||
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 | } |
@@ -259,2 +315,7 @@ void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p ) | |||
259 | 315 | ||
316 | if ( btn->parentWidget() ) { | ||
317 | btnBg = btn->parentWidget()->backgroundColor(); | ||
318 | fillBtnBorder = TRUE; | ||
319 | } | ||
320 | |||
260 | bool clearButton = TRUE; | 321 | bool clearButton = TRUE; |
@@ -285,2 +346,3 @@ void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p ) | |||
285 | 346 | ||
347 | fillBtnBorder = FALSE; | ||
286 | if ( p->brush().style() != NoBrush ) | 348 | if ( p->brush().style() != NoBrush ) |
@@ -591,3 +653,4 @@ void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sl | |||
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() ); |
@@ -786,2 +849,8 @@ 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 |
@@ -1010,3 +1079,3 @@ QString FlatStyleImpl::name() const | |||
1010 | { | 1079 | { |
1011 | return QString("Flat"); | 1080 | return qApp->translate("FlatStyle", "Flat", "Name of the style Flat"); |
1012 | } | 1081 | } |
@@ -1020,5 +1089,6 @@ QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **if | |||
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; |