summaryrefslogtreecommitdiff
path: root/noncore/styles/flat
Unidiff
Diffstat (limited to 'noncore/styles/flat') (more/less context) (show whitespace changes)
-rw-r--r--noncore/styles/flat/flat.cpp102
-rw-r--r--noncore/styles/flat/flat.h6
2 files changed, 91 insertions, 17 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,3 +59,4 @@ 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 ) {
61 if ( o->inherits( "QMenuBar" ) ) {
58 QWidget *w = (QWidget *)o; 62 QWidget *w = (QWidget *)o;
@@ -67,2 +71,13 @@ public:
67 } 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 }
82 }
68 } 83 }
@@ -70,5 +85,7 @@ public:
70 } 85 }
86
87 QMap<QFrame *,int> frameStyles;
71}; 88};
72 89
73FlatStyle::FlatStyle() : revItem(FALSE) 90FlatStyle::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 }
@@ -126,3 +154,5 @@ void FlatStyle::unPolish( QWidget *w )
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 );
@@ -130,5 +160,6 @@ void FlatStyle::unPolish( QWidget *w )
130 } 160 }
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
850void 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,4 +1089,5 @@ 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 )
1023 (*iface)->addRef(); 1093 (*iface)->addRef();
diff --git a/noncore/styles/flat/flat.h b/noncore/styles/flat/flat.h
index e446800..ebea95b 100644
--- a/noncore/styles/flat/flat.h
+++ b/noncore/styles/flat/flat.h
@@ -23,2 +23,3 @@
23 23
24#include <qcolor.h>
24#include <qwindowsstyle.h> 25#include <qwindowsstyle.h>
@@ -28,3 +29,3 @@ class FlatStylePrivate;
28 29
29class Q_EXPORT FlatStyle : public QWindowsStyle 30class FlatStyle : public QWindowsStyle
30{ 31{
@@ -75,2 +76,3 @@ public:
75 void drawTab( QPainter *, const QTabBar *, QTab *, bool selected ); 76 void drawTab( QPainter *, const QTabBar *, QTab *, bool selected );
77 void polishPopupMenu ( QPopupMenu * );
76 int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& ); 78 int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& );
@@ -88,2 +90,4 @@ private:
88 bool revItem; 90 bool revItem;
91 bool fillBtnBorder;
92 QColor btnBg;
89 // Disabled copy constructor and operator= 93 // Disabled copy constructor and operator=