-rw-r--r-- | noncore/styles/metal/metal.cpp | 1 |
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,194 +1,193 @@ | |||
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 | ||
26 | MetalStyle::MetalStyle() : QWindowsStyle() { } | 25 | MetalStyle::MetalStyle() : QWindowsStyle() { } |
27 | 26 | ||
28 | /*! | 27 | /*! |
29 | Reimplementation from QStyle | 28 | Reimplementation from QStyle |
30 | */ | 29 | */ |
31 | void MetalStyle::polish( QApplication *app) | 30 | void 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 | */ |
119 | void MetalStyle::unPolish( QApplication *app) | 118 | void 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 | */ |
128 | void MetalStyle::polish( QWidget* w) | 127 | void 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 | ||
160 | void MetalStyle::unPolish( QWidget* w) | 159 | void 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 |