summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/lightstyle.cpp10
-rw-r--r--library/lightstyle.h2
-rw-r--r--library/qpeapplication.cpp4
-rw-r--r--library/qpestyle.cpp4
-rw-r--r--library/qpestyle.h2
5 files changed, 11 insertions, 11 deletions
diff --git a/library/lightstyle.cpp b/library/lightstyle.cpp
index f18bdca..3bd1623 100644
--- a/library/lightstyle.cpp
+++ b/library/lightstyle.cpp
@@ -1,1284 +1,1284 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "lightstyle.h" 20#include "lightstyle.h"
21 21
22#if QT_VERSION < 300 22#if QT_VERSION < 0x030000
23 23
24#define INCLUDE_MENUITEM_DEF 24#define INCLUDE_MENUITEM_DEF
25#include "qmenubar.h" 25#include "qmenubar.h"
26#include "qapplication.h" 26#include "qapplication.h"
27#include "qpainter.h" 27#include "qpainter.h"
28#include "qpalette.h" 28#include "qpalette.h"
29#include "qframe.h" 29#include "qframe.h"
30#include "qpushbutton.h" 30#include "qpushbutton.h"
31#include "qdrawutil.h" 31#include "qdrawutil.h"
32#include "qscrollbar.h" 32#include "qscrollbar.h"
33#include "qtabbar.h" 33#include "qtabbar.h"
34#include "qguardedptr.h" 34#include "qguardedptr.h"
35#include "qlayout.h" 35#include "qlayout.h"
36#include "qlineedit.h" 36#include "qlineedit.h"
37 37
38 38
39class LightStylePrivate 39class LightStylePrivate
40{ 40{
41public: 41public:
42 LightStylePrivate() 42 LightStylePrivate()
43 : hoverWidget(0), ref(1), savePalette(0) 43 : hoverWidget(0), ref(1), savePalette(0)
44 { 44 {
45 } 45 }
46 46
47 QGuardedPtr<QWidget> hoverWidget; 47 QGuardedPtr<QWidget> hoverWidget;
48 QPalette oldPalette, hoverPalette; 48 QPalette oldPalette, hoverPalette;
49 int ref; 49 int ref;
50 QPoint mousePos; 50 QPoint mousePos;
51 QPalette *savePalette; 51 QPalette *savePalette;
52}; 52};
53 53
54 54
55static LightStylePrivate *singleton = 0; 55static LightStylePrivate *singleton = 0;
56 56
57 57
58LightStyle::LightStyle() 58LightStyle::LightStyle()
59 : QWindowsStyle() 59 : QWindowsStyle()
60{ 60{
61 if (! singleton) { 61 if (! singleton) {
62 singleton = new LightStylePrivate; 62 singleton = new LightStylePrivate;
63 63
64 QPalette pal = QApplication::palette(); 64 QPalette pal = QApplication::palette();
65 singleton->oldPalette = pal; 65 singleton->oldPalette = pal;
66 66
67 QColor bg = pal.color(QPalette::Active, QColorGroup::Background); 67 QColor bg = pal.color(QPalette::Active, QColorGroup::Background);
68 QColor prelight; 68 QColor prelight;
69 69
70 if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128) 70 if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128)
71 prelight = pal.color(QPalette::Active, 71 prelight = pal.color(QPalette::Active,
72 QColorGroup::Background).light(110); 72 QColorGroup::Background).light(110);
73 else 73 else
74 prelight = pal.color(QPalette::Active, 74 prelight = pal.color(QPalette::Active,
75 QColorGroup::Background).light(120); 75 QColorGroup::Background).light(120);
76 76
77 QColorGroup active2(pal.color(QPalette::Active, 77 QColorGroup active2(pal.color(QPalette::Active,
78 QColorGroup::Foreground), // foreground 78 QColorGroup::Foreground), // foreground
79 prelight, // button 79 prelight, // button
80 prelight.light(), // light 80 prelight.light(), // light
81 prelight.dark(), // dark 81 prelight.dark(), // dark
82 prelight.dark(120), // mid 82 prelight.dark(120), // mid
83 pal.color(QPalette::Active, 83 pal.color(QPalette::Active,
84 QColorGroup::Text), // text 84 QColorGroup::Text), // text
85 pal.color(QPalette::Active, 85 pal.color(QPalette::Active,
86 QColorGroup::BrightText), // bright text 86 QColorGroup::BrightText), // bright text
87 pal.color(QPalette::Active, 87 pal.color(QPalette::Active,
88 QColorGroup::Base), // base 88 QColorGroup::Base), // base
89 bg); // background 89 bg); // background
90 active2.setColor(QColorGroup::Highlight, 90 active2.setColor(QColorGroup::Highlight,
91 pal.color(QPalette::Active, QColorGroup::Highlight)); 91 pal.color(QPalette::Active, QColorGroup::Highlight));
92 92
93 singleton->hoverPalette = pal; 93 singleton->hoverPalette = pal;
94 singleton->hoverPalette.setActive(active2); 94 singleton->hoverPalette.setActive(active2);
95 singleton->hoverPalette.setInactive(active2); 95 singleton->hoverPalette.setInactive(active2);
96 } else 96 } else
97 singleton->ref++; 97 singleton->ref++;
98} 98}
99 99
100 100
101LightStyle::~LightStyle() 101LightStyle::~LightStyle()
102{ 102{
103 if (singleton && singleton->ref-- <= 0) { 103 if (singleton && singleton->ref-- <= 0) {
104 delete singleton; 104 delete singleton;
105 singleton = 0; 105 singleton = 0;
106 } 106 }
107} 107}
108 108
109 109
110QSize LightStyle::scrollBarExtent() const 110QSize LightStyle::scrollBarExtent() const
111{ 111{
112 return QSize(12 + defaultFrameWidth(), 12 + defaultFrameWidth()); 112 return QSize(12 + defaultFrameWidth(), 12 + defaultFrameWidth());
113} 113}
114 114
115 115
116int LightStyle::buttonDefaultIndicatorWidth() const 116int LightStyle::buttonDefaultIndicatorWidth() const
117{ 117{
118 return 2; 118 return 2;
119} 119}
120 120
121 121
122int LightStyle::sliderThickness() const 122int LightStyle::sliderThickness() const
123{ 123{
124 return 16; 124 return 16;
125} 125}
126 126
127int LightStyle::sliderLength() const 127int LightStyle::sliderLength() const
128{ 128{
129 return 13; 129 return 13;
130} 130}
131 131
132 132
133int LightStyle::buttonMargin() const 133int LightStyle::buttonMargin() const
134{ 134{
135 return 4; 135 return 4;
136} 136}
137 137
138 138
139QSize LightStyle::exclusiveIndicatorSize() const 139QSize LightStyle::exclusiveIndicatorSize() const
140{ 140{
141 return QSize(13, 13); 141 return QSize(13, 13);
142} 142}
143 143
144 144
145int LightStyle::defaultFrameWidth() const 145int LightStyle::defaultFrameWidth() const
146{ 146{
147 return 2; 147 return 2;
148} 148}
149 149
150 150
151QSize LightStyle::indicatorSize() const 151QSize LightStyle::indicatorSize() const
152{ 152{
153 return QSize(13, 13); 153 return QSize(13, 13);
154} 154}
155 155
156 156
157void LightStyle::polish(QWidget *widget) 157void LightStyle::polish(QWidget *widget)
158{ 158{
159 if (widget->inherits("QPushButton")) 159 if (widget->inherits("QPushButton"))
160 widget->installEventFilter(this); 160 widget->installEventFilter(this);
161 161
162#if QT_VERSION >= 300 162#if QT_VERSION >= 0x030000
163 if (widget->inherits("QLineEdit")) { 163 if (widget->inherits("QLineEdit")) {
164 QLineEdit *lineedit = (QLineEdit *) widget; 164 QLineEdit *lineedit = (QLineEdit *) widget;
165 lineedit->setFrameShape(QFrame::StyledPanel); 165 lineedit->setFrameShape(QFrame::StyledPanel);
166 lineedit->setLineWidth(2); 166 lineedit->setLineWidth(2);
167 } 167 }
168#endif 168#endif
169 169
170 QWindowsStyle::polish(widget); 170 QWindowsStyle::polish(widget);
171} 171}
172 172
173 173
174void LightStyle::unPolish(QWidget *widget) 174void LightStyle::unPolish(QWidget *widget)
175{ 175{
176 if (widget->inherits("QPushButton")) 176 if (widget->inherits("QPushButton"))
177 widget->removeEventFilter(this); 177 widget->removeEventFilter(this);
178 178
179#if QT_VERSION >= 300 179#if QT_VERSION >= 0x030000
180 if (widget->inherits("QLineEdit")) { 180 if (widget->inherits("QLineEdit")) {
181 QLineEdit *lineedit = (QLineEdit *) widget; 181 QLineEdit *lineedit = (QLineEdit *) widget;
182 lineedit->setLineWidth(1); 182 lineedit->setLineWidth(1);
183 lineedit->setFrameShape(QFrame::WinPanel); 183 lineedit->setFrameShape(QFrame::WinPanel);
184 } 184 }
185#endif 185#endif
186 186
187 QWindowsStyle::unPolish(widget); 187 QWindowsStyle::unPolish(widget);
188} 188}
189 189
190 190
191void LightStyle::polish(QApplication *app) 191void LightStyle::polish(QApplication *app)
192{ 192{
193 QPalette pal = app->palette(); 193 QPalette pal = app->palette();
194 194
195 QColorGroup active(pal.color(QPalette::Active, 195 QColorGroup active(pal.color(QPalette::Active,
196 QColorGroup::Foreground), // foreground 196 QColorGroup::Foreground), // foreground
197 pal.color(QPalette::Active, 197 pal.color(QPalette::Active,
198 QColorGroup::Button), // button 198 QColorGroup::Button), // button
199 pal.color(QPalette::Active, 199 pal.color(QPalette::Active,
200 QColorGroup::Background).light(), // light 200 QColorGroup::Background).light(), // light
201 pal.color(QPalette::Active, 201 pal.color(QPalette::Active,
202 QColorGroup::Background).dark(175), // dark 202 QColorGroup::Background).dark(175), // dark
203 pal.color(QPalette::Active, 203 pal.color(QPalette::Active,
204 QColorGroup::Background).dark(110), // mid 204 QColorGroup::Background).dark(110), // mid
205 pal.color(QPalette::Active, 205 pal.color(QPalette::Active,
206 QColorGroup::Text), // text 206 QColorGroup::Text), // text
207 pal.color(QPalette::Active, 207 pal.color(QPalette::Active,
208 QColorGroup::BrightText), // bright text 208 QColorGroup::BrightText), // bright text
209 pal.color(QPalette::Active, 209 pal.color(QPalette::Active,
210 QColorGroup::Base), // base 210 QColorGroup::Base), // base
211 pal.color(QPalette::Active, 211 pal.color(QPalette::Active,
212 QColorGroup::Background)), // background 212 QColorGroup::Background)), // background
213 213
214 214
215 disabled(pal.color(QPalette::Disabled, 215 disabled(pal.color(QPalette::Disabled,
216 QColorGroup::Foreground), // foreground 216 QColorGroup::Foreground), // foreground
217 pal.color(QPalette::Disabled, 217 pal.color(QPalette::Disabled,
218 QColorGroup::Button), // button 218 QColorGroup::Button), // button
219 pal.color(QPalette::Disabled, 219 pal.color(QPalette::Disabled,
220 QColorGroup::Background).light(), // light 220 QColorGroup::Background).light(), // light
221 pal.color(QPalette::Disabled, 221 pal.color(QPalette::Disabled,
222 QColorGroup::Background).dark(), // dark 222 QColorGroup::Background).dark(), // dark
223 pal.color(QPalette::Disabled, 223 pal.color(QPalette::Disabled,
224 QColorGroup::Background).dark(110), // mid 224 QColorGroup::Background).dark(110), // mid
225 pal.color(QPalette::Disabled, 225 pal.color(QPalette::Disabled,
226 QColorGroup::Text), // text 226 QColorGroup::Text), // text
227 pal.color(QPalette::Disabled, 227 pal.color(QPalette::Disabled,
228 QColorGroup::BrightText), // bright text 228 QColorGroup::BrightText), // bright text
229 pal.color(QPalette::Disabled, 229 pal.color(QPalette::Disabled,
230 QColorGroup::Base), // base 230 QColorGroup::Base), // base
231 pal.color(QPalette::Disabled, 231 pal.color(QPalette::Disabled,
232 QColorGroup::Background)); // background 232 QColorGroup::Background)); // background
233 233
234 active.setColor(QColorGroup::Highlight, 234 active.setColor(QColorGroup::Highlight,
235 pal.color(QPalette::Active, QColorGroup::Highlight)); 235 pal.color(QPalette::Active, QColorGroup::Highlight));
236 disabled.setColor(QColorGroup::Highlight, 236 disabled.setColor(QColorGroup::Highlight,
237 pal.color(QPalette::Disabled, QColorGroup::Highlight)); 237 pal.color(QPalette::Disabled, QColorGroup::Highlight));
238 238
239 active.setColor(QColorGroup::HighlightedText, 239 active.setColor(QColorGroup::HighlightedText,
240 pal.color(QPalette::Active, QColorGroup::HighlightedText)); 240 pal.color(QPalette::Active, QColorGroup::HighlightedText));
241 disabled.setColor(QColorGroup::HighlightedText, 241 disabled.setColor(QColorGroup::HighlightedText,
242 pal.color(QPalette::Disabled, QColorGroup::HighlightedText)); 242 pal.color(QPalette::Disabled, QColorGroup::HighlightedText));
243 243
244 pal.setActive(active); 244 pal.setActive(active);
245 pal.setInactive(active); 245 pal.setInactive(active);
246 pal.setDisabled(disabled); 246 pal.setDisabled(disabled);
247 247
248 singleton->oldPalette = pal; 248 singleton->oldPalette = pal;
249 249
250 QColor bg = pal.color(QPalette::Active, QColorGroup::Background); 250 QColor bg = pal.color(QPalette::Active, QColorGroup::Background);
251 QColor prelight; 251 QColor prelight;
252 252
253 if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128) 253 if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128)
254 prelight = pal.color(QPalette::Active, 254 prelight = pal.color(QPalette::Active,
255 QColorGroup::Background).light(110); 255 QColorGroup::Background).light(110);
256 else 256 else
257 prelight = pal.color(QPalette::Active, 257 prelight = pal.color(QPalette::Active,
258 QColorGroup::Background).light(120); 258 QColorGroup::Background).light(120);
259 259
260 QColorGroup active2(pal.color(QPalette::Active, 260 QColorGroup active2(pal.color(QPalette::Active,
261 QColorGroup::Foreground), // foreground 261 QColorGroup::Foreground), // foreground
262 prelight, // button 262 prelight, // button
263 prelight.light(), // light 263 prelight.light(), // light
264 prelight.dark(), // dark 264 prelight.dark(), // dark
265 prelight.dark(120), // mid 265 prelight.dark(120), // mid
266 pal.color(QPalette::Active, 266 pal.color(QPalette::Active,
267 QColorGroup::Text), // text 267 QColorGroup::Text), // text
268 pal.color(QPalette::Active, 268 pal.color(QPalette::Active,
269 QColorGroup::BrightText), // bright text 269 QColorGroup::BrightText), // bright text
270 pal.color(QPalette::Active, 270 pal.color(QPalette::Active,
271 QColorGroup::Base), // base 271 QColorGroup::Base), // base
272 bg); // background 272 bg); // background
273 active2.setColor(QColorGroup::Highlight, 273 active2.setColor(QColorGroup::Highlight,
274 pal.color(QPalette::Active, QColorGroup::Highlight)); 274 pal.color(QPalette::Active, QColorGroup::Highlight));
275 275
276 singleton->hoverPalette = pal; 276 singleton->hoverPalette = pal;
277 singleton->hoverPalette.setActive(active2); 277 singleton->hoverPalette.setActive(active2);
278 singleton->hoverPalette.setInactive(active2); 278 singleton->hoverPalette.setInactive(active2);
279 279
280 app->setPalette(pal); 280 app->setPalette(pal);
281} 281}
282 282
283 283
284void LightStyle::unPolish(QApplication *app) 284void LightStyle::unPolish(QApplication *app)
285{ 285{
286 app->setPalette(singleton->oldPalette); 286 app->setPalette(singleton->oldPalette);
287} 287}
288 288
289 289
290void LightStyle::polishPopupMenu(QPopupMenu *menu) 290void LightStyle::polishPopupMenu(QPopupMenu *menu)
291{ 291{
292 menu->setMouseTracking(TRUE); 292 menu->setMouseTracking(TRUE);
293} 293}
294 294
295 295
296void LightStyle::drawPushButton(QPushButton *button, QPainter *p) 296void LightStyle::drawPushButton(QPushButton *button, QPainter *p)
297{ 297{
298 int x1, y1, x2, y2; 298 int x1, y1, x2, y2;
299 button->rect().coords(&x1, &y1, &x2, &y2); 299 button->rect().coords(&x1, &y1, &x2, &y2);
300 300
301 if (button->isDefault()) { 301 if (button->isDefault()) {
302 p->save(); 302 p->save();
303 p->setPen(button->palette().active().color(QColorGroup::Highlight)); 303 p->setPen(button->palette().active().color(QColorGroup::Highlight));
304 p->setBrush(button->palette().active().brush(QColorGroup::Highlight)); 304 p->setBrush(button->palette().active().brush(QColorGroup::Highlight));
305 p->drawRoundRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1, 15, 15); 305 p->drawRoundRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1, 15, 15);
306 p->restore(); 306 p->restore();
307 } 307 }
308 308
309 if (button->isDefault() || button->autoDefault()) { 309 if (button->isDefault() || button->autoDefault()) {
310 x1 += buttonDefaultIndicatorWidth(); 310 x1 += buttonDefaultIndicatorWidth();
311 y1 += buttonDefaultIndicatorWidth(); 311 y1 += buttonDefaultIndicatorWidth();
312 x2 -= buttonDefaultIndicatorWidth(); 312 x2 -= buttonDefaultIndicatorWidth();
313 y2 -= buttonDefaultIndicatorWidth(); 313 y2 -= buttonDefaultIndicatorWidth();
314 314
315 if (button->isDefault()) { 315 if (button->isDefault()) {
316 QPointArray pa(8); 316 QPointArray pa(8);
317 pa.setPoint(0, x1 + 2, y1 ); 317 pa.setPoint(0, x1 + 2, y1 );
318 pa.setPoint(1, x2 - 1, y1 ); 318 pa.setPoint(1, x2 - 1, y1 );
319 pa.setPoint(2, x2 + 1, y1 + 2); 319 pa.setPoint(2, x2 + 1, y1 + 2);
320 pa.setPoint(3, x2 + 1, y2 - 2); 320 pa.setPoint(3, x2 + 1, y2 - 2);
321 pa.setPoint(4, x2 - 2, y2 + 1); 321 pa.setPoint(4, x2 - 2, y2 + 1);
322 pa.setPoint(5, x1 + 2, y2 + 1); 322 pa.setPoint(5, x1 + 2, y2 + 1);
323 pa.setPoint(6, x1, y2 - 1); 323 pa.setPoint(6, x1, y2 - 1);
324 pa.setPoint(7, x1, y1 + 2); 324 pa.setPoint(7, x1, y1 + 2);
325 QRegion r(pa); 325 QRegion r(pa);
326 p->setClipRegion(r); 326 p->setClipRegion(r);
327 } 327 }
328 } 328 }
329 329
330 QBrush fill; 330 QBrush fill;
331 if (button->isDown() || button->isOn()) 331 if (button->isDown() || button->isOn())
332 fill = button->colorGroup().brush(QColorGroup::Mid); 332 fill = button->colorGroup().brush(QColorGroup::Mid);
333 else 333 else
334 fill = button->colorGroup().brush(QColorGroup::Button); 334 fill = button->colorGroup().brush(QColorGroup::Button);
335 335
336 if ( !button->isFlat() || button->isOn() || button->isDown() ) 336 if ( !button->isFlat() || button->isOn() || button->isDown() )
337 drawButton(p, x1, y1, x2 - x1 + 1, y2 - y1 + 1, 337 drawButton(p, x1, y1, x2 - x1 + 1, y2 - y1 + 1,
338 button->colorGroup(), button->isOn() || button->isDown(), &fill); 338 button->colorGroup(), button->isOn() || button->isDown(), &fill);
339} 339}
340 340
341 341
342void LightStyle::drawButton(QPainter *p, int x, int y, int w, int h, 342void LightStyle::drawButton(QPainter *p, int x, int y, int w, int h,
343 const QColorGroup &g, 343 const QColorGroup &g,
344 bool sunken, const QBrush *fill) 344 bool sunken, const QBrush *fill)
345{ 345{
346 p->save(); 346 p->save();
347 if ( fill ) 347 if ( fill )
348 p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill); 348 p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill);
349 else 349 else
350 p->fillRect(x + 2, y + 2, w - 4, h - 4, 350 p->fillRect(x + 2, y + 2, w - 4, h - 4,
351 QBrush(sunken ? g.mid() : g.button())); 351 QBrush(sunken ? g.mid() : g.button()));
352 352
353 // frame 353 // frame
354 p->setPen(g.dark()); 354 p->setPen(g.dark());
355 p->drawLine(x, y + 2, x, y + h - 3); // left 355 p->drawLine(x, y + 2, x, y + h - 3); // left
356 p->drawLine(x + 2, y, x + w - 3, y); // top 356 p->drawLine(x + 2, y, x + w - 3, y); // top
357 p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right 357 p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right
358 p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom 358 p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom
359 p->drawPoint(x + 1, y + 1); 359 p->drawPoint(x + 1, y + 1);
360 p->drawPoint(x + 1, y + h - 2); 360 p->drawPoint(x + 1, y + h - 2);
361 p->drawPoint(x + w - 2, y + 1); 361 p->drawPoint(x + w - 2, y + 1);
362 p->drawPoint(x + w - 2, y + h - 2); 362 p->drawPoint(x + w - 2, y + h - 2);
363 363
364 // bevel 364 // bevel
365 if (sunken) 365 if (sunken)
366 p->setPen(g.mid()); 366 p->setPen(g.mid());
367 else 367 else
368 p->setPen(g.light()); 368 p->setPen(g.light());
369 369
370 p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left 370 p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left
371 p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top 371 p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top
372 372
373 if (sunken) 373 if (sunken)
374 p->setPen(g.light()); 374 p->setPen(g.light());
375 else 375 else
376 p->setPen(g.mid()); 376 p->setPen(g.mid());
377 377
378 p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1 378 p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1
379 p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1 379 p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1
380 380
381 p->restore(); 381 p->restore();
382} 382}
383 383
384 384
385void LightStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, 385void LightStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
386 const QColorGroup &g, 386 const QColorGroup &g,
387 bool sunken, const QBrush *fill) 387 bool sunken, const QBrush *fill)
388{ 388{
389 drawButton(p, x, y, w, h, g, sunken, fill); 389 drawButton(p, x, y, w, h, g, sunken, fill);
390} 390}
391 391
392 392
393void LightStyle::getButtonShift(int &x, int &y) const 393void LightStyle::getButtonShift(int &x, int &y) const
394{ 394{
395 x = y = 0; 395 x = y = 0;
396} 396}
397 397
398 398
399void LightStyle::drawComboButton(QPainter *p, int x, int y, int w, int h, 399void LightStyle::drawComboButton(QPainter *p, int x, int y, int w, int h,
400 const QColorGroup &g, bool, 400 const QColorGroup &g, bool,
401 bool editable, bool, 401 bool editable, bool,
402 const QBrush *fill) 402 const QBrush *fill)
403{ 403{
404 drawButton(p, x, y, w, h, g, FALSE, fill); 404 drawButton(p, x, y, w, h, g, FALSE, fill);
405 405
406 if (editable) { 406 if (editable) {
407 QRect r = comboButtonRect(x, y, w, h); 407 QRect r = comboButtonRect(x, y, w, h);
408 qDrawShadePanel(p, r.x() - 1, r.y() - 1, 408 qDrawShadePanel(p, r.x() - 1, r.y() - 1,
409 r.width() + defaultFrameWidth(), 409 r.width() + defaultFrameWidth(),
410 r.height() + defaultFrameWidth(), 410 r.height() + defaultFrameWidth(),
411 g, TRUE); 411 g, TRUE);
412 } 412 }
413 413
414 int indent = ((y + h) / 2) - 3; 414 int indent = ((y + h) / 2) - 3;
415 int xpos = x; 415 int xpos = x;
416 416
417#if QT_VERSION >= 300 417#if QT_VERSION >= 0x030000
418 if( QApplication::reverseLayout() ) 418 if( QApplication::reverseLayout() )
419 xpos += indent; 419 xpos += indent;
420 else 420 else
421#endif 421#endif
422 xpos += w - indent - 5; 422 xpos += w - indent - 5;
423 423
424 drawArrow(p, Qt::DownArrow, TRUE, xpos, indent, 5, 5, g, TRUE, fill); 424 drawArrow(p, Qt::DownArrow, TRUE, xpos, indent, 5, 5, g, TRUE, fill);
425} 425}
426 426
427 427
428QRect LightStyle::comboButtonRect( int x, int y, int w, int h ) const 428QRect LightStyle::comboButtonRect( int x, int y, int w, int h ) const
429{ 429{
430 QRect r(x + 3, y + 3, w - 6, h - 6); 430 QRect r(x + 3, y + 3, w - 6, h - 6);
431 int indent = ((y + h) / 2) - 3; 431 int indent = ((y + h) / 2) - 3;
432 r.setRight(r.right() - indent - 10); 432 r.setRight(r.right() - indent - 10);
433 433
434#if QT_VERSION >= 300 434#if QT_VERSION >= 0x030000
435 if( QApplication::reverseLayout() ) 435 if( QApplication::reverseLayout() )
436 r.moveBy( indent + 10, 0 ); 436 r.moveBy( indent + 10, 0 );
437#endif 437#endif
438 438
439 return r; 439 return r;
440} 440}
441 441
442 442
443QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h ) const 443QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h ) const
444{ 444{
445 return comboButtonRect(x, y, w, h); 445 return comboButtonRect(x, y, w, h);
446} 446}
447 447
448 448
449void LightStyle::drawPanel(QPainter *p, int x, int y, int w, int h, 449void LightStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
450 const QColorGroup &g, bool sunken, 450 const QColorGroup &g, bool sunken,
451 int lw, const QBrush *fill) 451 int lw, const QBrush *fill)
452{ 452{
453 if (lw >= 2) { 453 if (lw >= 2) {
454 if ( fill ) 454 if ( fill )
455 p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill); 455 p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill);
456 456
457 QPen oldpen = p->pen(); 457 QPen oldpen = p->pen();
458 458
459 // frame 459 // frame
460 p->setPen(g.dark()); 460 p->setPen(g.dark());
461 p->drawLine(x, y + 2, x, y + h - 3); // left 461 p->drawLine(x, y + 2, x, y + h - 3); // left
462 p->drawLine(x + 2, y, x + w - 3, y); // top 462 p->drawLine(x + 2, y, x + w - 3, y); // top
463 p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right 463 p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right
464 p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom 464 p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom
465 p->drawPoint(x + 1, y + 1); 465 p->drawPoint(x + 1, y + 1);
466 p->drawPoint(x + 1, y + h - 2); 466 p->drawPoint(x + 1, y + h - 2);
467 p->drawPoint(x + w - 2, y + 1); 467 p->drawPoint(x + w - 2, y + 1);
468 p->drawPoint(x + w - 2, y + h - 2); 468 p->drawPoint(x + w - 2, y + h - 2);
469 469
470 // bevel 470 // bevel
471 if (sunken) 471 if (sunken)
472 p->setPen(g.mid()); 472 p->setPen(g.mid());
473 else 473 else
474 p->setPen(g.light()); 474 p->setPen(g.light());
475 475
476 p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left 476 p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left
477 p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top 477 p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top
478 478
479 if (sunken) 479 if (sunken)
480 p->setPen(g.light()); 480 p->setPen(g.light());
481 else 481 else
482 p->setPen(g.mid()); 482 p->setPen(g.mid());
483 483
484 p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1 484 p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1
485 p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1 485 p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1
486 486
487 // corners 487 // corners
488 p->setPen(g.background()); 488 p->setPen(g.background());
489 p->drawLine(x, y, x + 1, y); 489 p->drawLine(x, y, x + 1, y);
490 p->drawLine(x, y + h - 1, x + 1, y + h - 1); 490 p->drawLine(x, y + h - 1, x + 1, y + h - 1);
491 p->drawLine(x + w - 2, y, x + w - 1, y); 491 p->drawLine(x + w - 2, y, x + w - 1, y);
492 p->drawLine(x + w - 2, y + h - 1, x + w - 1, y + h - 1); 492 p->drawLine(x + w - 2, y + h - 1, x + w - 1, y + h - 1);
493 p->drawPoint(x, y + 1); 493 p->drawPoint(x, y + 1);
494 p->drawPoint(x, y + h - 2); 494 p->drawPoint(x, y + h - 2);
495 p->drawPoint(x + w - 1, y + 1); 495 p->drawPoint(x + w - 1, y + 1);
496 p->drawPoint(x + w - 1, y + h - 2); 496 p->drawPoint(x + w - 1, y + h - 2);
497 497
498 p->setPen(oldpen); 498 p->setPen(oldpen);
499 } else 499 } else
500 qDrawShadePanel(p, x, y, w, h, g, sunken, lw, fill); 500 qDrawShadePanel(p, x, y, w, h, g, sunken, lw, fill);
501} 501}
502 502
503 503
504void LightStyle::drawIndicator(QPainter *p, int x, int y ,int w, int h, 504void LightStyle::drawIndicator(QPainter *p, int x, int y ,int w, int h,
505 const QColorGroup &g, int state, 505 const QColorGroup &g, int state,
506 bool down, bool) 506 bool down, bool)
507{ 507{
508 drawButton(p, x, y, w, h, g, TRUE, 508 drawButton(p, x, y, w, h, g, TRUE,
509 &g.brush(down ? QColorGroup::Mid : QColorGroup::Base)); 509 &g.brush(down ? QColorGroup::Mid : QColorGroup::Base));
510 510
511 p->save(); 511 p->save();
512 512
513 p->setPen(g.foreground()); 513 p->setPen(g.foreground());
514 if (state == QButton::NoChange) { 514 if (state == QButton::NoChange) {
515 p->drawLine(x + 3, y + h / 2, x + w - 4, y + h / 2); 515 p->drawLine(x + 3, y + h / 2, x + w - 4, y + h / 2);
516 p->drawLine(x + 3, y + 1 + h / 2, x + w - 4, y + 1 + h / 2); 516 p->drawLine(x + 3, y + 1 + h / 2, x + w - 4, y + 1 + h / 2);
517 p->drawLine(x + 3, y - 1 + h / 2, x + w - 4, y - 1 + h / 2); 517 p->drawLine(x + 3, y - 1 + h / 2, x + w - 4, y - 1 + h / 2);
518 } else if (state == QButton::On) { 518 } else if (state == QButton::On) {
519 p->drawLine(x + 4, y + 3, x + w - 4, y + h - 5); 519 p->drawLine(x + 4, y + 3, x + w - 4, y + h - 5);
520 p->drawLine(x + 3, y + 3, x + w - 4, y + h - 4); 520 p->drawLine(x + 3, y + 3, x + w - 4, y + h - 4);
521 p->drawLine(x + 3, y + 4, x + w - 5, y + h - 4); 521 p->drawLine(x + 3, y + 4, x + w - 5, y + h - 4);
522 p->drawLine(x + 3, y + h - 5, x + w - 5, y + 3); 522 p->drawLine(x + 3, y + h - 5, x + w - 5, y + 3);
523 p->drawLine(x + 3, y + h - 4, x + w - 4, y + 3); 523 p->drawLine(x + 3, y + h - 4, x + w - 4, y + 3);
524 p->drawLine(x + 4, y + h - 4, x + w - 4, y + 4); 524 p->drawLine(x + 4, y + h - 4, x + w - 4, y + 4);
525 } 525 }
526 526
527 p->restore(); 527 p->restore();
528} 528}
529 529
530 530
531void LightStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int w, int h, 531void LightStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int w, int h,
532 const QColorGroup &g, bool on, 532 const QColorGroup &g, bool on,
533 bool down, bool) 533 bool down, bool)
534{ 534{
535 p->save(); 535 p->save();
536 536
537 p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); 537 p->fillRect(x, y, w, h, g.brush(QColorGroup::Background));
538 538
539 p->setPen(g.dark()); 539 p->setPen(g.dark());
540 p->drawArc(x, y, w, h, 0, 16*360); 540 p->drawArc(x, y, w, h, 0, 16*360);
541 p->setPen(g.mid()); 541 p->setPen(g.mid());
542 p->drawArc(x + 1, y + 1, w - 2, h - 2, 45*16, 180*16); 542 p->drawArc(x + 1, y + 1, w - 2, h - 2, 45*16, 180*16);
543 p->setPen(g.light()); 543 p->setPen(g.light());
544 p->drawArc(x + 1, y + 1, w - 2, h - 2, 235*16, 180*16); 544 p->drawArc(x + 1, y + 1, w - 2, h - 2, 235*16, 180*16);
545 545
546 p->setPen(down ? g.mid() : g.base()); 546 p->setPen(down ? g.mid() : g.base());
547 p->setBrush(down ? g.mid() : g.base()); 547 p->setBrush(down ? g.mid() : g.base());
548 p->drawEllipse(x + 2, y + 2, w - 4, h - 4); 548 p->drawEllipse(x + 2, y + 2, w - 4, h - 4);
549 549
550 if (on) { 550 if (on) {
551 p->setBrush(g.foreground()); 551 p->setBrush(g.foreground());
552 p->drawEllipse(x + 3, y + 3, w - x - 6, h - y - 6); 552 p->drawEllipse(x + 3, y + 3, w - x - 6, h - y - 6);
553 } 553 }
554 554
555 p->restore(); 555 p->restore();
556} 556}
557 557
558 558
559 559
560#if 1 560#if 1
561//copied from QPE style 561//copied from QPE style
562void LightStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) 562void LightStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected )
563{ 563{
564#if 0 564#if 0
565 //We can't do this, because QTabBar::focusInEvent redraws the 565 //We can't do this, because QTabBar::focusInEvent redraws the
566 // tab label with the default font. 566 // tab label with the default font.
567 QFont f = tb->font(); 567 QFont f = tb->font();
568 f.setBold( selected ); 568 f.setBold( selected );
569 p->setFont( f ); 569 p->setFont( f );
570#endif 570#endif
571 QRect r( t->rect() ); 571 QRect r( t->rect() );
572 if ( tb->shape() == QTabBar::RoundedAbove ) { 572 if ( tb->shape() == QTabBar::RoundedAbove ) {
573 p->setPen( tb->colorGroup().light() ); 573 p->setPen( tb->colorGroup().light() );
574 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 574 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
575 if ( r.left() == 0 ) 575 if ( r.left() == 0 )
576 p->drawPoint( tb->rect().bottomLeft() ); 576 p->drawPoint( tb->rect().bottomLeft() );
577 else { 577 else {
578 p->setPen( tb->colorGroup().light() ); 578 p->setPen( tb->colorGroup().light() );
579 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 579 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
580 } 580 }
581 581
582 if ( selected ) { 582 if ( selected ) {
583 p->setPen( tb->colorGroup().background() ); 583 p->setPen( tb->colorGroup().background() );
584 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 584 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
585 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), 585 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2),
586 tb->colorGroup().brush( QColorGroup::Background )); 586 tb->colorGroup().brush( QColorGroup::Background ));
587 587
588 } else { 588 } else {
589 r.setRect( r.left() + 2, r.top() + 2, 589 r.setRect( r.left() + 2, r.top() + 2,
590 r.width() - 4, r.height() - 2 ); 590 r.width() - 4, r.height() - 2 );
591 p->setPen( tb->colorGroup().button() ); 591 p->setPen( tb->colorGroup().button() );
592 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 592 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
593 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), 593 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3),
594 tb->colorGroup().brush( QColorGroup::Button )); 594 tb->colorGroup().brush( QColorGroup::Button ));
595 //do shading; will not work for pixmap brushes 595 //do shading; will not work for pixmap brushes
596 QColor bg = tb->colorGroup().button(); 596 QColor bg = tb->colorGroup().button();
597 // int h,s,v; 597 // int h,s,v;
598 // bg.hsv( &h, &s, &v ); 598 // bg.hsv( &h, &s, &v );
599 int n = r.height()/2; 599 int n = r.height()/2;
600 int dark = 100; 600 int dark = 100;
601 for ( int i = 1; i < n; i++ ) { 601 for ( int i = 1; i < n; i++ ) {
602 dark = (dark * (100+(i*15)/n) )/100; 602 dark = (dark * (100+(i*15)/n) )/100;
603 p->setPen( bg.dark( dark ) ); 603 p->setPen( bg.dark( dark ) );
604 int y = r.bottom()-n+i; 604 int y = r.bottom()-n+i;
605 int x1 = r.left()+1; 605 int x1 = r.left()+1;
606 int x2 = r.right()-1; 606 int x2 = r.right()-1;
607 p->drawLine( x1, y, x2, y ); 607 p->drawLine( x1, y, x2, y );
608 } 608 }
609 609
610 } 610 }
611 611
612 p->setPen( tb->colorGroup().light() ); 612 p->setPen( tb->colorGroup().light() );
613 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); 613 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 );
614 p->drawPoint( r.left()+1, r.top() + 1 ); 614 p->drawPoint( r.left()+1, r.top() + 1 );
615 p->drawLine( r.left()+2, r.top(), 615 p->drawLine( r.left()+2, r.top(),
616 r.right() - 2, r.top() ); 616 r.right() - 2, r.top() );
617 617
618 p->setPen( tb->colorGroup().dark() ); 618 p->setPen( tb->colorGroup().dark() );
619 p->drawPoint( r.right() - 1, r.top() + 1 ); 619 p->drawPoint( r.right() - 1, r.top() + 1 );
620 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); 620 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1);
621 } else if ( tb->shape() == QTabBar::RoundedBelow ) { 621 } else if ( tb->shape() == QTabBar::RoundedBelow ) {
622 if ( selected ) { 622 if ( selected ) {
623 p->setPen( tb->colorGroup().background() ); 623 p->setPen( tb->colorGroup().background() );
624 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 624 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
625 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), 625 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2),
626 tb->palette().normal().brush( QColorGroup::Background )); 626 tb->palette().normal().brush( QColorGroup::Background ));
627 } else { 627 } else {
628 p->setPen( tb->colorGroup().dark() ); 628 p->setPen( tb->colorGroup().dark() );
629 p->drawLine( r.left(), r.top(), 629 p->drawLine( r.left(), r.top(),
630 r.right(), r.top() ); 630 r.right(), r.top() );
631 r.setRect( r.left() + 2, r.top(), 631 r.setRect( r.left() + 2, r.top(),
632 r.width() - 4, r.height() - 2 ); 632 r.width() - 4, r.height() - 2 );
633 p->setPen( tb->colorGroup().button() ); 633 p->setPen( tb->colorGroup().button() );
634 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 634 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
635 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), 635 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3),
636 tb->palette().normal().brush( QColorGroup::Button )); 636 tb->palette().normal().brush( QColorGroup::Button ));
637 } 637 }
638 638
639 p->setPen( tb->colorGroup().dark() ); 639 p->setPen( tb->colorGroup().dark() );
640 p->drawLine( r.right(), r.top(), 640 p->drawLine( r.right(), r.top(),
641 r.right(), r.bottom() - 2 ); 641 r.right(), r.bottom() - 2 );
642 p->drawPoint( r.right() - 1, r.bottom() - 1 ); 642 p->drawPoint( r.right() - 1, r.bottom() - 1 );
643 p->drawLine( r.right() - 2, r.bottom(), 643 p->drawLine( r.right() - 2, r.bottom(),
644 r.left() + 2, r.bottom() ); 644 r.left() + 2, r.bottom() );
645 645
646 p->setPen( tb->colorGroup().light() ); 646 p->setPen( tb->colorGroup().light() );
647 p->drawLine( r.left(), r.top()+1, 647 p->drawLine( r.left(), r.top()+1,
648 r.left(), r.bottom() - 2 ); 648 r.left(), r.bottom() - 2 );
649 p->drawPoint( r.left() + 1, r.bottom() - 1 ); 649 p->drawPoint( r.left() + 1, r.bottom() - 1 );
650 if ( r.left() == 0 ) 650 if ( r.left() == 0 )
651 p->drawPoint( tb->rect().topLeft() ); 651 p->drawPoint( tb->rect().topLeft() );
652 652
653 } else { 653 } else {
654 QCommonStyle::drawTab( p, tb, t, selected ); 654 QCommonStyle::drawTab( p, tb, t, selected );
655 } 655 }
656} 656}
657 657
658#else 658#else
659 659
660void LightStyle::drawTab(QPainter *p, const QTabBar *tabbar, QTab *tab, 660void LightStyle::drawTab(QPainter *p, const QTabBar *tabbar, QTab *tab,
661 bool selected) 661 bool selected)
662{ 662{
663 p->save(); 663 p->save();
664 664
665 QColorGroup g = tabbar->colorGroup(); 665 QColorGroup g = tabbar->colorGroup();
666 QRect fr(tab->r); 666 QRect fr(tab->r);
667 fr.setLeft(fr.left() + 2); 667 fr.setLeft(fr.left() + 2);
668 668
669 if (! selected) { 669 if (! selected) {
670 if (tabbar->shape() == QTabBar::RoundedAbove || 670 if (tabbar->shape() == QTabBar::RoundedAbove ||
671 tabbar->shape() == QTabBar::TriangularAbove) { 671 tabbar->shape() == QTabBar::TriangularAbove) {
672 672
673 fr.setTop(fr.top() + 2); 673 fr.setTop(fr.top() + 2);
674 } else { 674 } else {
675 fr.setBottom(fr.bottom() - 2); 675 fr.setBottom(fr.bottom() - 2);
676 } 676 }
677 } 677 }
678 678
679 QRegion tabr(tab->r); 679 QRegion tabr(tab->r);
680 680
681 QPointArray cliptri(4); 681 QPointArray cliptri(4);
682 cliptri.setPoint(0, fr.left(), fr.top()); 682 cliptri.setPoint(0, fr.left(), fr.top());
683 cliptri.setPoint(1, fr.left(), fr.top() + 5); 683 cliptri.setPoint(1, fr.left(), fr.top() + 5);
684 cliptri.setPoint(2, fr.left() + 5, fr.top()); 684 cliptri.setPoint(2, fr.left() + 5, fr.top());
685 cliptri.setPoint(3, fr.left(), fr.top()); 685 cliptri.setPoint(3, fr.left(), fr.top());
686 QRegion trir(cliptri); 686 QRegion trir(cliptri);
687 p->setClipRegion(tabr - trir); 687 p->setClipRegion(tabr - trir);
688 688
689 p->setPen( NoPen ); 689 p->setPen( NoPen );
690 p->setBrush(g.brush(selected ? QColorGroup::Background : QColorGroup::Mid)); 690 p->setBrush(g.brush(selected ? QColorGroup::Background : QColorGroup::Mid));
691 691
692 fr.setWidth(fr.width() - 1); 692 fr.setWidth(fr.width() - 1);
693 p->drawRect(fr.left() + 1, fr.top() + 1, fr.width() - 2, fr.height() - 2); 693 p->drawRect(fr.left() + 1, fr.top() + 1, fr.width() - 2, fr.height() - 2);
694 694
695 if (tabbar->shape() == QTabBar::RoundedAbove) { 695 if (tabbar->shape() == QTabBar::RoundedAbove) {
696 // "rounded" tabs on top 696 // "rounded" tabs on top
697 fr.setBottom(fr.bottom() - 1); 697 fr.setBottom(fr.bottom() - 1);
698 698
699 p->setPen(g.dark()); 699 p->setPen(g.dark());
700 p->drawLine(fr.left(), fr.top() + 5, fr.left(), fr.bottom() - 1); 700 p->drawLine(fr.left(), fr.top() + 5, fr.left(), fr.bottom() - 1);
701 p->drawLine(fr.left(), fr.top() + 5, fr.left() + 5, fr.top()); 701 p->drawLine(fr.left(), fr.top() + 5, fr.left() + 5, fr.top());
702 p->drawLine(fr.left() + 5, fr.top(), fr.right() - 1, fr.top()); 702 p->drawLine(fr.left() + 5, fr.top(), fr.right() - 1, fr.top());
703 p->drawLine(fr.right(), fr.top() + 1, fr.right(), fr.bottom() - 1); 703 p->drawLine(fr.right(), fr.top() + 1, fr.right(), fr.bottom() - 1);
704 704
705 if (selected) { 705 if (selected) {
706 p->drawLine(fr.right(), fr.bottom(), fr.right() + 2, fr.bottom()); 706 p->drawLine(fr.right(), fr.bottom(), fr.right() + 2, fr.bottom());
707 p->drawPoint(fr.left(), fr.bottom()); 707 p->drawPoint(fr.left(), fr.bottom());
708 } else 708 } else
709 p->drawLine(fr.left(), fr.bottom(), fr.right() + 2, fr.bottom()); 709 p->drawLine(fr.left(), fr.bottom(), fr.right() + 2, fr.bottom());
710 710
711 if (fr.left() == 2) { 711 if (fr.left() == 2) {
712 p->drawPoint(fr.left() - 1, fr.bottom() + 1); 712 p->drawPoint(fr.left() - 1, fr.bottom() + 1);
713 p->drawPoint(fr.left() - 2, fr.bottom() + 2); 713 p->drawPoint(fr.left() - 2, fr.bottom() + 2);
714 } 714 }
715 715
716 if (selected) { 716 if (selected) {
717 p->setPen(g.mid()); 717 p->setPen(g.mid());
718 p->drawLine(fr.right() - 1, fr.top() + 1, fr.right() - 1, fr.bottom() - 2); 718 p->drawLine(fr.right() - 1, fr.top() + 1, fr.right() - 1, fr.bottom() - 2);
719 } 719 }
720 720
721 p->setPen(g.light()); p->setPen(red); 721 p->setPen(g.light()); p->setPen(red);
722 p->drawLine(fr.left() + 1, fr.top() + 6, fr.left() + 1, 722 p->drawLine(fr.left() + 1, fr.top() + 6, fr.left() + 1,
723 fr.bottom() - (selected ? 0 : 1)); 723 fr.bottom() - (selected ? 0 : 1));
724 p->drawLine(fr.left() + 1, fr.top() + 5, fr.left() + 5, fr.top() + 1); 724 p->drawLine(fr.left() + 1, fr.top() + 5, fr.left() + 5, fr.top() + 1);
725 p->drawLine(fr.left() + 6, fr.top() + 1, fr.right() - 3, fr.top() + 1); 725 p->drawLine(fr.left() + 6, fr.top() + 1, fr.right() - 3, fr.top() + 1);
726 if (selected) { 726 if (selected) {
727 p->drawLine(fr.right() + 1, fr.bottom() + 1, 727 p->drawLine(fr.right() + 1, fr.bottom() + 1,
728 fr.right() + 2, fr.bottom() + 1); 728 fr.right() + 2, fr.bottom() + 1);
729 p->drawLine(fr.left(), fr.bottom() + 1, fr.left() + 1, fr.bottom() + 1); 729 p->drawLine(fr.left(), fr.bottom() + 1, fr.left() + 1, fr.bottom() + 1);
730 } else 730 } else
731 p->drawLine(fr.left(), fr.bottom() + 1, 731 p->drawLine(fr.left(), fr.bottom() + 1,
732 fr.right() + 2, fr.bottom() + 1); 732 fr.right() + 2, fr.bottom() + 1);
733 } else if (tabbar->shape() == QTabBar::RoundedBelow) { 733 } else if (tabbar->shape() == QTabBar::RoundedBelow) {
734 // "rounded" tabs on bottom 734 // "rounded" tabs on bottom
735 fr.setTop(fr.top() + 1); 735 fr.setTop(fr.top() + 1);
736 736
737 p->setPen(g.dark()); 737 p->setPen(g.dark());
738 p->drawLine(fr.left(), fr.top(), fr.left(), fr.bottom() - 1); 738 p->drawLine(fr.left(), fr.top(), fr.left(), fr.bottom() - 1);
739 p->drawLine(fr.left() + 1, fr.bottom(), fr.right() - 1, fr.bottom()); 739 p->drawLine(fr.left() + 1, fr.bottom(), fr.right() - 1, fr.bottom());
740 p->drawLine(fr.right(), fr.top(), fr.right(), fr.bottom() - 1); 740 p->drawLine(fr.right(), fr.top(), fr.right(), fr.bottom() - 1);
741 741
742 if (! selected) 742 if (! selected)
743 p->drawLine(fr.left(), fr.top(), fr.right() + 3, fr.top()); 743 p->drawLine(fr.left(), fr.top(), fr.right() + 3, fr.top());
744 else 744 else
745 p->drawLine(fr.right(), fr.top(), fr.right() + 3, fr.top()); 745 p->drawLine(fr.right(), fr.top(), fr.right() + 3, fr.top());
746 746
747 p->setPen(g.mid()); 747 p->setPen(g.mid());
748 if (selected) 748 if (selected)
749 p->drawLine(fr.right() - 1, fr.top() + 1, fr.right() - 1, fr.bottom() - 1); 749 p->drawLine(fr.right() - 1, fr.top() + 1, fr.right() - 1, fr.bottom() - 1);
750 else 750 else
751 p->drawLine(fr.left(), fr.top() - 1, fr.right() + 3, fr.top() - 1); 751 p->drawLine(fr.left(), fr.top() - 1, fr.right() + 3, fr.top() - 1);
752 752
753 p->setPen(g.light()); 753 p->setPen(g.light());
754 p->drawLine(fr.left() + 1, fr.top() + (selected ? -1 : 2), 754 p->drawLine(fr.left() + 1, fr.top() + (selected ? -1 : 2),
755 fr.left() + 1, fr.bottom() - 1); 755 fr.left() + 1, fr.bottom() - 1);
756 756
757 } else { 757 } else {
758 // triangular drawing code 758 // triangular drawing code
759 QCommonStyle::drawTab(p, tabbar, tab, selected); 759 QCommonStyle::drawTab(p, tabbar, tab, selected);
760 } 760 }
761 761
762 p->restore(); 762 p->restore();
763} 763}
764#endif 764#endif
765 765
766void LightStyle::drawSlider(QPainter *p, int x, int y, int w, int h, 766void LightStyle::drawSlider(QPainter *p, int x, int y, int w, int h,
767 const QColorGroup &g, Qt::Orientation orientation, 767 const QColorGroup &g, Qt::Orientation orientation,
768 bool above, bool below) 768 bool above, bool below)
769{ 769{
770 drawButton(p, x, y, w, h, g, FALSE, &g.brush(QColorGroup::Button)); 770 drawButton(p, x, y, w, h, g, FALSE, &g.brush(QColorGroup::Button));
771 771
772 if (orientation == Horizontal) { 772 if (orientation == Horizontal) {
773 if (above && below) { 773 if (above && below) {
774 drawArrow(p, Qt::UpArrow, FALSE, x + 1, y + 1, w, h / 2, g, TRUE); 774 drawArrow(p, Qt::UpArrow, FALSE, x + 1, y + 1, w, h / 2, g, TRUE);
775 drawArrow(p, Qt::DownArrow, FALSE, x + 1, y + (h / 2) - 1, 775 drawArrow(p, Qt::DownArrow, FALSE, x + 1, y + (h / 2) - 1,
776 w, h / 2, g, TRUE); 776 w, h / 2, g, TRUE);
777 } else 777 } else
778 drawArrow(p, (above) ? Qt::UpArrow : Qt::DownArrow, 778 drawArrow(p, (above) ? Qt::UpArrow : Qt::DownArrow,
779 FALSE, x + 1, y, w, h, g, TRUE); 779 FALSE, x + 1, y, w, h, g, TRUE);
780 } else { 780 } else {
781 if (above && below) { 781 if (above && below) {
782 drawArrow(p, Qt::LeftArrow, FALSE, x + 1, y, w / 2, h, g, TRUE); 782 drawArrow(p, Qt::LeftArrow, FALSE, x + 1, y, w / 2, h, g, TRUE);
783 drawArrow(p, Qt::RightArrow, FALSE, x + (w / 2) - 2, y, w / 2, h, g, TRUE); 783 drawArrow(p, Qt::RightArrow, FALSE, x + (w / 2) - 2, y, w / 2, h, g, TRUE);
784 } else 784 } else
785 drawArrow(p, (above) ? Qt::LeftArrow : Qt::RightArrow, 785 drawArrow(p, (above) ? Qt::LeftArrow : Qt::RightArrow,
786 FALSE, x, y, w, h, g, TRUE); 786 FALSE, x, y, w, h, g, TRUE);
787 } 787 }
788} 788}
789 789
790 790
791void LightStyle::drawSliderGroove(QPainter *p, int x, int y, int w, int h, 791void LightStyle::drawSliderGroove(QPainter *p, int x, int y, int w, int h,
792 const QColorGroup& g, QCOORD c, 792 const QColorGroup& g, QCOORD c,
793 Qt::Orientation orientation) 793 Qt::Orientation orientation)
794{ 794{
795 if (orientation == Horizontal) 795 if (orientation == Horizontal)
796 drawButton(p, x, y+c - 3, w, 6, g, TRUE, &g.brush(QColorGroup::Mid)); 796 drawButton(p, x, y+c - 3, w, 6, g, TRUE, &g.brush(QColorGroup::Mid));
797 else 797 else
798 drawButton(p, x+c - 3, y, 6, h, g, TRUE, &g.brush(QColorGroup::Mid)); 798 drawButton(p, x+c - 3, y, 6, h, g, TRUE, &g.brush(QColorGroup::Mid));
799} 799}
800 800
801 801
802void LightStyle::scrollBarMetrics(const QScrollBar *scrollbar, 802void LightStyle::scrollBarMetrics(const QScrollBar *scrollbar,
803 int &sliderMin, int &sliderMax, 803 int &sliderMin, int &sliderMax,
804 int &sliderLength, int &buttonDim) const 804 int &sliderLength, int &buttonDim) const
805{ 805{
806 int maxLength; 806 int maxLength;
807 int length = ((scrollbar->orientation() == Horizontal) ? 807 int length = ((scrollbar->orientation() == Horizontal) ?
808 scrollbar->width() : scrollbar->height()); 808 scrollbar->width() : scrollbar->height());
809 int extent = ((scrollbar->orientation() == Horizontal) ? 809 int extent = ((scrollbar->orientation() == Horizontal) ?
810 scrollbar->height() : scrollbar->width()); 810 scrollbar->height() : scrollbar->width());
811 extent--; 811 extent--;
812 812
813 if (length > (extent + defaultFrameWidth() - 1) * 2 + defaultFrameWidth()) 813 if (length > (extent + defaultFrameWidth() - 1) * 2 + defaultFrameWidth())
814 buttonDim = extent - defaultFrameWidth(); 814 buttonDim = extent - defaultFrameWidth();
815 else 815 else
816 buttonDim = (length - defaultFrameWidth()) / 2 - 1; 816 buttonDim = (length - defaultFrameWidth()) / 2 - 1;
817 817
818 sliderMin = buttonDim; 818 sliderMin = buttonDim;
819 maxLength = length - buttonDim * 3; 819 maxLength = length - buttonDim * 3;
820 820
821 if (scrollbar->maxValue() != scrollbar->minValue()) { 821 if (scrollbar->maxValue() != scrollbar->minValue()) {
822 uint range = scrollbar->maxValue() - scrollbar->minValue(); 822 uint range = scrollbar->maxValue() - scrollbar->minValue();
823 sliderLength = (scrollbar->pageStep() * maxLength) / 823 sliderLength = (scrollbar->pageStep() * maxLength) /
824 (range + scrollbar->pageStep()); 824 (range + scrollbar->pageStep());
825 825
826 if (sliderLength < buttonDim || range > INT_MAX / 2) 826 if (sliderLength < buttonDim || range > INT_MAX / 2)
827 sliderLength = buttonDim; 827 sliderLength = buttonDim;
828 if (sliderLength > maxLength) 828 if (sliderLength > maxLength)
829 sliderLength = maxLength; 829 sliderLength = maxLength;
830 } else 830 } else
831 sliderLength = maxLength; 831 sliderLength = maxLength;
832 832
833 sliderMax = sliderMin + maxLength - sliderLength; 833 sliderMax = sliderMin + maxLength - sliderLength;
834} 834}
835 835
836 836
837QStyle::ScrollControl LightStyle::scrollBarPointOver(const QScrollBar *scrollbar, 837QStyle::ScrollControl LightStyle::scrollBarPointOver(const QScrollBar *scrollbar,
838 int sliderStart, const QPoint &p) 838 int sliderStart, const QPoint &p)
839{ 839{
840 if (! scrollbar->rect().contains(p)) 840 if (! scrollbar->rect().contains(p))
841 return NoScroll; 841 return NoScroll;
842 842
843 int sliderMin, sliderMax, sliderLength, buttonDim, pos; 843 int sliderMin, sliderMax, sliderLength, buttonDim, pos;
844 scrollBarMetrics( scrollbar, sliderMin, sliderMax, sliderLength, buttonDim ); 844 scrollBarMetrics( scrollbar, sliderMin, sliderMax, sliderLength, buttonDim );
845 845
846 if (scrollbar->orientation() == Horizontal) 846 if (scrollbar->orientation() == Horizontal)
847 pos = p.x(); 847 pos = p.x();
848 else 848 else
849 pos = p.y(); 849 pos = p.y();
850 850
851 if (pos < buttonDim) 851 if (pos < buttonDim)
852 return SubLine; 852 return SubLine;
853 if (pos < sliderStart) 853 if (pos < sliderStart)
854 return SubPage; 854 return SubPage;
855 if (pos < sliderStart + sliderLength) 855 if (pos < sliderStart + sliderLength)
856 return Slider; 856 return Slider;
857 if (pos < sliderMax + sliderLength) 857 if (pos < sliderMax + sliderLength)
858 return AddPage; 858 return AddPage;
859 if (pos < sliderMax + sliderLength + buttonDim) 859 if (pos < sliderMax + sliderLength + buttonDim)
860 return SubLine; 860 return SubLine;
861 return AddLine; 861 return AddLine;
862} 862}
863 863
864 864
865 865
866void LightStyle::drawScrollBarControls( QPainter* p, const QScrollBar* scrollbar, 866void LightStyle::drawScrollBarControls( QPainter* p, const QScrollBar* scrollbar,
867 int sliderStart, uint controls, 867 int sliderStart, uint controls,
868 uint activeControl ) 868 uint activeControl )
869{ 869{
870 QColorGroup g = scrollbar->colorGroup(); 870 QColorGroup g = scrollbar->colorGroup();
871 871
872 int sliderMin, sliderMax, sliderLength, buttonDim; 872 int sliderMin, sliderMax, sliderLength, buttonDim;
873 scrollBarMetrics( scrollbar, sliderMin, sliderMax, sliderLength, buttonDim ); 873 scrollBarMetrics( scrollbar, sliderMin, sliderMax, sliderLength, buttonDim );
874 874
875 if (sliderStart > sliderMax) { // sanity check 875 if (sliderStart > sliderMax) { // sanity check
876 sliderStart = sliderMax; 876 sliderStart = sliderMax;
877 } 877 }
878 878
879 QRect addR, subR, subR2, addPageR, subPageR, sliderR; 879 QRect addR, subR, subR2, addPageR, subPageR, sliderR;
880 int length = ((scrollbar->orientation() == Horizontal) ? 880 int length = ((scrollbar->orientation() == Horizontal) ?
881 scrollbar->width() : scrollbar->height()); 881 scrollbar->width() : scrollbar->height());
882 int extent = ((scrollbar->orientation() == Horizontal) ? 882 int extent = ((scrollbar->orientation() == Horizontal) ?
883 scrollbar->height() : scrollbar->width()); 883 scrollbar->height() : scrollbar->width());
884 884
885 885
886 int fudge = 3; //####disgusting hack 886 int fudge = 3; //####disgusting hack
887 887
888 if (scrollbar->orientation() == Horizontal) { 888 if (scrollbar->orientation() == Horizontal) {
889 subR.setRect(0, defaultFrameWidth(), 889 subR.setRect(0, defaultFrameWidth(),
890 buttonDim + fudge, buttonDim); 890 buttonDim + fudge, buttonDim);
891 subR2.setRect(length - (buttonDim * 2), defaultFrameWidth() , 891 subR2.setRect(length - (buttonDim * 2), defaultFrameWidth() ,
892 buttonDim, buttonDim); 892 buttonDim, buttonDim);
893 addR.setRect(length - buttonDim, defaultFrameWidth(), 893 addR.setRect(length - buttonDim, defaultFrameWidth(),
894 buttonDim, buttonDim); 894 buttonDim, buttonDim);
895 } else { 895 } else {
896 subR.setRect(defaultFrameWidth() + 1, 0, 896 subR.setRect(defaultFrameWidth() + 1, 0,
897 buttonDim, buttonDim + fudge); 897 buttonDim, buttonDim + fudge);
898 subR2.setRect(defaultFrameWidth() + 1, length - (buttonDim * 2), 898 subR2.setRect(defaultFrameWidth() + 1, length - (buttonDim * 2),
899 buttonDim, buttonDim); 899 buttonDim, buttonDim);
900 addR.setRect(defaultFrameWidth() + 1, length - buttonDim, 900 addR.setRect(defaultFrameWidth() + 1, length - buttonDim,
901 buttonDim, buttonDim); 901 buttonDim, buttonDim);
902 } 902 }
903 903
904 int sliderEnd = sliderStart + sliderLength; 904 int sliderEnd = sliderStart + sliderLength;
905 int sliderW = extent - defaultFrameWidth() - 1; 905 int sliderW = extent - defaultFrameWidth() - 1;
906 if (scrollbar->orientation() == Horizontal) { 906 if (scrollbar->orientation() == Horizontal) {
907 subPageR.setRect( subR.right() + 1, defaultFrameWidth(), 907 subPageR.setRect( subR.right() + 1, defaultFrameWidth(),
908 sliderStart - subR.right() - 1 , sliderW ); 908 sliderStart - subR.right() - 1 , sliderW );
909 addPageR.setRect( sliderEnd, defaultFrameWidth(), 909 addPageR.setRect( sliderEnd, defaultFrameWidth(),
910 subR2.left() - sliderEnd, sliderW ); 910 subR2.left() - sliderEnd, sliderW );
911 sliderR.setRect( sliderStart, defaultFrameWidth(), sliderLength, sliderW ); 911 sliderR.setRect( sliderStart, defaultFrameWidth(), sliderLength, sliderW );
912 } else { 912 } else {
913 subPageR.setRect( defaultFrameWidth(), subR.bottom() + 1, 913 subPageR.setRect( defaultFrameWidth(), subR.bottom() + 1,
914 sliderW, sliderStart - subR.bottom() - 1 ); 914 sliderW, sliderStart - subR.bottom() - 1 );
915 addPageR.setRect( defaultFrameWidth(), sliderEnd, 915 addPageR.setRect( defaultFrameWidth(), sliderEnd,
916 sliderW, subR2.top() - sliderEnd ); 916 sliderW, subR2.top() - sliderEnd );
917 sliderR .setRect( defaultFrameWidth(), sliderStart, 917 sliderR .setRect( defaultFrameWidth(), sliderStart,
918 sliderW, sliderLength ); 918 sliderW, sliderLength );
919 } 919 }
920 920
921 if ( controls == ( AddLine | SubLine | AddPage | SubPage | 921 if ( controls == ( AddLine | SubLine | AddPage | SubPage |
922 Slider | First | Last ) ) { 922 Slider | First | Last ) ) {
923 if (scrollbar->orientation() == Horizontal) 923 if (scrollbar->orientation() == Horizontal)
924 qDrawShadePanel(p, 0, 0, length, 2, g, TRUE, 1, 924 qDrawShadePanel(p, 0, 0, length, 2, g, TRUE, 1,
925 &g.brush(QColorGroup::Background)); 925 &g.brush(QColorGroup::Background));
926 else 926 else
927 qDrawShadePanel(p, 0, 0, 2, length, g, TRUE, 1, 927 qDrawShadePanel(p, 0, 0, 2, length, g, TRUE, 1,
928 &g.brush(QColorGroup::Background)); 928 &g.brush(QColorGroup::Background));
929 } 929 }
930 930
931 if ( controls & AddLine ) 931 if ( controls & AddLine )
932 drawArrow( p, (scrollbar->orientation() == Vertical) ? DownArrow : RightArrow, 932 drawArrow( p, (scrollbar->orientation() == Vertical) ? DownArrow : RightArrow,
933 FALSE, addR.x(), addR.y(), 933 FALSE, addR.x(), addR.y(),
934 addR.width(), addR.height(), 934 addR.width(), addR.height(),
935 (( activeControl == AddLine ) ? 935 (( activeControl == AddLine ) ?
936 singleton->hoverPalette.active() : g), 936 singleton->hoverPalette.active() : g),
937 TRUE, &g.brush(QColorGroup::Background)); 937 TRUE, &g.brush(QColorGroup::Background));
938 if ( controls & SubLine ) { 938 if ( controls & SubLine ) {
939 drawArrow( p, (scrollbar->orientation() == Vertical) ? UpArrow : LeftArrow, 939 drawArrow( p, (scrollbar->orientation() == Vertical) ? UpArrow : LeftArrow,
940 FALSE, subR.x(), subR.y(), 940 FALSE, subR.x(), subR.y(),
941 subR.width(), subR.height(), 941 subR.width(), subR.height(),
942 (( activeControl == SubLine ) ? 942 (( activeControl == SubLine ) ?
943 singleton->hoverPalette.active() : g), 943 singleton->hoverPalette.active() : g),
944 TRUE, &g.brush(QColorGroup::Background)); 944 TRUE, &g.brush(QColorGroup::Background));
945 drawArrow( p, (scrollbar->orientation() == Vertical) ? UpArrow : LeftArrow, 945 drawArrow( p, (scrollbar->orientation() == Vertical) ? UpArrow : LeftArrow,
946 FALSE, subR2.x(), subR2.y(), 946 FALSE, subR2.x(), subR2.y(),
947 subR2.width(), subR2.height(), 947 subR2.width(), subR2.height(),
948 (( activeControl == SubLine ) ? 948 (( activeControl == SubLine ) ?
949 singleton->hoverPalette.active() : g), 949 singleton->hoverPalette.active() : g),
950 TRUE, &g.brush(QColorGroup::Background)); 950 TRUE, &g.brush(QColorGroup::Background));
951 } 951 }
952 952
953 if ( controls & SubPage ) 953 if ( controls & SubPage )
954 p->fillRect( subPageR, 954 p->fillRect( subPageR,
955 ((activeControl == SubPage) ? 955 ((activeControl == SubPage) ?
956 g.brush( QColorGroup::Dark ) : 956 g.brush( QColorGroup::Dark ) :
957 g.brush( QColorGroup::Mid ))); 957 g.brush( QColorGroup::Mid )));
958 if ( controls & AddPage ) 958 if ( controls & AddPage )
959 p->fillRect( addPageR, 959 p->fillRect( addPageR,
960 ((activeControl == AddPage) ? 960 ((activeControl == AddPage) ?
961 g.brush( QColorGroup::Dark ) : 961 g.brush( QColorGroup::Dark ) :
962 g.brush( QColorGroup::Mid ))); 962 g.brush( QColorGroup::Mid )));
963 963
964 if ( controls & Slider ) { 964 if ( controls & Slider ) {
965 965
966 QPoint bo = p->brushOrigin(); 966 QPoint bo = p->brushOrigin();
967 p->setBrushOrigin(sliderR.topLeft()); 967 p->setBrushOrigin(sliderR.topLeft());
968 if ( sliderR.isValid() ) { 968 if ( sliderR.isValid() ) {
969 p->fillRect( sliderR.x(), sliderR.y(), 2, 2, 969 p->fillRect( sliderR.x(), sliderR.y(), 2, 2,
970 g.brush( QColorGroup::Mid )); 970 g.brush( QColorGroup::Mid ));
971 p->fillRect( sliderR.x() + sliderR.width() - 2, 971 p->fillRect( sliderR.x() + sliderR.width() - 2,
972 sliderR.y(), 2, 2, 972 sliderR.y(), 2, 2,
973 g.brush( QColorGroup::Mid )); 973 g.brush( QColorGroup::Mid ));
974 p->fillRect( sliderR.x() + sliderR.width() - 2, 974 p->fillRect( sliderR.x() + sliderR.width() - 2,
975 sliderR.y() + sliderR.height() - 2, 2, 2, 975 sliderR.y() + sliderR.height() - 2, 2, 2,
976 g.brush( QColorGroup::Mid )); 976 g.brush( QColorGroup::Mid ));
977 p->fillRect( sliderR.x(), 977 p->fillRect( sliderR.x(),
978 sliderR.y() + sliderR.height() - 2, 2, 2, 978 sliderR.y() + sliderR.height() - 2, 2, 2,
979 g.brush( QColorGroup::Mid )); 979 g.brush( QColorGroup::Mid ));
980 980
981 QColorGroup cg( g ); 981 QColorGroup cg( g );
982 cg.setBrush( QColorGroup::Background, g.brush( QColorGroup::Mid ) ); 982 cg.setBrush( QColorGroup::Background, g.brush( QColorGroup::Mid ) );
983 drawBevelButton( p, sliderR.x(), sliderR.y(), 983 drawBevelButton( p, sliderR.x(), sliderR.y(),
984 sliderR.width(), sliderR.height(), 984 sliderR.width(), sliderR.height(),
985 cg, FALSE, &g.brush( QColorGroup::Button ) ); 985 cg, FALSE, &g.brush( QColorGroup::Button ) );
986 } 986 }
987 987
988 p->setBrushOrigin(bo); 988 p->setBrushOrigin(bo);
989 } 989 }
990} 990}
991 991
992 992
993void LightStyle::drawToolBarHandle(QPainter *p, const QRect &rect, 993void LightStyle::drawToolBarHandle(QPainter *p, const QRect &rect,
994 Qt::Orientation orientation, 994 Qt::Orientation orientation,
995 bool, const QColorGroup &g, bool) 995 bool, const QColorGroup &g, bool)
996{ 996{
997 p->save(); 997 p->save();
998 p->setPen(g.mid()); 998 p->setPen(g.mid());
999 p->setBrush(g.brush(QColorGroup::Mid)); 999 p->setBrush(g.brush(QColorGroup::Mid));
1000 1000
1001 if (orientation == Qt::Horizontal) { 1001 if (orientation == Qt::Horizontal) {
1002 QRect l, r; 1002 QRect l, r;
1003 l.setRect(rect.x() + 1, rect.y() + 1, rect.width() - 5, rect.height() - 2); 1003 l.setRect(rect.x() + 1, rect.y() + 1, rect.width() - 5, rect.height() - 2);
1004 r.setRect(l.right() + 1, l.y(), 3, l.height()); 1004 r.setRect(l.right() + 1, l.y(), 3, l.height());
1005 1005
1006 p->drawRect(l); 1006 p->drawRect(l);
1007 qDrawShadePanel(p, r, g, FALSE); 1007 qDrawShadePanel(p, r, g, FALSE);
1008 } else { 1008 } else {
1009 QRect t, b; 1009 QRect t, b;
1010 t.setRect(rect.x() + 1, rect.y() + 1, rect.width() - 2, rect.height() - 5); 1010 t.setRect(rect.x() + 1, rect.y() + 1, rect.width() - 2, rect.height() - 5);
1011 b.setRect(t.x(), t.bottom() + 1, t.width(), 3); 1011 b.setRect(t.x(), t.bottom() + 1, t.width(), 3);
1012 1012
1013 p->drawRect(t); 1013 p->drawRect(t);
1014 qDrawShadePanel(p, b, g, FALSE); 1014 qDrawShadePanel(p, b, g, FALSE);
1015 } 1015 }
1016 1016
1017 p->restore(); 1017 p->restore();
1018} 1018}
1019 1019
1020 1020
1021bool LightStyle::eventFilter(QObject *object, QEvent *event) 1021bool LightStyle::eventFilter(QObject *object, QEvent *event)
1022{ 1022{
1023 switch(event->type()) { 1023 switch(event->type()) {
1024 case QEvent::Enter: 1024 case QEvent::Enter:
1025 { 1025 {
1026 if (! object->isWidgetType() || 1026 if (! object->isWidgetType() ||
1027 ! object->inherits("QPushButton")) 1027 ! object->inherits("QPushButton"))
1028 break; 1028 break;
1029 1029
1030 singleton->hoverWidget = (QWidget *) object; 1030 singleton->hoverWidget = (QWidget *) object;
1031 if (! singleton->hoverWidget->isEnabled()) { 1031 if (! singleton->hoverWidget->isEnabled()) {
1032 singleton->hoverWidget = 0; 1032 singleton->hoverWidget = 0;
1033 break; 1033 break;
1034 } 1034 }
1035 1035
1036 QPalette pal = singleton->hoverWidget->palette(); 1036 QPalette pal = singleton->hoverWidget->palette();
1037 if (singleton->hoverWidget->ownPalette()) 1037 if (singleton->hoverWidget->ownPalette())
1038 singleton->savePalette = new QPalette(pal); 1038 singleton->savePalette = new QPalette(pal);
1039 1039
1040 singleton->hoverWidget->setPalette(singleton->hoverPalette); 1040 singleton->hoverWidget->setPalette(singleton->hoverPalette);
1041 1041
1042 break; 1042 break;
1043 } 1043 }
1044 1044
1045 case QEvent::Leave: 1045 case QEvent::Leave:
1046 { 1046 {
1047 if (object != singleton->hoverWidget) 1047 if (object != singleton->hoverWidget)
1048 break; 1048 break;
1049 1049
1050 if (singleton->savePalette) { 1050 if (singleton->savePalette) {
1051 singleton->hoverWidget->setPalette(*(singleton->savePalette)); 1051 singleton->hoverWidget->setPalette(*(singleton->savePalette));
1052 delete singleton->savePalette; 1052 delete singleton->savePalette;
1053 singleton->savePalette = 0; 1053 singleton->savePalette = 0;
1054 } else 1054 } else
1055 singleton->hoverWidget->unsetPalette(); 1055 singleton->hoverWidget->unsetPalette();
1056 1056
1057 singleton->hoverWidget = 0; 1057 singleton->hoverWidget = 0;
1058 1058
1059 break; 1059 break;
1060 } 1060 }
1061 1061
1062 default: 1062 default:
1063 { 1063 {
1064 ; 1064 ;
1065 } 1065 }
1066 } 1066 }
1067 1067
1068 return QWindowsStyle::eventFilter(object, event); 1068 return QWindowsStyle::eventFilter(object, event);
1069} 1069}
1070 1070
1071 1071
1072 static const int motifItemFrame = 1;// menu item frame width 1072 static const int motifItemFrame = 1;// menu item frame width
1073 static const int motifSepHeight = 2;// separator item height 1073 static const int motifSepHeight = 2;// separator item height
1074 static const int motifItemHMargin = 1;// menu item hor text margin 1074 static const int motifItemHMargin = 1;// menu item hor text margin
1075 static const int motifItemVMargin = 2;// menu item ver text margin 1075 static const int motifItemVMargin = 2;// menu item ver text margin
1076 static const int motifArrowHMargin = 0;// arrow horizontal margin 1076 static const int motifArrowHMargin = 0;// arrow horizontal margin
1077 static const int motifTabSpacing = 12;// space between text and tab 1077 static const int motifTabSpacing = 12;// space between text and tab
1078 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark 1078 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark
1079 static const int windowsRightBorder= 8; // right border on windows 1079 static const int windowsRightBorder= 8; // right border on windows
1080static const int windowsCheckMarkWidth = 2; // checkmarks width on windows 1080static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
1081 1081
1082/*! \reimp 1082/*! \reimp
1083*/ 1083*/
1084int LightStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ ) 1084int LightStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ )
1085{ 1085{
1086#ifndef QT_NO_MENUDATA 1086#ifndef QT_NO_MENUDATA
1087 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm 1087 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
1088 1088
1089 if ( mi->isSeparator() ) 1089 if ( mi->isSeparator() )
1090 return 10; // arbitrary 1090 return 10; // arbitrary
1091 else if ( mi->pixmap() ) 1091 else if ( mi->pixmap() )
1092 w += mi->pixmap()->width();// pixmap only 1092 w += mi->pixmap()->width();// pixmap only
1093 1093
1094 if ( !mi->text().isNull() ) { 1094 if ( !mi->text().isNull() ) {
1095 if ( mi->text().find('\t') >= 0 )// string contains tab 1095 if ( mi->text().find('\t') >= 0 )// string contains tab
1096 w += motifTabSpacing; 1096 w += motifTabSpacing;
1097 } 1097 }
1098 1098
1099 if ( maxpmw ) { // we have iconsets 1099 if ( maxpmw ) { // we have iconsets
1100 w += maxpmw; 1100 w += maxpmw;
1101 w += 6; // add a little extra border around the iconset 1101 w += 6; // add a little extra border around the iconset
1102 } 1102 }
1103 1103
1104 if ( checkable && maxpmw < windowsCheckMarkWidth ) { 1104 if ( checkable && maxpmw < windowsCheckMarkWidth ) {
1105 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks 1105 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
1106 } 1106 }
1107 1107
1108 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks) 1108 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
1109 w += motifCheckMarkHMargin; // add space to separate the columns 1109 w += motifCheckMarkHMargin; // add space to separate the columns
1110 1110
1111 w += windowsRightBorder; // windows has a strange wide border on the right side 1111 w += windowsRightBorder; // windows has a strange wide border on the right side
1112 1112
1113 return w; 1113 return w;
1114#endif 1114#endif
1115} 1115}
1116 1116
1117/*! \reimp 1117/*! \reimp
1118*/ 1118*/
1119int LightStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) 1119int LightStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
1120{ 1120{
1121#ifndef QT_NO_MENUDATA 1121#ifndef QT_NO_MENUDATA
1122 int h = 0; 1122 int h = 0;
1123 if ( mi->isSeparator() ) // separator height 1123 if ( mi->isSeparator() ) // separator height
1124 h = motifSepHeight; 1124 h = motifSepHeight;
1125 else if ( mi->pixmap() ) // pixmap height 1125 else if ( mi->pixmap() ) // pixmap height
1126 h = mi->pixmap()->height() + 2*motifItemFrame; 1126 h = mi->pixmap()->height() + 2*motifItemFrame;
1127 else // text height 1127 else // text height
1128 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame; 1128 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame;
1129 1129
1130 if ( !mi->isSeparator() && mi->iconSet() != 0 ) { 1130 if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
1131 h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); 1131 h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame );
1132 } 1132 }
1133 if ( mi->custom() ) 1133 if ( mi->custom() )
1134 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; 1134 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
1135 return h; 1135 return h;
1136#endif 1136#endif
1137} 1137}
1138 1138
1139void LightStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, 1139void LightStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
1140 const QPalette& pal, 1140 const QPalette& pal,
1141 bool act, bool enabled, int x, int y, int w, int h) 1141 bool act, bool enabled, int x, int y, int w, int h)
1142{ 1142{
1143#ifndef QT_NO_MENUDATA 1143#ifndef QT_NO_MENUDATA
1144 const QColorGroup & g = pal.active(); 1144 const QColorGroup & g = pal.active();
1145 bool dis = !enabled; 1145 bool dis = !enabled;
1146 QColorGroup itemg = dis ? pal.disabled() : pal.active(); 1146 QColorGroup itemg = dis ? pal.disabled() : pal.active();
1147 1147
1148 if ( checkable ) 1148 if ( checkable )
1149 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks 1149 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks
1150 1150
1151 int checkcol = maxpmw; 1151 int checkcol = maxpmw;
1152 1152
1153 if ( mi && mi->isSeparator() ) { // draw separator 1153 if ( mi && mi->isSeparator() ) { // draw separator
1154 p->setPen( g.dark() ); 1154 p->setPen( g.dark() );
1155 p->drawLine( x, y, x+w, y ); 1155 p->drawLine( x, y, x+w, y );
1156 p->setPen( g.light() ); 1156 p->setPen( g.light() );
1157 p->drawLine( x, y+1, x+w, y+1 ); 1157 p->drawLine( x, y+1, x+w, y+1 );
1158 return; 1158 return;
1159 } 1159 }
1160 1160
1161 QBrush fill = act? g.brush( QColorGroup::Highlight ) : 1161 QBrush fill = act? g.brush( QColorGroup::Highlight ) :
1162 g.brush( QColorGroup::Button ); 1162 g.brush( QColorGroup::Button );
1163 p->fillRect( x, y, w, h, fill); 1163 p->fillRect( x, y, w, h, fill);
1164 1164
1165 if ( !mi ) 1165 if ( !mi )
1166 return; 1166 return;
1167 1167
1168 if ( mi->isChecked() ) { 1168 if ( mi->isChecked() ) {
1169 if ( act && !dis ) { 1169 if ( act && !dis ) {
1170 qDrawShadePanel( p, x, y, checkcol, h, 1170 qDrawShadePanel( p, x, y, checkcol, h,
1171 g, TRUE, 1, &g.brush( QColorGroup::Button ) ); 1171 g, TRUE, 1, &g.brush( QColorGroup::Button ) );
1172 } else { 1172 } else {
1173 qDrawShadePanel( p, x, y, checkcol, h, 1173 qDrawShadePanel( p, x, y, checkcol, h,
1174 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); 1174 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
1175 } 1175 }
1176 } else if ( !act ) { 1176 } else if ( !act ) {
1177 p->fillRect(x, y, checkcol , h, 1177 p->fillRect(x, y, checkcol , h,
1178 g.brush( QColorGroup::Button )); 1178 g.brush( QColorGroup::Button ));
1179 } 1179 }
1180 1180
1181 if ( mi->iconSet() ) { // draw iconset 1181 if ( mi->iconSet() ) { // draw iconset
1182 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; 1182 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
1183 if (act && !dis ) 1183 if (act && !dis )
1184 mode = QIconSet::Active; 1184 mode = QIconSet::Active;
1185 QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode ); 1185 QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
1186 int pixw = pixmap.width(); 1186 int pixw = pixmap.width();
1187 int pixh = pixmap.height(); 1187 int pixh = pixmap.height();
1188 if ( act && !dis ) { 1188 if ( act && !dis ) {
1189 if ( !mi->isChecked() ) 1189 if ( !mi->isChecked() )
1190 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) ); 1190 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
1191 } 1191 }
1192 QRect cr( x, y, checkcol, h ); 1192 QRect cr( x, y, checkcol, h );
1193 QRect pmr( 0, 0, pixw, pixh ); 1193 QRect pmr( 0, 0, pixw, pixh );
1194 pmr.moveCenter( cr.center() ); 1194 pmr.moveCenter( cr.center() );
1195 p->setPen( itemg.text() ); 1195 p->setPen( itemg.text() );
1196 p->drawPixmap( pmr.topLeft(), pixmap ); 1196 p->drawPixmap( pmr.topLeft(), pixmap );
1197 1197
1198 QBrush fill = act? g.brush( QColorGroup::Highlight ) : 1198 QBrush fill = act? g.brush( QColorGroup::Highlight ) :
1199 g.brush( QColorGroup::Button ); 1199 g.brush( QColorGroup::Button );
1200 p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill); 1200 p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
1201 } else if ( checkable ) {// just "checking"... 1201 } else if ( checkable ) {// just "checking"...
1202 int mw = checkcol + motifItemFrame; 1202 int mw = checkcol + motifItemFrame;
1203 int mh = h - 2*motifItemFrame; 1203 int mh = h - 2*motifItemFrame;
1204 if ( mi->isChecked() ) { 1204 if ( mi->isChecked() ) {
1205 drawCheckMark( p, x + motifItemFrame + 2, 1205 drawCheckMark( p, x + motifItemFrame + 2,
1206 y+motifItemFrame, mw, mh, itemg, act, dis ); 1206 y+motifItemFrame, mw, mh, itemg, act, dis );
1207 } 1207 }
1208 } 1208 }
1209 1209
1210 p->setPen( act ? g.highlightedText() : g.buttonText() ); 1210 p->setPen( act ? g.highlightedText() : g.buttonText() );
1211 1211
1212 QColor discol; 1212 QColor discol;
1213 if ( dis ) { 1213 if ( dis ) {
1214 discol = itemg.text(); 1214 discol = itemg.text();
1215 p->setPen( discol ); 1215 p->setPen( discol );
1216 } 1216 }
1217 1217
1218 int xm = motifItemFrame + checkcol + motifItemHMargin; 1218 int xm = motifItemFrame + checkcol + motifItemHMargin;
1219 1219
1220 if ( mi->custom() ) { 1220 if ( mi->custom() ) {
1221 int m = motifItemVMargin; 1221 int m = motifItemVMargin;
1222 p->save(); 1222 p->save();
1223 if ( dis && !act ) { 1223 if ( dis && !act ) {
1224 p->setPen( g.light() ); 1224 p->setPen( g.light() );
1225 mi->custom()->paint( p, itemg, act, enabled, 1225 mi->custom()->paint( p, itemg, act, enabled,
1226 x+xm+1, y+m+1, w-xm-tab+1, h-2*m ); 1226 x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
1227 p->setPen( discol ); 1227 p->setPen( discol );
1228 } 1228 }
1229 mi->custom()->paint( p, itemg, act, enabled, 1229 mi->custom()->paint( p, itemg, act, enabled,
1230 x+xm, y+m, w-xm-tab+1, h-2*m ); 1230 x+xm, y+m, w-xm-tab+1, h-2*m );
1231 p->restore(); 1231 p->restore();
1232 } 1232 }
1233 QString s = mi->text(); 1233 QString s = mi->text();
1234 if ( !s.isNull() ) { // draw text 1234 if ( !s.isNull() ) { // draw text
1235 int t = s.find( '\t' ); 1235 int t = s.find( '\t' );
1236 int m = motifItemVMargin; 1236 int m = motifItemVMargin;
1237 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; 1237 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
1238 if ( t >= 0 ) { // draw tab text 1238 if ( t >= 0 ) { // draw tab text
1239 if ( dis && !act ) { 1239 if ( dis && !act ) {
1240 p->setPen( g.light() ); 1240 p->setPen( g.light() );
1241 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, 1241 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
1242 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); 1242 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
1243 p->setPen( discol ); 1243 p->setPen( discol );
1244 } 1244 }
1245 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame, 1245 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame,
1246 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); 1246 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
1247 } 1247 }
1248 if ( dis && !act ) { 1248 if ( dis && !act ) {
1249 p->setPen( g.light() ); 1249 p->setPen( g.light() );
1250 p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t ); 1250 p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t );
1251 p->setPen( discol ); 1251 p->setPen( discol );
1252 } 1252 }
1253 p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t ); 1253 p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
1254 } else if ( mi->pixmap() ) { // draw pixmap 1254 } else if ( mi->pixmap() ) { // draw pixmap
1255 QPixmap *pixmap = mi->pixmap(); 1255 QPixmap *pixmap = mi->pixmap();
1256 if ( pixmap->depth() == 1 ) 1256 if ( pixmap->depth() == 1 )
1257 p->setBackgroundMode( OpaqueMode ); 1257 p->setBackgroundMode( OpaqueMode );
1258 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap ); 1258 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap );
1259 if ( pixmap->depth() == 1 ) 1259 if ( pixmap->depth() == 1 )
1260 p->setBackgroundMode( TransparentMode ); 1260 p->setBackgroundMode( TransparentMode );
1261 } 1261 }
1262 if ( mi->popup() ) { // draw sub menu arrow 1262 if ( mi->popup() ) { // draw sub menu arrow
1263 int dim = (h-2*motifItemFrame) / 2; 1263 int dim = (h-2*motifItemFrame) / 2;
1264 if ( act ) { 1264 if ( act ) {
1265 if ( !dis ) 1265 if ( !dis )
1266 discol = white; 1266 discol = white;
1267 QColorGroup g2( discol, g.highlight(), 1267 QColorGroup g2( discol, g.highlight(),
1268 white, white, 1268 white, white,
1269 dis ? discol : white, 1269 dis ? discol : white,
1270 discol, white ); 1270 discol, white );
1271 drawArrow( p, RightArrow, FALSE, 1271 drawArrow( p, RightArrow, FALSE,
1272 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 1272 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
1273 dim, dim, g2, TRUE ); 1273 dim, dim, g2, TRUE );
1274 } else { 1274 } else {
1275 drawArrow( p, RightArrow, 1275 drawArrow( p, RightArrow,
1276 FALSE, 1276 FALSE,
1277 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 1277 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
1278 dim, dim, g, mi->isEnabled() ); 1278 dim, dim, g, mi->isEnabled() );
1279 } 1279 }
1280 } 1280 }
1281#endif 1281#endif
1282} 1282}
1283 1283
1284#endif 1284#endif
diff --git a/library/lightstyle.h b/library/lightstyle.h
index c377cc2..0392957 100644
--- a/library/lightstyle.h
+++ b/library/lightstyle.h
@@ -1,120 +1,120 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LIGHTSTYLE_H 20#ifndef LIGHTSTYLE_H
21#define LIGHTSTYLE_H 21#define LIGHTSTYLE_H
22 22
23 23
24#ifndef QT_H 24#ifndef QT_H
25#include <qstyle.h> 25#include <qstyle.h>
26#include <qwindowsstyle.h> 26#include <qwindowsstyle.h>
27#endif // QT_H 27#endif // QT_H
28 28
29#if QT_VERSION < 300 29#if QT_VERSION < 0x030000
30 30
31#ifdef QT_PLUGIN_STYLE_LIGHT 31#ifdef QT_PLUGIN_STYLE_LIGHT
32# define Q_EXPORT_STYLE_LIGHT 32# define Q_EXPORT_STYLE_LIGHT
33#else 33#else
34# define Q_EXPORT_STYLE_LIGHT Q_EXPORT 34# define Q_EXPORT_STYLE_LIGHT Q_EXPORT
35#endif // QT_PLUGIN_STYLE_LIGHT 35#endif // QT_PLUGIN_STYLE_LIGHT
36 36
37 37
38class Q_EXPORT_STYLE_LIGHT LightStyle : public QWindowsStyle 38class Q_EXPORT_STYLE_LIGHT LightStyle : public QWindowsStyle
39{ 39{
40public: 40public:
41 LightStyle(); 41 LightStyle();
42 virtual ~LightStyle(); 42 virtual ~LightStyle();
43 43
44 void polish(QWidget *widget); 44 void polish(QWidget *widget);
45 void unPolish(QWidget*widget); 45 void unPolish(QWidget*widget);
46 46
47 void polish(QApplication *app); 47 void polish(QApplication *app);
48 void unPolish(QApplication *app); 48 void unPolish(QApplication *app);
49 49
50 void polishPopupMenu(QPopupMenu *menu); 50 void polishPopupMenu(QPopupMenu *menu);
51 51
52 void drawPushButton(QPushButton *button, QPainter *p); 52 void drawPushButton(QPushButton *button, QPainter *p);
53 void drawButton(QPainter *p, int x, int y, int w, int h, 53 void drawButton(QPainter *p, int x, int y, int w, int h,
54 const QColorGroup &g, bool sunken = FALSE, 54 const QColorGroup &g, bool sunken = FALSE,
55 const QBrush *fill = 0); 55 const QBrush *fill = 0);
56 void drawBevelButton(QPainter *p, int x, int y, int w, int h, 56 void drawBevelButton(QPainter *p, int x, int y, int w, int h,
57 const QColorGroup &g, bool sunken = FALSE, 57 const QColorGroup &g, bool sunken = FALSE,
58 const QBrush *fill = 0); 58 const QBrush *fill = 0);
59 void getButtonShift(int &x, int &y) const; 59 void getButtonShift(int &x, int &y) const;
60 60
61 void drawComboButton(QPainter *p, int x, int y, int w, int h, 61 void drawComboButton(QPainter *p, int x, int y, int w, int h,
62 const QColorGroup &g, bool sunken = FALSE, 62 const QColorGroup &g, bool sunken = FALSE,
63 bool editable = FALSE, bool = TRUE, 63 bool editable = FALSE, bool = TRUE,
64 const QBrush *fill = 0); 64 const QBrush *fill = 0);
65 QRect comboButtonRect(int x, int y, int w, int h) const; 65 QRect comboButtonRect(int x, int y, int w, int h) const;
66 QRect comboButtonFocusRect(int x, int y, int w, int h) const; 66 QRect comboButtonFocusRect(int x, int y, int w, int h) const;
67 67
68 void drawIndicator(QPainter *p, int x, int y ,int w, int h, 68 void drawIndicator(QPainter *p, int x, int y ,int w, int h,
69 const QColorGroup &g, int state, 69 const QColorGroup &g, int state,
70 bool = FALSE, bool = TRUE); 70 bool = FALSE, bool = TRUE);
71 QSize indicatorSize() const; 71 QSize indicatorSize() const;
72 72
73 void drawExclusiveIndicator(QPainter *p, int x, int y ,int w, int h, 73 void drawExclusiveIndicator(QPainter *p, int x, int y ,int w, int h,
74 const QColorGroup &g, bool on, 74 const QColorGroup &g, bool on,
75 bool = FALSE, bool = TRUE); 75 bool = FALSE, bool = TRUE);
76 QSize exclusiveIndicatorSize() const; 76 QSize exclusiveIndicatorSize() const;
77 77
78 void drawPanel(QPainter * p, int x, int y, int w, int h, 78 void drawPanel(QPainter * p, int x, int y, int w, int h,
79 const QColorGroup &g, bool sunken = FALSE, 79 const QColorGroup &g, bool sunken = FALSE,
80 int = 1, const QBrush * = 0); 80 int = 1, const QBrush * = 0);
81 81
82 void scrollBarMetrics( const QScrollBar *, 82 void scrollBarMetrics( const QScrollBar *,
83 int &, int &, int &, int & ) const; 83 int &, int &, int &, int & ) const;
84 void drawScrollBarControls(QPainter* p, const QScrollBar* sb, 84 void drawScrollBarControls(QPainter* p, const QScrollBar* sb,
85 int sliderStart, uint controls, 85 int sliderStart, uint controls,
86 uint activeControl); 86 uint activeControl);
87 QStyle::ScrollControl scrollBarPointOver(const QScrollBar *, int, const QPoint& p); 87 QStyle::ScrollControl scrollBarPointOver(const QScrollBar *, int, const QPoint& p);
88 88
89 void drawTab(QPainter *p, const QTabBar *tabbar, QTab *tab, bool selected); 89 void drawTab(QPainter *p, const QTabBar *tabbar, QTab *tab, bool selected);
90 90
91 void drawSlider(QPainter *p, int x, int y, int w, int h, 91 void drawSlider(QPainter *p, int x, int y, int w, int h,
92 const QColorGroup &g, Qt::Orientation orientation, 92 const QColorGroup &g, Qt::Orientation orientation,
93 bool, bool); 93 bool, bool);
94 void drawSliderGroove(QPainter *p, int x, int y, int w, int h, 94 void drawSliderGroove(QPainter *p, int x, int y, int w, int h,
95 const QColorGroup& g, QCOORD, 95 const QColorGroup& g, QCOORD,
96 Qt::Orientation ); 96 Qt::Orientation );
97 97
98 void drawToolBarHandle(QPainter *, const QRect &, Qt::Orientation, 98 void drawToolBarHandle(QPainter *, const QRect &, Qt::Orientation,
99 bool, const QColorGroup &, bool = FALSE ); 99 bool, const QColorGroup &, bool = FALSE );
100 100
101 QSize scrollBarExtent() const; 101 QSize scrollBarExtent() const;
102 int buttonDefaultIndicatorWidth() const; 102 int buttonDefaultIndicatorWidth() const;
103 int buttonMargin() const; 103 int buttonMargin() const;
104 int sliderThickness() const; 104 int sliderThickness() const;
105 int sliderLength() const; 105 int sliderLength() const;
106 int defaultFrameWidth() const; 106 int defaultFrameWidth() const;
107 107
108 int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& ); 108 int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& );
109 int popupMenuItemHeight( bool checkable, QMenuItem*, const QFontMetrics& ); 109 int popupMenuItemHeight( bool checkable, QMenuItem*, const QFontMetrics& );
110 void drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, 110 void drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
111 const QPalette& pal, 111 const QPalette& pal,
112 bool act, bool enabled, int x, int y, int w, int h); 112 bool act, bool enabled, int x, int y, int w, int h);
113 113
114protected: 114protected:
115 bool eventFilter(QObject *, QEvent *); 115 bool eventFilter(QObject *, QEvent *);
116}; 116};
117 117
118#endif 118#endif
119 119
120#endif // LIGHTSTYLE_H 120#endif // LIGHTSTYLE_H
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index af00f49..1c5ced3 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,2322 +1,2322 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19*/ 19*/
20#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
21#include <stdlib.h> 21#include <stdlib.h>
22#include <unistd.h> 22#include <unistd.h>
23#ifndef Q_OS_MACX 23#ifndef Q_OS_MACX
24#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 24#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
25#endif 25#endif
26#include <qfile.h> 26#include <qfile.h>
27#include <qqueue.h> 27#include <qqueue.h>
28#ifdef Q_WS_QWS 28#ifdef Q_WS_QWS
29#ifndef QT_NO_COP 29#ifndef QT_NO_COP
30#if QT_VERSION <= 231 30#if QT_VERSION <= 231
31#define private public 31#define private public
32#define sendLocally processEvent 32#define sendLocally processEvent
33#include "qcopenvelope_qws.h" 33#include "qcopenvelope_qws.h"
34#undef private 34#undef private
35#else 35#else
36#include "qcopenvelope_qws.h" 36#include "qcopenvelope_qws.h"
37#endif 37#endif
38#endif 38#endif
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#endif 40#endif
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qpalette.h> 42#include <qpalette.h>
43#include <qbuffer.h> 43#include <qbuffer.h>
44#include <qptrdict.h> 44#include <qptrdict.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qdir.h> 46#include <qdir.h>
47#include <qlabel.h> 47#include <qlabel.h>
48#include <qdialog.h> 48#include <qdialog.h>
49#include <qdragobject.h> 49#include <qdragobject.h>
50#include <qtextcodec.h> 50#include <qtextcodec.h>
51#include <qevent.h> 51#include <qevent.h>
52#include <qtooltip.h> 52#include <qtooltip.h>
53#include <qsignal.h> 53#include <qsignal.h>
54#include <qmainwindow.h> 54#include <qmainwindow.h>
55#include <qwidgetlist.h> 55#include <qwidgetlist.h>
56#include <qpixmapcache.h> 56#include <qpixmapcache.h>
57 57
58#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 58#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
59#define QTOPIA_INTERNAL_INITAPP 59#define QTOPIA_INTERNAL_INITAPP
60#include "qpeapplication.h" 60#include "qpeapplication.h"
61#include "qpestyle.h" 61#include "qpestyle.h"
62#include "styleinterface.h" 62#include "styleinterface.h"
63#if QT_VERSION >= 300 63#if QT_VERSION >= 0x030000
64#include <qstylefactory.h> 64#include <qstylefactory.h>
65#else 65#else
66#include <qplatinumstyle.h> 66#include <qplatinumstyle.h>
67#include <qwindowsstyle.h> 67#include <qwindowsstyle.h>
68#include <qmotifstyle.h> 68#include <qmotifstyle.h>
69#include <qmotifplusstyle.h> 69#include <qmotifplusstyle.h>
70#include "lightstyle.h" 70#include "lightstyle.h"
71 71
72#include <qpe/qlibrary.h> 72#include <qpe/qlibrary.h>
73#endif 73#endif
74#include "global.h" 74#include "global.h"
75#include "resource.h" 75#include "resource.h"
76#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 76#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
77#include "qutfcodec.h" 77#include "qutfcodec.h"
78#endif 78#endif
79#include "config.h" 79#include "config.h"
80#include "network.h" 80#include "network.h"
81#ifdef QWS 81#ifdef QWS
82#include "fontmanager.h" 82#include "fontmanager.h"
83#include "fontdatabase.h" 83#include "fontdatabase.h"
84#endif 84#endif
85 85
86#include "alarmserver.h" 86#include "alarmserver.h"
87#include "applnk.h" 87#include "applnk.h"
88#include "qpemenubar.h" 88#include "qpemenubar.h"
89#include "textcodecinterface.h" 89#include "textcodecinterface.h"
90#include "imagecodecinterface.h" 90#include "imagecodecinterface.h"
91#include <qtopia/qpeglobal.h> 91#include <qtopia/qpeglobal.h>
92 92
93#include <unistd.h> 93#include <unistd.h>
94#include <sys/file.h> 94#include <sys/file.h>
95#include <sys/ioctl.h> 95#include <sys/ioctl.h>
96#ifndef QT_NO_SOUND 96#ifndef QT_NO_SOUND
97#include <sys/soundcard.h> 97#include <sys/soundcard.h>
98#endif 98#endif
99#include "qt_override_p.h" 99#include "qt_override_p.h"
100 100
101#include <backend/rohfeedback.h> 101#include <backend/rohfeedback.h>
102 102
103 103
104static bool useBigPixmaps = 0; 104static bool useBigPixmaps = 0;
105 105
106class HackWidget : public QWidget 106class HackWidget : public QWidget
107{ 107{
108public: 108public:
109 bool needsOk() 109 bool needsOk()
110 { return (getWState() & WState_Reserved1 ); } 110 { return (getWState() & WState_Reserved1 ); }
111 111
112 QRect normalGeometry() 112 QRect normalGeometry()
113 { return topData()->normalGeometry; }; 113 { return topData()->normalGeometry; };
114}; 114};
115 115
116class QPEApplicationData 116class QPEApplicationData
117{ 117{
118public: 118public:
119 QPEApplicationData ( ) : 119 QPEApplicationData ( ) :
120 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 120 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
122 keep_running( true ), qcopQok( false ), 122 keep_running( true ), qcopQok( false ),
123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
124 bigIconSize( 32 ), qpe_main_widget( 0 ) 124 bigIconSize( 32 ), qpe_main_widget( 0 )
125 { 125 {
126 Config cfg( "qpe" ); 126 Config cfg( "qpe" );
127 cfg.setGroup( "Appearance" ); 127 cfg.setGroup( "Appearance" );
128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
129 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 129 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
130 fontSize = cfg.readNumEntry( "FontSize", 10 ); 130 fontSize = cfg.readNumEntry( "FontSize", 10 );
131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
133#ifdef OPIE_WITHROHFEEDBACK 133#ifdef OPIE_WITHROHFEEDBACK
134 RoH = 0; 134 RoH = 0;
135#endif 135#endif
136 } 136 }
137 137
138 int presstimer; 138 int presstimer;
139 QWidget* presswidget; 139 QWidget* presswidget;
140 QPoint presspos; 140 QPoint presspos;
141#ifdef OPIE_WITHROHFEEDBACK 141#ifdef OPIE_WITHROHFEEDBACK
142 Opie::Internal::RoHFeedback *RoH; 142 Opie::Internal::RoHFeedback *RoH;
143#endif 143#endif
144 144
145 bool rightpressed : 1; 145 bool rightpressed : 1;
146 bool kbgrabbed : 1; 146 bool kbgrabbed : 1;
147 bool notbusysent : 1; 147 bool notbusysent : 1;
148 bool preloaded : 1; 148 bool preloaded : 1;
149 bool forceshow : 1; 149 bool forceshow : 1;
150 bool nomaximize : 1; 150 bool nomaximize : 1;
151 bool keep_running : 1; 151 bool keep_running : 1;
152 bool qcopQok : 1; 152 bool qcopQok : 1;
153 153
154 QCString fontFamily; 154 QCString fontFamily;
155 int fontSize; 155 int fontSize;
156 int smallIconSize; 156 int smallIconSize;
157 int bigIconSize; 157 int bigIconSize;
158 158
159 QString appName; 159 QString appName;
160 struct QCopRec 160 struct QCopRec
161 { 161 {
162 QCopRec( const QCString &ch, const QCString &msg, 162 QCopRec( const QCString &ch, const QCString &msg,
163 const QByteArray &d ) : 163 const QByteArray &d ) :
164 channel( ch ), message( msg ), data( d ) 164 channel( ch ), message( msg ), data( d )
165 { } 165 { }
166 166
167 QCString channel; 167 QCString channel;
168 QCString message; 168 QCString message;
169 QByteArray data; 169 QByteArray data;
170 }; 170 };
171 QWidget* qpe_main_widget; 171 QWidget* qpe_main_widget;
172 QGuardedPtr<QWidget> lastraised; 172 QGuardedPtr<QWidget> lastraised;
173 QQueue<QCopRec> qcopq; 173 QQueue<QCopRec> qcopq;
174 QString styleName; 174 QString styleName;
175 QString decorationName; 175 QString decorationName;
176 176
177 void enqueueQCop( const QCString &ch, const QCString &msg, 177 void enqueueQCop( const QCString &ch, const QCString &msg,
178 const QByteArray &data ) 178 const QByteArray &data )
179 { 179 {
180 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 180 qcopq.enqueue( new QCopRec( ch, msg, data ) );
181 } 181 }
182 void sendQCopQ() 182 void sendQCopQ()
183 { 183 {
184 if (!qcopQok ) 184 if (!qcopQok )
185 return; 185 return;
186 186
187 QCopRec * r; 187 QCopRec * r;
188 188
189 while((r=qcopq.dequeue())) { 189 while((r=qcopq.dequeue())) {
190 // remove from queue before sending... 190 // remove from queue before sending...
191 // event loop can come around again before getting 191 // event loop can come around again before getting
192 // back from sendLocally 192 // back from sendLocally
193#ifndef QT_NO_COP 193#ifndef QT_NO_COP
194 QCopChannel::sendLocally( r->channel, r->message, r->data ); 194 QCopChannel::sendLocally( r->channel, r->message, r->data );
195#endif 195#endif
196 196
197 delete r; 197 delete r;
198 } 198 }
199 } 199 }
200 200
201 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) { 201 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) {
202 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 202 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
203 { 203 {
204 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 204 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
205 } 205 }
206 QPoint p; 206 QPoint p;
207 QSize s; 207 QSize s;
208 bool max; 208 bool max;
209 209
210 if ( mw->isVisible() ) { 210 if ( mw->isVisible() ) {
211 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 211 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
212 mw->resize(s); 212 mw->resize(s);
213 mw->move(p); 213 mw->move(p);
214 } 214 }
215 mw->raise(); 215 mw->raise();
216 } else { 216 } else {
217 217
218 if ( mw->layout() && mw->inherits("QDialog") ) { 218 if ( mw->layout() && mw->inherits("QDialog") ) {
219 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 219 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
220 mw->resize(s); 220 mw->resize(s);
221 mw->move(p); 221 mw->move(p);
222 222
223 if ( max && !nomaximize ) { 223 if ( max && !nomaximize ) {
224 mw->showMaximized(); 224 mw->showMaximized();
225 } else { 225 } else {
226 mw->show(); 226 mw->show();
227 } 227 }
228 } else { 228 } else {
229 QPEApplication::showDialog((QDialog*)mw,nomaximize); 229 QPEApplication::showDialog((QDialog*)mw,nomaximize);
230 } 230 }
231 } else { 231 } else {
232 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 232 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
233 mw->resize(s); 233 mw->resize(s);
234 mw->move(p); 234 mw->move(p);
235 } else { //no stored rectangle, make an estimation 235 } else { //no stored rectangle, make an estimation
236 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 236 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
237 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 237 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
238 mw->move( QMAX(x,0), QMAX(y,0) ); 238 mw->move( QMAX(x,0), QMAX(y,0) );
239#ifdef Q_WS_QWS 239#ifdef Q_WS_QWS
240 if ( !nomaximize ) 240 if ( !nomaximize )
241 mw->showMaximized(); 241 mw->showMaximized();
242#endif 242#endif
243 } 243 }
244 if ( max && !nomaximize ) 244 if ( max && !nomaximize )
245 mw->showMaximized(); 245 mw->showMaximized();
246 else 246 else
247 mw->show(); 247 mw->show();
248 } 248 }
249 } 249 }
250 } 250 }
251 251
252 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 252 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
253 { 253 {
254 maximized = TRUE; 254 maximized = TRUE;
255 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 255 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
256 if ( qApp->desktop()->width() <= 350 ) 256 if ( qApp->desktop()->width() <= 350 )
257 return FALSE; 257 return FALSE;
258 258
259 Config cfg( "qpe" ); 259 Config cfg( "qpe" );
260 cfg.setGroup("ApplicationPositions"); 260 cfg.setGroup("ApplicationPositions");
261 QString str = cfg.readEntry( app, QString::null ); 261 QString str = cfg.readEntry( app, QString::null );
262 QStringList l = QStringList::split(",", str); 262 QStringList l = QStringList::split(",", str);
263 263
264 if ( l.count() == 5) { 264 if ( l.count() == 5) {
265 p.setX( l[0].toInt() ); 265 p.setX( l[0].toInt() );
266 p.setY( l[1].toInt() ); 266 p.setY( l[1].toInt() );
267 267
268 s.setWidth( l[2].toInt() ); 268 s.setWidth( l[2].toInt() );
269 s.setHeight( l[3].toInt() ); 269 s.setHeight( l[3].toInt() );
270 270
271 maximized = l[4].toInt(); 271 maximized = l[4].toInt();
272 272
273 return TRUE; 273 return TRUE;
274 } 274 }
275 275
276 return FALSE; 276 return FALSE;
277 } 277 }
278 278
279 279
280 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 280 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
281 { 281 {
282#ifndef Q_WS_QWS 282#ifndef Q_WS_QWS
283 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 283 QRect qt_maxWindowRect = qApp->desktop()->geometry();
284#endif 284#endif
285 int maxX = qt_maxWindowRect.width(); 285 int maxX = qt_maxWindowRect.width();
286 int maxY = qt_maxWindowRect.height(); 286 int maxY = qt_maxWindowRect.height();
287 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 287 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
288 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 288 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
289 289
290 // total window size is not allowed to be larger than desktop window size 290 // total window size is not allowed to be larger than desktop window size
291 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 291 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
292 return FALSE; 292 return FALSE;
293 293
294 if ( wWidth > maxX ) { 294 if ( wWidth > maxX ) {
295 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 295 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
296 wWidth = maxX; 296 wWidth = maxX;
297 } 297 }
298 298
299 if ( wHeight > maxY ) { 299 if ( wHeight > maxY ) {
300 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 300 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
301 wHeight = maxY; 301 wHeight = maxY;
302 } 302 }
303 303
304 // any smaller than this and the maximize/close/help buttons will be overlapping 304 // any smaller than this and the maximize/close/help buttons will be overlapping
305 if ( wWidth < 80 || wHeight < 60 ) 305 if ( wWidth < 80 || wHeight < 60 )
306 return FALSE; 306 return FALSE;
307 307
308 if ( p.x() < 0 ) 308 if ( p.x() < 0 )
309 p.setX(0); 309 p.setX(0);
310 if ( p.y() < 0 ) 310 if ( p.y() < 0 )
311 p.setY(0); 311 p.setY(0);
312 312
313 if ( p.x() + wWidth > maxX ) 313 if ( p.x() + wWidth > maxX )
314 p.setX( maxX - wWidth ); 314 p.setX( maxX - wWidth );
315 if ( p.y() + wHeight > maxY ) 315 if ( p.y() + wHeight > maxY )
316 p.setY( maxY - wHeight ); 316 p.setY( maxY - wHeight );
317 317
318 return TRUE; 318 return TRUE;
319 } 319 }
320 320
321 static void store_widget_rect(QWidget *w, QString &app) 321 static void store_widget_rect(QWidget *w, QString &app)
322 { 322 {
323 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 323 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
324 if ( qApp->desktop()->width() <= 350 ) 324 if ( qApp->desktop()->width() <= 350 )
325 return; 325 return;
326 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 326 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
327 // get the non-maximized version, so we have to do it the hard way ) 327 // get the non-maximized version, so we have to do it the hard way )
328 int offsetX = w->x() - w->geometry().left(); 328 int offsetX = w->x() - w->geometry().left();
329 int offsetY = w->y() - w->geometry().top(); 329 int offsetY = w->y() - w->geometry().top();
330 330
331 QRect r; 331 QRect r;
332 if ( w->isMaximized() ) 332 if ( w->isMaximized() )
333 r = ( (HackWidget *) w)->normalGeometry(); 333 r = ( (HackWidget *) w)->normalGeometry();
334 else 334 else
335 r = w->geometry(); 335 r = w->geometry();
336 336
337 // Stores the window placement as pos(), size() (due to the offset mapping) 337 // Stores the window placement as pos(), size() (due to the offset mapping)
338 Config cfg( "qpe" ); 338 Config cfg( "qpe" );
339 cfg.setGroup("ApplicationPositions"); 339 cfg.setGroup("ApplicationPositions");
340 QString s; 340 QString s;
341 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 341 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
342 cfg.writeEntry( app, s ); 342 cfg.writeEntry( app, s );
343 } 343 }
344 344
345 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 345 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
346 { 346 {
347 /* 347 /*
348 // This works but disable it for now until it is safe to apply 348 // This works but disable it for now until it is safe to apply
349 // What is does is scan the .desktop files of all the apps for 349 // What is does is scan the .desktop files of all the apps for
350 // the applnk that has the corresponding argv[0] as this program 350 // the applnk that has the corresponding argv[0] as this program
351 // then it uses the name stored in the .desktop file as the caption 351 // then it uses the name stored in the .desktop file as the caption
352 // for the main widget. This saves duplicating translations for 352 // for the main widget. This saves duplicating translations for
353 // the app name in the program and in the .desktop files. 353 // the app name in the program and in the .desktop files.
354 354
355 AppLnkSet apps( appsPath ); 355 AppLnkSet apps( appsPath );
356 356
357 QList<AppLnk> appsList = apps.children(); 357 QList<AppLnk> appsList = apps.children();
358 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 358 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
359 if ( (*it)->exec() == appName ) { 359 if ( (*it)->exec() == appName ) {
360 mw->setCaption( (*it)->name() ); 360 mw->setCaption( (*it)->name() );
361 return TRUE; 361 return TRUE;
362 } 362 }
363 } 363 }
364 */ 364 */
365 return FALSE; 365 return FALSE;
366 } 366 }
367 367
368 368
369 void show(QWidget* mw, bool nomax) 369 void show(QWidget* mw, bool nomax)
370 { 370 {
371 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 371 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
372 nomaximize = nomax; 372 nomaximize = nomax;
373 qpe_main_widget = mw; 373 qpe_main_widget = mw;
374 qcopQok = TRUE; 374 qcopQok = TRUE;
375#ifndef QT_NO_COP 375#ifndef QT_NO_COP
376 376
377 sendQCopQ(); 377 sendQCopQ();
378#endif 378#endif
379 379
380 if ( preloaded ) { 380 if ( preloaded ) {
381 if (forceshow) 381 if (forceshow)
382 show_mx(mw, nomax, appName); 382 show_mx(mw, nomax, appName);
383 } 383 }
384 else if ( keep_running ) { 384 else if ( keep_running ) {
385 show_mx(mw, nomax, appName); 385 show_mx(mw, nomax, appName);
386 } 386 }
387 } 387 }
388 388
389 void loadTextCodecs() 389 void loadTextCodecs()
390 { 390 {
391 QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; 391 QString path = QPEApplication::qpeDir() + "plugins/textcodecs";
392#ifdef Q_OS_MACX 392#ifdef Q_OS_MACX
393 QDir dir( path, "lib*.dylib" ); 393 QDir dir( path, "lib*.dylib" );
394#else 394#else
395 QDir dir( path, "lib*.so" ); 395 QDir dir( path, "lib*.so" );
396#endif 396#endif
397 QStringList list; 397 QStringList list;
398 if ( dir. exists ( )) 398 if ( dir. exists ( ))
399 list = dir.entryList(); 399 list = dir.entryList();
400 QStringList::Iterator it; 400 QStringList::Iterator it;
401 for ( it = list.begin(); it != list.end(); ++it ) { 401 for ( it = list.begin(); it != list.end(); ++it ) {
402 TextCodecInterface *iface = 0; 402 TextCodecInterface *iface = 0;
403 QLibrary *lib = new QLibrary( path + "/" + *it ); 403 QLibrary *lib = new QLibrary( path + "/" + *it );
404 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 404 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
405 QValueList<int> mibs = iface->mibEnums(); 405 QValueList<int> mibs = iface->mibEnums();
406 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 406 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
407 (void)iface->createForMib(*i); 407 (void)iface->createForMib(*i);
408 // ### it exists now; need to remember if we can delete it 408 // ### it exists now; need to remember if we can delete it
409 } 409 }
410 } 410 }
411 else { 411 else {
412 lib->unload(); 412 lib->unload();
413 delete lib; 413 delete lib;
414 } 414 }
415 } 415 }
416 } 416 }
417 417
418 void loadImageCodecs() 418 void loadImageCodecs()
419 { 419 {
420 QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; 420 QString path = QPEApplication::qpeDir() + "plugins/imagecodecs";
421#ifdef Q_OS_MACX 421#ifdef Q_OS_MACX
422 QDir dir( path, "lib*.dylib" ); 422 QDir dir( path, "lib*.dylib" );
423#else 423#else
424 QDir dir( path, "lib*.so" ); 424 QDir dir( path, "lib*.so" );
425#endif 425#endif
426 QStringList list; 426 QStringList list;
427 if ( dir. exists ( )) 427 if ( dir. exists ( ))
428 list = dir.entryList(); 428 list = dir.entryList();
429 QStringList::Iterator it; 429 QStringList::Iterator it;
430 for ( it = list.begin(); it != list.end(); ++it ) { 430 for ( it = list.begin(); it != list.end(); ++it ) {
431 ImageCodecInterface *iface = 0; 431 ImageCodecInterface *iface = 0;
432 QLibrary *lib = new QLibrary( path + "/" + *it ); 432 QLibrary *lib = new QLibrary( path + "/" + *it );
433 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 433 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
434 QStringList formats = iface->keys(); 434 QStringList formats = iface->keys();
435 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 435 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
436 (void)iface->installIOHandler(*i); 436 (void)iface->installIOHandler(*i);
437 // ### it exists now; need to remember if we can delete it 437 // ### it exists now; need to remember if we can delete it
438 } 438 }
439 } 439 }
440 else { 440 else {
441 lib->unload(); 441 lib->unload();
442 delete lib; 442 delete lib;
443 } 443 }
444 } 444 }
445 } 445 }
446 446
447}; 447};
448 448
449class ResourceMimeFactory : public QMimeSourceFactory 449class ResourceMimeFactory : public QMimeSourceFactory
450{ 450{
451public: 451public:
452 ResourceMimeFactory() : resImage( 0 ) 452 ResourceMimeFactory() : resImage( 0 )
453 { 453 {
454 setFilePath( Global::helpPath() ); 454 setFilePath( Global::helpPath() );
455 setExtensionType( "html", "text/html;charset=UTF-8" ); 455 setExtensionType( "html", "text/html;charset=UTF-8" );
456 } 456 }
457 ~ResourceMimeFactory() { 457 ~ResourceMimeFactory() {
458 delete resImage; 458 delete resImage;
459 } 459 }
460 460
461 const QMimeSource* data( const QString& abs_name ) const 461 const QMimeSource* data( const QString& abs_name ) const
462 { 462 {
463 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 463 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
464 if ( !r ) { 464 if ( !r ) {
465 int sl = abs_name.length(); 465 int sl = abs_name.length();
466 do { 466 do {
467 sl = abs_name.findRev( '/', sl - 1 ); 467 sl = abs_name.findRev( '/', sl - 1 );
468 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 468 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
469 int dot = name.findRev( '.' ); 469 int dot = name.findRev( '.' );
470 if ( dot >= 0 ) 470 if ( dot >= 0 )
471 name = name.left( dot ); 471 name = name.left( dot );
472 QImage img = Resource::loadImage( name ); 472 QImage img = Resource::loadImage( name );
473 if ( !img.isNull() ) { 473 if ( !img.isNull() ) {
474 delete resImage; 474 delete resImage;
475 resImage = new QImageDrag( img ); 475 resImage = new QImageDrag( img );
476 r = resImage; 476 r = resImage;
477 } 477 }
478 } 478 }
479 while ( !r && sl > 0 ); 479 while ( !r && sl > 0 );
480 } 480 }
481 return r; 481 return r;
482 } 482 }
483private: 483private:
484 mutable QImageDrag *resImage; 484 mutable QImageDrag *resImage;
485}; 485};
486 486
487static int& hack(int& i) 487static int& hack(int& i)
488{ 488{
489#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 489#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
490 // These should be created, but aren't in Qt 2.3.0 490 // These should be created, but aren't in Qt 2.3.0
491 (void)new QUtf8Codec; 491 (void)new QUtf8Codec;
492 (void)new QUtf16Codec; 492 (void)new QUtf16Codec;
493#endif 493#endif
494 return i; 494 return i;
495} 495}
496 496
497static int muted = 0; 497static int muted = 0;
498static int micMuted = 0; 498static int micMuted = 0;
499 499
500static void setVolume( int t = 0, int percent = -1 ) 500static void setVolume( int t = 0, int percent = -1 )
501{ 501{
502 switch ( t ) { 502 switch ( t ) {
503 case 0: { 503 case 0: {
504 Config cfg( "qpe" ); 504 Config cfg( "qpe" );
505 cfg.setGroup( "Volume" ); 505 cfg.setGroup( "Volume" );
506 if ( percent < 0 ) 506 if ( percent < 0 )
507 percent = cfg.readNumEntry( "VolumePercent", 50 ); 507 percent = cfg.readNumEntry( "VolumePercent", 50 );
508#ifndef QT_NO_SOUND 508#ifndef QT_NO_SOUND
509 int fd = 0; 509 int fd = 0;
510#ifdef QT_QWS_DEVFS 510#ifdef QT_QWS_DEVFS
511 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 511 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
512#else 512#else
513 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 513 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
514#endif 514#endif
515 int vol = muted ? 0 : percent; 515 int vol = muted ? 0 : percent;
516 // set both channels to same volume 516 // set both channels to same volume
517 vol |= vol << 8; 517 vol |= vol << 8;
518 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 518 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
519 ::close( fd ); 519 ::close( fd );
520 } 520 }
521#endif 521#endif
522 } 522 }
523 break; 523 break;
524 } 524 }
525} 525}
526 526
527static void setMic( int t = 0, int percent = -1 ) 527static void setMic( int t = 0, int percent = -1 )
528{ 528{
529 switch ( t ) { 529 switch ( t ) {
530 case 0: { 530 case 0: {
531 Config cfg( "qpe" ); 531 Config cfg( "qpe" );
532 cfg.setGroup( "Volume" ); 532 cfg.setGroup( "Volume" );
533 if ( percent < 0 ) 533 if ( percent < 0 )
534 percent = cfg.readNumEntry( "Mic", 50 ); 534 percent = cfg.readNumEntry( "Mic", 50 );
535 535
536#ifndef QT_NO_SOUND 536#ifndef QT_NO_SOUND
537 int fd = 0; 537 int fd = 0;
538 int mic = micMuted ? 0 : percent; 538 int mic = micMuted ? 0 : percent;
539#ifdef QT_QWS_DEVFS 539#ifdef QT_QWS_DEVFS
540 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 540 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
541#else 541#else
542 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 542 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
543#endif 543#endif
544 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 544 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
545 ::close( fd ); 545 ::close( fd );
546 } 546 }
547#endif 547#endif
548 } 548 }
549 break; 549 break;
550 } 550 }
551} 551}
552 552
553 553
554static void setBass( int t = 0, int percent = -1 ) 554static void setBass( int t = 0, int percent = -1 )
555{ 555{
556 switch ( t ) { 556 switch ( t ) {
557 case 0: { 557 case 0: {
558 Config cfg( "qpe" ); 558 Config cfg( "qpe" );
559 cfg.setGroup( "Volume" ); 559 cfg.setGroup( "Volume" );
560 if ( percent < 0 ) 560 if ( percent < 0 )
561 percent = cfg.readNumEntry( "BassPercent", 50 ); 561 percent = cfg.readNumEntry( "BassPercent", 50 );
562 562
563#ifndef QT_NO_SOUND 563#ifndef QT_NO_SOUND
564 int fd = 0; 564 int fd = 0;
565 int bass = percent; 565 int bass = percent;
566#ifdef QT_QWS_DEVFS 566#ifdef QT_QWS_DEVFS
567 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 567 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
568#else 568#else
569 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 569 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
570#endif 570#endif
571 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 571 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
572 ::close( fd ); 572 ::close( fd );
573 } 573 }
574#endif 574#endif
575 } 575 }
576 break; 576 break;
577 } 577 }
578} 578}
579 579
580 580
581static void setTreble( int t = 0, int percent = -1 ) 581static void setTreble( int t = 0, int percent = -1 )
582{ 582{
583 switch ( t ) { 583 switch ( t ) {
584 case 0: { 584 case 0: {
585 Config cfg( "qpe" ); 585 Config cfg( "qpe" );
586 cfg.setGroup( "Volume" ); 586 cfg.setGroup( "Volume" );
587 if ( percent < 0 ) 587 if ( percent < 0 )
588 percent = cfg.readNumEntry( "TreblePercent", 50 ); 588 percent = cfg.readNumEntry( "TreblePercent", 50 );
589 589
590#ifndef QT_NO_SOUND 590#ifndef QT_NO_SOUND
591 int fd = 0; 591 int fd = 0;
592 int treble = percent; 592 int treble = percent;
593#ifdef QT_QWS_DEVFS 593#ifdef QT_QWS_DEVFS
594 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 594 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
595#else 595#else
596 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 596 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
597#endif 597#endif
598 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 598 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
599 ::close( fd ); 599 ::close( fd );
600 } 600 }
601#endif 601#endif
602 } 602 }
603 break; 603 break;
604 } 604 }
605} 605}
606 606
607 607
608/** 608/**
609 \class QPEApplication 609 \class QPEApplication
610 \brief The QPEApplication class implements various system services 610 \brief The QPEApplication class implements various system services
611 that are available to all Qtopia applications. 611 that are available to all Qtopia applications.
612 612
613 Simply by using QPEApplication instead of QApplication, a standard Qt 613 Simply by using QPEApplication instead of QApplication, a standard Qt
614 application becomes a Qtopia application. It automatically follows 614 application becomes a Qtopia application. It automatically follows
615 style changes, quits and raises, and in the 615 style changes, quits and raises, and in the
616 case of \link docwidget.html document-oriented\endlink applications, 616 case of \link docwidget.html document-oriented\endlink applications,
617 changes the currently displayed document in response to the environment. 617 changes the currently displayed document in response to the environment.
618 618
619 To create a \link docwidget.html document-oriented\endlink 619 To create a \link docwidget.html document-oriented\endlink
620 application use showMainDocumentWidget(); to create a 620 application use showMainDocumentWidget(); to create a
621 non-document-oriented application use showMainWidget(). The 621 non-document-oriented application use showMainWidget(). The
622 keepRunning() function indicates whether the application will 622 keepRunning() function indicates whether the application will
623 continue running after it's processed the last \link qcop.html 623 continue running after it's processed the last \link qcop.html
624 QCop\endlink message. This can be changed using setKeepRunning(). 624 QCop\endlink message. This can be changed using setKeepRunning().
625 625
626 A variety of signals are emitted when certain events occur, for 626 A variety of signals are emitted when certain events occur, for
627 example, timeChanged(), clockChanged(), weekChanged(), 627 example, timeChanged(), clockChanged(), weekChanged(),
628 dateFormatChanged() and volumeChanged(). If the application receives 628 dateFormatChanged() and volumeChanged(). If the application receives
629 a \link qcop.html QCop\endlink message on the application's 629 a \link qcop.html QCop\endlink message on the application's
630 QPE/Application/\e{appname} channel, the appMessage() signal is 630 QPE/Application/\e{appname} channel, the appMessage() signal is
631 emitted. There are also flush() and reload() signals, which 631 emitted. There are also flush() and reload() signals, which
632 are emitted when synching begins and ends respectively - upon these 632 are emitted when synching begins and ends respectively - upon these
633 signals, the application should save and reload any data 633 signals, the application should save and reload any data
634 files that are involved in synching. Most of these signals will initially 634 files that are involved in synching. Most of these signals will initially
635 be received and unfiltered through the appMessage() signal. 635 be received and unfiltered through the appMessage() signal.
636 636
637 This class also provides a set of useful static functions. The 637 This class also provides a set of useful static functions. The
638 qpeDir() and documentDir() functions return the respective paths. 638 qpeDir() and documentDir() functions return the respective paths.
639 The grabKeyboard() and ungrabKeyboard() functions are used to 639 The grabKeyboard() and ungrabKeyboard() functions are used to
640 control whether the application takes control of the device's 640 control whether the application takes control of the device's
641 physical buttons (e.g. application launch keys). The stylus' mode of 641 physical buttons (e.g. application launch keys). The stylus' mode of
642 operation is set with setStylusOperation() and retrieved with 642 operation is set with setStylusOperation() and retrieved with
643 stylusOperation(). There are also setInputMethodHint() and 643 stylusOperation(). There are also setInputMethodHint() and
644 inputMethodHint() functions. 644 inputMethodHint() functions.
645 645
646 \ingroup qtopiaemb 646 \ingroup qtopiaemb
647*/ 647*/
648 648
649/*! 649/*!
650 \fn void QPEApplication::clientMoused() 650 \fn void QPEApplication::clientMoused()
651 651
652 \internal 652 \internal
653*/ 653*/
654 654
655/*! 655/*!
656 \fn void QPEApplication::timeChanged(); 656 \fn void QPEApplication::timeChanged();
657 This signal is emitted when the time changes outside the normal 657 This signal is emitted when the time changes outside the normal
658 passage of time, i.e. if the time is set backwards or forwards. 658 passage of time, i.e. if the time is set backwards or forwards.
659*/ 659*/
660 660
661/*! 661/*!
662 \fn void QPEApplication::clockChanged( bool ampm ); 662 \fn void QPEApplication::clockChanged( bool ampm );
663 663
664 This signal is emitted when the user changes the clock's style. If 664 This signal is emitted when the user changes the clock's style. If
665 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 665 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
666 they want a 24-hour clock. 666 they want a 24-hour clock.
667*/ 667*/
668 668
669/*! 669/*!
670 \fn void QPEApplication::volumeChanged( bool muted ) 670 \fn void QPEApplication::volumeChanged( bool muted )
671 671
672 This signal is emitted whenever the mute state is changed. If \a 672 This signal is emitted whenever the mute state is changed. If \a
673 muted is TRUE, then sound output has been muted. 673 muted is TRUE, then sound output has been muted.
674*/ 674*/
675 675
676/*! 676/*!
677 \fn void QPEApplication::weekChanged( bool startOnMonday ) 677 \fn void QPEApplication::weekChanged( bool startOnMonday )
678 678
679 This signal is emitted if the week start day is changed. If \a 679 This signal is emitted if the week start day is changed. If \a
680 startOnMonday is TRUE then the first day of the week is Monday; if 680 startOnMonday is TRUE then the first day of the week is Monday; if
681 \a startOnMonday is FALSE then the first day of the week is 681 \a startOnMonday is FALSE then the first day of the week is
682 Sunday. 682 Sunday.
683*/ 683*/
684 684
685/*! 685/*!
686 \fn void QPEApplication::dateFormatChanged(DateFormat) 686 \fn void QPEApplication::dateFormatChanged(DateFormat)
687 687
688 This signal is emitted whenever the date format is changed. 688 This signal is emitted whenever the date format is changed.
689*/ 689*/
690 690
691/*! 691/*!
692 \fn void QPEApplication::flush() 692 \fn void QPEApplication::flush()
693 693
694 ### 694 ###
695*/ 695*/
696 696
697/*! 697/*!
698 \fn void QPEApplication::reload() 698 \fn void QPEApplication::reload()
699 699
700*/ 700*/
701 701
702 702
703 703
704void QPEApplication::processQCopFile() 704void QPEApplication::processQCopFile()
705{ 705{
706 QString qcopfn("/tmp/qcop-msg-"); 706 QString qcopfn("/tmp/qcop-msg-");
707 qcopfn += d->appName; // append command name 707 qcopfn += d->appName; // append command name
708 708
709 QFile f(qcopfn); 709 QFile f(qcopfn);
710 if ( f.open(IO_ReadWrite) ) { 710 if ( f.open(IO_ReadWrite) ) {
711#ifndef Q_OS_WIN32 711#ifndef Q_OS_WIN32
712 flock(f.handle(), LOCK_EX); 712 flock(f.handle(), LOCK_EX);
713#endif 713#endif
714 QDataStream ds(&f); 714 QDataStream ds(&f);
715 QCString channel, message; 715 QCString channel, message;
716 QByteArray data; 716 QByteArray data;
717 while(!ds.atEnd()) { 717 while(!ds.atEnd()) {
718 ds >> channel >> message >> data; 718 ds >> channel >> message >> data;
719 d->enqueueQCop(channel,message,data); 719 d->enqueueQCop(channel,message,data);
720 } 720 }
721 ::ftruncate(f.handle(), 0); 721 ::ftruncate(f.handle(), 0);
722#ifndef Q_OS_WIN32 722#ifndef Q_OS_WIN32
723 f.flush(); 723 f.flush();
724 flock(f.handle(), LOCK_UN); 724 flock(f.handle(), LOCK_UN);
725#endif 725#endif
726 } 726 }
727#endif 727#endif
728} 728}
729 729
730 730
731/*! 731/*!
732 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 732 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
733 733
734 This signal is emitted when a message is received on this 734 This signal is emitted when a message is received on this
735 application's QPE/Application/<i>appname</i> \link qcop.html 735 application's QPE/Application/<i>appname</i> \link qcop.html
736 QCop\endlink channel. 736 QCop\endlink channel.
737 737
738 The slot to which you connect this signal uses \a msg and \a data 738 The slot to which you connect this signal uses \a msg and \a data
739 in the following way: 739 in the following way:
740 740
741\code 741\code
742 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 742 void MyWidget::receive( const QCString& msg, const QByteArray& data )
743 { 743 {
744 QDataStream stream( data, IO_ReadOnly ); 744 QDataStream stream( data, IO_ReadOnly );
745 if ( msg == "someMessage(int,int,int)" ) { 745 if ( msg == "someMessage(int,int,int)" ) {
746 int a,b,c; 746 int a,b,c;
747 stream >> a >> b >> c; 747 stream >> a >> b >> c;
748 ... 748 ...
749 } else if ( msg == "otherMessage(QString)" ) { 749 } else if ( msg == "otherMessage(QString)" ) {
750 ... 750 ...
751 } 751 }
752 } 752 }
753\endcode 753\endcode
754 754
755 \sa qcop.html 755 \sa qcop.html
756 Note that messages received here may be processed by qpe application 756 Note that messages received here may be processed by qpe application
757 and emitted as signals, such as flush() and reload(). 757 and emitted as signals, such as flush() and reload().
758*/ 758*/
759 759
760#ifndef QT_NO_TRANSLATION 760#ifndef QT_NO_TRANSLATION
761static void qtopia_loadTranslations( const QStringList& qms ) 761static void qtopia_loadTranslations( const QStringList& qms )
762{ 762{
763 QStringList langs = Global::languageList(); 763 QStringList langs = Global::languageList();
764 764
765 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 765 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
766 QString lang = *it; 766 QString lang = *it;
767 767
768 QTranslator * trans; 768 QTranslator * trans;
769 QString tfn; 769 QString tfn;
770 770
771 for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) { 771 for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) {
772 trans = new QTranslator(qApp); 772 trans = new QTranslator(qApp);
773 tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm"; 773 tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm";
774 if ( trans->load( tfn )) 774 if ( trans->load( tfn ))
775 qApp->installTranslator( trans ); 775 qApp->installTranslator( trans );
776 else 776 else
777 delete trans; 777 delete trans;
778 } 778 }
779 } 779 }
780} 780}
781#endif 781#endif
782 782
783/* 783/*
784 Turn off qDebug in release mode 784 Turn off qDebug in release mode
785 */ 785 */
786static void qtopiaMsgHandler(QtMsgType type, const char* msg) 786static void qtopiaMsgHandler(QtMsgType type, const char* msg)
787{ 787{
788 switch ( type ) { 788 switch ( type ) {
789 case QtDebugMsg: 789 case QtDebugMsg:
790#ifdef QT_DEBUG 790#ifdef QT_DEBUG
791 fprintf( stderr, "Debug: %s\n", msg ); 791 fprintf( stderr, "Debug: %s\n", msg );
792#endif 792#endif
793 break; 793 break;
794 case QtWarningMsg: 794 case QtWarningMsg:
795#ifdef QT_DEBUG 795#ifdef QT_DEBUG
796 fprintf( stderr, "Warning: %s\n", msg ); 796 fprintf( stderr, "Warning: %s\n", msg );
797#endif 797#endif
798 break; 798 break;
799 case QtFatalMsg: 799 case QtFatalMsg:
800 fprintf( stderr, "Fatal: %s\n", msg ); 800 fprintf( stderr, "Fatal: %s\n", msg );
801 abort(); 801 abort();
802 } 802 }
803} 803}
804 804
805/*! 805/*!
806 Constructs a QPEApplication just as you would construct 806 Constructs a QPEApplication just as you would construct
807 a QApplication, passing \a argc, \a argv, and \a t. 807 a QApplication, passing \a argc, \a argv, and \a t.
808 808
809 For applications, \a t should be the default, GuiClient. Only 809 For applications, \a t should be the default, GuiClient. Only
810 the Qtopia server passes GuiServer. 810 the Qtopia server passes GuiServer.
811*/ 811*/
812QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 812QPEApplication::QPEApplication( int & argc, char **argv, Type t )
813 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 813 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
814{ 814{
815 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 815 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
816 qInstallMsgHandler(qtopiaMsgHandler); 816 qInstallMsgHandler(qtopiaMsgHandler);
817 817
818 d = new QPEApplicationData; 818 d = new QPEApplicationData;
819 d->loadTextCodecs(); 819 d->loadTextCodecs();
820 d->loadImageCodecs(); 820 d->loadImageCodecs();
821 821
822 setFont( QFont( d->fontFamily, d->fontSize ) ); 822 setFont( QFont( d->fontFamily, d->fontSize ) );
823 AppLnk::setSmallIconSize( d->smallIconSize ); 823 AppLnk::setSmallIconSize( d->smallIconSize );
824 AppLnk::setBigIconSize( d->bigIconSize ); 824 AppLnk::setBigIconSize( d->bigIconSize );
825 825
826 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 826 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
827 827
828 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 828 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
829 829
830 830
831 sysChannel = new QCopChannel( "QPE/System", this ); 831 sysChannel = new QCopChannel( "QPE/System", this );
832 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 832 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
833 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 833 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
834 834
835/* COde now in initapp */ 835/* COde now in initapp */
836#if 0 836#if 0
837#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 837#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
838 838
839 QString qcopfn( "/tmp/qcop-msg-" ); 839 QString qcopfn( "/tmp/qcop-msg-" );
840 qcopfn += QString( argv[ 0 ] ); // append command name 840 qcopfn += QString( argv[ 0 ] ); // append command name
841 841
842 QFile f( qcopfn ); 842 QFile f( qcopfn );
843 if ( f.open( IO_ReadOnly ) ) { 843 if ( f.open( IO_ReadOnly ) ) {
844 flock( f.handle(), LOCK_EX ); 844 flock( f.handle(), LOCK_EX );
845 } 845 }
846 846
847 847
848 848
849 QCString channel = QCString( argv[ 0 ] ); 849 QCString channel = QCString( argv[ 0 ] );
850 channel.replace( QRegExp( ".*/" ), "" ); 850 channel.replace( QRegExp( ".*/" ), "" );
851 d->appName = channel; 851 d->appName = channel;
852 channel = "QPE/Application/" + channel; 852 channel = "QPE/Application/" + channel;
853 pidChannel = new QCopChannel( channel, this ); 853 pidChannel = new QCopChannel( channel, this );
854 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 854 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
855 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); 855 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
856 856
857 if ( f.isOpen() ) { 857 if ( f.isOpen() ) {
858 d->keep_running = FALSE; 858 d->keep_running = FALSE;
859 QDataStream ds( &f ); 859 QDataStream ds( &f );
860 QCString channel, message; 860 QCString channel, message;
861 QByteArray data; 861 QByteArray data;
862 while ( !ds.atEnd() ) { 862 while ( !ds.atEnd() ) {
863 ds >> channel >> message >> data; 863 ds >> channel >> message >> data;
864 d->enqueueQCop( channel, message, data ); 864 d->enqueueQCop( channel, message, data );
865 } 865 }
866 866
867 flock( f.handle(), LOCK_UN ); 867 flock( f.handle(), LOCK_UN );
868 f.close(); 868 f.close();
869 f.remove(); 869 f.remove();
870 } 870 }
871 871
872 for ( int a = 0; a < argc; a++ ) { 872 for ( int a = 0; a < argc; a++ ) {
873 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 873 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
874 argv[ a ] = argv[ a + 1 ]; 874 argv[ a ] = argv[ a + 1 ];
875 a++; 875 a++;
876 d->preloaded = TRUE; 876 d->preloaded = TRUE;
877 argc -= 1; 877 argc -= 1;
878 } 878 }
879 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 879 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
880 argv[ a ] = argv[ a + 1 ]; 880 argv[ a ] = argv[ a + 1 ];
881 a++; 881 a++;
882 d->preloaded = TRUE; 882 d->preloaded = TRUE;
883 d->forceshow = TRUE; 883 d->forceshow = TRUE;
884 argc -= 1; 884 argc -= 1;
885 } 885 }
886 } 886 }
887 887
888 /* overide stored arguments */ 888 /* overide stored arguments */
889 setArgs( argc, argv ); 889 setArgs( argc, argv );
890 890
891#endif 891#endif
892#else 892#else
893 initApp( argc, argv ); 893 initApp( argc, argv );
894#endif 894#endif
895#ifdef Q_WS_QWS 895#ifdef Q_WS_QWS
896 /* load the font renderer factories */ 896 /* load the font renderer factories */
897 FontDatabase::loadRenderers(); 897 FontDatabase::loadRenderers();
898#endif 898#endif
899#ifndef QT_NO_TRANSLATION 899#ifndef QT_NO_TRANSLATION
900 QStringList qms; 900 QStringList qms;
901 qms << "libqpe"; 901 qms << "libqpe";
902 qms << "libopie"; 902 qms << "libopie";
903 qms << d->appName; 903 qms << d->appName;
904 904
905 qtopia_loadTranslations(qms); 905 qtopia_loadTranslations(qms);
906#endif 906#endif
907 907
908 applyStyle(); 908 applyStyle();
909 909
910 if ( type() == GuiServer ) { 910 if ( type() == GuiServer ) {
911 setVolume(); 911 setVolume();
912 } 912 }
913 913
914 installEventFilter( this ); 914 installEventFilter( this );
915 915
916 QPEMenuToolFocusManager::initialize(); 916 QPEMenuToolFocusManager::initialize();
917 917
918#ifdef QT_NO_QWS_CURSOR 918#ifdef QT_NO_QWS_CURSOR
919 // if we have no cursor, probably don't want tooltips 919 // if we have no cursor, probably don't want tooltips
920 QToolTip::setEnabled( FALSE ); 920 QToolTip::setEnabled( FALSE );
921#endif 921#endif
922} 922}
923 923
924 924
925#ifdef QTOPIA_INTERNAL_INITAPP 925#ifdef QTOPIA_INTERNAL_INITAPP
926void QPEApplication::initApp( int argc, char **argv ) 926void QPEApplication::initApp( int argc, char **argv )
927{ 927{
928 delete pidChannel; 928 delete pidChannel;
929 d->keep_running = TRUE; 929 d->keep_running = TRUE;
930 d->preloaded = FALSE; 930 d->preloaded = FALSE;
931 d->forceshow = FALSE; 931 d->forceshow = FALSE;
932 932
933 QCString channel = QCString(argv[0]); 933 QCString channel = QCString(argv[0]);
934 934
935 channel.replace(QRegExp(".*/"),""); 935 channel.replace(QRegExp(".*/"),"");
936 d->appName = channel; 936 d->appName = channel;
937 937
938#ifndef QT_NO_TRANSLATION 938#ifndef QT_NO_TRANSLATION
939 qtopia_loadTranslations( QStringList()<<channel ); 939 qtopia_loadTranslations( QStringList()<<channel );
940#endif 940#endif
941 941
942 #if QT_VERSION > 235 942 #if QT_VERSION > 235
943 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 943 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
944 #endif 944 #endif
945 945
946 channel = "QPE/Application/" + channel; 946 channel = "QPE/Application/" + channel;
947 pidChannel = new QCopChannel( channel, this); 947 pidChannel = new QCopChannel( channel, this);
948 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 948 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
949 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 949 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
950 950
951 951
952 952
953 processQCopFile(); 953 processQCopFile();
954 d->keep_running = d->qcopq.isEmpty(); 954 d->keep_running = d->qcopq.isEmpty();
955 955
956 for (int a=0; a<argc; a++) { 956 for (int a=0; a<argc; a++) {
957 if ( qstrcmp(argv[a],"-preload")==0 ) { 957 if ( qstrcmp(argv[a],"-preload")==0 ) {
958 argv[a] = argv[a+1]; 958 argv[a] = argv[a+1];
959 a++; 959 a++;
960 d->preloaded = TRUE; 960 d->preloaded = TRUE;
961 argc-=1; 961 argc-=1;
962 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 962 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
963 argv[a] = argv[a+1]; 963 argv[a] = argv[a+1];
964 a++; 964 a++;
965 d->preloaded = TRUE; 965 d->preloaded = TRUE;
966 d->forceshow = TRUE; 966 d->forceshow = TRUE;
967 argc-=1; 967 argc-=1;
968 } 968 }
969 } 969 }
970 970
971 /* overide stored arguments */ 971 /* overide stored arguments */
972 setArgs(argc, argv); 972 setArgs(argc, argv);
973} 973}
974#endif 974#endif
975 975
976 976
977static QPtrDict<void>* inputMethodDict = 0; 977static QPtrDict<void>* inputMethodDict = 0;
978static void createInputMethodDict() 978static void createInputMethodDict()
979{ 979{
980 if ( !inputMethodDict ) 980 if ( !inputMethodDict )
981 inputMethodDict = new QPtrDict<void>; 981 inputMethodDict = new QPtrDict<void>;
982} 982}
983 983
984/*! 984/*!
985 Returns the currently set hint to the system as to whether 985 Returns the currently set hint to the system as to whether
986 widget \a w has any use for text input methods. 986 widget \a w has any use for text input methods.
987 987
988 988
989 \sa setInputMethodHint() InputMethodHint 989 \sa setInputMethodHint() InputMethodHint
990*/ 990*/
991QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 991QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
992{ 992{
993 if ( inputMethodDict && w ) 993 if ( inputMethodDict && w )
994 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 994 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
995 return Normal; 995 return Normal;
996} 996}
997 997
998/*! 998/*!
999 \enum QPEApplication::InputMethodHint 999 \enum QPEApplication::InputMethodHint
1000 1000
1001 \value Normal the application sometimes needs text input (the default). 1001 \value Normal the application sometimes needs text input (the default).
1002 \value AlwaysOff the application never needs text input. 1002 \value AlwaysOff the application never needs text input.
1003 \value AlwaysOn the application always needs text input. 1003 \value AlwaysOn the application always needs text input.
1004*/ 1004*/
1005 1005
1006/*! 1006/*!
1007 Hints to the system that widget \a w has use for text input methods 1007 Hints to the system that widget \a w has use for text input methods
1008 as specified by \a mode. 1008 as specified by \a mode.
1009 1009
1010 \sa inputMethodHint() InputMethodHint 1010 \sa inputMethodHint() InputMethodHint
1011*/ 1011*/
1012void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 1012void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1013{ 1013{
1014 createInputMethodDict(); 1014 createInputMethodDict();
1015 if ( mode == Normal ) { 1015 if ( mode == Normal ) {
1016 inputMethodDict->remove 1016 inputMethodDict->remove
1017 ( w ); 1017 ( w );
1018 } 1018 }
1019 else { 1019 else {
1020 inputMethodDict->insert( w, ( void* ) mode ); 1020 inputMethodDict->insert( w, ( void* ) mode );
1021 } 1021 }
1022} 1022}
1023 1023
1024class HackDialog : public QDialog 1024class HackDialog : public QDialog
1025{ 1025{
1026public: 1026public:
1027 void acceptIt() 1027 void acceptIt()
1028 { 1028 {
1029 accept(); 1029 accept();
1030 } 1030 }
1031 void rejectIt() 1031 void rejectIt()
1032 { 1032 {
1033 reject(); 1033 reject();
1034 } 1034 }
1035}; 1035};
1036 1036
1037 1037
1038void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1038void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1039{ 1039{
1040 // specialised actions for certain widgets. May want to 1040 // specialised actions for certain widgets. May want to
1041 // add more stuff here. 1041 // add more stuff here.
1042 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1042 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1043 && activePopupWidget() ->parentWidget() 1043 && activePopupWidget() ->parentWidget()
1044 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1044 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1045 key = Qt::Key_Return; 1045 key = Qt::Key_Return;
1046 1046
1047 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1047 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1048 key = Qt::Key_Return; 1048 key = Qt::Key_Return;
1049 1049
1050#ifdef QWS 1050#ifdef QWS
1051 1051
1052 ke->simpleData.keycode = key; 1052 ke->simpleData.keycode = key;
1053#endif 1053#endif
1054} 1054}
1055 1055
1056 1056
1057/*! 1057/*!
1058 \internal 1058 \internal
1059*/ 1059*/
1060 1060
1061#ifdef QWS 1061#ifdef QWS
1062bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1062bool QPEApplication::qwsEventFilter( QWSEvent * e )
1063{ 1063{
1064 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1064 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1065 if ( qApp->type() != QApplication::GuiServer ) { 1065 if ( qApp->type() != QApplication::GuiServer ) {
1066 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1066 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1067 e << d->appName; 1067 e << d->appName;
1068 } 1068 }
1069 d->notbusysent = TRUE; 1069 d->notbusysent = TRUE;
1070 } 1070 }
1071 if ( type() == GuiServer ) { 1071 if ( type() == GuiServer ) {
1072 switch ( e->type ) { 1072 switch ( e->type ) {
1073 case QWSEvent::Mouse: 1073 case QWSEvent::Mouse:
1074 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1074 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1075 emit clientMoused(); 1075 emit clientMoused();
1076 break; 1076 break;
1077 default: 1077 default:
1078 break; 1078 break;
1079 } 1079 }
1080 } 1080 }
1081 if ( e->type == QWSEvent::Key ) { 1081 if ( e->type == QWSEvent::Key ) {
1082 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1082 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1083 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1083 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1084 // Use special "OK" key to press "OK" on top level widgets 1084 // Use special "OK" key to press "OK" on top level widgets
1085 QWidget * active = activeWindow(); 1085 QWidget * active = activeWindow();
1086 QWidget *popup = 0; 1086 QWidget *popup = 0;
1087 if ( active && active->isPopup() ) { 1087 if ( active && active->isPopup() ) {
1088 popup = active; 1088 popup = active;
1089 active = active->parentWidget(); 1089 active = active->parentWidget();
1090 } 1090 }
1091 if ( active && ( int ) active->winId() == ke->simpleData.window && 1091 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1092 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1092 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1093 if ( ke->simpleData.is_press ) { 1093 if ( ke->simpleData.is_press ) {
1094 if ( popup ) 1094 if ( popup )
1095 popup->close(); 1095 popup->close();
1096 if ( active->inherits( "QDialog" ) ) { 1096 if ( active->inherits( "QDialog" ) ) {
1097 HackDialog * d = ( HackDialog * ) active; 1097 HackDialog * d = ( HackDialog * ) active;
1098 d->acceptIt(); 1098 d->acceptIt();
1099 return TRUE; 1099 return TRUE;
1100 } 1100 }
1101 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1101 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1102 QSignal s; 1102 QSignal s;
1103 s.connect( active, SLOT( accept() ) ); 1103 s.connect( active, SLOT( accept() ) );
1104 s.activate(); 1104 s.activate();
1105 } 1105 }
1106 else { 1106 else {
1107 // do the same as with the select key: Map to the default action of the widget: 1107 // do the same as with the select key: Map to the default action of the widget:
1108 mapToDefaultAction( ke, Qt::Key_Return ); 1108 mapToDefaultAction( ke, Qt::Key_Return );
1109 } 1109 }
1110 } 1110 }
1111 } 1111 }
1112 } 1112 }
1113 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1113 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1114 // Use special "select" key to do whatever default action a widget has 1114 // Use special "select" key to do whatever default action a widget has
1115 mapToDefaultAction( ke, Qt::Key_Space ); 1115 mapToDefaultAction( ke, Qt::Key_Space );
1116 } 1116 }
1117 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1117 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1118 ke->simpleData.is_press ) { 1118 ke->simpleData.is_press ) {
1119 // Escape key closes app if focus on toplevel 1119 // Escape key closes app if focus on toplevel
1120 QWidget * active = activeWindow(); 1120 QWidget * active = activeWindow();
1121 if ( active && active->testWFlags( WType_TopLevel ) && 1121 if ( active && active->testWFlags( WType_TopLevel ) &&
1122 ( int ) active->winId() == ke->simpleData.window && 1122 ( int ) active->winId() == ke->simpleData.window &&
1123 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1123 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1124 if ( active->inherits( "QDialog" ) ) { 1124 if ( active->inherits( "QDialog" ) ) {
1125 HackDialog * d = ( HackDialog * ) active; 1125 HackDialog * d = ( HackDialog * ) active;
1126 d->rejectIt(); 1126 d->rejectIt();
1127 return TRUE; 1127 return TRUE;
1128 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { 1128 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1129 active->close(); 1129 active->close();
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 } 1133 }
1134 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1134 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1135 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1135 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1136 // but we cannot access libopie function within libqpe :( 1136 // but we cannot access libopie function within libqpe :(
1137 1137
1138 QWidget * active = activeWindow ( ); 1138 QWidget * active = activeWindow ( );
1139 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1139 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1140 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1140 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1141 QChar ch ( ke-> simpleData.unicode ); 1141 QChar ch ( ke-> simpleData.unicode );
1142 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1142 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1143 ke-> simpleData.keycode, 1143 ke-> simpleData.keycode,
1144 ch. latin1 ( ), 1144 ch. latin1 ( ),
1145 ke-> simpleData.modifiers, 1145 ke-> simpleData.modifiers,
1146 QString ( ch ), 1146 QString ( ch ),
1147 ke-> simpleData.is_auto_repeat, 1 ); 1147 ke-> simpleData.is_auto_repeat, 1 );
1148 1148
1149 QObject *which = QWidget::keyboardGrabber ( ); 1149 QObject *which = QWidget::keyboardGrabber ( );
1150 if ( !which ) 1150 if ( !which )
1151 which = QApplication::focusWidget ( ); 1151 which = QApplication::focusWidget ( );
1152 if ( !which ) 1152 if ( !which )
1153 which = QApplication::activeWindow ( ); 1153 which = QApplication::activeWindow ( );
1154 if ( !which ) 1154 if ( !which )
1155 which = qApp; 1155 which = qApp;
1156 1156
1157 QApplication::sendEvent ( which, &qke ); 1157 QApplication::sendEvent ( which, &qke );
1158 } 1158 }
1159 else { // we didn't grab the keyboard, so send the event to the launcher 1159 else { // we didn't grab the keyboard, so send the event to the launcher
1160 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1160 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1161 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1161 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1162 } 1162 }
1163 } 1163 }
1164 return true; 1164 return true;
1165 } 1165 }
1166 } 1166 }
1167 if ( e->type == QWSEvent::Focus ) { 1167 if ( e->type == QWSEvent::Focus ) {
1168 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1168 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1169 if ( !fe->simpleData.get_focus ) { 1169 if ( !fe->simpleData.get_focus ) {
1170 QWidget * active = activeWindow(); 1170 QWidget * active = activeWindow();
1171 while ( active && active->isPopup() ) { 1171 while ( active && active->isPopup() ) {
1172 active->close(); 1172 active->close();
1173 active = activeWindow(); 1173 active = activeWindow();
1174 } 1174 }
1175 } 1175 }
1176 else { 1176 else {
1177 // make sure our modal widget is ALWAYS on top 1177 // make sure our modal widget is ALWAYS on top
1178 QWidget *topm = activeModalWidget(); 1178 QWidget *topm = activeModalWidget();
1179 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1179 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1180 topm->raise(); 1180 topm->raise();
1181 } 1181 }
1182 } 1182 }
1183 if ( fe->simpleData.get_focus && inputMethodDict ) { 1183 if ( fe->simpleData.get_focus && inputMethodDict ) {
1184 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1184 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1185 if ( m == AlwaysOff ) 1185 if ( m == AlwaysOff )
1186 Global::hideInputMethod(); 1186 Global::hideInputMethod();
1187 if ( m == AlwaysOn ) 1187 if ( m == AlwaysOn )
1188 Global::showInputMethod(); 1188 Global::showInputMethod();
1189 } 1189 }
1190 } 1190 }
1191 1191
1192 1192
1193 return QApplication::qwsEventFilter( e ); 1193 return QApplication::qwsEventFilter( e );
1194} 1194}
1195#endif 1195#endif
1196 1196
1197/*! 1197/*!
1198 Destroys the QPEApplication. 1198 Destroys the QPEApplication.
1199*/ 1199*/
1200QPEApplication::~QPEApplication() 1200QPEApplication::~QPEApplication()
1201{ 1201{
1202 ungrabKeyboard(); 1202 ungrabKeyboard();
1203#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1203#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1204 // Need to delete QCopChannels early, since the display will 1204 // Need to delete QCopChannels early, since the display will
1205 // be gone by the time we get to ~QObject(). 1205 // be gone by the time we get to ~QObject().
1206 delete sysChannel; 1206 delete sysChannel;
1207 delete pidChannel; 1207 delete pidChannel;
1208#endif 1208#endif
1209 1209
1210#ifdef OPIE_WITHROHFEEDBACK 1210#ifdef OPIE_WITHROHFEEDBACK
1211 if( d->RoH ) 1211 if( d->RoH )
1212 delete d->RoH; 1212 delete d->RoH;
1213#endif 1213#endif
1214 delete d; 1214 delete d;
1215} 1215}
1216 1216
1217/*! 1217/*!
1218 Returns <tt>$OPIEDIR/</tt>. 1218 Returns <tt>$OPIEDIR/</tt>.
1219*/ 1219*/
1220QString QPEApplication::qpeDir() 1220QString QPEApplication::qpeDir()
1221{ 1221{
1222 QString base, dir; 1222 QString base, dir;
1223 1223
1224 if (getenv( "OPIEDIR" )) 1224 if (getenv( "OPIEDIR" ))
1225 base = QString(getenv("OPIEDIR")).stripWhiteSpace(); 1225 base = QString(getenv("OPIEDIR")).stripWhiteSpace();
1226 if ( !base.isNull() && (base.length() > 0 )){ 1226 if ( !base.isNull() && (base.length() > 0 )){
1227#ifdef Q_OS_WIN32 1227#ifdef Q_OS_WIN32
1228 QString temp(base); 1228 QString temp(base);
1229 if (temp[(int)temp.length()-1] != QDir::separator()) 1229 if (temp[(int)temp.length()-1] != QDir::separator())
1230 temp.append(QDir::separator()); 1230 temp.append(QDir::separator());
1231 dir = temp; 1231 dir = temp;
1232#else 1232#else
1233 dir = QString( base ) + "/"; 1233 dir = QString( base ) + "/";
1234#endif 1234#endif
1235 }else{ 1235 }else{
1236 dir = QString( ".." ) + QDir::separator(); 1236 dir = QString( ".." ) + QDir::separator();
1237 } 1237 }
1238 1238
1239 return dir; 1239 return dir;
1240} 1240}
1241 1241
1242/*! 1242/*!
1243 Returns the user's current Document directory. There is a trailing "/". 1243 Returns the user's current Document directory. There is a trailing "/".
1244 .. well, it does now,, and there's no trailing '/' 1244 .. well, it does now,, and there's no trailing '/'
1245*/ 1245*/
1246QString QPEApplication::documentDir() 1246QString QPEApplication::documentDir()
1247{ 1247{
1248 const char* base = getenv( "HOME"); 1248 const char* base = getenv( "HOME");
1249 if ( base ) 1249 if ( base )
1250 return QString( base ) + "/Documents"; 1250 return QString( base ) + "/Documents";
1251 1251
1252 return QString( "../Documents" ); 1252 return QString( "../Documents" );
1253} 1253}
1254 1254
1255static int deforient = -1; 1255static int deforient = -1;
1256 1256
1257/*! 1257/*!
1258 \internal 1258 \internal
1259*/ 1259*/
1260int QPEApplication::defaultRotation() 1260int QPEApplication::defaultRotation()
1261{ 1261{
1262 if ( deforient < 0 ) { 1262 if ( deforient < 0 ) {
1263 QString d = getenv( "QWS_DISPLAY" ); 1263 QString d = getenv( "QWS_DISPLAY" );
1264 if ( d.contains( "Rot90" ) ) { 1264 if ( d.contains( "Rot90" ) ) {
1265 deforient = 90; 1265 deforient = 90;
1266 } 1266 }
1267 else if ( d.contains( "Rot180" ) ) { 1267 else if ( d.contains( "Rot180" ) ) {
1268 deforient = 180; 1268 deforient = 180;
1269 } 1269 }
1270 else if ( d.contains( "Rot270" ) ) { 1270 else if ( d.contains( "Rot270" ) ) {
1271 deforient = 270; 1271 deforient = 270;
1272 } 1272 }
1273 else { 1273 else {
1274 deforient = 0; 1274 deforient = 0;
1275 } 1275 }
1276 } 1276 }
1277 return deforient; 1277 return deforient;
1278} 1278}
1279 1279
1280/*! 1280/*!
1281 \internal 1281 \internal
1282*/ 1282*/
1283void QPEApplication::setDefaultRotation( int r ) 1283void QPEApplication::setDefaultRotation( int r )
1284{ 1284{
1285 if ( qApp->type() == GuiServer ) { 1285 if ( qApp->type() == GuiServer ) {
1286 deforient = r; 1286 deforient = r;
1287 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1287 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1288 Config config("qpe"); 1288 Config config("qpe");
1289 config.setGroup( "Rotation" ); 1289 config.setGroup( "Rotation" );
1290 config.writeEntry( "Rot", r ); 1290 config.writeEntry( "Rot", r );
1291 } 1291 }
1292 else { 1292 else {
1293#ifndef QT_NO_COP 1293#ifndef QT_NO_COP
1294 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1294 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1295 e << r; 1295 e << r;
1296 } 1296 }
1297#endif 1297#endif
1298 1298
1299 } 1299 }
1300} 1300}
1301 1301
1302#include <qgfx_qws.h> 1302#include <qgfx_qws.h>
1303#include <qwindowsystem_qws.h> 1303#include <qwindowsystem_qws.h>
1304 1304
1305#if QT_VERSION > 236 1305#if QT_VERSION > 236
1306extern void qws_clearLoadedFonts(); 1306extern void qws_clearLoadedFonts();
1307#endif 1307#endif
1308 1308
1309void QPEApplication::setCurrentMode( int x, int y, int depth ) 1309void QPEApplication::setCurrentMode( int x, int y, int depth )
1310{ 1310{
1311 // Reset the caches 1311 // Reset the caches
1312#if QT_VERSION > 236 1312#if QT_VERSION > 236
1313 qws_clearLoadedFonts(); 1313 qws_clearLoadedFonts();
1314#endif 1314#endif
1315 QPixmapCache::clear(); 1315 QPixmapCache::clear();
1316 1316
1317 // Change the screen mode 1317 // Change the screen mode
1318 qt_screen->setMode(x, y, depth); 1318 qt_screen->setMode(x, y, depth);
1319 1319
1320 if ( qApp->type() == GuiServer ) { 1320 if ( qApp->type() == GuiServer ) {
1321#if QT_VERSION > 236 1321#if QT_VERSION > 236
1322 // Reconfigure the GuiServer 1322 // Reconfigure the GuiServer
1323 qwsServer->beginDisplayReconfigure(); 1323 qwsServer->beginDisplayReconfigure();
1324 qwsServer->endDisplayReconfigure(); 1324 qwsServer->endDisplayReconfigure();
1325#endif 1325#endif
1326 // Get all the running apps to reset 1326 // Get all the running apps to reset
1327 QCopEnvelope env( "QPE/System", "reset()" ); 1327 QCopEnvelope env( "QPE/System", "reset()" );
1328 } 1328 }
1329} 1329}
1330 1330
1331void QPEApplication::reset() { 1331void QPEApplication::reset() {
1332 // Reconnect to the screen 1332 // Reconnect to the screen
1333 qt_screen->disconnect(); 1333 qt_screen->disconnect();
1334 qt_screen->connect( QString::null ); 1334 qt_screen->connect( QString::null );
1335 1335
1336 // Redraw everything 1336 // Redraw everything
1337 applyStyle(); 1337 applyStyle();
1338} 1338}
1339 1339
1340#if (QT_VERSION < 238) && defined Q_OS_MACX 1340#if (QT_VERSION < 238) && defined Q_OS_MACX
1341bool qt_left_hand_scrollbars = false; 1341bool qt_left_hand_scrollbars = false;
1342#else 1342#else
1343extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; 1343extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL;
1344#endif 1344#endif
1345 1345
1346/*! 1346/*!
1347 \internal 1347 \internal
1348*/ 1348*/
1349void QPEApplication::applyStyle() 1349void QPEApplication::applyStyle()
1350{ 1350{
1351 Config config( "qpe" ); 1351 Config config( "qpe" );
1352 config.setGroup( "Appearance" ); 1352 config.setGroup( "Appearance" );
1353 1353
1354#if QT_VERSION > 233 1354#if QT_VERSION > 233
1355#if !defined(OPIE_NO_OVERRIDE_QT) 1355#if !defined(OPIE_NO_OVERRIDE_QT)
1356 // don't block ourselves ... 1356 // don't block ourselves ...
1357 Opie::force_appearance = 0; 1357 Opie::force_appearance = 0;
1358 1358
1359 static QString appname = Opie::binaryName ( ); 1359 static QString appname = Opie::binaryName ( );
1360 1360
1361 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 1361 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1362 int nostyle = 0; 1362 int nostyle = 0;
1363 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 1363 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1364 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 1364 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1365 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 1365 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1366 break; 1366 break;
1367 } 1367 }
1368 } 1368 }
1369#else 1369#else
1370 int nostyle = 0; 1370 int nostyle = 0;
1371#endif 1371#endif
1372 1372
1373 // Widget style 1373 // Widget style
1374 QString style = config.readEntry( "Style", "FlatStyle" ); 1374 QString style = config.readEntry( "Style", "FlatStyle" );
1375 1375
1376 // don't set a custom style 1376 // don't set a custom style
1377 if ( nostyle & Opie::Force_Style ) 1377 if ( nostyle & Opie::Force_Style )
1378 style = "FlatStyle"; 1378 style = "FlatStyle";
1379 1379
1380 internalSetStyle ( style ); 1380 internalSetStyle ( style );
1381 1381
1382 // Colors - from /etc/colors/Liquid.scheme 1382 // Colors - from /etc/colors/Liquid.scheme
1383 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1383 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1384 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1384 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1385 QPalette pal( btncolor, bgcolor ); 1385 QPalette pal( btncolor, bgcolor );
1386 QString color = config.readEntry( "Highlight", "#73adef" ); 1386 QString color = config.readEntry( "Highlight", "#73adef" );
1387 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1387 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1388 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1388 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1389 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1389 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1390 color = config.readEntry( "Text", "#000000" ); 1390 color = config.readEntry( "Text", "#000000" );
1391 pal.setColor( QColorGroup::Text, QColor( color ) ); 1391 pal.setColor( QColorGroup::Text, QColor( color ) );
1392 color = config.readEntry( "ButtonText", "#000000" ); 1392 color = config.readEntry( "ButtonText", "#000000" );
1393 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1393 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1394 color = config.readEntry( "Base", "#FFFFFF" ); 1394 color = config.readEntry( "Base", "#FFFFFF" );
1395 pal.setColor( QColorGroup::Base, QColor( color ) ); 1395 pal.setColor( QColorGroup::Base, QColor( color ) );
1396 1396
1397 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1397 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1398 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1398 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1399 1399
1400 setPalette( pal, TRUE ); 1400 setPalette( pal, TRUE );
1401 1401
1402 1402
1403 // Set the ScrollBar on the 'right' side but only if the weak symbol is present 1403 // Set the ScrollBar on the 'right' side but only if the weak symbol is present
1404 if (&qt_left_hand_scrollbars ) 1404 if (&qt_left_hand_scrollbars )
1405 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); 1405 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false );
1406 1406
1407 // Window Decoration 1407 // Window Decoration
1408 QString dec = config.readEntry( "Decoration", "Flat" ); 1408 QString dec = config.readEntry( "Decoration", "Flat" );
1409 1409
1410 // don't set a custom deco 1410 // don't set a custom deco
1411 if ( nostyle & Opie::Force_Decoration ) 1411 if ( nostyle & Opie::Force_Decoration )
1412 dec = ""; 1412 dec = "";
1413 1413
1414 1414
1415 if ( dec != d->decorationName ) { 1415 if ( dec != d->decorationName ) {
1416 qwsSetDecoration( new QPEDecoration( dec ) ); 1416 qwsSetDecoration( new QPEDecoration( dec ) );
1417 d->decorationName = dec; 1417 d->decorationName = dec;
1418 } 1418 }
1419 1419
1420 // Font 1420 // Font
1421 QString ff = config.readEntry( "FontFamily", font().family() ); 1421 QString ff = config.readEntry( "FontFamily", font().family() );
1422 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1422 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1423 1423
1424 // don't set a custom font 1424 // don't set a custom font
1425 if ( nostyle & Opie::Force_Font ) { 1425 if ( nostyle & Opie::Force_Font ) {
1426 ff = "Vera"; 1426 ff = "Vera";
1427 fs = 10; 1427 fs = 10;
1428 } 1428 }
1429 1429
1430 setFont ( QFont ( ff, fs ), true ); 1430 setFont ( QFont ( ff, fs ), true );
1431 1431
1432#if !defined(OPIE_NO_OVERRIDE_QT) 1432#if !defined(OPIE_NO_OVERRIDE_QT)
1433 // revert to global blocking policy ... 1433 // revert to global blocking policy ...
1434 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1434 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1435 Opie::force_appearance &= ~nostyle; 1435 Opie::force_appearance &= ~nostyle;
1436#endif 1436#endif
1437#endif 1437#endif
1438} 1438}
1439 1439
1440void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1440void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1441{ 1441{
1442#ifdef Q_WS_QWS 1442#ifdef Q_WS_QWS
1443 QDataStream stream( data, IO_ReadOnly ); 1443 QDataStream stream( data, IO_ReadOnly );
1444 if ( msg == "applyStyle()" ) { 1444 if ( msg == "applyStyle()" ) {
1445 applyStyle(); 1445 applyStyle();
1446 } 1446 }
1447 else if ( msg == "toggleApplicationMenu()" ) { 1447 else if ( msg == "toggleApplicationMenu()" ) {
1448 QWidget *active = activeWindow ( ); 1448 QWidget *active = activeWindow ( );
1449 1449
1450 if ( active ) { 1450 if ( active ) {
1451 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1451 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1452 bool oldactive = man-> isActive ( ); 1452 bool oldactive = man-> isActive ( );
1453 1453
1454 man-> setActive( !man-> isActive() ); 1454 man-> setActive( !man-> isActive() );
1455 1455
1456 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1456 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1457 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1457 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1458 } 1458 }
1459 } 1459 }
1460 } 1460 }
1461 else if ( msg == "setDefaultRotation(int)" ) { 1461 else if ( msg == "setDefaultRotation(int)" ) {
1462 if ( type() == GuiServer ) { 1462 if ( type() == GuiServer ) {
1463 int r; 1463 int r;
1464 stream >> r; 1464 stream >> r;
1465 setDefaultRotation( r ); 1465 setDefaultRotation( r );
1466 } 1466 }
1467 } 1467 }
1468 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> 1468 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net>
1469 if ( type() == GuiServer ) { 1469 if ( type() == GuiServer ) {
1470 int x, y, depth; 1470 int x, y, depth;
1471 stream >> x; 1471 stream >> x;
1472 stream >> y; 1472 stream >> y;
1473 stream >> depth; 1473 stream >> depth;
1474 setCurrentMode( x, y, depth ); 1474 setCurrentMode( x, y, depth );
1475 } 1475 }
1476 } 1476 }
1477 else if ( msg == "reset()" ) { 1477 else if ( msg == "reset()" ) {
1478 if ( type() != GuiServer ) 1478 if ( type() != GuiServer )
1479 reset(); 1479 reset();
1480 } 1480 }
1481 else if ( msg == "setCurrentRotation(int)" ) { 1481 else if ( msg == "setCurrentRotation(int)" ) {
1482 int r; 1482 int r;
1483 stream >> r; 1483 stream >> r;
1484 setCurrentRotation( r ); 1484 setCurrentRotation( r );
1485 } 1485 }
1486 else if ( msg == "shutdown()" ) { 1486 else if ( msg == "shutdown()" ) {
1487 if ( type() == GuiServer ) 1487 if ( type() == GuiServer )
1488 shutdown(); 1488 shutdown();
1489 } 1489 }
1490 else if ( msg == "quit()" ) { 1490 else if ( msg == "quit()" ) {
1491 if ( type() != GuiServer ) 1491 if ( type() != GuiServer )
1492 tryQuit(); 1492 tryQuit();
1493 } 1493 }
1494 else if ( msg == "forceQuit()" ) { 1494 else if ( msg == "forceQuit()" ) {
1495 if ( type() != GuiServer ) 1495 if ( type() != GuiServer )
1496 quit(); 1496 quit();
1497 } 1497 }
1498 else if ( msg == "restart()" ) { 1498 else if ( msg == "restart()" ) {
1499 if ( type() == GuiServer ) 1499 if ( type() == GuiServer )
1500 restart(); 1500 restart();
1501 } 1501 }
1502 else if ( msg == "language(QString)" ) { 1502 else if ( msg == "language(QString)" ) {
1503 if ( type() == GuiServer ) { 1503 if ( type() == GuiServer ) {
1504 QString l; 1504 QString l;
1505 stream >> l; 1505 stream >> l;
1506 QString cl = getenv( "LANG" ); 1506 QString cl = getenv( "LANG" );
1507 if ( cl != l ) { 1507 if ( cl != l ) {
1508 if ( l.isNull() ) 1508 if ( l.isNull() )
1509 unsetenv( "LANG" ); 1509 unsetenv( "LANG" );
1510 else 1510 else
1511 setenv( "LANG", l.latin1(), 1 ); 1511 setenv( "LANG", l.latin1(), 1 );
1512 restart(); 1512 restart();
1513 } 1513 }
1514 } 1514 }
1515 } 1515 }
1516 else if ( msg == "timeChange(QString)" ) { 1516 else if ( msg == "timeChange(QString)" ) {
1517 QString t; 1517 QString t;
1518 stream >> t; 1518 stream >> t;
1519 if ( t.isNull() ) 1519 if ( t.isNull() )
1520 unsetenv( "TZ" ); 1520 unsetenv( "TZ" );
1521 else 1521 else
1522 setenv( "TZ", t.latin1(), 1 ); 1522 setenv( "TZ", t.latin1(), 1 );
1523 // emit the signal so everyone else knows... 1523 // emit the signal so everyone else knows...
1524 emit timeChanged(); 1524 emit timeChanged();
1525 } 1525 }
1526 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1526 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1527 if ( type() == GuiServer ) { 1527 if ( type() == GuiServer ) {
1528 QDateTime when; 1528 QDateTime when;
1529 QCString channel, message; 1529 QCString channel, message;
1530 int data; 1530 int data;
1531 stream >> when >> channel >> message >> data; 1531 stream >> when >> channel >> message >> data;
1532 AlarmServer::addAlarm( when, channel, message, data ); 1532 AlarmServer::addAlarm( when, channel, message, data );
1533 } 1533 }
1534 } 1534 }
1535 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1535 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1536 if ( type() == GuiServer ) { 1536 if ( type() == GuiServer ) {
1537 QDateTime when; 1537 QDateTime when;
1538 QCString channel, message; 1538 QCString channel, message;
1539 int data; 1539 int data;
1540 stream >> when >> channel >> message >> data; 1540 stream >> when >> channel >> message >> data;
1541 AlarmServer::deleteAlarm( when, channel, message, data ); 1541 AlarmServer::deleteAlarm( when, channel, message, data );
1542 } 1542 }
1543 } 1543 }
1544 else if ( msg == "clockChange(bool)" ) { 1544 else if ( msg == "clockChange(bool)" ) {
1545 int tmp; 1545 int tmp;
1546 stream >> tmp; 1546 stream >> tmp;
1547 emit clockChanged( tmp ); 1547 emit clockChanged( tmp );
1548 } 1548 }
1549 else if ( msg == "weekChange(bool)" ) { 1549 else if ( msg == "weekChange(bool)" ) {
1550 int tmp; 1550 int tmp;
1551 stream >> tmp; 1551 stream >> tmp;
1552 emit weekChanged( tmp ); 1552 emit weekChanged( tmp );
1553 } 1553 }
1554 else if ( msg == "setDateFormat(DateFormat)" ) { 1554 else if ( msg == "setDateFormat(DateFormat)" ) {
1555 DateFormat tmp; 1555 DateFormat tmp;
1556 stream >> tmp; 1556 stream >> tmp;
1557 emit dateFormatChanged( tmp ); 1557 emit dateFormatChanged( tmp );
1558 } 1558 }
1559 else if ( msg == "setVolume(int,int)" ) { 1559 else if ( msg == "setVolume(int,int)" ) {
1560 int t, v; 1560 int t, v;
1561 stream >> t >> v; 1561 stream >> t >> v;
1562 setVolume( t, v ); 1562 setVolume( t, v );
1563 emit volumeChanged( muted ); 1563 emit volumeChanged( muted );
1564 } 1564 }
1565 else if ( msg == "volumeChange(bool)" ) { 1565 else if ( msg == "volumeChange(bool)" ) {
1566 stream >> muted; 1566 stream >> muted;
1567 setVolume(); 1567 setVolume();
1568 emit volumeChanged( muted ); 1568 emit volumeChanged( muted );
1569 } 1569 }
1570 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1570 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1571 int t, v; 1571 int t, v;
1572 stream >> t >> v; 1572 stream >> t >> v;
1573 setMic( t, v ); 1573 setMic( t, v );
1574 emit micChanged( micMuted ); 1574 emit micChanged( micMuted );
1575 } 1575 }
1576 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1576 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1577 stream >> micMuted; 1577 stream >> micMuted;
1578 setMic(); 1578 setMic();
1579 emit micChanged( micMuted ); 1579 emit micChanged( micMuted );
1580 } 1580 }
1581 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1581 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1582 int t, v; 1582 int t, v;
1583 stream >> t >> v; 1583 stream >> t >> v;
1584 setBass( t, v ); 1584 setBass( t, v );
1585 } 1585 }
1586 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1586 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1587 setBass(); 1587 setBass();
1588 } 1588 }
1589 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1589 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1590 int t, v; 1590 int t, v;
1591 stream >> t >> v; 1591 stream >> t >> v;
1592 setTreble( t, v ); 1592 setTreble( t, v );
1593 } 1593 }
1594 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1594 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1595 setTreble(); 1595 setTreble();
1596 } else if ( msg == "getMarkedText()" ) { 1596 } else if ( msg == "getMarkedText()" ) {
1597 if ( type() == GuiServer ) { 1597 if ( type() == GuiServer ) {
1598 const ushort unicode = 'C'-'@'; 1598 const ushort unicode = 'C'-'@';
1599 const int scan = Key_C; 1599 const int scan = Key_C;
1600 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); 1600 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );
1601 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); 1601 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );
1602 } 1602 }
1603 } else if ( msg == "newChannel(QString)") { 1603 } else if ( msg == "newChannel(QString)") {
1604 QString myChannel = "QPE/Application/" + d->appName; 1604 QString myChannel = "QPE/Application/" + d->appName;
1605 QString channel; 1605 QString channel;
1606 stream >> channel; 1606 stream >> channel;
1607 if (channel == myChannel) { 1607 if (channel == myChannel) {
1608 processQCopFile(); 1608 processQCopFile();
1609 d->sendQCopQ(); 1609 d->sendQCopQ();
1610 } 1610 }
1611 } 1611 }
1612 1612
1613 1613
1614#endif 1614#endif
1615} 1615}
1616 1616
1617 1617
1618 1618
1619 1619
1620 1620
1621/*! 1621/*!
1622 \internal 1622 \internal
1623*/ 1623*/
1624bool QPEApplication::raiseAppropriateWindow() 1624bool QPEApplication::raiseAppropriateWindow()
1625{ 1625{
1626 bool r=FALSE; 1626 bool r=FALSE;
1627 1627
1628 // 1. Raise the main widget 1628 // 1. Raise the main widget
1629 QWidget *top = d->qpe_main_widget; 1629 QWidget *top = d->qpe_main_widget;
1630 if ( !top ) top = mainWidget(); 1630 if ( !top ) top = mainWidget();
1631 1631
1632 if ( top && d->keep_running ) { 1632 if ( top && d->keep_running ) {
1633 if ( top->isVisible() ) 1633 if ( top->isVisible() )
1634 r = TRUE; 1634 r = TRUE;
1635 else if (d->preloaded) { 1635 else if (d->preloaded) {
1636 // We are preloaded and not visible.. pretend we just started.. 1636 // We are preloaded and not visible.. pretend we just started..
1637#ifndef QT_NO_COP 1637#ifndef QT_NO_COP
1638 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1638 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1639 e << d->appName; 1639 e << d->appName;
1640#endif 1640#endif
1641 } 1641 }
1642 1642
1643 d->show_mx(top,d->nomaximize, d->appName); 1643 d->show_mx(top,d->nomaximize, d->appName);
1644 top->raise(); 1644 top->raise();
1645 } 1645 }
1646 1646
1647 QWidget *topm = activeModalWidget(); 1647 QWidget *topm = activeModalWidget();
1648 1648
1649 // 2. Raise any parentless widgets (except top and topm, as they 1649 // 2. Raise any parentless widgets (except top and topm, as they
1650 // are raised before and after this loop). Order from most 1650 // are raised before and after this loop). Order from most
1651 // recently raised as deepest to least recently as top, so 1651 // recently raised as deepest to least recently as top, so
1652 // that repeated calls cycle through widgets. 1652 // that repeated calls cycle through widgets.
1653 QWidgetList *list = topLevelWidgets(); 1653 QWidgetList *list = topLevelWidgets();
1654 if ( list ) { 1654 if ( list ) {
1655 bool foundlast = FALSE; 1655 bool foundlast = FALSE;
1656 QWidget* topsub = 0; 1656 QWidget* topsub = 0;
1657 if ( d->lastraised ) { 1657 if ( d->lastraised ) {
1658 for (QWidget* w = list->first(); w; w = list->next()) { 1658 for (QWidget* w = list->first(); w; w = list->next()) {
1659 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1659 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1660 if ( w == d->lastraised ) 1660 if ( w == d->lastraised )
1661 foundlast = TRUE; 1661 foundlast = TRUE;
1662 if ( foundlast ) { 1662 if ( foundlast ) {
1663 w->raise(); 1663 w->raise();
1664 topsub = w; 1664 topsub = w;
1665 } 1665 }
1666 } 1666 }
1667 } 1667 }
1668 } 1668 }
1669 for (QWidget* w = list->first(); w; w = list->next()) { 1669 for (QWidget* w = list->first(); w; w = list->next()) {
1670 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1670 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1671 if ( w == d->lastraised ) 1671 if ( w == d->lastraised )
1672 break; 1672 break;
1673 w->raise(); 1673 w->raise();
1674 topsub = w; 1674 topsub = w;
1675 } 1675 }
1676 } 1676 }
1677 d->lastraised = topsub; 1677 d->lastraised = topsub;
1678 delete list; 1678 delete list;
1679 } 1679 }
1680 1680
1681 // 3. Raise the active modal widget. 1681 // 3. Raise the active modal widget.
1682 if ( topm ) { 1682 if ( topm ) {
1683 topm->show(); 1683 topm->show();
1684 topm->raise(); 1684 topm->raise();
1685 // If we haven't already handled the fastAppShowing message 1685 // If we haven't already handled the fastAppShowing message
1686 if (!top && d->preloaded) { 1686 if (!top && d->preloaded) {
1687#ifndef QT_NO_COP 1687#ifndef QT_NO_COP
1688 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1688 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1689 e << d->appName; 1689 e << d->appName;
1690#endif 1690#endif
1691 } 1691 }
1692 r = FALSE; 1692 r = FALSE;
1693 } 1693 }
1694 1694
1695 return r; 1695 return r;
1696} 1696}
1697 1697
1698 1698
1699void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1699void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1700{ 1700{
1701#ifdef Q_WS_QWS 1701#ifdef Q_WS_QWS
1702 1702
1703 if ( msg == "quit()" ) { 1703 if ( msg == "quit()" ) {
1704 tryQuit(); 1704 tryQuit();
1705 } 1705 }
1706 else if ( msg == "quitIfInvisible()" ) { 1706 else if ( msg == "quitIfInvisible()" ) {
1707 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1707 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1708 quit(); 1708 quit();
1709 } 1709 }
1710 else if ( msg == "close()" ) { 1710 else if ( msg == "close()" ) {
1711 hideOrQuit(); 1711 hideOrQuit();
1712 } 1712 }
1713 else if ( msg == "disablePreload()" ) { 1713 else if ( msg == "disablePreload()" ) {
1714 d->preloaded = FALSE; 1714 d->preloaded = FALSE;
1715 d->keep_running = TRUE; 1715 d->keep_running = TRUE;
1716 /* so that quit will quit */ 1716 /* so that quit will quit */
1717 } 1717 }
1718 else if ( msg == "enablePreload()" ) { 1718 else if ( msg == "enablePreload()" ) {
1719 if (d->qpe_main_widget) 1719 if (d->qpe_main_widget)
1720 d->preloaded = TRUE; 1720 d->preloaded = TRUE;
1721 d->keep_running = TRUE; 1721 d->keep_running = TRUE;
1722 /* so next quit won't quit */ 1722 /* so next quit won't quit */
1723 } 1723 }
1724 else if ( msg == "raise()" ) { 1724 else if ( msg == "raise()" ) {
1725 d->keep_running = TRUE; 1725 d->keep_running = TRUE;
1726 d->notbusysent = FALSE; 1726 d->notbusysent = FALSE;
1727 raiseAppropriateWindow(); 1727 raiseAppropriateWindow();
1728 // Tell the system we're still chugging along... 1728 // Tell the system we're still chugging along...
1729 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1729 QCopEnvelope e("QPE/System", "appRaised(QString)");
1730 e << d->appName; 1730 e << d->appName;
1731 } 1731 }
1732 else if ( msg == "flush()" ) { 1732 else if ( msg == "flush()" ) {
1733 emit flush(); 1733 emit flush();
1734 // we need to tell the desktop 1734 // we need to tell the desktop
1735 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1735 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1736 e << d->appName; 1736 e << d->appName;
1737 } 1737 }
1738 else if ( msg == "reload()" ) { 1738 else if ( msg == "reload()" ) {
1739 emit reload(); 1739 emit reload();
1740 } 1740 }
1741 else if ( msg == "setDocument(QString)" ) { 1741 else if ( msg == "setDocument(QString)" ) {
1742 d->keep_running = TRUE; 1742 d->keep_running = TRUE;
1743 QDataStream stream( data, IO_ReadOnly ); 1743 QDataStream stream( data, IO_ReadOnly );
1744 QString doc; 1744 QString doc;
1745 stream >> doc; 1745 stream >> doc;
1746 QWidget *mw = mainWidget(); 1746 QWidget *mw = mainWidget();
1747 if ( !mw ) 1747 if ( !mw )
1748 mw = d->qpe_main_widget; 1748 mw = d->qpe_main_widget;
1749 if ( mw ) 1749 if ( mw )
1750 Global::setDocument( mw, doc ); 1750 Global::setDocument( mw, doc );
1751 1751
1752 } else if ( msg == "QPEProcessQCop()" ) { 1752 } else if ( msg == "QPEProcessQCop()" ) {
1753 processQCopFile(); 1753 processQCopFile();
1754 d->sendQCopQ(); 1754 d->sendQCopQ();
1755 }else 1755 }else
1756 { 1756 {
1757 bool p = d->keep_running; 1757 bool p = d->keep_running;
1758 d->keep_running = FALSE; 1758 d->keep_running = FALSE;
1759 emit appMessage( msg, data); 1759 emit appMessage( msg, data);
1760 if ( d->keep_running ) { 1760 if ( d->keep_running ) {
1761 d->notbusysent = FALSE; 1761 d->notbusysent = FALSE;
1762 raiseAppropriateWindow(); 1762 raiseAppropriateWindow();
1763 if ( !p ) { 1763 if ( !p ) {
1764 // Tell the system we're still chugging along... 1764 // Tell the system we're still chugging along...
1765#ifndef QT_NO_COP 1765#ifndef QT_NO_COP
1766 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1766 QCopEnvelope e("QPE/System", "appRaised(QString)");
1767 e << d->appName; 1767 e << d->appName;
1768#endif 1768#endif
1769 } 1769 }
1770 } 1770 }
1771 if ( p ) 1771 if ( p )
1772 d->keep_running = p; 1772 d->keep_running = p;
1773 } 1773 }
1774#endif 1774#endif
1775} 1775}
1776 1776
1777 1777
1778/*! 1778/*!
1779 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1779 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1780 consider passing TRUE for \a nomaximize rather than the default FALSE. 1780 consider passing TRUE for \a nomaximize rather than the default FALSE.
1781 1781
1782 \sa showMainDocumentWidget() 1782 \sa showMainDocumentWidget()
1783*/ 1783*/
1784void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1784void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1785{ 1785{
1786// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit 1786// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit
1787 d->show(mw, nomaximize ); 1787 d->show(mw, nomaximize );
1788} 1788}
1789 1789
1790/*! 1790/*!
1791 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1791 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1792 consider passing TRUE for \a nomaximize rather than the default FALSE. 1792 consider passing TRUE for \a nomaximize rather than the default FALSE.
1793 1793
1794 This calls designates the application as 1794 This calls designates the application as
1795 a \link docwidget.html document-oriented\endlink application. 1795 a \link docwidget.html document-oriented\endlink application.
1796 1796
1797 The \a mw widget \e must have this slot: setDocument(const QString&). 1797 The \a mw widget \e must have this slot: setDocument(const QString&).
1798 1798
1799 \sa showMainWidget() 1799 \sa showMainWidget()
1800*/ 1800*/
1801void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1801void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1802{ 1802{
1803 if ( mw && argc() == 2 ) 1803 if ( mw && argc() == 2 )
1804 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1804 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1805 1805
1806 1806
1807// setMainWidget(mw); see above 1807// setMainWidget(mw); see above
1808 d->show(mw, nomaximize ); 1808 d->show(mw, nomaximize );
1809} 1809}
1810 1810
1811 1811
1812/*! 1812/*!
1813 If an application is started via a \link qcop.html QCop\endlink 1813 If an application is started via a \link qcop.html QCop\endlink
1814 message, the application will process the \link qcop.html 1814 message, the application will process the \link qcop.html
1815 QCop\endlink message and then quit. If the application calls this 1815 QCop\endlink message and then quit. If the application calls this
1816 function while processing a \link qcop.html QCop\endlink message, 1816 function while processing a \link qcop.html QCop\endlink message,
1817 after processing its outstanding \link qcop.html QCop\endlink 1817 after processing its outstanding \link qcop.html QCop\endlink
1818 messages the application will start 'properly' and show itself. 1818 messages the application will start 'properly' and show itself.
1819 1819
1820 \sa keepRunning() 1820 \sa keepRunning()
1821*/ 1821*/
1822void QPEApplication::setKeepRunning() 1822void QPEApplication::setKeepRunning()
1823{ 1823{
1824 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1824 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1825 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1825 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1826 qpeApp->d->keep_running = TRUE; 1826 qpeApp->d->keep_running = TRUE;
1827 } 1827 }
1828} 1828}
1829 1829
1830/*! 1830/*!
1831 Returns TRUE if the application will quit after processing the 1831 Returns TRUE if the application will quit after processing the
1832 current list of qcop messages; otherwise returns FALSE. 1832 current list of qcop messages; otherwise returns FALSE.
1833 1833
1834 \sa setKeepRunning() 1834 \sa setKeepRunning()
1835*/ 1835*/
1836bool QPEApplication::keepRunning() const 1836bool QPEApplication::keepRunning() const
1837{ 1837{
1838 return d->keep_running; 1838 return d->keep_running;
1839} 1839}
1840 1840
1841/*! 1841/*!
1842 \internal 1842 \internal
1843*/ 1843*/
1844void QPEApplication::internalSetStyle( const QString &style ) 1844void QPEApplication::internalSetStyle( const QString &style )
1845{ 1845{
1846#if QT_VERSION >= 300 1846#if QT_VERSION >= 0x030000
1847 if ( style == "QPE" ) { 1847 if ( style == "QPE" ) {
1848 setStyle( new QPEStyle ); 1848 setStyle( new QPEStyle );
1849 } 1849 }
1850 else { 1850 else {
1851 QStyle *s = QStyleFactory::create( style ); 1851 QStyle *s = QStyleFactory::create( style );
1852 if ( s ) 1852 if ( s )
1853 setStyle( s ); 1853 setStyle( s );
1854 } 1854 }
1855#else 1855#else
1856 if ( style == "Windows" ) { 1856 if ( style == "Windows" ) {
1857 setStyle( new QWindowsStyle ); 1857 setStyle( new QWindowsStyle );
1858 } 1858 }
1859 else if ( style == "QPE" ) { 1859 else if ( style == "QPE" ) {
1860 setStyle( new QPEStyle ); 1860 setStyle( new QPEStyle );
1861 } 1861 }
1862 else if ( style == "Light" ) { 1862 else if ( style == "Light" ) {
1863 setStyle( new LightStyle ); 1863 setStyle( new LightStyle );
1864 } 1864 }
1865#ifndef QT_NO_STYLE_PLATINUM 1865#ifndef QT_NO_STYLE_PLATINUM
1866 else if ( style == "Platinum" ) { 1866 else if ( style == "Platinum" ) {
1867 setStyle( new QPlatinumStyle ); 1867 setStyle( new QPlatinumStyle );
1868 } 1868 }
1869#endif 1869#endif
1870#ifndef QT_NO_STYLE_MOTIF 1870#ifndef QT_NO_STYLE_MOTIF
1871 else if ( style == "Motif" ) { 1871 else if ( style == "Motif" ) {
1872 setStyle( new QMotifStyle ); 1872 setStyle( new QMotifStyle );
1873 } 1873 }
1874#endif 1874#endif
1875#ifndef QT_NO_STYLE_MOTIFPLUS 1875#ifndef QT_NO_STYLE_MOTIFPLUS
1876 else if ( style == "MotifPlus" ) { 1876 else if ( style == "MotifPlus" ) {
1877 setStyle( new QMotifPlusStyle ); 1877 setStyle( new QMotifPlusStyle );
1878 } 1878 }
1879#endif 1879#endif
1880 1880
1881 else { 1881 else {
1882 QStyle *sty = 0; 1882 QStyle *sty = 0;
1883 QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; 1883 QString path = QPEApplication::qpeDir ( ) + "plugins/styles/";
1884 1884
1885#ifdef Q_OS_MACX 1885#ifdef Q_OS_MACX
1886 if ( style. find ( ".dylib" ) > 0 ) 1886 if ( style. find ( ".dylib" ) > 0 )
1887 path += style; 1887 path += style;
1888 else 1888 else
1889 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility 1889 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility
1890#else 1890#else
1891 if ( style. find ( ".so" ) > 0 ) 1891 if ( style. find ( ".so" ) > 0 )
1892 path += style; 1892 path += style;
1893 else 1893 else
1894 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1894 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1895#endif 1895#endif
1896 static QLibrary *lastlib = 0; 1896 static QLibrary *lastlib = 0;
1897 static StyleInterface *lastiface = 0; 1897 static StyleInterface *lastiface = 0;
1898 1898
1899 QLibrary *lib = new QLibrary ( path ); 1899 QLibrary *lib = new QLibrary ( path );
1900 StyleInterface *iface = 0; 1900 StyleInterface *iface = 0;
1901 1901
1902 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1902 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1903 sty = iface-> style ( ); 1903 sty = iface-> style ( );
1904 1904
1905 if ( sty ) { 1905 if ( sty ) {
1906 setStyle ( sty ); 1906 setStyle ( sty );
1907 1907
1908 if ( lastiface ) 1908 if ( lastiface )
1909 lastiface-> release ( ); 1909 lastiface-> release ( );
1910 lastiface = iface; 1910 lastiface = iface;
1911 1911
1912 if ( lastlib ) { 1912 if ( lastlib ) {
1913 lastlib-> unload ( ); 1913 lastlib-> unload ( );
1914 delete lastlib; 1914 delete lastlib;
1915 } 1915 }
1916 lastlib = lib; 1916 lastlib = lib;
1917 } 1917 }
1918 else { 1918 else {
1919 if ( iface ) 1919 if ( iface )
1920 iface-> release ( ); 1920 iface-> release ( );
1921 delete lib; 1921 delete lib;
1922 1922
1923 setStyle ( new LightStyle ( )); 1923 setStyle ( new LightStyle ( ));
1924 } 1924 }
1925 } 1925 }
1926#endif 1926#endif
1927} 1927}
1928 1928
1929/*! 1929/*!
1930 \internal 1930 \internal
1931*/ 1931*/
1932void QPEApplication::prepareForTermination( bool willrestart ) 1932void QPEApplication::prepareForTermination( bool willrestart )
1933{ 1933{
1934 if ( willrestart ) { 1934 if ( willrestart ) {
1935 QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | 1935 QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize |
1936 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1936 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1937 lblWait->setAlignment( QWidget::AlignCenter ); 1937 lblWait->setAlignment( QWidget::AlignCenter );
1938 lblWait->show(); 1938 lblWait->show();
1939 lblWait->showMaximized(); 1939 lblWait->showMaximized();
1940 } 1940 }
1941 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1941 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1942 } 1942 }
1943 processEvents(); // ensure the message goes out. 1943 processEvents(); // ensure the message goes out.
1944} 1944}
1945 1945
1946/*! 1946/*!
1947 \internal 1947 \internal
1948*/ 1948*/
1949void QPEApplication::shutdown() 1949void QPEApplication::shutdown()
1950{ 1950{
1951 // Implement in server's QPEApplication subclass 1951 // Implement in server's QPEApplication subclass
1952} 1952}
1953 1953
1954/*! 1954/*!
1955 \internal 1955 \internal
1956*/ 1956*/
1957void QPEApplication::restart() 1957void QPEApplication::restart()
1958{ 1958{
1959 // Implement in server's QPEApplication subclass 1959 // Implement in server's QPEApplication subclass
1960} 1960}
1961 1961
1962static QPtrDict<void>* stylusDict = 0; 1962static QPtrDict<void>* stylusDict = 0;
1963static void createDict() 1963static void createDict()
1964{ 1964{
1965 if ( !stylusDict ) 1965 if ( !stylusDict )
1966 stylusDict = new QPtrDict<void>; 1966 stylusDict = new QPtrDict<void>;
1967} 1967}
1968 1968
1969/*! 1969/*!
1970 Returns the current StylusMode for widget \a w. 1970 Returns the current StylusMode for widget \a w.
1971 1971
1972 \sa setStylusOperation() StylusMode 1972 \sa setStylusOperation() StylusMode
1973*/ 1973*/
1974QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1974QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1975{ 1975{
1976 if ( stylusDict ) 1976 if ( stylusDict )
1977 return ( StylusMode ) ( int ) stylusDict->find( w ); 1977 return ( StylusMode ) ( int ) stylusDict->find( w );
1978 return LeftOnly; 1978 return LeftOnly;
1979} 1979}
1980 1980
1981/*! 1981/*!
1982 \enum QPEApplication::StylusMode 1982 \enum QPEApplication::StylusMode
1983 1983
1984 \value LeftOnly the stylus only generates LeftButton 1984 \value LeftOnly the stylus only generates LeftButton
1985 events (the default). 1985 events (the default).
1986 \value RightOnHold the stylus generates RightButton events 1986 \value RightOnHold the stylus generates RightButton events
1987 if the user uses the press-and-hold gesture. 1987 if the user uses the press-and-hold gesture.
1988 1988
1989 \sa setStylusOperation() stylusOperation() 1989 \sa setStylusOperation() stylusOperation()
1990*/ 1990*/
1991 1991
1992/*! 1992/*!
1993 Causes widget \a w to receive mouse events according to the stylus 1993 Causes widget \a w to receive mouse events according to the stylus
1994 \a mode. 1994 \a mode.
1995 1995
1996 \sa stylusOperation() StylusMode 1996 \sa stylusOperation() StylusMode
1997*/ 1997*/
1998void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1998void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1999{ 1999{
2000 createDict(); 2000 createDict();
2001 if ( mode == LeftOnly ) { 2001 if ( mode == LeftOnly ) {
2002 stylusDict->remove 2002 stylusDict->remove
2003 ( w ); 2003 ( w );
2004 w->removeEventFilter( qApp ); 2004 w->removeEventFilter( qApp );
2005 } 2005 }
2006 else { 2006 else {
2007 stylusDict->insert( w, ( void* ) mode ); 2007 stylusDict->insert( w, ( void* ) mode );
2008 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 2008 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
2009 w->installEventFilter( qApp ); 2009 w->installEventFilter( qApp );
2010 } 2010 }
2011} 2011}
2012 2012
2013 2013
2014/*! 2014/*!
2015 \reimp 2015 \reimp
2016*/ 2016*/
2017bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 2017bool QPEApplication::eventFilter( QObject *o, QEvent *e )
2018{ 2018{
2019 if ( !o->isWidgetType() ) 2019 if ( !o->isWidgetType() )
2020 return FALSE; 2020 return FALSE;
2021 2021
2022 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 2022 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2023 QMouseEvent * me = ( QMouseEvent* ) e; 2023 QMouseEvent * me = ( QMouseEvent* ) e;
2024 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 2024 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2025 switch (mode) { 2025 switch (mode) {
2026 case RightOnHold: 2026 case RightOnHold:
2027 switch ( me->type() ) { 2027 switch ( me->type() ) {
2028 case QEvent::MouseButtonPress: 2028 case QEvent::MouseButtonPress:
2029 if ( me->button() == LeftButton ) { 2029 if ( me->button() == LeftButton ) {
2030 static long Pref = 500; // #### pref. 2030 static long Pref = 500; // #### pref.
2031 d->presswidget = (QWidget*)o; 2031 d->presswidget = (QWidget*)o;
2032 d->presspos = me->pos(); 2032 d->presspos = me->pos();
2033 d->rightpressed = FALSE; 2033 d->rightpressed = FALSE;
2034#ifdef OPIE_WITHROHFEEDBACK 2034#ifdef OPIE_WITHROHFEEDBACK
2035 if( ! d->RoH ) 2035 if( ! d->RoH )
2036 d->RoH = new Opie::Internal::RoHFeedback; 2036 d->RoH = new Opie::Internal::RoHFeedback;
2037 2037
2038 d->RoH->init( me->globalPos(), d->presswidget ); 2038 d->RoH->init( me->globalPos(), d->presswidget );
2039 Pref = d->RoH->delay(); 2039 Pref = d->RoH->delay();
2040 2040
2041#endif 2041#endif
2042 if (!d->presstimer ) 2042 if (!d->presstimer )
2043 d->presstimer = startTimer( Pref ); // #### pref. 2043 d->presstimer = startTimer( Pref ); // #### pref.
2044 2044
2045 } 2045 }
2046 break; 2046 break;
2047 case QEvent::MouseMove: 2047 case QEvent::MouseMove:
2048 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2048 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2049 killTimer(d->presstimer); 2049 killTimer(d->presstimer);
2050#ifdef OPIE_WITHROHFEEDBACK 2050#ifdef OPIE_WITHROHFEEDBACK
2051 d->RoH->stop(); 2051 d->RoH->stop();
2052#endif 2052#endif
2053 d->presstimer = 0; 2053 d->presstimer = 0;
2054 } 2054 }
2055 break; 2055 break;
2056 case QEvent::MouseButtonRelease: 2056 case QEvent::MouseButtonRelease:
2057 if ( me->button() == LeftButton ) { 2057 if ( me->button() == LeftButton ) {
2058 if ( d->presstimer ) { 2058 if ( d->presstimer ) {
2059 killTimer(d->presstimer); 2059 killTimer(d->presstimer);
2060#ifdef OPIE_WITHROHFEEDBACK 2060#ifdef OPIE_WITHROHFEEDBACK
2061 d->RoH->stop( ); 2061 d->RoH->stop( );
2062#endif 2062#endif
2063 d->presstimer = 0; 2063 d->presstimer = 0;
2064 } 2064 }
2065 if ( d->rightpressed && d->presswidget ) { 2065 if ( d->rightpressed && d->presswidget ) {
2066 printf( "Send ButtonRelease\n" ); 2066 printf( "Send ButtonRelease\n" );
2067 // Right released 2067 // Right released
2068 postEvent( d->presswidget, 2068 postEvent( d->presswidget,
2069 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2069 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2070 RightButton, LeftButton + RightButton ) ); 2070 RightButton, LeftButton + RightButton ) );
2071 // Left released, off-widget 2071 // Left released, off-widget
2072 postEvent( d->presswidget, 2072 postEvent( d->presswidget,
2073 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2073 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2074 LeftButton, LeftButton ) ); 2074 LeftButton, LeftButton ) );
2075 postEvent( d->presswidget, 2075 postEvent( d->presswidget,
2076 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2076 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2077 LeftButton, LeftButton ) ); 2077 LeftButton, LeftButton ) );
2078 d->rightpressed = FALSE; 2078 d->rightpressed = FALSE;
2079 return TRUE; // don't send the real Left release 2079 return TRUE; // don't send the real Left release
2080 } 2080 }
2081 } 2081 }
2082 break; 2082 break;
2083 default: 2083 default:
2084 break; 2084 break;
2085 } 2085 }
2086 break; 2086 break;
2087 default: 2087 default:
2088 ; 2088 ;
2089 } 2089 }
2090 } 2090 }
2091 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2091 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2092 QKeyEvent *ke = (QKeyEvent *)e; 2092 QKeyEvent *ke = (QKeyEvent *)e;
2093 if ( ke->key() == Key_Enter ) { 2093 if ( ke->key() == Key_Enter ) {
2094 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2094 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2095 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2095 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2096 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2096 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2097 return TRUE; 2097 return TRUE;
2098 } 2098 }
2099 } 2099 }
2100 } 2100 }
2101 return FALSE; 2101 return FALSE;
2102} 2102}
2103 2103
2104/*! 2104/*!
2105 \reimp 2105 \reimp
2106*/ 2106*/
2107void QPEApplication::timerEvent( QTimerEvent *e ) 2107void QPEApplication::timerEvent( QTimerEvent *e )
2108{ 2108{
2109 if ( e->timerId() == d->presstimer && d->presswidget ) { 2109 if ( e->timerId() == d->presstimer && d->presswidget ) {
2110 2110
2111 // Right pressed 2111 // Right pressed
2112 postEvent( d->presswidget, 2112 postEvent( d->presswidget,
2113 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2113 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2114 RightButton, LeftButton ) ); 2114 RightButton, LeftButton ) );
2115 killTimer( d->presstimer ); 2115 killTimer( d->presstimer );
2116 d->presstimer = 0; 2116 d->presstimer = 0;
2117 d->rightpressed = TRUE; 2117 d->rightpressed = TRUE;
2118#ifdef OPIE_WITHROHFEEDBACK 2118#ifdef OPIE_WITHROHFEEDBACK
2119 d->RoH->stop(); 2119 d->RoH->stop();
2120#endif 2120#endif
2121 } 2121 }
2122} 2122}
2123 2123
2124void QPEApplication::removeSenderFromStylusDict() 2124void QPEApplication::removeSenderFromStylusDict()
2125{ 2125{
2126 stylusDict->remove 2126 stylusDict->remove
2127 ( ( void* ) sender() ); 2127 ( ( void* ) sender() );
2128 if ( d->presswidget == sender() ) 2128 if ( d->presswidget == sender() )
2129 d->presswidget = 0; 2129 d->presswidget = 0;
2130} 2130}
2131 2131
2132/*! 2132/*!
2133 \internal 2133 \internal
2134*/ 2134*/
2135bool QPEApplication::keyboardGrabbed() const 2135bool QPEApplication::keyboardGrabbed() const
2136{ 2136{
2137 return d->kbgrabbed; 2137 return d->kbgrabbed;
2138} 2138}
2139 2139
2140 2140
2141/*! 2141/*!
2142 Reverses the effect of grabKeyboard(). This is called automatically 2142 Reverses the effect of grabKeyboard(). This is called automatically
2143 on program exit. 2143 on program exit.
2144*/ 2144*/
2145void QPEApplication::ungrabKeyboard() 2145void QPEApplication::ungrabKeyboard()
2146{ 2146{
2147 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2147 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2148} 2148}
2149 2149
2150/*! 2150/*!
2151 Grabs the physical keyboard keys, e.g. the application's launching 2151 Grabs the physical keyboard keys, e.g. the application's launching
2152 keys. Instead of launching applications when these keys are pressed 2152 keys. Instead of launching applications when these keys are pressed
2153 the signals emitted are sent to this application instead. Some games 2153 the signals emitted are sent to this application instead. Some games
2154 programs take over the launch keys in this way to make interaction 2154 programs take over the launch keys in this way to make interaction
2155 easier. 2155 easier.
2156 2156
2157 \sa ungrabKeyboard() 2157 \sa ungrabKeyboard()
2158*/ 2158*/
2159void QPEApplication::grabKeyboard() 2159void QPEApplication::grabKeyboard()
2160{ 2160{
2161 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2161 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2162} 2162}
2163 2163
2164/*! 2164/*!
2165 \reimp 2165 \reimp
2166*/ 2166*/
2167int QPEApplication::exec() 2167int QPEApplication::exec()
2168{ 2168{
2169 d->qcopQok = true; 2169 d->qcopQok = true;
2170#ifndef QT_NO_COP 2170#ifndef QT_NO_COP
2171 d->sendQCopQ(); 2171 d->sendQCopQ();
2172 if ( !d->keep_running ) 2172 if ( !d->keep_running )
2173 processEvents(); // we may have received QCop messages in the meantime. 2173 processEvents(); // we may have received QCop messages in the meantime.
2174#endif 2174#endif
2175 2175
2176 if ( d->keep_running ) 2176 if ( d->keep_running )
2177 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2177 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2178 return QApplication::exec(); 2178 return QApplication::exec();
2179 2179
2180#ifndef QT_NO_COP 2180#ifndef QT_NO_COP
2181 2181
2182 { 2182 {
2183 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2183 QCopEnvelope e( "QPE/System", "closing(QString)" );
2184 e << d->appName; 2184 e << d->appName;
2185 } 2185 }
2186#endif 2186#endif
2187 processEvents(); 2187 processEvents();
2188 return 0; 2188 return 0;
2189} 2189}
2190 2190
2191/*! 2191/*!
2192 \internal 2192 \internal
2193 External request for application to quit. Quits if possible without 2193 External request for application to quit. Quits if possible without
2194 loosing state. 2194 loosing state.
2195*/ 2195*/
2196void QPEApplication::tryQuit() 2196void QPEApplication::tryQuit()
2197{ 2197{
2198 if ( activeModalWidget() ) 2198 if ( activeModalWidget() )
2199 return ; // Inside modal loop or konsole. Too hard to save state. 2199 return ; // Inside modal loop or konsole. Too hard to save state.
2200#ifndef QT_NO_COP 2200#ifndef QT_NO_COP
2201 2201
2202 { 2202 {
2203 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2203 QCopEnvelope e( "QPE/System", "closing(QString)" );
2204 e << d->appName; 2204 e << d->appName;
2205 } 2205 }
2206#endif 2206#endif
2207 if ( d->keep_running ) 2207 if ( d->keep_running )
2208 d->store_widget_rect(d->qpe_main_widget, d->appName); 2208 d->store_widget_rect(d->qpe_main_widget, d->appName);
2209 processEvents(); 2209 processEvents();
2210 2210
2211 quit(); 2211 quit();
2212} 2212}
2213 2213
2214 2214
2215/*! 2215/*!
2216 \internal 2216 \internal
2217 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2217 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2218 hiding the window. If not it means quitting the application. 2218 hiding the window. If not it means quitting the application.
2219 As this is user initiated we don't need to check state. 2219 As this is user initiated we don't need to check state.
2220*/ 2220*/
2221void QPEApplication::hideOrQuit() 2221void QPEApplication::hideOrQuit()
2222{ 2222{
2223 if ( d->keep_running ) 2223 if ( d->keep_running )
2224 d->store_widget_rect(d->qpe_main_widget, d->appName); 2224 d->store_widget_rect(d->qpe_main_widget, d->appName);
2225 processEvents(); 2225 processEvents();
2226 2226
2227 // If we are a preloaded application we don't actually quit, so emit 2227 // If we are a preloaded application we don't actually quit, so emit
2228 // a System message indicating we're quasi-closing. 2228 // a System message indicating we're quasi-closing.
2229 if ( d->preloaded && d->qpe_main_widget ) 2229 if ( d->preloaded && d->qpe_main_widget )
2230#ifndef QT_NO_COP 2230#ifndef QT_NO_COP
2231 2231
2232 { 2232 {
2233 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2233 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2234 e << d->appName; 2234 e << d->appName;
2235 d->qpe_main_widget->hide(); 2235 d->qpe_main_widget->hide();
2236 } 2236 }
2237#endif 2237#endif
2238 else 2238 else
2239 quit(); 2239 quit();
2240} 2240}
2241 2241
2242#if (__GNUC__ > 2 ) 2242#if (__GNUC__ > 2 )
2243extern "C" void __cxa_pure_virtual(); 2243extern "C" void __cxa_pure_virtual();
2244 2244
2245void __cxa_pure_virtual() 2245void __cxa_pure_virtual()
2246{ 2246{
2247 fprintf( stderr, "Pure virtual called\n"); 2247 fprintf( stderr, "Pure virtual called\n");
2248 abort(); 2248 abort();
2249 2249
2250} 2250}
2251 2251
2252#endif 2252#endif
2253 2253
2254 2254
2255#if defined(OPIE_NEW_MALLOC) 2255#if defined(OPIE_NEW_MALLOC)
2256 2256
2257// The libraries with the skiff package (and possibly others) have 2257// The libraries with the skiff package (and possibly others) have
2258// completely useless implementations of builtin new and delete that 2258// completely useless implementations of builtin new and delete that
2259// use about 50% of your CPU. Here we revert to the simple libc 2259// use about 50% of your CPU. Here we revert to the simple libc
2260// functions. 2260// functions.
2261 2261
2262void* operator new[]( size_t size ) 2262void* operator new[]( size_t size )
2263{ 2263{
2264 return malloc( size ); 2264 return malloc( size );
2265} 2265}
2266 2266
2267void* operator new( size_t size ) 2267void* operator new( size_t size )
2268{ 2268{
2269 return malloc( size ); 2269 return malloc( size );
2270} 2270}
2271 2271
2272void operator delete[]( void* p ) 2272void operator delete[]( void* p )
2273{ 2273{
2274 if ( p ) 2274 if ( p )
2275 free( p ); 2275 free( p );
2276} 2276}
2277 2277
2278void operator delete[]( void* p, size_t /*size*/ ) 2278void operator delete[]( void* p, size_t /*size*/ )
2279{ 2279{
2280 if ( p ) 2280 if ( p )
2281 free( p ); 2281 free( p );
2282} 2282}
2283 2283
2284 2284
2285void operator delete( void* p ) 2285void operator delete( void* p )
2286{ 2286{
2287 if ( p ) 2287 if ( p )
2288 free( p ); 2288 free( p );
2289} 2289}
2290 2290
2291void operator delete( void* p, size_t /*size*/ ) 2291void operator delete( void* p, size_t /*size*/ )
2292{ 2292{
2293 if ( p ) 2293 if ( p )
2294 free( p ); 2294 free( p );
2295} 2295}
2296 2296
2297#endif 2297#endif
2298 2298
2299#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2299#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2300#include <qwidgetlist.h> 2300#include <qwidgetlist.h>
2301#ifdef QWS 2301#ifdef QWS
2302#include <qgfx_qws.h> 2302#include <qgfx_qws.h>
2303extern QRect qt_maxWindowRect; 2303extern QRect qt_maxWindowRect;
2304void qt_setMaxWindowRect(const QRect& r ) 2304void qt_setMaxWindowRect(const QRect& r )
2305{ 2305{
2306 qt_maxWindowRect = qt_screen->mapFromDevice( r, 2306 qt_maxWindowRect = qt_screen->mapFromDevice( r,
2307 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 2307 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
2308 // Re-resize any maximized windows 2308 // Re-resize any maximized windows
2309 QWidgetList* l = QApplication::topLevelWidgets(); 2309 QWidgetList* l = QApplication::topLevelWidgets();
2310 if ( l ) { 2310 if ( l ) {
2311 QWidget * w = l->first(); 2311 QWidget * w = l->first();
2312 while ( w ) { 2312 while ( w ) {
2313 if ( w->isVisible() && w->isMaximized() ) { 2313 if ( w->isVisible() && w->isMaximized() ) {
2314 w->showMaximized(); 2314 w->showMaximized();
2315 } 2315 }
2316 w = l->next(); 2316 w = l->next();
2317 } 2317 }
2318 delete l; 2318 delete l;
2319 } 2319 }
2320} 2320}
2321#endif 2321#endif
2322#endif 2322#endif
diff --git a/library/qpestyle.cpp b/library/qpestyle.cpp
index b61ada4..0566f6b 100644
--- a/library/qpestyle.cpp
+++ b/library/qpestyle.cpp
@@ -1,1191 +1,1191 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "qpestyle.h" 21#include "qpestyle.h"
22 22
23 23
24#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 24#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
25 25
26#if QT_VERSION >= 300 26#if QT_VERSION >= 0x030000
27 27
28#include <qdrawutil.h> 28#include <qdrawutil.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30#include <qtabbar.h> 30#include <qtabbar.h>
31 31
32QPEStyle::QPEStyle() 32QPEStyle::QPEStyle()
33{ 33{
34} 34}
35 35
36QPEStyle::~QPEStyle() 36QPEStyle::~QPEStyle()
37{ 37{
38} 38}
39 39
40void QPEStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r, 40void QPEStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r,
41 const QColorGroup &cg, SFlags flags, const QStyleOption &data) const 41 const QColorGroup &cg, SFlags flags, const QStyleOption &data) const
42{ 42{
43 switch ( pe ) { 43 switch ( pe ) {
44 case PE_ButtonTool: 44 case PE_ButtonTool:
45 { 45 {
46 QColorGroup mycg = cg; 46 QColorGroup mycg = cg;
47 if ( flags & Style_On ) { 47 if ( flags & Style_On ) {
48 QBrush fill( cg.mid(), Dense4Pattern ); 48 QBrush fill( cg.mid(), Dense4Pattern );
49 mycg.setBrush( QColorGroup::Button, fill ); 49 mycg.setBrush( QColorGroup::Button, fill );
50 } 50 }
51 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data ); 51 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data );
52 break; 52 break;
53 } 53 }
54 case PE_ButtonCommand: 54 case PE_ButtonCommand:
55 case PE_ButtonDefault: 55 case PE_ButtonDefault:
56 case PE_ButtonBevel: 56 case PE_ButtonBevel:
57 case PE_HeaderSection: 57 case PE_HeaderSection:
58 { 58 {
59 QPen oldPen = p->pen(); 59 QPen oldPen = p->pen();
60 p->fillRect( r.x()+1, r.y()+1, r.width()-2, r.height()-2, cg.brush(QColorGroup::Button) ); 60 p->fillRect( r.x()+1, r.y()+1, r.width()-2, r.height()-2, cg.brush(QColorGroup::Button) );
61 61
62 int x2 = r.right(); 62 int x2 = r.right();
63 int y2 = r.bottom(); 63 int y2 = r.bottom();
64 64
65 if ( flags & (Style_Sunken | Style_Down | Style_On) ) 65 if ( flags & (Style_Sunken | Style_Down | Style_On) )
66 p->setPen( cg.dark() ); 66 p->setPen( cg.dark() );
67 else 67 else
68 p->setPen( cg.light() ); 68 p->setPen( cg.light() );
69 p->drawLine( r.x(), r.y()+1, r.x(), y2-1 ); 69 p->drawLine( r.x(), r.y()+1, r.x(), y2-1 );
70 p->drawLine( r.x()+1, r.y(), x2-1, r.y() ); 70 p->drawLine( r.x()+1, r.y(), x2-1, r.y() );
71 71
72 if ( flags & (Style_Sunken | Style_Down | Style_On) ) 72 if ( flags & (Style_Sunken | Style_Down | Style_On) )
73 p->setPen( cg.light() ); 73 p->setPen( cg.light() );
74 else 74 else
75 p->setPen( cg.dark() ); 75 p->setPen( cg.dark() );
76 p->drawLine( x2, r.y()+1, x2, y2-1 ); 76 p->drawLine( x2, r.y()+1, x2, y2-1 );
77 p->drawLine( r.x()+1, y2, x2-1, y2 ); 77 p->drawLine( r.x()+1, y2, x2-1, y2 );
78 p->setPen( oldPen ); 78 p->setPen( oldPen );
79 break; 79 break;
80 } 80 }
81 case PE_FocusRect: 81 case PE_FocusRect:
82 break; 82 break;
83 case PE_Indicator: 83 case PE_Indicator:
84 { 84 {
85 QColorGroup mycg( cg ); 85 QColorGroup mycg( cg );
86 QBrush fill; 86 QBrush fill;
87 if ( flags & Style_Down ) 87 if ( flags & Style_Down )
88 fill = cg.brush( QColorGroup::Button ); 88 fill = cg.brush( QColorGroup::Button );
89 else 89 else
90 fill = cg.brush( (flags&Style_Enabled) ? QColorGroup::Base : QColorGroup::Background ); 90 fill = cg.brush( (flags&Style_Enabled) ? QColorGroup::Base : QColorGroup::Background );
91 mycg.setBrush( QColorGroup::Button, fill ); 91 mycg.setBrush( QColorGroup::Button, fill );
92 if ( flags&Style_Enabled ) 92 if ( flags&Style_Enabled )
93 flags |= Style_Sunken; 93 flags |= Style_Sunken;
94 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags ); 94 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags );
95 if ( flags & Style_On ) { 95 if ( flags & Style_On ) {
96 QPointArray a( 7*2 ); 96 QPointArray a( 7*2 );
97 int i, xx, yy; 97 int i, xx, yy;
98 xx = r.x()+3; 98 xx = r.x()+3;
99 yy = r.y()+5; 99 yy = r.y()+5;
100 for ( i=0; i<3; i++ ) { 100 for ( i=0; i<3; i++ ) {
101 a.setPoint( 2*i, xx, yy ); 101 a.setPoint( 2*i, xx, yy );
102 a.setPoint( 2*i+1, xx, yy+2 ); 102 a.setPoint( 2*i+1, xx, yy+2 );
103 xx++; yy++; 103 xx++; yy++;
104 } 104 }
105 yy -= 2; 105 yy -= 2;
106 for ( i=3; i<7; i++ ) { 106 for ( i=3; i<7; i++ ) {
107 a.setPoint( 2*i, xx, yy ); 107 a.setPoint( 2*i, xx, yy );
108 a.setPoint( 2*i+1, xx, yy+2 ); 108 a.setPoint( 2*i+1, xx, yy+2 );
109 xx++; yy--; 109 xx++; yy--;
110 } 110 }
111 if ( flags & Style_NoChange ) { 111 if ( flags & Style_NoChange ) {
112 p->setPen( mycg.dark() ); 112 p->setPen( mycg.dark() );
113 } else { 113 } else {
114 p->setPen( mycg.text() ); 114 p->setPen( mycg.text() );
115 } 115 }
116 p->drawLineSegments( a ); 116 p->drawLineSegments( a );
117 } 117 }
118 break; 118 break;
119 } 119 }
120 case PE_ExclusiveIndicator: 120 case PE_ExclusiveIndicator:
121 { 121 {
122 static const QCOORD pts1[] = { // dark lines 122 static const QCOORD pts1[] = { // dark lines
123 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; 123 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
124 static const QCOORD pts4[] = { // white lines 124 static const QCOORD pts4[] = { // white lines
125 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, 125 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
126 11,4, 10,3, 10,2 }; 126 11,4, 10,3, 10,2 };
127 static const QCOORD pts5[] = { // inner fill 127 static const QCOORD pts5[] = { // inner fill
128 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; 128 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
129 129
130 int x, y, w, h; 130 int x, y, w, h;
131 r.rect( &x, &y, &w, &h ); 131 r.rect( &x, &y, &w, &h );
132 p->eraseRect( x, y, w, h ); 132 p->eraseRect( x, y, w, h );
133 QPointArray a( QCOORDARRLEN(pts1), pts1 ); 133 QPointArray a( QCOORDARRLEN(pts1), pts1 );
134 a.translate( x, y ); 134 a.translate( x, y );
135 p->setPen( cg.dark() ); 135 p->setPen( cg.dark() );
136 p->drawPolyline( a ); 136 p->drawPolyline( a );
137 a.setPoints( QCOORDARRLEN(pts4), pts4 ); 137 a.setPoints( QCOORDARRLEN(pts4), pts4 );
138 a.translate( x, y ); 138 a.translate( x, y );
139 p->setPen( cg.light() ); 139 p->setPen( cg.light() );
140 p->drawPolyline( a ); 140 p->drawPolyline( a );
141 a.setPoints( QCOORDARRLEN(pts5), pts5 ); 141 a.setPoints( QCOORDARRLEN(pts5), pts5 );
142 a.translate( x, y ); 142 a.translate( x, y );
143 QColor fillColor = ( flags&Style_Down || !(flags&Style_Enabled) ) ? cg.button() : cg.base(); 143 QColor fillColor = ( flags&Style_Down || !(flags&Style_Enabled) ) ? cg.button() : cg.base();
144 p->setPen( fillColor ); 144 p->setPen( fillColor );
145 p->setBrush( fillColor ) ; 145 p->setBrush( fillColor ) ;
146 p->drawPolygon( a ); 146 p->drawPolygon( a );
147 if ( flags&Style_On ) { 147 if ( flags&Style_On ) {
148 p->setPen( NoPen ); 148 p->setPen( NoPen );
149 p->setBrush( cg.text() ); 149 p->setBrush( cg.text() );
150 p->drawRect( x+5, y+4, 2, 4 ); 150 p->drawRect( x+5, y+4, 2, 4 );
151 p->drawRect( x+4, y+5, 4, 2 ); 151 p->drawRect( x+4, y+5, 4, 2 );
152 } 152 }
153 break; 153 break;
154 } 154 }
155 default: 155 default:
156 QWindowsStyle::drawPrimitive( pe, p, r, cg, flags, data ); 156 QWindowsStyle::drawPrimitive( pe, p, r, cg, flags, data );
157 break; 157 break;
158 } 158 }
159} 159}
160 160
161void QPEStyle::drawControl( ControlElement ce, QPainter *p, 161void QPEStyle::drawControl( ControlElement ce, QPainter *p,
162 const QWidget *widget, const QRect &r, 162 const QWidget *widget, const QRect &r,
163 const QColorGroup &cg, SFlags how, const QStyleOption &data) const 163 const QColorGroup &cg, SFlags how, const QStyleOption &data) const
164{ 164{
165 switch ( ce ) { 165 switch ( ce ) {
166 case CE_PushButton: 166 case CE_PushButton:
167 { 167 {
168 const QPushButton *btn = (QPushButton*)widget; 168 const QPushButton *btn = (QPushButton*)widget;
169 SFlags flags; 169 SFlags flags;
170 flags = Style_Default; 170 flags = Style_Default;
171 if ( btn->isDown() ) 171 if ( btn->isDown() )
172 flags |= Style_Down; 172 flags |= Style_Down;
173 if ( btn->isOn() ) 173 if ( btn->isOn() )
174 flags |= Style_On; 174 flags |= Style_On;
175 if ( btn->isEnabled() ) 175 if ( btn->isEnabled() )
176 flags |= Style_Enabled; 176 flags |= Style_Enabled;
177 if ( btn->isDefault() ) 177 if ( btn->isDefault() )
178 flags |= Style_Default; 178 flags |= Style_Default;
179 if (! btn->isFlat() && !(flags & Style_Down)) 179 if (! btn->isFlat() && !(flags & Style_Down))
180 flags |= Style_Raised; 180 flags |= Style_Raised;
181 p->setPen( cg.foreground() ); 181 p->setPen( cg.foreground() );
182 p->setBrush( QBrush(cg.button(), NoBrush) ); 182 p->setBrush( QBrush(cg.button(), NoBrush) );
183 QColorGroup mycg( cg ); 183 QColorGroup mycg( cg );
184 if ( flags & Style_On ) { 184 if ( flags & Style_On ) {
185 QBrush fill = QBrush( cg.mid(), Dense4Pattern ); 185 QBrush fill = QBrush( cg.mid(), Dense4Pattern );
186 mycg.setBrush( QColorGroup::Button, fill ); 186 mycg.setBrush( QColorGroup::Button, fill );
187 } 187 }
188 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data ); 188 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data );
189 break; 189 break;
190 } 190 }
191 case CE_TabBarTab: 191 case CE_TabBarTab:
192 { 192 {
193 if ( !widget || !widget->parentWidget() ) 193 if ( !widget || !widget->parentWidget() )
194 break; 194 break;
195 195
196 const QTabBar *tb = (const QTabBar *) widget; 196 const QTabBar *tb = (const QTabBar *) widget;
197 bool selected = how & Style_Selected; 197 bool selected = how & Style_Selected;
198 198
199 QRect r2(r); 199 QRect r2(r);
200 if ( tb->shape() == QTabBar::RoundedAbove ) { 200 if ( tb->shape() == QTabBar::RoundedAbove ) {
201 p->setPen( cg.light() ); 201 p->setPen( cg.light() );
202 p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() ); 202 p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
203 if ( r2.left() == 0 ) 203 if ( r2.left() == 0 )
204 p->drawPoint( tb->rect().bottomLeft() ); 204 p->drawPoint( tb->rect().bottomLeft() );
205 else { 205 else {
206 p->setPen( cg.light() ); 206 p->setPen( cg.light() );
207 p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() ); 207 p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
208 } 208 }
209 209
210 if ( selected ) { 210 if ( selected ) {
211 p->setPen( cg.background() ); 211 p->setPen( cg.background() );
212 p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 ); 212 p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 );
213 p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-2), 213 p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-2),
214 cg.brush( QColorGroup::Background )); 214 cg.brush( QColorGroup::Background ));
215 } else { 215 } else {
216 r2.setRect( r2.left() + 2, r2.top() + 2, 216 r2.setRect( r2.left() + 2, r2.top() + 2,
217 r2.width() - 4, r2.height() - 2 ); 217 r2.width() - 4, r2.height() - 2 );
218 p->setPen( cg.button() ); 218 p->setPen( cg.button() );
219 p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 ); 219 p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 );
220 p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-3), 220 p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-3),
221 cg.brush( QColorGroup::Button )); 221 cg.brush( QColorGroup::Button ));
222 222
223 //do shading; will not work for pixmap brushes 223 //do shading; will not work for pixmap brushes
224 QColor bg = cg.button(); 224 QColor bg = cg.button();
225 // int h,s,v; 225 // int h,s,v;
226 // bg.hsv( &h, &s, &v ); 226 // bg.hsv( &h, &s, &v );
227 int n = r2.height()/2; 227 int n = r2.height()/2;
228 int dark = 100; 228 int dark = 100;
229 for ( int i = 1; i < n; i++ ) { 229 for ( int i = 1; i < n; i++ ) {
230 dark = (dark * (100+(i*15)/n) )/100; 230 dark = (dark * (100+(i*15)/n) )/100;
231 p->setPen( bg.dark( dark ) ); 231 p->setPen( bg.dark( dark ) );
232 int y = r2.bottom()-n+i; 232 int y = r2.bottom()-n+i;
233 int x1 = r2.left()+1; 233 int x1 = r2.left()+1;
234 int x2 = r2.right()-1; 234 int x2 = r2.right()-1;
235 p->drawLine( x1, y, x2, y ); 235 p->drawLine( x1, y, x2, y );
236 } 236 }
237 } 237 }
238 238
239 p->setPen( cg.light() ); 239 p->setPen( cg.light() );
240 p->drawLine( r2.left(), r2.bottom()-1, r2.left(), r2.top() + 2 ); 240 p->drawLine( r2.left(), r2.bottom()-1, r2.left(), r2.top() + 2 );
241 p->drawPoint( r2.left()+1, r2.top() + 1 ); 241 p->drawPoint( r2.left()+1, r2.top() + 1 );
242 p->drawLine( r2.left()+2, r2.top(), 242 p->drawLine( r2.left()+2, r2.top(),
243 r2.right() - 2, r2.top() ); 243 r2.right() - 2, r2.top() );
244 244
245 p->setPen( cg.dark() ); 245 p->setPen( cg.dark() );
246 p->drawPoint( r2.right() - 1, r2.top() + 1 ); 246 p->drawPoint( r2.right() - 1, r2.top() + 1 );
247 p->drawLine( r2.right(), r2.top() + 2, r2.right(), r2.bottom() - 1); 247 p->drawLine( r2.right(), r2.top() + 2, r2.right(), r2.bottom() - 1);
248 } else if ( tb->shape() == QTabBar::RoundedBelow ) { 248 } else if ( tb->shape() == QTabBar::RoundedBelow ) {
249 if ( selected ) { 249 if ( selected ) {
250 p->setPen( cg.background() ); 250 p->setPen( cg.background() );
251 p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 ); 251 p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 );
252 p->fillRect( QRect( r2.left()+1, r2.top(), r2.width()-2, r2.height()-2), 252 p->fillRect( QRect( r2.left()+1, r2.top(), r2.width()-2, r2.height()-2),
253 tb->palette().normal().brush( QColorGroup::Background )); 253 tb->palette().normal().brush( QColorGroup::Background ));
254 } else { 254 } else {
255 p->setPen( cg.dark() ); 255 p->setPen( cg.dark() );
256 p->drawLine( r2.left(), r2.top(), 256 p->drawLine( r2.left(), r2.top(),
257 r2.right(), r2.top() ); 257 r2.right(), r2.top() );
258 r2.setRect( r2.left() + 2, r2.top(), 258 r2.setRect( r2.left() + 2, r2.top(),
259 r2.width() - 4, r2.height() - 2 ); 259 r2.width() - 4, r2.height() - 2 );
260 p->setPen( cg.button() ); 260 p->setPen( cg.button() );
261 p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 ); 261 p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 );
262 p->fillRect( QRect( r2.left()+1, r2.top()+1, r2.width()-2, r2.height()-3), 262 p->fillRect( QRect( r2.left()+1, r2.top()+1, r2.width()-2, r2.height()-3),
263 tb->palette().normal().brush( QColorGroup::Button )); 263 tb->palette().normal().brush( QColorGroup::Button ));
264 } 264 }
265 265
266 p->setPen( cg.dark() ); 266 p->setPen( cg.dark() );
267 p->drawLine( r2.right(), r2.top(), 267 p->drawLine( r2.right(), r2.top(),
268 r2.right(), r2.bottom() - 2 ); 268 r2.right(), r2.bottom() - 2 );
269 p->drawPoint( r2.right() - 1, r2.bottom() - 1 ); 269 p->drawPoint( r2.right() - 1, r2.bottom() - 1 );
270 p->drawLine( r2.right() - 2, r2.bottom(), 270 p->drawLine( r2.right() - 2, r2.bottom(),
271 r2.left() + 2, r2.bottom() ); 271 r2.left() + 2, r2.bottom() );
272 272
273 p->setPen( cg.light() ); 273 p->setPen( cg.light() );
274 p->drawLine( r2.left(), r2.top()+1, 274 p->drawLine( r2.left(), r2.top()+1,
275 r2.left(), r2.bottom() - 2 ); 275 r2.left(), r2.bottom() - 2 );
276 p->drawPoint( r2.left() + 1, r2.bottom() - 1 ); 276 p->drawPoint( r2.left() + 1, r2.bottom() - 1 );
277 if ( r2.left() == 0 ) 277 if ( r2.left() == 0 )
278 p->drawPoint( tb->rect().topLeft() ); 278 p->drawPoint( tb->rect().topLeft() );
279 279
280 } else { 280 } else {
281 QCommonStyle::drawControl( ce, p, widget, r, cg, how, data ); 281 QCommonStyle::drawControl( ce, p, widget, r, cg, how, data );
282 } 282 }
283 break; 283 break;
284 } 284 }
285 default: 285 default:
286 QWindowsStyle::drawControl( ce, p, widget, r, cg, how, data ); 286 QWindowsStyle::drawControl( ce, p, widget, r, cg, how, data );
287 break; 287 break;
288 } 288 }
289} 289}
290 290
291void QPEStyle::drawComplexControl( ComplexControl control, QPainter *p, 291void QPEStyle::drawComplexControl( ComplexControl control, QPainter *p,
292 const QWidget *widget, const QRect &r, 292 const QWidget *widget, const QRect &r,
293 const QColorGroup &cg, SFlags how, 293 const QColorGroup &cg, SFlags how,
294 SCFlags sub, SCFlags subActive, const QStyleOption &data) const 294 SCFlags sub, SCFlags subActive, const QStyleOption &data) const
295{ 295{
296 switch ( control ) { 296 switch ( control ) {
297 case CC_ComboBox: 297 case CC_ComboBox:
298 if ( sub & SC_ComboBoxArrow ) { 298 if ( sub & SC_ComboBoxArrow ) {
299 SFlags flags = Style_Default; 299 SFlags flags = Style_Default;
300 300
301 drawPrimitive( PE_ButtonBevel, p, r, cg, flags, data ); 301 drawPrimitive( PE_ButtonBevel, p, r, cg, flags, data );
302 302
303 QRect ar = 303 QRect ar =
304 QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget, 304 QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
305 SC_ComboBoxArrow ), widget ); 305 SC_ComboBoxArrow ), widget );
306 306
307 if ( subActive == SC_ComboBoxArrow ) { 307 if ( subActive == SC_ComboBoxArrow ) {
308 p->setPen( cg.dark() ); 308 p->setPen( cg.dark() );
309 p->setBrush( cg.brush( QColorGroup::Button ) ); 309 p->setBrush( cg.brush( QColorGroup::Button ) );
310 p->drawRect( ar ); 310 p->drawRect( ar );
311 } 311 }
312 312
313 ar.addCoords( 2, 2, -2, -2 ); 313 ar.addCoords( 2, 2, -2, -2 );
314 if ( widget->isEnabled() ) 314 if ( widget->isEnabled() )
315 flags |= Style_Enabled; 315 flags |= Style_Enabled;
316 316
317 if ( subActive & Style_Sunken ) { 317 if ( subActive & Style_Sunken ) {
318 flags |= Style_Sunken; 318 flags |= Style_Sunken;
319 } 319 }
320 drawPrimitive( PE_ArrowDown, p, ar, cg, flags ); 320 drawPrimitive( PE_ArrowDown, p, ar, cg, flags );
321 } 321 }
322 322
323 if ( sub & SC_ComboBoxEditField ) { 323 if ( sub & SC_ComboBoxEditField ) {
324 const QComboBox * cb = (const QComboBox *) widget; 324 const QComboBox * cb = (const QComboBox *) widget;
325 QRect re = 325 QRect re =
326 QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget, 326 QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
327 SC_ComboBoxEditField ), widget ); 327 SC_ComboBoxEditField ), widget );
328 if ( cb->hasFocus() && !cb->editable() ) 328 if ( cb->hasFocus() && !cb->editable() )
329 p->fillRect( re.x(), re.y(), re.width(), re.height(), 329 p->fillRect( re.x(), re.y(), re.width(), re.height(),
330 cg.brush( QColorGroup::Highlight ) ); 330 cg.brush( QColorGroup::Highlight ) );
331 331
332 if ( cb->hasFocus() ) { 332 if ( cb->hasFocus() ) {
333 p->setPen( cg.highlightedText() ); 333 p->setPen( cg.highlightedText() );
334 p->setBackgroundColor( cg.highlight() ); 334 p->setBackgroundColor( cg.highlight() );
335 335
336 } else { 336 } else {
337 p->setPen( cg.text() ); 337 p->setPen( cg.text() );
338 p->setBackgroundColor( cg.background() ); 338 p->setBackgroundColor( cg.background() );
339 } 339 }
340 340
341 if ( cb->hasFocus() && !cb->editable() ) { 341 if ( cb->hasFocus() && !cb->editable() ) {
342 QRect re = 342 QRect re =
343 QStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), widget ); 343 QStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), widget );
344 drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, QStyleOption(cg.highlight())); 344 drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, QStyleOption(cg.highlight()));
345 } 345 }
346 } 346 }
347 break; 347 break;
348 default: 348 default:
349 QWindowsStyle::drawComplexControl( control, p, widget, r, cg, how, 349 QWindowsStyle::drawComplexControl( control, p, widget, r, cg, how,
350 sub, subActive, data ); 350 sub, subActive, data );
351 break; 351 break;
352 } 352 }
353} 353}
354 354
355int QPEStyle::pixelMetric( PixelMetric metric, const QWidget *widget ) const 355int QPEStyle::pixelMetric( PixelMetric metric, const QWidget *widget ) const
356{ 356{
357 int ret; 357 int ret;
358 switch( metric ) { 358 switch( metric ) {
359 case PM_ButtonMargin: 359 case PM_ButtonMargin:
360 ret = 2; 360 ret = 2;
361 break; 361 break;
362 case PM_DefaultFrameWidth: 362 case PM_DefaultFrameWidth:
363 ret = 1; 363 ret = 1;
364 break; 364 break;
365 case PM_ButtonDefaultIndicator: 365 case PM_ButtonDefaultIndicator:
366 ret = 2; 366 ret = 2;
367 break; 367 break;
368 case PM_ButtonShiftHorizontal: 368 case PM_ButtonShiftHorizontal:
369 case PM_ButtonShiftVertical: 369 case PM_ButtonShiftVertical:
370 ret = -1; 370 ret = -1;
371 break; 371 break;
372 case PM_IndicatorWidth: 372 case PM_IndicatorWidth:
373 ret = 15; 373 ret = 15;
374 break; 374 break;
375 case PM_IndicatorHeight: 375 case PM_IndicatorHeight:
376 ret = 13; 376 ret = 13;
377 break; 377 break;
378 case PM_ExclusiveIndicatorHeight: 378 case PM_ExclusiveIndicatorHeight:
379 case PM_ExclusiveIndicatorWidth: 379 case PM_ExclusiveIndicatorWidth:
380 ret = 15; 380 ret = 15;
381 break; 381 break;
382 case PM_ScrollBarExtent: 382 case PM_ScrollBarExtent:
383 ret = 13; 383 ret = 13;
384 break; 384 break;
385 case PM_SliderLength: 385 case PM_SliderLength:
386 ret = 12; 386 ret = 12;
387 break; 387 break;
388 default: 388 default:
389 ret = QWindowsStyle::pixelMetric( metric, widget ); 389 ret = QWindowsStyle::pixelMetric( metric, widget );
390 break; 390 break;
391 } 391 }
392 return ret; 392 return ret;
393} 393}
394 394
395QSize QPEStyle::sizeFromContents( ContentsType contents, const QWidget *widget, 395QSize QPEStyle::sizeFromContents( ContentsType contents, const QWidget *widget,
396 const QSize &contentsSize, const QStyleOption &data) const 396 const QSize &contentsSize, const QStyleOption &data) const
397{ 397{
398 QSize sz(contentsSize); 398 QSize sz(contentsSize);
399 399
400 switch ( contents ) { 400 switch ( contents ) {
401 case CT_PopupMenuItem: 401 case CT_PopupMenuItem:
402 { 402 {
403 if ( !widget || data.isDefault() ) 403 if ( !widget || data.isDefault() )
404 break; 404 break;
405 sz = QWindowsStyle::sizeFromContents( contents, widget, contentsSize, data ); 405 sz = QWindowsStyle::sizeFromContents( contents, widget, contentsSize, data );
406 sz = QSize( sz.width(), sz.height()-2 ); 406 sz = QSize( sz.width(), sz.height()-2 );
407 break; 407 break;
408 } 408 }
409 default: 409 default:
410 sz = QWindowsStyle::sizeFromContents( contents, widget, contentsSize, data ); 410 sz = QWindowsStyle::sizeFromContents( contents, widget, contentsSize, data );
411 break; 411 break;
412 } 412 }
413 413
414 return sz; 414 return sz;
415} 415}
416 416
417#else 417#else
418 418
419#include <qfontmetrics.h> 419#include <qfontmetrics.h>
420#include <qpalette.h> 420#include <qpalette.h>
421#include <qdrawutil.h> 421#include <qdrawutil.h>
422#include <qscrollbar.h> 422#include <qscrollbar.h>
423#include <qbutton.h> 423#include <qbutton.h>
424#include <qframe.h> 424#include <qframe.h>
425#include <qtabbar.h> 425#include <qtabbar.h>
426 426
427#define INCLUDE_MENUITEM_DEF 427#define INCLUDE_MENUITEM_DEF
428#include <qmenudata.h> 428#include <qmenudata.h>
429 429
430QPEStyle::QPEStyle() 430QPEStyle::QPEStyle()
431{ 431{
432#if QT_VERSION < 300 432#if QT_VERSION < 0x030000
433 setButtonMargin(buttonMargin()); 433 setButtonMargin(buttonMargin());
434 setScrollBarExtent(scrollBarExtent().width(),scrollBarExtent().height()); 434 setScrollBarExtent(scrollBarExtent().width(),scrollBarExtent().height());
435#endif 435#endif
436} 436}
437 437
438QPEStyle::~QPEStyle() 438QPEStyle::~QPEStyle()
439{ 439{
440} 440}
441 441
442int QPEStyle::buttonMargin() const 442int QPEStyle::buttonMargin() const
443{ 443{
444 return 2; 444 return 2;
445} 445}
446 446
447QSize QPEStyle::scrollBarExtent() const 447QSize QPEStyle::scrollBarExtent() const
448{ 448{
449 return QSize(13,13); 449 return QSize(13,13);
450} 450}
451 451
452void QPEStyle::polish ( QPalette & ) 452void QPEStyle::polish ( QPalette & )
453{ 453{
454} 454}
455 455
456void QPEStyle::polish( QWidget *w ) 456void QPEStyle::polish( QWidget *w )
457{ 457{
458 if ( w->inherits( "QListBox" ) || 458 if ( w->inherits( "QListBox" ) ||
459 w->inherits( "QListView" ) || 459 w->inherits( "QListView" ) ||
460 w->inherits( "QPopupMenu" ) || 460 w->inherits( "QPopupMenu" ) ||
461 w->inherits( "QSpinBox" ) ) { 461 w->inherits( "QSpinBox" ) ) {
462 QFrame *f = (QFrame *)w; 462 QFrame *f = (QFrame *)w;
463 f->setFrameShape( QFrame::StyledPanel ); 463 f->setFrameShape( QFrame::StyledPanel );
464 f->setLineWidth( 1 ); 464 f->setLineWidth( 1 );
465 } 465 }
466} 466}
467 467
468void QPEStyle::unPolish( QWidget *w ) 468void QPEStyle::unPolish( QWidget *w )
469{ 469{
470 if ( w->inherits( "QListBox" ) || 470 if ( w->inherits( "QListBox" ) ||
471 w->inherits( "QListView" ) || 471 w->inherits( "QListView" ) ||
472 w->inherits( "QPopupMenu" ) || 472 w->inherits( "QPopupMenu" ) ||
473 w->inherits( "QSpinBox" ) ) { 473 w->inherits( "QSpinBox" ) ) {
474 QFrame *f = (QFrame *)w; 474 QFrame *f = (QFrame *)w;
475 f->setFrameShape( QFrame::StyledPanel ); 475 f->setFrameShape( QFrame::StyledPanel );
476 f->setLineWidth( 2 ); 476 f->setLineWidth( 2 );
477 } 477 }
478} 478}
479 479
480int QPEStyle::defaultFrameWidth() const 480int QPEStyle::defaultFrameWidth() const
481{ 481{
482 return 1; 482 return 1;
483} 483}
484 484
485void QPEStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, 485void QPEStyle::drawPanel ( QPainter * p, int x, int y, int w, int h,
486 const QColorGroup &g, bool sunken, int lineWidth, const QBrush * fill ) 486 const QColorGroup &g, bool sunken, int lineWidth, const QBrush * fill )
487{ 487{
488 qDrawShadePanel( p, QRect(x, y, w, h), g, sunken, lineWidth, fill ); 488 qDrawShadePanel( p, QRect(x, y, w, h), g, sunken, lineWidth, fill );
489} 489}
490 490
491void QPEStyle::drawButton( QPainter *p, int x, int y, int w, int h, 491void QPEStyle::drawButton( QPainter *p, int x, int y, int w, int h,
492 const QColorGroup &g, bool sunken, const QBrush* fill ) 492 const QColorGroup &g, bool sunken, const QBrush* fill )
493{ 493{
494 QPen oldPen = p->pen(); 494 QPen oldPen = p->pen();
495 if ( sunken ) 495 if ( sunken )
496 p->setPen( g.dark() ); 496 p->setPen( g.dark() );
497 else 497 else
498 p->setPen( g.light() ); 498 p->setPen( g.light() );
499 499
500 int x2 = x+w-1; 500 int x2 = x+w-1;
501 int y2 = y+h-1; 501 int y2 = y+h-1;
502 502
503 p->drawLine( x, y, x, y2 ); 503 p->drawLine( x, y, x, y2 );
504 p->drawLine( x, y, x2, y ); 504 p->drawLine( x, y, x2, y );
505 505
506 if ( sunken ) 506 if ( sunken )
507 p->setPen( g.light() ); 507 p->setPen( g.light() );
508 else 508 else
509 p->setPen( g.dark() ); 509 p->setPen( g.dark() );
510 510
511 p->drawLine( x2, y, x2, y2 ); 511 p->drawLine( x2, y, x2, y2 );
512 p->drawLine( x, y2, x2, y2 ); 512 p->drawLine( x, y2, x2, y2 );
513 p->setPen( oldPen ); 513 p->setPen( oldPen );
514 514
515 p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) ); 515 p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) );
516} 516}
517 517
518void QPEStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h ) 518void QPEStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h )
519{ 519{
520 p->fillRect( x, y, w, h, color1 ); 520 p->fillRect( x, y, w, h, color1 );
521} 521}
522 522
523void QPEStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, 523void QPEStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
524 const QColorGroup &g, bool sunken, const QBrush* fill ) 524 const QColorGroup &g, bool sunken, const QBrush* fill )
525{ 525{
526 drawButton( p, x, y, w, h, g, sunken, fill ); 526 drawButton( p, x, y, w, h, g, sunken, fill );
527} 527}
528 528
529QRect QPEStyle::comboButtonRect( int x, int y, int w, int h) 529QRect QPEStyle::comboButtonRect( int x, int y, int w, int h)
530{ 530{
531 return QRect(x+1, y+1, w-2-14, h-2); 531 return QRect(x+1, y+1, w-2-14, h-2);
532} 532}
533 533
534 534
535QRect QPEStyle::comboButtonFocusRect( int x, int y, int w, int h) 535QRect QPEStyle::comboButtonFocusRect( int x, int y, int w, int h)
536{ 536{
537 return QRect(x+2, y+2, w-4-14, h-4); 537 return QRect(x+2, y+2, w-4-14, h-4);
538} 538}
539 539
540void QPEStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, 540void QPEStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
541 const QColorGroup &g, bool sunken, 541 const QColorGroup &g, bool sunken,
542 bool /*editable*/, 542 bool /*editable*/,
543 bool enabled, 543 bool enabled,
544 const QBrush *fill ) 544 const QBrush *fill )
545{ 545{
546 drawBevelButton( p, x, y, w, h, g, FALSE, fill ); 546 drawBevelButton( p, x, y, w, h, g, FALSE, fill );
547 drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill ); 547 drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill );
548 drawArrow( p, QStyle::DownArrow, sunken, 548 drawArrow( p, QStyle::DownArrow, sunken,
549 x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled, 549 x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled,
550 &g.brush( QColorGroup::Button ) ); 550 &g.brush( QColorGroup::Button ) );
551 551
552} 552}
553 553
554 554
555void QPEStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, 555void QPEStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w,
556 int h, const QColorGroup & g, bool on, bool down, bool enabled ) 556 int h, const QColorGroup & g, bool on, bool down, bool enabled )
557{ 557{
558 static const QCOORD pts1[] = { // dark lines 558 static const QCOORD pts1[] = { // dark lines
559 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; 559 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
560 static const QCOORD pts4[] = { // white lines 560 static const QCOORD pts4[] = { // white lines
561 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, 561 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
562 11,4, 10,3, 10,2 }; 562 11,4, 10,3, 10,2 };
563 static const QCOORD pts5[] = { // inner fill 563 static const QCOORD pts5[] = { // inner fill
564 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; 564 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
565 565
566 p->eraseRect( x, y, w, h ); 566 p->eraseRect( x, y, w, h );
567 QPointArray a( QCOORDARRLEN(pts1), pts1 ); 567 QPointArray a( QCOORDARRLEN(pts1), pts1 );
568 a.translate( x, y ); 568 a.translate( x, y );
569 p->setPen( g.dark() ); 569 p->setPen( g.dark() );
570 p->drawPolyline( a ); 570 p->drawPolyline( a );
571 a.setPoints( QCOORDARRLEN(pts4), pts4 ); 571 a.setPoints( QCOORDARRLEN(pts4), pts4 );
572 a.translate( x, y ); 572 a.translate( x, y );
573 p->setPen( g.light() ); 573 p->setPen( g.light() );
574 p->drawPolyline( a ); 574 p->drawPolyline( a );
575 a.setPoints( QCOORDARRLEN(pts5), pts5 ); 575 a.setPoints( QCOORDARRLEN(pts5), pts5 );
576 a.translate( x, y ); 576 a.translate( x, y );
577 QColor fillColor = ( down || !enabled ) ? g.button() : g.base(); 577 QColor fillColor = ( down || !enabled ) ? g.button() : g.base();
578 p->setPen( fillColor ); 578 p->setPen( fillColor );
579 p->setBrush( fillColor ) ; 579 p->setBrush( fillColor ) ;
580 p->drawPolygon( a ); 580 p->drawPolygon( a );
581 if ( on ) { 581 if ( on ) {
582 p->setPen( NoPen ); 582 p->setPen( NoPen );
583 p->setBrush( g.text() ); 583 p->setBrush( g.text() );
584 p->drawRect( x+5, y+4, 2, 4 ); 584 p->drawRect( x+5, y+4, 2, 4 );
585 p->drawRect( x+4, y+5, 4, 2 ); 585 p->drawRect( x+4, y+5, 4, 2 );
586 } 586 }
587} 587}
588 588
589void QPEStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h, 589void QPEStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h,
590 const QColorGroup & g, int state, bool down, bool enabled ) 590 const QColorGroup & g, int state, bool down, bool enabled )
591{ 591{
592 592
593 QBrush fill; 593 QBrush fill;
594 if ( state == QButton::NoChange ) { 594 if ( state == QButton::NoChange ) {
595 QBrush b = p->brush(); 595 QBrush b = p->brush();
596 QColor c = p->backgroundColor(); 596 QColor c = p->backgroundColor();
597 p->setBackgroundMode( TransparentMode ); 597 p->setBackgroundMode( TransparentMode );
598 p->setBackgroundColor( green ); 598 p->setBackgroundColor( green );
599 fill = QBrush(g.base(), Dense4Pattern); 599 fill = QBrush(g.base(), Dense4Pattern);
600 p->setBackgroundColor( c ); 600 p->setBackgroundColor( c );
601 p->setBrush( b ); 601 p->setBrush( b );
602 } else if ( down ) 602 } else if ( down )
603 fill = g.brush( QColorGroup::Button ); 603 fill = g.brush( QColorGroup::Button );
604 else 604 else
605 fill = g.brush( enabled ? QColorGroup::Base : QColorGroup::Background ); 605 fill = g.brush( enabled ? QColorGroup::Base : QColorGroup::Background );
606 drawPanel( p, x, y, w, h, g, TRUE, 1, &fill ); 606 drawPanel( p, x, y, w, h, g, TRUE, 1, &fill );
607 if ( state != QButton::Off ) { 607 if ( state != QButton::Off ) {
608 QPointArray a( 7*2 ); 608 QPointArray a( 7*2 );
609 int i, xx, yy; 609 int i, xx, yy;
610 xx = x+3; 610 xx = x+3;
611 yy = y+5; 611 yy = y+5;
612 for ( i=0; i<3; i++ ) { 612 for ( i=0; i<3; i++ ) {
613 a.setPoint( 2*i, xx, yy ); 613 a.setPoint( 2*i, xx, yy );
614 a.setPoint( 2*i+1, xx, yy+2 ); 614 a.setPoint( 2*i+1, xx, yy+2 );
615 xx++; yy++; 615 xx++; yy++;
616 } 616 }
617 yy -= 2; 617 yy -= 2;
618 for ( i=3; i<7; i++ ) { 618 for ( i=3; i<7; i++ ) {
619 a.setPoint( 2*i, xx, yy ); 619 a.setPoint( 2*i, xx, yy );
620 a.setPoint( 2*i+1, xx, yy+2 ); 620 a.setPoint( 2*i+1, xx, yy+2 );
621 xx++; yy--; 621 xx++; yy--;
622 } 622 }
623 if ( state == QButton::NoChange ) { 623 if ( state == QButton::NoChange ) {
624 p->setPen( g.dark() ); 624 p->setPen( g.dark() );
625 } else { 625 } else {
626 p->setPen( g.text() ); 626 p->setPen( g.text() );
627 } 627 }
628 p->drawLineSegments( a ); 628 p->drawLineSegments( a );
629 } 629 }
630} 630}
631 631
632 #define HORIZONTAL(sb->orientation() == QScrollBar::Horizontal) 632 #define HORIZONTAL(sb->orientation() == QScrollBar::Horizontal)
633 #define VERTICAL!HORIZONTAL 633 #define VERTICAL!HORIZONTAL
634 #define MOTIF_BORDER2 634 #define MOTIF_BORDER2
635 #define SLIDER_MIN9 // ### motif says 6 but that's too small 635 #define SLIDER_MIN9 // ### motif says 6 but that's too small
636 636
637/*! \reimp */ 637/*! \reimp */
638 638
639void QPEStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int& buttonDim ) 639void QPEStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int& buttonDim )
640{ 640{
641 int maxLength; 641 int maxLength;
642 int length = HORIZONTAL ? sb->width() : sb->height(); 642 int length = HORIZONTAL ? sb->width() : sb->height();
643 int extent = HORIZONTAL ? sb->height() : sb->width(); 643 int extent = HORIZONTAL ? sb->height() : sb->width();
644 644
645 if ( length > (extent - 1)*2 ) 645 if ( length > (extent - 1)*2 )
646 buttonDim = extent; 646 buttonDim = extent;
647 else 647 else
648 buttonDim = length/2 - 1; 648 buttonDim = length/2 - 1;
649 649
650 sliderMin = 0; 650 sliderMin = 0;
651 maxLength = length - buttonDim*2; 651 maxLength = length - buttonDim*2;
652 652
653 if ( sb->maxValue() == sb->minValue() ) { 653 if ( sb->maxValue() == sb->minValue() ) {
654 sliderLength = maxLength; 654 sliderLength = maxLength;
655 } else { 655 } else {
656 sliderLength = (sb->pageStep()*maxLength)/ 656 sliderLength = (sb->pageStep()*maxLength)/
657 (sb->maxValue()-sb->minValue()+sb->pageStep()); 657 (sb->maxValue()-sb->minValue()+sb->pageStep());
658 uint range = sb->maxValue()-sb->minValue(); 658 uint range = sb->maxValue()-sb->minValue();
659 if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 ) 659 if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 )
660 sliderLength = SLIDER_MIN; 660 sliderLength = SLIDER_MIN;
661 if ( sliderLength > maxLength ) 661 if ( sliderLength > maxLength )
662 sliderLength = maxLength; 662 sliderLength = maxLength;
663 } 663 }
664 664
665 sliderMax = sliderMin + maxLength - sliderLength; 665 sliderMax = sliderMin + maxLength - sliderLength;
666} 666}
667 667
668/*!\reimp 668/*!\reimp
669 */ 669 */
670QStyle::ScrollControl QPEStyle::scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p ) 670QStyle::ScrollControl QPEStyle::scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p )
671{ 671{
672 if ( !sb->rect().contains( p ) ) 672 if ( !sb->rect().contains( p ) )
673 return NoScroll; 673 return NoScroll;
674 int sliderMin, sliderMax, sliderLength, buttonDim, pos; 674 int sliderMin, sliderMax, sliderLength, buttonDim, pos;
675 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 675 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
676 676
677 if (sb->orientation() == QScrollBar::Horizontal) 677 if (sb->orientation() == QScrollBar::Horizontal)
678 pos = p.x(); 678 pos = p.x();
679 else 679 else
680 pos = p.y(); 680 pos = p.y();
681 681
682 if (pos < sliderStart) 682 if (pos < sliderStart)
683 return SubPage; 683 return SubPage;
684 if (pos < sliderStart + sliderLength) 684 if (pos < sliderStart + sliderLength)
685 return Slider; 685 return Slider;
686 if (pos < sliderMax + sliderLength) 686 if (pos < sliderMax + sliderLength)
687 return AddPage; 687 return AddPage;
688 if (pos < sliderMax + sliderLength + buttonDim) 688 if (pos < sliderMax + sliderLength + buttonDim)
689 return SubLine; 689 return SubLine;
690 return AddLine; 690 return AddLine;
691} 691}
692 692
693/*! \reimp */ 693/*! \reimp */
694 694
695void QPEStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl ) 695void QPEStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl )
696{ 696{
697#define ADD_LINE_ACTIVE ( activeControl == AddLine ) 697#define ADD_LINE_ACTIVE ( activeControl == AddLine )
698#define SUB_LINE_ACTIVE ( activeControl == SubLine ) 698#define SUB_LINE_ACTIVE ( activeControl == SubLine )
699 QColorGroup g = sb->colorGroup(); 699 QColorGroup g = sb->colorGroup();
700 700
701 int sliderMin, sliderMax, sliderLength, buttonDim; 701 int sliderMin, sliderMax, sliderLength, buttonDim;
702 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 702 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
703 703
704 if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) 704 if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) )
705 p->fillRect( 0, 0, sb->width(), sb->height(), g.brush( QColorGroup::Mid )); 705 p->fillRect( 0, 0, sb->width(), sb->height(), g.brush( QColorGroup::Mid ));
706 706
707 if (sliderStart > sliderMax) { // sanity check 707 if (sliderStart > sliderMax) { // sanity check
708 sliderStart = sliderMax; 708 sliderStart = sliderMax;
709 } 709 }
710 710
711 int dimB = buttonDim; 711 int dimB = buttonDim;
712 QRect addB; 712 QRect addB;
713 QRect subB; 713 QRect subB;
714 QRect addPageR; 714 QRect addPageR;
715 QRect subPageR; 715 QRect subPageR;
716 QRect sliderR; 716 QRect sliderR;
717 int addX, addY, subX, subY; 717 int addX, addY, subX, subY;
718 int length = HORIZONTAL ? sb->width() : sb->height(); 718 int length = HORIZONTAL ? sb->width() : sb->height();
719 int extent = HORIZONTAL ? sb->height() : sb->width(); 719 int extent = HORIZONTAL ? sb->height() : sb->width();
720 720
721 if ( HORIZONTAL ) { 721 if ( HORIZONTAL ) {
722 subY = addY = ( extent - dimB ) / 2; 722 subY = addY = ( extent - dimB ) / 2;
723 subX = length - dimB - dimB; 723 subX = length - dimB - dimB;
724 addX = length - dimB; 724 addX = length - dimB;
725 } else { 725 } else {
726 subX = addX = ( extent - dimB ) / 2; 726 subX = addX = ( extent - dimB ) / 2;
727 subY = length - dimB - dimB; 727 subY = length - dimB - dimB;
728 addY = length - dimB; 728 addY = length - dimB;
729 } 729 }
730 730
731 int sliderEnd = sliderStart + sliderLength; 731 int sliderEnd = sliderStart + sliderLength;
732 int sliderW = extent; 732 int sliderW = extent;
733 if ( HORIZONTAL ) { 733 if ( HORIZONTAL ) {
734 subB.setRect( subX,subY+1,dimB,dimB-1 ); 734 subB.setRect( subX,subY+1,dimB,dimB-1 );
735 addB.setRect( addX,addY+1,dimB,dimB-1 ); 735 addB.setRect( addX,addY+1,dimB,dimB-1 );
736 736
737 subPageR.setRect( 0, 0, 737 subPageR.setRect( 0, 0,
738 sliderStart+1, sliderW ); 738 sliderStart+1, sliderW );
739 addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+1, sliderW ); 739 addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+1, sliderW );
740 sliderR .setRect( sliderStart, 1, sliderLength, sliderW-1 ); 740 sliderR .setRect( sliderStart, 1, sliderLength, sliderW-1 );
741 741
742 } else { 742 } else {
743 subB.setRect( subX+1,subY,dimB-1,dimB ); 743 subB.setRect( subX+1,subY,dimB-1,dimB );
744 addB.setRect( addX+1,addY,dimB-1,dimB ); 744 addB.setRect( addX+1,addY,dimB-1,dimB );
745 745
746 subPageR.setRect( 0, 0, sliderW, 746 subPageR.setRect( 0, 0, sliderW,
747 sliderStart+1 ); 747 sliderStart+1 );
748 addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+1 ); 748 addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+1 );
749 sliderR .setRect( 1, sliderStart, sliderW-1, sliderLength ); 749 sliderR .setRect( 1, sliderStart, sliderW-1, sliderLength );
750 } 750 }
751 751
752 bool maxedOut = (sb->maxValue() == sb->minValue()); 752 bool maxedOut = (sb->maxValue() == sb->minValue());
753 if ( controls & AddLine ) { 753 if ( controls & AddLine ) {
754 drawBevelButton( p, addB.x(), addB.y(), 754 drawBevelButton( p, addB.x(), addB.y(),
755 addB.width(), addB.height(), g, 755 addB.width(), addB.height(), g,
756 ADD_LINE_ACTIVE); 756 ADD_LINE_ACTIVE);
757 p->setPen(g.shadow()); 757 p->setPen(g.shadow());
758 drawArrow( p, VERTICAL ? DownArrow : RightArrow, 758 drawArrow( p, VERTICAL ? DownArrow : RightArrow,
759 FALSE, addB.x()+2, addB.y()+2, 759 FALSE, addB.x()+2, addB.y()+2,
760 addB.width()-4, addB.height()-4, g, !maxedOut, 760 addB.width()-4, addB.height()-4, g, !maxedOut,
761 &g.brush( QColorGroup::Button )); 761 &g.brush( QColorGroup::Button ));
762 } 762 }
763 if ( controls & SubLine ) { 763 if ( controls & SubLine ) {
764 drawBevelButton( p, subB.x(), subB.y(), 764 drawBevelButton( p, subB.x(), subB.y(),
765 subB.width(), subB.height(), g, 765 subB.width(), subB.height(), g,
766 SUB_LINE_ACTIVE ); 766 SUB_LINE_ACTIVE );
767 p->setPen(g.shadow()); 767 p->setPen(g.shadow());
768 drawArrow( p, VERTICAL ? UpArrow : LeftArrow, 768 drawArrow( p, VERTICAL ? UpArrow : LeftArrow,
769 FALSE, subB.x()+2, subB.y()+2, 769 FALSE, subB.x()+2, subB.y()+2,
770 subB.width()-4, subB.height()-4, g, !maxedOut, 770 subB.width()-4, subB.height()-4, g, !maxedOut,
771 &g.brush( QColorGroup::Button )); 771 &g.brush( QColorGroup::Button ));
772 } 772 }
773 773
774 774
775 if ( controls & SubPage ) 775 if ( controls & SubPage )
776 p->fillRect( subPageR.x(), subPageR.y(), subPageR.width(), 776 p->fillRect( subPageR.x(), subPageR.y(), subPageR.width(),
777 subPageR.height(), g.brush( QColorGroup::Mid )); 777 subPageR.height(), g.brush( QColorGroup::Mid ));
778 if ( controls & AddPage ) 778 if ( controls & AddPage )
779 p->fillRect( addPageR.x(), addPageR.y(), addPageR.width(), 779 p->fillRect( addPageR.x(), addPageR.y(), addPageR.width(),
780 addPageR.height(), g.brush( QColorGroup::Mid )); 780 addPageR.height(), g.brush( QColorGroup::Mid ));
781 if ( controls & Slider ) { 781 if ( controls & Slider ) {
782 QPoint bo = p->brushOrigin(); 782 QPoint bo = p->brushOrigin();
783 p->setBrushOrigin(sliderR.topLeft()); 783 p->setBrushOrigin(sliderR.topLeft());
784 drawBevelButton( p, sliderR.x(), sliderR.y(), 784 drawBevelButton( p, sliderR.x(), sliderR.y(),
785 sliderR.width(), sliderR.height(), g, 785 sliderR.width(), sliderR.height(), g,
786 FALSE, &g.brush( QColorGroup::Button ) ); 786 FALSE, &g.brush( QColorGroup::Button ) );
787 p->setBrushOrigin(bo); 787 p->setBrushOrigin(bo);
788 drawRiffles( p, sliderR.x(), sliderR.y(), 788 drawRiffles( p, sliderR.x(), sliderR.y(),
789 sliderR.width(), sliderR.height(), g, HORIZONTAL ); 789 sliderR.width(), sliderR.height(), g, HORIZONTAL );
790 } 790 }
791 791
792 // ### perhaps this should not be able to accept focus if maxedOut? 792 // ### perhaps this should not be able to accept focus if maxedOut?
793 if ( sb->hasFocus() && (controls & Slider) ) 793 if ( sb->hasFocus() && (controls & Slider) )
794 p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2, 794 p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2,
795 sliderR.width()-5, sliderR.height()-5, 795 sliderR.width()-5, sliderR.height()-5,
796 sb->backgroundColor() ); 796 sb->backgroundColor() );
797 797
798} 798}
799 799
800void QPEStyle::drawRiffles( QPainter* p, int x, int y, int w, int h, 800void QPEStyle::drawRiffles( QPainter* p, int x, int y, int w, int h,
801 const QColorGroup &g, bool horizontal ) 801 const QColorGroup &g, bool horizontal )
802{ 802{
803 if (!horizontal) { 803 if (!horizontal) {
804 if (h > 20) { 804 if (h > 20) {
805 y += (h-20)/2 ; 805 y += (h-20)/2 ;
806 h = 20; 806 h = 20;
807 } 807 }
808 if (h > 12) { 808 if (h > 12) {
809 int n = 3; 809 int n = 3;
810 int my = y+h/2-4; 810 int my = y+h/2-4;
811 int i ; 811 int i ;
812 p->setPen(g.light()); 812 p->setPen(g.light());
813 for (i=0; i<n; i++) { 813 for (i=0; i<n; i++) {
814 p->drawLine(x+2, my+3*i, x+w-4, my+3*i); 814 p->drawLine(x+2, my+3*i, x+w-4, my+3*i);
815 } 815 }
816 p->setPen(g.dark()); 816 p->setPen(g.dark());
817 my++; 817 my++;
818 for (i=0; i<n; i++) { 818 for (i=0; i<n; i++) {
819 p->drawLine(x+2, my+3*i, x+w-4, my+3*i); 819 p->drawLine(x+2, my+3*i, x+w-4, my+3*i);
820 } 820 }
821 } 821 }
822 } 822 }
823 else { 823 else {
824 if (w > 20) { 824 if (w > 20) {
825 x += (w-20)/2 ; 825 x += (w-20)/2 ;
826 w = 20; 826 w = 20;
827 } 827 }
828 if (w > 12) { 828 if (w > 12) {
829 int n = 3; 829 int n = 3;
830 int mx = x+w/2-4; 830 int mx = x+w/2-4;
831 int i ; 831 int i ;
832 p->setPen(g.light()); 832 p->setPen(g.light());
833 for (i=0; i<n; i++) { 833 for (i=0; i<n; i++) {
834 p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4); 834 p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4);
835 } 835 }
836 p->setPen(g.dark()); 836 p->setPen(g.dark());
837 mx++; 837 mx++;
838 for (i=0; i<n; i++) { 838 for (i=0; i<n; i++) {
839 p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4); 839 p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4);
840 } 840 }
841 } 841 }
842 } 842 }
843} 843}
844 844
845int QPEStyle::sliderLength() const 845int QPEStyle::sliderLength() const
846{ 846{
847 return 12; 847 return 12;
848} 848}
849 849
850void QPEStyle::drawSlider( QPainter *p, int x, int y, int w, int h, 850void QPEStyle::drawSlider( QPainter *p, int x, int y, int w, int h,
851 const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow ) 851 const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow )
852{ 852{
853 int a = tickAbove ? 3 : 0; 853 int a = tickAbove ? 3 : 0;
854 int b = tickBelow ? 3 : 0; 854 int b = tickBelow ? 3 : 0;
855 855
856 if ( o == Horizontal ) { 856 if ( o == Horizontal ) {
857 drawBevelButton( p, x, y+a, w, h-a-b, g, FALSE, &g.brush( QColorGroup::Button ) ); 857 drawBevelButton( p, x, y+a, w, h-a-b, g, FALSE, &g.brush( QColorGroup::Button ) );
858 int xp = x + w/2; 858 int xp = x + w/2;
859 qDrawShadeLine( p, xp, y+a+2, xp, y+h-b-3, g ); 859 qDrawShadeLine( p, xp, y+a+2, xp, y+h-b-3, g );
860 } else { 860 } else {
861 drawBevelButton( p, x+a, y, w-a-b, h, g, FALSE, &g.brush( QColorGroup::Button ) ); 861 drawBevelButton( p, x+a, y, w-a-b, h, g, FALSE, &g.brush( QColorGroup::Button ) );
862 int yp = y + h/2; 862 int yp = y + h/2;
863 qDrawShadeLine( p, x+a+2, yp, x+w-b-3, yp, g ); 863 qDrawShadeLine( p, x+a+2, yp, x+w-b-3, yp, g );
864 } 864 }
865} 865}
866 866
867void QPEStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h, 867void QPEStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h,
868 Orientation o, bool tickAbove, bool tickBelow ) 868 Orientation o, bool tickAbove, bool tickBelow )
869{ 869{
870 int a = tickAbove ? 3 : 0; 870 int a = tickAbove ? 3 : 0;
871 int b = tickBelow ? 3 : 0; 871 int b = tickBelow ? 3 : 0;
872 if ( o == Horizontal ) 872 if ( o == Horizontal )
873 p->fillRect( x, y+a, w, h-a-b, color1 ); 873 p->fillRect( x, y+a, w, h-a-b, color1 );
874 else 874 else
875 p->fillRect( x+a, y, w-a-b, h, color1 ); 875 p->fillRect( x+a, y, w-a-b, h, color1 );
876} 876}
877 877
878/*!\reimp 878/*!\reimp
879 */ 879 */
880void QPEStyle::drawSliderGrooveMask( QPainter *p, 880void QPEStyle::drawSliderGrooveMask( QPainter *p,
881 int x, int y, int w, int h, 881 int x, int y, int w, int h,
882 const QColorGroup& , QCOORD c, 882 const QColorGroup& , QCOORD c,
883 Orientation orient ) 883 Orientation orient )
884{ 884{
885 if ( orient == Horizontal ) 885 if ( orient == Horizontal )
886 p->fillRect( x, y + c - 2, w, 4, color1 ); 886 p->fillRect( x, y + c - 2, w, 4, color1 );
887 else 887 else
888 p->fillRect( x + c - 2, y, 4, h, color1 ); 888 p->fillRect( x + c - 2, y, 4, h, color1 );
889} 889}
890 890
891void QPEStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) 891void QPEStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected )
892{ 892{
893 QRect r( t->rect() ); 893 QRect r( t->rect() );
894 if ( tb->shape() == QTabBar::RoundedAbove ) { 894 if ( tb->shape() == QTabBar::RoundedAbove ) {
895 p->setPen( tb->colorGroup().light() ); 895 p->setPen( tb->colorGroup().light() );
896 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 896 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
897 if ( r.left() == 0 ) 897 if ( r.left() == 0 )
898 p->drawPoint( tb->rect().bottomLeft() ); 898 p->drawPoint( tb->rect().bottomLeft() );
899 else { 899 else {
900 p->setPen( tb->colorGroup().light() ); 900 p->setPen( tb->colorGroup().light() );
901 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 901 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
902 } 902 }
903 903
904 if ( selected ) { 904 if ( selected ) {
905 p->setPen( tb->colorGroup().background() ); 905 p->setPen( tb->colorGroup().background() );
906 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 906 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
907 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), 907 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2),
908 tb->colorGroup().brush( QColorGroup::Background )); 908 tb->colorGroup().brush( QColorGroup::Background ));
909 } else { 909 } else {
910 r.setRect( r.left() + 2, r.top() + 2, 910 r.setRect( r.left() + 2, r.top() + 2,
911 r.width() - 4, r.height() - 2 ); 911 r.width() - 4, r.height() - 2 );
912 p->setPen( tb->colorGroup().button() ); 912 p->setPen( tb->colorGroup().button() );
913 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 913 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
914 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), 914 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3),
915 tb->colorGroup().brush( QColorGroup::Button )); 915 tb->colorGroup().brush( QColorGroup::Button ));
916 916
917 //do shading; will not work for pixmap brushes 917 //do shading; will not work for pixmap brushes
918 QColor bg = tb->colorGroup().button(); 918 QColor bg = tb->colorGroup().button();
919 // int h,s,v; 919 // int h,s,v;
920 // bg.hsv( &h, &s, &v ); 920 // bg.hsv( &h, &s, &v );
921 int n = r.height()/2; 921 int n = r.height()/2;
922 int dark = 100; 922 int dark = 100;
923 for ( int i = 1; i < n; i++ ) { 923 for ( int i = 1; i < n; i++ ) {
924 dark = (dark * (100+(i*15)/n) )/100; 924 dark = (dark * (100+(i*15)/n) )/100;
925 p->setPen( bg.dark( dark ) ); 925 p->setPen( bg.dark( dark ) );
926 int y = r.bottom()-n+i; 926 int y = r.bottom()-n+i;
927 int x1 = r.left()+1; 927 int x1 = r.left()+1;
928 int x2 = r.right()-1; 928 int x2 = r.right()-1;
929 p->drawLine( x1, y, x2, y ); 929 p->drawLine( x1, y, x2, y );
930 } 930 }
931 } 931 }
932 932
933 p->setPen( tb->colorGroup().light() ); 933 p->setPen( tb->colorGroup().light() );
934 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); 934 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 );
935 p->drawPoint( r.left()+1, r.top() + 1 ); 935 p->drawPoint( r.left()+1, r.top() + 1 );
936 p->drawLine( r.left()+2, r.top(), 936 p->drawLine( r.left()+2, r.top(),
937 r.right() - 2, r.top() ); 937 r.right() - 2, r.top() );
938 938
939 p->setPen( tb->colorGroup().dark() ); 939 p->setPen( tb->colorGroup().dark() );
940 p->drawPoint( r.right() - 1, r.top() + 1 ); 940 p->drawPoint( r.right() - 1, r.top() + 1 );
941 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); 941 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1);
942 } else if ( tb->shape() == QTabBar::RoundedBelow ) { 942 } else if ( tb->shape() == QTabBar::RoundedBelow ) {
943 if ( selected ) { 943 if ( selected ) {
944 p->setPen( tb->colorGroup().background() ); 944 p->setPen( tb->colorGroup().background() );
945 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 945 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
946 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), 946 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2),
947 tb->palette().normal().brush( QColorGroup::Background )); 947 tb->palette().normal().brush( QColorGroup::Background ));
948 } else { 948 } else {
949 p->setPen( tb->colorGroup().dark() ); 949 p->setPen( tb->colorGroup().dark() );
950 p->drawLine( r.left(), r.top(), 950 p->drawLine( r.left(), r.top(),
951 r.right(), r.top() ); 951 r.right(), r.top() );
952 r.setRect( r.left() + 2, r.top(), 952 r.setRect( r.left() + 2, r.top(),
953 r.width() - 4, r.height() - 2 ); 953 r.width() - 4, r.height() - 2 );
954 p->setPen( tb->colorGroup().button() ); 954 p->setPen( tb->colorGroup().button() );
955 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 955 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
956 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), 956 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3),
957 tb->palette().normal().brush( QColorGroup::Button )); 957 tb->palette().normal().brush( QColorGroup::Button ));
958 } 958 }
959 959
960 p->setPen( tb->colorGroup().dark() ); 960 p->setPen( tb->colorGroup().dark() );
961 p->drawLine( r.right(), r.top(), 961 p->drawLine( r.right(), r.top(),
962 r.right(), r.bottom() - 2 ); 962 r.right(), r.bottom() - 2 );
963 p->drawPoint( r.right() - 1, r.bottom() - 1 ); 963 p->drawPoint( r.right() - 1, r.bottom() - 1 );
964 p->drawLine( r.right() - 2, r.bottom(), 964 p->drawLine( r.right() - 2, r.bottom(),
965 r.left() + 2, r.bottom() ); 965 r.left() + 2, r.bottom() );
966 966
967 p->setPen( tb->colorGroup().light() ); 967 p->setPen( tb->colorGroup().light() );
968 p->drawLine( r.left(), r.top()+1, 968 p->drawLine( r.left(), r.top()+1,
969 r.left(), r.bottom() - 2 ); 969 r.left(), r.bottom() - 2 );
970 p->drawPoint( r.left() + 1, r.bottom() - 1 ); 970 p->drawPoint( r.left() + 1, r.bottom() - 1 );
971 if ( r.left() == 0 ) 971 if ( r.left() == 0 )
972 p->drawPoint( tb->rect().topLeft() ); 972 p->drawPoint( tb->rect().topLeft() );
973 973
974 } else { 974 } else {
975 QCommonStyle::drawTab( p, tb, t, selected ); 975 QCommonStyle::drawTab( p, tb, t, selected );
976 } 976 }
977} 977}
978 978
979 static const int motifItemFrame = 0;// menu item frame width 979 static const int motifItemFrame = 0;// menu item frame width
980 static const int motifSepHeight = 2;// separator item height 980 static const int motifSepHeight = 2;// separator item height
981 static const int motifItemHMargin = 1;// menu item hor text margin 981 static const int motifItemHMargin = 1;// menu item hor text margin
982 static const int motifItemVMargin = 2;// menu item ver text margin 982 static const int motifItemVMargin = 2;// menu item ver text margin
983 static const int motifArrowHMargin = 0;// arrow horizontal margin 983 static const int motifArrowHMargin = 0;// arrow horizontal margin
984 static const int motifTabSpacing = 12;// space between text and tab 984 static const int motifTabSpacing = 12;// space between text and tab
985 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark 985 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark
986 static const int windowsRightBorder= 8; // right border on windows 986 static const int windowsRightBorder= 8; // right border on windows
987static const int windowsCheckMarkWidth = 2; // checkmarks width on windows 987static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
988 988
989/*! \reimp 989/*! \reimp
990*/ 990*/
991int QPEStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ ) 991int QPEStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ )
992{ 992{
993#ifndef QT_NO_MENUDATA 993#ifndef QT_NO_MENUDATA
994 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm 994 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
995 995
996 if ( mi->isSeparator() ) 996 if ( mi->isSeparator() )
997 return 10; // arbitrary 997 return 10; // arbitrary
998 else if ( mi->pixmap() ) 998 else if ( mi->pixmap() )
999 w += mi->pixmap()->width();// pixmap only 999 w += mi->pixmap()->width();// pixmap only
1000 1000
1001 if ( !mi->text().isNull() ) { 1001 if ( !mi->text().isNull() ) {
1002 if ( mi->text().find('\t') >= 0 )// string contains tab 1002 if ( mi->text().find('\t') >= 0 )// string contains tab
1003 w += motifTabSpacing; 1003 w += motifTabSpacing;
1004 } 1004 }
1005 1005
1006 if ( maxpmw ) { // we have iconsets 1006 if ( maxpmw ) { // we have iconsets
1007 w += maxpmw; 1007 w += maxpmw;
1008 w += 6; // add a little extra border around the iconset 1008 w += 6; // add a little extra border around the iconset
1009 } 1009 }
1010 1010
1011 if ( checkable && maxpmw < windowsCheckMarkWidth ) { 1011 if ( checkable && maxpmw < windowsCheckMarkWidth ) {
1012 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks 1012 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
1013 } 1013 }
1014 1014
1015 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks) 1015 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
1016 w += motifCheckMarkHMargin; // add space to separate the columns 1016 w += motifCheckMarkHMargin; // add space to separate the columns
1017 1017
1018 w += windowsRightBorder; // windows has a strange wide border on the right side 1018 w += windowsRightBorder; // windows has a strange wide border on the right side
1019 1019
1020 return w; 1020 return w;
1021#endif 1021#endif
1022} 1022}
1023 1023
1024/*! \reimp 1024/*! \reimp
1025*/ 1025*/
1026int QPEStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) 1026int QPEStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
1027{ 1027{
1028#ifndef QT_NO_MENUDATA 1028#ifndef QT_NO_MENUDATA
1029 int h = 0; 1029 int h = 0;
1030 if ( mi->isSeparator() ) // separator height 1030 if ( mi->isSeparator() ) // separator height
1031 h = motifSepHeight; 1031 h = motifSepHeight;
1032 else if ( mi->pixmap() ) // pixmap height 1032 else if ( mi->pixmap() ) // pixmap height
1033 h = mi->pixmap()->height() + 2*motifItemFrame; 1033 h = mi->pixmap()->height() + 2*motifItemFrame;
1034 else // text height 1034 else // text height
1035 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; 1035 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
1036 1036
1037 if ( !mi->isSeparator() && mi->iconSet() != 0 ) { 1037 if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
1038 h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); 1038 h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame );
1039 } 1039 }
1040 if ( mi->custom() ) 1040 if ( mi->custom() )
1041 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; 1041 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
1042 return h; 1042 return h;
1043#endif 1043#endif
1044} 1044}
1045 1045
1046void QPEStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, 1046void QPEStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
1047 const QPalette& pal, 1047 const QPalette& pal,
1048 bool act, bool enabled, int x, int y, int w, int h) 1048 bool act, bool enabled, int x, int y, int w, int h)
1049{ 1049{
1050#ifndef QT_NO_MENUDATA 1050#ifndef QT_NO_MENUDATA
1051 const QColorGroup & g = pal.active(); 1051 const QColorGroup & g = pal.active();
1052 bool dis = !enabled; 1052 bool dis = !enabled;
1053 QColorGroup itemg = dis ? pal.disabled() : pal.active(); 1053 QColorGroup itemg = dis ? pal.disabled() : pal.active();
1054 1054
1055 if ( checkable ) 1055 if ( checkable )
1056 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks 1056 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks
1057 1057
1058 int checkcol = maxpmw; 1058 int checkcol = maxpmw;
1059 1059
1060 if ( mi && mi->isSeparator() ) { // draw separator 1060 if ( mi && mi->isSeparator() ) { // draw separator
1061 p->setPen( g.dark() ); 1061 p->setPen( g.dark() );
1062 p->drawLine( x, y, x+w, y ); 1062 p->drawLine( x, y, x+w, y );
1063 p->setPen( g.light() ); 1063 p->setPen( g.light() );
1064 p->drawLine( x, y+1, x+w, y+1 ); 1064 p->drawLine( x, y+1, x+w, y+1 );
1065 return; 1065 return;
1066 } 1066 }
1067 1067
1068 QBrush fill = act? g.brush( QColorGroup::Highlight ) : 1068 QBrush fill = act? g.brush( QColorGroup::Highlight ) :
1069 g.brush( QColorGroup::Button ); 1069 g.brush( QColorGroup::Button );
1070 p->fillRect( x, y, w, h, fill); 1070 p->fillRect( x, y, w, h, fill);
1071 1071
1072 if ( !mi ) 1072 if ( !mi )
1073 return; 1073 return;
1074 1074
1075 if ( mi->isChecked() ) { 1075 if ( mi->isChecked() ) {
1076 if ( act && !dis ) { 1076 if ( act && !dis ) {
1077 qDrawShadePanel( p, x, y, checkcol, h, 1077 qDrawShadePanel( p, x, y, checkcol, h,
1078 g, TRUE, 1, &g.brush( QColorGroup::Button ) ); 1078 g, TRUE, 1, &g.brush( QColorGroup::Button ) );
1079 } else { 1079 } else {
1080 qDrawShadePanel( p, x, y, checkcol, h, 1080 qDrawShadePanel( p, x, y, checkcol, h,
1081 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); 1081 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
1082 } 1082 }
1083 } else if ( !act ) { 1083 } else if ( !act ) {
1084 p->fillRect(x, y, checkcol , h, 1084 p->fillRect(x, y, checkcol , h,
1085 g.brush( QColorGroup::Button )); 1085 g.brush( QColorGroup::Button ));
1086 } 1086 }
1087 1087
1088 if ( mi->iconSet() ) { // draw iconset 1088 if ( mi->iconSet() ) { // draw iconset
1089 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; 1089 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
1090 if (act && !dis ) 1090 if (act && !dis )
1091 mode = QIconSet::Active; 1091 mode = QIconSet::Active;
1092 QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode ); 1092 QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
1093 int pixw = pixmap.width(); 1093 int pixw = pixmap.width();
1094 int pixh = pixmap.height(); 1094 int pixh = pixmap.height();
1095 if ( act && !dis ) { 1095 if ( act && !dis ) {
1096 if ( !mi->isChecked() ) 1096 if ( !mi->isChecked() )
1097 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) ); 1097 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
1098 } 1098 }
1099 QRect cr( x, y, checkcol, h ); 1099 QRect cr( x, y, checkcol, h );
1100 QRect pmr( 0, 0, pixw, pixh ); 1100 QRect pmr( 0, 0, pixw, pixh );
1101 pmr.moveCenter( cr.center() ); 1101 pmr.moveCenter( cr.center() );
1102 p->setPen( itemg.text() ); 1102 p->setPen( itemg.text() );
1103 p->drawPixmap( pmr.topLeft(), pixmap ); 1103 p->drawPixmap( pmr.topLeft(), pixmap );
1104 1104
1105 QBrush fill = act? g.brush( QColorGroup::Highlight ) : 1105 QBrush fill = act? g.brush( QColorGroup::Highlight ) :
1106 g.brush( QColorGroup::Button ); 1106 g.brush( QColorGroup::Button );
1107 p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill); 1107 p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
1108 } else if ( checkable ) {// just "checking"... 1108 } else if ( checkable ) {// just "checking"...
1109 int mw = checkcol + motifItemFrame; 1109 int mw = checkcol + motifItemFrame;
1110 int mh = h - 2*motifItemFrame; 1110 int mh = h - 2*motifItemFrame;
1111 if ( mi->isChecked() ) { 1111 if ( mi->isChecked() ) {
1112 drawCheckMark( p, x + motifItemFrame + 2, 1112 drawCheckMark( p, x + motifItemFrame + 2,
1113 y+motifItemFrame, mw, mh, itemg, act, dis ); 1113 y+motifItemFrame, mw, mh, itemg, act, dis );
1114 } 1114 }
1115 } 1115 }
1116 1116
1117 p->setPen( act ? g.highlightedText() : g.buttonText() ); 1117 p->setPen( act ? g.highlightedText() : g.buttonText() );
1118 1118
1119 QColor discol; 1119 QColor discol;
1120 if ( dis ) { 1120 if ( dis ) {
1121 discol = itemg.text(); 1121 discol = itemg.text();
1122 p->setPen( discol ); 1122 p->setPen( discol );
1123 } 1123 }
1124 1124
1125 int xm = motifItemFrame + checkcol + motifItemHMargin; 1125 int xm = motifItemFrame + checkcol + motifItemHMargin;
1126 1126
1127 if ( mi->custom() ) { 1127 if ( mi->custom() ) {
1128 int m = motifItemVMargin; 1128 int m = motifItemVMargin;
1129 p->save(); 1129 p->save();
1130 if ( dis && !act ) { 1130 if ( dis && !act ) {
1131 p->setPen( g.light() ); 1131 p->setPen( g.light() );
1132 mi->custom()->paint( p, itemg, act, enabled, 1132 mi->custom()->paint( p, itemg, act, enabled,
1133 x+xm+1, y+m+1, w-xm-tab+1, h-2*m ); 1133 x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
1134 p->setPen( discol ); 1134 p->setPen( discol );
1135 } 1135 }
1136 mi->custom()->paint( p, itemg, act, enabled, 1136 mi->custom()->paint( p, itemg, act, enabled,
1137 x+xm, y+m, w-xm-tab+1, h-2*m ); 1137 x+xm, y+m, w-xm-tab+1, h-2*m );
1138 p->restore(); 1138 p->restore();
1139 } 1139 }
1140 QString s = mi->text(); 1140 QString s = mi->text();
1141 if ( !s.isNull() ) { // draw text 1141 if ( !s.isNull() ) { // draw text
1142 int t = s.find( '\t' ); 1142 int t = s.find( '\t' );
1143 int m = motifItemVMargin; 1143 int m = motifItemVMargin;
1144 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; 1144 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
1145 if ( t >= 0 ) { // draw tab text 1145 if ( t >= 0 ) { // draw tab text
1146 if ( dis && !act ) { 1146 if ( dis && !act ) {
1147 p->setPen( g.light() ); 1147 p->setPen( g.light() );
1148 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, 1148 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
1149 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); 1149 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
1150 p->setPen( discol ); 1150 p->setPen( discol );
1151 } 1151 }
1152 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame, 1152 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame,
1153 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); 1153 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
1154 } 1154 }
1155 if ( dis && !act ) { 1155 if ( dis && !act ) {
1156 p->setPen( g.light() ); 1156 p->setPen( g.light() );
1157 p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t ); 1157 p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t );
1158 p->setPen( discol ); 1158 p->setPen( discol );
1159 } 1159 }
1160 p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t ); 1160 p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
1161 } else if ( mi->pixmap() ) { // draw pixmap 1161 } else if ( mi->pixmap() ) { // draw pixmap
1162 QPixmap *pixmap = mi->pixmap(); 1162 QPixmap *pixmap = mi->pixmap();
1163 if ( pixmap->depth() == 1 ) 1163 if ( pixmap->depth() == 1 )
1164 p->setBackgroundMode( OpaqueMode ); 1164 p->setBackgroundMode( OpaqueMode );
1165 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap ); 1165 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap );
1166 if ( pixmap->depth() == 1 ) 1166 if ( pixmap->depth() == 1 )
1167 p->setBackgroundMode( TransparentMode ); 1167 p->setBackgroundMode( TransparentMode );
1168 } 1168 }
1169 if ( mi->popup() ) { // draw sub menu arrow 1169 if ( mi->popup() ) { // draw sub menu arrow
1170 int dim = (h-2*motifItemFrame) / 2; 1170 int dim = (h-2*motifItemFrame) / 2;
1171 if ( act ) { 1171 if ( act ) {
1172 if ( !dis ) 1172 if ( !dis )
1173 discol = white; 1173 discol = white;
1174 QColorGroup g2( discol, g.highlight(), 1174 QColorGroup g2( discol, g.highlight(),
1175 white, white, 1175 white, white,
1176 dis ? discol : white, 1176 dis ? discol : white,
1177 discol, white ); 1177 discol, white );
1178 drawArrow( p, RightArrow, FALSE, 1178 drawArrow( p, RightArrow, FALSE,
1179 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 1179 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
1180 dim, dim, g2, TRUE ); 1180 dim, dim, g2, TRUE );
1181 } else { 1181 } else {
1182 drawArrow( p, RightArrow, 1182 drawArrow( p, RightArrow,
1183 FALSE, 1183 FALSE,
1184 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 1184 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
1185 dim, dim, g, mi->isEnabled() ); 1185 dim, dim, g, mi->isEnabled() );
1186 } 1186 }
1187 } 1187 }
1188#endif 1188#endif
1189} 1189}
1190 1190
1191#endif 1191#endif
diff --git a/library/qpestyle.h b/library/qpestyle.h
index 19ef346..1bde0ff 100644
--- a/library/qpestyle.h
+++ b/library/qpestyle.h
@@ -1,102 +1,102 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef QPESTYLE_H 21#ifndef QPESTYLE_H
22#define QPESTYLE_H 22#define QPESTYLE_H
23 23
24#ifndef QT_H 24#ifndef QT_H
25#include "qwindowsstyle.h" 25#include "qwindowsstyle.h"
26#endif // QT_H 26#endif // QT_H
27 27
28#if QT_VERSION >= 300 28#if QT_VERSION >= 0x030000
29 29
30class Q_EXPORT QPEStyle : public QWindowsStyle 30class Q_EXPORT QPEStyle : public QWindowsStyle
31{ 31{
32public: 32public:
33 QPEStyle(); 33 QPEStyle();
34 virtual ~QPEStyle(); 34 virtual ~QPEStyle();
35 35
36 virtual void drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags=Style_Default, const QStyleOption & = QStyleOption::Default) const; 36 virtual void drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags=Style_Default, const QStyleOption & = QStyleOption::Default) const;
37 virtual void drawControl( ControlElement ce, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how=Style_Default, const QStyleOption & = QStyleOption::Default) const; 37 virtual void drawControl( ControlElement ce, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how=Style_Default, const QStyleOption & = QStyleOption::Default) const;
38 virtual void drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how=Style_Default, SCFlags sub=SC_All, SCFlags subActive=SC_None, const QStyleOption & = QStyleOption::Default) const; 38 virtual void drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how=Style_Default, SCFlags sub=SC_All, SCFlags subActive=SC_None, const QStyleOption & = QStyleOption::Default) const;
39 virtual int pixelMetric( PixelMetric metric, const QWidget *widget=0 ) const; 39 virtual int pixelMetric( PixelMetric metric, const QWidget *widget=0 ) const;
40 virtual QSize sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentsSize, const QStyleOption & = QStyleOption::Default) const; 40 virtual QSize sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentsSize, const QStyleOption & = QStyleOption::Default) const;
41}; 41};
42 42
43#else 43#else
44 44
45class Q_EXPORT QPEStyle : public QWindowsStyle 45class Q_EXPORT QPEStyle : public QWindowsStyle
46{ 46{
47public: 47public:
48 QPEStyle(); 48 QPEStyle();
49 virtual ~QPEStyle(); 49 virtual ~QPEStyle();
50 virtual void polish( QPalette &p ); 50 virtual void polish( QPalette &p );
51 virtual void polish( QWidget *w ); 51 virtual void polish( QWidget *w );
52 virtual void unPolish( QWidget *w ); 52 virtual void unPolish( QWidget *w );
53 53
54 int defaultFrameWidth () const; 54 int defaultFrameWidth () const;
55 void drawPanel ( QPainter * p, int x, int y, int w, int h, 55 void drawPanel ( QPainter * p, int x, int y, int w, int h,
56 const QColorGroup &, bool sunken=FALSE, int lineWidth = 1, const QBrush * fill = 0 ); 56 const QColorGroup &, bool sunken=FALSE, int lineWidth = 1, const QBrush * fill = 0 );
57 void drawButton( QPainter *p, int x, int y, int w, int h, 57 void drawButton( QPainter *p, int x, int y, int w, int h,
58 const QColorGroup &g, bool sunken, const QBrush* fill ); 58 const QColorGroup &g, bool sunken, const QBrush* fill );
59 void drawButtonMask ( QPainter * p, int x, int y, int w, int h ); 59 void drawButtonMask ( QPainter * p, int x, int y, int w, int h );
60 void drawBevelButton( QPainter *p, int x, int y, int w, int h, 60 void drawBevelButton( QPainter *p, int x, int y, int w, int h,
61 const QColorGroup &g, bool sunken=FALSE, const QBrush* fill=0 ); 61 const QColorGroup &g, bool sunken=FALSE, const QBrush* fill=0 );
62 QRect comboButtonRect( int x, int y, int w, int h); 62 QRect comboButtonRect( int x, int y, int w, int h);
63 QRect comboButtonFocusRect( int x, int y, int w, int h); 63 QRect comboButtonFocusRect( int x, int y, int w, int h);
64 void drawComboButton( QPainter *p, int x, int y, int w, int h, 64 void drawComboButton( QPainter *p, int x, int y, int w, int h,
65 const QColorGroup &g, bool sunken, bool, bool enabled, 65 const QColorGroup &g, bool sunken, bool, bool enabled,
66 const QBrush *fill ); 66 const QBrush *fill );
67 void drawExclusiveIndicator ( QPainter * p, int x, int y, int w, int h, 67 void drawExclusiveIndicator ( QPainter * p, int x, int y, int w, int h,
68 const QColorGroup & g, bool on, bool down = FALSE, bool enabled = TRUE ); 68 const QColorGroup & g, bool on, bool down = FALSE, bool enabled = TRUE );
69 void drawIndicator ( QPainter * p, int x, int y, int w, int h, 69 void drawIndicator ( QPainter * p, int x, int y, int w, int h,
70 const QColorGroup & g, int state, bool down = FALSE, bool enabled = TRUE ); 70 const QColorGroup & g, int state, bool down = FALSE, bool enabled = TRUE );
71 void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int&); 71 void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int&);
72 void drawScrollBarControls( QPainter*, const QScrollBar*, int sliderStart, uint controls, uint activeControl ); 72 void drawScrollBarControls( QPainter*, const QScrollBar*, int sliderStart, uint controls, uint activeControl );
73 ScrollControl scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p ); 73 ScrollControl scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p );
74 void drawRiffles( QPainter* p, int x, int y, int w, int h, 74 void drawRiffles( QPainter* p, int x, int y, int w, int h,
75 const QColorGroup &g, bool horizontal ); 75 const QColorGroup &g, bool horizontal );
76 int sliderLength() const; 76 int sliderLength() const;
77 void drawSlider( QPainter *p, int x, int y, int w, int h, 77 void drawSlider( QPainter *p, int x, int y, int w, int h,
78 const QColorGroup &g, Orientation, bool tickAbove, bool tickBelow ); 78 const QColorGroup &g, Orientation, bool tickAbove, bool tickBelow );
79 void drawSliderMask( QPainter *p, int x, int y, int w, int h, 79 void drawSliderMask( QPainter *p, int x, int y, int w, int h,
80 Orientation, bool tickAbove, bool tickBelow ); 80 Orientation, bool tickAbove, bool tickBelow );
81 void drawSliderGrooveMask( QPainter *p, int x, int y, int w, int h, 81 void drawSliderGrooveMask( QPainter *p, int x, int y, int w, int h,
82 const QColorGroup& , QCOORD c, Orientation orient ); 82 const QColorGroup& , QCOORD c, Orientation orient );
83 void drawTab( QPainter *, const QTabBar *, QTab *, bool selected ); 83 void drawTab( QPainter *, const QTabBar *, QTab *, bool selected );
84 int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& ); 84 int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& );
85 int popupMenuItemHeight( bool checkable, QMenuItem*, const QFontMetrics& ); 85 int popupMenuItemHeight( bool checkable, QMenuItem*, const QFontMetrics& );
86 void drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, 86 void drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
87 const QPalette& pal, 87 const QPalette& pal,
88 bool act, bool enabled, int x, int y, int w, int h); 88 bool act, bool enabled, int x, int y, int w, int h);
89 89
90 int buttonMargin() const; 90 int buttonMargin() const;
91 QSize scrollBarExtent() const; 91 QSize scrollBarExtent() const;
92 92
93 private:// Disabled copy constructor and operator= 93 private:// Disabled copy constructor and operator=
94#if defined(Q_DISABLE_COPY) 94#if defined(Q_DISABLE_COPY)
95 QPEStyle( const QPEStyle & ); 95 QPEStyle( const QPEStyle & );
96 QPEStyle& operator=( const QPEStyle & ); 96 QPEStyle& operator=( const QPEStyle & );
97#endif 97#endif
98}; 98};
99 99
100#endif 100#endif
101 101
102#endif // QPESTYLE_H 102#endif // QPESTYLE_H