author | drw <drw> | 2005-04-14 18:30:23 (UTC) |
---|---|---|
committer | drw <drw> | 2005-04-14 18:30:23 (UTC) |
commit | 5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf (patch) (unidiff) | |
tree | d4ba8a948d876db9bbff10cbd282fd16aab91feb /noncore/styles/web/webstyle.cpp | |
parent | 7a3b813cc3bfbb2f7c31f347c35405851e82aecf (diff) | |
download | opie-5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf.zip opie-5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf.tar.gz opie-5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf.tar.bz2 |
More icon sizing updates
Diffstat (limited to 'noncore/styles/web/webstyle.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/styles/web/webstyle.cpp | 126 |
1 files changed, 123 insertions, 3 deletions
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 | |||
@@ -43,6 +43,15 @@ static int _savedFrameLineWidth; | |||
43 | static int _savedFrameMidLineWidth; | 43 | static int _savedFrameMidLineWidth; |
44 | static ulong _savedFrameStyle; | 44 | static ulong _savedFrameStyle; |
45 | 45 | ||
46 | static const int ITEMFRAME = 1; // menu stuff | ||
47 | static const int ITEMHMARGIN = 3; | ||
48 | static const int ITEMVMARGIN = 0; | ||
49 | |||
50 | static const int ARROWMARGIN = 6; | ||
51 | static const int RIGHTBORDER = 10; | ||
52 | static const int MINICONSIZE = 12; | ||
53 | |||
54 | |||
46 | static QColor contrastingForeground(const QColor & fg, const QColor & bg) | 55 | static QColor contrastingForeground(const QColor & fg, const QColor & bg) |
47 | { | 56 | { |
48 | int h, s, vbg, vfg; | 57 | int h, s, vbg, vfg; |
@@ -969,7 +978,7 @@ WebStyle::drawPopupMenuItem | |||
969 | QPainter * p, | 978 | QPainter * p, |
970 | bool checkable, | 979 | bool checkable, |
971 | int maxpmw, | 980 | int maxpmw, |
972 | int tab, | 981 | int tabwidth, |
973 | QMenuItem * mi, | 982 | QMenuItem * mi, |
974 | const QPalette & pal, | 983 | const QPalette & pal, |
975 | bool act, | 984 | bool act, |
@@ -981,7 +990,118 @@ WebStyle::drawPopupMenuItem | |||
981 | ) | 990 | ) |
982 | { | 991 | { |
983 | // TODO | 992 | // TODO |
984 | QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h); | 993 | //QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h); |
994 | if ( !mi ) | ||
995 | return; | ||
996 | |||
997 | QRect rect(x, y, w, h ); | ||
998 | int x2, y2; | ||
999 | x2 = rect.right(); | ||
1000 | y2 = rect.bottom(); | ||
1001 | const QColorGroup& g = pal.active(); | ||
1002 | QColorGroup itemg = !enabled ? pal.disabled() : pal.active(); | ||
1003 | |||
1004 | if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20); | ||
1005 | |||
1006 | if (act && enabled ) | ||
1007 | p->fillRect(x, y, w, h, g.highlight() ); | ||
1008 | else | ||
1009 | p->fillRect(x, y, w, h, g.background() ); | ||
1010 | |||
1011 | // draw seperator | ||
1012 | if (mi->isSeparator() ) { | ||
1013 | p->setPen( g.dark() ); | ||
1014 | p->drawLine( x+8, y+1, x+w-8, y+1 ); | ||
1015 | |||
1016 | p->setPen( g.mid() ); | ||
1017 | p->drawLine( x+8, y, x+w-8, y ); | ||
1018 | p->drawPoint(x+w,y+1); | ||
1019 | |||
1020 | p->setPen( g.midlight() ); | ||
1021 | p->drawLine( x+8, y-1, x+w-8, y-1 ); | ||
1022 | p->drawPoint(x+8, y ); | ||
1023 | return; | ||
1024 | } | ||
1025 | |||
1026 | // draw icon | ||
1027 | QIconSet::Mode mode; | ||
1028 | if ( mi->iconSet() && !mi->isChecked() ) { | ||
1029 | if ( act ) | ||
1030 | mode = enabled ? QIconSet::Active : QIconSet::Disabled; | ||
1031 | else | ||
1032 | mode = enabled ? QIconSet::Normal : QIconSet::Disabled; | ||
1033 | QPixmap pixmap; | ||
1034 | if ( mode == QIconSet::Disabled ) | ||
1035 | pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode ); | ||
1036 | else | ||
1037 | pixmap = mi->iconSet()->pixmap(); | ||
1038 | QRect pmrect(0, 0, pixmap.width(), pixmap.height() ); | ||
1039 | QRect cr(x, y, maxpmw, h ); | ||
1040 | pmrect.moveCenter( cr.center() ); | ||
1041 | p->drawPixmap(pmrect.topLeft(), pixmap); | ||
1042 | } | ||
1043 | |||
1044 | // draw check | ||
1045 | if(mi->isChecked() ) { | ||
1046 | drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled ); | ||
1047 | } | ||
1048 | |||
1049 | |||
1050 | // draw text | ||
1051 | int xm = maxpmw + 2; | ||
1052 | int xp = x + xm; | ||
1053 | int tw = w -xm - 2; | ||
1054 | |||
1055 | p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) : | ||
1056 | g.mid() ); | ||
1057 | |||
1058 | |||
1059 | if ( mi->custom() ) { | ||
1060 | p->save(); | ||
1061 | mi->custom()->paint(p, g, act, enabled, | ||
1062 | xp, y+1, tw, h-2 ); | ||
1063 | p->restore(); | ||
1064 | }else { // draw label | ||
1065 | QString text = mi->text(); | ||
1066 | if (!text.isNull() ) { | ||
1067 | int t = text.find('\t'); | ||
1068 | const int tflags = AlignVCenter | DontClip | | ||
1069 | ShowPrefix | SingleLine | | ||
1070 | AlignLeft; | ||
1071 | |||
1072 | if (t >= 0) { | ||
1073 | int tabx = x + w - tabwidth - RIGHTBORDER - | ||
1074 | ITEMHMARGIN - ITEMFRAME; | ||
1075 | p->drawText(tabx, y+ITEMVMARGIN, tabwidth, | ||
1076 | h-2*ITEMVMARGIN, tflags, | ||
1077 | text.mid(t+1) ); | ||
1078 | text = text.left(t ); | ||
1079 | } | ||
1080 | |||
1081 | // draw left label | ||
1082 | p->drawText(xp, y+ITEMVMARGIN, | ||
1083 | tw, h-2*ITEMVMARGIN, | ||
1084 | tflags, text, t); | ||
1085 | }else if ( mi->pixmap() ) { // pixmap as label | ||
1086 | QPixmap pixmap = *mi->pixmap(); | ||
1087 | if ( pixmap.depth() == 1 ) | ||
1088 | p->setBackgroundMode( OpaqueMode ); | ||
1089 | |||
1090 | int dx = ((w-pixmap.width() ) /2 ) + | ||
1091 | ((w - pixmap.width()) %2 ); | ||
1092 | p->drawPixmap(x+dx, y+ITEMFRAME, pixmap ); | ||
1093 | |||
1094 | if ( pixmap.depth() == 1 ) | ||
1095 | p->setBackgroundMode( TransparentMode ); | ||
1096 | } | ||
1097 | } | ||
1098 | |||
1099 | if ( mi->popup() ) { // draw submenu arrow | ||
1100 | int dim = (h-2*ITEMFRAME) / 2; | ||
1101 | drawArrow( p, RightArrow, false, | ||
1102 | x+w-ARROWMARGIN-ITEMFRAME-dim, | ||
1103 | y+h/2-dim/2, dim, dim, g, enabled ); | ||
1104 | } | ||
985 | } | 1105 | } |
986 | 1106 | ||
987 | void | 1107 | void |
@@ -1168,7 +1288,7 @@ WebStyle::popupMenuItemHeight(bool, QMenuItem * i, const QFontMetrics & fm) | |||
1168 | { | 1288 | { |
1169 | h = QMAX | 1289 | h = QMAX |
1170 | ( | 1290 | ( |
1171 | i->iconSet()->pixmap(QIconSet::Small, QIconSet::Normal).height(), | 1291 | i->iconSet()->pixmap().height(), |
1172 | h | 1292 | h |
1173 | ); | 1293 | ); |
1174 | } | 1294 | } |