summaryrefslogtreecommitdiff
path: root/library/qpestyle.cpp
Unidiff
Diffstat (limited to 'library/qpestyle.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpestyle.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/qpestyle.cpp b/library/qpestyle.cpp
index b61ada4..0566f6b 100644
--- a/library/qpestyle.cpp
+++ b/library/qpestyle.cpp
@@ -1,90 +1,90 @@
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 );
@@ -368,129 +368,129 @@ int QPEStyle::pixelMetric( PixelMetric metric, const QWidget *widget ) const
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() );