summaryrefslogtreecommitdiff
path: root/noncore/styles
Side-by-side diff
Diffstat (limited to 'noncore/styles') (more/less context) (show whitespace changes)
-rw-r--r--noncore/styles/flat/flat.cpp10
-rw-r--r--noncore/styles/fresh/fresh.cpp8
-rw-r--r--noncore/styles/liquid/liquid.cpp15
-rw-r--r--noncore/styles/phase/phasestyle.cpp14
-rw-r--r--noncore/styles/theme/othemestyle.cpp11
-rw-r--r--noncore/styles/web/webstyle.cpp126
-rw-r--r--noncore/styles/web/webstyle.h2
7 files changed, 165 insertions, 21 deletions
diff --git a/noncore/styles/flat/flat.cpp b/noncore/styles/flat/flat.cpp
index f3bacf9..c164ecc 100644
--- a/noncore/styles/flat/flat.cpp
+++ b/noncore/styles/flat/flat.cpp
@@ -370,13 +370,13 @@ void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
if ( btn->iconSet() && !btn->iconSet()->isNull() ) {
QIconSet::Mode mode = btn->isEnabled()
? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && btn->hasFocus() )
mode = QIconSet::Active;
- QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode );
+ QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Automatic, mode );
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( x+2, y+h/2-pixh/2, pixmap );
x += pixw + 4;
w -= pixw + 4;
}
@@ -899,13 +899,13 @@ int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFo
else if ( mi->pixmap() ) // pixmap height
h = mi->pixmap()->height() + 2*motifItemFrame;
else // text height
h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
- h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame );
+ h = QMAX( h, mi->iconSet()->pixmap().height() + 2*motifItemFrame );
}
if ( mi->custom() )
h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
return h;
#endif
}
@@ -951,13 +951,17 @@ void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int
}
if ( mi->iconSet() ) { // draw iconset
QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
if (act && !dis )
mode = QIconSet::Active;
- QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = mi->iconSet()->pixmap();
int pixw = pixmap.width();
int pixh = pixmap.height();
if ( act && !dis ) {
if ( !mi->isChecked() )
qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
}
diff --git a/noncore/styles/fresh/fresh.cpp b/noncore/styles/fresh/fresh.cpp
index 831b620..856f68b 100644
--- a/noncore/styles/fresh/fresh.cpp
+++ b/noncore/styles/fresh/fresh.cpp
@@ -645,13 +645,13 @@ int FreshStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QF
else if ( mi->pixmap() ) // pixmap height
h = mi->pixmap()->height() + 2*motifItemFrame;
else // text height
h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
- h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame );
+ h = QMAX( h, mi->iconSet()->pixmap().height() + 2*motifItemFrame );
}
if ( mi->custom() )
h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
return h;
#endif
}
@@ -699,13 +699,17 @@ void FreshStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int
}
if ( mi->iconSet() ) { // draw iconset
QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
if (act && !dis )
mode = QIconSet::Active;
- QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = mi->iconSet()->pixmap();
int pixw = pixmap.width();
int pixh = pixmap.height();
if ( act && !dis ) {
if ( !mi->isChecked() )
qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
}
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 51814e7..77cf198 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1300,13 +1300,17 @@ void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
if ( btn->iconSet() && !btn->iconSet()->isNull() )
{
QIconSet::Mode mode = btn->isEnabled()
? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && btn->hasFocus() )
mode = QIconSet::Active;
- QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode );
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = btn->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = btn->iconSet()->pixmap();
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap );
x1 += pixw + 8;
w -= pixw + 8;
@@ -2152,13 +2156,17 @@ static const int windowsRightBorder = 12;
return;
}
if(mi->iconSet()) {
QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal;
if (!dis)
mode = QIconSet::Active;
- QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode);
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = mi->iconSet()->pixmap();
int pixw = pixmap.width();
int pixh = pixmap.height();
QRect cr(x, y, checkcol, h);
QRect pmr(0, 0, pixw, pixh);
pmr.moveCenter( cr.center() );
p->setPen(itemg.highlightedText());
@@ -2233,14 +2241,13 @@ int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi,
int h = 0;
if (mi->pixmap())
h = mi->pixmap()->height();
if (mi->iconSet())
- h = QMAX(mi->iconSet()->
- pixmap(QIconSet::Small, QIconSet::Normal).height(), h);
+ h = QMAX(mi->iconSet()->pixmap().height(), h);
h = QMAX(fm.height() + 4, h);
// we want a minimum size of 18
h = QMAX(h, 18);
diff --git a/noncore/styles/phase/phasestyle.cpp b/noncore/styles/phase/phasestyle.cpp
index 746354e..c2b9de8 100644
--- a/noncore/styles/phase/phasestyle.cpp
+++ b/noncore/styles/phase/phasestyle.cpp
@@ -387,13 +387,16 @@ void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) {
state = true;
} else {
state = false;
}
#endif
- pixmap = button->iconSet()->pixmap(QIconSet::Small, mode);
+ if ( mode == QIconSet::Disabled )
+ pixmap = button->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = button->iconSet()->pixmap();
if (button->text().isEmpty() && !button->pixmap()) {
painter->drawPixmap(x+w/2 - pixmap.width()/2,
y+h/2 - pixmap.height()/2, pixmap);
} else {
painter->drawPixmap(x+4, y+h/2 - pixmap.height()/2, pixmap);
}
@@ -566,14 +569,13 @@ int PhaseStyle::popupMenuItemHeight ( bool ,
}else {
h = QMAX(h, MINICONSIZE+ITEMFRAME*2 );
h = QMAX(h, fm.height()
+ ITEMVMARGIN*2 + ITEMFRAME*2 );
}
if ( mi->iconSet() )
- h = QMAX(h, mi->iconSet()->
- pixmap(QIconSet::Small, QIconSet::Normal ).height()
+ h = QMAX(h, mi->iconSet()->pixmap().height()
+ ITEMFRAME*2 );
}
return h;
}
@@ -658,13 +660,17 @@ void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable,
QIconSet::Mode mode;
if ( mi->iconSet() && !mi->isChecked() ) {
if ( act )
mode = enabled ? QIconSet::Active : QIconSet::Disabled;
else
mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
- QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode );
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = mi->iconSet()->pixmap();
QRect pmrect(0, 0, pixmap.width(), pixmap.height() );
QRect cr(x, y, maxpmw, h );
pmrect.moveCenter( cr.center() );
p->drawPixmap(pmrect.topLeft(), pixmap);
}
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp
index 98e7253..106d206 100644
--- a/noncore/styles/theme/othemestyle.cpp
+++ b/noncore/styles/theme/othemestyle.cpp
@@ -1180,13 +1180,13 @@ void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
// Next, draw iconset, if any
if ( btn->iconSet() && !btn->iconSet() ->isNull() ) {
QIconSet::Mode mode = btn->isEnabled()
? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && btn->hasFocus() )
mode = QIconSet::Active;
- QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode );
+ QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Automatic, mode );
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap );
x += pixw + 8;
w -= pixw + 8;
@@ -1243,14 +1243,13 @@ int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi,
offset + 16;
if ( mi->pixmap() ) {
h2 = mi->pixmap() ->height() + offset;
h = h2 > h ? h2 : h;
}
if ( mi->iconSet() ) {
- h2 = mi->iconSet() ->
- pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset;
+ h2 = mi->iconSet() ->pixmap().height() + offset;
h = h2 > h ? h2 : h;
}
h2 = fm.height() + offset;
h = h2 > h ? h2 : h;
return ( h );
}
@@ -1322,13 +1321,17 @@ void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
if ( !mi )
return ;
if ( mi->iconSet() ) {
QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
if ( act && !dis )
mode = QIconSet::Active;
- QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode );
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = mi->iconSet()->pixmap();
int pixw = pixmap.width();
int pixh = pixmap.height();
QRect cr( x, y, checkcol, h );
QRect pmr( 0, 0, pixw, pixh );
pmr.moveCenter( cr.center() );
p->setPen( itemg.text() );
diff --git a/noncore/styles/web/webstyle.cpp b/noncore/styles/web/webstyle.cpp
index cd3cf08..7b58d89 100644
--- a/noncore/styles/web/webstyle.cpp
+++ b/noncore/styles/web/webstyle.cpp
@@ -40,12 +40,21 @@ static const int _scrollBarExtent = 12;
static QFrame * _currentFrame = 0;
static int _savedFrameLineWidth;
static int _savedFrameMidLineWidth;
static ulong _savedFrameStyle;
+static const int ITEMFRAME = 1; // menu stuff
+static const int ITEMHMARGIN = 3;
+static const int ITEMVMARGIN = 0;
+
+static const int ARROWMARGIN = 6;
+static const int RIGHTBORDER = 10;
+static const int MINICONSIZE = 12;
+
+
static QColor contrastingForeground(const QColor & fg, const QColor & bg)
{
int h, s, vbg, vfg;
bg.hsv(&h, &s, &vbg);
fg.hsv(&h, &s, &vfg);
@@ -966,25 +975,136 @@ WebStyle::drawSlider
void
WebStyle::drawPopupMenuItem
(
QPainter * p,
bool checkable,
int maxpmw,
- int tab,
+ int tabwidth,
QMenuItem * mi,
const QPalette & pal,
bool act,
bool enabled,
int x,
int y,
int w,
int h
)
{
// TODO
- QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h);
+ //QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h);
+ if ( !mi )
+ return;
+
+ QRect rect(x, y, w, h );
+ int x2, y2;
+ x2 = rect.right();
+ y2 = rect.bottom();
+ const QColorGroup& g = pal.active();
+ QColorGroup itemg = !enabled ? pal.disabled() : pal.active();
+
+ if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20);
+
+ if (act && enabled )
+ p->fillRect(x, y, w, h, g.highlight() );
+ else
+ p->fillRect(x, y, w, h, g.background() );
+
+ // draw seperator
+ if (mi->isSeparator() ) {
+ p->setPen( g.dark() );
+ p->drawLine( x+8, y+1, x+w-8, y+1 );
+
+ p->setPen( g.mid() );
+ p->drawLine( x+8, y, x+w-8, y );
+ p->drawPoint(x+w,y+1);
+
+ p->setPen( g.midlight() );
+ p->drawLine( x+8, y-1, x+w-8, y-1 );
+ p->drawPoint(x+8, y );
+ return;
+ }
+
+ // draw icon
+ QIconSet::Mode mode;
+ if ( mi->iconSet() && !mi->isChecked() ) {
+ if ( act )
+ mode = enabled ? QIconSet::Active : QIconSet::Disabled;
+ else
+ mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = mi->iconSet()->pixmap();
+ QRect pmrect(0, 0, pixmap.width(), pixmap.height() );
+ QRect cr(x, y, maxpmw, h );
+ pmrect.moveCenter( cr.center() );
+ p->drawPixmap(pmrect.topLeft(), pixmap);
+ }
+
+ // draw check
+ if(mi->isChecked() ) {
+ drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled );
+ }
+
+
+ // draw text
+ int xm = maxpmw + 2;
+ int xp = x + xm;
+ int tw = w -xm - 2;
+
+ p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) :
+ g.mid() );
+
+
+ if ( mi->custom() ) {
+ p->save();
+ mi->custom()->paint(p, g, act, enabled,
+ xp, y+1, tw, h-2 );
+ p->restore();
+ }else { // draw label
+ QString text = mi->text();
+ if (!text.isNull() ) {
+ int t = text.find('\t');
+ const int tflags = AlignVCenter | DontClip |
+ ShowPrefix | SingleLine |
+ AlignLeft;
+
+ if (t >= 0) {
+ int tabx = x + w - tabwidth - RIGHTBORDER -
+ ITEMHMARGIN - ITEMFRAME;
+ p->drawText(tabx, y+ITEMVMARGIN, tabwidth,
+ h-2*ITEMVMARGIN, tflags,
+ text.mid(t+1) );
+ text = text.left(t );
+ }
+
+ // draw left label
+ p->drawText(xp, y+ITEMVMARGIN,
+ tw, h-2*ITEMVMARGIN,
+ tflags, text, t);
+ }else if ( mi->pixmap() ) { // pixmap as label
+ QPixmap pixmap = *mi->pixmap();
+ if ( pixmap.depth() == 1 )
+ p->setBackgroundMode( OpaqueMode );
+
+ int dx = ((w-pixmap.width() ) /2 ) +
+ ((w - pixmap.width()) %2 );
+ p->drawPixmap(x+dx, y+ITEMFRAME, pixmap );
+
+ if ( pixmap.depth() == 1 )
+ p->setBackgroundMode( TransparentMode );
+ }
+ }
+
+ if ( mi->popup() ) { // draw submenu arrow
+ int dim = (h-2*ITEMFRAME) / 2;
+ drawArrow( p, RightArrow, false,
+ x+w-ARROWMARGIN-ITEMFRAME-dim,
+ y+h/2-dim/2, dim, dim, g, enabled );
+ }
}
void
WebStyle::drawFocusRect
(
QPainter * p,
@@ -1165,13 +1285,13 @@ WebStyle::popupMenuItemHeight(bool, QMenuItem * i, const QFontMetrics & fm)
}
if (0 != i->iconSet())
{
h = QMAX
(
- i->iconSet()->pixmap(QIconSet::Small, QIconSet::Normal).height(),
+ i->iconSet()->pixmap().height(),
h
);
}
h = QMAX(fm.height() + 4, h);
diff --git a/noncore/styles/web/webstyle.h b/noncore/styles/web/webstyle.h
index 83ab784..d6f153b 100644
--- a/noncore/styles/web/webstyle.h
+++ b/noncore/styles/web/webstyle.h
@@ -212,13 +212,13 @@ class WebStyle : public QWindowsStyle {
void drawPopupMenuItem
(
QPainter *,
bool checkable,
int maxpmw,
- int tab,
+ int tabwidth,
QMenuItem *,
const QPalette &,
bool act,
bool enabled,
int x,
int y,