summaryrefslogtreecommitdiff
authorzecke <zecke>2004-08-02 18:37:26 (UTC)
committer zecke <zecke>2004-08-02 18:37:26 (UTC)
commit4d0a9fc4a21e7a7242e466f8eec1dc61d173800d (patch) (unidiff)
treef66b7c11f1325363fb4d426cc133802f9b8e59ab
parentdb991191fa216293191a0a8b0a2db18866b94dca (diff)
downloadopie-4d0a9fc4a21e7a7242e466f8eec1dc61d173800d.zip
opie-4d0a9fc4a21e7a7242e466f8eec1dc61d173800d.tar.gz
opie-4d0a9fc4a21e7a7242e466f8eec1dc61d173800d.tar.bz2
Initial revision
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/phase/.cvsignore3
-rw-r--r--noncore/styles/phase/README47
-rw-r--r--noncore/styles/phase/bitmaps.h70
-rw-r--r--noncore/styles/phase/config.in4
-rw-r--r--noncore/styles/phase/phase.pro15
-rw-r--r--noncore/styles/phase/phasestyle.cpp1221
-rw-r--r--noncore/styles/phase/phasestyle.h166
-rw-r--r--noncore/styles/phase/plugin.cpp71
-rw-r--r--noncore/styles/phase/plugin.h54
9 files changed, 1651 insertions, 0 deletions
diff --git a/noncore/styles/phase/.cvsignore b/noncore/styles/phase/.cvsignore
new file mode 100644
index 0000000..c8de896
--- a/dev/null
+++ b/noncore/styles/phase/.cvsignore
@@ -0,0 +1,3 @@
1Makefile*
2*.moc
3.obj
diff --git a/noncore/styles/phase/README b/noncore/styles/phase/README
new file mode 100644
index 0000000..5dc9e9c
--- a/dev/null
+++ b/noncore/styles/phase/README
@@ -0,0 +1,47 @@
1Opie Phase is based on the style from David Johnson
2and was backported to Qt2 by Holger Hans Peter Freyther
3
4
5
6Original PHASE 0.4 README
7
8
9Phase, Version 0.x
10==================
11
12Phase is a look and feel for KDE. It is designed to be functional but not drab
13and aesthetic but not distracting. Artistic design draws upon the genius of
14earlier masters. This is particularly true for minimalistic designs. Therefore
15I cannot in good conscience claim this look to be truly original. But I have
16done my best.
17
18The Phase widget style is built as a KDE plugin, but is also useful for
19standalone Qt programs provided that the KDE libraries are installed. Please
20read the INSTALL file for installation instructions. You can activate the
21style through the KDE Control Center.
22
23Please note that Phase requires KDE 3.x and above. It will not build or run
24under earlier versions of KDE. Full functionality requires KDE 3.2 or greater.
25The Phase homepage is at <http://www.usermode.org/code.html>.
26
27=================
28
29Copyright (c) 2004 David Johnson <david@usermode.org>
30
31Permission is hereby granted, free of charge, to any person obtaining a copy
32of this software and associated documentation files (the "Software"), to
33deal in the Software without restriction, including without limitation the
34rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
35sell copies of the Software, and to permit persons to whom the Software is
36furnished to do so, subject to the following conditions:
37
38The above copyright notice and this permission notice shall be included in
39all copies or substantial portions of the Software.
40
41THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
46FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
47IN THE SOFTWARE.
diff --git a/noncore/styles/phase/bitmaps.h b/noncore/styles/phase/bitmaps.h
new file mode 100644
index 0000000..28bc1db
--- a/dev/null
+++ b/noncore/styles/phase/bitmaps.h
@@ -0,0 +1,70 @@
1//////////////////////////////////////////////////////////////////////////////
2// bitmaps.h
3// -------------------
4// Bitmaps for Phase
5// -------------------
6// Copyright (c) 2004 David Johnson
7// Please see the phasestyle.h file for copyright and license information.
8//////////////////////////////////////////////////////////////////////////////
9
10// Note: the "light" bits are drawn with midlight color
11
12// Arrows (6x6)
13
14#include <qbitmap.h>
15
16static QBitmap uarrow;
17static unsigned char uarrow_bits[] = {
18 0x00, 0x0c, 0x1e, 0x3f, 0x3f, 0x00};
19
20static QBitmap darrow;
21static unsigned char darrow_bits[] = {
22 0x00, 0x3f, 0x3f, 0x1e, 0x0c, 0x00};
23
24static QBitmap larrow;
25static unsigned char larrow_bits[] = {
26 0x18, 0x1c, 0x1e, 0x1e, 0x1c, 0x18};
27
28static QBitmap rarrow;
29static unsigned char rarrow_bits[] = {
30 0x06, 0x0e, 0x1e, 0x1e, 0x0e, 0x06};
31
32// plus/minus "arrows"
33
34static QBitmap bplus;
35static unsigned char bplus_bits[] = {
36 0x0c, 0x0c, 0x3f, 0x3f, 0x0c, 0x0c};
37
38static QBitmap bminus;
39static unsigned char bminus_bits[] = {
40 0x00, 0x00, 0x3f, 0x3f, 0x00, 0x00};
41
42// checkmark (9x9)
43
44static QBitmap bcheck;
45static unsigned char bcheck_bits[] = {
46 0x00, 0x00, 0x80, 0x01, 0xc0, 0x01, 0xe0, 0x00, 0x73, 0x00, 0x3f, 0x00,
47 0x1e, 0x00, 0x0c, 0x00, 0x00, 0x00};
48
49// expander arrows (9x9)
50
51static QBitmap dexpand;
52static unsigned char dexpand_bits[] = {
53 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00,
54 0x10, 0x00, 0x00, 0x00, 0x00, 0x00};
55
56static QBitmap rexpand;
57static unsigned char rexpand_bits[] = {
58 0x04, 0x00, 0x0c, 0x00, 0x1c, 0x00, 0x3c, 0x00, 0x7c, 0x00, 0x3c, 0x00,
59 0x1c, 0x00, 0x0c, 0x00, 0x04, 0x00};
60
61// scrollbar doodads (4x4)
62
63static QBitmap doodad_mid;
64static unsigned char doodad_mid_bits[] = {
65 0x07, 0x01, 0x01, 0x00};
66
67static QBitmap doodad_light;
68static unsigned char doodad_light_bits[] = {
69 0x00, 0x08, 0x08, 0x0e};
70
diff --git a/noncore/styles/phase/config.in b/noncore/styles/phase/config.in
new file mode 100644
index 0000000..40949e6
--- a/dev/null
+++ b/noncore/styles/phase/config.in
@@ -0,0 +1,4 @@
1 config PHASE
2 boolean "Phase Style 0.4 port"
3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 )
diff --git a/noncore/styles/phase/phase.pro b/noncore/styles/phase/phase.pro
new file mode 100644
index 0000000..7ec3d01
--- a/dev/null
+++ b/noncore/styles/phase/phase.pro
@@ -0,0 +1,15 @@
1TEMPLATE = lib
2CONFIG = qt plugin embedded warn_on
3SOURCES = phasestyle.cpp \
4 plugin.cpp
5HEADERS = bitmaps.h \
6 phasestyle.h \
7 plugin.h
8
9LIBS += -lqpe
10INCLUDEPATH += $(OPIEDIR)/include
11DESTDIR = $(OPIEDIR)/plugins/styles
12TARGET = phase
13VERSION = 0.4.0
14
15include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/styles/phase/phasestyle.cpp b/noncore/styles/phase/phasestyle.cpp
new file mode 100644
index 0000000..fb6411c
--- a/dev/null
+++ b/noncore/styles/phase/phasestyle.cpp
@@ -0,0 +1,1221 @@
1//////////////////////////////////////////////////////////////////////////////
2// phasestyle.h
3// -------------------
4// A style for KDE
5// -------------------
6// Copyright (c) 2004 David Johnson <david@usermode.org>
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to
10// deal in the Software without restriction, including without limitation the
11// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12// sell copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25//////////////////////////////////////////////////////////////////////////////
26
27#include "phasestyle.h"
28
29#include "bitmaps.h"
30
31#define INCLUDE_MENUITEM_DEF
32#include <qpopupmenu.h>
33#include <qpushbutton.h>
34#include <qtoolbutton.h>
35#include <qpainter.h>
36#include <qbrush.h>
37#include <qiconset.h>
38#include <qtabbar.h>
39#include <qscrollbar.h>
40
41
42/* Spacing and sizeHint */
43static unsigned contrast = 110;
44
45static const int ITEMFRAME = 1; // menu stuff
46static const int ITEMHMARGIN = 3;
47static const int ITEMVMARGIN = 0;
48
49static const int ARROWMARGIN = 6;
50static const int RIGHTBORDER = 10;
51static const int MINICONSIZE = 12;
52static const int CHECKSIZE = 9;
53static const int SCROLLBAR_EXTENT = 12;
54
55
56/*
57 * Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
58 * LGPLv2 from kdelibs/kdefx/kdrawutil.cpp
59 */
60void kColorBitmaps(QPainter *p, const QColorGroup &g, int x, int y,
61 QBitmap *lightColor, QBitmap *midColor,
62 QBitmap *midlightColor, QBitmap *darkColor,
63 QBitmap *blackColor, QBitmap *whiteColor)
64{
65 QBitmap *bitmaps[]={lightColor, midColor, midlightColor, darkColor,
66 blackColor, whiteColor};
67
68 QColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(),
69 Qt::black, Qt::white};
70
71 int i;
72 for(i=0; i < 6; ++i){
73 if(bitmaps[i]){
74 if(!bitmaps[i]->mask())
75 bitmaps[i]->setMask(*bitmaps[i]);
76 p->setPen(colors[i]);
77 p->drawPixmap(x, y, *bitmaps[i]);
78 }
79 }
80}
81
82
83/*
84 * drawMenuBarItem is not virtual
85 * this way we define our draw handler
86 */
87typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
88 QColorGroup &, bool, bool);
89
90extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
91
92
93PhaseStyle::PhaseStyle()
94 : QWindowsStyle()
95{
96 setName( "PhaseStyle" );
97
98 /* small default sizes */
99 setButtonDefaultIndicatorWidth(1);
100 setScrollBarExtent(SCROLLBAR_EXTENT, SCROLLBAR_EXTENT);
101 setSliderThickness(12);
102 setButtonMargin( 1 );
103
104 // create bitmaps
105 uarrow = QBitmap(6, 6, uarrow_bits, true);
106 uarrow.setMask(uarrow);
107 darrow = QBitmap(6, 6, darrow_bits, true);
108 darrow.setMask(darrow);
109 larrow = QBitmap(6, 6, larrow_bits, true);
110 larrow.setMask(larrow);
111 rarrow = QBitmap(6, 6, rarrow_bits, true);
112 rarrow.setMask(rarrow);
113 bplus = QBitmap(6, 6, bplus_bits, true);
114 bplus.setMask(bplus);
115 bminus = QBitmap(6, 6, bminus_bits, true);
116 bminus.setMask(bminus);
117 bcheck = QBitmap(9, 9, bcheck_bits, true);
118 bcheck.setMask(bcheck);
119 dexpand = QBitmap(9, 9, dexpand_bits, true);
120 dexpand.setMask(dexpand);
121 rexpand = QBitmap(9, 9, rexpand_bits, true);
122 rexpand.setMask(rexpand);
123 doodad_mid = QBitmap(4, 4, doodad_mid_bits, true);
124 doodad_light = QBitmap(4, 4, doodad_light_bits, true);
125}
126
127PhaseStyle::~PhaseStyle() {
128 /* deleted by Qt */
129}
130
131void PhaseStyle::drawCheckMark ( QPainter * p, int x, int y, int w,
132 int h, const QColorGroup & g,
133 bool , bool) {
134 p->setPen(g.text());
135 p->drawPixmap(x+w/2-4, y+h/2-4, bcheck);
136}
137
138void PhaseStyle::drawArrow(QPainter *painter, Qt::ArrowType type, bool down,
139 int x, int y, int w, int h, const QColorGroup &group,
140 bool enabled , const QBrush * ) {
141 switch( type ) {
142 case UpArrow:
143 if (enabled)
144 painter->setPen(down ? group.midlight() : group.dark());
145 else painter->setPen(group.mid());
146 painter->drawPixmap(x+w/2-3, y+h/2-3, uarrow);
147 break;
148 case DownArrow:
149 if (enabled) painter->setPen(down ? group.midlight() : group.dark());
150 else painter->setPen(group.mid());
151 painter->drawPixmap(x+w/2-3, y+h/2-3, darrow);
152 break;
153 case LeftArrow:
154 if (enabled) painter->setPen(down ? group.midlight() : group.dark());
155 else painter->setPen(group.mid());
156 painter->drawPixmap(x+w/2-3, y+h/2-3, larrow);
157 break;
158 case RightArrow:
159 if (enabled) painter->setPen(down ? group.midlight() : group.dark());
160 else painter->setPen(group.mid());
161 painter->drawPixmap(x+w/2-3, y+h/2-3, rarrow);
162 break;
163 }
164}
165
166void PhaseStyle::drawPushButton(QPushButton *btn, QPainter *painter) {
167 QRect r = btn->rect();
168 int x = r.x();
169 int y = r.y();
170 int h = r.height();
171 int w = r.width();
172 bool depress = btn->isOn() || btn->isDown();
173 QColorGroup group = btn->colorGroup();
174 QBrush brush(group.button() );
175// int bd = pixelMetric(PM_ButtonDefaultIndicator, widget) + 1;
176 static int bd = 2;
177
178 if (btn->isDefault() && !depress) {
179 drawPanel(painter, x, y, h, w, group,
180 &group.brush(QColorGroup::Mid), true);
181 drawBevelButton(painter, x+bd, y+bd, w-bd*2, h-bd*2, group,
182 false, &brush );
183 } else {
184 drawButton(painter, x, y, w, h, group, depress,
185 &brush );
186 }
187
188 if (btn->hasFocus() ) { // draw focus
189 QColor col;
190 drawFocusRect(painter, r, group,
191 &col, false );
192 }
193}
194
195
196void PhaseStyle::drawPanel(QPainter* painter, int x, int y, int w, int h,
197 const QColorGroup& group, bool sunken,
198 int , const QBrush* fill) {
199 int x2 = x + w - 1;
200 int y2 = y + h - 1;
201 painter->save();
202
203 if (sunken) {
204 painter->setPen(group.dark());
205 painter->drawRect(x+1, y+1, w-2, h-2);
206 painter->setPen(group.midlight());
207 painter->drawLine(x+1, y2, x2, y2);
208 painter->drawLine(x2, y+1, x2, y2-1);
209 painter->setPen(group.mid());
210 painter->drawLine(x, y, x, y2-1);
211 painter->drawLine(x+1, y, x2-1, y);
212 painter->setPen(group.background());
213 painter->drawPoint(x, y2);
214 painter->drawPoint(x2, y);
215 } else {
216 painter->setPen(group.dark());
217 painter->drawRect(x, y, w, h);
218 painter->setPen(group.midlight());
219 painter->drawLine(x+1, y+1, x2-2, y+1);
220 painter->drawLine(x+1, y+2, x+1, y2-2);
221 painter->setPen(group.mid());
222 painter->drawLine(x+2, y2-1, x2-1, y2-1);
223 painter->drawLine(x2-1, y+2, x2-1, y2-2);
224 painter->setPen(group.background());
225 painter->drawPoint(x+1, y2-1);
226 painter->drawPoint(x2-1, y+1);
227 }
228
229 if (fill) {
230 painter->fillRect(x+2, y+2, w-4, h-4, *fill );
231 }
232 painter->restore();
233}
234
235
236
237void PhaseStyle::drawButton(QPainter *p, int x, int y, int w, int h,
238 const QColorGroup &group, bool sunken ,
239 const QBrush *fill ) {
240 int x2 = x + w - 1;
241 int y2 = y + h - 1;
242
243 p->setPen(group.midlight());
244 p->drawLine(x+1, y2, x2, y2);
245 p->drawLine(x2, y+1, x2, y2-1);
246
247 p->setPen(group.mid());
248 p->drawLine(x, y, x2-1, y);
249 p->drawLine(x, y+1, x, y2-1);
250
251 p->setPen(group.button());
252 p->drawPoint(x, y2);
253 p->drawPoint(x2, y);
254
255 drawBevelButton(p, x+1, y+1, w-2, h-2, group, sunken,
256 fill);
257}
258
259void PhaseStyle::drawButtonMask( QPainter* p, int x, int y,
260 int w, int h ) {
261 QRect rect(x, y, w, h );
262 p->fillRect(rect, Qt::color1);
263 p->setPen(Qt::color0);
264}
265
266
267void PhaseStyle::drawBevelButton(QPainter* p, int x, int y,
268 int w, int h, const QColorGroup& group,
269 bool sunken, const QBrush* fill ) {
270 int x2 = x + w - 1;
271 int y2 = y + h - 1;
272 p->save();
273
274 p->setPen(group.dark());
275 p->drawRect(x, y, w, h);
276
277 p->setPen(sunken ? group.mid() : group.midlight());
278 p->drawLine(x+1, y+1, x2-2, y+1);
279 p->drawLine(x+1, y+2, x+1, y2-2);
280
281 p->setPen(sunken ? group.midlight() : group.mid());
282 p->drawLine(x+2, y2-1, x2-1, y2-1);
283 p->drawLine(x2-1, y+2, x2-1, y2-2);
284
285 p->setPen(group.button());
286 p->drawPoint(x+1, y2-1);
287 p->drawPoint(x2-1, y+1);
288
289 QBrush b = fill ? *fill : group.brush( QColorGroup::Button );
290 if (sunken) {
291 // sunken bevels don't get gradients
292 p->fillRect(x+2, y+2, w-4, h-4, b);
293 } else
294 drawPhaseGradient(p, QRect(x+2, y+2, w-4, h-4), b.color() );
295
296 p->restore();
297}
298
299void PhaseStyle::drawPhaseGradient(QPainter* painter,
300 const QRect& rect,
301 const QColor& color )const {
302 painter->fillRect(rect, color);
303}
304
305void PhaseStyle::polish( QWidget* widget ) {
306 QWindowsStyle::polish(widget );
307
308#if 0
309 if (widget->inherits("QMenuBar") ||
310 widget->inherits("QPopupMenu" ) ||
311 widget->inherits("QToolButton") ||
312 widget->inherits("QHeader" ) ) {
313 widget->setBackgroundMode(QWidget::NoBackground);
314 }
315// else if (widget->inherits("QFrame") ) {
316// widget->installEventFilter(this);
317// }
318#endif
319}
320
321void PhaseStyle::polish( QPalette &pal ) {
322 QWindowsStyle::polish( pal );
323 // lighten up a bit, so the look is not so "crisp"
324 if (QPixmap::defaultDepth() > 8) { // but not on low color displays
325 pal.setColor(QPalette::Disabled, QColorGroup::Dark,
326 pal.color(QPalette::Disabled, QColorGroup::Dark).light(contrast));
327 pal.setColor(QPalette::Active, QColorGroup::Dark,
328 pal.color(QPalette::Active, QColorGroup::Dark).light(contrast));
329 pal.setColor(QPalette::Inactive, QColorGroup::Dark,
330 pal.color(QPalette::Inactive, QColorGroup::Dark).light(contrast));
331 }
332}
333
334void PhaseStyle::polish( QApplication* app ) {
335 QWindowsStyle::polish( app );
336
337 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl)&PhaseStyle::drawMenuBarItem);
338}
339
340void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) {
341 bool active = button->isOn() || button->isDown();
342 QRect r = pushButtonContentsRect( button );
343 QColorGroup group = button->colorGroup();
344 int x, y, w, h;
345 r.rect( &x, &y, &w, &h );
346 bool sunken = false;
347 QIconSet::Mode mode;
348 QPixmap pixmap;
349
350 if (active) {// shift contents
351 x++; y++;
352 sunken = true;
353 }
354
355
356 if (button->isMenuButton()) { // draw the indicator
357 //dx = pixelMetric(PM_MenuButtonIndicator, widget);
358 int dx = menuButtonIndicatorWidth( button->height() );
359 drawArrow(painter, Qt::DownArrow, active,
360 x+w-dx, y+2, dx-4, h-4, group,button->isEnabled() );
361 w -= dx;
362 }
363
364 if (button->iconSet() && !button->iconSet()->isNull()) { // draw icon
365 if (button->isEnabled()) {
366 if (button->hasFocus()) {
367 mode = QIconSet::Active;
368 } else {
369 mode = QIconSet::Normal;
370 }
371 } else {
372 mode = QIconSet::Disabled;
373 }
374
375#if 0
376 if (button->isToggleButton() && button->isOn()) {
377 state = true;
378 } else {
379 state = false;
380 }
381#endif
382
383 pixmap = button->iconSet()->pixmap(QIconSet::Small, mode);
384 if (button->text().isEmpty() && !button->pixmap()) {
385 painter->drawPixmap(x+w/2 - pixmap.width()/2,
386 y+h/2 - pixmap.height()/2, pixmap);
387 } else {
388 painter->drawPixmap(x+4, y+h/2 - pixmap.height()/2, pixmap);
389 }
390 x += pixmap.width() + 4;
391 w -= pixmap.width() + 4;
392 }
393
394 if (active || button->isDefault()) { // default button
395 for(int n=0; n<2; n++) {
396 drawItem(painter, x+n, y, w, h,
397 AlignCenter | ShowPrefix,
398 button->colorGroup(),
399 button->isEnabled(),
400 button->pixmap(),
401 button->text(), -1,
402 (button->isEnabled()) ?
403 &button->colorGroup().buttonText() :
404 &button->colorGroup().mid());
405 }
406 } else { // normal button
407 drawItem(painter, x, y, w, h,
408 AlignCenter | ShowPrefix,
409 button->colorGroup(),
410 button->isEnabled(),
411 button->pixmap(),
412 button->text(), -1,
413 (button->isEnabled()) ?
414 &button->colorGroup().buttonText() :
415 &button->colorGroup().mid());
416 }
417}
418
419
420void PhaseStyle::drawFocusRect(QPainter *painter, const QRect &rect,
421 const QColorGroup &group,
422 const QColor *, bool atBorder) {
423
424
425 QPen old = painter->pen();
426 painter->setPen(group.highlight().dark(contrast));
427 painter->setBrush(NoBrush);
428
429 if ( atBorder )
430 painter->drawRect(QRect(rect.x()+1, rect.y()+1,
431 rect.width()-2, rect.height()-2 ));
432 else
433 painter->drawRect(rect);
434
435
436 painter->setPen(old);
437
438}
439
440void PhaseStyle::drawSeperator( QPainter* painter, int x, int y, int w,
441 int h, const QColorGroup& group, bool,
442 int , int ) {
443 qWarning( "Seperator" );
444 QRect rect(x, y, w, h);
445 int x2 = rect.right();
446 int y2 = rect.bottom();
447
448 painter->setPen(group.dark());
449 if (w < h)
450 painter->drawLine(w/2, y, w/2, y2);
451 else
452 painter->drawLine(x, h/2, x2, h/2);
453}
454
455void PhaseStyle::drawMenuBarItem(QPainter* p, int x, int y, int w, int h,
456 QMenuItem *mi, QColorGroup& g, bool enabled,
457 bool act ) {
458 return QWindowsStyle::drawMenuBarItem(p, x, y, w, h, mi, g, enabled, act);
459}
460
461
462void PhaseStyle::drawIndicator(QPainter* painter, int x, int y, int w, int h,
463 const QColorGroup &group, int state, bool,
464 bool enabled ) {
465 drawPanel(painter, x, y, w, h, group, true, 1, enabled ?
466 &group.brush(QColorGroup::Base) :
467 &group.brush(QColorGroup::Background));
468
469 if (QButton::On == state ) {
470 painter->setPen(group.dark());
471 painter->drawRect(x+3, y+3, w-6, h-6);
472 painter->fillRect(x+4, y+4, w-8, h-8,
473 group.brush(QColorGroup::Highlight));
474 }
475}
476
477
478void PhaseStyle::drawExclusiveIndicator(QPainter* painter, int x, int y, int w, int h,
479 const QColorGroup &group, bool on,
480 bool /*down*/, bool enabled) {
481
482 QRect r(x, y, w, h );
483
484
485 /*
486 * As Polygon and Polyline are broken in Qt2 lets use
487 * something not that spectacilur -> ellipse
488 */
489 painter->save();
490 painter->fillRect(x, y, w, h, group.background());
491
492
493 painter->setBrush(enabled
494 ? group.brush(QColorGroup::Base)
495 : group.brush(QColorGroup::Background));
496 painter->setPen(group.dark());
497
498 if (0 == w % 2) --w;
499 if (0 == h % 2) --h;
500 painter->drawEllipse(x, y, w, h );
501
502 if(on) {
503 painter->setBrush(group.brush(QColorGroup::Highlight));
504 painter->drawEllipse(x+3,y+3,w-6,h-6);
505 }
506
507 painter->restore();
508}
509
510
511/*
512 * Does not get called in QWS as it seems
513 */
514void PhaseStyle::drawExclusiveIndicatorMask(QPainter *painter, int x, int y, int w,
515 int h, bool /*on*/ ) {
516 return;
517
518
519
520 if (0 != w%2) --w;
521 if (0 != h%2) --h;
522
523 QRect r(x, y, w, h );
524 int x2 = r.right();
525 int y2 = r.bottom();
526 int cx = (x + x2) / 2;
527 int cy = (y + y2) / 2;
528 QPointArray parray;
529
530
531 painter->setBrush(Qt::color1);
532 painter->setPen(Qt::color1);
533 parray.putPoints(0, 8,
534 x,cy+1, x,cy, cx,y, cx+1,y,
535 x2,cy, x2,cy+1, cx+1,y2, cx,y2);
536 painter->drawPolygon(parray, 0, 8);
537}
538
539int PhaseStyle::defaultFrameWidth()const {
540 return 1;
541}
542
543int PhaseStyle::popupMenuItemHeight ( bool ,
544 QMenuItem * mi,
545 const QFontMetrics & fm ) {
546 int h = 0;
547 if (mi->custom() ) {
548 h = mi->custom()->sizeHint().height();
549 if (!mi->custom()->fullSpan() )
550 h += ITEMVMARGIN*2 + ITEMFRAME*2;
551 }else if (mi->isSeparator() ) {
552 h = 1;
553 }else {
554 if ( mi->pixmap() ) {
555 h = QMAX(h, mi->pixmap()->height() + ITEMFRAME*2);
556 }else {
557 h = QMAX(h, MINICONSIZE+ITEMFRAME*2 );
558 h = QMAX(h, fm.height()
559 + ITEMVMARGIN*2 + ITEMFRAME*2 );
560 }
561 if ( mi->iconSet() )
562 h = QMAX(h, mi->iconSet()->
563 pixmap(QIconSet::Small, QIconSet::Normal ).height()
564 + ITEMFRAME*2 );
565 }
566
567
568 return h;
569}
570
571int PhaseStyle::extraPopupMenuItemWidth(bool checkable, int maxpmw,
572 QMenuItem* mi, const QFontMetrics& ) {
573 int w = 0;
574 if (mi->isSeparator() )
575 return 3;
576
577 else if ( mi->pixmap() )
578 w = mi->pixmap()->width();
579
580 if (!mi->text().isNull() &&
581 mi->text().find('\t' ) >= 0 )
582 w += 12;
583 else if ( mi->popup() )
584 w += 2*ARROWMARGIN;
585
586 if ( maxpmw )
587 w += maxpmw +4;
588
589
590 if ( maxpmw > 0 || checkable )
591 w += ITEMHMARGIN*2+8;
592
593 w += RIGHTBORDER;
594 return w;
595}
596
597QSize PhaseStyle::indicatorSize()const {
598 return QSize( 11, 11 );
599}
600
601QSize PhaseStyle::exclusiveIndicatorSize()const {
602 return QSize( 11, 11 );
603}
604
605void PhaseStyle::getButtonShift( int &x, int &y ) {
606 x++;
607 y++;
608}
609
610void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable,
611 int maxpmw,int tabwidth,
612 QMenuItem * mi, const QPalette & pal,
613 bool act, bool enabled, int x,
614 int y, int w, int h ) {
615 if ( !mi )
616 return;
617
618 QRect rect(x, y, w, h );
619 int x2, y2;
620 x2 = rect.right();
621 y2 = rect.bottom();
622 const QColorGroup& g = pal.active();
623 QColorGroup itemg = !enabled ? pal.disabled() : pal.active();
624
625 if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20);
626
627 if (act && enabled )
628 p->fillRect(x, y, w, h, g.highlight() );
629 else
630 p->fillRect(x, y, w, h, g.background() );
631
632 // draw seperator
633 if (mi->isSeparator() ) {
634 p->setPen( g.dark() );
635 p->drawLine( x+8, y+1, x+w-8, y+1 );
636
637 p->setPen( g.mid() );
638 p->drawLine( x+8, y, x+w-8, y );
639 p->drawPoint(x+w,y+1);
640
641 p->setPen( g.midlight() );
642 p->drawLine( x+8, y-1, x+w-8, y-1 );
643 p->drawPoint(x+8, y );
644 return;
645 }
646
647 // draw icon
648 QIconSet::Mode mode;
649 if ( mi->iconSet() && !mi->isChecked() ) {
650 if ( act )
651 mode = enabled ? QIconSet::Active : QIconSet::Disabled;
652 else
653 mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
654 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode );
655 QRect pmrect(0, 0, pixmap.width(), pixmap.height() );
656 QRect cr(x, y, maxpmw, h );
657 pmrect.moveCenter( cr.center() );
658 p->drawPixmap(pmrect.topLeft(), pixmap);
659 }
660
661 // draw check
662 if(mi->isChecked() ) {
663 drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled );
664 }
665
666
667 // draw text
668 int xm = maxpmw + 2;
669 int xp = x + xm;
670 int tw = w -xm - 2;
671
672 p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) :
673 g.mid() );
674
675
676 if ( mi->custom() ) {
677 p->save();
678 mi->custom()->paint(p, g, act, enabled,
679 xp, y+1, tw, h-2 );
680 p->restore();
681 }else { // draw label
682 QString text = mi->text();
683 if (!text.isNull() ) {
684 int t = text.find('\t');
685 const int tflags = AlignVCenter | DontClip |
686 ShowPrefix | SingleLine |
687 AlignLeft;
688
689 if (t >= 0) {
690 int tabx = x + w - tabwidth - RIGHTBORDER -
691 ITEMHMARGIN - ITEMFRAME;
692 p->drawText(tabx, y+ITEMVMARGIN, tabwidth,
693 h-2*ITEMVMARGIN, tflags,
694 text.mid(t+1) );
695 text = text.left(t );
696 }
697
698 // draw left label
699 p->drawText(xp, y+ITEMVMARGIN,
700 tw, h-2*ITEMVMARGIN,
701 tflags, text, t);
702 }else if ( mi->pixmap() ) { // pixmap as label
703 QPixmap pixmap = *mi->pixmap();
704 if ( pixmap.depth() == 1 )
705 p->setBackgroundMode( OpaqueMode );
706
707 int dx = ((w-pixmap.width() ) /2 ) +
708 ((w - pixmap.width()) %2 );
709 p->drawPixmap(x+dx, y+ITEMFRAME, pixmap );
710
711 if ( pixmap.depth() == 1 )
712 p->setBackgroundMode( TransparentMode );
713 }
714 }
715
716 if ( mi->popup() ) { // draw submenu arrow
717 int dim = (h-2*ITEMFRAME) / 2;
718 drawArrow( p, RightArrow, false,
719 x+w-ARROWMARGIN-ITEMFRAME-dim,
720 y+h/2-dim/2, dim, dim, g, enabled );
721 }
722}
723
724
725QRect PhaseStyle::comboButtonRect ( int x, int y, int w, int h ) {
726 return QRect(x+2, y+2, w-4-17, h-5 );
727}
728
729void PhaseStyle::drawComboButton( QPainter * p, int x, int y,
730 int w, int h,
731 const QColorGroup & g,
732 bool sunken,
733 bool editable,
734 bool,
735 const QBrush *) {
736 drawButton(p, x, y, w, h, g,
737 sunken, &g.brush(QColorGroup::Button ));
738
739
740 bool odd = (h % 2);
741 drawPanel(p, w-15 , y+(h/2)-3, 10, (odd ? 7 : 6 ),
742 g, true , 1, sunken ? &g.brush(QColorGroup::Midlight)
743 : &g.brush(QColorGroup::Mid) );
744
745 if (editable ) {
746 const int x2 = x+w-1; const int y2 = y+h-1;
747 p->setPen(g.dark());
748 p->drawLine(x2+1, y, x2+1, y2);
749 p->setPen(g.midlight());
750 p->drawLine(x2+2, y, x2+2, y2-1);
751 p->setPen(g.button());
752 p->drawPoint(x2+2, y2);
753 }
754
755 p->setPen(g.buttonText() );
756}
757
758
759void PhaseStyle::drawTab(QPainter* painter, const QTabBar* bar, QTab* tab,
760 bool selected ) {
761 bool edge = false;
762 int x, y, w, h;
763 QRect r = tab->rect();
764 r.rect(&x,&y,&w,&h);
765 const int x2 = x+w-1;
766 const int y2 = y+h-1;
767 const QColorGroup &group = bar->colorGroup();
768
769
770 painter->save();
771
772 // what position is the tab?
773 if ((bar->count() == 1 ))
774 edge = true;
775 else
776 edge = false;
777
778 switch (QTabBar::Shape(bar->shape())) {
779 case QTabBar::RoundedAbove:
780 case QTabBar::TriangularAbove: {
781 if (!selected) { // shorten
782 y += 2; h -= 2;
783 }
784 if (selected) {
785 painter->setPen(Qt::NoPen);
786 painter->fillRect(x+1, y+1, w-1, h-1,
787 group.brush(QColorGroup::Background));
788 } else
789 drawPhaseGradient(painter, QRect(x+1, y+1, w-1, h-2),
790 group.background().dark(contrast) );
791
792
793 // draw tab
794 painter->setPen(group.dark());
795 painter->drawLine(x, y, x, y2-2);
796 painter->drawLine(x+1, y, x2, y);
797 painter->drawLine(x2, y+1, x2, y2-2);
798
799 painter->setPen(group.mid());
800 painter->drawLine(x2-1, y+2, x2-1, y2-2);
801
802 painter->setPen(group.midlight());
803 painter->drawLine(x+1, y+1, x2-2, y+1);
804 if ((selected) || edge) painter->drawLine(x+1, y+2, x+1, y2-2);
805
806 // finish off bottom
807 if (selected) {
808 painter->setPen(group.dark());
809 painter->drawPoint(x, y2-1);
810 painter->drawPoint(x2, y2-1);
811
812 painter->setPen(group.midlight());
813 painter->drawPoint(x, y2);
814 painter->drawLine(x+1, y2-1, x+1, y2);
815 painter->drawPoint(x2, y2);
816
817 painter->setPen(group.mid());
818 painter->drawPoint(x2-1, y2-1);
819
820 if (edge) {
821 painter->setPen(group.dark());
822 painter->drawLine(x, y2-1, x, y2);
823 painter->setPen(group.midlight());
824 painter->drawPoint(x+1, y2);
825 }
826 } else {
827 painter->setPen(group.dark());
828 painter->drawLine(x, y2-1, x2, y2-1);
829
830 painter->setPen(group.midlight());
831 painter->drawLine(x, y2, x2, y2);
832
833 if (edge) {
834 painter->setPen(group.dark());
835 painter->drawLine(x, y2-1, x, y2);
836 }
837 }
838 break;
839 }
840 case QTabBar::RoundedBelow:
841 case QTabBar::TriangularBelow: {
842 painter->setBrush( group.background().dark(contrast));
843 painter->setPen(Qt::NoPen);
844 painter->fillRect(x+1, y+1, w-1, h-1, painter->brush());
845
846 // draw tab
847 painter->setPen(group.dark());
848 painter->drawLine(x, y+1, x, y2);
849 painter->drawLine(x+1, y2, x2, y2);
850 painter->drawLine(x2, y+1, x2, y2-1);
851
852 painter->setPen(group.mid());
853 painter->drawLine(x2-1, y+1, x2-1, y2-1);
854 painter->drawLine(x+2, y2-1, x2-1, y2-1);
855 painter->drawPoint(x, y);
856 painter->drawPoint(x2, y);
857
858 if ((selected) || edge) {
859 painter->setPen(group.midlight());
860 painter->drawLine(x+1, y+1, x+1, y2-2);
861 }
862
863 // finish off top
864 if (selected) {
865 if (edge) {
866 painter->setPen(group.dark());
867 painter->drawPoint(x, y);
868 painter->setPen(group.midlight());
869 painter->drawPoint(x+1, y);
870 }
871 } else {
872 painter->setPen(group.dark());
873 painter->drawLine(x, y+1, x2, y+1);
874
875 painter->setPen(group.mid());
876 painter->drawLine(x, y, x2, y);
877
878 if (edge) {
879 painter->setPen(group.dark());
880 painter->drawPoint(x, y);
881 }
882 }
883 break;
884 }
885 }
886
887 painter->restore();
888}
889
890void PhaseStyle::drawTabMask( QPainter* p, const QTabBar*, QTab* tab,
891 bool ) {
892 p->fillRect(tab->rect(), Qt::color1);
893}
894
895void PhaseStyle::drawToolButton(QPainter * p, int x, int y,
896 int w, int h, const QColorGroup & g,
897 bool sunken,
898 const QBrush * fill ) {
899 QRect r(x, y, w, h );
900 p->fillRect(r, g.background());
901
902 drawPanel(p, x, y, w, h, g, sunken, 1,
903 fill ? fill : &g.brush(QColorGroup::Button) );
904
905
906 p->setPen(g.text() );
907}
908
909
910/*
911 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
912 *
913 * ../web/webstyle.cpp
914 */
915void PhaseStyle::scrollBarMetrics(const QScrollBar* sb, int& sliderMin,
916 int& sliderMax, int &sliderLength,
917 int& buttonDim ) {
918 int maxlen;
919 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
920 int len = (horizontal) ? sb->width() : sb->height();
921 int extent = (horizontal) ? sb->height() : sb->width();
922
923 if (len > (extent - 1) * 2)
924 buttonDim = extent;
925 else
926 buttonDim = len / 2 - 1;
927
928 if (horizontal)
929 sliderMin = buttonDim * 2;
930 else
931 sliderMin = 1;
932
933 maxlen = len - buttonDim * 2 - 1;
934 int div = QMAX(1, (sb->maxValue() - sb->minValue() + sb->pageStep() ) );
935
936 sliderLength =
937 (sb->pageStep() * maxlen) / div;
938
939 if (sliderLength < SCROLLBAR_EXTENT)
940 sliderLength = SCROLLBAR_EXTENT;
941
942 if (sliderLength > maxlen)
943 sliderLength = maxlen;
944
945 sliderMax = sliderMin + maxlen - sliderLength;
946}
947
948void PhaseStyle::drawScrollBarControls( QPainter* p, const QScrollBar *sb,
949 int sliderStart, uint controls,
950 uint activeControl) {
951 const bool horizontal = (sb->orientation() == Qt::Horizontal );
952 int sliderMin, sliderMax, sliderLength, buttonDim;
953 const QColorGroup& g = sb->colorGroup();
954 QRect sub, add, subPage, addPage, slider;
955 int x, y, x2, y2;
956
957 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
958
959 /* lets get the positions */
960 scrollBarItemPositions(sb, horizontal, sliderStart,
961 sliderMax, sliderLength, buttonDim,
962 sub, add, subPage, addPage,
963 slider );
964
965
966 /* sanity */
967 if ( sliderStart > sliderMax )
968 sliderStart = sliderMax;
969
970 // addline
971 if ( controls & AddLine && add.isValid() ) {
972 x = add.x(); y = add.y();
973 x2 = add.width(); y2 = add.height();
974 const bool down = (activeControl & AddLine );
975 drawBevelButton(p, x, y, x2, y2, g, down,
976 &g.brush(QColorGroup::Button));
977
978 Qt::ArrowType arrow = horizontal ? RightArrow : DownArrow;
979 if (down ) {
980 switch (arrow ) {
981 case DownArrow: y++; break;
982 case RightArrow: x++; break;
983 default: break;
984 }
985 }
986 drawArrow( p, arrow, down, x, y, x2, y2, g, true );
987 }
988
989 if ( controls & SubLine && sub.isValid() ) {
990 x = sub.x(); y = sub.y();
991 x2 = sub.width(); y2 = sub.height();
992 const bool down = (activeControl & SubLine );
993 drawBevelButton(p, x, y, x2, y2, g, down,
994 &g.brush(QColorGroup::Button));
995
996 Qt::ArrowType arrow = horizontal ? LeftArrow : UpArrow;
997 if (down ) {
998 switch (arrow ) {
999 case UpArrow: y--; break;
1000 case LeftArrow: x--; break;
1001 default: break;
1002 }
1003 }
1004 drawArrow( p, arrow, down, x, y, x2, y2, g, true );
1005 }
1006
1007 if ( controls & AddPage && addPage.isValid() ) {
1008 x = addPage.x(); y = addPage.y();
1009 x2 = addPage.right(); y2 = addPage.bottom();
1010
1011 p->fillRect(addPage, g.mid());
1012 p->setPen(g.dark());
1013 if (horizontal) { // vertical
1014 p->drawLine(x, y, x2, y);
1015 p->drawLine(x, y2, x2, y2);
1016 } else { // horizontal
1017 p->drawLine(x, y, x, y2);
1018 p->drawLine(x2, y, x2, y2);
1019 }
1020 }
1021
1022 if ( controls & SubPage && subPage.isValid() ) {
1023 x = subPage.x(); y = subPage.y();
1024 x2 = subPage.right(); y2 = subPage.bottom();
1025
1026 p->fillRect(subPage, g.mid());
1027 p->setPen(g.dark());
1028 if (horizontal) { // vertical
1029 p->drawLine(x, y, x2, y);
1030 p->drawLine(x, y2, x2, y2);
1031 } else { // horizontal
1032 p->drawLine(x, y, x, y2);
1033 p->drawLine(x2, y, x2, y2);
1034 }
1035}
1036
1037 if ( controls & Slider && slider.isValid() ) {
1038 x = slider.x(); y = slider.y();
1039 x2 = slider.width(); y2 = slider.height();
1040 const bool down = ( activeControl & Slider );
1041 int cx = x + x2/2 -2; int cy = y + y2/2 -2;
1042
1043 drawBevelButton(p, x, y, x2, y2, g, down,
1044 &g.brush(QColorGroup::Button) );
1045
1046 if (horizontal && (x2 >=20)) {
1047 for (int n = -5; n <= 5; n += 5)
1048 kColorBitmaps(p, g, cx+n, cy,
1049 0, &doodad_mid, &doodad_light, 0, 0, 0);
1050 } else if (!horizontal && (y2 >= 20)) {
1051 for (int n = -5; n <= 5; n += 5)
1052 kColorBitmaps(p, g, cx, cy+n,
1053 0, &doodad_mid, &doodad_light, 0, 0, 0);
1054 }
1055
1056 if ( sb->hasFocus() && down ) {
1057 slider = QRect(slider.x()+2, slider.y()+2,
1058 slider.width()-2, slider.height()-2 );
1059 drawFocusRect(p, slider, g, false );
1060 }
1061
1062 }
1063}
1064
1065/*
1066 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
1067 *
1068 * ../web/webstyle.cpp
1069 */
1070QStyle::ScrollControl PhaseStyle::scrollBarPointOver( const QScrollBar * sb,
1071 int sliderStart,
1072 const QPoint & point ) {
1073 if (!sb->rect().contains(point))
1074 return NoScroll;
1075
1076 int sliderMin, sliderMax, sliderLength, buttonDim;
1077 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim);
1078
1079 if (sb->orientation() == QScrollBar::Horizontal) {
1080 int x = point.x();
1081
1082 if (x <= buttonDim)
1083 return SubLine;
1084 else if (x <= buttonDim * 2)
1085 return AddLine;
1086 else if (x < sliderStart)
1087 return SubPage;
1088 else if (x < sliderStart+sliderLength)
1089 return Slider;
1090 else
1091 return AddPage;
1092 } else {
1093 int y = point.y();
1094
1095 if (y < sliderStart)
1096 return SubPage;
1097 else if (y < sliderStart + sliderLength)
1098 return Slider;
1099 else if (y < sliderMax + sliderLength)
1100 return AddPage;
1101 else if (y < sliderMax + sliderLength + buttonDim)
1102 return SubLine;
1103 else
1104 return AddLine;
1105 }
1106}
1107
1108/*
1109 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
1110 *
1111 * ../web/webstyle.cpp
1112 * scrollBarControlsMetrics
1113 */
1114void PhaseStyle::scrollBarItemPositions( const QScrollBar* sb, const bool horizontal,
1115 int sliderStart, int sliderMax,
1116 int sliderLength, int buttonDim,
1117 QRect &rSub, QRect& rAdd, QRect& rSubPage,
1118 QRect &rAddPage, QRect& rSlider ) {
1119
1120 int len = horizontal ? sb->width() : sb->height();
1121 int extent = horizontal ? sb->height() : sb->width();
1122
1123 QColorGroup g = sb->colorGroup();
1124
1125 if (sliderStart > sliderMax)
1126 sliderStart = sliderMax;
1127
1128 int sliderEnd = sliderStart + sliderLength;
1129
1130 int addX, addY;
1131 int subX, subY;
1132 int subPageX, subPageY, subPageW, subPageH;
1133 int addPageX, addPageY, addPageW, addPageH;
1134 int sliderX, sliderY, sliderW, sliderH;
1135
1136 if (horizontal){
1137 subY = 0;
1138 addY = 0;
1139 subX = 0;
1140 addX = buttonDim;
1141
1142 subPageX = buttonDim * 2;
1143 subPageY = 0;
1144 subPageW = sliderStart - 1;
1145 subPageH = extent;
1146
1147 addPageX = sliderEnd;
1148 addPageY = 0;
1149 addPageW = len - sliderEnd;
1150 addPageH = extent;
1151
1152 sliderX = sliderStart;
1153 sliderY = 0;
1154 sliderW = sliderLength;
1155 sliderH = extent;
1156 }else {
1157 subX = 0;
1158 addX = 0;
1159 subY = len - buttonDim * 2;
1160 addY = len - buttonDim;
1161
1162 subPageX = 0;
1163 subPageY = 0;
1164 subPageW = extent;
1165 subPageH = sliderStart;
1166
1167 addPageX = 0;
1168 addPageY = sliderEnd;
1169 addPageW = extent;
1170 addPageH = subY - sliderEnd;
1171
1172 sliderX = 0;
1173 sliderY = sliderStart;
1174 sliderW = extent;
1175 sliderH = sliderLength;
1176 }
1177
1178 rSub .setRect( subX, subY, buttonDim, buttonDim);
1179 rAdd .setRect( addX, addY, buttonDim, buttonDim);
1180 rSubPage .setRect(subPageX, subPageY, subPageW, subPageH);
1181 rAddPage .setRect(addPageX, addPageY, addPageW, addPageH);
1182 rSlider .setRect( sliderX, sliderY, sliderW, sliderH);
1183
1184}
1185
1186
1187void PhaseStyle::drawSlider (QPainter * p, int x, int y,
1188 int w, int h, const QColorGroup &g,
1189 Orientation o, bool, bool ) {
1190 int cx = x + w/2;
1191 int cy = y + h/2;
1192 QBrush brush = g.brush( QColorGroup::Button );
1193
1194 if ( o == Horizontal ) {
1195 drawBevelButton(p, cx-5, y, 6, h, g, false,
1196 &brush );
1197 drawBevelButton(p, cx, y, 6, h, g, false,
1198 &brush );
1199 }else {
1200 drawBevelButton(p, x, cy-5, w, 6, g, false,
1201 &brush );
1202 drawBevelButton(p, x, cy, w, 6, g, false,
1203 &brush );
1204 }
1205}
1206
1207void PhaseStyle::drawSliderGroove(QPainter* p, int x, int y,
1208 int w, int h, const QColorGroup& g,
1209 QCOORD , Orientation o ) {
1210 int cx = x + w/2;
1211 int cy = y + h/2;
1212
1213 if ( o == Horizontal ) {
1214 y = cy-3; h = 7;
1215 }else {
1216 x = cx-3; w = 7;
1217 }
1218
1219 drawPanel(p, x, y, w, h, g, true, 1,
1220 &g.brush(QColorGroup::Mid ) );
1221}
diff --git a/noncore/styles/phase/phasestyle.h b/noncore/styles/phase/phasestyle.h
new file mode 100644
index 0000000..ab593e6
--- a/dev/null
+++ b/noncore/styles/phase/phasestyle.h
@@ -0,0 +1,166 @@
1//////////////////////////////////////////////////////////////////////////////
2// phasestyle.h
3// -------------------
4// A style for KDE
5// -------------------
6// Copyright (c) 2004 David Johnson <david@usermode.org>
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to
10// deal in the Software without restriction, including without limitation the
11// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12// sell copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25//////////////////////////////////////////////////////////////////////////////
26
27#ifndef PHASESTYLE_H
28#define PHASESTYLE_H
29
30#include <qstyle.h>
31#include <qwindowsstyle.h>
32#include <qcolor.h>
33
34class KPixmap;
35
36class PhaseStyle : public QWindowsStyle
37{
38 Q_OBJECT
39public:
40 PhaseStyle();
41 virtual ~PhaseStyle();
42
43 void polish( QWidget * );
44 void polish( QPalette& );
45 void polish( QApplication* );
46
47
48 void drawCheckMark ( QPainter * p, int x, int y, int w,
49 int h, const QColorGroup & g,
50 bool act, bool dis );
51 void drawArrow(QPainter *p, Qt::ArrowType type, bool down,
52 int x, int y, int w, int h, const QColorGroup &g,
53 bool enabled=true, const QBrush *fill = 0);
54
55 void drawPushButton(QPushButton* btn, QPainter* p );
56 void drawPushButtonLabel(QPushButton* btn, QPainter* p );
57 void drawPanel(QPainter* p, int , int, int, int,
58 const QColorGroup&, bool sunken = false,
59 int lineWidth = 1, const QBrush *b = 0l );
60 void drawButton( QPainter*, int x, int y, int w, int h,
61 const QColorGroup&, bool sunken = false,
62 const QBrush* fill = 0);
63 void drawBevelButton(QPainter*, int, int, int, int,
64 const QColorGroup&, bool sunken = false,
65 const QBrush* fill = 0 );
66 void drawFocusRect( QPainter* p, const QRect& r,
67 const QColorGroup&, const QColor* = 0,
68 bool atBorder = false );
69 void drawButtonMask( QPainter* p, int x, int y,
70 int w, int h );
71
72
73 /* Menu Stuff */
74 void drawSeperator( QPainter* p, int x, int y, int w,
75 int h, const QColorGroup& group, bool sunken = true,
76 int lineWidth = 1, int midLineWidtth = 0 );
77 void drawMenuBarItem(QPainter* p, int x, int y, int w, int h,
78 QMenuItem *mi, QColorGroup& g, bool enabled,
79 bool act);
80
81 /* RadioButton, CheckBox... */
82 void drawIndicator(QPainter* p, int x, int y, int w, int h,
83 const QColorGroup &g, int state, bool down = FALSE,
84 bool enabled = TRUE );
85 void drawExclusiveIndicator( QPainter*, int, int, int, int,
86 const QColorGroup&, bool on,
87 bool down = false,bool enabled = true );
88 void drawExclusiveIndicatorMask (QPainter*, int, int, int, int, bool );
89
90 /* spacing,dimensions */
91 int defaultFrameWidth () const;
92 int popupMenuItemHeight ( bool checkable,
93 QMenuItem * mi,
94 const QFontMetrics & fm );
95 int extraPopupMenuItemWidth(bool checkable, int maxpmw,
96 QMenuItem* mi, const QFontMetrics& fm );
97
98 QSize indicatorSize()const;
99 QSize exclusiveIndicatorSize()const;
100 void getButtonShift( int &x, int &y );
101
102 /* popup drawing */
103 void drawPopupMenuItem ( QPainter * p, bool checkable, int maxpmw,
104 int tab, QMenuItem * mi,
105 const QPalette & pal, bool act,
106 bool enabled, int x, int y,
107 int w, int h );
108
109 /* combo box */
110 QRect comboButtonRect ( int x, int y, int w, int h );
111 void drawComboButton( QPainter * p, int x, int y,
112 int w, int h,
113 const QColorGroup & g,
114 bool sunken = FALSE,
115 bool editable = FALSE,
116 bool enabled = TRUE,
117 const QBrush * fill = 0 );
118
119 /* tabbar */
120 void drawTab(QPainter*, const QTabBar*, QTab*,
121 bool selected );
122 void drawTabMask( QPainter*, const QTabBar*, QTab*,
123 bool );
124
125 /* tool button */
126 void drawToolButton ( QPainter * p, int x, int y,
127 int w, int h,
128 const QColorGroup & g,
129 bool sunken = FALSE,
130 const QBrush * fill = 0 );
131
132 /* scrollbar */
133 void drawScrollBarControls ( QPainter *, const QScrollBar *,
134 int sliderStart, uint controls,
135 uint activeControl );
136 void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int& );
137 QStyle::ScrollControl scrollBarPointOver( const QScrollBar*, int sliderStart,
138 const QPoint& );
139
140 /* slider drawing */
141 void drawSlider ( QPainter * p, int x, int y, int w, int h,
142 const QColorGroup & g, Orientation,
143 bool tickAbove, bool tickBelow );
144
145 void drawSliderGroove ( QPainter * p, int x, int y, int w,
146 int h, const QColorGroup & g,
147 QCOORD c, Orientation );
148private:
149 void drawPhaseGradient(QPainter* p,
150 const QRect& rec,
151 const QColor& col )const;
152 static void scrollBarItemPositions( const QScrollBar *,
153 const bool horizontal,
154 int sliderStart,
155 int sliderMax,
156 int sliderLength,
157 int buttomDim,
158 QRect& sub,
159 QRect& add,
160 QRect& subPage,
161 QRect& addPage,
162 QRect& slider );
163};
164
165
166#endif
diff --git a/noncore/styles/phase/plugin.cpp b/noncore/styles/phase/plugin.cpp
new file mode 100644
index 0000000..8396c0a
--- a/dev/null
+++ b/noncore/styles/phase/plugin.cpp
@@ -0,0 +1,71 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Holger Hans Peter Freyther <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "plugin.h"
30
31#include "phasestyle.h"
32
33#include <qapplication.h>
34
35PhaseStyleImpl::PhaseStyleImpl()
36 : m_style( 0l )
37{}
38
39/* Qt will delete the style */
40PhaseStyleImpl::~PhaseStyleImpl()
41{}
42
43QRESULT PhaseStyleImpl::queryInterface( const QUuid& uuid, QUnknownInterface **iface ) {
44 *iface = 0;
45
46 if ( uuid == IID_QUnknown || uuid == IID_Style)
47 *iface = this;
48 else
49 return QS_FALSE;
50
51 (*iface)->addRef();
52
53 return QS_OK;
54}
55
56QStyle* PhaseStyleImpl::style() {
57 if (!m_style )
58 m_style = new PhaseStyle();
59 return m_style;
60}
61
62QString PhaseStyleImpl::name()const {
63 return qApp->translate("PhaseStyle", "Phase", "Name of the style Phase");
64}
65
66
67Q_EXPORT_INTERFACE()
68{
69 Q_CREATE_INSTANCE( PhaseStyleImpl )
70}
71
diff --git a/noncore/styles/phase/plugin.h b/noncore/styles/phase/plugin.h
new file mode 100644
index 0000000..9340737
--- a/dev/null
+++ b/noncore/styles/phase/plugin.h
@@ -0,0 +1,54 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2004 Holger Hans Peter Freyther <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef PHASESTYLE_PLUGIN_H
30#define PHASESTYLE_PLUGIN_H
31
32#include <qtopia/styleinterface.h>
33
34
35class PhaseStyle;
36
37/**
38 * Factory to create PhaseStyle
39 */
40class PhaseStyleImpl : public StyleInterface {
41public:
42 PhaseStyleImpl();
43 virtual ~PhaseStyleImpl();
44
45 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
46 Q_REFCOUNT
47
48 virtual QStyle *style();
49 virtual QString name()const;
50private:
51 PhaseStyle* m_style;
52};
53
54#endif