author | kergoth <kergoth> | 2003-08-09 17:14:54 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 17:14:54 (UTC) |
commit | a7e015198a8c5ad3b6e144a9032b059086253e00 (patch) (side-by-side diff) | |
tree | b712b6f11310d88744fe393a92b3160b741a7efe /noncore/styles/flat | |
parent | beba0e73306815337bf04dee39502233595e9739 (diff) | |
download | opie-a7e015198a8c5ad3b6e144a9032b059086253e00.zip opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.gz opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.bz2 |
Merge from BRANCH_1_0
-rw-r--r-- | noncore/styles/flat/flat.cpp | 102 | ||||
-rw-r--r-- | noncore/styles/flat/flat.h | 6 |
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 @@ -#include "flat.h" -#include <qpe/qpeapplication.h> +#include <qtopia/qpeapplication.h> #include <qpushbutton.h> @@ -34,2 +33,3 @@ #include <qlineedit.h> +#include <qmap.h> @@ -37,2 +37,5 @@ #include <qmenudata.h> +#include <qpopupmenu.h> + +#include "flat.h" @@ -56,3 +59,4 @@ public: bool eventFilter( QObject *o, QEvent *e ) { - if ( e->type() == QEvent::ParentPaletteChange && o->inherits( "QMenuBar" ) ) { + if ( e->type() == QEvent::ParentPaletteChange ) { + if ( o->inherits( "QMenuBar" ) ) { QWidget *w = (QWidget *)o; @@ -67,2 +71,13 @@ public: } + } else if ( o->inherits( "QHeader" ) ) { + QWidget *w = (QWidget *)o; + if ( w->parentWidget() ) { + QPalette p = w->parentWidget()->palette(); + QColorGroup a = p.active(); + a.setColor( QColorGroup::Light, a.button() ); + p.setActive( a ); + p.setInactive( a ); + w->setPalette( p ); + } + } } @@ -70,5 +85,7 @@ public: } + + QMap<QFrame *,int> frameStyles; }; -FlatStyle::FlatStyle() : revItem(FALSE) +FlatStyle::FlatStyle() : revItem(FALSE), fillBtnBorder(FALSE) { @@ -103,3 +120,5 @@ void FlatStyle::polish( QWidget *w ) QFrame *f = (QFrame *)w; - if ( f->frameShape() != QFrame::NoFrame ) + if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) + f->setFrameShadow( QFrame::Plain ); + else if ( f->frameShape() != QFrame::NoFrame ) f->setFrameShape( QFrame::StyledPanel ); @@ -119,2 +138,11 @@ void FlatStyle::polish( QWidget *w ) w->installEventFilter( d ); + } else if ( w->inherits( "QHeader" ) ) { + // make headers look flat + QPalette p = w->palette(); + QColorGroup a = p.active(); + a.setColor( QColorGroup::Light, a.button() ); + p.setActive( a ); + p.setInactive( a ); + w->setPalette( p ); + w->installEventFilter( d ); } @@ -126,3 +154,5 @@ void FlatStyle::unPolish( QWidget *w ) QFrame *f = (QFrame *)w; - if ( f->frameShape() != QFrame::NoFrame ) + if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) { + f->setFrameShadow( QFrame::Sunken ); + } else if ( f->frameShape() != QFrame::NoFrame ) { f->setFrameShape( QFrame::StyledPanel ); @@ -130,5 +160,6 @@ void FlatStyle::unPolish( QWidget *w ) } + } if ( w->inherits( "QSpinBox" ) ) ((SpinBoxHack*)w)->setFlatButtons( FALSE ); - if ( w->inherits( "QMenuBar" ) ) { + if ( w->inherits("QMenuBar") || w->inherits("QHeader") ) { w->unsetPalette(); @@ -140,3 +171,3 @@ int FlatStyle::defaultFrameWidth() const { - return 1; + return 2; } @@ -173,4 +204,23 @@ void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h, + int x2 = x+w-1; + int y2 = y+h-1; + + if ( fillBtnBorder && btnBg != cg.color(QColorGroup::Button) ) { + p->setPen( btnBg ); + p->drawLine( x, y, x2, y ); + p->drawLine( x, y2, x2, y2 ); + p->drawLine( x, y+1, x, y2-1 ); + p->drawLine( x2, y+1, x2, y2-1 ); + p->fillRect( x+1, y+1, 3, 3, btnBg ); + p->fillRect( x+1, y2-3, 3, 3, btnBg ); + p->fillRect( x2-3, y2-3, 3, 3, btnBg ); + p->fillRect( x2-3, y+1, 3, 3, btnBg ); + p->fillRect( x+2, y+2, w-4, h-4, fill?(*fill):cg.brush(QColorGroup::Button) ); + } else { + p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) ); + } + if ( h >= 10 ) { x++; y++; + x2--; y2--; w -= 2; h -= 2; @@ -178,7 +228,2 @@ void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h, - p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) ); - - int x2 = x+w-1; - int y2 = y+h-1; - p->setPen( cg.foreground() ); @@ -227,2 +272,12 @@ void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, { + if ( p->device()->devType() == QInternal::Widget ) { + QWidget *w = (QWidget *)p->device(); + if ( w->isA("QToolButton") ) { + QToolButton *btn = (QToolButton *)w; + if ( btn->parentWidget() ) { + btnBg = btn->parentWidget()->backgroundColor(); + fillBtnBorder = TRUE; + } + } + } QBrush fb( fill ? *fill : g.button() ); @@ -233,2 +288,3 @@ void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, drawButton( p, x, y, w, h, g, sunken, &fb ); + fillBtnBorder = FALSE; } @@ -259,2 +315,7 @@ void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p ) + if ( btn->parentWidget() ) { + btnBg = btn->parentWidget()->backgroundColor(); + fillBtnBorder = TRUE; + } + bool clearButton = TRUE; @@ -285,2 +346,3 @@ void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p ) + fillBtnBorder = FALSE; if ( p->brush().style() != NoBrush ) @@ -591,3 +653,4 @@ void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sl p->drawRect( subPageR.x(), subPageR.y(), subPageR.width(), subPageR.height() ); - if ( controls & AddPage && addPageR.y() < addPageR.bottom() ) + if ( controls & AddPage && addPageR.y() < addPageR.bottom() && + addPageR.x() < addPageR.right() ) p->drawRect( addPageR.x(), addPageR.y(), addPageR.width(), addPageR.height() ); @@ -786,2 +849,8 @@ static const int windowsCheckMarkWidth = 2; // checkmarks width on windows +void FlatStyle::polishPopupMenu ( QPopupMenu *m ) +{ + QWindowsStyle::polishPopupMenu( m ); + m->setLineWidth( 1 ); +} + /*! \reimp @@ -1010,3 +1079,3 @@ QString FlatStyleImpl::name() const { - return QString("Flat"); + return qApp->translate("FlatStyle", "Flat", "Name of the style Flat"); } @@ -1020,4 +1089,5 @@ QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **if *iface = this; + else + return QS_FALSE; - if ( *iface ) (*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 @@ +#include <qcolor.h> #include <qwindowsstyle.h> @@ -28,3 +29,3 @@ class FlatStylePrivate; -class Q_EXPORT FlatStyle : public QWindowsStyle +class FlatStyle : public QWindowsStyle { @@ -75,2 +76,3 @@ public: void drawTab( QPainter *, const QTabBar *, QTab *, bool selected ); + void polishPopupMenu ( QPopupMenu * ); int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& ); @@ -88,2 +90,4 @@ private: bool revItem; + bool fillBtnBorder; + QColor btnBg; // Disabled copy constructor and operator= |