summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-29 16:53:56 (UTC)
committer mickeyl <mickeyl>2003-10-29 16:53:56 (UTC)
commit80fc44ae81d88c4cee5ea160818881acb2422a62 (patch) (unidiff)
treec7a9b698aa1bc3f12fc757e924ed424916ce1a06
parentf254437deda45d7cccf2ba3c27c5fe934af1fca7 (diff)
downloadopie-80fc44ae81d88c4cee5ea160818881acb2422a62.zip
opie-80fc44ae81d88c4cee5ea160818881acb2422a62.tar.gz
opie-80fc44ae81d88c4cee5ea160818881acb2422a62.tar.bz2
merge noncore/styles/*
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/metal/metal.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/styles/metal/metal.cpp b/noncore/styles/metal/metal.cpp
index 5cb2d22..e13a249 100644
--- a/noncore/styles/metal/metal.cpp
+++ b/noncore/styles/metal/metal.cpp
@@ -1,258 +1,257 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 3** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5** 4**
6** This file is part of an example program for Qt. This example 5** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation. 6** program may be used, distributed and modified without limitation.
8** 7**
9*****************************************************************************/ 8*****************************************************************************/
10 9
11#include "metal.h" 10#include "metal.h"
12#include <qapplication.h> 11#include <qapplication.h>
13#include <qpushbutton.h> 12#include <qpushbutton.h>
14#include <qscrollbar.h> 13#include <qscrollbar.h>
15#include <limits.h> 14#include <limits.h>
16 15
17 16
18///////////////////////////////////////////////////////// 17/////////////////////////////////////////////////////////
19#include "stonedark.xpm" 18#include "stonedark.xpm"
20#include "stone1.xpm" 19#include "stone1.xpm"
21#include "marble.xpm" 20#include "marble.xpm"
22/////////////////////////////////////////////////////// 21///////////////////////////////////////////////////////
23 22
24 23
25 24
26MetalStyle::MetalStyle() : QWindowsStyle() { } 25MetalStyle::MetalStyle() : QWindowsStyle() { }
27 26
28/*! 27/*!
29 Reimplementation from QStyle 28 Reimplementation from QStyle
30 */ 29 */
31void MetalStyle::polish( QApplication *app) 30void MetalStyle::polish( QApplication *app)
32{ 31{
33 oldPalette = app->palette(); 32 oldPalette = app->palette();
34 33
35 // we simply create a nice QColorGroup with a couple of fancy 34 // we simply create a nice QColorGroup with a couple of fancy
36 // pixmaps here and apply to it all widgets 35 // pixmaps here and apply to it all widgets
37 36
38 QFont f("times", app->font().pointSize() ); 37 QFont f("times", app->font().pointSize() );
39 f.setBold( TRUE ); 38 f.setBold( TRUE );
40 f.setItalic( TRUE ); 39 f.setItalic( TRUE );
41 app->setFont( f, TRUE, "QMenuBar"); 40 app->setFont( f, TRUE, "QMenuBar");
42 app->setFont( f, TRUE, "QPopupMenu"); 41 app->setFont( f, TRUE, "QPopupMenu");
43 42
44 43
45 //QPixmap button( stone1_xpm ); 44 //QPixmap button( stone1_xpm );
46 QPixmap button( stonedark_xpm ); 45 QPixmap button( stonedark_xpm );
47 QPixmap background(marble_xpm); 46 QPixmap background(marble_xpm);
48#if 0 47#if 0
49 48
50 int i; 49 int i;
51 for (i=0; i<img.numColors(); i++) { 50 for (i=0; i<img.numColors(); i++) {
52 QRgb rgb = img.color(i); 51 QRgb rgb = img.color(i);
53 QColor c(rgb); 52 QColor c(rgb);
54 rgb = c.dark().rgb(); 53 rgb = c.dark().rgb();
55 img.setColor(i,rgb); 54 img.setColor(i,rgb);
56 } 55 }
57 QPixmap mid; 56 QPixmap mid;
58 mid.convertFromImage(img); 57 mid.convertFromImage(img);
59 58
60 img = orig; 59 img = orig;
61 for (i=0; i<img.numColors(); i++) { 60 for (i=0; i<img.numColors(); i++) {
62 QRgb rgb = img.color(i); 61 QRgb rgb = img.color(i);
63 QColor c(rgb); 62 QColor c(rgb);
64 rgb = c.light().rgb(); 63 rgb = c.light().rgb();
65 img.setColor(i,rgb); 64 img.setColor(i,rgb);
66 } 65 }
67 QPixmap light; 66 QPixmap light;
68 light.convertFromImage(img); 67 light.convertFromImage(img);
69 68
70 img = orig; 69 img = orig;
71 for (i=0; i<img.numColors(); i++) { 70 for (i=0; i<img.numColors(); i++) {
72 QRgb rgb = img.color(i); 71 QRgb rgb = img.color(i);
73 QColor c(rgb); 72 QColor c(rgb);
74 rgb = c.dark().rgb(); 73 rgb = c.dark().rgb();
75 img.setColor(i,rgb); 74 img.setColor(i,rgb);
76 } 75 }
77 QPixmap dark; 76 QPixmap dark;
78 dark.convertFromImage(img); 77 dark.convertFromImage(img);
79#else 78#else
80 QPixmap dark( 1, 1 ); dark.fill( red.dark() ); 79 QPixmap dark( 1, 1 ); dark.fill( red.dark() );
81 QPixmap mid( stone1_xpm ); 80 QPixmap mid( stone1_xpm );
82 QPixmap light( stone1_xpm );//1, 1 ); light.fill( green ); 81 QPixmap light( stone1_xpm );//1, 1 ); light.fill( green );
83#endif 82#endif
84 QPalette op = app->palette(); 83 QPalette op = app->palette();
85 84
86 QColor backCol( 227,227,227 ); 85 QColor backCol( 227,227,227 );
87 86
88 // QPalette op(white); 87 // QPalette op(white);
89 QColorGroup active (op.normal().foreground(), 88 QColorGroup active (op.normal().foreground(),
90 QBrush(op.normal().button(),button), 89 QBrush(op.normal().button(),button),
91 QBrush(op.normal().light(), light), 90 QBrush(op.normal().light(), light),
92 QBrush(op.normal().dark(), dark), 91 QBrush(op.normal().dark(), dark),
93 QBrush(op.normal().mid(), mid), 92 QBrush(op.normal().mid(), mid),
94 op.normal().text(), 93 op.normal().text(),
95 Qt::white, 94 Qt::white,
96 op.normal().base(),// QColor(236,182,120), 95 op.normal().base(),// QColor(236,182,120),
97 QBrush(backCol, background) 96 QBrush(backCol, background)
98 ); 97 );
99 active.setColor( QColorGroup::ButtonText, Qt::white ); 98 active.setColor( QColorGroup::ButtonText, Qt::white );
100 active.setColor( QColorGroup::Shadow, Qt::black ); 99 active.setColor( QColorGroup::Shadow, Qt::black );
101 QColorGroup disabled (op.disabled().foreground(), 100 QColorGroup disabled (op.disabled().foreground(),
102 QBrush(op.disabled().button(),button), 101 QBrush(op.disabled().button(),button),
103 QBrush(op.disabled().light(), light), 102 QBrush(op.disabled().light(), light),
104 op.disabled().dark(), 103 op.disabled().dark(),
105 QBrush(op.disabled().mid(), mid), 104 QBrush(op.disabled().mid(), mid),
106 op.disabled().text(), 105 op.disabled().text(),
107 Qt::white, 106 Qt::white,
108 op.disabled().base(),// QColor(236,182,120), 107 op.disabled().base(),// QColor(236,182,120),
109 QBrush(backCol, background) 108 QBrush(backCol, background)
110 ); 109 );
111 110
112 QPalette newPalette( active, disabled, active ); 111 QPalette newPalette( active, disabled, active );
113 app->setPalette( newPalette, TRUE ); 112 app->setPalette( newPalette, TRUE );
114} 113}
115 114
116/*! 115/*!
117 Reimplementation from QStyle 116 Reimplementation from QStyle
118 */ 117 */
119void MetalStyle::unPolish( QApplication *app) 118void MetalStyle::unPolish( QApplication *app)
120{ 119{
121 app->setPalette(oldPalette, TRUE); 120 app->setPalette(oldPalette, TRUE);
122 app->setFont( app->font(), TRUE ); 121 app->setFont( app->font(), TRUE );
123} 122}
124 123
125/*! 124/*!
126 Reimplementation from QStyle 125 Reimplementation from QStyle
127 */ 126 */
128void MetalStyle::polish( QWidget* w) 127void MetalStyle::polish( QWidget* w)
129{ 128{
130 129
131 // the polish function sets some widgets to transparent mode and 130 // the polish function sets some widgets to transparent mode and
132 // some to translate background mode in order to get the full 131 // some to translate background mode in order to get the full
133 // benefit from the nice pixmaps in the color group. 132 // benefit from the nice pixmaps in the color group.
134 133
135 if (w->inherits("QPushButton")){ 134 if (w->inherits("QPushButton")){
136 w->setBackgroundMode( QWidget::NoBackground ); 135 w->setBackgroundMode( QWidget::NoBackground );
137 return; 136 return;
138 } 137 }
139 138
140 if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){ 139 if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){
141 return; 140 return;
142 } 141 }
143 142
144 if ( !w->isTopLevel() ) { 143 if ( !w->isTopLevel() ) {
145 if ( w->inherits("QGroupBox") 144 if ( w->inherits("QGroupBox")
146 || w->inherits("QTabWidget") ) { 145 || w->inherits("QTabWidget") ) {
147 w->setAutoMask( TRUE ); 146 w->setAutoMask( TRUE );
148 return; 147 return;
149 } 148 }
150 if (w->inherits("QLabel") 149 if (w->inherits("QLabel")
151 || w->inherits("QSlider") 150 || w->inherits("QSlider")
152 || w->inherits("QButton") 151 || w->inherits("QButton")
153 || w->inherits("QProgressBar") 152 || w->inherits("QProgressBar")
154 ){ 153 ){
155 w->setBackgroundOrigin( QWidget::ParentOrigin ); 154 w->setBackgroundOrigin( QWidget::ParentOrigin );
156 } 155 }
157 } 156 }
158} 157}
159 158
160void MetalStyle::unPolish( QWidget* w) 159void MetalStyle::unPolish( QWidget* w)
161{ 160{
162 161
163 // the polish function sets some widgets to transparent mode and 162 // the polish function sets some widgets to transparent mode and
164 // some to translate background mode in order to get the full 163 // some to translate background mode in order to get the full
165 // benefit from the nice pixmaps in the color group. 164 // benefit from the nice pixmaps in the color group.
166 165
167 if (w->inherits("QPushButton")){ 166 if (w->inherits("QPushButton")){
168 w->setBackgroundMode( QWidget::PaletteButton ); 167 w->setBackgroundMode( QWidget::PaletteButton );
169 return; 168 return;
170 } 169 }
171 170
172 if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){ 171 if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){
173 return; 172 return;
174 } 173 }
175 174
176 if ( !w->isTopLevel() ) { 175 if ( !w->isTopLevel() ) {
177 if ( w->inherits("QGroupBox") 176 if ( w->inherits("QGroupBox")
178 || w->inherits("QTabWidget") ) { 177 || w->inherits("QTabWidget") ) {
179 w->setAutoMask( FALSE ); 178 w->setAutoMask( FALSE );
180 return; 179 return;
181 } 180 }
182 if (w->inherits("QLabel") 181 if (w->inherits("QLabel")
183 || w->inherits("QSlider") 182 || w->inherits("QSlider")
184 || w->inherits("QButton") 183 || w->inherits("QButton")
185 || w->inherits("QProgressBar") 184 || w->inherits("QProgressBar")
186 ){ 185 ){
187 w->setBackgroundOrigin( QWidget::WidgetOrigin ); 186 w->setBackgroundOrigin( QWidget::WidgetOrigin );
188 } 187 }
189 } 188 }
190 189
191} 190}
192 191
193/*! 192/*!
194 Draw a metallic button, sunken if \a sunken is TRUE, horizontal if 193 Draw a metallic button, sunken if \a sunken is TRUE, horizontal if
195 /a horz is TRUE. 194 /a horz is TRUE.
196*/ 195*/
197 196
198void MetalStyle::drawMetalButton( QPainter *p, int x, int y, int w, int h, 197void MetalStyle::drawMetalButton( QPainter *p, int x, int y, int w, int h,
199 bool sunken, bool horz ) 198 bool sunken, bool horz )
200{ 199{
201 QColor top1("#878769691515"); 200 QColor top1("#878769691515");
202 QColor top2("#C6C6B4B44949"); 201 QColor top2("#C6C6B4B44949");
203 202
204 QColor bot2("#70705B5B1414"); 203 QColor bot2("#70705B5B1414");
205 QColor bot1("56564A4A0E0E"); //first from the bottom 204 QColor bot1("56564A4A0E0E"); //first from the bottom
206 205
207 QColor highlight("#E8E8DDDD6565"); 206 QColor highlight("#E8E8DDDD6565");
208 QColor subh1("#CECEBDBD5151"); 207 QColor subh1("#CECEBDBD5151");
209 QColor subh2("#BFBFACAC4545"); 208 QColor subh2("#BFBFACAC4545");
210 209
211 QColor topgrad("#B9B9A5A54040"); 210 QColor topgrad("#B9B9A5A54040");
212 QColor botgrad("#89896C6C1A1A"); 211 QColor botgrad("#89896C6C1A1A");
213 212
214 213
215 int x2 = x + w - 1; 214 int x2 = x + w - 1;
216 int y2 = y + h - 1; 215 int y2 = y + h - 1;
217 216
218 //frame: 217 //frame:
219 218
220 p->setPen( top1 ); 219 p->setPen( top1 );
221 p->drawLine( x, y2, x, y ); 220 p->drawLine( x, y2, x, y );
222 p->drawLine( x, y, x2-1, y ); 221 p->drawLine( x, y, x2-1, y );
223 p->setPen( top2 ); 222 p->setPen( top2 );
224 p->drawLine( x+1, y2 -1, x+1, y+1 ); 223 p->drawLine( x+1, y2 -1, x+1, y+1 );
225 p->drawLine( x+1, y+1 , x2-2, y+1 ); 224 p->drawLine( x+1, y+1 , x2-2, y+1 );
226 225
227 p->setPen( bot1 ); 226 p->setPen( bot1 );
228 p->drawLine( x+1, y2, x2, y2 ); 227 p->drawLine( x+1, y2, x2, y2 );
229 p->drawLine( x2, y2, x2, y ); 228 p->drawLine( x2, y2, x2, y );
230 p->setPen( bot2 ); 229 p->setPen( bot2 );
231 p->drawLine( x+1, y2-1, x2-1, y2-1 ); 230 p->drawLine( x+1, y2-1, x2-1, y2-1 );
232 p->drawLine( x2-1, y2-1, x2-1, y+1 ); 231 p->drawLine( x2-1, y2-1, x2-1, y+1 );
233 232
234 // highlight: 233 // highlight:
235 int i = 0; 234 int i = 0;
236 int x1 = x + 2; 235 int x1 = x + 2;
237 int y1 = y + 2; 236 int y1 = y + 2;
238 if ( horz ) 237 if ( horz )
239 x2 = x2 - 2; 238 x2 = x2 - 2;
240 else 239 else
241 y2 = y2 - 2; 240 y2 = y2 - 2;
242 // Note that x2/y2 mean something else from this point down... 241 // Note that x2/y2 mean something else from this point down...
243 242
244#define DRAWLINE if (horz) \ 243#define DRAWLINE if (horz) \
245 p->drawLine( x1, y1+i, x2, y1+i ); \ 244 p->drawLine( x1, y1+i, x2, y1+i ); \
246 else \ 245 else \
247 p->drawLine( x1+i, y1, x1+i, y2 ); \ 246 p->drawLine( x1+i, y1, x1+i, y2 ); \
248 i++; 247 i++;
249 248
250 if ( !sunken ) { 249 if ( !sunken ) {
251 p->setPen( highlight ); 250 p->setPen( highlight );
252 DRAWLINE; 251 DRAWLINE;
253 DRAWLINE; 252 DRAWLINE;
254 p->setPen( subh1 ); 253 p->setPen( subh1 );
255 DRAWLINE; 254 DRAWLINE;
256 p->setPen( subh2 ); 255 p->setPen( subh2 );
257 DRAWLINE; 256 DRAWLINE;
258 } 257 }