summaryrefslogtreecommitdiffstats
path: root/src/styles
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /src/styles
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'src/styles')
-rw-r--r--src/styles/qcdestyle.cpp367
-rw-r--r--src/styles/qcdestyle.h86
-rw-r--r--src/styles/qcommonstyle.cpp2727
-rw-r--r--src/styles/qcommonstyle.h137
-rw-r--r--src/styles/qcompactstyle.cpp321
-rw-r--r--src/styles/qcompactstyle.h75
-rw-r--r--src/styles/qinterlacestyle.cpp805
-rw-r--r--src/styles/qinterlacestyle.h107
-rw-r--r--src/styles/qmotifplusstyle.cpp1584
-rw-r--r--src/styles/qmotifplusstyle.h124
-rw-r--r--src/styles/qmotifstyle.cpp2359
-rw-r--r--src/styles/qmotifstyle.h136
-rw-r--r--src/styles/qplatinumstyle.cpp1557
-rw-r--r--src/styles/qplatinumstyle.h117
-rw-r--r--src/styles/qsgistyle.cpp1468
-rw-r--r--src/styles/qsgistyle.h133
-rw-r--r--src/styles/qstylefactory.cpp268
-rw-r--r--src/styles/qstylefactory.h62
-rw-r--r--src/styles/qstyleinterface_p.h76
-rw-r--r--src/styles/qstyleplugin.cpp185
-rw-r--r--src/styles/qstyleplugin.h72
-rw-r--r--src/styles/qt_styles.pri140
-rw-r--r--src/styles/qwindowsstyle.cpp2161
-rw-r--r--src/styles/qwindowsstyle.h135
24 files changed, 15202 insertions, 0 deletions
diff --git a/src/styles/qcdestyle.cpp b/src/styles/qcdestyle.cpp
new file mode 100644
index 000000000..3a5baf375
--- /dev/null
+++ b/src/styles/qcdestyle.cpp
@@ -0,0 +1,367 @@
+/****************************************************************************
+**
+** Implementation of CDE-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qcdestyle.h"
+
+#if !defined(QT_NO_STYLE_CDE) || defined(QT_PLUGIN)
+
+#include "qpainter.h"
+#include "qdrawutil.h"
+#include "qbutton.h"
+#include <limits.h>
+
+/*!
+ \class TQCDEStyle qcdestyle.h
+ \brief The TQCDEStyle class provides a CDE look and feel.
+
+ \ingroup appearance
+
+ This style provides a slightly improved Motif look similar to some
+ versions of the Common Desktop Environment (CDE). The main
+ differences are thinner frames and more modern radio buttons and
+ checkboxes. Together with a dark background and a bright
+ text/foreground color, the style looks tquite attractive (at least
+ for Motif fans).
+
+ Note that the functions provided by TQCDEStyle are
+ reimplementations of TQStyle functions; see TQStyle for their
+ documentation.
+*/
+
+/*!
+ Constructs a TQCDEStyle.
+
+ If \a useHighlightCols is FALSE (the default), then the style will
+ polish the application's color palette to emulate the Motif way of
+ highlighting, which is a simple inversion between the base and the
+ text color.
+*/
+TQCDEStyle::TQCDEStyle( bool useHighlightCols ) : TQMotifStyle( useHighlightCols )
+{
+}
+
+/*!
+ Destroys the style.
+*/
+TQCDEStyle::~TQCDEStyle()
+{
+}
+
+
+/*!\reimp
+*/
+int TQCDEStyle::pixelMetric( PixelMetric metric, const TQWidget *widget ) const
+{
+ int ret;
+
+ switch( metric ) {
+ case PM_DefaultFrameWidth:
+ ret = 1;
+ break ;
+ case PM_MenuBarFrameWidth:
+ ret = 1;
+ break;
+ case PM_ScrollBarExtent:
+ ret = 13;
+ break;
+ default:
+ ret = TQMotifStyle::pixelMetric( metric, widget );
+ break;
+ }
+ return ret;
+}
+
+/*! \reimp
+*/
+void TQCDEStyle::drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how,
+ const TQStyleOption& opt ) const
+{
+
+ switch( element ) {
+ case CE_MenuBarItem:
+ {
+ if ( how & Style_Active ) // active item
+ qDrawShadePanel( p, r, cg, TRUE, 1,
+ &cg.brush( TQColorGroup::Button ) );
+ else // other item
+ p->fillRect( r, cg.brush( TQColorGroup::Button ) );
+ TQCommonStyle::drawControl( element, p, widget, r, cg, how, opt );
+ break;
+ }
+ default:
+ TQMotifStyle::drawControl( element, p, widget, r, cg, how, opt );
+ break;
+ }
+
+
+}
+
+/*! \reimp
+*/
+void TQCDEStyle::drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch( pe ) {
+ case PE_Indicator: {
+#ifndef QT_NO_BUTTON
+ bool down = flags & Style_Down;
+ bool on = flags & Style_On;
+ bool showUp = !( down ^ on );
+ TQBrush fill = showUp || flags & Style_NoChange ? cg.brush( TQColorGroup::Button ) : cg.brush( TQColorGroup::Mid );
+ qDrawShadePanel( p, r, cg, !showUp, pixelMetric( PM_DefaultFrameWidth ), &cg.brush( TQColorGroup::Button ) );
+
+ if ( !( flags & Style_Off ) ) {
+ TQPointArray a( 7 * 2 );
+ int i, xx, yy;
+ xx = r.x() + 3;
+ yy = r.y() + 5;
+ for ( i = 0; i < 3; i++ ) {
+ a.setPoint( 2 * i, xx, yy );
+ a.setPoint( 2 * i + 1, xx, yy + 2 );
+ xx++; yy++;
+ }
+ yy -= 2;
+ for ( i = 3; i < 7; i++ ) {
+ a.setPoint( 2 * i, xx, yy );
+ a.setPoint( 2 * i + 1, xx, yy + 2 );
+ xx++; yy--;
+ }
+ if ( flags & Style_NoChange )
+ p->setPen( cg.dark() );
+ else
+ p->setPen( cg.foreground() );
+ p->drawLineSegments( a );
+ }
+#endif
+ }
+ break;
+ case PE_ExclusiveIndicator:
+ {
+#define TQCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2)
+ static const TQCOORD pts1[] = { // up left lines
+ 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
+ static const TQCOORD pts4[] = { // bottom right lines
+ 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
+ 11,4, 10,3, 10,2 };
+ static const TQCOORD pts5[] = { // inner fill
+ 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
+ bool down = flags & Style_Down;
+ bool on = flags & Style_On;
+ p->eraseRect( r );
+ TQPointArray a( TQCOORDARRLEN(pts1), pts1 );
+ a.translate( r.x(), r.y() );
+ p->setPen( ( down || on ) ? cg.dark() : cg.light() );
+ p->drawPolyline( a );
+ a.setPoints( TQCOORDARRLEN(pts4), pts4 );
+ a.translate( r.x(), r.y() );
+ p->setPen( ( down || on ) ? cg.light() : cg.dark() );
+ p->drawPolyline( a );
+ a.setPoints( TQCOORDARRLEN(pts5), pts5 );
+ a.translate( r.x(), r.y() );
+ TQColor fillColor = on ? cg.dark() : cg.background();
+ p->setPen( fillColor );
+ p->setBrush( on ? cg.brush( TQColorGroup::Dark ) :
+ cg.brush( TQColorGroup::Background ) );
+ p->drawPolygon( a );
+ break;
+ }
+
+ case PE_ExclusiveIndicatorMask:
+ {
+ static const TQCOORD pts1[] = {
+ // up left lines
+ 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1,
+ // bottom right lines
+ 10,2, 10,3, 11,4, 11,7, 10,8, 10,9, 9,10, 8,10, 7,11, 4,11, 3,10, 2,10
+ };
+ TQPointArray a(TQCOORDARRLEN(pts1), pts1);
+ a.translate(r.x(), r.y());
+ p->setPen(color1);
+ p->setBrush(color1);
+ p->drawPolygon(a);
+ break;
+ }
+ case PE_ArrowUp:
+ case PE_ArrowDown:
+ case PE_ArrowRight:
+ case PE_ArrowLeft: {
+ TQRect rect = r;
+ TQPointArray bFill; // fill polygon
+ TQPointArray bTop; // top shadow.
+ TQPointArray bBot; // bottom shadow.
+ TQPointArray bLeft; // left shadow.
+ TQWMatrix matrix; // xform matrix
+ bool vertical = pe == PE_ArrowUp || pe == PE_ArrowDown;
+ bool horizontal = !vertical;
+ int dim = rect.width() < rect.height() ? rect.width() : rect.height();
+ int colspec = 0x0000; // color specification array
+
+ if ( dim < 2 ) // too small arrow
+ return;
+
+ // adjust size and center (to fix rotation below)
+ if ( rect.width() > dim ) {
+ rect.setX( rect.x() + ( ( rect.width() - dim ) / 2 ) );
+ rect.setWidth( dim );
+ }
+ if ( rect.height() > dim ) {
+ rect.setY( rect.y() + ( ( rect.height() - dim ) / 2 ) );
+ rect.setHeight( dim );
+ }
+
+ if ( dim > 3 ) {
+ bFill.resize( dim & 1 ? 3 : 4 );
+ bTop.resize( 2 );
+ bBot.resize( 2 );
+ bLeft.resize( 2 );
+ bLeft.putPoints( 0, 2, 0, 0, 0, dim-1 );
+ bTop.putPoints( 0, 2, 1, 0, dim-1, dim/2 );
+ bBot.putPoints( 0, 2, 1, dim-1, dim-1, dim/2 );
+
+ if ( dim > 6 ) { // dim>6: must fill interior
+ bFill.putPoints( 0, 2, 1, dim-1, 1, 1 );
+ if ( dim & 1 ) // if size is an odd number
+ bFill.setPoint( 2, dim - 2, dim / 2 );
+ else
+ bFill.putPoints( 2, 2, dim-2, dim/2-1, dim-2, dim/2 );
+ }
+ } else {
+ if ( dim == 3 ) { // 3x3 arrow pattern
+ bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 );
+ bTop .setPoints( 2, 1,0, 1,0 );
+ bBot .setPoints( 2, 1,2, 2,1 );
+ } else { // 2x2 arrow pattern
+ bLeft.setPoints( 2, 0,0, 0,1 );
+ bTop .setPoints( 2, 1,0, 1,0 );
+ bBot .setPoints( 2, 1,1, 1,1 );
+ }
+ }
+
+ if ( pe == PE_ArrowUp || pe == PE_ArrowLeft ) {
+ matrix.translate( rect.x(), rect.y() );
+ if ( vertical ) {
+ matrix.translate( 0, rect.height() - 1 );
+ matrix.rotate( -90 );
+ } else {
+ matrix.translate( rect.width() - 1, rect.height() - 1 );
+ matrix.rotate( 180 );
+ }
+ if ( flags & Style_Down )
+ colspec = horizontal ? 0x2334 : 0x2343;
+ else
+ colspec = horizontal ? 0x1443 : 0x1434;
+ } else if ( pe == PE_ArrowDown || pe == PE_ArrowRight ) {
+ matrix.translate( rect.x(), rect.y() );
+ if ( vertical ) {
+ matrix.translate( rect.width()-1, 0 );
+ matrix.rotate( 90 );
+ }
+ if ( flags & Style_Down )
+ colspec = horizontal ? 0x2443 : 0x2434;
+ else
+ colspec = horizontal ? 0x1334 : 0x1343;
+ }
+
+ TQColor *cols[5];
+ if ( flags & Style_Enabled ) {
+ cols[0] = 0;
+ cols[1] = (TQColor *)&cg.button();
+ cols[2] = (TQColor *)&cg.mid();
+ cols[3] = (TQColor *)&cg.light();
+ cols[4] = (TQColor *)&cg.dark();
+ } else {
+ cols[0] = 0;
+ cols[1] = (TQColor *)&cg.button();
+ cols[2] = (TQColor *)&cg.button();
+ cols[3] = (TQColor *)&cg.button();
+ cols[4] = (TQColor *)&cg.button();
+ }
+
+#define CMID *cols[ (colspec>>12) & 0xf ]
+#define CLEFT *cols[ (colspec>>8) & 0xf ]
+#define CTOP *cols[ (colspec>>4) & 0xf ]
+#define CBOT *cols[ colspec & 0xf ]
+
+ TQPen savePen = p->pen(); // save current pen
+ TQBrush saveBrush = p->brush(); // save current brush
+ TQWMatrix wxm = p->worldMatrix();
+ TQPen pen( NoPen );
+ TQBrush brush = cg.brush( flags & Style_Enabled ? TQColorGroup::Button :
+ TQColorGroup::Mid );
+
+ p->setPen( pen );
+ p->setBrush( brush );
+ p->setWorldMatrix( matrix, TRUE ); // set transformation matrix
+ p->drawPolygon( bFill ); // fill arrow
+ p->setBrush( NoBrush ); // don't fill
+
+ p->setPen( CLEFT );
+ p->drawLineSegments( bLeft );
+ p->setPen( CBOT );
+ p->drawLineSegments( bBot );
+ p->setPen( CTOP );
+ p->drawLineSegments( bTop );
+
+ p->setWorldMatrix( wxm );
+ p->setBrush( saveBrush ); // restore brush
+ p->setPen( savePen ); // restore pen
+
+#undef CMID
+#undef CLEFT
+#undef CTOP
+#undef CBOT
+
+ }
+ break;
+ default:
+ TQMotifStyle::drawPrimitive( pe, p, r, cg, flags, opt );
+ }
+}
+
+#endif
diff --git a/src/styles/qcdestyle.h b/src/styles/qcdestyle.h
new file mode 100644
index 000000000..883d308f5
--- /dev/null
+++ b/src/styles/qcdestyle.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Definition of the CDE-like style class
+**
+** Created : 990513
+**
+** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+
+#ifndef TQCDESTYLE_H
+#define TQCDESTYLE_H
+
+#ifndef QT_H
+#include "qmotifstyle.h"
+#endif // QT_H
+
+#if !defined(QT_NO_STYLE_CDE) || defined(QT_PLUGIN)
+
+#if defined(QT_PLUGIN)
+#define Q_EXPORT_STYLE_CDE
+#else
+#define Q_EXPORT_STYLE_CDE Q_EXPORT
+#endif
+
+class Q_EXPORT_STYLE_CDE TQCDEStyle : public TQMotifStyle
+{
+ Q_OBJECT
+public:
+
+ TQCDEStyle( bool useHighlightCols = FALSE );
+ virtual ~TQCDEStyle();
+
+ int pixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const;
+
+ void drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+};
+
+#endif // QT_NO_STYLE_CDE
+
+#endif // TQCDESTYLE_H
diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp
new file mode 100644
index 000000000..5043ed17a
--- /dev/null
+++ b/src/styles/qcommonstyle.cpp
@@ -0,0 +1,2727 @@
+/****************************************************************************
+**
+** Implementation of the TQCommonStyle class
+**
+** Created : 981231
+**
+** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qcommonstyle.h"
+
+#ifndef QT_NO_STYLE
+
+#include "qmenubar.h"
+#include "qapplication.h"
+#include "qpainter.h"
+#include "qdrawutil.h"
+#include "qpixmap.h"
+#include "qpushbutton.h"
+#include "qtabbar.h"
+#include "qscrollbar.h"
+#include "qtoolbutton.h"
+#include "qtoolbar.h"
+#include "qdockarea.h"
+#include "qheader.h"
+#include "qspinbox.h"
+#include "qrangecontrol.h"
+#include "qgroupbox.h"
+#include "qslider.h"
+#include "qlistview.h"
+#include "qcheckbox.h"
+#include "qradiobutton.h"
+#include "qbitmap.h"
+#include "qprogressbar.h"
+#include "private/qdialogbuttons_p.h"
+#include <limits.h>
+#include <qpixmap.h>
+#include "../widgets/qtitlebar_p.h"
+#include <qtoolbox.h>
+
+/*!
+ \class TQCommonStyle qcommonstyle.h
+ \brief The TQCommonStyle class encapsulates the common Look and Feel of a GUI.
+
+ \ingroup appearance
+
+ This abstract class implements some of the widget's look and feel
+ that is common to all GUI styles provided and shipped as part of
+ TQt.
+
+ All the functions are documented in \l TQStyle.
+*/
+
+/*!
+ \enum TQt::ArrowType
+
+ \value UpArrow
+ \value DownArrow
+ \value LeftArrow
+ \value RightArrow
+
+*/
+
+// the active painter, if any... this is used as an optimzation to
+// avoid creating a painter if we have an active one (since
+// TQStyle::itemRect() needs a painter to operate correctly
+static TQPainter *activePainter = 0;
+
+/*!
+ Constructs a TQCommonStyle.
+*/
+TQCommonStyle::TQCommonStyle() : TQStyle()
+{
+ activePainter = 0;
+}
+
+/*! \reimp */
+TQCommonStyle::~TQCommonStyle()
+{
+ activePainter = 0;
+}
+
+
+static const char * const check_list_controller_xpm[] = {
+"16 16 4 1",
+" c None",
+". c #000000000000",
+"X c #FFFFFFFF0000",
+"o c #C71BC30BC71B",
+" ",
+" ",
+" .......... ",
+" .XXXXXXXX. ",
+" .XXXXXXXX.oo ",
+" .XXXXXXXX.oo ",
+" .XXXXXXXX.oo ",
+" .XXXXXXXX.oo ",
+" .XXXXXXXX.oo ",
+" .XXXXXXXX.oo ",
+" .XXXXXXXX.oo ",
+" ..........oo ",
+" oooooooooo ",
+" oooooooooo ",
+" ",
+" "};
+
+/*! \reimp */
+void TQCommonStyle::drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ activePainter = p;
+
+ switch (pe) {
+#ifndef QT_NO_LISTVIEW
+ case PE_CheckListController: {
+ p->drawPixmap(r, TQPixmap((const char **)check_list_controller_xpm));
+ break; }
+ case PE_CheckListExclusiveIndicator: {
+ TQCheckListItem *item = opt.checkListItem();
+ TQListView *lv = item->listView();
+ if(!item)
+ return;
+ int x = r.x(), y = r.y();
+#define TQCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2)
+ static const TQCOORD pts1[] = { // dark lines
+ 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
+ static const TQCOORD pts2[] = { // black lines
+ 2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 };
+ static const TQCOORD pts3[] = { // background lines
+ 2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 };
+ static const TQCOORD pts4[] = { // white lines
+ 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
+ 11,4, 10,3, 10,2 };
+ // static const TQCOORD pts5[] = { // inner fill
+ // 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
+ //TQPointArray a;
+ // p->eraseRect( x, y, w, h );
+
+ if ( flags & Style_Enabled )
+ p->setPen( cg.text() );
+ else
+ p->setPen( TQPen( lv->palette().color( TQPalette::Disabled, TQColorGroup::Text ) ) );
+ TQPointArray a( TQCOORDARRLEN(pts1), pts1 );
+ a.translate( x, y );
+ //p->setPen( cg.dark() );
+ p->drawPolyline( a );
+ a.setPoints( TQCOORDARRLEN(pts2), pts2 );
+ a.translate( x, y );
+ p->drawPolyline( a );
+ a.setPoints( TQCOORDARRLEN(pts3), pts3 );
+ a.translate( x, y );
+ // p->setPen( black );
+ p->drawPolyline( a );
+ a.setPoints( TQCOORDARRLEN(pts4), pts4 );
+ a.translate( x, y );
+ // p->setPen( blue );
+ p->drawPolyline( a );
+ // a.setPoints( TQCOORDARRLEN(pts5), pts5 );
+ // a.translate( x, y );
+ // TQColor fillColor = isDown() ? g.background() : g.base();
+ // p->setPen( fillColor );
+ // p->setBrush( fillColor );
+ // p->drawPolygon( a );
+ if ( flags & Style_On ) {
+ p->setPen( NoPen );
+ p->setBrush( cg.text() );
+ p->drawRect( x+5, y+4, 2, 4 );
+ p->drawRect( x+4, y+5, 4, 2 );
+ }
+ break; }
+ case PE_CheckListIndicator: {
+ TQCheckListItem *item = opt.checkListItem();
+ TQListView *lv = item->listView();
+ if(!item)
+ return;
+ int x = r.x(), y = r.y(), w = r.width(), h = r.width(), marg = lv->itemMargin();
+
+ if ( flags & Style_Enabled )
+ p->setPen( TQPen( cg.text(), 2 ) );
+ else
+ p->setPen( TQPen( lv->palette().color( TQPalette::Disabled, TQColorGroup::Text ),
+ 2 ) );
+ bool parentControl = FALSE;
+ if ( item->parent() && item->parent()->rtti() == 1 &&
+ ((TQCheckListItem*) item->parent())->type() == TQCheckListItem::Controller )
+ parentControl = TRUE;
+ if ( flags & Style_Selected && !lv->rootIsDecorated() && !parentControl ) {
+ p->fillRect( 0, 0, x + marg + w + 4, item->height(),
+ cg.brush( TQColorGroup::Highlight ) );
+ if ( item->isEnabled() )
+ p->setPen( TQPen( cg.highlightedText(), 2 ) );
+ }
+
+ if ( flags & Style_NoChange )
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->drawRect( x+marg, y+2, w-4, h-4 );
+ /////////////////////
+ x++;
+ y++;
+ if ( ( flags & Style_On) || ( flags & Style_NoChange ) ) {
+ TQPointArray a( 7*2 );
+ int i, xx = x+1+marg, yy=y+5;
+ for ( i=0; i<3; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy++;
+ }
+ yy -= 2;
+ for ( i=3; i<7; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy--;
+ }
+ p->drawLineSegments( a );
+ }
+ break; }
+#endif
+ case PE_HeaderArrow:
+ p->save();
+ if ( flags & Style_Down ) {
+ TQPointArray pa( 3 );
+ p->setPen( cg.light() );
+ p->drawLine( r.x() + r.width(), r.y(), r.x() + r.width() / 2, r.height() );
+ p->setPen( cg.dark() );
+ pa.setPoint( 0, r.x() + r.width() / 2, r.height() );
+ pa.setPoint( 1, r.x(), r.y() );
+ pa.setPoint( 2, r.x() + r.width(), r.y() );
+ p->drawPolyline( pa );
+ } else {
+ TQPointArray pa( 3 );
+ p->setPen( cg.light() );
+ pa.setPoint( 0, r.x(), r.height() );
+ pa.setPoint( 1, r.x() + r.width(), r.height() );
+ pa.setPoint( 2, r.x() + r.width() / 2, r.y() );
+ p->drawPolyline( pa );
+ p->setPen( cg.dark() );
+ p->drawLine( r.x(), r.height(), r.x() + r.width() / 2, r.y() );
+ }
+ p->restore();
+ break;
+
+ case PE_StatusBarSection:
+ qDrawShadeRect( p, r, cg, TRUE, 1, 0, 0 );
+ break;
+
+ case PE_ButtonCommand:
+ case PE_ButtonBevel:
+ case PE_ButtonTool:
+ case PE_ButtonDropDown:
+ case PE_HeaderSection:
+ case PE_HeaderSectionMenu:
+ qDrawShadePanel(p, r, cg, flags & (Style_Sunken | Style_Down | Style_On) , 1,
+ &cg.brush(TQColorGroup::Button));
+ break;
+
+ case PE_Separator:
+ qDrawShadeLine( p, r.left(), r.top(), r.right(), r.bottom(), cg,
+ flags & Style_Sunken, 1, 0);
+ break;
+
+ case PE_FocusRect: {
+ const TQColor *bg = 0;
+
+ if (!opt.isDefault())
+ bg = &opt.color();
+
+ TQPen oldPen = p->pen();
+
+ if (bg) {
+ int h, s, v;
+ bg->hsv(&h, &s, &v);
+ if (v >= 128)
+ p->setPen(TQt::black);
+ else
+ p->setPen(TQt::white);
+ } else
+ p->setPen(cg.foreground());
+
+ if (flags & Style_FocusAtBorder)
+ p->drawRect(TQRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2));
+ else
+ p->drawRect(r);
+
+ p->setPen(oldPen);
+ break; }
+
+ case PE_SpinWidgetPlus:
+ case PE_SpinWidgetMinus: {
+ p->save();
+ int fw = pixelMetric( PM_DefaultFrameWidth, 0 );
+ TQRect br;
+ br.setRect( r.x() + fw, r.y() + fw, r.width() - fw*2,
+ r.height() - fw*2 );
+
+ p->fillRect( br, cg.brush( TQColorGroup::Button ) );
+ p->setPen( cg.buttonText() );
+ p->setBrush( cg.buttonText() );
+
+ int length;
+ int x = r.x(), y = r.y(), w = r.width(), h = r.height();
+ if ( w <= 8 || h <= 6 )
+ length = TQMIN( w-2, h-2 );
+ else
+ length = TQMIN( 2*w / 3, 2*h / 3 );
+
+ if ( !(length & 1) )
+ length -=1;
+ int xmarg = ( w - length ) / 2;
+ int ymarg = ( h - length ) / 2;
+
+ p->drawLine( x + xmarg, ( y + h / 2 - 1 ),
+ x + xmarg + length - 1, ( y + h / 2 - 1 ) );
+ if ( pe == PE_SpinWidgetPlus )
+ p->drawLine( ( x+w / 2 ) - 1, y + ymarg,
+ ( x+w / 2 ) - 1, y + ymarg + length - 1 );
+ p->restore();
+ break; }
+
+ case PE_SpinWidgetUp:
+ case PE_SpinWidgetDown: {
+ int fw = pixelMetric( PM_DefaultFrameWidth, 0 );
+ TQRect br;
+ br.setRect( r.x() + fw, r.y() + fw, r.width() - fw*2,
+ r.height() - fw*2 );
+ p->fillRect( br, cg.brush( TQColorGroup::Button ) );
+ int x = r.x(), y = r.y(), w = r.width(), h = r.height();
+ int sw = w-4;
+ if ( sw < 3 )
+ break;
+ else if ( !(sw & 1) )
+ sw--;
+ sw -= ( sw / 7 ) * 2; // Empty border
+ int sh = sw/2 + 2; // Must have empty row at foot of arrow
+
+ int sx = x + w / 2 - sw / 2 - 1;
+ int sy = y + h / 2 - sh / 2 - 1;
+
+ TQPointArray a;
+ if ( pe == PE_SpinWidgetDown )
+ a.setPoints( 3, 0, 1, sw-1, 1, sh-2, sh-1 );
+ else
+ a.setPoints( 3, 0, sh-1, sw-1, sh-1, sh-2, 1 );
+ int bsx = 0;
+ int bsy = 0;
+ if ( flags & Style_Sunken ) {
+ bsx = pixelMetric(PM_ButtonShiftHorizontal);
+ bsy = pixelMetric(PM_ButtonShiftVertical);
+ }
+ p->save();
+ p->translate( sx + bsx, sy + bsy );
+ p->setPen( cg.buttonText() );
+ p->setBrush( cg.buttonText() );
+ p->drawPolygon( a );
+ p->restore();
+ break; }
+
+ case PE_Indicator: {
+ if (flags & Style_NoChange) {
+ p->setPen(cg.foreground());
+ p->fillRect(r, cg.brush(TQColorGroup::Button));
+ p->drawRect(r);
+ p->drawLine(r.topLeft(), r.bottomRight());
+ } else
+ qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(),
+ cg, flags & (Style_Sunken | Style_On), 1,
+ &cg.brush(TQColorGroup::Button));
+ break; }
+
+ case PE_IndicatorMask: {
+ p->fillRect(r, color1);
+ break; }
+
+ case PE_ExclusiveIndicator: {
+ TQRect ir = r;
+ p->setPen(cg.dark());
+ p->drawArc(r, 0, 5760);
+
+ if (flags & (Style_Sunken | Style_On)) {
+ ir.addCoords(2, 2, -2, -2);
+ p->setBrush(cg.foreground());
+ p->drawEllipse(ir);
+ }
+
+ break; }
+
+ case PE_ExclusiveIndicatorMask: {
+ p->setPen(color1);
+ p->setBrush(color1);
+ p->drawEllipse(r);
+ break; }
+
+ case PE_DockWindowHandle: {
+ bool highlight = flags & Style_On;
+
+ p->save();
+ p->translate( r.x(), r.y() );
+ if ( flags & Style_Horizontal ) {
+ int x = r.width() / 3;
+ if ( r.height() > 4 ) {
+ qDrawShadePanel( p, x, 2, 3, r.height() - 4,
+ cg, highlight, 1, 0 );
+ qDrawShadePanel( p, x+3, 2, 3, r.height() - 4,
+ cg, highlight, 1, 0 );
+ }
+ } else {
+ if ( r.width() > 4 ) {
+ int y = r.height() / 3;
+ qDrawShadePanel( p, 2, y, r.width() - 4, 3,
+ cg, highlight, 1, 0 );
+ qDrawShadePanel( p, 2, y+3, r.width() - 4, 3,
+ cg, highlight, 1, 0 );
+ }
+ }
+ p->restore();
+ break;
+ }
+
+ case PE_DockWindowSeparator: {
+ TQPoint p1, p2;
+ if ( flags & Style_Horizontal ) {
+ p1 = TQPoint( r.width()/2, 0 );
+ p2 = TQPoint( p1.x(), r.height() );
+ } else {
+ p1 = TQPoint( 0, r.height()/2 );
+ p2 = TQPoint( r.width(), p1.y() );
+ }
+ qDrawShadeLine( p, p1, p2, cg, 1, 1, 0 );
+ break; }
+
+ case PE_Panel:
+ case PE_PanelPopup: {
+ int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth)
+ : opt.lineWidth();
+
+ qDrawShadePanel(p, r, cg, (flags & Style_Sunken), lw);
+ break; }
+
+ case PE_PanelDockWindow: {
+ int lw = opt.isDefault() ? pixelMetric(PM_DockWindowFrameWidth)
+ : opt.lineWidth();
+
+ qDrawShadePanel(p, r, cg, FALSE, lw);
+ break; }
+
+ case PE_PanelMenuBar: {
+ int lw = opt.isDefault() ? pixelMetric(PM_MenuBarFrameWidth)
+ : opt.lineWidth();
+
+ qDrawShadePanel(p, r, cg, FALSE, lw, &cg.brush(TQColorGroup::Button));
+ break; }
+
+ case PE_SizeGrip: {
+ p->save();
+
+ int x, y, w, h;
+ r.rect(&x, &y, &w, &h);
+
+ int sw = TQMIN( h,w );
+ if ( h > w )
+ p->translate( 0, h - w );
+ else
+ p->translate( w - h, 0 );
+
+ int sx = x;
+ int sy = y;
+ int s = sw / 3;
+
+ if ( TQApplication::reverseLayout() ) {
+ sx = x + sw;
+ for ( int i = 0; i < 4; ++i ) {
+ p->setPen( TQPen( cg.light(), 1 ) );
+ p->drawLine( x, sy - 1 , sx + 1, sw );
+ p->setPen( TQPen( cg.dark(), 1 ) );
+ p->drawLine( x, sy, sx, sw );
+ p->setPen( TQPen( cg.dark(), 1 ) );
+ p->drawLine( x, sy + 1, sx - 1, sw );
+ sx -= s;
+ sy += s;
+ }
+ } else {
+ for ( int i = 0; i < 4; ++i ) {
+ p->setPen( TQPen( cg.light(), 1 ) );
+ p->drawLine( sx-1, sw, sw, sy-1 );
+ p->setPen( TQPen( cg.dark(), 1 ) );
+ p->drawLine( sx, sw, sw, sy );
+ p->setPen( TQPen( cg.dark(), 1 ) );
+ p->drawLine( sx+1, sw, sw, sy+1 );
+ sx += s;
+ sy += s;
+ }
+ }
+
+ p->restore();
+ break; }
+
+ case PE_CheckMark: {
+ const int markW = r.width() > 7 ? 7 : r.width();
+ const int markH = markW;
+ int posX = r.x() + ( r.width() - markW )/2 + 1;
+ int posY = r.y() + ( r.height() - markH )/2;
+
+ // Could do with some optimizing/caching...
+ TQPointArray a( markH*2 );
+ int i, xx, yy;
+ xx = posX;
+ yy = 3 + posY;
+ for ( i=0; i<markW/2; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy++;
+ }
+ yy -= 2;
+ for ( ; i<markH; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy--;
+ }
+ if ( !(flags & Style_Enabled) && !(flags & Style_On)) {
+ int pnt;
+ p->setPen( cg.highlightedText() );
+ TQPoint offset(1,1);
+ for ( pnt = 0; pnt < (int)a.size(); pnt++ )
+ a[pnt] += offset;
+ p->drawLineSegments( a );
+ for ( pnt = 0; pnt < (int)a.size(); pnt++ )
+ a[pnt] -= offset;
+ }
+ p->setPen( cg.text() );
+ p->drawLineSegments( a );
+ break; }
+
+ case PE_PanelGroupBox: //We really do not need PE_GroupBoxFrame anymore, nasty holdover ###
+ drawPrimitive( PE_GroupBoxFrame, p, r, cg, flags, opt );
+ break;
+ case PE_GroupBoxFrame: {
+#ifndef QT_NO_FRAME
+ if ( opt.isDefault() )
+ break;
+ int lwidth = opt.lineWidth(), mlwidth = opt.midLineWidth();
+ if ( flags & (Style_Sunken|Style_Raised))
+ qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(), cg, flags & Style_Sunken, lwidth, mlwidth );
+ else
+ qDrawPlainRect( p, r.x(), r.y(), r.width(), r.height(), cg.foreground(), lwidth );
+#endif
+ break; }
+
+ case PE_ProgressBarChunk:
+ p->fillRect( r.x(), r.y() + 3, r.width() -2, r.height() - 6,
+ cg.brush(TQColorGroup::Highlight));
+ break;
+
+ case PE_PanelLineEdit:
+ case PE_PanelTabWidget:
+ case PE_WindowFrame:
+ drawPrimitive( PE_Panel, p, r, cg, flags, opt );
+ break;
+
+ case PE_RubberBand:
+ drawPrimitive(PE_FocusRect, p, r, cg, flags, opt);
+ break;
+ default:
+ break;
+ }
+
+ activePainter = 0;
+}
+
+/*! \reimp */
+void TQCommonStyle::drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+#if defined(QT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::drawControl: widget parameter cannot be zero!");
+ return;
+ }
+#endif
+
+ activePainter = p;
+
+ switch (element) {
+ case CE_MenuBarEmptyArea: {
+ TQRegion reg;
+ if(p->hasClipping()) //ick
+ reg = p->clipRegion();
+ else
+ reg = r;
+ ((TQWidget *)widget)->erase( reg );
+ break; }
+ case CE_PushButton:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ TQRect br = r;
+ int dbi = pixelMetric(PM_ButtonDefaultIndicator, widget);
+
+ if (button->isDefault() || button->autoDefault()) {
+ if ( button->isDefault())
+ drawPrimitive(PE_ButtonDefault, p, br, cg, flags);
+
+ br.setCoords(br.left() + dbi,
+ br.top() + dbi,
+ br.right() - dbi,
+ br.bottom() - dbi);
+ }
+
+ p->save();
+ p->setBrushOrigin( -widget->backgroundOffset().x(),
+ -widget->backgroundOffset().y() );
+ drawPrimitive(PE_ButtonCommand, p, br, cg, flags);
+ p->restore();
+#endif
+ break;
+ }
+
+ case CE_PushButtonLabel:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ TQRect ir = r;
+
+ if (button->isDown() || button->isOn()) {
+ flags |= Style_Sunken;
+ ir.moveBy(pixelMetric(PM_ButtonShiftHorizontal, widget),
+ pixelMetric(PM_ButtonShiftVertical, widget));
+ }
+
+ if (button->isMenuButton()) {
+ int mbi = pixelMetric(PM_MenuButtonIndicator, widget);
+ TQRect ar(ir.right() - mbi, ir.y() + 2, mbi - 4, ir.height() - 4);
+ drawPrimitive(PE_ArrowDown, p, ar, cg, flags, opt);
+ ir.setWidth(ir.width() - mbi);
+ }
+
+ int tf=AlignVCenter | ShowPrefix;
+ if (!styleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ tf |= NoAccel;
+
+#ifndef QT_NO_ICONSET
+ if ( button->iconSet() && ! button->iconSet()->isNull() ) {
+ TQIconSet::Mode mode =
+ button->isEnabled() ? TQIconSet::Normal : TQIconSet::Disabled;
+ if ( mode == TQIconSet::Normal && button->hasFocus() )
+ mode = TQIconSet::Active;
+
+ TQIconSet::State state = TQIconSet::Off;
+ if ( button->isToggleButton() && button->isOn() )
+ state = TQIconSet::On;
+
+ TQPixmap pixmap = button->iconSet()->pixmap( TQIconSet::Small, mode, state );
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+
+ //Center the icon if there is neither text nor pixmap
+ if ( button->text().isEmpty() && !button->pixmap() )
+ p->drawPixmap( ir.x() + ir.width() / 2 - pixw / 2, ir.y() + ir.height() / 2 - pixh / 2, pixmap );
+ else
+ p->drawPixmap( ir.x() + 2, ir.y() + ir.height() / 2 - pixh / 2, pixmap );
+
+ ir.moveBy(pixw + 4, 0);
+ ir.setWidth(ir.width() - (pixw + 4));
+ // left-align text if there is
+ if (!button->text().isEmpty())
+ tf |= AlignLeft;
+ else if (button->pixmap())
+ tf |= AlignHCenter;
+ } else
+#endif //QT_NO_ICONSET
+ tf |= AlignHCenter;
+ drawItem(p, ir, tf, cg,
+ flags & Style_Enabled, button->pixmap(), button->text(),
+ button->text().length(), &(cg.buttonText()) );
+
+ if (flags & Style_HasFocus)
+ drawPrimitive(PE_FocusRect, p, subRect(SR_PushButtonFocusRect, widget),
+ cg, flags);
+#endif
+ break;
+ }
+
+ case CE_CheckBox:
+ drawPrimitive(PE_Indicator, p, r, cg, flags, opt);
+ break;
+
+ case CE_CheckBoxLabel:
+ {
+#ifndef QT_NO_CHECKBOX
+ const TQCheckBox *checkbox = (const TQCheckBox *) widget;
+
+ int alignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft;
+ if (!styleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ alignment |= NoAccel;
+
+ drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
+ flags & Style_Enabled, checkbox->pixmap(), checkbox->text());
+
+ if (flags & Style_HasFocus) {
+ TQRect fr = visualRect(subRect(SR_CheckBoxFocusRect, widget), widget);
+ drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CE_RadioButton:
+ drawPrimitive(PE_ExclusiveIndicator, p, r, cg, flags, opt);
+ break;
+
+ case CE_RadioButtonLabel:
+ {
+#ifndef QT_NO_RADIOBUTTON
+ const TQRadioButton *radiobutton = (const TQRadioButton *) widget;
+
+ int alignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft;
+ if (!styleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ alignment |= NoAccel;
+ drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
+ flags & Style_Enabled, radiobutton->pixmap(), radiobutton->text());
+
+ if (flags & Style_HasFocus) {
+ TQRect fr = visualRect(subRect(SR_RadioButtonFocusRect, widget), widget);
+ drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+#ifndef QT_NO_TABBAR
+ case CE_TabBarTab:
+ {
+ const TQTabBar * tb = (const TQTabBar *) widget;
+
+ if ( tb->shape() == TQTabBar::TriangularAbove ||
+ tb->shape() == TQTabBar::TriangularBelow ) {
+ // triangular, above or below
+ int y;
+ int x;
+ TQPointArray a( 10 );
+ a.setPoint( 0, 0, -1 );
+ a.setPoint( 1, 0, 0 );
+ y = r.height()-2;
+ x = y/3;
+ a.setPoint( 2, x++, y-1 );
+ a.setPoint( 3, x++, y );
+ a.setPoint( 3, x++, y++ );
+ a.setPoint( 4, x, y );
+
+ int i;
+ int right = r.width() - 1;
+ for ( i = 0; i < 5; i++ )
+ a.setPoint( 9-i, right - a.point( i ).x(), a.point( i ).y() );
+
+ if ( tb->shape() == TQTabBar::TriangularAbove )
+ for ( i = 0; i < 10; i++ )
+ a.setPoint( i, a.point(i).x(),
+ r.height() - 1 - a.point( i ).y() );
+
+ a.translate( r.left(), r.top() );
+
+ if ( flags & Style_Selected )
+ p->setBrush( cg.base() );
+ else
+ p->setBrush( cg.background() );
+ p->setPen( cg.foreground() );
+ p->drawPolygon( a );
+ p->setBrush( NoBrush );
+ }
+ break;
+ }
+
+ case CE_TabBarLabel:
+ {
+ if ( opt.isDefault() )
+ break;
+
+ const TQTabBar * tb = (const TQTabBar *) widget;
+ TQTab * t = opt.tab();
+
+ TQRect tr = r;
+ if ( t->identifier() == tb->currentTab() )
+ tr.setBottom( tr.bottom() -
+ pixelMetric( TQStyle::PM_DefaultFrameWidth, tb ) );
+
+ int alignment = AlignCenter | ShowPrefix;
+ if (!styleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ alignment |= NoAccel;
+ drawItem( p, tr, alignment, cg,
+ flags & Style_Enabled, 0, t->text() );
+
+ if ( (flags & Style_HasFocus) && !t->text().isEmpty() )
+ drawPrimitive( PE_FocusRect, p, r, cg );
+ break;
+ }
+#endif // QT_NO_TABBAR
+#ifndef QT_NO_TOOLBOX
+ case CE_ToolBoxTab:
+ {
+ int d = 20 + r.height() - 3;
+ TQPointArray a( 7 );
+ a.setPoint( 0, -1, r.height() + 1 );
+ a.setPoint( 1, -1, 1 );
+ a.setPoint( 2, r.width() - d, 1 );
+ a.setPoint( 3, r.width() - 20, r.height() - 2 );
+ a.setPoint( 4, r.width() - 1, r.height() - 2 );
+ a.setPoint( 5, r.width() - 1, r.height() + 1 );
+ a.setPoint( 6, -1, r.height() + 1 );
+
+ const TQToolBox *tb = (const TQToolBox*)widget;
+
+ if ( flags & Style_Selected && tb->currentItem() )
+ p->setBrush( tb->currentItem()->paletteBackgroundColor() );
+ else
+ p->setBrush( cg.brush(TQColorGroup::Background) );
+
+ p->setPen( cg.mid().dark( 150 ) );
+ p->drawPolygon( a );
+ p->setPen( cg.light() );
+ p->drawLine( 0, 2, r.width() - d, 2 );
+ p->drawLine( r.width() - d - 1, 2, r.width() - 21, r.height() - 1 );
+ p->drawLine( r.width() - 20, r.height() - 1, r.width(), r.height() - 1 );
+ p->setBrush( NoBrush );
+ break;
+ }
+#endif // QT_NO_TOOLBOX
+ case CE_ProgressBarGroove:
+ qDrawShadePanel(p, r, cg, TRUE, 1, &cg.brush(TQColorGroup::Background));
+ break;
+
+#ifndef QT_NO_PROGRESSBAR
+ case CE_ProgressBarContents:
+ {
+ const TQProgressBar *progressbar = (const TQProgressBar *) widget;
+ // Correct the highlight color if same as background,
+ // or else we cannot see the progress...
+ TQColorGroup cgh = cg;
+ if ( cgh.highlight() == cgh.background() )
+ cgh.setColor( TQColorGroup::Highlight, progressbar->palette().active().highlight() );
+ bool reverse = TQApplication::reverseLayout();
+ int fw = 2;
+ int w = r.width() - 2*fw;
+ if ( !progressbar->totalSteps() ) {
+ // draw busy indicator
+ int x = progressbar->progress() % (w * 2);
+ if (x > w)
+ x = 2 * w - x;
+ x = reverse ? r.right() - x : x + r.x();
+ p->setPen( TQPen(cgh.highlight(), 4) );
+ p->drawLine(x, r.y() + 1, x, r.height() - fw);
+ } else {
+ const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, widget);
+ int u;
+ if ( unit_width > 1 )
+ u = (r.width()+unit_width/3) / unit_width;
+ else
+ u = w / unit_width;
+ int p_v = progressbar->progress();
+ int t_s = progressbar->totalSteps() ? progressbar->totalSteps() : 1;
+
+ if ( u > 0 && p_v >= INT_MAX / u && t_s >= u ) {
+ // scale down to something usable.
+ p_v /= u;
+ t_s /= u;
+ }
+
+ // nu < tnu, if last chunk is only a partial chunk
+ int tnu, nu;
+ tnu = nu = p_v * u / t_s;
+
+ if (nu * unit_width > w)
+ nu--;
+
+ // Draw nu units out of a possible u of unit_width
+ // width, each a rectangle bordered by background
+ // color, all in a sunken panel with a percentage text
+ // display at the end.
+ int x = 0;
+ int x0 = reverse ? r.right() - ((unit_width > 1) ?
+ unit_width : fw) : r.x() + fw;
+ for (int i=0; i<nu; i++) {
+ drawPrimitive( PE_ProgressBarChunk, p,
+ TQRect( x0+x, r.y(), unit_width, r.height() ),
+ cgh, Style_Default, opt );
+ x += reverse ? -unit_width: unit_width;
+ }
+
+ // Draw the last partial chunk to fill up the
+ // progressbar entirely
+ if (nu < tnu) {
+ int pixels_left = w - (nu*unit_width);
+ int offset = reverse ? x0+x+unit_width-pixels_left : x0+x;
+ drawPrimitive( PE_ProgressBarChunk, p,
+ TQRect( offset, r.y(), pixels_left,
+ r.height() ), cgh, Style_Default,
+ opt );
+ }
+ }
+ }
+ break;
+
+ case CE_ProgressBarLabel:
+ {
+ const TQProgressBar *progressbar = (const TQProgressBar *) widget;
+ TQColor penColor = cg.highlightedText();
+ TQColor *pcolor = 0;
+ if ( progressbar->centerIndicator() && !progressbar->indicatorFollowsStyle() &&
+ progressbar->progress()*2 >= progressbar->totalSteps() )
+ pcolor = &penColor;
+ drawItem(p, r, AlignCenter | SingleLine, cg, flags & Style_Enabled, 0,
+ progressbar->progressString(), -1, pcolor );
+ }
+ break;
+#endif // QT_NO_PROGRESSBAR
+
+ case CE_MenuBarItem:
+ {
+#ifndef QT_NO_MENUDATA
+ if (opt.isDefault())
+ break;
+
+ TQMenuItem *mi = opt.menuItem();
+ int alignment = AlignCenter|ShowPrefix|DontClip|SingleLine;
+ if (!styleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ alignment |= NoAccel;
+ drawItem( p, r, alignment, cg,
+ flags & Style_Enabled, mi->pixmap(), mi->text(), -1,
+ &cg.buttonText() );
+#endif
+ break;
+ }
+
+#ifndef QT_NO_TOOLBUTTON
+ case CE_ToolButtonLabel:
+ {
+ const TQToolButton *toolbutton = (const TQToolButton *) widget;
+ TQRect rect = r;
+ TQt::ArrowType arrowType = opt.isDefault()
+ ? TQt::DownArrow : opt.arrowType();
+
+ int shiftX = 0;
+ int shiftY = 0;
+ if (flags & (Style_Down | Style_On)) {
+ shiftX = pixelMetric(PM_ButtonShiftHorizontal, widget);
+ shiftY = pixelMetric(PM_ButtonShiftVertical, widget);
+ }
+
+ if (!opt.isDefault()) {
+ PrimitiveElement pe;
+ switch (arrowType) {
+ case TQt::LeftArrow: pe = PE_ArrowLeft; break;
+ case TQt::RightArrow: pe = PE_ArrowRight; break;
+ case TQt::UpArrow: pe = PE_ArrowUp; break;
+ default:
+ case TQt::DownArrow: pe = PE_ArrowDown; break;
+ }
+
+ rect.moveBy(shiftX, shiftY);
+ drawPrimitive(pe, p, rect, cg, flags, opt);
+ } else {
+ TQColor btext = toolbutton->paletteForegroundColor();
+
+ if (toolbutton->iconSet().isNull() &&
+ ! toolbutton->text().isNull() &&
+ ! toolbutton->usesTextLabel()) {
+ int alignment = AlignCenter | ShowPrefix;
+ if (!styleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ alignment |= NoAccel;
+
+ rect.moveBy(shiftX, shiftY);
+ drawItem(p, rect, alignment, cg,
+ flags & Style_Enabled, 0, toolbutton->text(),
+ toolbutton->text().length(), &btext);
+ } else {
+ TQPixmap pm;
+ TQIconSet::Size size =
+ toolbutton->usesBigPixmap() ? TQIconSet::Large : TQIconSet::Small;
+ TQIconSet::State state =
+ toolbutton->isOn() ? TQIconSet::On : TQIconSet::Off;
+ TQIconSet::Mode mode;
+ if (! toolbutton->isEnabled())
+ mode = TQIconSet::Disabled;
+ else if (flags & (Style_Down | Style_On) ||
+ (flags & Style_Raised) && (flags & Style_AutoRaise))
+ mode = TQIconSet::Active;
+ else
+ mode = TQIconSet::Normal;
+ pm = toolbutton->iconSet().pixmap( size, mode, state );
+
+ if ( toolbutton->usesTextLabel() ) {
+ p->setFont( toolbutton->font() );
+ TQRect pr = rect, tr = rect;
+ int alignment = ShowPrefix;
+ if (!styleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ alignment |= NoAccel;
+
+ if ( toolbutton->textPosition() == TQToolButton::Under ) {
+ int fh = p->fontMetrics().height();
+ pr.addCoords( 0, 1, 0, -fh-3 );
+ tr.addCoords( 0, pr.bottom(), 0, -3 );
+ pr.moveBy(shiftX, shiftY);
+ drawItem( p, pr, AlignCenter, cg, TRUE, &pm, TQString::null );
+ alignment |= AlignCenter;
+ } else {
+ pr.setWidth( pm.width() + 8 );
+ tr.addCoords( pr.right(), 0, 0, 0 );
+ pr.moveBy(shiftX, shiftY);
+
+ drawItem( p, pr, AlignCenter, cg, TRUE, &pm, TQString::null );
+ alignment |= AlignLeft | AlignVCenter;
+ }
+
+ tr.moveBy(shiftX, shiftY);
+ drawItem( p, tr, alignment, cg,
+ flags & Style_Enabled, 0, toolbutton->textLabel(),
+ toolbutton->textLabel().length(), &btext);
+ } else {
+ rect.moveBy(shiftX, shiftY);
+ drawItem( p, rect, AlignCenter, cg, TRUE, &pm, TQString::null );
+ }
+ }
+ }
+
+ break;
+ }
+#endif // QT_NO_TOOLBUTTON
+#ifndef QT_NO_HEADER
+ case CE_HeaderLabel:
+ {
+ TQRect rect = r;
+ const TQHeader* header = (const TQHeader *) widget;
+ int section = opt.headerSection();
+
+ TQIconSet* icon = header->iconSet( section );
+ if ( icon ) {
+ TQPixmap pixmap = icon->pixmap( TQIconSet::Small,
+ flags & Style_Enabled ?
+ TQIconSet::Normal : TQIconSet::Disabled );
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ // "pixh - 1" because of tricky integer division
+
+ TQRect pixRect = rect;
+ pixRect.setY( rect.center().y() - (pixh - 1) / 2 );
+ drawItem ( p, pixRect, AlignVCenter, cg, flags & Style_Enabled,
+ &pixmap, TQString::null );
+ if (TQApplication::reverseLayout())
+ rect.setRight(rect.right() - pixw - 2);
+ else
+ rect.setLeft(rect.left() + pixw + 2);
+ }
+
+ if (rect.isValid())
+ drawItem ( p, rect, AlignVCenter, cg, flags & Style_Enabled,
+ 0, header->label( section ), -1, &(cg.buttonText()) );
+ }
+#endif // QT_NO_HEADER
+ default:
+ break;
+ }
+
+ activePainter = 0;
+}
+
+/*! \reimp */
+void TQCommonStyle::drawControlMask( ControlElement control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQStyleOption& opt ) const
+{
+ Q_UNUSED(widget);
+
+ activePainter = p;
+
+ TQColorGroup cg(color1,color1,color1,color1,color1,color1,color1,color1,color0);
+
+ switch (control) {
+ case CE_PushButton:
+ drawPrimitive(PE_ButtonCommand, p, r, cg, Style_Default, opt);
+ break;
+
+ case CE_CheckBox:
+ drawPrimitive(PE_IndicatorMask, p, r, cg, Style_Default, opt);
+ break;
+
+ case CE_RadioButton:
+ drawPrimitive(PE_ExclusiveIndicatorMask, p, r, cg, Style_Default, opt);
+ break;
+
+ default:
+ p->fillRect(r, color1);
+ break;
+ }
+
+ activePainter = 0;
+}
+
+/*! \reimp */
+TQRect TQCommonStyle::subRect(SubRect r, const TQWidget *widget) const
+{
+#if defined(QT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::subRect: widget parameter cannot be zero!");
+ return TQRect();
+ }
+#endif
+
+ TQRect rect, wrect(widget->rect());
+
+ switch (r) {
+#ifndef QT_NO_DIALOGBUTTONS
+ case SR_DialogButtonAbort:
+ case SR_DialogButtonRetry:
+ case SR_DialogButtonIgnore:
+ case SR_DialogButtonAccept:
+ case SR_DialogButtonReject:
+ case SR_DialogButtonApply:
+ case SR_DialogButtonHelp:
+ case SR_DialogButtonAll:
+ case SR_DialogButtonCustom: {
+ TQDialogButtons::Button srch = TQDialogButtons::None;
+ if(r == SR_DialogButtonAccept)
+ srch = TQDialogButtons::Accept;
+ else if(r == SR_DialogButtonReject)
+ srch = TQDialogButtons::Reject;
+ else if(r == SR_DialogButtonAll)
+ srch = TQDialogButtons::All;
+ else if(r == SR_DialogButtonApply)
+ srch = TQDialogButtons::Apply;
+ else if(r == SR_DialogButtonHelp)
+ srch = TQDialogButtons::Help;
+ else if(r == SR_DialogButtonRetry)
+ srch = TQDialogButtons::Retry;
+ else if(r == SR_DialogButtonIgnore)
+ srch = TQDialogButtons::Ignore;
+ else if(r == SR_DialogButtonAbort)
+ srch = TQDialogButtons::Abort;
+
+ const int bwidth = pixelMetric(PM_DialogButtonsButtonWidth, widget),
+ bheight = pixelMetric(PM_DialogButtonsButtonHeight, widget),
+ bspace = pixelMetric(PM_DialogButtonsSeparator, widget),
+ fw = pixelMetric(PM_DefaultFrameWidth, widget);
+ const TQDialogButtons *dbtns = (const TQDialogButtons *) widget;
+ int start = fw;
+ if(dbtns->orientation() == Horizontal)
+ start = wrect.right() - fw;
+ TQDialogButtons::Button btns[] = { TQDialogButtons::All, TQDialogButtons::Reject, TQDialogButtons::Accept, //reverse order (right to left)
+ TQDialogButtons::Apply, TQDialogButtons::Retry, TQDialogButtons::Ignore, TQDialogButtons::Abort,
+ TQDialogButtons::Help };
+ for(unsigned int i = 0, cnt = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) {
+ if(dbtns->isButtonVisible(btns[i])) {
+ TQSize szH = dbtns->sizeHint(btns[i]);
+ int mwidth = TQMAX(bwidth, szH.width()), mheight = TQMAX(bheight, szH.height());
+ if(dbtns->orientation() == Horizontal) {
+ start -= mwidth;
+ if(cnt)
+ start -= bspace;
+ } else if(cnt) {
+ start += mheight;
+ start += bspace;
+ }
+ cnt++;
+ if(btns[i] == srch) {
+ if(dbtns->orientation() == Horizontal)
+ return TQRect(start, wrect.bottom() - fw - mheight, mwidth, mheight);
+ else
+ return TQRect(fw, start, mwidth, mheight);
+ }
+ }
+ }
+ if(r == SR_DialogButtonCustom) {
+ if(dbtns->orientation() == Horizontal)
+ return TQRect(fw, fw, start - fw - bspace, wrect.height() - (fw*2));
+ else
+ return TQRect(fw, start, wrect.width() - (fw*2), wrect.height() - start - (fw*2));
+ }
+ return TQRect(); }
+#endif //QT_NO_DIALOGBUTTONS
+ case SR_PushButtonContents:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ int dx1, dx2;
+
+ dx1 = pixelMetric(PM_DefaultFrameWidth, widget);
+ if (button->isDefault() || button->autoDefault())
+ dx1 += pixelMetric(PM_ButtonDefaultIndicator, widget);
+ dx2 = dx1 * 2;
+
+ rect.setRect(wrect.x() + dx1,
+ wrect.y() + dx1,
+ wrect.width() - dx2,
+ wrect.height() - dx2);
+#endif
+ break;
+ }
+
+ case SR_PushButtonFocusRect:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ int dbw1 = 0, dbw2 = 0;
+ if (button->isDefault() || button->autoDefault()) {
+ dbw1 = pixelMetric(PM_ButtonDefaultIndicator, widget);
+ dbw2 = dbw1 * 2;
+ }
+
+ int dfw1 = pixelMetric(PM_DefaultFrameWidth, widget) * 2,
+ dfw2 = dfw1 * 2;
+
+ rect.setRect(wrect.x() + dfw1 + dbw1,
+ wrect.y() + dfw1 + dbw1,
+ wrect.width() - dfw2 - dbw2,
+ wrect.height() - dfw2 - dbw2);
+#endif
+ break;
+ }
+
+ case SR_CheckBoxIndicator:
+ {
+ int h = pixelMetric( PM_IndicatorHeight, widget );
+ rect.setRect(0, ( wrect.height() - h ) / 2,
+ pixelMetric( PM_IndicatorWidth, widget ), h );
+ break;
+ }
+
+ case SR_CheckBoxContents:
+ {
+#ifndef QT_NO_CHECKBOX
+ TQRect ir = subRect(SR_CheckBoxIndicator, widget);
+ rect.setRect(ir.right() + 6, wrect.y(),
+ wrect.width() - ir.width() - 6, wrect.height());
+#endif
+ break;
+ }
+
+ case SR_CheckBoxFocusRect:
+ {
+#ifndef QT_NO_CHECKBOX
+ const TQCheckBox *checkbox = (const TQCheckBox *) widget;
+ if ( !checkbox->pixmap() && checkbox->text().isEmpty() ) {
+ rect = subRect( SR_CheckBoxIndicator, widget );
+ rect.addCoords( 1, 1, -1, -1 );
+ break;
+ }
+ TQRect cr = subRect(SR_CheckBoxContents, widget);
+
+ // don't create a painter if we have an active one
+ TQPainter *p = 0;
+ if (! activePainter)
+ p = new TQPainter(checkbox);
+ rect = itemRect((activePainter ? activePainter : p),
+ cr, AlignLeft | AlignVCenter | ShowPrefix,
+ checkbox->isEnabled(),
+ checkbox->pixmap(),
+ checkbox->text());
+
+ delete p;
+
+ rect.addCoords( -3, -2, 3, 2 );
+ rect = rect.intersect(wrect);
+#endif
+ break;
+ }
+
+ case SR_RadioButtonIndicator:
+ {
+ int h = pixelMetric( PM_ExclusiveIndicatorHeight, widget );
+ rect.setRect(0, ( wrect.height() - h ) / 2,
+ pixelMetric( PM_ExclusiveIndicatorWidth, widget ), h );
+ break;
+ }
+
+ case SR_RadioButtonContents:
+ {
+ TQRect ir = subRect(SR_RadioButtonIndicator, widget);
+ rect.setRect(ir.right() + 6, wrect.y(),
+ wrect.width() - ir.width() - 6, wrect.height());
+ break;
+ }
+
+ case SR_RadioButtonFocusRect:
+ {
+#ifndef QT_NO_RADIOBUTTON
+ const TQRadioButton *radiobutton = (const TQRadioButton *) widget;
+ if ( !radiobutton->pixmap() && radiobutton->text().isEmpty() ) {
+ rect = subRect( SR_RadioButtonIndicator, widget );
+ rect.addCoords( 1, 1, -1, -1 );
+ break;
+ }
+ TQRect cr = subRect(SR_RadioButtonContents, widget);
+
+ // don't create a painter if we have an active one
+ TQPainter *p = 0;
+ if (! activePainter)
+ p = new TQPainter(radiobutton);
+ rect = itemRect((activePainter ? activePainter : p),
+ cr, AlignLeft | AlignVCenter | ShowPrefix,
+ radiobutton->isEnabled(),
+ radiobutton->pixmap(),
+ radiobutton->text());
+ delete p;
+
+ rect.addCoords( -3, -2, 3, 2 );
+ rect = rect.intersect(wrect);
+#endif
+ break;
+ }
+
+ case SR_ComboBoxFocusRect:
+ rect.setRect(3, 3, widget->width()-6-16, widget->height()-6);
+ break;
+
+#ifndef QT_NO_SLIDER
+ case SR_SliderFocusRect:
+ {
+ const TQSlider * sl = (const TQSlider *) widget;
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, sl );
+ int thickness = pixelMetric( PM_SliderControlThickness, sl );
+
+ if ( sl->orientation() == Horizontal )
+ rect.setRect( 0, tickOffset-1, sl->width(), thickness+2 );
+ else
+ rect.setRect( tickOffset-1, 0, thickness+2, sl->height() );
+ rect = rect.intersect( sl->rect() ); // ## is this really necessary?
+ break;
+ }
+#endif // QT_NO_SLIDER
+
+#ifndef QT_NO_MAINWINDOW
+ case SR_DockWindowHandleRect:
+ {
+ if (! widget->parentWidget())
+ break;
+
+ const TQDockWindow * dw = (const TQDockWindow *) widget->parentWidget();
+
+ if ( !dw->area() || !dw->isCloseEnabled() )
+ rect.setRect( 0, 0, widget->width(), widget->height() );
+ else {
+ if ( dw->area()->orientation() == Horizontal )
+ rect.setRect(0, 15, widget->width(), widget->height() - 15);
+ else
+ rect.setRect(0, 1, widget->width() - 15, widget->height() - 1);
+ }
+ break;
+ }
+#endif // QT_NO_MAINWINDOW
+
+ case SR_ProgressBarGroove:
+ case SR_ProgressBarContents:
+ {
+#ifndef QT_NO_PROGRESSBAR
+ TQFontMetrics fm( ( widget ? widget->fontMetrics() :
+ TQApplication::fontMetrics() ) );
+ const TQProgressBar *progressbar = (const TQProgressBar *) widget;
+ int textw = 0;
+ if (progressbar->percentageVisible())
+ textw = fm.width("100%") + 6;
+
+ if (progressbar->indicatorFollowsStyle() ||
+ ! progressbar->centerIndicator())
+ rect.setCoords(wrect.left(), wrect.top(),
+ wrect.right() - textw, wrect.bottom());
+ else
+ rect = wrect;
+#endif
+ break;
+ }
+
+ case SR_ProgressBarLabel:
+ {
+#ifndef QT_NO_PROGRESSBAR
+ TQFontMetrics fm( ( widget ? widget->fontMetrics() :
+ TQApplication::fontMetrics() ) );
+ const TQProgressBar *progressbar = (const TQProgressBar *) widget;
+ int textw = 0;
+ if (progressbar->percentageVisible())
+ textw = fm.width("100%") + 6;
+
+ if (progressbar->indicatorFollowsStyle() ||
+ ! progressbar->centerIndicator())
+ rect.setCoords(wrect.right() - textw, wrect.top(),
+ wrect.right(), wrect.bottom());
+ else
+ rect = wrect;
+#endif
+ break;
+ }
+
+ case SR_ToolButtonContents:
+ rect = querySubControlMetrics(CC_ToolButton, widget, SC_ToolButton);
+ break;
+
+ case SR_ToolBoxTabContents:
+ rect = wrect;
+ rect.addCoords( 0, 0, -30, 0 );
+ break;
+
+ default:
+ rect = wrect;
+ break;
+ }
+
+ return rect;
+}
+
+#ifndef QT_NO_RANGECONTROL
+/*
+ I really need this and I don't want to expose it in TQRangeControl..
+*/
+static int qPositionFromValue( const TQRangeControl * rc, int logical_val,
+ int span )
+{
+ if ( span <= 0 || logical_val < rc->minValue() ||
+ rc->maxValue() <= rc->minValue() )
+ return 0;
+ if ( logical_val > rc->maxValue() )
+ return span;
+
+ uint range = rc->maxValue() - rc->minValue();
+ uint p = logical_val - rc->minValue();
+
+ if ( range > (uint)INT_MAX/4096 ) {
+ const int scale = 4096*2;
+ return ( (p/scale) * span ) / (range/scale);
+ // ### the above line is probably not 100% correct
+ // ### but fixing it isn't worth the extreme pain...
+ } else if ( range > (uint)span ) {
+ return (2*p*span + range) / (2*range);
+ } else {
+ uint div = span / range;
+ uint mod = span % range;
+ return p*div + (2*p*mod + range) / (2*range);
+ }
+ //equiv. to (p*span)/range + 0.5
+ // no overflow because of this implicit assumption:
+ // span <= 4096
+}
+#endif // QT_NO_RANGECONTROL
+
+/*! \reimp */
+void TQCommonStyle::drawComplexControl( ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ SCFlags controls,
+ SCFlags active,
+ const TQStyleOption& opt ) const
+{
+#if defined(QT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::drawComplexControl: widget parameter cannot be zero!");
+ return;
+ }
+#endif
+
+ activePainter = p;
+
+ switch (control) {
+#ifndef QT_NO_SCROLLBAR
+ case CC_ScrollBar:
+ {
+ const TQScrollBar *scrollbar = (const TQScrollBar *) widget;
+ TQRect addline, subline, addpage, subpage, slider, first, last;
+ bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue());
+
+ subline = querySubControlMetrics(control, widget, SC_ScrollBarSubLine, opt);
+ addline = querySubControlMetrics(control, widget, SC_ScrollBarAddLine, opt);
+ subpage = querySubControlMetrics(control, widget, SC_ScrollBarSubPage, opt);
+ addpage = querySubControlMetrics(control, widget, SC_ScrollBarAddPage, opt);
+ slider = querySubControlMetrics(control, widget, SC_ScrollBarSlider, opt);
+ first = querySubControlMetrics(control, widget, SC_ScrollBarFirst, opt);
+ last = querySubControlMetrics(control, widget, SC_ScrollBarLast, opt);
+
+ if ((controls & SC_ScrollBarSubLine) && subline.isValid())
+ drawPrimitive(PE_ScrollBarSubLine, p, subline, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarSubLine) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : 0));
+ if ((controls & SC_ScrollBarAddLine) && addline.isValid())
+ drawPrimitive(PE_ScrollBarAddLine, p, addline, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarAddLine) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : 0));
+ if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
+ drawPrimitive(PE_ScrollBarSubPage, p, subpage, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarSubPage) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : 0));
+ if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
+ drawPrimitive(PE_ScrollBarAddPage, p, addpage, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarAddPage) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : 0));
+ if ((controls & SC_ScrollBarFirst) && first.isValid())
+ drawPrimitive(PE_ScrollBarFirst, p, first, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarFirst) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : 0));
+ if ((controls & SC_ScrollBarLast) && last.isValid())
+ drawPrimitive(PE_ScrollBarLast, p, last, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarLast) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : 0));
+ if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
+ drawPrimitive(PE_ScrollBarSlider, p, slider, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarSlider) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : 0));
+
+ // ### perhaps this should not be able to accept focus if maxedOut?
+ if (scrollbar->hasFocus()) {
+ TQRect fr(slider.x() + 2, slider.y() + 2,
+ slider.width() - 5, slider.height() - 5);
+ drawPrimitive(PE_FocusRect, p, fr, cg, Style_Default);
+ }
+ }
+
+ break;
+ }
+#endif // QT_NO_SCROLLBAR
+
+#ifndef QT_NO_TOOLBUTTON
+ case CC_ToolButton:
+ {
+ const TQToolButton *toolbutton = (const TQToolButton *) widget;
+
+ TQColorGroup c = cg;
+ if ( toolbutton->backgroundMode() != PaletteButton )
+ c.setBrush( TQColorGroup::Button,
+ toolbutton->paletteBackgroundColor() );
+ TQRect button, menuarea;
+ button = visualRect( querySubControlMetrics(control, widget, SC_ToolButton, opt), widget );
+ menuarea = visualRect( querySubControlMetrics(control, widget, SC_ToolButtonMenu, opt), widget );
+
+ SFlags bflags = flags,
+ mflags = flags;
+
+ if (active & SC_ToolButton)
+ bflags |= Style_Down;
+ if (active & SC_ToolButtonMenu)
+ mflags |= Style_Down;
+
+ if (controls & SC_ToolButton) {
+ if (bflags & (Style_Down | Style_On | Style_Raised)) {
+ drawPrimitive(PE_ButtonTool, p, button, c, bflags, opt);
+ } else if ( toolbutton->parentWidget() &&
+ toolbutton->parentWidget()->backgroundPixmap() &&
+ ! toolbutton->parentWidget()->backgroundPixmap()->isNull() ) {
+ TQPixmap pixmap =
+ *(toolbutton->parentWidget()->backgroundPixmap());
+
+ p->drawTiledPixmap( r, pixmap, toolbutton->pos() );
+ }
+ }
+
+ if (controls & SC_ToolButtonMenu) {
+ if (mflags & (Style_Down | Style_On | Style_Raised))
+ drawPrimitive(PE_ButtonDropDown, p, menuarea, c, mflags, opt);
+ drawPrimitive(PE_ArrowDown, p, menuarea, c, mflags, opt);
+ }
+
+ if (toolbutton->hasFocus() && !toolbutton->focusProxy()) {
+ TQRect fr = toolbutton->rect();
+ fr.addCoords(3, 3, -3, -3);
+ drawPrimitive(PE_FocusRect, p, fr, c);
+ }
+
+ break;
+ }
+#endif // QT_NO_TOOLBUTTON
+
+#ifndef QT_NO_TITLEBAR
+ case CC_TitleBar:
+ {
+ const TQTitleBar *titlebar = (const TQTitleBar *) widget;
+ if ( controls & SC_TitleBarLabel ) {
+ TQColorGroup cgroup = titlebar->usesActiveColor() ?
+ titlebar->palette().active() : titlebar->palette().inactive();
+
+ TQColor left = cgroup.highlight();
+ TQColor right = cgroup.base();
+
+ if ( left != right ) {
+ double rS = left.red();
+ double gS = left.green();
+ double bS = left.blue();
+
+ const double rD = double(right.red() - rS) / titlebar->width();
+ const double gD = double(right.green() - gS) / titlebar->width();
+ const double bD = double(right.blue() - bS) / titlebar->width();
+
+ const int w = titlebar->width();
+ for ( int sx = 0; sx < w; sx++ ) {
+ rS+=rD;
+ gS+=gD;
+ bS+=bD;
+ p->setPen( TQColor( (int)rS, (int)gS, (int)bS ) );
+ p->drawLine( sx, 0, sx, titlebar->height() );
+ }
+ } else {
+ p->fillRect( titlebar->rect(), left );
+ }
+
+ TQRect ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarLabel ), widget );
+
+ p->setPen( cgroup.highlightedText() );
+ p->drawText(ir.x()+2, ir.y(), ir.width()-2, ir.height(),
+ AlignAuto | AlignVCenter | SingleLine, titlebar->visibleText() );
+ }
+
+ TQRect ir;
+ bool down = FALSE;
+ TQPixmap pm;
+
+ if ( controls & SC_TitleBarCloseButton ) {
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarCloseButton ), widget );
+ down = active & SC_TitleBarCloseButton;
+ if ( widget->testWFlags( WStyle_Tool )
+#ifndef QT_NO_MAINWINDOW
+ || ::qt_cast<TQDockWindow*>(widget)
+#endif
+ )
+ pm = stylePixmap(SP_DockWindowCloseButton, widget);
+ else
+ pm = stylePixmap(SP_TitleBarCloseButton, widget);
+ drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ down ? Style_Down : Style_Raised);
+
+ p->save();
+ if( down )
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
+ pixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+
+ if ( titlebar->window() ) {
+ if ( controls & SC_TitleBarMaxButton ) {
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarMaxButton ), widget );
+
+ down = active & SC_TitleBarMaxButton;
+ pm = TQPixmap(stylePixmap(SP_TitleBarMaxButton, widget));
+ drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ down ? Style_Down : Style_Raised);
+
+ p->save();
+ if( down )
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
+ pixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+
+ if ( controls & SC_TitleBarNormalButton || controls & SC_TitleBarMinButton ) {
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarMinButton ), widget );
+ TQStyle::SubControl ctrl = (controls & SC_TitleBarNormalButton ?
+ SC_TitleBarNormalButton :
+ SC_TitleBarMinButton);
+ TQStyle::StylePixmap spixmap = (controls & SC_TitleBarNormalButton ?
+ SP_TitleBarNormalButton :
+ SP_TitleBarMinButton);
+ down = active & ctrl;
+ pm = TQPixmap(stylePixmap(spixmap, widget));
+ drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ down ? Style_Down : Style_Raised);
+
+ p->save();
+ if( down )
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
+ pixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+
+ if ( controls & SC_TitleBarShadeButton ) {
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarShadeButton ), widget );
+
+ down = active & SC_TitleBarShadeButton;
+ pm = TQPixmap(stylePixmap(SP_TitleBarShadeButton, widget));
+ drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ down ? Style_Down : Style_Raised);
+ p->save();
+ if( down )
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
+ pixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+
+ if ( controls & SC_TitleBarUnshadeButton ) {
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarUnshadeButton ), widget );
+
+ down = active & SC_TitleBarUnshadeButton;
+ pm = TQPixmap(stylePixmap(SP_TitleBarUnshadeButton, widget));
+ drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ down ? Style_Down : Style_Raised);
+ p->save();
+ if( down )
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
+ pixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+ }
+#ifndef QT_NO_WIDGET_TOPEXTRA
+ if ( controls & SC_TitleBarSysMenu ) {
+ if ( titlebar->icon() ) {
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarSysMenu ), widget );
+ drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, titlebar->icon(), TQString::null );
+ }
+ }
+#endif
+ break;
+ }
+#endif //QT_NO_TITLEBAR
+
+ case CC_SpinWidget: {
+#ifndef QT_NO_SPINWIDGET
+ const TQSpinWidget * sw = (const TQSpinWidget *) widget;
+ SFlags flags;
+ PrimitiveElement pe;
+
+ if ( controls & SC_SpinWidgetFrame )
+ qDrawWinPanel( p, r, cg, TRUE ); //cstyle == Sunken );
+
+ if ( controls & SC_SpinWidgetUp ) {
+ flags = Style_Default | Style_Enabled;
+ if (active == SC_SpinWidgetUp ) {
+ flags |= Style_On;
+ flags |= Style_Sunken;
+ } else
+ flags |= Style_Raised;
+ if ( sw->buttonSymbols() == TQSpinWidget::PlusMinus )
+ pe = PE_SpinWidgetPlus;
+ else
+ pe = PE_SpinWidgetUp;
+
+ TQRect re = sw->upRect();
+ TQColorGroup ucg = sw->isUpEnabled() ? cg : sw->palette().disabled();
+ drawPrimitive(PE_ButtonBevel, p, re, ucg, flags);
+ drawPrimitive(pe, p, re, ucg, flags);
+ }
+
+ if ( controls & SC_SpinWidgetDown ) {
+ flags = Style_Default | Style_Enabled;
+ if (active == SC_SpinWidgetDown ) {
+ flags |= Style_On;
+ flags |= Style_Sunken;
+ } else
+ flags |= Style_Raised;
+ if ( sw->buttonSymbols() == TQSpinWidget::PlusMinus )
+ pe = PE_SpinWidgetMinus;
+ else
+ pe = PE_SpinWidgetDown;
+
+ TQRect re = sw->downRect();
+ TQColorGroup dcg = sw->isDownEnabled() ? cg : sw->palette().disabled();
+ drawPrimitive(PE_ButtonBevel, p, re, dcg, flags);
+ drawPrimitive(pe, p, re, dcg, flags);
+ }
+#endif
+ break; }
+
+#ifndef QT_NO_SLIDER
+ case CC_Slider:
+ switch ( controls ) {
+ case SC_SliderTickmarks: {
+ const TQSlider * sl = (const TQSlider *) widget;
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, sl );
+ int ticks = sl->tickmarks();
+ int thickness = pixelMetric( PM_SliderControlThickness, sl );
+ int len = pixelMetric( PM_SliderLength, sl );
+ int available = pixelMetric( PM_SliderSpaceAvailable, sl );
+ int interval = sl->tickInterval();
+
+ if ( interval <= 0 ) {
+ interval = sl->lineStep();
+ if ( qPositionFromValue( sl, interval, available ) -
+ qPositionFromValue( sl, 0, available ) < 3 )
+ interval = sl->pageStep();
+ }
+
+ int fudge = len / 2;
+ int pos;
+
+ if ( ticks & TQSlider::Above ) {
+ p->setPen( cg.foreground() );
+ int v = sl->minValue();
+ if ( !interval )
+ interval = 1;
+ while ( v <= sl->maxValue() + 1 ) {
+ pos = qPositionFromValue( sl, v, available ) + fudge;
+ if ( sl->orientation() == Horizontal )
+ p->drawLine( pos, 0, pos, tickOffset-2 );
+ else
+ p->drawLine( 0, pos, tickOffset-2, pos );
+ v += interval;
+ }
+ }
+
+ if ( ticks & TQSlider::Below ) {
+ p->setPen( cg.foreground() );
+ int v = sl->minValue();
+ if ( !interval )
+ interval = 1;
+ while ( v <= sl->maxValue() + 1 ) {
+ pos = qPositionFromValue( sl, v, available ) + fudge;
+ if ( sl->orientation() == Horizontal )
+ p->drawLine( pos, tickOffset+thickness+1, pos,
+ tickOffset+thickness+1 + available-2 );
+ else
+ p->drawLine( tickOffset+thickness+1, pos,
+ tickOffset+thickness+1 + available-2,
+ pos );
+ v += interval;
+ }
+
+ }
+
+ break; }
+ }
+ break;
+#endif // QT_NO_SLIDER
+#ifndef QT_NO_LISTVIEW
+ case CC_ListView:
+ if ( controls & SC_ListView ) {
+ TQListView *listview = (TQListView*)widget;
+ p->fillRect( r, listview->viewport()->backgroundBrush() );
+ }
+ break;
+#endif //QT_NO_LISTVIEW
+ default:
+ break;
+ }
+
+ activePainter = 0;
+}
+
+
+/*! \reimp */
+void TQCommonStyle::drawComplexControlMask( ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQStyleOption& opt ) const
+{
+ Q_UNUSED(control);
+ Q_UNUSED(widget);
+ Q_UNUSED(opt);
+
+ p->fillRect(r, color1);
+}
+
+
+/*! \reimp */
+TQRect TQCommonStyle::querySubControlMetrics( ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption &opt ) const
+{
+#if defined(QT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::querySubControlMetrics: widget parameter cannot be zero!");
+ return TQRect();
+ }
+#endif
+
+ switch ( control ) {
+ case CC_SpinWidget: {
+ int fw = pixelMetric( PM_SpinBoxFrameWidth, widget);
+ TQSize bs;
+ bs.setHeight( widget->height()/2 - fw );
+ if ( bs.height() < 8 )
+ bs.setHeight( 8 );
+ bs.setWidth( TQMIN( bs.height() * 8 / 5, widget->width() / 4 ) ); // 1.6 -approximate golden mean
+ bs = bs.expandedTo( TQApplication::globalStrut() );
+ int y = fw;
+ int x, lx, rx;
+ x = widget->width() - y - bs.width();
+ lx = fw;
+ rx = x - fw;
+ switch ( sc ) {
+ case SC_SpinWidgetUp:
+ return TQRect(x, y, bs.width(), bs.height());
+ case SC_SpinWidgetDown:
+ return TQRect(x, y + bs.height(), bs.width(), bs.height());
+ case SC_SpinWidgetButtonField:
+ return TQRect(x, y, bs.width(), widget->height() - 2*fw);
+ case SC_SpinWidgetEditField:
+ return TQRect(lx, fw, rx, widget->height() - 2*fw);
+ case SC_SpinWidgetFrame:
+ return widget->rect();
+ default:
+ break;
+ }
+ break; }
+
+ case CC_ComboBox: {
+ int x = 0, y = 0, wi = widget->width(), he = widget->height();
+ int xpos = x;
+ xpos += wi - 2 - 16;
+
+ switch ( sc ) {
+ case SC_ComboBoxFrame:
+ return widget->rect();
+ case SC_ComboBoxArrow:
+ return TQRect(xpos, y+2, 16, he-4);
+ case SC_ComboBoxEditField:
+ return TQRect(x+3, y+3, wi-6-16, he-6);
+ case SC_ComboBoxListBoxPopup:
+ return opt.rect();
+ default:
+ break;
+ }
+ break; }
+
+#ifndef QT_NO_SCROLLBAR
+ case CC_ScrollBar: {
+ const TQScrollBar *scrollbar = (const TQScrollBar *) widget;
+ int sliderstart = 0;
+ int sbextent = pixelMetric(PM_ScrollBarExtent, widget);
+ int maxlen = ((scrollbar->orientation() == TQt::Horizontal) ?
+ scrollbar->width() : scrollbar->height()) - (sbextent * 2);
+ int sliderlen;
+
+ sliderstart = scrollbar->sliderStart();
+
+ // calculate slider length
+ if (scrollbar->maxValue() != scrollbar->minValue()) {
+ uint range = scrollbar->maxValue() - scrollbar->minValue();
+ sliderlen = (Q_LLONG(scrollbar->pageStep()) * maxlen) / (range + scrollbar->pageStep());
+
+ int slidermin = pixelMetric( PM_ScrollBarSliderMin, widget );
+ if ( sliderlen < slidermin || range > INT_MAX / 2 )
+ sliderlen = slidermin;
+ if ( sliderlen > maxlen )
+ sliderlen = maxlen;
+ } else
+ sliderlen = maxlen;
+
+ switch (sc) {
+ case SC_ScrollBarSubLine: // top/left button
+ if (scrollbar->orientation() == TQt::Horizontal) {
+ int buttonWidth = TQMIN(scrollbar->width()/2, sbextent);
+ return TQRect( 0, 0, buttonWidth, sbextent );
+ } else {
+ int buttonHeight = TQMIN(scrollbar->height()/2, sbextent);
+ return TQRect( 0, 0, sbextent, buttonHeight );
+ }
+
+ case SC_ScrollBarAddLine: // bottom/right button
+ if (scrollbar->orientation() == TQt::Horizontal) {
+ int buttonWidth = TQMIN(scrollbar->width()/2, sbextent);
+ return TQRect( scrollbar->width() - buttonWidth, 0, buttonWidth, sbextent );
+ } else {
+ int buttonHeight = TQMIN(scrollbar->height()/2, sbextent);
+ return TQRect( 0, scrollbar->height() - buttonHeight, sbextent, buttonHeight );
+ }
+
+ case SC_ScrollBarSubPage: // between top/left button and slider
+ if (scrollbar->orientation() == TQt::Horizontal)
+ return TQRect(sbextent, 0, sliderstart - sbextent, sbextent);
+ return TQRect(0, sbextent, sbextent, sliderstart - sbextent);
+
+ case SC_ScrollBarAddPage: // between bottom/right button and slider
+ if (scrollbar->orientation() == TQt::Horizontal)
+ return TQRect(sliderstart + sliderlen, 0,
+ maxlen - sliderstart - sliderlen + sbextent, sbextent);
+ return TQRect(0, sliderstart + sliderlen,
+ sbextent, maxlen - sliderstart - sliderlen + sbextent);
+
+ case SC_ScrollBarGroove:
+ if (scrollbar->orientation() == TQt::Horizontal)
+ return TQRect(sbextent, 0, scrollbar->width() - sbextent * 2,
+ scrollbar->height());
+ return TQRect(0, sbextent, scrollbar->width(),
+ scrollbar->height() - sbextent * 2);
+
+ case SC_ScrollBarSlider:
+ if (scrollbar->orientation() == TQt::Horizontal)
+ return TQRect(sliderstart, 0, sliderlen, sbextent);
+ return TQRect(0, sliderstart, sbextent, sliderlen);
+
+ default: break;
+ }
+
+ break; }
+#endif // QT_NO_SCROLLBAR
+
+#ifndef QT_NO_SLIDER
+ case CC_Slider: {
+ const TQSlider * sl = (const TQSlider *) widget;
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, sl );
+ int thickness = pixelMetric( PM_SliderControlThickness, sl );
+
+ switch ( sc ) {
+ case SC_SliderHandle: {
+ int sliderPos = 0;
+ int len = pixelMetric( PM_SliderLength, sl );
+
+ sliderPos = sl->sliderStart();
+
+ if ( sl->orientation() == Horizontal )
+ return TQRect( sliderPos, tickOffset, len, thickness );
+ return TQRect( tickOffset, sliderPos, thickness, len ); }
+ case SC_SliderGroove: {
+ if ( sl->orientation() == Horizontal )
+ return TQRect( 0, tickOffset, sl->width(), thickness );
+ return TQRect( tickOffset, 0, thickness, sl->height() ); }
+
+ default:
+ break;
+ }
+ break; }
+#endif // QT_NO_SLIDER
+
+#if !defined(QT_NO_TOOLBUTTON) && !defined(QT_NO_POPUPMENU)
+ case CC_ToolButton: {
+ const TQToolButton *toolbutton = (const TQToolButton *) widget;
+ int mbi = pixelMetric(PM_MenuButtonIndicator, widget);
+
+ TQRect rect = toolbutton->rect();
+ switch (sc) {
+ case SC_ToolButton:
+ if (toolbutton->popup() && ! toolbutton->popupDelay())
+ rect.addCoords(0, 0, -mbi, 0);
+ return rect;
+
+ case SC_ToolButtonMenu:
+ if (toolbutton->popup() && ! toolbutton->popupDelay())
+ rect.addCoords(rect.width() - mbi, 0, 0, 0);
+ return rect;
+
+ default: break;
+ }
+ break;
+ }
+#endif // QT_NO_TOOLBUTTON && QT_NO_POPUPMENU
+
+#ifndef QT_NO_TITLEBAR
+ case CC_TitleBar: {
+ const TQTitleBar *titlebar = (const TQTitleBar *) widget;
+ const int controlTop = 2;
+ const int controlHeight = widget->height() - controlTop * 2;
+
+ switch (sc) {
+ case SC_TitleBarLabel: {
+ const TQTitleBar *titlebar = (TQTitleBar*)widget;
+ TQRect ir( 0, 0, titlebar->width(), titlebar->height() );
+ if ( titlebar->testWFlags( WStyle_Tool ) ) {
+ if ( titlebar->testWFlags( WStyle_SysMenu ) )
+ ir.addCoords( 0, 0, -controlHeight-3, 0 );
+ if ( titlebar->testWFlags( WStyle_MinMax ) )
+ ir.addCoords( 0, 0, -controlHeight-2, 0 );
+ } else {
+ if ( titlebar->testWFlags( WStyle_SysMenu ) )
+ ir.addCoords( controlHeight+3, 0, -controlHeight-3, 0 );
+ if ( titlebar->testWFlags( WStyle_Minimize ) )
+ ir.addCoords( 0, 0, -controlHeight-2, 0 );
+ if ( titlebar->testWFlags( WStyle_Maximize ) )
+ ir.addCoords( 0, 0, -controlHeight-2, 0 );
+ }
+ return ir; }
+
+ case SC_TitleBarCloseButton:
+ return TQRect( titlebar->width() - ( controlHeight + controlTop ),
+ controlTop, controlHeight, controlHeight );
+
+ case SC_TitleBarMaxButton:
+ case SC_TitleBarShadeButton:
+ case SC_TitleBarUnshadeButton:
+ return TQRect( titlebar->width() - ( ( controlHeight + controlTop ) * 2 ),
+ controlTop, controlHeight, controlHeight );
+
+ case SC_TitleBarMinButton:
+ case SC_TitleBarNormalButton: {
+ int offset = controlHeight + controlTop;
+ if ( !titlebar->testWFlags( WStyle_Maximize ) )
+ offset *= 2;
+ else
+ offset *= 3;
+ return TQRect( titlebar->width() - offset, controlTop, controlHeight, controlHeight );
+ }
+
+ case SC_TitleBarSysMenu:
+ return TQRect( 3, controlTop, controlHeight, controlHeight);
+
+ default: break;
+ }
+ break; }
+#endif //QT_NO_TITLEBAR
+
+ default:
+ break;
+ }
+ return TQRect();
+}
+
+
+/*! \reimp */
+TQStyle::SubControl TQCommonStyle::querySubControl(ComplexControl control,
+ const TQWidget *widget,
+ const TQPoint &pos,
+ const TQStyleOption& opt ) const
+{
+ SubControl ret = SC_None;
+
+ switch (control) {
+#ifndef QT_NO_LISTVIEW
+ case CC_ListView:
+ {
+ if(pos.x() >= 0 && pos.x() <
+ opt.listViewItem()->listView()->treeStepSize())
+ ret = SC_ListViewExpand;
+ break;
+ }
+#endif
+#ifndef QT_NO_SCROLLBAR
+ case CC_ScrollBar:
+ {
+ TQRect r;
+ uint ctrl = SC_ScrollBarAddLine;
+
+ // we can do this because subcontrols were designed to be masks as well...
+ while (ret == SC_None && ctrl <= SC_ScrollBarGroove) {
+ r = querySubControlMetrics(control, widget,
+ (TQStyle::SubControl) ctrl, opt);
+ if (r.isValid() && r.contains(pos))
+ ret = (TQStyle::SubControl) ctrl;
+
+ ctrl <<= 1;
+ }
+
+ break;
+ }
+#endif
+ case CC_TitleBar:
+ {
+#ifndef QT_NO_TITLEBAR
+ const TQTitleBar *titlebar = (TQTitleBar*)widget;
+ TQRect r;
+ uint ctrl = SC_TitleBarLabel;
+
+ // we can do this because subcontrols were designed to be masks as well...
+ while (ret == SC_None && ctrl <= SC_TitleBarUnshadeButton) {
+ r = visualRect( querySubControlMetrics( control, widget, (TQStyle::SubControl) ctrl, opt ), widget );
+ if (r.isValid() && r.contains(pos))
+ ret = (TQStyle::SubControl) ctrl;
+
+ ctrl <<= 1;
+ }
+ if ( titlebar->window() ) {
+ if (titlebar->testWFlags( WStyle_Tool )) {
+ if ( ret == SC_TitleBarMinButton || ret == SC_TitleBarMaxButton ) {
+ if ( titlebar->window()->isMinimized() )
+ ret = SC_TitleBarUnshadeButton;
+ else
+ ret = SC_TitleBarShadeButton;
+ }
+ } else if ( ret == SC_TitleBarMinButton && titlebar->window()->isMinimized() ) {
+ ret = TQStyle::SC_TitleBarNormalButton;
+ }
+ }
+#endif
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+
+/*! \reimp */
+int TQCommonStyle::pixelMetric(PixelMetric m, const TQWidget *widget) const
+{
+ int ret;
+
+ switch (m) {
+ case PM_DialogButtonsSeparator:
+ ret = 5;
+ break;
+ case PM_DialogButtonsButtonWidth:
+ ret = 70;
+ break;
+ case PM_DialogButtonsButtonHeight:
+ ret = 30;
+ break;
+ case PM_CheckListControllerSize:
+ case PM_CheckListButtonSize:
+ ret = 16;
+ break;
+ case PM_TitleBarHeight: {
+ if ( widget ) {
+ if ( widget->testWFlags( WStyle_Tool ) ) {
+ ret = TQMAX( widget->fontMetrics().lineSpacing(), 16 );
+#ifndef QT_NO_MAINWINDOW
+ } else if ( ::qt_cast<TQDockWindow*>(widget) ) {
+ ret = TQMAX( widget->fontMetrics().lineSpacing(), 13 );
+#endif
+ } else {
+ ret = TQMAX( widget->fontMetrics().lineSpacing(), 18 );
+ }
+ } else {
+ ret = 0;
+ }
+
+ break; }
+ case PM_ScrollBarSliderMin:
+ ret = 9;
+ break;
+
+ case PM_ButtonMargin:
+ ret = 6;
+ break;
+
+ case PM_ButtonDefaultIndicator:
+ ret = 0;
+ break;
+
+ case PM_MenuButtonIndicator:
+ if (! widget)
+ ret = 12;
+ else
+ ret = TQMAX(12, (widget->height() - 4) / 3);
+ break;
+
+ case PM_ButtonShiftHorizontal:
+ case PM_ButtonShiftVertical:
+ ret = 0;
+ break;
+
+ case PM_SpinBoxFrameWidth:
+ case PM_DefaultFrameWidth:
+ ret = 2;
+ break;
+
+ case PM_MDIFrameWidth:
+ ret = 2;
+ break;
+
+ case PM_MDIMinimizedWidth:
+ ret = 196;
+ break;
+
+#ifndef QT_NO_SCROLLBAR
+ case PM_ScrollBarExtent:
+ if ( !widget ) {
+ ret = 16;
+ } else {
+ const TQScrollBar *bar = (const TQScrollBar*)widget;
+ int s = bar->orientation() == TQt::Horizontal ?
+ TQApplication::globalStrut().height()
+ : TQApplication::globalStrut().width();
+ ret = TQMAX( 16, s );
+ }
+ break;
+#endif
+ case PM_MaximumDragDistance:
+ ret = -1;
+ break;
+
+#ifndef QT_NO_SLIDER
+ case PM_SliderThickness:
+ ret = 16;
+ break;
+
+ case PM_SliderTickmarkOffset:
+ {
+ if (! widget) {
+ ret = 0;
+ break;
+ }
+
+ const TQSlider * sl = (const TQSlider *) widget;
+ int space = (sl->orientation() == Horizontal) ? sl->height() :
+ sl->width();
+ int thickness = pixelMetric( PM_SliderControlThickness, sl );
+ int ticks = sl->tickmarks();
+
+ if ( ticks == TQSlider::Both )
+ ret = (space - thickness) / 2;
+ else if ( ticks == TQSlider::Above )
+ ret = space - thickness;
+ else
+ ret = 0;
+ break;
+ }
+
+ case PM_SliderSpaceAvailable:
+ {
+ const TQSlider * sl = (const TQSlider *) widget;
+ if ( sl->orientation() == Horizontal )
+ ret = sl->width() - pixelMetric( PM_SliderLength, sl );
+ else
+ ret = sl->height() - pixelMetric( PM_SliderLength, sl );
+ break;
+ }
+#endif // QT_NO_SLIDER
+
+ case PM_DockWindowSeparatorExtent:
+ ret = 6;
+ break;
+
+ case PM_DockWindowHandleExtent:
+ ret = 8;
+ break;
+
+ case PM_DockWindowFrameWidth:
+ ret = 1;
+ break;
+
+ case PM_MenuBarFrameWidth:
+ ret = 2;
+ break;
+
+ case PM_MenuBarItemSpacing:
+ case PM_ToolBarItemSpacing:
+ ret = 0;
+ break;
+
+ case PM_TabBarTabOverlap:
+ ret = 3;
+ break;
+
+ case PM_TabBarBaseHeight:
+ ret = 0;
+ break;
+
+ case PM_TabBarBaseOverlap:
+ ret = 0;
+ break;
+
+ case PM_TabBarTabHSpace:
+ ret = 24;
+ break;
+
+ case PM_TabBarTabShiftHorizontal:
+ case PM_TabBarTabShiftVertical:
+ ret = 2;
+ break;
+
+#ifndef QT_NO_TABBAR
+ case PM_TabBarTabVSpace:
+ {
+ const TQTabBar * tb = (const TQTabBar *) widget;
+ if ( tb && ( tb->shape() == TQTabBar::RoundedAbove ||
+ tb->shape() == TQTabBar::RoundedBelow ) )
+ ret = 10;
+ else
+ ret = 0;
+ break;
+ }
+#endif
+
+ case PM_ProgressBarChunkWidth:
+ ret = 9;
+ break;
+
+ case PM_IndicatorWidth:
+ ret = 13;
+ break;
+
+ case PM_IndicatorHeight:
+ ret = 13;
+ break;
+
+ case PM_ExclusiveIndicatorWidth:
+ ret = 12;
+ break;
+
+ case PM_ExclusiveIndicatorHeight:
+ ret = 12;
+ break;
+
+ case PM_PopupMenuFrameHorizontalExtra:
+ case PM_PopupMenuFrameVerticalExtra:
+ ret = 0;
+ break;
+
+ case PM_HeaderMargin:
+ ret = 4;
+ break;
+ case PM_HeaderMarkSize:
+ ret = 32;
+ break;
+ case PM_HeaderGripMargin:
+ ret = 4;
+ break;
+ case PM_TabBarScrollButtonWidth:
+ ret = 16;
+ break;
+ default:
+ ret = 0;
+ break;
+ }
+
+ return ret;
+}
+
+
+/*! \reimp */
+TQSize TQCommonStyle::sizeFromContents(ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& opt ) const
+{
+ TQSize sz(contentsSize);
+
+#if defined(QT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::sizeFromContents: widget parameter cannot be zero!");
+ return sz;
+ }
+#endif
+
+ switch (contents) {
+#ifndef QT_NO_DIALOGBUTTONS
+ case CT_DialogButtons: {
+ const TQDialogButtons *dbtns = (const TQDialogButtons *)widget;
+ int w = contentsSize.width(), h = contentsSize.height();
+ const int bwidth = pixelMetric(PM_DialogButtonsButtonWidth, widget),
+ bspace = pixelMetric(PM_DialogButtonsSeparator, widget),
+ bheight = pixelMetric(PM_DialogButtonsButtonHeight, widget);
+ if(dbtns->orientation() == Horizontal) {
+ if(!w)
+ w = bwidth;
+ } else {
+ if(!h)
+ h = bheight;
+ }
+ TQDialogButtons::Button btns[] = { TQDialogButtons::All, TQDialogButtons::Reject, TQDialogButtons::Accept, //reverse order (right to left)
+ TQDialogButtons::Apply, TQDialogButtons::Retry, TQDialogButtons::Ignore, TQDialogButtons::Abort,
+ TQDialogButtons::Help };
+ for(unsigned int i = 0, cnt = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) {
+ if(dbtns->isButtonVisible(btns[i])) {
+ TQSize szH = dbtns->sizeHint(btns[i]);
+ int mwidth = TQMAX(bwidth, szH.width()), mheight = TQMAX(bheight, szH.height());
+ if(dbtns->orientation() == Horizontal)
+ h = TQMAX(h, mheight);
+ else
+ w = TQMAX(w, mwidth);
+
+ if(cnt)
+ w += bspace;
+ cnt++;
+ if(dbtns->orientation() == Horizontal)
+ w += mwidth;
+ else
+ h += mheight;
+ }
+ }
+ const int fw = pixelMetric(PM_DefaultFrameWidth, widget) * 2;
+ sz = TQSize(w + fw, h + fw);
+ break; }
+#endif //QT_NO_DIALOGBUTTONS
+ case CT_PushButton:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ int w = contentsSize.width(),
+ h = contentsSize.height(),
+ bm = pixelMetric(PM_ButtonMargin, widget),
+ fw = pixelMetric(PM_DefaultFrameWidth, widget) * 2;
+
+ w += bm + fw;
+ h += bm + fw;
+
+ if (button->isDefault() || button->autoDefault()) {
+ int dbw = pixelMetric(PM_ButtonDefaultIndicator, widget) * 2;
+ w += dbw;
+ h += dbw;
+ }
+
+ sz = TQSize(w, h);
+#endif
+ break;
+ }
+
+ case CT_CheckBox:
+ {
+#ifndef QT_NO_CHECKBOX
+ const TQCheckBox *checkbox = (const TQCheckBox *) widget;
+ TQRect irect = subRect(SR_CheckBoxIndicator, widget);
+ int h = pixelMetric( PM_IndicatorHeight, widget );
+ int margins = (!checkbox->pixmap() && checkbox->text().isEmpty()) ? 0 : 10;
+ sz += TQSize(irect.right() + margins, 4 );
+ sz.setHeight( TQMAX( sz.height(), h ) );
+#endif
+ break;
+ }
+
+ case CT_RadioButton:
+ {
+#ifndef QT_NO_RADIOBUTTON
+ const TQRadioButton *radiobutton = (const TQRadioButton *) widget;
+ TQRect irect = subRect(SR_RadioButtonIndicator, widget);
+ int h = pixelMetric( PM_ExclusiveIndicatorHeight, widget );
+ int margins = (!radiobutton->pixmap() && radiobutton->text().isEmpty()) ? 0 : 10;
+ sz += TQSize(irect.right() + margins, 4 );
+ sz.setHeight( TQMAX( sz.height(), h ) );
+#endif
+ break;
+ }
+
+ case CT_ToolButton:
+ {
+ sz = TQSize(sz.width() + 6, sz.height() + 5);
+ break;
+ }
+
+ case CT_ComboBox:
+ {
+ int dfw = pixelMetric(PM_DefaultFrameWidth, widget) * 2;
+ sz = TQSize(sz.width() + dfw + 21, sz.height() + dfw );
+ break;
+ }
+
+ case CT_PopupMenuItem:
+ {
+#ifndef QT_NO_POPUPMENU
+ if (opt.isDefault())
+ break;
+
+ const TQPopupMenu *popup = (const TQPopupMenu *) widget;
+ bool checkable = popup->isCheckable();
+ TQMenuItem *mi = opt.menuItem();
+ int maxpmw = opt.maxIconWidth();
+ int w = sz.width(), h = sz.height();
+
+ if (mi->custom()) {
+ w = mi->custom()->sizeHint().width();
+ h = mi->custom()->sizeHint().height();
+ if (! mi->custom()->fullSpan())
+ h += 8;
+ } else if ( mi->widget() ) {
+ } else if (mi->isSeparator()) {
+ w = 10;
+ h = 2;
+ } else {
+ if (mi->pixmap())
+ h = TQMAX(h, mi->pixmap()->height() + 4);
+ else
+ h = TQMAX(h, popup->fontMetrics().height() + 8);
+
+ if (mi->iconSet() != 0)
+ h = TQMAX(h, mi->iconSet()->pixmap(TQIconSet::Small,
+ TQIconSet::Normal).height() + 4);
+ }
+
+ if (! mi->text().isNull()) {
+ if (mi->text().find('\t') >= 0)
+ w += 12;
+ }
+
+ if (maxpmw)
+ w += maxpmw + 6;
+ if (checkable && maxpmw < 20)
+ w += 20 - maxpmw;
+ if (checkable || maxpmw > 0)
+ w += 2;
+ w += 12;
+
+ sz = TQSize(w, h);
+#endif
+ break;
+ }
+
+ case CT_LineEdit:
+ case CT_Header:
+ case CT_Slider:
+ case CT_ProgressBar:
+ // just return the contentsSize for now
+ // fall through intended
+
+ default:
+ break;
+ }
+
+ return sz;
+}
+
+
+/*! \reimp */
+int TQCommonStyle::styleHint(StyleHint sh, const TQWidget * w, const TQStyleOption &, TQStyleHintReturn *) const
+{
+ int ret;
+
+ switch (sh) {
+#ifndef QT_NO_DIALOGBUTTONS
+ case SH_DialogButtons_DefaultButton:
+ ret = TQDialogButtons::Accept;
+ break;
+#endif
+ case SH_GroupBox_TextLabelVerticalAlignment:
+ ret = TQt::AlignVCenter;
+ break;
+
+ case SH_GroupBox_TextLabelColor:
+ ret = (int) ( w ? w->paletteForegroundColor().rgb() : 0 );
+ break;
+
+ case SH_ListViewExpand_SelectMouseType:
+ case SH_TabBar_SelectMouseType:
+ ret = TQEvent::MouseButtonPress;
+ break;
+
+ case SH_GUIStyle:
+ ret = WindowsStyle;
+ break;
+
+ case SH_ScrollBar_BackgroundMode:
+ ret = TQWidget::PaletteBackground;
+ break;
+
+ case SH_TabBar_Alignment:
+ case SH_Header_ArrowAlignment:
+ ret = TQt::AlignLeft;
+ break;
+
+ case SH_PopupMenu_SubMenuPopupDelay:
+ ret = 256;
+ break;
+
+ case SH_ProgressDialog_TextLabelAlignment:
+ ret = TQt::AlignCenter;
+ break;
+
+ case SH_BlinkCursorWhenTextSelected:
+ ret = 1;
+ break;
+
+ case SH_Table_GridLineColor:
+ ret = -1;
+ break;
+
+ case SH_LineEdit_PasswordCharacter:
+ ret = '*';
+ break;
+
+ case SH_ToolBox_SelectedPageTitleBold:
+ ret = 1;
+ break;
+
+ case SH_UnderlineAccelerator:
+ ret = 1;
+ break;
+
+ case SH_ToolButton_Uses3D:
+ ret = 1;
+ break;
+
+ default:
+ ret = 0;
+ break;
+ }
+
+ return ret;
+}
+
+/*! \reimp */
+TQPixmap TQCommonStyle::stylePixmap(StylePixmap, const TQWidget *, const TQStyleOption&) const
+{
+ return TQPixmap();
+}
+
+
+#endif // QT_NO_STYLE
diff --git a/src/styles/qcommonstyle.h b/src/styles/qcommonstyle.h
new file mode 100644
index 000000000..d507038fc
--- /dev/null
+++ b/src/styles/qcommonstyle.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Definition of TQCommonStyle class
+**
+** Created : 980616
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQCOMMONSTYLE_H
+#define TQCOMMONSTYLE_H
+
+#ifndef QT_H
+#include "qstyle.h"
+#endif // QT_H
+
+#ifndef QT_NO_STYLE
+
+class Q_EXPORT TQCommonStyle: public TQStyle
+{
+ Q_OBJECT
+
+public:
+ TQCommonStyle();
+ ~TQCommonStyle();
+
+ void drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawControlMask( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect subRect( SubRect r, const TQWidget *widget ) const;
+
+ void drawComplexControl( ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+#ifdef Q_QDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawComplexControlMask( ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect querySubControlMetrics( ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ SubControl querySubControl( ComplexControl control,
+ const TQWidget *widget,
+ const TQPoint &pos,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int pixelMetric( PixelMetric m, const TQWidget *widget = 0 ) const;
+
+ TQSize sizeFromContents( ContentsType s,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int styleHint(StyleHint sh, const TQWidget *, const TQStyleOption &, TQStyleHintReturn *) const;
+
+ TQPixmap stylePixmap( StylePixmap sp,
+ const TQWidget *widget = 0,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+
+private:
+ // Disabled copy constructor and operator=
+#if defined(Q_DISABLE_COPY)
+ TQCommonStyle( const TQCommonStyle & );
+ TQCommonStyle &operator=( const TQCommonStyle & );
+#endif
+};
+
+
+
+#endif // QT_NO_STYLE
+
+#endif // TQCOMMONSTYLE_H
diff --git a/src/styles/qcompactstyle.cpp b/src/styles/qcompactstyle.cpp
new file mode 100644
index 000000000..e65645c34
--- /dev/null
+++ b/src/styles/qcompactstyle.cpp
@@ -0,0 +1,321 @@
+/****************************************************************************
+**
+** Implementation of compact style class
+**
+** Created : 006231
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qcompactstyle.h"
+
+#if !defined(QT_NO_STYLE_COMPACT) || defined(QT_PLUGIN)
+
+#include "qfontmetrics.h"
+#include "qpalette.h"
+#include "qpainter.h"
+#include "qdrawutil.h"
+#include "qmenudata.h"
+#include "qpopupmenu.h"
+
+TQCompactStyle::TQCompactStyle()
+: TQWindowsStyle()
+{
+}
+
+/*! \reimp */
+int TQCompactStyle::pixelMetric( PixelMetric metric, const TQWidget *widget )
+{
+ int ret;
+ switch ( metric ) {
+ case PM_ButtonMargin:
+ ret = 2;
+ break;
+ // tws - I added this in to stop this "Windows Scroll behaivor." Remove it
+ // if you don't want it.
+ case PM_MaximumDragDistance:
+ ret = -1;
+ break;
+ default:
+ ret = TQWindowsStyle::pixelMetric( metric, widget );
+ break;
+ }
+ return ret;
+}
+
+static const int motifItemFrame = 0; // menu item frame width
+static const int motifSepHeight = 2; // separator item height
+static const int motifItemHMargin = 1; // menu item hor text margin
+static const int motifItemVMargin = 2; // menu item ver text margin
+static const int motifArrowHMargin = 0; // arrow horizontal margin
+static const int motifTabSpacing = 4; // space between text and tab
+static const int motifCheckMarkHMargin = 1; // horiz. margins of check mark
+static const int windowsRightBorder = 8; // right border on windows
+static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
+
+static int extraPopupMenuItemWidth( bool checkable, int maxpmw, TQMenuItem* mi, const TQFontMetrics& /*fm*/ )
+{
+ int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
+
+ if ( mi->isSeparator() )
+ return 10; // arbitrary
+ else if ( mi->pixmap() )
+ w += mi->pixmap()->width(); // pixmap only
+
+ if ( !mi->text().isNull() ) {
+ if ( mi->text().find('\t') >= 0 ) // string contains tab
+ w += motifTabSpacing;
+ }
+
+ if ( maxpmw ) { // we have iconsets
+ w += maxpmw;
+ w += 6; // add a little extra border around the iconset
+ }
+
+ if ( checkable && maxpmw < windowsCheckMarkWidth ) {
+ w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
+ }
+
+ if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
+ w += motifCheckMarkHMargin; // add space to separate the columns
+
+ w += windowsRightBorder; // windows has a strange wide border on the right side
+
+ return w;
+}
+
+static int popupMenuItemHeight( bool /*checkable*/, TQMenuItem* mi, const TQFontMetrics& fm )
+{
+ int h = 0;
+ if ( mi->isSeparator() ) // separator height
+ h = motifSepHeight;
+ else if ( mi->pixmap() ) // pixmap height
+ h = mi->pixmap()->height() + 2*motifItemFrame;
+ else // text height
+ h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
+
+ if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
+ h = TQMAX( h, mi->iconSet()->pixmap( TQIconSet::Small, TQIconSet::Normal ).height() + 2*motifItemFrame );
+ }
+ if ( mi->custom() )
+ h = TQMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
+ return h;
+}
+
+void drawPopupMenuItem( TQPainter* p, bool checkable,
+ int maxpmw, int tab, TQMenuItem* mi,
+ const TQPalette& pal, bool act,
+ bool enabled,
+ int x, int y, int w, int h)
+{
+
+}
+
+/*! \reimp */
+void TQCompactStyle::drawControl( ControlElement element, TQPainter *p, const TQWidget *widget, const TQRect &r,
+ const TQColorGroup &g, SFlags flags, const TQStyleOption& opt )
+{
+ switch ( element ) {
+ case CE_PopupMenuItem:
+ {
+ if (! widget || opt.isDefault())
+ break;
+
+ const TQPopupMenu *popupmenu = (const TQPopupMenu *) widget;
+ TQMenuItem *mi = opt.menuItem();
+ if ( !mi )
+ break;
+
+ int tab = opt.tabWidth();
+ int maxpmw = opt.maxIconWidth();
+ bool dis = !(flags & Style_Enabled);
+ bool checkable = popupmenu->isCheckable();
+ bool act = flags & Style_Active;
+ int x, y, w, h;
+ r.rect( &x, &y, &w, &h );
+
+ TQColorGroup itemg = g;
+
+ if ( checkable )
+ maxpmw = TQMAX( maxpmw, 8 ); // space for the checkmarks
+
+ int checkcol = maxpmw;
+
+ if ( mi && mi->isSeparator() ) { // draw separator
+ p->setPen( g.dark() );
+ p->drawLine( x, y, x+w, y );
+ p->setPen( g.light() );
+ p->drawLine( x, y+1, x+w, y+1 );
+ return;
+ }
+
+ TQBrush fill = act? g.brush( TQColorGroup::Highlight ) :
+ g.brush( TQColorGroup::Button );
+ p->fillRect( x, y, w, h, fill);
+
+ if ( !mi )
+ return;
+
+ if ( mi->isChecked() ) {
+ if ( act && !dis ) {
+ qDrawShadePanel( p, x, y, checkcol, h,
+ g, TRUE, 1, &g.brush( TQColorGroup::Button ) );
+ } else {
+ qDrawShadePanel( p, x, y, checkcol, h,
+ g, TRUE, 1, &g.brush( TQColorGroup::Midlight ) );
+ }
+ } else if ( !act ) {
+ p->fillRect(x, y, checkcol , h,
+ g.brush( TQColorGroup::Button ));
+ }
+
+ if ( mi->iconSet() ) { // draw iconset
+ TQIconSet::Mode mode = dis ? TQIconSet::Disabled : TQIconSet::Normal;
+ if (act && !dis )
+ mode = TQIconSet::Active;
+ TQPixmap pixmap;
+ if ( checkable && mi->isChecked() )
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode, TQIconSet::On );
+ else
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode );
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ if ( act && !dis ) {
+ if ( !mi->isChecked() )
+ qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( TQColorGroup::Button ) );
+ }
+ TQRect cr( x, y, checkcol, h );
+ TQRect pmr( 0, 0, pixw, pixh );
+ pmr.moveCenter( cr.center() );
+ p->setPen( itemg.text() );
+ p->drawPixmap( pmr.topLeft(), pixmap );
+
+ TQBrush fill = act? g.brush( TQColorGroup::Highlight ) :
+ g.brush( TQColorGroup::Button );
+ p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
+ } else if ( checkable ) { // just "checking"...
+ int mw = checkcol + motifItemFrame;
+ int mh = h - 2*motifItemFrame;
+ if ( mi->isChecked() ) {
+
+ SFlags cflags = Style_Default;
+ if (! dis)
+ cflags |= Style_Enabled;
+ if (act)
+ cflags |= Style_On;
+
+ drawPrimitive( PE_CheckMark, p, TQRect(x + motifItemFrame + 2, y + motifItemFrame,
+ mw, mh), itemg, cflags, opt );
+ }
+ }
+
+ p->setPen( act ? g.highlightedText() : g.buttonText() );
+
+ TQColor discol;
+ if ( dis ) {
+ discol = itemg.text();
+ p->setPen( discol );
+ }
+
+ int xm = motifItemFrame + checkcol + motifItemHMargin;
+
+ if ( mi->custom() ) {
+ int m = motifItemVMargin;
+ p->save();
+ if ( dis && !act ) {
+ p->setPen( g.light() );
+ mi->custom()->paint( p, itemg, act, !dis,
+ x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
+ p->setPen( discol );
+ }
+ mi->custom()->paint( p, itemg, act, !dis,
+ x+xm, y+m, w-xm-tab+1, h-2*m );
+ p->restore();
+ }
+ TQString s = mi->text();
+ if ( !s.isNull() ) { // draw text
+ int t = s.find( '\t' );
+ int m = motifItemVMargin;
+ const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
+ if ( t >= 0 ) { // draw tab text
+ if ( dis && !act ) {
+ p->setPen( g.light() );
+ p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
+ y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
+ p->setPen( discol );
+ }
+ p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame,
+ y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
+ s = s.left( t );
+ }
+ if ( dis && !act ) {
+ p->setPen( g.light() );
+ p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t );
+ p->setPen( discol );
+ }
+ p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
+ } else if ( mi->pixmap() ) { // draw pixmap
+ TQPixmap *pixmap = mi->pixmap();
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( OpaqueMode );
+ p->drawPixmap( x+xm, y+motifItemFrame, *pixmap );
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( TransparentMode );
+ }
+ if ( mi->popup() ) { // draw sub menu arrow
+ int dim = (h-2*motifItemFrame) / 2;
+ if ( act ) {
+ if ( !dis )
+ discol = white;
+ TQColorGroup g2( discol, g.highlight(),
+ white, white,
+ dis ? discol : white,
+ discol, white );
+ drawPrimitive(PE_ArrowRight, p, TQRect(x+w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, dim, dim),
+ g2, Style_Enabled);
+ } else {
+ drawPrimitive(PE_ArrowRight, p, TQRect(x+w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, dim, dim),
+ g, !dis ? Style_Enabled : Style_Default);
+ }
+ }
+ }
+ break;
+
+ default:
+ TQWindowsStyle::drawControl( element, p, widget, r, g, flags, opt );
+ break;
+ }
+}
+
+#endif
diff --git a/src/styles/qcompactstyle.h b/src/styles/qcompactstyle.h
new file mode 100644
index 000000000..943ab2804
--- /dev/null
+++ b/src/styles/qcompactstyle.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Definition of compact style class, good for small displays
+**
+** Created : 000623
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQCOMPACTSTYLE_H
+#define TQCOMPACTSTYLE_H
+
+#ifndef QT_H
+#include "qwindowsstyle.h"
+#endif // QT_H
+
+#if !defined(QT_NO_STYLE_COMPACT) || defined(QT_PLUGIN)
+
+#if defined(QT_PLUGIN)
+#define Q_EXPORT_STYLE_COMPACT
+#else
+#define Q_EXPORT_STYLE_COMPACT Q_EXPORT
+#endif
+
+class Q_EXPORT_STYLE_COMPACT TQCompactStyle : public TQWindowsStyle
+{
+public:
+ TQCompactStyle();
+
+ int pixelMetric( PixelMetric metric, const TQWidget *widget = 0 );
+
+ void drawControl( ControlElement element, TQPainter *p, const TQWidget *w, const TQRect &r,
+ const TQColorGroup &cg, SFlags how = Style_Default, const TQStyleOption& = TQStyleOption::Default );
+
+private: // Disabled copy constructor and operator=
+#if defined(Q_DISABLE_COPY)
+ TQCompactStyle( const TQCompactStyle & );
+ TQCompactStyle& operator=( const TQCompactStyle & );
+#endif
+};
+
+#endif // QT_NO_STYLE_WINDOWS
+
+#endif // TQCOMPACTSTYLE_H
diff --git a/src/styles/qinterlacestyle.cpp b/src/styles/qinterlacestyle.cpp
new file mode 100644
index 000000000..753c4def2
--- /dev/null
+++ b/src/styles/qinterlacestyle.cpp
@@ -0,0 +1,805 @@
+/****************************************************************************
+**
+** Implementation of TQInterlaceStyle class
+**
+** Created : 010122
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#if 0 // ###### not ported to new API yet
+
+#include "qinterlacestyle.h"
+
+#if !defined(QT_NO_STYLE_INTERLACE) || defined(QT_PLUGIN)
+
+#include "qapplication.h"
+#include "qpainter.h"
+#include "qdrawutil.h" // for now
+#include "qpalette.h" // for now
+#include "qwidget.h"
+#include "qlabel.h"
+#include "qpushbutton.h"
+#include "qwidget.h"
+#include "qrangecontrol.h"
+#include "qscrollbar.h"
+#include "qlistbox.h"
+
+#include <limits.h>
+
+/*!
+ \class TQInterlaceStyle qinterlacestyle.h
+ \brief The TQInterlaceStyle class provides a Look and Feel suitable for interlaced displays.
+ \ingroup appearance
+
+ This class implements a look and feel that reduces flicker as much as
+ possible on interlaced displays (i.e. television). It is an experimental
+ style. In addition to using this style you will need to select a font
+ that does not flicker.
+*/
+
+/*!
+ Constructs a TQInterlaceStyle
+*/
+TQInterlaceStyle::TQInterlaceStyle() : TQMotifStyle()
+{
+ setUseHighlightColors( TRUE );
+}
+
+/*! \reimp
+*/
+int TQInterlaceStyle::buttonDefaultIndicatorWidth() const
+{
+ return 0;
+}
+
+/*! \reimp
+*/
+int TQInterlaceStyle::setSliderThickness() const
+{
+ return 18;
+}
+
+/*! \reimp
+*/
+TQSize TQInterlaceStyle::scrollBarExtent() const
+{
+ return TQSize( 18, 18 );
+}
+
+/*! \reimp
+*/
+int TQInterlaceStyle::defaultFrameWidth() const
+{
+ return 2;
+}
+
+/*!
+ \reimp
+ */
+void TQInterlaceStyle::polish( TQApplication *app)
+{
+ oldPalette = app->palette();
+#if 0
+ TQColor bg( 128, 64, 128 );
+ TQColor btn( 255, 145, 0 );
+ TQColor mid = bg.dark( 120 );
+ TQColor low = mid.dark( 120 );
+ TQColor fg( white );
+#else
+ TQColor bg( 224, 224, 224 );
+ TQColor btn = bg.dark( 105 );
+ TQColor mid = bg.dark( 120 );
+ TQColor low = mid.dark( 120 );
+ TQColor fg( black );
+#endif
+
+ TQColorGroup cg( fg, btn, low, low, mid, black, black, white, bg );
+ cg.setColor( TQColorGroup::Highlight, TQColor( 255, 255, 192 ) );
+ cg.setColor( TQColorGroup::HighlightedText, black );
+
+ TQColorGroup dcg( cg );
+ dcg.setColor( TQColorGroup::ButtonText, low );
+ dcg.setColor( TQColorGroup::Text, low );
+
+ app->setPalette( TQPalette( cg, dcg, cg ), TRUE );
+}
+
+/*!
+ \reimp
+ */
+void TQInterlaceStyle::unPolish( TQApplication *app)
+{
+ app->setPalette(oldPalette, TRUE);
+}
+
+/*!
+ \reimp
+ */
+void TQInterlaceStyle::polish( TQWidget* w)
+{
+
+ // the polish function sets some widgets to transparent mode and
+ // some to translate background mode in order to get the full
+ // benefit from the nice pixmaps in the color group.
+
+ if ( w->inherits("TQLCDNumber") ){
+ return;
+ }
+
+ if ( !w->isTopLevel() ) {
+ if ( w->inherits("TQGroupBox")
+ || w->inherits("TQTabWidget")
+ || w->inherits("TQPushButton") ) {
+ w->setAutoMask( TRUE );
+ return;
+ }
+ if (w->inherits("TQLabel")
+ || w->inherits("TQSlider")
+ || w->inherits("TQButton")
+ || w->inherits("TQProgressBar")
+ ){
+ w->setBackgroundOrigin( TQWidget::ParentOrigin );
+ }
+ }
+
+ if ( w->inherits( "TQFrame" ) ) {
+ TQFrame *f = (TQFrame *)w;
+ switch ( f->frameShape() ) {
+ case TQFrame::WinPanel:
+ f->setFrameShape( TQFrame::StyledPanel );
+
+ case TQFrame::Panel:
+ case TQFrame::Box:
+ case TQFrame::StyledPanel:
+ case TQFrame::PopupPanel:
+ if ( f->frameWidth() == 1 )
+ f->setLineWidth( 2 );
+ break;
+ default:
+ break;
+ }
+ }
+
+ if ( w->inherits( "TQListBox" ) ) {
+ // the list box in combos has an ugly border otherwise
+ TQFrame *f = (TQFrame *)w;
+ if ( f->frameShadow() == TQFrame::Plain ) {
+ f->setFrameShadow( TQFrame::Raised );
+ f->setLineWidth( 1 );
+ }
+ }
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::unPolish( TQWidget* w)
+{
+
+ // the polish function sets some widgets to transparent mode and
+ // some to translate background mode in order to get the full
+ // benefit from the nice pixmaps in the color group.
+
+ if ( w->inherits("TQLCDNumber") ){
+ return;
+ }
+
+ if ( !w->isTopLevel() ) {
+ if ( w->inherits("TQGroupBox")
+ || w->inherits("TQTabWidget")
+ || w->inherits("TQPushButton" ) ) {
+ w->setAutoMask( FALSE );
+ return;
+ }
+ if (w->inherits("TQLabel")
+ || w->inherits("TQSlider")
+ || w->inherits("TQButton")
+ || w->inherits("TQProgressBar")
+ ){
+ w->setBackgroundOrigin( TQWidget::WidgetOrigin );
+ }
+ }
+
+}
+
+/*!
+ \reimp
+*/
+TQRect TQInterlaceStyle::pushButtonContentsRect( TQPushButton *btn )
+{
+ int fw = 0;
+ if ( btn->isDefault() || btn->autoDefault() )
+ fw = buttonDefaultIndicatorWidth();
+
+ return buttonRect( fw+5, fw, btn->width()-2*fw-10, btn->height()-2*fw );
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawFocusRect ( TQPainter *p, const TQRect &/*r*/, const TQColorGroup &g, const TQColor * bg, bool /*atBorder*/ )
+{
+ if (bg ) {
+ int h,s,v;
+ bg->hsv(&h,&s,&v);
+ if (v >= 128)
+ p->setPen( TQt::black );
+ else
+ p->setPen( TQt::white );
+ }
+ else
+ p->setPen( g.foreground() );
+/*
+ p->setBrush( NoBrush );
+ if ( atBorder ) {
+ p->drawRect( TQRect( r.x()+1, r.y()+2, r.width()-2, r.height()-4 ) );
+ p->drawRect( TQRect( r.x()+2, r.y()+1, r.width()-4, r.height()-2 ) );
+ } else {
+ p->drawRect( TQRect( r.x(), r.y()+1, r.width(), r.height()-2 ) );
+ p->drawRect( TQRect( r.x()+1, r.y(), r.width()-2, r.height() ) );
+ }
+*/
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawButton( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &g, bool /* sunken */,
+ const TQBrush *fill )
+{
+ const int lineWidth = 2;
+
+ p->setBrush( g.brush( TQColorGroup::Dark ) );
+ p->setPen( NoPen );
+ p->drawRect( x+1, y+1, 2, 2 );
+ p->drawRect( x+w-3, y+1, 2, 2 );
+ p->drawRect( x+1, y+h-3, 2, 2 );
+ p->drawRect( x+w-3, y+h-3, 2, 2 );
+
+ p->drawRect( x+2, y, w-4, 2 );
+ p->drawRect( x+2, y+h-lineWidth, w-4, lineWidth );
+ p->drawRect( x, y+2, lineWidth, h-4 );
+ p->drawRect( x+w-lineWidth, y+2, lineWidth, h-4 );
+
+ if ( fill ) {
+ x += 2;
+ y += 2;
+ w -= 4;
+ h -= 4;
+ p->setBrush( *fill );
+ p->setPen( NoPen );
+ p->drawRect( x+1, y, w-2, 1 );
+ p->drawRect( x, y+1, w, h-2 );
+ p->drawRect( x+1, y+h-1, w-2, 1 );
+ }
+}
+
+/*! \reimp */
+void TQInterlaceStyle::drawButtonMask( TQPainter * p, int x, int y, int w, int h )
+{
+ TQBrush fill( color1 );
+ TQColorGroup cg;
+ cg.setBrush( TQColorGroup::Dark, color1 );
+ drawButton( p, x, y, w, h, cg, FALSE, &fill );
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawBevelButton( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &g, bool sunken, const TQBrush* fill )
+{
+ TQInterlaceStyle::drawButton(p, x, y, w, h, g, sunken, fill);
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawPushButton( TQPushButton* btn, TQPainter *p)
+{
+ TQColorGroup g = btn->colorGroup();
+ int x1, y1, x2, y2;
+
+ btn->rect().coords( &x1, &y1, &x2, &y2 ); // get coordinates
+
+ TQBrush fill( g.button() );
+ if ( btn->isDown() || btn->isOn() )
+ fill = g.mid();
+
+ if ( btn->hasFocus() )
+ g.setBrush( TQColorGroup::Dark, black );
+ drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, FALSE, &fill );
+
+ if ( btn->isMenuButton() ) {
+ int dx = (y1-y2-4)/3;
+ drawArrow( p, DownArrow, FALSE,
+ x2 - dx, dx, y1, y2 - y1,
+ g, btn->isEnabled() );
+ }
+
+ if ( p->brush().style() != NoBrush )
+ p->setBrush( NoBrush );
+}
+
+/*!
+ \reimp
+*/
+TQSize TQInterlaceStyle::indicatorSize () const
+{
+ return TQSize(13,13);
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawIndicator( TQPainter * p, int x, int y, int w, int h, const TQColorGroup &g, int s, bool down, bool enabled )
+{
+ p->fillRect( x, y, w, h, g.brush( TQColorGroup::Background ) );
+ TQBrush fill;
+ if ( s == TQButton::NoChange ) {
+ TQBrush b = p->brush();
+ TQColor c = p->backgroundColor();
+ p->setBackgroundMode( TransparentMode );
+ p->setBackgroundColor( green );
+ fill = TQBrush(g.base(), Dense4Pattern);
+ p->setBackgroundColor( c );
+ p->setBrush( b );
+ } else if ( down )
+ fill = g.brush( TQColorGroup::Button );
+ else
+ fill = g.brush( enabled ? TQColorGroup::Base : TQColorGroup::Background );
+
+ drawButton( p, x, y, w, h, g, FALSE, &fill );
+
+ if ( s != TQButton::Off ) {
+ TQPointArray a( 7*2 );
+ int i, xx, yy;
+ xx = x+3;
+ yy = y+5;
+ for ( i=0; i<3; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy++;
+ }
+ yy -= 2;
+ for ( i=3; i<7; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy--;
+ }
+ if ( s == TQButton::NoChange ) {
+ p->setPen( g.dark() );
+ } else {
+ p->setPen( g.text() );
+ }
+ p->drawLineSegments( a );
+ }
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawIndicatorMask( TQPainter *p, int x, int y, int w, int h, int )
+{
+ drawButtonMask( p, x, y, w, h );
+}
+
+/*!
+ \reimp
+*/
+TQSize TQInterlaceStyle::exclusiveIndicatorSize() const
+{
+ return TQSize(13,13);
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawExclusiveIndicator( TQPainter *p, int x, int y, int w, int h, const TQColorGroup &g, bool on, bool down, bool enabled )
+{
+ p->fillRect( x, y, w, h, g.brush( TQColorGroup::Background ) );
+ p->setBrush( g.dark() );
+ p->setPen( TQPen( NoPen ) );
+ p->drawEllipse( x, y, w, h );
+
+ x += 2;
+ y += 2;
+ w -= 4;
+ h -= 4;
+ TQColor fillColor = ( down || !enabled ) ? g.button() : g.base();
+ p->setBrush( fillColor );
+ p->drawEllipse( x, y, w, h );
+
+ if ( on ) {
+ p->setBrush( g.text() );
+ p->drawEllipse( x+2, y+2, w-4, h-4 );
+ }
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawExclusiveIndicatorMask( TQPainter *p, int x, int y, int w, int h, bool )
+{
+ p->setBrush( color1 );
+ p->setPen( TQPen( NoPen ) );
+ p->drawEllipse( x, y, w, h );
+}
+
+static int get_combo_extra_width( int h, int *return_awh=0 )
+{
+ int awh;
+ if ( h < 8 ) {
+ awh = 6;
+ } else if ( h < 14 ) {
+ awh = h - 2;
+ } else {
+ awh = h/2;
+ }
+ if ( return_awh )
+ *return_awh = awh;
+ return awh*3/2;
+}
+
+/*!
+ \reimp
+*/
+TQRect TQInterlaceStyle::comboButtonRect ( int x, int y, int w, int h )
+{
+ TQRect r = buttonRect( x, y, w, h );
+ int ew = get_combo_extra_width( r.height() );
+ return TQRect(r.x(), r.y(), r.width()-ew, r.height());
+}
+
+static void get_combo_parameters( const TQRect &r,
+ int &ew, int &awh, int &ax,
+ int &ay, int &sh, int &dh,
+ int &sy )
+{
+ ew = get_combo_extra_width( r.height(), &awh );
+
+ sh = (awh+3)/4;
+ if ( sh < 3 )
+ sh = 3;
+ dh = sh/2 + 1;
+
+ ay = r.y() + (r.height()-awh-sh-dh)/2;
+ if ( ay < 0 ) {
+ //panic mode
+ ay = 0;
+ sy = r.height();
+ } else {
+ sy = ay+awh+dh;
+ }
+ ax = r.x() + r.width() - ew +(ew-awh)/2;
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawComboButton( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &g,
+ bool /* sunken */,
+ bool /*editable*/,
+ bool /*enabled */,
+ const TQBrush *fb )
+{
+ TQBrush fill = fb ? *fb : g.brush( TQColorGroup::Button );
+
+ int awh, ax, ay, sh, sy, dh, ew;
+ get_combo_parameters( buttonRect(x,y,w,h), ew, awh, ax, ay, sh, dh, sy );
+
+ drawButton( p, x, y, w, h, g, FALSE, &fill );
+
+ qDrawArrow( p, DownArrow, MotifStyle, FALSE, ax, ay, awh, awh, g, TRUE );
+
+ p->setPen( g.dark() );
+ p->drawRect( ax+1, sy+1, awh-1, sh-1 );
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawPushButtonLabel( TQPushButton* btn, TQPainter *p)
+{
+ TQRect r = btn->rect();
+ int x, y, w, h;
+ r.rect( &x, &y, &w, &h );
+
+ int x1, y1, x2, y2;
+ btn->rect().coords( &x1, &y1, &x2, &y2 ); // get coordinates
+ int dx = 0;
+ int dy = 0;
+ if ( btn->isMenuButton() )
+ dx = (y2-y1) / 3;
+ if ( btn->isOn() || btn->isDown() ) {
+// dx--;
+// dy--;
+ }
+ if ( dx || dy )
+ p->translate( dx, dy );
+
+ x += 2; y += 2; w -= 4; h -= 4;
+ TQColorGroup g = btn->colorGroup();
+ const TQColor *col = &btn->colorGroup().buttonText();
+ if ( (btn->isDown() || btn->isOn()) )
+ col = &btn->colorGroup().brightText();
+ else if ( !btn->isEnabled() )
+ col = &btn->colorGroup().dark();
+ drawItem( p, x, y, w, h,
+ AlignCenter|ShowPrefix,
+ g, btn->isEnabled(),
+ btn->pixmap(), btn->text(), -1, col );
+
+ if ( dx || dy )
+ p->translate( -dx, -dy );
+}
+
+#define HORIZONTAL (sb->orientation() == TQScrollBar::Horizontal)
+#define VERTICAL !HORIZONTAL
+#define MOTIF_BORDER defaultFrameWidth()
+#define SLIDER_MIN 9 // ### motif says 6 but that's too small
+
+
+/*! \reimp */
+
+void TQInterlaceStyle::scrollBarMetrics( const TQScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int &buttonDim )
+{
+ int maxLength;
+ int b = MOTIF_BORDER;
+ int length = HORIZONTAL ? sb->width() : sb->height();
+ int extent = HORIZONTAL ? sb->height() : sb->width();
+
+ if ( length > ( extent - b*2 - 1 )*2 + b*2 )
+ buttonDim = extent - b*2;
+ else
+ buttonDim = ( length - b*2 )/2 - 1;
+
+ sliderMin = b + buttonDim;
+ maxLength = length - b*2 - buttonDim*2;
+
+ if ( sb->maxValue() == sb->minValue() ) {
+ sliderLength = maxLength;
+ } else {
+ uint range = sb->maxValue()-sb->minValue();
+ sliderLength = (sb->pageStep()*maxLength)/
+ (range + sb->pageStep());
+ if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 )
+ sliderLength = SLIDER_MIN;
+ if ( sliderLength > maxLength )
+ sliderLength = maxLength;
+ }
+ sliderMax = sliderMin + maxLength - sliderLength;
+
+}
+
+
+/*! \reimp */
+
+void TQInterlaceStyle::drawScrollBarControls( TQPainter* p, const TQScrollBar* sb,
+ int sliderStart, uint controls,
+ uint activeControl )
+{
+#define ADD_LINE_ACTIVE ( activeControl == AddLine )
+#define SUB_LINE_ACTIVE ( activeControl == SubLine )
+ TQColorGroup g = sb->colorGroup();
+
+ int sliderMin, sliderMax, sliderLength, buttonDim;
+ scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
+
+ TQBrush fill = g.brush( TQColorGroup::Mid );
+ if (sb->backgroundPixmap() ){
+ fill = TQBrush( g.mid(), *sb->backgroundPixmap() );
+ }
+
+ if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) )
+ drawPanel( p, 0, 0, sb->width(), sb->height(), g, FALSE, 2, &fill );
+
+ if (sliderStart > sliderMax) { // sanity check
+ sliderStart = sliderMax;
+ }
+
+ int b = MOTIF_BORDER;
+ int dimB = buttonDim;
+ TQRect addB;
+ TQRect subB;
+ TQRect addPageR;
+ TQRect subPageR;
+ TQRect sliderR;
+ int addX, addY, subX, subY;
+ int length = HORIZONTAL ? sb->width() : sb->height();
+ int extent = HORIZONTAL ? sb->height() : sb->width();
+
+ if ( HORIZONTAL ) {
+ subY = addY = ( extent - dimB ) / 2;
+ subX = b;
+ addX = length - dimB - b;
+ } else {
+ subX = addX = ( extent - dimB ) / 2;
+ subY = b;
+ addY = length - dimB - b;
+ }
+
+ subB.setRect( subX,subY,dimB,dimB );
+ addB.setRect( addX,addY,dimB,dimB );
+
+ int sliderEnd = sliderStart + sliderLength;
+ int sliderW = extent - b*2;
+ if ( HORIZONTAL ) {
+ subPageR.setRect( subB.right() + 1, b,
+ sliderStart - subB.right() , sliderW );
+ addPageR.setRect( sliderEnd-1, b, addX - sliderEnd+1, sliderW );
+ sliderR .setRect( sliderStart, b, sliderLength, sliderW );
+ } else {
+ subPageR.setRect( b, subB.bottom()+1, sliderW,
+ sliderStart - subB.bottom() );
+ addPageR.setRect( b, sliderEnd-1, sliderW, addY - sliderEnd + 1);
+ sliderR .setRect( b, sliderStart, sliderW, sliderLength );
+ }
+
+ if ( controls & AddLine )
+ drawArrow( p, VERTICAL ? DownArrow : RightArrow,
+ ADD_LINE_ACTIVE, addB.x(), addB.y(),
+ addB.width(), addB.height(), g, TRUE );
+ if ( controls & SubLine )
+ drawArrow( p, VERTICAL ? UpArrow : LeftArrow,
+ SUB_LINE_ACTIVE, subB.x(), subB.y(),
+ subB.width(), subB.height(), g, TRUE );
+
+ if ( controls & SubPage )
+ p->fillRect( subPageR, fill );
+
+ if ( controls & AddPage )
+ p->fillRect( addPageR, fill );
+
+ if ( controls & Slider ) {
+ TQPoint bo = p->brushOrigin();
+ p->setBrushOrigin(sliderR.topLeft());
+ if ( sliderR.isValid() )
+ drawButton( p, sliderR.x(), sliderR.y(),
+ sliderR.width(), sliderR.height(), g,
+ FALSE, &g.brush( TQColorGroup::Button ) );
+ p->setBrushOrigin(bo);
+ }
+
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawSlider ( TQPainter * p, int x, int y, int w, int h, const TQColorGroup & g, Orientation orient, bool, bool)
+{
+ p->fillRect( x, y, w, h, g.brush( TQColorGroup::Background ) );
+ drawButton( p, x, y, w, h, g, FALSE, &g.brush( TQColorGroup::Button ) );
+ if ( orient == Horizontal ) {
+ TQCOORD mid = x + w / 2;
+ qDrawShadeLine( p, mid, y , mid, y + h - 2, g, TRUE, 1);
+ } else {
+ TQCOORD mid = y +h / 2;
+ qDrawShadeLine( p, x, mid, x + w - 2, mid, g, TRUE, 1);
+ }
+}
+
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawSliderGroove ( TQPainter * p, int x, int y, int w, int h, const TQColorGroup & g, TQCOORD , Orientation o)
+{
+ p->setBrush( g.brush( TQColorGroup::Dark ) );
+ p->setPen( NoPen );
+
+ if ( o == Horizontal )
+ drawButton( p, x, y+h/2-3, w, 6, g, FALSE, &g.brush( TQColorGroup::Mid ) );
+ else
+ drawButton( p, x+w/2-3, y, 6, h, g, FALSE, &g.brush( TQColorGroup::Mid ) );
+}
+
+
+/*!
+ \reimp
+*/
+int TQInterlaceStyle::splitterWidth() const
+{
+ return TQMAX( 12, TQApplication::globalStrut().width() );
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawSplitter( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &g, Orientation orient)
+{
+ const int motifOffset = 12;
+ int sw = splitterWidth();
+ if ( orient == Horizontal ) {
+ TQCOORD xPos = x + w/2;
+ TQCOORD kPos = motifOffset;
+ TQCOORD kSize = sw - 4;
+
+ qDrawShadeLine( p, xPos, kPos + kSize - 1 ,
+ xPos, h, g );
+ drawPanel( p, xPos-sw/2+2, kPos,
+ kSize, kSize, g, FALSE, 2,
+ &g.brush( TQColorGroup::Button ));
+ qDrawShadeLine( p, xPos, 0, xPos, kPos, g );
+ } else {
+ TQCOORD yPos = y + h/2;
+ TQCOORD kPos = w - motifOffset - sw;
+ TQCOORD kSize = sw - 4;
+
+ qDrawShadeLine( p, 0, yPos, kPos, yPos, g );
+ drawPanel( p, kPos, yPos-sw/2+2,
+ kSize, kSize, g, FALSE, 2,
+ &g.brush( TQColorGroup::Button ));
+ qDrawShadeLine( p, kPos + kSize -1, yPos,
+ w, yPos, g );
+ }
+
+}
+
+/*!
+ \reimp
+*/
+void TQInterlaceStyle::drawPanel( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &g, bool /*sunken*/,
+ int lineWidth, const TQBrush *fill )
+{
+ if ( lineWidth < 2 )
+ lineWidth = 2;
+
+ p->setBrush( g.brush( TQColorGroup::Dark ) );
+ p->setPen( NoPen );
+
+ p->drawRect( x, y, w, lineWidth );
+ p->drawRect( x, y+h-lineWidth, w, lineWidth );
+ p->drawRect( x, y, lineWidth, h );
+ p->drawRect( x+w-lineWidth, y, lineWidth, h );
+
+ if ( fill ) {
+ x += lineWidth;
+ y += lineWidth;
+ w -= 2*lineWidth;
+ h -= 2*lineWidth;
+ p->setBrush( *fill );
+ p->setPen( NoPen );
+ p->drawRect( x, y, w, h );
+ }
+}
+
+#endif // QT_NO_STYLE_INTERLACE
+
+#endif
diff --git a/src/styles/qinterlacestyle.h b/src/styles/qinterlacestyle.h
new file mode 100644
index 000000000..7ff508d9d
--- /dev/null
+++ b/src/styles/qinterlacestyle.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Implementation of TQInterlaceStyle widget class
+**
+** Created : 010122
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#if 0 // ###### not ported to new API yet
+#ifndef TQINTERLACESTYLE_H
+#define TQINTERLACESTYLE_H
+
+#ifndef QT_H
+#include "qmotifstyle.h"
+#endif // QT_H
+
+#if !defined(QT_NO_STYLE_INTERLACE) || defined(QT_PLUGIN)
+
+#include "qpalette.h"
+
+class Q_EXPORT TQInterlaceStyle : public TQMotifStyle
+{
+public:
+ TQInterlaceStyle();
+ void polish( TQApplication*);
+ void unPolish( TQApplication*);
+ void polish( TQWidget* );
+ void unPolish( TQWidget* );
+
+ int defaultFrameWidth() const;
+ TQRect pushButtonContentsRect( TQPushButton *btn );
+
+ void drawFocusRect ( TQPainter *, const TQRect &, const TQColorGroup &, const TQColor * bg = 0, bool = FALSE );
+ void drawButton( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &g, bool sunken = FALSE,
+ const TQBrush *fill = 0 );
+ void drawButtonMask ( TQPainter * p, int x, int y, int w, int h );
+ void drawBevelButton( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &g, bool sunken = FALSE,
+ const TQBrush *fill = 0 );
+
+ void drawPushButton( TQPushButton* btn, TQPainter *p);
+ TQSize indicatorSize () const;
+ void drawIndicator ( TQPainter * p, int x, int y, int w, int h, const TQColorGroup & g, int state, bool down = FALSE, bool enabled = TRUE );
+ void drawIndicatorMask( TQPainter *p, int x, int y, int w, int h, int );
+ TQSize exclusiveIndicatorSize () const;
+ void drawExclusiveIndicator( TQPainter * p, int x, int y, int w, int h, const TQColorGroup & g, bool on, bool down = FALSE, bool enabled = TRUE );
+ void drawExclusiveIndicatorMask( TQPainter * p, int x, int y, int w, int h, bool );
+ TQRect comboButtonRect ( int x, int y, int w, int h );
+ void drawComboButton( TQPainter *p, int x, int y, int w, int h, const TQColorGroup &g, bool sunken, bool editable, bool enabled, const TQBrush *fb );
+ void drawPushButtonLabel( TQPushButton* btn, TQPainter *p);
+ void drawPanel( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &, bool sunken,
+ int lineWidth, const TQBrush *fill );
+
+ void scrollBarMetrics( const TQScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int &buttonDim );
+ void drawScrollBarControls( TQPainter* p, const TQScrollBar* sb, int sliderStart, uint controls, uint activeControl );
+ void drawSlider( TQPainter * p, int x, int y, int w, int h, const TQColorGroup & g, Orientation, bool tickAbove, bool tickBelow );
+ void drawSliderGroove( TQPainter * p, int x, int y, int w, int h, const TQColorGroup & g, TQCOORD c, Orientation );
+ int splitterWidth() const;
+ void drawSplitter( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &g, Orientation orient);
+
+ int buttonDefaultIndicatorWidth() const;
+ int setSliderThickness() const;
+ TQSize scrollBarExtent() const;
+
+private:
+ TQPalette oldPalette;
+};
+
+#endif // QT_NO_STYLE_INTERLACE
+
+#endif
+#endif
diff --git a/src/styles/qmotifplusstyle.cpp b/src/styles/qmotifplusstyle.cpp
new file mode 100644
index 000000000..1d76dc106
--- /dev/null
+++ b/src/styles/qmotifplusstyle.cpp
@@ -0,0 +1,1584 @@
+/****************************************************************************
+**
+** Implementation of TQMotifPlusStyle class
+**
+** Created : 000727
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qmotifplusstyle.h"
+
+#if !defined(QT_NO_STYLE_MOTIFPLUS) || defined(QT_PLUGIN)
+
+#include "qmenubar.h"
+#include "qapplication.h"
+#include "qpainter.h"
+#include "qpalette.h"
+#include "qframe.h"
+#include "qpushbutton.h"
+#include "qcheckbox.h"
+#include "qradiobutton.h"
+#include "qcombobox.h"
+#include "qlineedit.h"
+#include "qspinbox.h"
+#include "qslider.h"
+#include "qdrawutil.h"
+#include "qscrollbar.h"
+#include "qtabbar.h"
+#include "qtoolbar.h"
+#include "qguardedptr.h"
+#include "qlayout.h"
+
+
+struct TQMotifPlusStylePrivate
+{
+ TQMotifPlusStylePrivate()
+ : hoverWidget(0), hovering(FALSE), sliderActive(FALSE), mousePressed(FALSE),
+ scrollbarElement(0), lastElement(0), ref(1)
+ { ; }
+
+ TQGuardedPtr<TQWidget> hoverWidget;
+ bool hovering, sliderActive, mousePressed;
+ int scrollbarElement, lastElement, ref;
+ TQPoint mousePos;
+};
+
+static TQMotifPlusStylePrivate * singleton = 0;
+
+
+static void drawMotifPlusShade(TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &g,
+ bool sunken, bool mouseover,
+ const TQBrush *fill = 0)
+{
+ TQPen oldpen = p->pen();
+ TQPointArray a(4);
+ TQColor button =
+ mouseover ? g.midlight() : g.button();
+ TQBrush brush =
+ mouseover ? g.brush(TQColorGroup::Midlight) : g.brush(TQColorGroup::Button);
+ int x, y, w, h;
+
+ r.rect(&x, &y, &w, &h);
+
+ if (sunken) p->setPen(g.dark()); else p->setPen(g.light());
+ a.setPoint(0, x, y + h - 1);
+ a.setPoint(1, x, y);
+ a.setPoint(2, x, y);
+ a.setPoint(3, x + w - 1, y);
+ p->drawLineSegments(a);
+
+ if (sunken) p->setPen(TQt::black); else p->setPen(button);
+ a.setPoint(0, x + 1, y + h - 2);
+ a.setPoint(1, x + 1, y + 1);
+ a.setPoint(2, x + 1, y + 1);
+ a.setPoint(3, x + w - 2, y + 1);
+ p->drawLineSegments(a);
+
+ if (sunken) p->setPen(button); else p->setPen(g.dark());
+ a.setPoint(0, x + 2, y + h - 2);
+ a.setPoint(1, x + w - 2, y + h - 2);
+ a.setPoint(2, x + w - 2, y + h - 2);
+ a.setPoint(3, x + w - 2, y + 2);
+ p->drawLineSegments(a);
+
+ if (sunken) p->setPen(g.light()); else p->setPen(TQt::black);
+ a.setPoint(0, x + 1, y + h - 1);
+ a.setPoint(1, x + w - 1, y + h - 1);
+ a.setPoint(2, x + w - 1, y + h - 1);
+ a.setPoint(3, x + w - 1, y);
+ p->drawLineSegments(a);
+
+ if (fill)
+ p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill);
+ else
+ p->fillRect(x + 2, y + 2, w - 4, h - 4, brush);
+
+ p->setPen(oldpen);
+}
+
+
+/*!
+ \class TQMotifPlusStyle qmotifplusstyle.h
+ \brief The TQMotifPlusStyle class provides a more sophisticated Motif-ish look and feel.
+
+ \ingroup appearance
+
+ This class implements a Motif-ish look and feel with the more
+ sophisticated bevelling as used by the GIMP Toolkit (GTK+) for
+ Unix/X11.
+*/
+
+/*!
+ Constructs a TQMotifPlusStyle
+
+ If \a hoveringHighlight is TRUE (the default), then the style will
+ not highlight push buttons, checkboxes, radiobuttons, comboboxes,
+ scrollbars or sliders.
+*/
+TQMotifPlusStyle::TQMotifPlusStyle(bool hoveringHighlight) : TQMotifStyle(TRUE)
+{
+ if ( !singleton )
+ singleton = new TQMotifPlusStylePrivate;
+ else
+ singleton->ref++;
+
+ useHoveringHighlight = hoveringHighlight;
+}
+
+/*! \reimp */
+TQMotifPlusStyle::~TQMotifPlusStyle()
+{
+ if ( singleton && singleton->ref-- <= 0) {
+ delete singleton;
+ singleton = 0;
+ }
+}
+
+
+/*! \reimp */
+void TQMotifPlusStyle::polish(TQPalette &)
+{
+}
+
+
+/*! \reimp */
+void TQMotifPlusStyle::polish(TQWidget *widget)
+{
+#ifndef QT_NO_FRAME
+ if (::qt_cast<TQFrame*>(widget) && ((TQFrame *) widget)->frameStyle() == TQFrame::Panel)
+ ((TQFrame *) widget)->setFrameStyle(TQFrame::WinPanel);
+#endif
+
+#ifndef QT_NO_MENUBAR
+ if (::qt_cast<TQMenuBar*>(widget) && ((TQMenuBar *) widget)->frameStyle() != TQFrame::NoFrame)
+ ((TQMenuBar *) widget)->setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised);
+#endif
+
+#ifndef QT_NO_TOOLBAR
+ if (::qt_cast<TQToolBar*>(widget))
+ widget->layout()->setMargin(2);
+#endif
+ if (useHoveringHighlight) {
+ if (::qt_cast<TQButton*>(widget) || ::qt_cast<TQComboBox*>(widget))
+ widget->installEventFilter(this);
+
+ if (::qt_cast<TQScrollBar*>(widget) || ::qt_cast<TQSlider*>(widget)) {
+ widget->setMouseTracking(TRUE);
+ widget->installEventFilter(this);
+ }
+ }
+
+ TQMotifStyle::polish(widget);
+}
+
+
+/*! \reimp */
+void TQMotifPlusStyle::unPolish(TQWidget *widget)
+{
+ widget->removeEventFilter(this);
+ TQMotifStyle::unPolish(widget);
+}
+
+
+/*! \reimp */
+void TQMotifPlusStyle::polish(TQApplication *)
+{
+}
+
+
+/*! \reimp */
+void TQMotifPlusStyle::unPolish(TQApplication *)
+{
+}
+
+
+/*! \reimp */
+int TQMotifPlusStyle::pixelMetric(PixelMetric metric, const TQWidget *widget) const
+{
+ int ret;
+
+ switch (metric) {
+ case PM_ScrollBarExtent:
+ ret = 15;
+ break;
+
+ case PM_ButtonDefaultIndicator:
+ ret = 5;
+ break;
+
+ case PM_ButtonMargin:
+ ret = 4;
+ break;
+
+ case PM_SliderThickness:
+ ret = 15;
+ break;
+
+ case PM_IndicatorWidth:
+ case PM_IndicatorHeight:
+ ret = 10;
+ break;
+
+ case PM_ExclusiveIndicatorWidth:
+ case PM_ExclusiveIndicatorHeight:
+ ret = 11;
+ break;
+
+ default:
+ ret = TQMotifStyle::pixelMetric(metric, widget);
+ break;
+ }
+
+ return ret;
+}
+
+
+/*! \reimp */
+void TQMotifPlusStyle::drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch (pe) {
+ case PE_HeaderSection:
+
+ case PE_ButtonCommand:
+ case PE_ButtonBevel:
+ case PE_ButtonTool:
+ if (flags & (Style_Down | Style_On | Style_Raised | Style_Sunken))
+ drawMotifPlusShade( p, r, cg, bool(flags & (Style_Down | Style_On)),
+ bool(flags & Style_MouseOver));
+ else if (flags & Style_MouseOver)
+ p->fillRect(r, cg.brush(TQColorGroup::Midlight));
+ else
+ p->fillRect(r, cg.brush(TQColorGroup::Button));
+ break;
+
+ case PE_Panel:
+ case PE_PanelPopup:
+ case PE_PanelMenuBar:
+ case PE_PanelDockWindow:
+ if ( opt.lineWidth() )
+ drawMotifPlusShade( p, r, cg, (flags & Style_Sunken), (flags & Style_MouseOver));
+ else if ( flags & Style_MouseOver )
+ p->fillRect(r, cg.brush(TQColorGroup::Midlight));
+ else
+ p->fillRect(r, cg.brush(TQColorGroup::Button));
+ break;
+
+ case PE_SpinWidgetUp:
+ drawPrimitive(PE_ArrowUp, p, r, cg, flags, opt);
+ break;
+
+ case PE_SpinWidgetDown:
+ drawPrimitive(PE_ArrowDown, p, r, cg, flags, opt);
+ break;
+
+ case PE_Indicator:
+ {
+ TQBrush fill;
+ if (flags & Style_On)
+ fill = cg.brush(TQColorGroup::Mid);
+ else if (flags & Style_MouseOver)
+ fill = cg.brush(TQColorGroup::Midlight);
+ else
+ fill = cg.brush(TQColorGroup::Button);
+
+ if (flags & Style_NoChange) {
+ qDrawPlainRect(p, r, cg.text(), 1, &fill);
+ p->drawLine(r.topRight(), r.bottomLeft());
+ } else
+ drawMotifPlusShade(p, r, cg, (flags & Style_On),
+ (flags & Style_MouseOver), &fill);
+ break;
+ }
+
+ case PE_ExclusiveIndicator:
+ {
+ TQPen oldpen = p->pen();
+ TQPointArray thick(8);
+ TQPointArray thin(4);
+ TQColor button = ((flags & Style_MouseOver) ? cg.midlight() : cg.button());
+ TQBrush brush = ((flags & Style_MouseOver) ?
+ cg.brush(TQColorGroup::Midlight) :
+ cg.brush(TQColorGroup::Button));
+ int x, y, w, h;
+ r.rect(&x, &y, &w, &h);
+
+ p->fillRect(x, y, w, h, brush);
+
+
+ if (flags & Style_On) {
+ thick.setPoint(0, x, y + (h / 2));
+ thick.setPoint(1, x + (w / 2), y);
+ thick.setPoint(2, x + 1, y + (h / 2));
+ thick.setPoint(3, x + (w / 2), y + 1);
+ thick.setPoint(4, x + (w / 2), y);
+ thick.setPoint(5, x + w - 1, y + (h / 2));
+ thick.setPoint(6, x + (w / 2), y + 1);
+ thick.setPoint(7, x + w - 2, y + (h / 2));
+ p->setPen(cg.dark());
+ p->drawLineSegments(thick);
+
+ thick.setPoint(0, x + 1, y + (h / 2) + 1);
+ thick.setPoint(1, x + (w / 2), y + h - 1);
+ thick.setPoint(2, x + 2, y + (h / 2) + 1);
+ thick.setPoint(3, x + (w / 2), y + h - 2);
+ thick.setPoint(4, x + (w / 2), y + h - 1);
+ thick.setPoint(5, x + w - 2, y + (h / 2) + 1);
+ thick.setPoint(6, x + (w / 2), y + h - 2);
+ thick.setPoint(7, x + w - 3, y + (h / 2) + 1);
+ p->setPen(cg.light());
+ p->drawLineSegments(thick);
+
+ thin.setPoint(0, x + 2, y + (h / 2));
+ thin.setPoint(1, x + (w / 2), y + 2);
+ thin.setPoint(2, x + (w / 2), y + 2);
+ thin.setPoint(3, x + w - 3, y + (h / 2));
+ p->setPen(TQt::black);
+ p->drawLineSegments(thin);
+
+ thin.setPoint(0, x + 3, y + (h / 2) + 1);
+ thin.setPoint(1, x + (w / 2), y + h - 3);
+ thin.setPoint(2, x + (w / 2), y + h - 3);
+ thin.setPoint(3, x + w - 4, y + (h / 2) + 1);
+ p->setPen(cg.mid());
+ p->drawLineSegments(thin);
+ } else {
+ thick.setPoint(0, x, y + (h / 2));
+ thick.setPoint(1, x + (w / 2), y);
+ thick.setPoint(2, x + 1, y + (h / 2));
+ thick.setPoint(3, x + (w / 2), y + 1);
+ thick.setPoint(4, x + (w / 2), y);
+ thick.setPoint(5, x + w - 1, y + (h / 2));
+ thick.setPoint(6, x + (w / 2), y + 1);
+ thick.setPoint(7, x + w - 2, y + (h / 2));
+ p->setPen(cg.light());
+ p->drawLineSegments(thick);
+
+ thick.setPoint(0, x + 2, y + (h / 2) + 1);
+ thick.setPoint(1, x + (w / 2), y + h - 2);
+ thick.setPoint(2, x + 3, y + (h / 2) + 1);
+ thick.setPoint(3, x + (w / 2), y + h - 3);
+ thick.setPoint(4, x + (w / 2), y + h - 2);
+ thick.setPoint(5, x + w - 3, y + (h / 2) + 1);
+ thick.setPoint(6, x + (w / 2), y + h - 3);
+ thick.setPoint(7, x + w - 4, y + (h / 2) + 1);
+ p->setPen(cg.dark());
+ p->drawLineSegments(thick);
+
+ thin.setPoint(0, x + 2, y + (h / 2));
+ thin.setPoint(1, x + (w / 2), y + 2);
+ thin.setPoint(2, x + (w / 2), y + 2);
+ thin.setPoint(3, x + w - 3, y + (h / 2));
+ p->setPen(button);
+ p->drawLineSegments(thin);
+
+ thin.setPoint(0, x + 1, y + (h / 2) + 1);
+ thin.setPoint(1, x + (w / 2), y + h - 1);
+ thin.setPoint(2, x + (w / 2), y + h - 1);
+ thin.setPoint(3, x + w - 2, y + (h / 2) + 1);
+ p->setPen(TQt::black);
+ p->drawLineSegments(thin);
+ }
+
+ p->setPen(oldpen);
+ break;
+ }
+
+
+
+ case PE_ArrowDown:
+ case PE_ArrowLeft:
+ case PE_ArrowRight:
+ case PE_ArrowUp:
+ {
+ TQPen oldpen = p->pen();
+ TQBrush oldbrush = p->brush();
+ TQPointArray poly(3);
+ TQColor button = (flags & Style_MouseOver) ? cg.midlight() : cg.button();
+ bool down = (flags & Style_Down);
+ int x, y, w, h;
+ r.rect(&x, &y, &w, &h);
+
+ p->save();
+ p->setBrush(button);
+
+ switch (pe) {
+ case PE_ArrowUp:
+ {
+ poly.setPoint(0, x + (w / 2), y );
+ poly.setPoint(1, x, y + h - 1);
+ poly.setPoint(2, x + w - 1, y + h - 1);
+ p->drawPolygon(poly);
+
+ if (down)
+ p->setPen(button);
+ else
+ p->setPen(cg.dark());
+ p->drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
+
+ if (down)
+ p->setPen(cg.light());
+ else
+ p->setPen(black);
+ p->drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+
+ if (down)
+ p->setPen(button);
+ else
+ p->setPen(cg.dark());
+ p->drawLine(x + w - 2, y + h - 1, x + (w / 2), y + 1);
+
+ if (down)
+ p->setPen(cg.light());
+ else
+ p->setPen(black);
+ p->drawLine(x + w - 1, y + h - 1, x + (w / 2), y);
+
+ if (down)
+ p->setPen(black);
+ else
+ p->setPen(button);
+ p->drawLine(x + (w / 2), y + 1, x + 1, y + h - 1);
+
+ if (down)
+ p->setPen(cg.dark());
+ else
+ p->setPen(cg.light());
+ p->drawLine(x + (w / 2), y, x, y + h - 1);
+ break;
+ }
+
+ case PE_ArrowDown:
+ {
+ poly.setPoint(0, x + w - 1, y);
+ poly.setPoint(1, x, y);
+ poly.setPoint(2, x + (w / 2), y + h - 1);
+ p->drawPolygon(poly);
+
+ if (down)
+ p->setPen(black);
+ else
+ p->setPen(button);
+ p->drawLine(x + w - 2, y + 1, x + 1, y + 1);
+
+ if (down)
+ p->setPen(cg.dark());
+ else
+ p->setPen(cg.light());
+ p->drawLine(x + w - 1, y, x, y);
+
+ if (down)
+ p->setPen(black);
+ else
+ p->setPen(button);
+ p->drawLine(x + 1, y, x + (w / 2), y + h - 2);
+
+ if (down)
+ p->setPen(cg.dark());
+ else
+ p->setPen(cg.light());
+ p->drawLine(x, y, x + (w / 2), y + h - 1);
+
+ if (down)
+ p->setPen(button);
+ else
+ p->setPen(cg.dark());
+ p->drawLine(x + (w / 2), y + h - 2, x + w - 2, y);
+
+ if (down)
+ p->setPen(cg.light());
+ else
+ p->setPen(black);
+ p->drawLine(x + (w / 2), y + h - 1, x + w - 1, y);
+ break;
+ }
+
+ case PE_ArrowLeft:
+ {
+ poly.setPoint(0, x, y + (h / 2));
+ poly.setPoint(1, x + w - 1, y + h - 1);
+ poly.setPoint(2, x + w - 1, y);
+ p->drawPolygon(poly);
+
+ if (down)
+ p->setPen(button);
+ else
+ p->setPen(cg.dark());
+ p->drawLine(x + 1, y + (h / 2), x + w - 1, y + h - 1);
+
+ if (down)
+ p->setPen(cg.light());
+ else
+ p->setPen(black);
+ p->drawLine(x, y + (h / 2), x + w - 1, y + h - 1);
+
+ if (down)
+ p->setPen(button);
+ else
+ p->setPen(cg.dark());
+ p->drawLine(x + w - 2, y + h - 1, x + w - 2, y + 1);
+
+ if (down)
+ p->setPen(cg.light());
+ else
+ p->setPen(black);
+ p->drawLine(x + w - 1, y + h - 1, x + w - 1, y);
+
+ if (down)
+ p->setPen(black);
+ else
+ p->setPen(button);
+ p->drawLine(x + w - 1, y + 1, x + 1, y + (h / 2));
+
+ if (down)
+ p->setPen(cg.dark());
+ else
+ p->setPen(cg.light());
+ p->drawLine(x + w - 1, y, x, y + (h / 2));
+ break;
+ }
+
+ case PE_ArrowRight:
+ {
+ poly.setPoint(0, x + w - 1, y + (h / 2));
+ poly.setPoint(1, x, y);
+ poly.setPoint(2, x, y + h - 1);
+ p->drawPolygon(poly);
+
+ if (down)
+ p->setPen(black);
+ else
+ p->setPen(button);
+ p->drawLine( x + w - 1, y + (h / 2), x + 1, y + 1);
+
+ if (down)
+ p->setPen(cg.dark());
+ else
+ p->setPen(cg.light());
+ p->drawLine(x + w - 1, y + (h / 2), x, y);
+
+ if (down)
+ p->setPen(black);
+ else
+ p->setPen(button);
+ p->drawLine(x + 1, y + 1, x + 1, y + h - 2);
+
+ if (down)
+ p->setPen(cg.dark());
+ else
+ p->setPen(cg.light());
+ p->drawLine(x, y, x, y + h - 1);
+
+ if (down)
+ p->setPen(button);
+ else
+ p->setPen(cg.dark());
+ p->drawLine(x + 1, y + h - 2, x + w - 1, y + (h / 2));
+
+ if (down)
+ p->setPen(cg.light());
+ else
+ p->setPen(black);
+ p->drawLine(x, y + h - 1, x + w - 1, y + (h / 2));
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ p->restore();
+ p->setBrush(oldbrush);
+ p->setPen(oldpen);
+ break;
+ }
+
+ default:
+ TQMotifStyle::drawPrimitive(pe, p, r, cg, flags, opt);
+ break;
+ }
+}
+
+
+/*! \reimp
+*/
+void TQMotifPlusStyle::drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ if (widget == singleton->hoverWidget)
+ flags |= Style_MouseOver;
+
+ switch (element) {
+ case CE_PushButton:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ TQRect br = r;
+ int dbi = pixelMetric(PM_ButtonDefaultIndicator, widget);
+
+ if (button->isDefault() || button->autoDefault()) {
+ if (button->isDefault())
+ drawMotifPlusShade(p, br, cg, TRUE, FALSE,
+ &cg.brush(TQColorGroup::Background));
+
+ br.setCoords(br.left() + dbi,
+ br.top() + dbi,
+ br.right() - dbi,
+ br.bottom() - dbi);
+ }
+
+ if (flags & Style_HasFocus)
+ br.addCoords(1, 1, -1, -1);
+ p->save();
+ p->setBrushOrigin( -button->backgroundOffset().x(),
+ -button->backgroundOffset().y() );
+ drawPrimitive(PE_ButtonCommand, p, br, cg, flags);
+ p->restore();
+#endif
+ break;
+ }
+
+ case CE_CheckBoxLabel:
+ {
+#ifndef QT_NO_CHECKBOX
+ const TQCheckBox *checkbox = (const TQCheckBox *) widget;
+
+ if (flags & Style_MouseOver) {
+ TQRegion r(checkbox->rect());
+ r -= visualRect(subRect(SR_CheckBoxIndicator, widget), widget);
+ p->setClipRegion(r);
+ p->fillRect(checkbox->rect(), cg.brush(TQColorGroup::Midlight));
+ p->setClipping(FALSE);
+ }
+
+ int alignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft;
+ drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
+ flags & Style_Enabled, checkbox->pixmap(), checkbox->text());
+
+ if (checkbox->hasFocus()) {
+ TQRect fr = visualRect(subRect(SR_CheckBoxFocusRect, widget), widget);
+ drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CE_RadioButtonLabel:
+ {
+#ifndef QT_NO_RADIOBUTTON
+ const TQRadioButton *radiobutton = (const TQRadioButton *) widget;
+
+ if (flags & Style_MouseOver) {
+ TQRegion r(radiobutton->rect());
+ r -= visualRect(subRect(SR_RadioButtonIndicator, widget), widget);
+ p->setClipRegion(r);
+ p->fillRect(radiobutton->rect(), cg.brush(TQColorGroup::Midlight));
+ p->setClipping(FALSE);
+ }
+
+ int alignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft;
+ drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
+ flags & Style_Enabled, radiobutton->pixmap(), radiobutton->text());
+
+ if (radiobutton->hasFocus()) {
+ TQRect fr = visualRect(subRect(SR_RadioButtonFocusRect, widget), widget);
+ drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CE_MenuBarItem:
+ {
+#ifndef QT_NO_MENUDATA
+ if (opt.isDefault())
+ break;
+
+ TQMenuItem *mi = opt.menuItem();
+ if ((flags & Style_Enabled) && (flags & Style_Active))
+ drawMotifPlusShade(p, r, cg, FALSE, TRUE);
+ else
+ p->fillRect(r, cg.button());
+
+ drawItem(p, r, AlignCenter | ShowPrefix | DontClip | SingleLine,
+ cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1,
+ &cg.buttonText());
+#endif
+ break;
+ }
+
+
+#ifndef QT_NO_POPUPMENU
+ case CE_PopupMenuItem:
+ {
+ if (! widget || opt.isDefault())
+ break;
+
+ TQPopupMenu *popupmenu = (TQPopupMenu *) widget;
+ TQMenuItem *mi = opt.menuItem();
+ if ( !mi )
+ break;
+
+ int tab = opt.tabWidth();
+ int maxpmw = opt.maxIconWidth();
+ bool dis = ! (flags & Style_Enabled);
+ bool checkable = popupmenu->isCheckable();
+ bool act = flags & Style_Active;
+ int x, y, w, h;
+
+ r.rect(&x, &y, &w, &h);
+
+ if (checkable)
+ maxpmw = TQMAX(maxpmw, 15);
+
+ int checkcol = maxpmw;
+
+ if (mi && mi->isSeparator()) {
+ p->setPen( cg.dark() );
+ p->drawLine( x, y, x+w, y );
+ p->setPen( cg.light() );
+ p->drawLine( x, y+1, x+w, y+1 );
+ return;
+ }
+
+ if ( act && !dis )
+ drawMotifPlusShade(p, TQRect(x, y, w, h), cg, FALSE, TRUE);
+ else
+ p->fillRect(x, y, w, h, cg.brush( TQColorGroup::Button ));
+
+ if ( !mi )
+ return;
+
+ TQRect vrect = visualRect( TQRect( x+2, y+2, checkcol, h-2 ), r );
+ if ( mi->isChecked() ) {
+ if ( mi->iconSet() ) {
+ qDrawShadePanel( p, vrect.x(), y+2, checkcol, h-2*2,
+ cg, TRUE, 1, &cg.brush( TQColorGroup::Midlight ) );
+ }
+ } else if ( !act ) {
+ p->fillRect(vrect,
+ cg.brush( TQColorGroup::Button ));
+ }
+
+ if ( mi->iconSet() ) { // draw iconset
+ TQIconSet::Mode mode = (!dis) ? TQIconSet::Normal : TQIconSet::Disabled;
+
+ if (act && !dis)
+ mode = TQIconSet::Active;
+
+ TQPixmap pixmap;
+ if ( checkable && mi->isChecked() )
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode,
+ TQIconSet::On );
+ else
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode );
+
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+
+ TQRect pmr( 0, 0, pixw, pixh );
+
+ pmr.moveCenter(vrect.center());
+
+ p->setPen( cg.text() );
+ p->drawPixmap( pmr.topLeft(), pixmap );
+
+ } else if (checkable) {
+ if (mi->isChecked()) {
+ SFlags cflags = Style_Default;
+ if (! dis)
+ cflags |= Style_Enabled;
+ if (act)
+ cflags |= Style_On;
+
+ drawPrimitive(PE_CheckMark, p, vrect, cg, cflags);
+ }
+ }
+
+ p->setPen( cg.buttonText() );
+
+ TQColor discol;
+ if (dis) {
+ discol = cg.text();
+ p->setPen( discol );
+ }
+
+ vrect = visualRect( TQRect(x + checkcol + 4, y + 2,
+ w - checkcol - tab - 3, h - 4), r );
+ if (mi->custom()) {
+ p->save();
+ mi->custom()->paint(p, cg, act, !dis, vrect.x(), y + 2,
+ w - checkcol - tab - 3, h - 4);
+ p->restore();
+ }
+
+ TQString s = mi->text();
+ if ( !s.isNull() ) { // draw text
+ int t = s.find( '\t' );
+ int m = 2;
+ int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
+ text_flags |= (TQApplication::reverseLayout() ? AlignRight : AlignLeft );
+ if ( t >= 0 ) { // draw tab text
+ TQRect vr = visualRect( TQRect(x+w-tab-2-2,
+ y+m, tab, h-2*m), r );
+ p->drawText( vr.x(),
+ y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
+ }
+ p->drawText(vrect.x(), y + 2, w - checkcol -tab - 3, h - 4,
+ text_flags, s, t);
+ } else if (mi->pixmap()) {
+ TQPixmap *pixmap = mi->pixmap();
+
+ if (pixmap->depth() == 1) p->setBackgroundMode(OpaqueMode);
+ TQRect vr = visualRect( TQRect( x + checkcol + 2, y + 2, w - checkcol - 1, h - 4 ), r );
+ p->drawPixmap(vr.x(), y + 2, *pixmap);
+ if (pixmap->depth() == 1) p->setBackgroundMode(TransparentMode);
+ }
+
+ if (mi->popup()) {
+ int hh = h / 2;
+ TQStyle::PrimitiveElement arrow = (TQApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight);
+ vrect = visualRect( TQRect(x + w - hh - 6, y + (hh / 2), hh, hh), r );
+ drawPrimitive(arrow, p,
+ vrect, cg,
+ ((act && !dis) ?
+ Style_Down : Style_Default) |
+ ((!dis) ? Style_Enabled : Style_Default));
+ }
+ break;
+ }
+#endif // QT_NO_POPUPMENU
+
+ case CE_TabBarTab:
+ {
+#ifndef QT_NO_TABBAR
+ const TQTabBar *tabbar = (const TQTabBar *) widget;
+ bool selected = flags & Style_Selected;
+
+ TQColorGroup g = tabbar->colorGroup();
+ TQPen oldpen = p->pen();
+ TQRect fr(r);
+
+ if (! selected) {
+ if (tabbar->shape() == TQTabBar::RoundedAbove ||
+ tabbar->shape() == TQTabBar::TriangularAbove) {
+ fr.setTop(fr.top() + 2);
+ } else {
+ fr.setBottom(fr.bottom() - 2);
+ }
+ }
+
+ fr.setWidth(fr.width() - 3);
+
+ p->fillRect(fr.left() + 1, fr.top() + 1, fr.width() - 2, fr.height() - 2,
+ (selected) ? cg.brush(TQColorGroup::Button)
+ : cg.brush(TQColorGroup::Mid));
+
+ if (tabbar->shape() == TQTabBar::RoundedAbove) {
+ // "rounded" tabs on top
+ fr.setBottom(fr.bottom() - 1);
+
+ p->setPen(g.light());
+ p->drawLine(fr.left(), fr.top() + 1,
+ fr.left(), fr.bottom() - 1);
+ p->drawLine(fr.left() + 1, fr.top(),
+ fr.right() - 1, fr.top());
+ if (! selected)
+ p->drawLine(fr.left(), fr.bottom(),
+ fr.right() + 3, fr.bottom());
+
+ if (fr.left() == 0)
+ p->drawLine(fr.left(), fr.bottom(),
+ fr.left(), fr.bottom() + 1);
+
+ p->setPen(g.dark());
+ p->drawLine(fr.right() - 1, fr.top() + 2,
+ fr.right() - 1, fr.bottom() - 1);
+
+ p->setPen(black);
+ p->drawLine(fr.right(), fr.top() + 1,
+ fr.right(), fr.bottom() - 1);
+ } else if (tabbar->shape() == TQTabBar::RoundedBelow) {
+ // "rounded" tabs on bottom
+ fr.setTop(fr.top() + 1);
+
+ p->setPen(g.dark());
+ p->drawLine(fr.right() + 3, fr.top() - 1,
+ fr.right() - 1, fr.top() - 1);
+ p->drawLine(fr.right() - 1, fr.top(),
+ fr.right() - 1, fr.bottom() - 2);
+ p->drawLine(fr.right() - 1, fr.bottom() - 2,
+ fr.left() + 2, fr.bottom() - 2);
+ if (! selected) {
+ p->drawLine(fr.right(), fr.top() - 1,
+ fr.left() + 1, fr.top() - 1);
+
+ if (fr.left() != 0)
+ p->drawPoint(fr.left(), fr.top() - 1);
+ }
+
+ p->setPen(black);
+ p->drawLine(fr.right(), fr.top(),
+ fr.right(), fr.bottom() - 2);
+ p->drawLine(fr.right() - 1, fr.bottom() - 1,
+ fr.left(), fr.bottom() - 1);
+ if (! selected)
+ p->drawLine(fr.right() + 3, fr.top(),
+ fr.left(), fr.top());
+ else
+ p->drawLine(fr.right() + 3, fr.top(),
+ fr.right(), fr.top());
+
+ p->setPen(g.light());
+ p->drawLine(fr.left(), fr.top() + 1,
+ fr.left(), fr.bottom() - 2);
+
+ if (selected) {
+ p->drawPoint(fr.left(), fr.top());
+ if (fr.left() == 0)
+ p->drawPoint(fr.left(), fr.top() - 1);
+
+ p->setPen(g.button());
+ p->drawLine(fr.left() + 2, fr.top() - 1,
+ fr.left() + 1, fr.top() - 1);
+ }
+ } else
+ // triangular drawing code
+ TQMotifStyle::drawControl(element, p, widget, r, cg, flags, opt);
+
+ p->setPen(oldpen);
+#endif
+ break;
+ }
+
+ default:
+ TQMotifStyle::drawControl(element, p, widget, r, cg, flags, opt);
+ break;
+ }
+}
+
+
+/*! \reimp
+*/
+TQRect TQMotifPlusStyle::subRect(SubRect r, const TQWidget *widget) const
+{
+ TQRect rect;
+
+ switch (r) {
+ case SR_PushButtonFocusRect:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ int dfi = pixelMetric(PM_ButtonDefaultIndicator, widget);
+
+ rect = button->rect();
+ if (button->isDefault() || button->autoDefault())
+ rect.addCoords(dfi, dfi, -dfi, -dfi);
+#endif
+ break;
+ }
+
+ case SR_CheckBoxIndicator:
+ {
+ int h = pixelMetric( PM_IndicatorHeight );
+ rect.setRect(( widget->rect().height() - h ) / 2,
+ ( widget->rect().height() - h ) / 2,
+ pixelMetric( PM_IndicatorWidth ), h );
+ break;
+ }
+
+ case SR_RadioButtonIndicator:
+ {
+ int h = pixelMetric( PM_ExclusiveIndicatorHeight );
+ rect.setRect( ( widget->rect().height() - h ) / 2,
+ ( widget->rect().height() - h ) / 2,
+ pixelMetric( PM_ExclusiveIndicatorWidth ), h );
+ break;
+ }
+
+ case SR_CheckBoxFocusRect:
+ case SR_RadioButtonFocusRect:
+ rect = widget->rect();
+ break;
+
+ case SR_ComboBoxFocusRect:
+ {
+#ifndef QT_NO_COMBOBOX
+ const TQComboBox *combobox = (const TQComboBox *) widget;
+
+ if (combobox->editable()) {
+ rect = querySubControlMetrics(CC_ComboBox, widget,
+ SC_ComboBoxEditField);
+ rect.addCoords(-3, -3, 3, 3);
+ } else
+ rect = combobox->rect();
+#endif
+ break;
+ }
+
+ case SR_SliderFocusRect:
+ {
+#ifndef QT_NO_SLIDER
+ const TQSlider *slider = (const TQSlider *) widget;
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, widget );
+ int thickness = pixelMetric( PM_SliderControlThickness, widget );
+ int x, y, wi, he;
+
+ if ( slider->orientation() == Horizontal ) {
+ x = 0;
+ y = tickOffset;
+ wi = slider->width();
+ he = thickness;
+ } else {
+ x = tickOffset;
+ y = 0;
+ wi = thickness;
+ he = slider->height();
+ }
+
+ rect.setRect(x, y, wi, he);
+#endif
+ break;
+ }
+
+ default:
+ rect = TQMotifStyle::subRect(r, widget);
+ break;
+ }
+
+ return rect;
+}
+
+
+/*! \reimp */
+void TQMotifPlusStyle::drawComplexControl(ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ SCFlags controls,
+ SCFlags active,
+ const TQStyleOption& opt ) const
+{
+ if (widget == singleton->hoverWidget)
+ flags |= Style_MouseOver;
+
+ switch (control) {
+ case CC_ScrollBar:
+ {
+#ifndef QT_NO_SCROLLBAR
+ const TQScrollBar *scrollbar = (const TQScrollBar *) widget;
+ TQRect addline, subline, addpage, subpage, slider, first, last;
+ bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue());
+
+ subline = querySubControlMetrics(control, widget, SC_ScrollBarSubLine, opt);
+ addline = querySubControlMetrics(control, widget, SC_ScrollBarAddLine, opt);
+ subpage = querySubControlMetrics(control, widget, SC_ScrollBarSubPage, opt);
+ addpage = querySubControlMetrics(control, widget, SC_ScrollBarAddPage, opt);
+ slider = querySubControlMetrics(control, widget, SC_ScrollBarSlider, opt);
+ first = querySubControlMetrics(control, widget, SC_ScrollBarFirst, opt);
+ last = querySubControlMetrics(control, widget, SC_ScrollBarLast, opt);
+
+ bool skipUpdate = FALSE;
+ if (singleton->hovering) {
+ if (addline.contains(singleton->mousePos)) {
+ skipUpdate =
+ (singleton->scrollbarElement == SC_ScrollBarAddLine);
+ singleton->scrollbarElement = SC_ScrollBarAddLine;
+ } else if (subline.contains(singleton->mousePos)) {
+ skipUpdate =
+ (singleton->scrollbarElement == SC_ScrollBarSubLine);
+ singleton->scrollbarElement = SC_ScrollBarSubLine;
+ } else if (slider.contains(singleton->mousePos)) {
+ skipUpdate =
+ (singleton->scrollbarElement == SC_ScrollBarSlider);
+ singleton->scrollbarElement = SC_ScrollBarSlider;
+ } else {
+ skipUpdate =
+ (singleton->scrollbarElement == 0);
+ singleton->scrollbarElement = 0;
+ }
+ } else
+ singleton->scrollbarElement = 0;
+
+ if (skipUpdate && singleton->scrollbarElement == singleton->lastElement)
+ break;
+
+ singleton->lastElement = singleton->scrollbarElement;
+
+ if (controls == (SC_ScrollBarAddLine | SC_ScrollBarSubLine |
+ SC_ScrollBarAddPage | SC_ScrollBarSubPage |
+ SC_ScrollBarFirst | SC_ScrollBarLast | SC_ScrollBarSlider))
+ drawMotifPlusShade(p, widget->rect(), cg, TRUE, FALSE,
+ &cg.brush(TQColorGroup::Mid));
+
+ if ((controls & SC_ScrollBarSubLine) && subline.isValid())
+ drawPrimitive(PE_ScrollBarSubLine, p, subline, cg,
+ ((active == SC_ScrollBarSubLine ||
+ singleton->scrollbarElement == SC_ScrollBarSubLine) ?
+ Style_MouseOver: Style_Default) |
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarSubLine) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarAddLine) && addline.isValid())
+ drawPrimitive(PE_ScrollBarAddLine, p, addline, cg,
+ ((active == SC_ScrollBarAddLine ||
+ singleton->scrollbarElement == SC_ScrollBarAddLine) ?
+ Style_MouseOver: Style_Default) |
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarAddLine) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
+ drawPrimitive(PE_ScrollBarSubPage, p, subpage, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarSubPage) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
+ drawPrimitive(PE_ScrollBarAddPage, p, addpage, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarAddPage) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarFirst) && first.isValid())
+ drawPrimitive(PE_ScrollBarFirst, p, first, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarFirst) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarLast) && last.isValid())
+ drawPrimitive(PE_ScrollBarLast, p, last, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarLast) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
+ drawPrimitive(PE_ScrollBarSlider, p, slider, cg,
+ ((active == SC_ScrollBarSlider ||
+ singleton->scrollbarElement == SC_ScrollBarSlider) ?
+ Style_MouseOver: Style_Default) |
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((scrollbar->orientation() == TQt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+
+ // ### perhaps this should not be able to accept focus if maxedOut?
+ if (scrollbar->hasFocus()) {
+ TQRect fr(slider.x() + 2, slider.y() + 2,
+ slider.width() - 5, slider.height() - 5);
+ drawPrimitive(PE_FocusRect, p, fr, cg, Style_Default);
+ }
+ }
+#endif
+ break;
+ }
+
+ case CC_ComboBox:
+ {
+#ifndef QT_NO_COMBOBOX
+ const TQComboBox *combobox = (const TQComboBox *) widget;
+
+ TQRect editfield, arrow;
+ editfield =
+ visualRect(querySubControlMetrics(CC_ComboBox,
+ combobox,
+ SC_ComboBoxEditField,
+ opt), widget);
+ arrow =
+ visualRect(querySubControlMetrics(CC_ComboBox,
+ combobox,
+ SC_ComboBoxArrow,
+ opt), widget);
+
+ if (combobox->editable()) {
+ if (controls & SC_ComboBoxEditField && editfield.isValid()) {
+ editfield.addCoords(-3, -3, 3, 3);
+ if (combobox->hasFocus())
+ editfield.addCoords(1, 1, -1, -1);
+ drawMotifPlusShade(p, editfield, cg, TRUE, FALSE,
+ (widget->isEnabled() ?
+ &cg.brush(TQColorGroup::Base) :
+ &cg.brush(TQColorGroup::Background)));
+ }
+
+ if (controls & SC_ComboBoxArrow && arrow.isValid()) {
+ drawMotifPlusShade(p, arrow, cg, (active == SC_ComboBoxArrow),
+ (flags & Style_MouseOver));
+
+ int space = (r.height() - 13) / 2;
+ arrow.addCoords(space, space, -space, -space);
+
+ if (active == SC_ComboBoxArrow)
+ flags |= Style_Sunken;
+ drawPrimitive(PE_ArrowDown, p, arrow, cg, flags);
+ }
+ } else {
+ if (controls & SC_ComboBoxEditField && editfield.isValid()) {
+ editfield.addCoords(-3, -3, 3, 3);
+ if (combobox->hasFocus())
+ editfield.addCoords(1, 1, -1, -1);
+ drawMotifPlusShade(p, editfield, cg, FALSE,
+ (flags & Style_MouseOver));
+ }
+
+ if (controls & SC_ComboBoxArrow && arrow.isValid())
+ drawMotifPlusShade(p, arrow, cg, FALSE, (flags & Style_MouseOver));
+ }
+
+ if (combobox->hasFocus() ||
+ (combobox->editable() && combobox->lineEdit()->hasFocus())) {
+ TQRect fr = visualRect(subRect(SR_ComboBoxFocusRect, widget), widget);
+ drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CC_SpinWidget:
+ {
+#ifndef QT_NO_SPINWIDGET
+ const TQSpinWidget * sw = (const TQSpinWidget *) widget;
+ SFlags flags = Style_Default;
+
+ if (controls & SC_SpinWidgetFrame)
+ drawMotifPlusShade(p, r, cg, TRUE, FALSE, &cg.brush(TQColorGroup::Base));
+
+ if (controls & SC_SpinWidgetUp) {
+ flags = Style_Enabled;
+ if (active == SC_SpinWidgetUp )
+ flags |= Style_Down;
+
+ PrimitiveElement pe;
+ if ( sw->buttonSymbols() == TQSpinWidget::PlusMinus )
+ pe = PE_SpinWidgetPlus;
+ else
+ pe = PE_SpinWidgetUp;
+
+ TQRect re = sw->upRect();
+ TQColorGroup ucg = sw->isUpEnabled() ? cg : sw->palette().disabled();
+ drawPrimitive(pe, p, re, ucg, flags);
+ }
+
+ if (controls & SC_SpinWidgetDown) {
+ flags = Style_Enabled;
+ if (active == SC_SpinWidgetDown )
+ flags |= Style_Down;
+
+ PrimitiveElement pe;
+ if ( sw->buttonSymbols() == TQSpinWidget::PlusMinus )
+ pe = PE_SpinWidgetMinus;
+ else
+ pe = PE_SpinWidgetDown;
+
+ TQRect re = sw->downRect();
+ TQColorGroup dcg = sw->isDownEnabled() ? cg : sw->palette().disabled();
+ drawPrimitive(pe, p, re, dcg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CC_Slider:
+ {
+#ifndef QT_NO_SLIDER
+ const TQSlider *slider = (const TQSlider *) widget;
+ bool mouseover = (flags & Style_MouseOver);
+
+ TQRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
+ opt),
+ handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
+ opt);
+
+ if ((controls & SC_SliderGroove) && groove.isValid()) {
+ drawMotifPlusShade(p, groove, cg, TRUE, FALSE,
+ &cg.brush(TQColorGroup::Mid));
+
+ if ( flags & Style_HasFocus ) {
+ TQRect fr = subRect( SR_SliderFocusRect, widget );
+ drawPrimitive( PE_FocusRect, p, fr, cg, flags );
+ }
+ }
+
+ if ((controls & SC_SliderHandle) && handle.isValid()) {
+ if ((mouseover && handle.contains(singleton->mousePos)) ||
+ singleton->sliderActive)
+ flags |= Style_MouseOver;
+ else
+ flags &= ~Style_MouseOver;
+ drawPrimitive(PE_ButtonBevel, p, handle, cg, flags | Style_Raised);
+
+ if ( slider->orientation() == Horizontal ) {
+ TQCOORD mid = handle.x() + handle.width() / 2;
+ qDrawShadeLine( p, mid, handle.y() + 1, mid ,
+ handle.y() + handle.height() - 3,
+ cg, TRUE, 1);
+ } else {
+ TQCOORD mid = handle.y() + handle.height() / 2;
+ qDrawShadeLine( p, handle.x() + 1, mid,
+ handle.x() + handle.width() - 3, mid,
+ cg, TRUE, 1);
+ }
+ }
+
+ if (controls & SC_SliderTickmarks)
+ TQMotifStyle::drawComplexControl(control, p, widget, r, cg, flags,
+ SC_SliderTickmarks, active, opt);
+#endif
+ break;
+ }
+
+ default:
+ TQMotifStyle::drawComplexControl(control, p, widget, r, cg, flags,
+ controls, active, opt);
+ }
+}
+
+
+/*! \reimp
+*/
+TQRect TQMotifPlusStyle::querySubControlMetrics(ComplexControl control,
+ const TQWidget *widget,
+ SubControl subcontrol,
+ const TQStyleOption& opt) const
+{
+ switch (control) {
+ case CC_SpinWidget: {
+ int fw = pixelMetric( PM_SpinBoxFrameWidth, 0 );
+ TQSize bs;
+ bs.setHeight( (widget->height() + 1)/2 );
+ if ( bs.height() < 10 )
+ bs.setHeight( 10 );
+ bs.setWidth( bs.height() ); // 1.6 -approximate golden mean
+ bs = bs.expandedTo( TQApplication::globalStrut() );
+ int y = 0;
+ int x, lx, rx, h;
+ x = widget->width() - y - bs.width();
+ lx = fw;
+ rx = x - fw * 2;
+ h = bs.height() * 2;
+
+ switch ( subcontrol ) {
+ case SC_SpinWidgetUp:
+ return TQRect(x + 1, y, bs.width(), bs.height() - 1);
+ case SC_SpinWidgetDown:
+ return TQRect(x + 1, y + bs.height() + 1, bs.width(), bs.height());
+ case SC_SpinWidgetButtonField:
+ return TQRect(x, y, bs.width(), h - 2*fw);
+ case SC_SpinWidgetEditField:
+ return TQRect(lx, fw, rx, h - 2*fw);
+ case SC_SpinWidgetFrame:
+ return TQRect( 0, 0, widget->width() - bs.width(), h);
+ default:
+ break;
+ }
+ break; }
+
+#ifndef QT_NO_COMBOBOX
+ case CC_ComboBox: {
+ const TQComboBox *combobox = (const TQComboBox *) widget;
+ if (combobox->editable()) {
+ int space = (combobox->height() - 13) / 2;
+ switch (subcontrol) {
+ case SC_ComboBoxFrame:
+ return TQRect();
+ case SC_ComboBoxEditField: {
+ TQRect rect = widget->rect();
+ rect.setWidth(rect.width() - 13 - space * 2);
+ rect.addCoords(3, 3, -3, -3);
+ return rect; }
+ case SC_ComboBoxArrow:
+ return TQRect(combobox->width() - 13 - space * 2, 0,
+ 13 + space * 2, combobox->height());
+ default: break; // shouldn't get here
+ }
+
+ } else {
+ int space = (combobox->height() - 7) / 2;
+ switch (subcontrol) {
+ case SC_ComboBoxFrame:
+ return TQRect();
+ case SC_ComboBoxEditField: {
+ TQRect rect = widget->rect();
+ rect.addCoords(3, 3, -3, -3);
+ return rect; }
+ case SC_ComboBoxArrow: // 12 wide, 7 tall
+ return TQRect(combobox->width() - 12 - space, space, 12, 7);
+ default: break; // shouldn't get here
+ }
+ }
+ break; }
+#endif
+
+#ifndef QT_NO_SLIDER
+ case CC_Slider: {
+
+ if (subcontrol == SC_SliderHandle) {
+ const TQSlider *slider = (const TQSlider *) widget;
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, widget );
+ int thickness = pixelMetric( PM_SliderControlThickness, widget );
+ int len = pixelMetric( PM_SliderLength, widget ) + 2;
+ int sliderPos = slider->sliderStart();
+ int motifBorder = 2;
+
+ if ( slider->orientation() == Horizontal )
+ return TQRect( sliderPos + motifBorder, tickOffset + motifBorder, len,
+ thickness - 2*motifBorder );
+ return TQRect( tickOffset + motifBorder, sliderPos + motifBorder,
+ thickness - 2*motifBorder, len);
+ }
+ break; }
+#endif
+ default: break;
+ }
+ return TQMotifStyle::querySubControlMetrics(control, widget, subcontrol, opt);
+}
+
+
+/*! \reimp */
+bool TQMotifPlusStyle::eventFilter(TQObject *object, TQEvent *event)
+{
+ switch(event->type()) {
+ case TQEvent::MouseButtonPress:
+ {
+ singleton->mousePressed = TRUE;
+
+ if (!::qt_cast<TQSlider*>(object))
+ break;
+
+ singleton->sliderActive = TRUE;
+ break;
+ }
+
+ case TQEvent::MouseButtonRelease:
+ {
+ singleton->mousePressed = FALSE;
+
+ if (!::qt_cast<TQSlider*>(object))
+ break;
+
+ singleton->sliderActive = FALSE;
+ ((TQWidget *) object)->repaint(FALSE);
+ break;
+ }
+
+ case TQEvent::Enter:
+ {
+ if (! object->isWidgetType())
+ break;
+
+ singleton->hoverWidget = (TQWidget *) object;
+ if (! singleton->hoverWidget->isEnabled()) {
+ singleton->hoverWidget = 0;
+ break;
+ }
+ singleton->hoverWidget->repaint(FALSE);
+ break;
+ }
+
+ case TQEvent::Leave:
+ {
+ if (object != singleton->hoverWidget)
+ break;
+ TQWidget *w = singleton->hoverWidget;
+ singleton->hoverWidget = 0;
+ w->repaint(FALSE);
+ break;
+ }
+
+ case TQEvent::MouseMove:
+ {
+ if (! object->isWidgetType() || object != singleton->hoverWidget)
+ break;
+
+ if (!::qt_cast<TQScrollBar*>(object) && ! ::qt_cast<TQSlider*>(object))
+ break;
+
+ singleton->mousePos = ((TQMouseEvent *) event)->pos();
+ if (! singleton->mousePressed) {
+ singleton->hovering = TRUE;
+ singleton->hoverWidget->repaint(FALSE);
+ singleton->hovering = FALSE;
+ }
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return TQMotifStyle::eventFilter(object, event);
+}
+
+
+/*! \reimp */
+int TQMotifPlusStyle::styleHint(StyleHint hint,
+ const TQWidget *widget,
+ const TQStyleOption &opt,
+ TQStyleHintReturn *returnData) const
+{
+ int ret;
+ switch (hint) {
+ case SH_PopupMenu_MouseTracking:
+ ret = 1;
+ break;
+ default:
+ ret = TQMotifStyle::styleHint(hint, widget, opt, returnData);
+ break;
+ }
+ return ret;
+}
+
+
+#endif // QT_NO_STYLE_MOTIFPLUS
diff --git a/src/styles/qmotifplusstyle.h b/src/styles/qmotifplusstyle.h
new file mode 100644
index 000000000..2448c67db
--- /dev/null
+++ b/src/styles/qmotifplusstyle.h
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Definition of TQMotifPlusStyle class
+**
+** Created : 000727
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQMOTIFPLUSSTYLE_H
+#define TQMOTIFPLUSSTYLE_H
+
+
+#ifndef QT_H
+#include "qmotifstyle.h"
+#endif // QT_H
+
+#if !defined(QT_NO_STYLE_MOTIFPLUS) || defined(QT_PLUGIN)
+
+#if defined(QT_PLUGIN)
+#define Q_EXPORT_STYLE_MOTIFPLUS
+#else
+#define Q_EXPORT_STYLE_MOTIFPLUS Q_EXPORT
+#endif
+
+class Q_EXPORT_STYLE_MOTIFPLUS TQMotifPlusStyle : public TQMotifStyle
+{
+ Q_OBJECT
+
+public:
+ TQMotifPlusStyle(bool hoveringHighlight = TRUE);
+ virtual ~TQMotifPlusStyle();
+
+ void polish(TQPalette &pal);
+ void polish(TQWidget *widget);
+ void unPolish(TQWidget*widget);
+
+ void polish(TQApplication *app);
+ void unPolish(TQApplication *app);
+
+ void drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect subRect(SubRect r, const TQWidget *widget) const;
+
+ void drawComplexControl(ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+#ifdef Q_QDOC
+ SCFlags controls = SC_All,
+#else
+ SCFlags controls = (uint)SC_All,
+#endif
+ SCFlags active = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect querySubControlMetrics(ComplexControl control,
+ const TQWidget *widget,
+ SubControl subcontrol,
+ const TQStyleOption& = TQStyleOption::Default) const;
+
+ int pixelMetric(PixelMetric metric, const TQWidget *widget = 0) const;
+
+ int styleHint(StyleHint sh, const TQWidget *, const TQStyleOption & = TQStyleOption::Default,
+ TQStyleHintReturn* = 0) const;
+
+protected:
+ bool eventFilter(TQObject *, TQEvent *);
+
+
+private:
+ bool useHoveringHighlight;
+};
+
+
+#endif // QT_NO_STYLE_MOTIFPLUS
+
+#endif // TQMOTIFPLUSSTYLE_H
diff --git a/src/styles/qmotifstyle.cpp b/src/styles/qmotifstyle.cpp
new file mode 100644
index 000000000..19673e1f6
--- /dev/null
+++ b/src/styles/qmotifstyle.cpp
@@ -0,0 +1,2359 @@
+/****************************************************************************
+**
+** Implementation of Motif-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qmotifstyle.h"
+
+#if !defined(QT_NO_STYLE_MOTIF) || defined(QT_PLUGIN)
+
+#include "qpopupmenu.h"
+#include "qapplication.h"
+#include "qpainter.h"
+#include "qdrawutil.h"
+#include "qpixmap.h"
+#include "qpalette.h"
+#include "qwidget.h"
+#include "qpushbutton.h"
+#include "qscrollbar.h"
+#include "qtabbar.h"
+#include "qtabwidget.h"
+#include "qlistview.h"
+#include "qsplitter.h"
+#include "qslider.h"
+#include "qcombobox.h"
+#include "qdockwindow.h"
+#include "qdockarea.h"
+#include "qprogressbar.h"
+#include "qimage.h"
+#include <limits.h>
+
+
+
+// old constants that might still be useful...
+static const int motifItemFrame = 2; // menu item frame width
+static const int motifSepHeight = 2; // separator item height
+static const int motifItemHMargin = 3; // menu item hor text margin
+static const int motifItemVMargin = 2; // menu item ver text margin
+static const int motifArrowHMargin = 6; // arrow horizontal margin
+static const int motifTabSpacing = 12; // space between text and tab
+static const int motifCheckMarkHMargin = 2; // horiz. margins of check mark
+static const int motifCheckMarkSpace = 12;
+
+
+/*!
+ \class TQMotifStyle qmotifstyle.h
+ \brief The TQMotifStyle class provides Motif look and feel.
+
+ \ingroup appearance
+
+ This class implements the Motif look and feel. It closely
+ resembles the original Motif look as defined by the Open Group,
+ but with some minor improvements. The Motif style is TQt's default
+ GUI style on UNIX platforms.
+*/
+
+/*!
+ Constructs a TQMotifStyle.
+
+ If \a useHighlightCols is FALSE (the default), the style will
+ polish the application's color palette to emulate the Motif way of
+ highlighting, which is a simple inversion between the base and the
+ text color.
+*/
+TQMotifStyle::TQMotifStyle( bool useHighlightCols ) : TQCommonStyle()
+{
+ highlightCols = useHighlightCols;
+}
+
+/*!\reimp
+*/
+TQMotifStyle::~TQMotifStyle()
+{
+}
+
+/*!
+ If \a arg is FALSE, the style will polish the application's color
+ palette to emulate the Motif way of highlighting, which is a
+ simple inversion between the base and the text color.
+
+ The effect will show up the next time an application palette is
+ set via TQApplication::setPalette(). The current color palette of
+ the application remains unchanged.
+
+ \sa TQStyle::polish()
+*/
+void TQMotifStyle::setUseHighlightColors( bool arg )
+{
+ highlightCols = arg;
+}
+
+/*!
+ Returns TRUE if the style treats the highlight colors of the
+ palette in a Motif-like manner, which is a simple inversion
+ between the base and the text color; otherwise returns FALSE. The
+ default is FALSE.
+*/
+bool TQMotifStyle::useHighlightColors() const
+{
+ return highlightCols;
+}
+
+/*! \reimp */
+
+void TQMotifStyle::polish( TQPalette& pal )
+{
+ if ( pal.active().light() == pal.active().base() ) {
+ TQColor nlight = pal.active().light().dark(108 );
+ pal.setColor( TQPalette::Active, TQColorGroup::Light, nlight ) ;
+ pal.setColor( TQPalette::Disabled, TQColorGroup::Light, nlight ) ;
+ pal.setColor( TQPalette::Inactive, TQColorGroup::Light, nlight ) ;
+ }
+
+ if ( highlightCols )
+ return;
+
+ // force the ugly motif way of highlighting *sigh*
+ TQColorGroup disabled = pal.disabled();
+ TQColorGroup active = pal.active();
+
+ pal.setColor( TQPalette::Active, TQColorGroup::Highlight,
+ active.text() );
+ pal.setColor( TQPalette::Active, TQColorGroup::HighlightedText,
+ active.base());
+ pal.setColor( TQPalette::Disabled, TQColorGroup::Highlight,
+ disabled.text() );
+ pal.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText,
+ disabled.base() );
+ pal.setColor( TQPalette::Inactive, TQColorGroup::Highlight,
+ active.text() );
+ pal.setColor( TQPalette::Inactive, TQColorGroup::HighlightedText,
+ active.base() );
+}
+
+/*!
+ \reimp
+ \internal
+ Keep TQStyle::polish() visible.
+*/
+void TQMotifStyle::polish( TQWidget* w )
+{
+ TQStyle::polish(w);
+}
+
+/*!
+ \reimp
+ \internal
+ Keep TQStyle::polish() visible.
+*/
+void TQMotifStyle::polish( TQApplication* a )
+{
+ TQStyle::polish(a);
+}
+
+static void rot(TQPointArray& a, int n)
+{
+ TQPointArray r(a.size());
+ for (int i = 0; i < (int)a.size(); i++) {
+ switch (n) {
+ case 1: r.setPoint(i,-a[i].y(),a[i].x()); break;
+ case 2: r.setPoint(i,-a[i].x(),-a[i].y()); break;
+ case 3: r.setPoint(i,a[i].y(),-a[i].x()); break;
+ }
+ }
+ a = r;
+}
+
+
+/*!\reimp
+*/
+void TQMotifStyle::drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch( pe ) {
+#ifndef QT_NO_LISTVIEW
+ case PE_CheckListExclusiveIndicator: {
+ TQCheckListItem *item = opt.checkListItem();
+ TQListView *lv = item->listView();
+ if(!item)
+ return;
+
+ if ( item->isEnabled() )
+ p->setPen( TQPen( cg.text() ) );
+ else
+ p->setPen( TQPen( lv->palette().color( TQPalette::Disabled, TQColorGroup::Text ) ) );
+ TQPointArray a;
+
+ int cx = r.width()/2 - 1;
+ int cy = r.height()/2;
+ int e = r.width()/2 - 1;
+ for ( int i = 0; i < 3; i++ ) { //penWidth 2 doesn't tquite work
+ a.setPoints( 4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e );
+ p->drawPolygon( a );
+ e--;
+ }
+ if ( item->isOn() ) {
+ if ( item->isEnabled() )
+ p->setPen( TQPen( cg.text()) );
+ else
+ p->setPen( TQPen( item->listView()->palette().color( TQPalette::Disabled,
+ TQColorGroup::Text ) ) );
+ TQBrush saveBrush = p->brush();
+ p->setBrush( cg.text() );
+ e = e - 2;
+ a.setPoints( 4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e );
+ p->drawPolygon( a );
+ p->setBrush( saveBrush );
+ }
+ break; }
+#endif
+ case PE_ButtonCommand:
+ case PE_ButtonBevel:
+ case PE_ButtonTool:
+ case PE_HeaderSection:
+ qDrawShadePanel( p, r, cg, bool(flags & (Style_Down | Style_On )),
+ pixelMetric(PM_DefaultFrameWidth),
+ &cg.brush(TQColorGroup::Button) );
+ break;
+
+ case PE_Indicator: {
+#ifndef QT_NO_BUTTON
+ bool on = flags & Style_On;
+ bool down = flags & Style_Down;
+ bool showUp = !( down ^ on );
+ TQBrush fill = showUp || flags & Style_NoChange ? cg.brush( TQColorGroup::Button ) : cg.brush(TQColorGroup::Mid );
+ if ( flags & Style_NoChange ) {
+ qDrawPlainRect( p, r, cg.text(),
+ 1, &fill );
+ p->drawLine( r.x() + r.width() - 1, r.y(),
+ r.x(), r.y() + r.height() - 1);
+ } else
+ qDrawShadePanel( p, r, cg, !showUp,
+ pixelMetric(PM_DefaultFrameWidth), &fill );
+#endif
+ break;
+ }
+
+ case PE_ExclusiveIndicator:
+ {
+#define TQCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2)
+ TQCOORD inner_pts[] = { // used for filling diamond
+ 2,r.height()/2,
+ r.width()/2,2,
+ r.width()-3,r.height()/2,
+ r.width()/2,r.height()-3
+ };
+ TQCOORD top_pts[] = { // top (^) of diamond
+ 0,r.height()/2,
+ r.width()/2,0,
+ r.width()-2,r.height()/2-1,
+ r.width()-3,r.height()/2-1,
+ r.width()/2,1,
+ 1,r.height()/2,
+ 2,r.height()/2,
+ r.width()/2,2,
+ r.width()-4,r.height()/2-1
+ };
+ TQCOORD bottom_pts[] = { // bottom (v) of diamond
+ 1,r.height()/2+1,
+ r.width()/2,r.height()-1,
+ r.width()-1,r.height()/2,
+ r.width()-2,r.height()/2,
+ r.width()/2,r.height()-2,
+ 2,r.height()/2+1,
+ 3,r.height()/2+1,
+ r.width()/2,r.height()-3,
+ r.width()-3,r.height()/2
+ };
+ bool on = flags & Style_On;
+ bool down = flags & Style_Down;
+ bool showUp = !(down ^ on );
+ TQPointArray a( TQCOORDARRLEN(inner_pts), inner_pts );
+ p->eraseRect( r );
+ p->setPen( NoPen );
+ p->setBrush( showUp ? cg.brush( TQColorGroup::Button ) :
+ cg.brush( TQColorGroup::Mid ) );
+ a.translate( r.x(), r.y() );
+ p->drawPolygon( a );
+ p->setPen( showUp ? cg.light() : cg.dark() );
+ p->setBrush( NoBrush );
+ a.setPoints( TQCOORDARRLEN(top_pts), top_pts );
+ a.translate( r.x(), r.y() );
+ p->drawPolyline( a );
+ p->setPen( showUp ? cg.dark() : cg.light() );
+ a.setPoints( TQCOORDARRLEN(bottom_pts), bottom_pts );
+ a.translate( r.x(), r.y() );
+ p->drawPolyline( a );
+
+ break;
+ }
+
+ case PE_ExclusiveIndicatorMask:
+ {
+ static TQCOORD inner_pts[] = { // used for filling diamond
+ 0,r.height()/2,
+ r.width()/2,0,
+ r.width()-1,r.height()/2,
+ r.width()/2,r.height()-1
+ };
+ TQPointArray a(TQCOORDARRLEN(inner_pts), inner_pts);
+ p->setPen(color1);
+ p->setBrush(color1);
+ a.translate(r.x(), r.y());
+ p->drawPolygon(a);
+ break;
+ }
+
+ case PE_ArrowUp:
+ case PE_ArrowDown:
+ case PE_ArrowRight:
+ case PE_ArrowLeft:
+ {
+ TQRect rect = r;
+ TQPointArray bFill;
+ TQPointArray bTop;
+ TQPointArray bBot;
+ TQPointArray bLeft;
+ bool vertical = pe == PE_ArrowUp || pe == PE_ArrowDown;
+ bool horizontal = !vertical;
+ int dim = rect.width() < rect.height() ? rect.width() : rect.height();
+ int colspec = 0x0000;
+
+ if ( dim < 2 )
+ break;
+
+ // adjust size and center (to fix rotation below)
+ if ( rect.width() > dim ) {
+ rect.setX( rect.x() + ((rect.width() - dim ) / 2) );
+ rect.setWidth( dim );
+ }
+ if ( rect.height() > dim ) {
+ rect.setY( rect.y() + ((rect.height() - dim ) / 2 ));
+ rect.setHeight( dim );
+ }
+
+ if ( dim > 3 ) {
+ if ( dim > 6 )
+ bFill.resize( dim & 1 ? 3 : 4 );
+ bTop.resize( (dim/2)*2 );
+ bBot.resize( dim & 1 ? dim + 1 : dim );
+ bLeft.resize( dim > 4 ? 4 : 2 );
+ bLeft.putPoints( 0, 2, 0,0, 0,dim-1 );
+ if ( dim > 4 )
+ bLeft.putPoints( 2, 2, 1,2, 1,dim-3 );
+ bTop.putPoints( 0, 4, 1,0, 1,1, 2,1, 3,1 );
+ bBot.putPoints( 0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2 );
+
+ for( int i=0; i<dim/2-2 ; i++ ) {
+ bTop.putPoints( i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i );
+ bBot.putPoints( i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i );
+ }
+ if ( dim & 1 ) // odd number size: extra line
+ bBot.putPoints( dim-1, 2, dim-3,dim/2, dim-1,dim/2 );
+ if ( dim > 6 ) { // dim>6: must fill interior
+ bFill.putPoints( 0, 2, 1,dim-3, 1,2 );
+ if ( dim & 1 ) // if size is an odd number
+ bFill.setPoint( 2, dim - 3, dim / 2 );
+ else
+ bFill.putPoints( 2, 2, dim-4,dim/2-1, dim-4,dim/2 );
+ }
+ }
+ else {
+ if ( dim == 3 ) { // 3x3 arrow pattern
+ bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 );
+ bTop .setPoints( 2, 1,0, 1,0 );
+ bBot .setPoints( 2, 1,2, 2,1 );
+ }
+ else { // 2x2 arrow pattern
+ bLeft.setPoints( 2, 0,0, 0,1 );
+ bTop .setPoints( 2, 1,0, 1,0 );
+ bBot .setPoints( 2, 1,1, 1,1 );
+ }
+ }
+
+ // We use rot() and translate() as it is more efficient that
+ // matrix transformations on the painter, and because it still
+ // works with QT_NO_TRANSFORMATIONS defined.
+
+ if ( pe == PE_ArrowUp || pe == PE_ArrowLeft ) {
+ if ( vertical ) {
+ rot(bFill,3);
+ rot(bLeft,3);
+ rot(bTop,3);
+ rot(bBot,3);
+ bFill.translate( 0, rect.height() - 1 );
+ bLeft.translate( 0, rect.height() - 1 );
+ bTop.translate( 0, rect.height() - 1 );
+ bBot.translate( 0, rect.height() - 1 );
+ } else {
+ rot(bFill,2);
+ rot(bLeft,2);
+ rot(bTop,2);
+ rot(bBot,2);
+ bFill.translate( rect.width() - 1, rect.height() - 1 );
+ bLeft.translate( rect.width() - 1, rect.height() - 1 );
+ bTop.translate( rect.width() - 1, rect.height() - 1 );
+ bBot.translate( rect.width() - 1, rect.height() - 1 );
+ }
+ if ( flags & Style_Down )
+ colspec = horizontal ? 0x2334 : 0x2343;
+ else
+ colspec = horizontal ? 0x1443 : 0x1434;
+ } else {
+ if ( vertical ) {
+ rot(bFill,1);
+ rot(bLeft,1);
+ rot(bTop,1);
+ rot(bBot,1);
+ bFill.translate( rect.width() - 1, 0 );
+ bLeft.translate( rect.width() - 1, 0 );
+ bTop.translate( rect.width() - 1, 0 );
+ bBot.translate( rect.width() - 1, 0 );
+ }
+ if ( flags & Style_Down )
+ colspec = horizontal ? 0x2443 : 0x2434;
+ else
+ colspec = horizontal ? 0x1334 : 0x1343;
+ }
+ bFill.translate( rect.x(), rect.y() );
+ bLeft.translate( rect.x(), rect.y() );
+ bTop.translate( rect.x(), rect.y() );
+ bBot.translate( rect.x(), rect.y() );
+
+ TQColor *cols[5];
+ if ( flags & Style_Enabled ) {
+ cols[0] = 0;
+ cols[1] = (TQColor *)&cg.button();
+ cols[2] = (TQColor *)&cg.mid();
+ cols[3] = (TQColor *)&cg.light();
+ cols[4] = (TQColor *)&cg.dark();
+ } else {
+ cols[0] = 0;
+ cols[1] = (TQColor *)&cg.button();
+ cols[2] = (TQColor *)&cg.button();
+ cols[3] = (TQColor *)&cg.button();
+ cols[4] = (TQColor *)&cg.button();
+ }
+
+#define CMID *cols[ (colspec>>12) & 0xf ]
+#define CLEFT *cols[ (colspec>>8) & 0xf ]
+#define CTOP *cols[ (colspec>>4) & 0xf ]
+#define CBOT *cols[ colspec & 0xf ]
+
+ TQPen savePen = p->pen();
+ TQBrush saveBrush = p->brush();
+ TQPen pen( NoPen );
+ TQBrush brush = cg.brush( flags & Style_Enabled ? TQColorGroup::Button :
+ TQColorGroup::Mid );
+ p->setPen( pen );
+ p->setBrush( brush );
+ p->drawPolygon( bFill );
+ p->setBrush( NoBrush );
+
+ p->setPen( CLEFT );
+ p->drawLineSegments( bLeft );
+ p->setPen( CTOP );
+ p->drawLineSegments( bTop );
+ p->setPen( CBOT );
+ p->drawLineSegments( bBot );
+
+ p->setBrush( saveBrush );
+ p->setPen( savePen );
+#undef CMID
+#undef CLEFT
+#undef CTOP
+#undef CBOT
+ break;
+ }
+
+ case PE_SpinWidgetPlus:
+ case PE_SpinWidgetMinus:
+ {
+ p->save();
+ int fw = pixelMetric( PM_DefaultFrameWidth );
+ TQRect br;
+ br.setRect( r.x() + fw, r.y() + fw, r.width() - fw*2,
+ r.height() - fw*2 );
+
+ if ( flags & Style_Sunken )
+ p->fillRect( r, cg.brush( TQColorGroup::Dark ) );
+ else
+ p->fillRect( r, cg.brush( TQColorGroup::Button ) );
+
+ p->setPen( cg.buttonText() );
+ p->setBrush( cg.buttonText() );
+
+ int length;
+ int x = r.x(), y = r.y(), w = r.width(), h = r.height();
+ if ( w <= 8 || h <= 6 )
+ length = TQMIN( w-2, h-2 );
+ else
+ length = TQMIN( 2*w / 3, 2*h / 3 );
+
+ if ( !(length & 1) )
+ length -=1;
+ int xmarg = ( w - length ) / 2;
+ int ymarg = ( h - length ) / 2;
+
+ p->drawLine( x + xmarg, ( y + h / 2 - 1 ),
+ x + xmarg + length - 1, ( y + h / 2 - 1 ) );
+ if ( pe == PE_SpinWidgetPlus )
+ p->drawLine( ( x+w / 2 ) - 1, y + ymarg,
+ ( x+w / 2 ) - 1, y + ymarg + length - 1 );
+ p->restore();
+ break;
+ }
+
+ case PE_SpinWidgetUp:
+ case PE_SpinWidgetDown:
+ {
+ p->save();
+ int fw = pixelMetric( PM_DefaultFrameWidth );
+ TQRect br;
+ br.setRect( r.x() + fw, r.y() + fw, r.width() - fw*2,
+ r.height() - fw*2 );
+ if ( flags & Style_Sunken )
+ p->fillRect( br, cg.brush( TQColorGroup::Mid ) );
+ else
+ p->fillRect( br, cg.brush( TQColorGroup::Button ) );
+
+ int x = r.x(), y = r.y(), w = r.width(), h = r.height();
+ int sw = w-4;
+ if ( sw < 3 )
+ return;
+ else if ( !(sw & 1) )
+ sw--;
+ sw -= ( sw / 7 ) * 2; // Empty border
+ int sh = sw/2 + 2; // Must have empty row at foot of arrow
+
+ int sx = x + w / 2 - sw / 2 - 1;
+ int sy = y + h / 2 - sh / 2 - 1;
+
+ TQPointArray a;
+ if ( pe == PE_SpinWidgetDown )
+ a.setPoints( 3, 0, 1, sw-1, 1, sh-2, sh-1 );
+ else
+ a.setPoints( 3, 0, sh-1, sw-1, sh-1, sh-2, 1 );
+ int bsx = 0;
+ int bsy = 0;
+ if ( flags & Style_Sunken ) {
+ bsx = pixelMetric(PM_ButtonShiftHorizontal);
+ bsy = pixelMetric(PM_ButtonShiftVertical);
+ }
+ p->translate( sx + bsx, sy + bsy );
+ p->setPen( cg.buttonText() );
+ p->setBrush( cg.buttonText() );
+ p->drawPolygon( a );
+ p->restore();
+ break;
+ }
+
+ case PE_DockWindowHandle:
+ {
+ p->save();
+ p->translate( r.x(), r.y() );
+
+ TQColor dark( cg.dark() );
+ TQColor light( cg.light() );
+ unsigned int i;
+ if ( flags & Style_Horizontal ) {
+ int h = r.height();
+ if ( h > 6 ) {
+ if ( flags & Style_On )
+ p->fillRect( 1, 1, 8, h - 2, cg.highlight() );
+ TQPointArray a( 2 * ((h-6)/3) );
+ int y = 3 + (h%3)/2;
+ p->setPen( dark );
+ p->drawLine( 8, 1, 8, h-2 );
+ for( i=0; 2*i < a.size(); i ++ ) {
+ a.setPoint( 2*i, 5, y+1+3*i );
+ a.setPoint( 2*i+1, 2, y+2+3*i );
+ }
+ p->drawPoints( a );
+ p->setPen( light );
+ p->drawLine( 9, 1, 9, h-2 );
+ for( i=0; 2*i < a.size(); i++ ) {
+ a.setPoint( 2*i, 4, y+3*i );
+ a.setPoint( 2*i+1, 1, y+1+3*i );
+ }
+ p->drawPoints( a );
+ // if ( drawBorder ) {
+ // p->setPen( TQPen( TQt::darkGray ) );
+ // p->drawLine( 0, r.height() - 1,
+ // tbExtent, r.height() - 1 );
+ // }
+ }
+ } else {
+ int w = r.width();
+ if ( w > 6 ) {
+ if ( flags & Style_On )
+ p->fillRect( 1, 1, w - 2, 9, cg.highlight() );
+ TQPointArray a( 2 * ((w-6)/3) );
+
+ int x = 3 + (w%3)/2;
+ p->setPen( dark );
+ p->drawLine( 1, 8, w-2, 8 );
+ for( i=0; 2*i < a.size(); i ++ ) {
+ a.setPoint( 2*i, x+1+3*i, 6 );
+ a.setPoint( 2*i+1, x+2+3*i, 3 );
+ }
+ p->drawPoints( a );
+ p->setPen( light );
+ p->drawLine( 1, 9, w-2, 9 );
+ for( i=0; 2*i < a.size(); i++ ) {
+ a.setPoint( 2*i, x+3*i, 5 );
+ a.setPoint( 2*i+1, x+1+3*i, 2 );
+ }
+ p->drawPoints( a );
+ // if ( drawBorder ) {
+ // p->setPen( TQPen( TQt::darkGray ) );
+ // p->drawLine( r.width() - 1, 0,
+ // r.width() - 1, tbExtent );
+ // }
+ }
+ }
+ p->restore();
+ break;
+ }
+
+ case PE_Splitter:
+ if (flags & Style_Horizontal)
+ flags &= ~Style_Horizontal;
+ else
+ flags |= Style_Horizontal;
+ // fall through intended
+
+ case PE_DockWindowResizeHandle:
+ {
+ const int motifOffset = 10;
+ int sw = pixelMetric( PM_SplitterWidth );
+ if ( flags & Style_Horizontal ) {
+ TQCOORD yPos = r.y() + r.height() / 2;
+ TQCOORD kPos = r.width() - motifOffset - sw;
+ TQCOORD kSize = sw - 2;
+
+ qDrawShadeLine( p, 0, yPos, kPos, yPos, cg );
+ qDrawShadePanel( p, kPos, yPos - sw / 2 + 1, kSize, kSize,
+ cg, FALSE, 1, &cg.brush( TQColorGroup::Button ) );
+ qDrawShadeLine( p, kPos + kSize - 1, yPos, r.width(), yPos, cg );
+ } else {
+ TQCOORD xPos = r.x() + r.width() / 2;
+ TQCOORD kPos = motifOffset;
+ TQCOORD kSize = sw - 2;
+
+ qDrawShadeLine( p, xPos, kPos + kSize - 1, xPos, r.height(), cg );
+ qDrawShadePanel( p, xPos - sw / 2 + 1, kPos, kSize, kSize, cg,
+ FALSE, 1, &cg.brush( TQColorGroup::Button ) );
+ qDrawShadeLine( p, xPos, 0, xPos, kPos, cg );
+ }
+ break;
+ }
+
+ case PE_CheckMark:
+ {
+ const int markW = 6;
+ const int markH = 6;
+ int posX = r.x() + ( r.width() - markW ) / 2 - 1;
+ int posY = r.y() + ( r.height() - markH ) / 2;
+ int dfw = pixelMetric(PM_DefaultFrameWidth);
+
+ if (dfw < 2) {
+ // Could do with some optimizing/caching...
+ TQPointArray a( 7*2 );
+ int i, xx, yy;
+ xx = posX;
+ yy = 3 + posY;
+ for ( i=0; i<3; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy++;
+ }
+ yy -= 2;
+ for ( i=3; i<7; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy--;
+ }
+ if ( ! (flags & Style_Enabled) && ! (flags & Style_On) ) {
+ int pnt;
+ p->setPen( cg.highlightedText() );
+ TQPoint offset(1,1);
+ for ( pnt = 0; pnt < (int)a.size(); pnt++ )
+ a[pnt] += offset;
+ p->drawLineSegments( a );
+ for ( pnt = 0; pnt < (int)a.size(); pnt++ )
+ a[pnt] -= offset;
+ }
+ p->setPen( cg.text() );
+ p->drawLineSegments( a );
+
+ qDrawShadePanel( p, posX-2, posY-2, markW+4, markH+6, cg, TRUE, dfw);
+ } else
+ qDrawShadePanel( p, posX, posY, markW, markH, cg, TRUE, dfw,
+ &cg.brush( TQColorGroup::Mid ) );
+
+ break;
+ }
+
+ case PE_ScrollBarSubLine:
+ drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
+ p, r, cg, Style_Enabled | flags);
+ break;
+
+ case PE_ScrollBarAddLine:
+ drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown),
+ p, r, cg, Style_Enabled | flags);
+ break;
+
+ case PE_ScrollBarSubPage:
+ case PE_ScrollBarAddPage:
+ p->fillRect(r, cg.brush(TQColorGroup::Mid));
+ break;
+
+ case PE_ScrollBarSlider:
+ drawPrimitive(PE_ButtonBevel, p, r, cg,
+ (flags | Style_Raised) & ~Style_Down);
+ break;
+
+ case PE_ProgressBarChunk:
+ p->fillRect( r.x(), r.y() + 2, r.width() - 2,
+ r.height() - 4, cg.brush(TQColorGroup::Highlight));
+ break;
+
+ default:
+ TQCommonStyle::drawPrimitive( pe, p, r, cg, flags, opt );
+ break;
+ }
+}
+
+
+/*!\reimp
+*/
+void TQMotifStyle::drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch( element ) {
+ case CE_PushButton:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ int diw, x1, y1, x2, y2;
+ const TQPushButton *btn;
+ TQColorGroup newCg = cg;
+ btn = ( const TQPushButton * )widget;
+ p->setPen( cg.foreground() );
+ p->setBrush( TQBrush( cg.button(), NoBrush ) );
+ diw = pixelMetric( PM_ButtonDefaultIndicator );
+ r.coords( &x1, &y1, &x2, &y2 );
+ if ( btn->isDefault() || btn->autoDefault() ) {
+ x1 += diw;
+ y1 += diw;
+ x2 -= diw;
+ y2 -= diw;
+ }
+ TQBrush fill;
+ if ( btn->isDown() )
+ fill = newCg.brush( TQColorGroup::Mid );
+ else if ( btn->isOn() )
+ fill = TQBrush( newCg.mid(), Dense4Pattern );
+ else
+ fill = newCg.brush( TQColorGroup::Button );
+
+ newCg.setBrush( TQColorGroup::Button, fill );
+ if ( btn->isDefault() ) {
+ if ( diw == 0 ) {
+ TQPointArray a;
+ a.setPoints( 9,
+ x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1,
+ x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1 );
+ p->setPen( newCg.shadow() );
+ p->drawPolygon( a );
+ x1 += 2;
+ y1 += 2;
+ x2 -= 2;
+ y2 -= 2;
+ } else {
+ qDrawShadePanel( p, r, newCg, TRUE );
+ }
+ }
+ if ( !btn->isFlat() || btn->isOn() || btn->isDown() ) {
+ TQRect tmp( x1, y1, x2 - x1 + 1, y2 - y1 + 1 );
+ SFlags flags = Style_Default;
+ if ( btn->isOn())
+ flags |= Style_On;
+ if (btn->isDown())
+ flags |= Style_Down;
+ p->save();
+ p->setBrushOrigin( -widget->backgroundOffset().x(),
+ -widget->backgroundOffset().y() );
+ drawPrimitive( PE_ButtonCommand, p,
+ tmp, newCg,
+ flags );
+ p->restore();
+ }
+ if ( p->brush().style() != NoBrush )
+ p->setBrush( NoBrush );
+#endif
+ break;
+ }
+
+ case CE_TabBarTab:
+ {
+#ifndef QT_NO_TABBAR
+ if ( !widget || !widget->parentWidget() || !opt.tab() )
+ break;
+
+ const TQTabBar * tb = (const TQTabBar *) widget;
+ const TQTab * t = opt.tab();
+
+ int dfw = pixelMetric( PM_DefaultFrameWidth, tb );
+ bool selected = flags & Style_Selected;
+ int o = dfw > 1 ? 1 : 0;
+ bool lastTab = FALSE;
+
+ TQRect r2( r );
+ if ( tb->shape() == TQTabBar::RoundedAbove ) {
+ if ( styleHint( SH_TabBar_Alignment, tb ) == AlignRight &&
+ tb->indexOf( t->identifier() ) == tb->count()-1 )
+ lastTab = TRUE;
+
+ if ( o ) {
+ p->setPen( tb->colorGroup().light() );
+ p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
+ p->setPen( tb->colorGroup().light() );
+ p->drawLine( r2.left(), r2.bottom()-1, r2.right(), r2.bottom()-1 );
+ if ( r2.left() == 0 )
+ p->drawPoint( tb->rect().bottomLeft() );
+ }
+ else {
+ p->setPen( tb->colorGroup().light() );
+ p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
+ }
+
+ if ( selected ) {
+ p->fillRect( TQRect( r2.left()+1, r2.bottom()-o, r2.width()-3, 2),
+ tb->palette().active().brush( TQColorGroup::Background ));
+ p->setPen( tb->colorGroup().background() );
+ // p->drawLine( r2.left()+1, r2.bottom(), r2.right()-2, r2.bottom() );
+ // if (o)
+ // p->drawLine( r2.left()+1, r2.bottom()-1, r2.right()-2, r2.bottom()-1 );
+ p->drawLine( r2.left()+1, r2.bottom(), r2.left()+1, r2.top()+2 );
+ p->setPen( tb->colorGroup().light() );
+ } else {
+ p->setPen( tb->colorGroup().light() );
+ r2.setRect( r2.left() + 2, r2.top() + 2,
+ r2.width() - 4, r2.height() - 2 );
+ }
+
+ p->drawLine( r2.left(), r2.bottom()-1, r2.left(), r2.top() + 2 );
+ p->drawPoint( r2.left()+1, r2.top() + 1 );
+ p->drawLine( r2.left()+2, r2.top(),
+ r2.right() - 2, r2.top() );
+ p->drawPoint( r2.left(), r2.bottom());
+
+ if ( o ) {
+ p->drawLine( r2.left()+1, r2.bottom(), r2.left()+1, r2.top() + 2 );
+ p->drawLine( r2.left()+2, r2.top()+1,
+ r2.right() - 2, r2.top()+1 );
+ }
+
+ p->setPen( tb->colorGroup().dark() );
+ p->drawLine( r2.right() - 1, r2.top() + 2,
+ r2.right() - 1, r2.bottom() - 1 + (selected ? o : -o));
+ if ( o ) {
+ p->drawPoint( r2.right() - 1, r2.top() + 1 );
+ p->drawLine( r2.right(), r2.top() + 2, r2.right(),
+ r2.bottom() -
+ (selected ? (lastTab ? 0:1):1+o));
+ p->drawPoint( r2.right() - 1, r2.top() + 1 );
+ }
+ } else if ( tb->shape() == TQTabBar::RoundedBelow ) {
+ if ( styleHint( SH_TabBar_Alignment, tb ) == AlignLeft &&
+ tb->indexOf( t->identifier() ) == tb->count()-1 )
+ lastTab = TRUE;
+ if ( selected ) {
+ p->fillRect( TQRect( r2.left()+1, r2.top(), r2.width()-3, 1),
+ tb->palette().active().brush( TQColorGroup::Background ));
+ p->setPen( tb->colorGroup().background() );
+ // p->drawLine( r2.left()+1, r2.top(), r2.right()-2, r2.top() );
+ p->drawLine( r2.left()+1, r2.top(), r2.left()+1, r2.bottom()-2 );
+ p->setPen( tb->colorGroup().dark() );
+ } else {
+ p->setPen( tb->colorGroup().dark() );
+ p->drawLine( r2.left(), r2.top(), r2.right(), r2.top() );
+ p->drawLine( r2.left() + 1, r2.top() + 1,
+ r2.right() - (lastTab ? 0 : 2),
+ r2.top() + 1 );
+ r2.setRect( r2.left() + 2, r2.top(),
+ r2.width() - 4, r2.height() - 2 );
+ }
+
+ p->drawLine( r2.right() - 1, r2.top(),
+ r2.right() - 1, r2.bottom() - 2 );
+ p->drawPoint( r2.right() - 2, r2.bottom() - 2 );
+ p->drawLine( r2.right() - 2, r2.bottom() - 1,
+ r2.left() + 1, r2.bottom() - 1 );
+ p->drawPoint( r2.left() + 1, r2.bottom() - 2 );
+
+ if (dfw > 1) {
+ p->drawLine( r2.right(), r2.top(),
+ r2.right(), r2.bottom() - 1 );
+ p->drawPoint( r2.right() - 1, r2.bottom() - 1 );
+ p->drawLine( r2.right() - 1, r2.bottom(),
+ r2.left() + 2, r2.bottom() );
+ }
+
+ p->setPen( tb->colorGroup().light() );
+ p->drawLine( r2.left(), r2.top() + (selected ? 0 : 2),
+ r2.left(), r2.bottom() - 2 );
+ p->drawLine( r2.left() + 1, r2.top() + (selected ? 0 : 2),
+ r2.left() + 1, r2.bottom() - 3 );
+
+ } else {
+ TQCommonStyle::drawControl( element, p, widget, r, cg, flags, opt );
+ }
+#endif
+ break;
+ }
+
+ case CE_ProgressBarGroove:
+ qDrawShadePanel(p, r, cg, TRUE, 2);
+ break;
+
+ case CE_ProgressBarLabel:
+ {
+#ifndef QT_NO_PROGRESSBAR
+ const TQProgressBar * pb = (const TQProgressBar *) widget;
+ const int unit_width = pixelMetric( PM_ProgressBarChunkWidth, pb );
+ int u = r.width() / unit_width;
+ int p_v = pb->progress();
+ int t_s = pb->totalSteps();
+ if ( u > 0 && pb->progress() >= INT_MAX / u && t_s >= u ) {
+ // scale down to something usable.
+ p_v /= u;
+ t_s /= u;
+ }
+ if ( pb->percentageVisible() && pb->totalSteps() ) {
+ int nu = ( u * p_v + t_s/2 ) / t_s;
+ int x = unit_width * nu;
+ if (pb->indicatorFollowsStyle() || pb->centerIndicator()) {
+ p->setPen( cg.highlightedText() );
+ p->setClipRect( r.x(), r.y(), x, r.height() );
+ p->drawText( r, AlignCenter | SingleLine, pb->progressString() );
+
+ if ( pb->progress() != pb->totalSteps() ) {
+ p->setClipRect( r.x() + x, r.y(), r.width() - x, r.height() );
+ p->setPen( cg.highlight() );
+ p->drawText( r, AlignCenter | SingleLine, pb->progressString() );
+ }
+ } else {
+ p->setPen( cg.text() );
+ p->drawText( r, AlignCenter | SingleLine, pb->progressString() );
+ }
+ }
+#endif
+ break;
+ }
+
+#ifndef QT_NO_POPUPMENU
+ case CE_PopupMenuItem:
+ {
+ if (! widget || opt.isDefault())
+ break;
+
+ const TQPopupMenu *popupmenu = (const TQPopupMenu *) widget;
+ TQMenuItem *mi = opt.menuItem();
+ if ( !mi )
+ break;
+
+ int tab = opt.tabWidth();
+ int maxpmw = opt.maxIconWidth();
+ bool dis = ! (flags & Style_Enabled);
+ bool checkable = popupmenu->isCheckable();
+ bool act = flags & Style_Active;
+ int x, y, w, h;
+
+ r.rect(&x, &y, &w, &h);
+
+ if ( checkable )
+ maxpmw = TQMAX( maxpmw, motifCheckMarkSpace );
+
+ int checkcol = maxpmw;
+
+ if ( mi && mi->isSeparator() ) { // draw separator
+ p->setPen( cg.dark() );
+ p->drawLine( x, y, x+w, y );
+ p->setPen( cg.light() );
+ p->drawLine( x, y+1, x+w, y+1 );
+ return;
+ }
+
+ int pw = motifItemFrame;
+
+ if ( act && !dis ) { // active item frame
+ if (pixelMetric( PM_DefaultFrameWidth ) > 1)
+ qDrawShadePanel( p, x, y, w, h, cg, FALSE, pw,
+ &cg.brush( TQColorGroup::Button ) );
+ else
+ qDrawShadePanel( p, x+1, y+1, w-2, h-2, cg, TRUE, 1,
+ &cg.brush( TQColorGroup::Button ) );
+ }
+ else // incognito frame
+ p->fillRect(x, y, w, h, cg.brush( TQColorGroup::Button ));
+
+ if ( !mi )
+ return;
+
+ TQRect vrect = visualRect( TQRect( x+motifItemFrame, y+motifItemFrame, checkcol, h-2*motifItemFrame ), r );
+ int xvis = vrect.x();
+ if ( mi->isChecked() ) {
+ if ( mi->iconSet() ) {
+ qDrawShadePanel( p, xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame,
+ cg, TRUE, 1, &cg.brush( TQColorGroup::Midlight ) );
+ }
+ } else if ( !act ) {
+ p->fillRect(xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame,
+ cg.brush( TQColorGroup::Button ));
+ }
+
+ if ( mi->iconSet() ) { // draw iconset
+ TQIconSet::Mode mode = TQIconSet::Normal; // no disabled icons in Motif
+ if (act && !dis )
+ mode = TQIconSet::Active;
+ TQPixmap pixmap;
+ if ( checkable && mi->isChecked() )
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode, TQIconSet::On );
+ else
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode );
+
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ TQRect pmr( 0, 0, pixw, pixh );
+ pmr.moveCenter( vrect.center() );
+ p->setPen( cg.text() );
+ p->drawPixmap( pmr.topLeft(), pixmap );
+
+ } else if ( checkable ) { // just "checking"...
+ int mw = checkcol;
+ int mh = h - 2*motifItemFrame;
+ if ( mi->isChecked() ) {
+ SFlags cflags = Style_Default;
+ if (! dis)
+ cflags |= Style_Enabled;
+ if (act)
+ cflags |= Style_On;
+
+ drawPrimitive(PE_CheckMark, p,
+ TQRect(xvis, y+motifItemFrame, mw, mh),
+ cg, cflags);
+ }
+ }
+
+
+ p->setPen( cg.buttonText() );
+
+ TQColor discol;
+ if ( dis ) {
+ discol = cg.text();
+ p->setPen( discol );
+ }
+
+ int xm = motifItemFrame + checkcol + motifItemHMargin;
+
+ vrect = visualRect( TQRect( x+xm, y+motifItemVMargin, w-xm-tab, h-2*motifItemVMargin ), r );
+ xvis = vrect.x();
+ if ( mi->custom() ) {
+ int m = motifItemVMargin;
+ p->save();
+ mi->custom()->paint( p, cg, act, !dis,
+ xvis, y+m, w-xm-tab+1, h-2*m );
+ p->restore();
+ }
+ TQString s = mi->text();
+ if ( !s.isNull() ) { // draw text
+ int t = s.find( '\t' );
+ int m = motifItemVMargin;
+ int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
+ text_flags |= (TQApplication::reverseLayout() ? AlignRight : AlignLeft );
+ if ( t >= 0 ) { // draw tab text
+ TQRect vr = visualRect( TQRect( x+w-tab-motifItemHMargin-motifItemFrame,
+ y+motifItemVMargin, tab, h-2*motifItemVMargin ), r );
+ int xv = vr.x();
+ p->drawText( xv, y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
+ s = s.left( t );
+ }
+ p->drawText( xvis, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
+ } else if ( mi->pixmap() ) { // draw pixmap
+ TQPixmap *pixmap = mi->pixmap();
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( OpaqueMode );
+ p->drawPixmap( xvis, y+motifItemFrame, *pixmap );
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( TransparentMode );
+ }
+ if ( mi->popup() ) { // draw sub menu arrow
+ int dim = (h-2*motifItemFrame) / 2;
+ TQStyle::PrimitiveElement arrow = (TQApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight);
+ TQRect vr = visualRect( TQRect(x+w - motifArrowHMargin - motifItemFrame - dim,
+ y+h/2-dim/2, dim, dim), r );
+ if ( act )
+ drawPrimitive(arrow, p, vr, cg,
+ (Style_Down |
+ (dis ? Style_Default : Style_Enabled)) );
+ else
+ drawPrimitive(arrow, p, vr, cg,
+ (dis ? Style_Default : Style_Enabled));
+ }
+
+ break;
+ }
+#endif // QT_NO_POPUPMENU
+
+ case CE_MenuBarItem:
+ {
+ if ( flags & Style_Active ) // active item
+ qDrawShadePanel( p, r, cg, FALSE, motifItemFrame,
+ &cg.brush(TQColorGroup::Button) );
+ else // other item
+ p->fillRect( r, cg.brush(TQColorGroup::Button) );
+ TQCommonStyle::drawControl( element, p, widget, r, cg, flags, opt );
+ break;
+ }
+
+ default:
+ TQCommonStyle::drawControl( element, p, widget, r, cg, flags, opt );
+ break;
+ }
+}
+
+static int get_combo_extra_width( int h, int w, int *return_awh=0 )
+{
+ int awh,
+ tmp;
+ if ( h < 8 ) {
+ awh = 6;
+ } else if ( h < 14 ) {
+ awh = h - 2;
+ } else {
+ awh = h/2;
+ }
+ tmp = (awh * 3) / 2;
+ if ( tmp > w / 2 ) {
+ awh = w / 2 - 3;
+ tmp = w / 2 + 3;
+ }
+
+ if ( return_awh )
+ *return_awh = awh;
+
+ return tmp;
+}
+
+static void get_combo_parameters( const TQRect &r,
+ int &ew, int &awh, int &ax,
+ int &ay, int &sh, int &dh,
+ int &sy )
+{
+ ew = get_combo_extra_width( r.height(), r.width(), &awh );
+
+ sh = (awh+3)/4;
+ if ( sh < 3 )
+ sh = 3;
+ dh = sh/2 + 1;
+
+ ay = r.y() + (r.height()-awh-sh-dh)/2;
+ if ( ay < 0 ) {
+ //panic mode
+ ay = 0;
+ sy = r.height();
+ } else {
+ sy = ay+awh+dh;
+ }
+ ax = r.x() + r.width() - ew;
+ ax += (ew-awh)/2;
+}
+
+/*!\reimp
+*/
+void TQMotifStyle::drawComplexControl( ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ SCFlags sub,
+ SCFlags subActive,
+ const TQStyleOption& opt ) const
+{
+ switch ( control ) {
+ case CC_SpinWidget: {
+ SCFlags drawSub = SC_None;
+ if ( sub & SC_SpinWidgetFrame )
+ qDrawShadePanel( p, r, cg, TRUE,
+ pixelMetric( PM_DefaultFrameWidth) );
+
+ if ( sub & SC_SpinWidgetUp || sub & SC_SpinWidgetDown ) {
+ if ( sub & SC_SpinWidgetUp )
+ drawSub |= SC_SpinWidgetUp;
+ if ( sub & SC_SpinWidgetDown )
+ drawSub |= SC_SpinWidgetDown;
+
+ TQCommonStyle::drawComplexControl( control, p, widget, r, cg, flags,
+ drawSub, subActive, opt );
+ }
+ break; }
+
+ case CC_Slider:
+ {
+#ifndef QT_NO_SLIDER
+ const TQSlider * slider = (const TQSlider *) widget;
+
+ TQRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
+ opt),
+ handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
+ opt);
+
+ if ((sub & SC_SliderGroove) && groove.isValid()) {
+ qDrawShadePanel( p, groove, cg, TRUE, 2,
+ &cg.brush( TQColorGroup::Mid ) );
+
+
+ if ( flags & Style_HasFocus ) {
+ TQRect fr = subRect( SR_SliderFocusRect, widget );
+ drawPrimitive( PE_FocusRect, p, fr, cg );
+ }
+ }
+
+ if (( sub & SC_SliderHandle ) && handle.isValid()) {
+ drawPrimitive( PE_ButtonBevel, p, handle, cg );
+
+ if ( slider->orientation() == Horizontal ) {
+ TQCOORD mid = handle.x() + handle.width() / 2;
+ qDrawShadeLine( p, mid, handle.y(), mid,
+ handle.y() + handle.height() - 2,
+ cg, TRUE, 1);
+ } else {
+ TQCOORD mid = handle.y() + handle.height() / 2;
+ qDrawShadeLine( p, handle.x(), mid,
+ handle.x() + handle.width() - 2, mid,
+ cg, TRUE, 1);
+ }
+ }
+
+ if ( sub & SC_SliderTickmarks )
+ TQCommonStyle::drawComplexControl( control, p, widget, r, cg, flags,
+ SC_SliderTickmarks, subActive,
+ opt );
+#endif
+ break;
+ }
+
+ case CC_ComboBox:
+#ifndef QT_NO_COMBOBOX
+ if ( sub & SC_ComboBoxArrow ) {
+ const TQComboBox * cb = (const TQComboBox *) widget;
+ int awh, ax, ay, sh, sy, dh, ew;
+ int fw = pixelMetric( PM_DefaultFrameWidth, cb);
+
+ drawPrimitive( PE_ButtonCommand, p, r, cg, flags );
+ TQRect ar = TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb, SC_ComboBoxArrow,
+ opt ), cb );
+ drawPrimitive( PE_ArrowDown, p, ar, cg, flags | Style_Enabled );
+
+ TQRect tr = r;
+ tr.addCoords( fw, fw, -fw, -fw );
+ get_combo_parameters( tr, ew, awh, ax, ay, sh, dh, sy );
+
+ // draws the shaded line under the arrow
+ p->setPen( cg.light() );
+ p->drawLine( ar.x(), sy, ar.x()+awh-1, sy );
+ p->drawLine( ar.x(), sy, ar.x(), sy+sh-1 );
+ p->setPen( cg.dark() );
+ p->drawLine( ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1 );
+ p->drawLine( ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1 );
+
+ if ( cb->hasFocus() ) {
+ TQRect re = TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), cb );
+ drawPrimitive( PE_FocusRect, p, re, cg );
+ }
+ }
+
+ if ( sub & SC_ComboBoxEditField ) {
+ TQComboBox * cb = (TQComboBox *) widget;
+ if ( cb->editable() ) {
+ TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb,
+ SC_ComboBoxEditField ), cb );
+ er.addCoords( -1, -1, 1, 1);
+ qDrawShadePanel( p, er, cg, TRUE, 1,
+ &cg.brush( TQColorGroup::Button ));
+ }
+ }
+#endif
+ p->setPen(cg.buttonText());
+ break;
+
+ case CC_ScrollBar:
+ {
+ if (sub == (SC_ScrollBarAddLine | SC_ScrollBarSubLine | SC_ScrollBarAddPage |
+ SC_ScrollBarSubPage | SC_ScrollBarFirst | SC_ScrollBarLast |
+ SC_ScrollBarSlider))
+ qDrawShadePanel(p, widget->rect(), cg, TRUE,
+ pixelMetric(PM_DefaultFrameWidth, widget),
+ &cg.brush(TQColorGroup::Mid));
+ TQCommonStyle::drawComplexControl(control, p, widget, r, cg, flags, sub,
+ subActive, opt);
+ break;
+ }
+
+#ifndef QT_NO_LISTVIEW
+ case CC_ListView:
+ {
+ if ( sub & SC_ListView ) {
+ TQCommonStyle::drawComplexControl( control, p, widget, r, cg, flags, sub, subActive, opt );
+ }
+ if ( sub & ( SC_ListViewBranch | SC_ListViewExpand ) ) {
+ if (opt.isDefault())
+ break;
+
+ TQListViewItem *item = opt.listViewItem();
+ TQListViewItem *child = item->firstChild();
+
+ int y = r.y();
+ int c;
+ TQPointArray dotlines;
+ if ( subActive == (uint)SC_All && sub == SC_ListViewExpand ) {
+ c = 2;
+ dotlines.resize(2);
+ dotlines[0] = TQPoint( r.right(), r.top() );
+ dotlines[1] = TQPoint( r.right(), r.bottom() );
+ } else {
+ int linetop = 0, linebot = 0;
+ // each branch needs at most two lines, ie. four end points
+ dotlines.resize( item->childCount() * 4 );
+ c = 0;
+
+ // skip the stuff above the exposed rectangle
+ while ( child && y + child->height() <= 0 ) {
+ y += child->totalHeight();
+ child = child->nextSibling();
+ }
+
+ int bx = r.width() / 2;
+
+ // paint stuff in the magical area
+ TQListView* v = item->listView();
+ while ( child && y < r.height() ) {
+ if (child->isVisible()) {
+ int lh;
+ if ( !item->multiLinesEnabled() )
+ lh = child->height();
+ else
+ lh = p->fontMetrics().height() + 2 * v->itemMargin();
+ lh = TQMAX( lh, TQApplication::globalStrut().height() );
+ if ( lh % 2 > 0 )
+ lh++;
+ linebot = y + lh/2;
+ if ( (child->isExpandable() || child->childCount()) &&
+ (child->height() > 0) ) {
+ // needs a box
+ p->setPen( cg.text() );
+ p->drawRect( bx-4, linebot-4, 9, 9 );
+ TQPointArray a;
+ if ( child->isOpen() )
+ a.setPoints( 3, bx-2, linebot-2,
+ bx, linebot+2,
+ bx+2, linebot-2 ); //RightArrow
+ else
+ a.setPoints( 3, bx-2, linebot-2,
+ bx+2, linebot,
+ bx-2, linebot+2 ); //DownArrow
+ p->setBrush( cg.text() );
+ p->drawPolygon( a );
+ p->setBrush( NoBrush );
+ // dotlinery
+ dotlines[c++] = TQPoint( bx, linetop );
+ dotlines[c++] = TQPoint( bx, linebot - 5 );
+ dotlines[c++] = TQPoint( bx + 5, linebot );
+ dotlines[c++] = TQPoint( r.width(), linebot );
+ linetop = linebot + 5;
+ } else {
+ // just dotlinery
+ dotlines[c++] = TQPoint( bx+1, linebot );
+ dotlines[c++] = TQPoint( r.width(), linebot );
+ }
+ y += child->totalHeight();
+ }
+ child = child->nextSibling();
+ }
+
+ // Expand line height to edge of rectangle if there's any
+ // visible child below
+ while ( child && child->height() <= 0)
+ child = child->nextSibling();
+ if ( child )
+ linebot = r.height();
+
+ if ( linetop < linebot ) {
+ dotlines[c++] = TQPoint( bx, linetop );
+ dotlines[c++] = TQPoint( bx, linebot );
+ }
+ }
+
+ int line; // index into dotlines
+ p->setPen( cg.text() );
+ if ( sub & SC_ListViewBranch ) for( line = 0; line < c; line += 2 ) {
+ p->drawLine( dotlines[line].x(), dotlines[line].y(),
+ dotlines[line+1].x(), dotlines[line+1].y() );
+ }
+ }
+
+ break;
+ }
+#endif // QT_NO_LISTVIEW
+
+ default:
+ TQCommonStyle::drawComplexControl( control, p, widget, r, cg, flags,
+ sub, subActive, opt );
+ }
+}
+
+
+/*! \reimp */
+int TQMotifStyle::pixelMetric( PixelMetric metric, const TQWidget *widget ) const
+{
+ int ret;
+
+ switch( metric ) {
+ case PM_ButtonDefaultIndicator:
+ ret = 3;
+ break;
+
+ case PM_ButtonShiftHorizontal:
+ case PM_ButtonShiftVertical:
+ ret = 0;
+ break;
+
+ case PM_SplitterWidth:
+ ret = TQMAX( 10, TQApplication::globalStrut().width() );
+ break;
+
+ case PM_SliderLength:
+ ret = 30;
+ break;
+
+ case PM_SliderThickness:
+ ret = 24;
+ break;
+
+ case PM_SliderControlThickness:
+ {
+#ifndef QT_NO_SLIDER
+ const TQSlider * sl = (const TQSlider *) widget;
+ int space = (sl->orientation() == Horizontal) ? sl->height()
+ : sl->width();
+ int ticks = sl->tickmarks();
+ int n = 0;
+ if ( ticks & TQSlider::Above ) n++;
+ if ( ticks & TQSlider::Below ) n++;
+ if ( !n ) {
+ ret = space;
+ break;
+ }
+
+ int thick = 6; // Magic constant to get 5 + 16 + 5
+
+ space -= thick;
+ //### the two sides may be unequal in size
+ if ( space > 0 )
+ thick += (space * 2) / (n + 2);
+ ret = thick;
+#endif
+ break;
+ }
+
+ case PM_SliderSpaceAvailable:
+ {
+#ifndef QT_NO_SLIDER
+ const TQSlider * sl = (const TQSlider *) widget;
+ if ( sl->orientation() == Horizontal )
+ ret = sl->width() - pixelMetric( PM_SliderLength, sl ) - 6;
+ else
+ ret = sl->height() - pixelMetric( PM_SliderLength, sl ) - 6;
+#endif
+ break;
+ }
+
+ case PM_DockWindowHandleExtent:
+ ret = 9;
+ break;
+
+ case PM_ProgressBarChunkWidth:
+ ret = 1;
+ break;
+
+ case PM_ExclusiveIndicatorWidth:
+ case PM_ExclusiveIndicatorHeight:
+ ret = 13;
+ break;
+
+ default:
+ ret = TQCommonStyle::pixelMetric( metric, widget );
+ break;
+ }
+ return ret;
+}
+
+
+/*!\reimp
+*/
+TQRect TQMotifStyle::querySubControlMetrics( ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& opt ) const
+{
+ switch ( control ) {
+ case CC_SpinWidget: {
+ if ( !widget )
+ return TQRect();
+ int fw = pixelMetric( PM_SpinBoxFrameWidth, 0 );
+ TQSize bs;
+ bs.setHeight( widget->height()/2 );
+ if ( bs.height() < 8 )
+ bs.setHeight( 8 );
+ bs.setWidth( TQMIN( bs.height() * 8 / 5, widget->width() / 4 ) ); // 1.6 -approximate golden mean
+ bs = bs.expandedTo( TQApplication::globalStrut() );
+ int y = 0;
+ int x, lx, rx;
+ x = widget->width() - y - bs.width();
+ lx = fw;
+ rx = x - fw * 2;
+ switch ( sc ) {
+ case SC_SpinWidgetUp:
+ return TQRect(x, y, bs.width(), bs.height());
+ case SC_SpinWidgetDown:
+ return TQRect(x, y + bs.height(), bs.width(), bs.height());
+ case SC_SpinWidgetButtonField:
+ return TQRect(x, y, bs.width(), widget->height() - 2*fw);
+ case SC_SpinWidgetEditField:
+ return TQRect(lx, fw, rx, widget->height() - 2*fw);
+ case SC_SpinWidgetFrame:
+ return TQRect( 0, 0,
+ widget->width() - bs.width(), widget->height() );
+ default:
+ break;
+ }
+ break; }
+
+#ifndef QT_NO_SLIDER
+ case CC_Slider: {
+ if (sc == SC_SliderHandle) {
+ const TQSlider * sl = (const TQSlider *) widget;
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, sl );
+ int thickness = pixelMetric( PM_SliderControlThickness, sl );
+ int sliderPos = sl->sliderStart();
+ int len = pixelMetric( PM_SliderLength, sl );
+ int motifBorder = 3;
+
+ if ( sl->orientation() == Horizontal )
+ return TQRect( sliderPos + motifBorder, tickOffset + motifBorder, len,
+ thickness - 2*motifBorder );
+ return TQRect( tickOffset + motifBorder, sliderPos + motifBorder,
+ thickness - 2*motifBorder, len );
+ }
+ break; }
+#endif
+
+#ifndef QT_NO_SCROLLBAR
+ case CC_ScrollBar: {
+ if (! widget)
+ return TQRect();
+
+ const TQScrollBar *scrollbar = (const TQScrollBar *) widget;
+ int sliderstart = scrollbar->sliderStart();
+ int sbextent = pixelMetric(PM_ScrollBarExtent, widget);
+ int fw = pixelMetric(PM_DefaultFrameWidth, widget);
+ int buttonw = sbextent - (fw * 2);
+ int buttonh = sbextent - (fw * 2);
+ int maxlen = ((scrollbar->orientation() == TQt::Horizontal) ?
+ scrollbar->width() : scrollbar->height()) -
+ (buttonw * 2) - (fw * 2);
+ int sliderlen;
+
+ // calculate slider length
+ if (scrollbar->maxValue() != scrollbar->minValue()) {
+ uint range = scrollbar->maxValue() - scrollbar->minValue();
+ sliderlen = (scrollbar->pageStep() * maxlen) /
+ (range + scrollbar->pageStep());
+
+ if ( sliderlen < 9 || range > INT_MAX/2 )
+ sliderlen = 9;
+ if ( sliderlen > maxlen )
+ sliderlen = maxlen;
+ } else
+ sliderlen = maxlen;
+
+ switch (sc) {
+ case SC_ScrollBarSubLine:
+ // top/left button
+ if (scrollbar->orientation() == TQt::Horizontal) {
+ if ( scrollbar->width()/2 < sbextent )
+ buttonw = scrollbar->width()/2 - (fw*2);
+ return TQRect(fw, fw, buttonw, buttonh);
+ } else {
+ if ( scrollbar->height()/2 < sbextent )
+ buttonh = scrollbar->height()/2 - (fw*2);
+ return TQRect(fw, fw, buttonw, buttonh);
+ }
+ case SC_ScrollBarAddLine:
+ // bottom/right button
+ if (scrollbar->orientation() == TQt::Horizontal) {
+ if ( scrollbar->width()/2 < sbextent )
+ buttonw = scrollbar->width()/2 - (fw*2);
+ return TQRect(scrollbar->width() - buttonw - fw, fw,
+ buttonw, buttonh);
+ } else {
+ if ( scrollbar->height()/2 < sbextent )
+ buttonh = scrollbar->height()/2 - (fw*2);
+ return TQRect(fw, scrollbar->height() - buttonh - fw,
+ buttonw, buttonh);
+ }
+ case SC_ScrollBarSubPage:
+ if (scrollbar->orientation() == TQt::Horizontal)
+ return TQRect(buttonw + fw, fw, sliderstart - buttonw - fw, buttonw);
+ return TQRect(fw, buttonw + fw, buttonw, sliderstart - buttonw - fw);
+
+ case SC_ScrollBarAddPage:
+ if (scrollbar->orientation() == TQt::Horizontal)
+ return TQRect(sliderstart + sliderlen, fw,
+ maxlen - sliderstart - sliderlen + buttonw + fw, buttonw);
+ return TQRect(fw, sliderstart + sliderlen, buttonw,
+ maxlen - sliderstart - sliderlen + buttonw + fw);
+
+ case SC_ScrollBarGroove:
+ if (scrollbar->orientation() == TQt::Horizontal)
+ return TQRect(buttonw + fw, fw, maxlen, buttonw);
+ return TQRect(fw, buttonw + fw, buttonw, maxlen);
+
+ case SC_ScrollBarSlider:
+ if (scrollbar->orientation() == TQt::Horizontal)
+ return TQRect(sliderstart, fw, sliderlen, buttonw);
+ return TQRect(fw, sliderstart, buttonw, sliderlen);
+
+ default:
+ break;
+ }
+ break; }
+#endif
+
+#ifndef QT_NO_COMBOBOX
+ case CC_ComboBox:
+
+ switch ( sc ) {
+ case SC_ComboBoxArrow: {
+ const TQComboBox * cb = (const TQComboBox *) widget;
+ int ew, awh, sh, dh, ax, ay, sy;
+ int fw = pixelMetric( PM_DefaultFrameWidth, cb );
+ TQRect cr = cb->rect();
+ cr.addCoords( fw, fw, -fw, -fw );
+ get_combo_parameters( cr, ew, awh, ax, ay, sh, dh, sy );
+ return TQRect( ax, ay, awh, awh ); }
+
+ case SC_ComboBoxEditField: {
+ const TQComboBox * cb = (const TQComboBox *) widget;
+ int fw = pixelMetric( PM_DefaultFrameWidth, cb );
+ TQRect rect = cb->rect();
+ rect.addCoords( fw, fw, -fw, -fw );
+ int ew = get_combo_extra_width( rect.height(), rect.width() );
+ rect.addCoords( 1, 1, -1-ew, -1 );
+ return rect; }
+
+ default:
+ break;
+ }
+ break;
+#endif
+ default: break;
+ }
+ return TQCommonStyle::querySubControlMetrics( control, widget, sc, opt );
+}
+
+/*!\reimp
+*/
+TQSize TQMotifStyle::sizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& opt ) const
+{
+ TQSize sz(contentsSize);
+
+ switch(contents) {
+ case CT_PushButton:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ sz = TQCommonStyle::sizeFromContents(contents, widget, contentsSize, opt);
+ if ((button->isDefault() || button->autoDefault()) &&
+ sz.width() < 80 && ! button->pixmap())
+ sz.setWidth(80);
+#endif
+ break;
+ }
+
+ case CT_PopupMenuItem:
+ {
+#ifndef QT_NO_POPUPMENU
+ if (! widget || opt.isDefault())
+ break;
+
+ const TQPopupMenu *popup = (TQPopupMenu *) widget;
+ bool checkable = popup->isCheckable();
+ TQMenuItem *mi = opt.menuItem();
+ int maxpmw = opt.maxIconWidth();
+ int w = sz.width(), h = sz.height();
+
+ if (mi->custom()) {
+ w = mi->custom()->sizeHint().width();
+ h = mi->custom()->sizeHint().height();
+ if (! mi->custom()->fullSpan())
+ h += 2*motifItemVMargin + 2*motifItemFrame;
+ } else if ( mi->widget() ) {
+ } else if ( mi->isSeparator() ) {
+ w = 10;
+ h = motifSepHeight;
+ } else if (mi->pixmap() || ! mi->text().isNull())
+ h += 2*motifItemVMargin + 2*motifItemFrame;
+
+ // a little bit of border can never harm
+ w += 2*motifItemHMargin + 2*motifItemFrame;
+
+ if ( !mi->text().isNull() && mi->text().find('\t') >= 0 )
+ // string contains tab
+ w += motifTabSpacing;
+ else if (mi->popup())
+ // submenu indicator needs some room if we don't have a tab column
+ w += motifArrowHMargin + 4*motifItemFrame;
+
+ if ( checkable && maxpmw <= 0)
+ // if we are checkable and have no iconsets, add space for a checkmark
+ w += motifCheckMarkSpace;
+ else if (checkable && maxpmw < motifCheckMarkSpace)
+ // make sure the check-column is wide enough if we have iconsets
+ w += (motifCheckMarkSpace - maxpmw);
+
+ // if we have a check-column ( iconsets of checkmarks), add space
+ // to separate the columns
+ if ( maxpmw > 0 || checkable )
+ w += motifCheckMarkHMargin;
+
+ sz = TQSize(w, h);
+#endif
+ break;
+ }
+
+ default:
+ sz = TQCommonStyle::sizeFromContents( contents, widget, contentsSize, opt );
+ break;
+ }
+
+ return sz;
+}
+
+/*!\reimp
+*/
+TQRect TQMotifStyle::subRect( SubRect r, const TQWidget *widget ) const
+{
+ TQRect rect;
+ TQRect wrect = widget->rect();
+
+ switch ( r ) {
+ case SR_SliderFocusRect:
+ rect = TQCommonStyle::subRect( r, widget );
+ rect.addCoords( 2, 2, -2, -2 );
+ break;
+
+ case SR_ComboBoxFocusRect:
+ {
+ int awh, ax, ay, sh, sy, dh, ew;
+ int fw = pixelMetric( PM_DefaultFrameWidth, widget );
+ TQRect tr = wrect;
+
+ tr.addCoords( fw, fw, -fw, -fw );
+ get_combo_parameters( tr, ew, awh, ax, ay, sh, dh, sy );
+ rect.setRect(ax-2, ay-2, awh+4, awh+sh+dh+4);
+ break;
+ }
+
+ case SR_DockWindowHandleRect:
+ {
+#ifndef QT_NO_MAINWINDOW
+ if ( !widget || !widget->parent() )
+ break;
+
+ const TQDockWindow * dw = (const TQDockWindow *) widget->parent();
+ if ( !dw->area() || !dw->isCloseEnabled() )
+ rect.setRect( 0, 0, widget->width(), widget->height() );
+ else {
+ if ( dw->area()->orientation() == Horizontal )
+ rect.setRect(2, 15, widget->width()-2, widget->height() - 15);
+ else
+ rect.setRect(0, 2, widget->width() - 15, widget->height() - 2);
+ }
+#endif
+ break;
+ }
+
+ case SR_ProgressBarGroove:
+ case SR_ProgressBarContents:
+ {
+#ifndef QT_NO_PROGRESSBAR
+ TQFontMetrics fm( ( widget ? widget->fontMetrics() :
+ TQApplication::fontMetrics() ) );
+ const TQProgressBar *progressbar = (const TQProgressBar *) widget;
+ int textw = 0;
+ if (progressbar->percentageVisible())
+ textw = fm.width("100%") + 6;
+
+ if (progressbar->indicatorFollowsStyle() ||
+ progressbar->centerIndicator())
+ rect = wrect;
+ else
+ rect.setCoords(wrect.left(), wrect.top(),
+ wrect.right() - textw, wrect.bottom());
+#endif
+ break;
+ }
+
+ case SR_ProgressBarLabel:
+ {
+#ifndef QT_NO_PROGRESSBAR
+ TQFontMetrics fm( ( widget ? widget->fontMetrics() :
+ TQApplication::fontMetrics() ) );
+ const TQProgressBar *progressbar = (const TQProgressBar *) widget;
+ int textw = 0;
+ if (progressbar->percentageVisible())
+ textw = fm.width("100%") + 6;
+
+ if (progressbar->indicatorFollowsStyle() ||
+ progressbar->centerIndicator())
+ rect = wrect;
+ else
+ rect.setCoords(wrect.right() - textw, wrect.top(),
+ wrect.right(), wrect.bottom());
+#endif
+ break;
+ }
+
+ case SR_CheckBoxContents:
+ {
+#ifndef QT_NO_CHECKBOX
+ TQRect ir = subRect(SR_CheckBoxIndicator, widget);
+ rect.setRect(ir.right() + 10, wrect.y(),
+ wrect.width() - ir.width() - 10, wrect.height());
+#endif
+ break;
+ }
+
+ case SR_RadioButtonContents:
+ {
+ TQRect ir = subRect(SR_RadioButtonIndicator, widget);
+ rect.setRect(ir.right() + 10, wrect.y(),
+ wrect.width() - ir.width() - 10, wrect.height());
+ break;
+ }
+
+ default:
+ rect = TQCommonStyle::subRect( r, widget );
+ }
+
+ return rect;
+}
+
+/*! \reimp
+*/
+void TQMotifStyle::polishPopupMenu( TQPopupMenu* p)
+{
+#ifndef QT_NO_POPUPMENU
+ if ( !p->testWState( WState_Polished ) )
+ p->setCheckable( FALSE );
+#endif
+}
+
+
+#ifndef QT_NO_IMAGEIO_XPM
+static const char * const qt_close_xpm[] = {
+"12 12 2 1",
+" s None c None",
+". c black",
+" ",
+" ",
+" . . ",
+" ... ... ",
+" ...... ",
+" .... ",
+" .... ",
+" ...... ",
+" ... ... ",
+" . . ",
+" ",
+" "};
+
+static const char * const qt_maximize_xpm[] = {
+"12 12 2 1",
+" s None c None",
+". c black",
+" ",
+" ",
+" ",
+" . ",
+" ... ",
+" ..... ",
+" ....... ",
+" ......... ",
+" ",
+" ",
+" ",
+" "};
+
+static const char * const qt_minimize_xpm[] = {
+"12 12 2 1",
+" s None c None",
+". c black",
+" ",
+" ",
+" ",
+" ",
+" ......... ",
+" ....... ",
+" ..... ",
+" ... ",
+" . ",
+" ",
+" ",
+" "};
+
+#if 0 // ### not used???
+static const char * const qt_normalize_xpm[] = {
+"12 12 2 1",
+" s None c None",
+". c black",
+" ",
+" ",
+" . ",
+" .. ",
+" ... ",
+" .... ",
+" ..... ",
+" ...... ",
+" ....... ",
+" ",
+" ",
+" "};
+#endif
+
+static const char * const qt_normalizeup_xpm[] = {
+"12 12 2 1",
+" s None c None",
+". c black",
+" ",
+" ",
+" ",
+" ....... ",
+" ...... ",
+" ..... ",
+" .... ",
+" ... ",
+" .. ",
+" . ",
+" ",
+" "};
+
+static const char * const qt_shade_xpm[] = {
+"12 12 2 1", "# c #000000",
+". c None",
+"............",
+"............",
+".#########..",
+".#########..",
+"............",
+"............",
+"............",
+"............",
+"............",
+"............",
+"............",
+"............"};
+
+
+static const char * const qt_unshade_xpm[] = {
+"12 12 2 1",
+"# c #000000",
+". c None",
+"............",
+"............",
+".#########..",
+".#########..",
+".#.......#..",
+".#.......#..",
+".#.......#..",
+".#.......#..",
+".#.......#..",
+".#########..",
+"............",
+"............"};
+
+
+static const char * dock_window_close_xpm[] = {
+"8 8 2 1",
+"# c #000000",
+". c None",
+"##....##",
+".##..##.",
+"..####..",
+"...##...",
+"..####..",
+".##..##.",
+"##....##",
+"........"};
+
+// Message box icons, from page 210 of the Windows style guide.
+
+// Hand-drawn to resemble Microsoft's icons, but in the Mac/Netscape palette.
+// Thanks to TrueColor displays, it is slightly more efficient to have
+// them duplicated.
+/* XPM */
+static const char * const information_xpm[]={
+"32 32 5 1",
+". c None",
+"c c #000000",
+"* c #999999",
+"a c #ffffff",
+"b c #0000ff",
+"...........********.............",
+"........***aaaaaaaa***..........",
+"......**aaaaaaaaaaaaaa**........",
+".....*aaaaaaaaaaaaaaaaaa*.......",
+"....*aaaaaaaabbbbaaaaaaaac......",
+"...*aaaaaaaabbbbbbaaaaaaaac.....",
+"..*aaaaaaaaabbbbbbaaaaaaaaac....",
+".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
+".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
+"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
+"*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
+".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
+"..*aaaaaaaaaabbbbbaaaaaaaaac***.",
+"...caaaaaaabbbbbbbbbaaaaaac****.",
+"....caaaaaaaaaaaaaaaaaaaac****..",
+".....caaaaaaaaaaaaaaaaaac****...",
+"......ccaaaaaaaaaaaaaacc****....",
+".......*cccaaaaaaaaccc*****.....",
+"........***cccaaaac*******......",
+"..........****caaac*****........",
+".............*caaac**...........",
+"...............caac**...........",
+"................cac**...........",
+".................cc**...........",
+"..................***...........",
+"...................**..........."};
+/* XPM */
+static const char* const warning_xpm[]={
+"32 32 4 1",
+". c None",
+"a c #ffff00",
+"* c #000000",
+"b c #999999",
+".............***................",
+"............*aaa*...............",
+"...........*aaaaa*b.............",
+"...........*aaaaa*bb............",
+"..........*aaaaaaa*bb...........",
+"..........*aaaaaaa*bb...........",
+".........*aaaaaaaaa*bb..........",
+".........*aaaaaaaaa*bb..........",
+"........*aaaaaaaaaaa*bb.........",
+"........*aaaa***aaaa*bb.........",
+".......*aaaa*****aaaa*bb........",
+".......*aaaa*****aaaa*bb........",
+"......*aaaaa*****aaaaa*bb.......",
+"......*aaaaa*****aaaaa*bb.......",
+".....*aaaaaa*****aaaaaa*bb......",
+".....*aaaaaa*****aaaaaa*bb......",
+"....*aaaaaaaa***aaaaaaaa*bb.....",
+"....*aaaaaaaa***aaaaaaaa*bb.....",
+"...*aaaaaaaaa***aaaaaaaaa*bb....",
+"...*aaaaaaaaaa*aaaaaaaaaa*bb....",
+"..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
+"..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
+".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
+".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
+"*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
+"*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
+"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
+"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
+".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
+"..*************************bbbbb",
+"....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
+".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
+/* XPM */
+static const char* const critical_xpm[]={
+"32 32 4 1",
+". c None",
+"a c #999999",
+"* c #ff0000",
+"b c #ffffff",
+"...........********.............",
+".........************...........",
+".......****************.........",
+"......******************........",
+".....********************a......",
+"....**********************a.....",
+"...************************a....",
+"..*******b**********b*******a...",
+"..******bbb********bbb******a...",
+".******bbbbb******bbbbb******a..",
+".*******bbbbb****bbbbb*******a..",
+"*********bbbbb**bbbbb*********a.",
+"**********bbbbbbbbbb**********a.",
+"***********bbbbbbbb***********aa",
+"************bbbbbb************aa",
+"************bbbbbb************aa",
+"***********bbbbbbbb***********aa",
+"**********bbbbbbbbbb**********aa",
+"*********bbbbb**bbbbb*********aa",
+".*******bbbbb****bbbbb*******aa.",
+".******bbbbb******bbbbb******aa.",
+"..******bbb********bbb******aaa.",
+"..*******b**********b*******aa..",
+"...************************aaa..",
+"....**********************aaa...",
+"....a********************aaa....",
+".....a******************aaa.....",
+"......a****************aaa......",
+".......aa************aaaa.......",
+".........aa********aaaaa........",
+"...........aaaaaaaaaaa..........",
+".............aaaaaaa............"};
+/* XPM */
+static const char *const question_xpm[] = {
+"32 32 5 1",
+". c None",
+"c c #000000",
+"* c #999999",
+"a c #ffffff",
+"b c #0000ff",
+"...........********.............",
+"........***aaaaaaaa***..........",
+"......**aaaaaaaaaaaaaa**........",
+".....*aaaaaaaaaaaaaaaaaa*.......",
+"....*aaaaaaaaaaaaaaaaaaaac......",
+"...*aaaaaaaabbbbbbaaaaaaaac.....",
+"..*aaaaaaaabaaabbbbaaaaaaaac....",
+".*aaaaaaaabbaaaabbbbaaaaaaaac...",
+".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
+"*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
+"*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
+"*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
+"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
+"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
+"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
+".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
+".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
+"..*aaaaaaaaaabbbbaaaaaaaaaac***.",
+"...caaaaaaaaaabbaaaaaaaaaac****.",
+"....caaaaaaaaaaaaaaaaaaaac****..",
+".....caaaaaaaaaaaaaaaaaac****...",
+"......ccaaaaaaaaaaaaaacc****....",
+".......*cccaaaaaaaaccc*****.....",
+"........***cccaaaac*******......",
+"..........****caaac*****........",
+".............*caaac**...........",
+"...............caac**...........",
+"................cac**...........",
+".................cc**...........",
+"..................***...........",
+"...................**...........",
+};
+#endif
+
+/*!
+ \reimp
+ */
+TQPixmap TQMotifStyle::stylePixmap(StylePixmap sp,
+ const TQWidget *widget,
+ const TQStyleOption& opt) const
+{
+#ifndef QT_NO_IMAGEIO_XPM
+ switch (sp) {
+ case SP_TitleBarShadeButton:
+ return TQPixmap((const char **)qt_shade_xpm);
+ case SP_TitleBarUnshadeButton:
+ return TQPixmap((const char **)qt_unshade_xpm);
+ case SP_TitleBarNormalButton:
+ return TQPixmap((const char **)qt_normalizeup_xpm);
+ case SP_TitleBarMinButton:
+ return TQPixmap((const char **)qt_minimize_xpm);
+ case SP_TitleBarMaxButton:
+ return TQPixmap((const char **)qt_maximize_xpm);
+ case SP_TitleBarCloseButton:
+ return TQPixmap((const char **)qt_close_xpm);
+ case SP_DockWindowCloseButton:
+ return TQPixmap((const char **)dock_window_close_xpm );
+
+ case SP_MessageBoxInformation:
+ case SP_MessageBoxWarning:
+ case SP_MessageBoxCritical:
+ case SP_MessageBoxQuestion:
+ {
+ const char * const * xpm_data;
+ switch ( sp ) {
+ case SP_MessageBoxInformation:
+ xpm_data = information_xpm;
+ break;
+ case SP_MessageBoxWarning:
+ xpm_data = warning_xpm;
+ break;
+ case SP_MessageBoxCritical:
+ xpm_data = critical_xpm;
+ break;
+ case SP_MessageBoxQuestion:
+ xpm_data = question_xpm;
+ break;
+ default:
+ xpm_data = 0;
+ break;
+ }
+ TQPixmap pm;
+ if ( xpm_data ) {
+ TQImage image( (const char **) xpm_data);
+ // All that color looks ugly in Motif
+ TQColorGroup g = TQApplication::palette().active();
+ switch ( sp ) {
+ case SP_MessageBoxInformation:
+ case SP_MessageBoxQuestion:
+ image.setColor( 2, 0xff000000 | g.dark().rgb() );
+ image.setColor( 3, 0xff000000 | g.base().rgb() );
+ image.setColor( 4, 0xff000000 | g.text().rgb() );
+ break;
+ case SP_MessageBoxWarning:
+ image.setColor( 1, 0xff000000 | g.base().rgb() );
+ image.setColor( 2, 0xff000000 | g.text().rgb() );
+ image.setColor( 3, 0xff000000 | g.dark().rgb() );
+ break;
+ case SP_MessageBoxCritical:
+ image.setColor( 1, 0xff000000 | g.dark().rgb() );
+ image.setColor( 2, 0xff000000 | g.text().rgb() );
+ image.setColor( 3, 0xff000000 | g.base().rgb() );
+ break;
+ default:
+ break;
+ }
+ pm.convertFromImage(image);
+ }
+ return pm;
+ }
+
+ default:
+ break;
+ }
+#endif
+
+ return TQCommonStyle::stylePixmap(sp, widget, opt);
+}
+
+
+/*! \reimp */
+int TQMotifStyle::styleHint(StyleHint hint,
+ const TQWidget *widget,
+ const TQStyleOption &opt,
+ TQStyleHintReturn *returnData) const
+{
+ int ret;
+
+ switch (hint) {
+ case SH_GUIStyle:
+ ret = MotifStyle;
+ break;
+
+ case SH_ScrollBar_BackgroundMode:
+ ret = TQWidget::PaletteMid;
+ break;
+
+ case SH_ScrollBar_MiddleClickAbsolutePosition:
+ case SH_Slider_SloppyKeyEvents:
+ case SH_ProgressDialog_CenterCancelButton:
+ case SH_PopupMenu_SpaceActivatesItem:
+ case SH_ScrollView_FrameOnlyAroundContents:
+ ret = 1;
+ break;
+
+ case SH_PopupMenu_SubMenuPopupDelay:
+ ret = 96;
+ break;
+
+ case SH_ProgressDialog_TextLabelAlignment:
+ ret = AlignAuto | AlignVCenter;
+ break;
+
+ case SH_ItemView_ChangeHighlightOnFocus:
+ ret = 0;
+ break;
+
+ default:
+ ret = TQCommonStyle::styleHint(hint, widget, opt, returnData);
+ break;
+ }
+
+ return ret;
+}
+
+
+#endif
diff --git a/src/styles/qmotifstyle.h b/src/styles/qmotifstyle.h
new file mode 100644
index 000000000..93ef298dd
--- /dev/null
+++ b/src/styles/qmotifstyle.h
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Definition of Motif-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQMOTIFSTYLE_H
+#define TQMOTIFSTYLE_H
+
+#ifndef QT_H
+#include "qcommonstyle.h"
+#endif // QT_H
+
+#if !defined(QT_NO_STYLE_MOTIF) || defined(QT_PLUGIN)
+
+class TQPalette;
+
+#if defined(QT_PLUGIN)
+#define Q_EXPORT_STYLE_MOTIF
+#else
+#define Q_EXPORT_STYLE_MOTIF Q_EXPORT
+#endif
+
+
+class Q_EXPORT_STYLE_MOTIF TQMotifStyle : public TQCommonStyle
+{
+ Q_OBJECT
+public:
+ TQMotifStyle( bool useHighlightCols=FALSE );
+ virtual ~TQMotifStyle();
+
+ void setUseHighlightColors( bool );
+ bool useHighlightColors() const;
+
+ void polish( TQPalette& );
+ void polish( TQWidget* );
+ void polish( TQApplication* );
+
+ void polishPopupMenu( TQPopupMenu* );
+
+ // new style API
+ void drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawComplexControl( ComplexControl control,
+ TQPainter *p,
+ const TQWidget* widget,
+ const TQRect& r,
+ const TQColorGroup& cg,
+ SFlags how = Style_Default,
+#ifdef Q_QDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect querySubControlMetrics( ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int pixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const;
+
+ TQSize sizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect subRect( SubRect r, const TQWidget *widget ) const;
+
+ TQPixmap stylePixmap(StylePixmap, const TQWidget * = 0, const TQStyleOption& = TQStyleOption::Default) const;
+
+ int styleHint(StyleHint sh, const TQWidget *, const TQStyleOption & = TQStyleOption::Default,
+ TQStyleHintReturn* = 0) const;
+
+private:
+ bool highlightCols;
+
+ // Disabled copy constructor and operator=
+#if defined(Q_DISABLE_COPY)
+ TQMotifStyle( const TQMotifStyle & );
+ TQMotifStyle& operator=( const TQMotifStyle & );
+#endif
+};
+
+#endif // QT_NO_STYLE_MOTIF
+
+#endif // TQMOTIFSTYLE_H
diff --git a/src/styles/qplatinumstyle.cpp b/src/styles/qplatinumstyle.cpp
new file mode 100644
index 000000000..e2c45d121
--- /dev/null
+++ b/src/styles/qplatinumstyle.cpp
@@ -0,0 +1,1557 @@
+/****************************************************************************
+**
+** Implementation of Platinum-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qplatinumstyle.h"
+
+#if !defined(QT_NO_STYLE_PLATINUM) || defined(QT_PLUGIN)
+
+#include "qapplication.h"
+#include "qcombobox.h"
+#include "qdrawutil.h"
+#include "qpainter.h"
+#include "qpalette.h"
+#include "qpixmap.h"
+#include "qpushbutton.h"
+#include "qscrollbar.h"
+#include "qslider.h"
+#include <limits.h>
+
+/*!
+ \class TQPlatinumStyle qplatinumstyle.h
+ \brief The TQPlatinumStyle class provides Mac/Platinum look and feel.
+
+ \ingroup appearance
+
+ This class implements the Platinum look and feel. It's an
+ experimental class that tries to resemble a Macinosh-like GUI
+ style with the TQStyle system. The emulation is currently far from
+ perfect.
+
+ \sa TQAquaStyle
+*/
+
+
+/*!
+ Constructs a TQPlatinumStyle
+*/
+TQPlatinumStyle::TQPlatinumStyle()
+{
+}
+
+/*!\reimp
+*/
+TQPlatinumStyle::~TQPlatinumStyle()
+{
+}
+
+
+/*!\reimp
+ */
+void TQPlatinumStyle::drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch (pe) {
+ case PE_HeaderSection:
+ {
+ // adjust the sunken flag, otherwise headers are drawn
+ // sunken...
+ if ( flags & Style_Sunken )
+ flags ^= Style_Sunken;
+ drawPrimitive( PE_ButtonBevel, p, r, cg, flags, opt );
+ break;
+ }
+ case PE_ButtonTool:
+ {
+ // tool buttons don't change color when pushed in platinum,
+ // so we need to make the mid and button color the same
+ TQColorGroup myCG = cg;
+ TQBrush fill;
+
+ // tquick trick to make sure toolbuttons drawn sunken
+ // when they are activated...
+ if ( flags & Style_On )
+ flags |= Style_Sunken;
+
+ fill = myCG.brush( TQColorGroup::Button );
+ myCG.setBrush( TQColorGroup::Mid, fill );
+ drawPrimitive( PE_ButtonBevel, p, r, myCG, flags, opt );
+ break;
+ }
+ case PE_ButtonBevel:
+ {
+ int x,
+ y,
+ w,
+ h;
+ r.rect( &x, &y, &w, &h );
+
+ TQPen oldPen = p->pen();
+ if ( w * h < 1600 ||
+ TQABS(w - h) > 10 ) {
+ // small buttons
+
+ if ( !(flags & (Style_Sunken | Style_Down)) ) {
+ p->fillRect( x + 2, y + 2, w - 4, h - 4,
+ cg.brush(TQColorGroup::Button) );
+ // the bright side
+ p->setPen( cg.dark() );
+ // the bright side
+ p->setPen( cg.dark() );
+ p->drawLine( x, y, x + w - 1, y );
+ p->drawLine( x, y, x, y + h - 1 );
+
+ p->setPen( cg.light() );
+ p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
+ p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
+
+ // the dark side
+ p->setPen( cg.mid() );
+ p->drawLine( x + 2, y + h - 2, x + w - 2, y + h - 2 );
+ p->drawLine( x + w - 2, y + 2, x + w - 2, y + h - 3 );
+
+ p->setPen( cg.dark().dark() );
+ p->drawLine( x + 1, y + h - 1, x + w - 1,
+ y + h - 1 );
+ p->drawLine( x + w - 1, y + 1,
+ x + w - 1,
+ y + h - 2 );
+ } else {
+ p->fillRect(x + 2, y + 2,
+ w - 4, h - 4,
+ cg.brush( TQColorGroup::Mid ));
+
+ // the dark side
+ p->setPen( cg.dark().dark() );
+ p->drawLine( x, y, x + w - 1, y );
+ p->drawLine( x, y, x, y + h - 1 );
+
+ p->setPen( cg.mid().dark());
+ p->drawLine( x + 1, y + 1,
+ x + w-2, y + 1);
+ p->drawLine( x + 1, y + 1,
+ x + 1, y + h - 2 );
+
+
+ // the bright side!
+
+ p->setPen(cg.button());
+ p->drawLine( x + 1, y + h - 2,
+ x + w - 2,
+ y + h - 2 );
+ p->drawLine( x + w - 2, y + 1,
+ x + w - 2,
+ y + h - 2 );
+ p->setPen(cg.dark());
+ p->drawLine(x, y + h - 1,
+ x + w - 1,
+ y + h - 1 );
+ p->drawLine(x + w - 1, y,
+ x + w - 1,
+ y + h - 1 );
+ }
+ } else {
+ // big ones
+ if ( !(flags & (Style_Sunken | Style_Down)) ) {
+ p->fillRect( x + 3, y + 3, w - 6,
+ h - 6,
+ cg.brush(TQColorGroup::Button) );
+
+ // the bright side
+ p->setPen( cg.button().dark() );
+ p->drawLine( x, y, x + w - 1, y );
+ p->drawLine( x, y, x, y + h - 1 );
+
+ p->setPen( cg.button() );
+ p->drawLine( x + 1, y + 1,
+ x + w - 2, y + 1 );
+ p->drawLine( x + 1, y + 1,
+ x + 1, y + h - 2 );
+
+ p->setPen( cg.light() );
+ p->drawLine( x + 2, y + 2,
+ x + 2, y + h - 2 );
+ p->drawLine( x + 2, y + 2,
+ x + w - 2, y + 2 );
+ // the dark side!
+
+ p->setPen( cg.mid() );
+ p->drawLine( x + 3, y + h - 3,
+ x + w - 3,
+ y + h - 3 );
+ p->drawLine( x + w - 3, y + 3,
+ x + w - 3,
+ y + h - 3 );
+ p->setPen( cg.dark() );
+ p->drawLine( x + 2, y + h - 2,
+ x + w - 2,
+ y + h - 2 );
+ p->drawLine( x + w - 2, y + 2,
+ x + w - 2,
+ y + h - 2 );
+
+ p->setPen( cg.dark().dark() );
+ p->drawLine( x + 1, y + h - 1,
+ x + w - 1,
+ y + h - 1 );
+ p->drawLine( x + w - 1, y + 1,
+ x + w - 1,
+ y + h - 1 );
+ } else {
+ p->fillRect( x + 3, y + 3, w - 6,
+ h - 6,
+ cg.brush( TQColorGroup::Mid ) );
+
+ // the dark side
+ p->setPen( cg.dark().dark().dark() );
+ p->drawLine( x, y, x + w - 1, y );
+ p->drawLine( x, y, x, y + h - 1 );
+
+ p->setPen( cg.dark().dark() );
+ p->drawLine( x + 1, y + 1,
+ x + w - 2, y + 1 );
+ p->drawLine( x + 1, y + 1,
+ x + 1, y + h - 2 );
+
+ p->setPen( cg.mid().dark() );
+ p->drawLine( x + 2, y + 2,
+ x + 2, y + w - 2 );
+ p->drawLine( x + 2, y + 2,
+ x + w - 2, y + 2 );
+
+
+ // the bright side!
+
+ p->setPen( cg.button() );
+ p->drawLine( x + 2, y + h - 3,
+ x + w - 3,
+ y + h - 3 );
+ p->drawLine( x + w - 3, y + 3,
+ x + w - 3,
+ y + h - 3 );
+
+ p->setPen( cg.midlight() );
+ p->drawLine( x + 1, y + h - 2,
+ x + w - 2,
+ y + h - 2 );
+ p->drawLine( x + w - 2, y + 1,
+ x + w - 2,
+ y + h - 2 );
+
+ p->setPen( cg.dark() );
+ p->drawLine( x, y + h - 1,
+ x + w - 1,
+ y + h - 1 );
+ p->drawLine( x + w - 1, y,
+ x + w - 1,
+ y + h - 1 );
+
+
+ // corners
+ p->setPen( mixedColor(cg.dark().dark().dark(),
+ cg.dark()) );
+ p->drawPoint( x, y + h - 1 );
+ p->drawPoint( x + w - 1, y );
+
+ p->setPen( mixedColor(cg.dark().dark(), cg.midlight()) );
+ p->drawPoint( x + 1, y + h - 2 );
+ p->drawPoint( x + w - 2, y + 1 );
+
+ p->setPen( mixedColor(cg.mid().dark(), cg.button() ) );
+ p->drawPoint( x + 2, y + h - 3 );
+ p->drawPoint( x + w - 3, y + 2 );
+ }
+ }
+ p->setPen( oldPen );
+ break;
+ }
+ case PE_ButtonCommand:
+ {
+ TQPen oldPen = p->pen();
+ int x,
+ y,
+ w,
+ h;
+ r.rect( &x, &y, &w, &h);
+
+ if ( !(flags & (Style_Down | Style_On)) ) {
+ p->fillRect( x+3, y+3, w-6, h-6,
+ cg.brush( TQColorGroup::Button ));
+ // the bright side
+ p->setPen( cg.shadow() );
+ p->drawLine( x, y, x+w-1, y );
+ p->drawLine( x, y, x, y + h - 1 );
+
+ p->setPen( cg.button() );
+ p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
+ p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
+
+ p->setPen( cg.light() );
+ p->drawLine( x + 2, y + 2, x + 2, y + h - 2 );
+ p->drawLine( x + 2, y + 2, x + w - 2, y + 2 );
+
+
+ // the dark side!
+
+ p->setPen( cg.mid() );
+ p->drawLine( x + 3, y + h - 3 ,x + w - 3, y + h - 3 );
+ p->drawLine( x + w - 3, y + 3, x + w - 3, y + h - 3 );
+
+ p->setPen( cg.dark() );
+ p->drawLine( x + 2, y + h - 2, x + w - 2, y + h - 2 );
+ p->drawLine( x + w - 2, y + 2, x + w - 2, y + h - 2 );
+
+ p->setPen( cg.shadow() );
+ p->drawLine( x + 1, y + h - 1, x + w - 1, y + h - 1 );
+ p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 );
+
+
+ // top left corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x, y );
+ p->drawPoint( x + 1, y );
+ p->drawPoint( x, y+1 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + 1, y + 1 );
+ p->setPen( cg.button() );
+ p->drawPoint( x + 2, y + 2 );
+ p->setPen( white );
+ p->drawPoint( x + 3, y + 3 );
+ // bottom left corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x, y + h - 1 );
+ p->drawPoint( x + 1, y + h - 1 );
+ p->drawPoint( x, y + h - 2 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + 1, y + h - 2 );
+ p->setPen( cg.dark() );
+ p->drawPoint( x + 2, y + h - 3 );
+ // top right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x + w -1, y );
+ p->drawPoint( x + w - 2, y );
+ p->drawPoint( x + w - 1, y + 1 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + w - 2, y + 1 );
+ p->setPen( cg.dark() );
+ p->drawPoint( x + w - 3, y + 2 );
+ // bottom right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x + w - 1, y + h - 1 );
+ p->drawPoint( x + w - 2, y + h - 1 );
+ p->drawPoint( x + w - 1, y + h - 2 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + w - 2, y + h - 2 );
+ p->setPen( cg.dark() );
+ p->drawPoint( x + w - 3, y + h - 3 );
+ p->setPen( cg.mid() );
+ p->drawPoint( x + w - 4, y + h - 4 );
+
+ } else {
+ p->fillRect( x + 2, y + 2, w - 4, h - 4,
+ cg.brush(TQColorGroup::Dark) );
+
+ // the dark side
+ p->setPen( cg.shadow() );
+ p->drawLine( x, y, x + w - 1, y );
+ p->drawLine( x, y, x, y + h - 1 );
+
+ p->setPen( cg.dark().dark() );
+ p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
+ p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
+
+ // the bright side!
+
+ p->setPen( cg.button() );
+ p->drawLine( x + 1, y + h - 2, x + w - 2, y + h - 2 );
+ p->drawLine( x + w - 2, y + 1, x + w - 2, y + h - 2 );
+
+ p->setPen( cg.dark() );
+ p->drawLine( x, y + h - 1, x + w - 1, y + h - 1 );
+ p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 );
+
+ // top left corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x, y );
+ p->drawPoint( x + 1, y );
+ p->drawPoint( x, y + 1 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + 1, y + 1 );
+ p->setPen( cg.dark().dark() );
+ p->drawPoint( x + 3, y + 3 );
+ // bottom left corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x, y + h - 1 );
+ p->drawPoint( x + 1, y + h - 1 );
+ p->drawPoint( x, y + h - 2 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + 1, y + h - 2 );
+ // top right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x + w - 1, y );
+ p->drawPoint( x + w - 2, y );
+ p->drawPoint( x + w - 1, y + 1 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + w - 2, y + 1 );
+ // bottom right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x + w - 1, y + h - 1 );
+ p->drawPoint( x + w - 2, y + h - 1 );
+ p->drawPoint( x + w - 1, y + h - 2 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + w - 2, y + h - 2 );
+ p->setPen( cg.dark() );
+ p->drawPoint( x + w - 3, y + h - 3 );
+ p->setPen( cg.mid() );
+ p->drawPoint( x + w - 4, y + h - 4 );
+ }
+ p->setPen( oldPen );
+ break;
+ }
+ case PE_Indicator:
+ {
+ drawPrimitive( PE_ButtonBevel, p, TQRect(r.x(), r.y(),
+ r.width() - 2, r.height()),
+ cg, flags );
+ p->fillRect( r.x() + r.width() - 2, r.y(), 2, r.height(),
+ cg.brush( TQColorGroup::Background ) );
+ p->setPen( cg.shadow() );
+ p->drawRect( r.x(), r.y(), r.width() - 2, r.height() );
+
+ static const TQCOORD nochange_mark[] = { 3,5, 9,5, 3,6, 9,6 };
+ static const TQCOORD check_mark[] = {
+ 3,5, 5,5, 4,6, 5,6, 5,7, 6,7, 5,8, 6,8, 6,9, 9,9,
+ 6,10, 8,10, 7,11, 8,11, 7,12, 7,12, 8,8, 9,8, 8,7, 10,7,
+ 9,6, 10,6, 9,5, 11,5, 10,4, 11,4, 10,3, 12,3,
+ 11,2, 12,2, 11,1, 13,1, 12,0, 13,0 };
+ if ( !(flags & Style_Off) ) {
+ TQPen oldPen = p->pen();
+ int x1 = r.x();
+ int y1 = r.y();
+ if ( flags & Style_Down ) {
+ x1++;
+ y1++;
+ }
+ TQPointArray amark;
+ if ( flags & Style_On ) {
+ amark = TQPointArray( sizeof(check_mark)/(sizeof(TQCOORD)*2),
+ check_mark );
+ // ### KLUDGE!!
+ flags ^= Style_On;
+ flags ^= Style_Down;
+ } else if ( flags & Style_NoChange ) {
+ amark = TQPointArray( sizeof(nochange_mark)
+ / (sizeof(TQCOORD) * 2),
+ nochange_mark );
+ }
+
+ amark.translate( x1 + 1, y1 + 1 );
+ p->setPen( cg.dark() );
+ p->drawLineSegments( amark );
+ amark.translate( -1, -1 );
+ p->setPen( cg.foreground() );
+ p->drawLineSegments( amark );
+ p->setPen( oldPen );
+ }
+ break;
+ }
+ case PE_IndicatorMask:
+ {
+ int x,
+ y,
+ w,
+ h;
+ r.rect( &x, &y, &w, &h );
+ p->fillRect( x, y, w - 2, h, color1);
+ if ( flags & Style_Off ) {
+ TQPen oldPen = p->pen();
+ p->setPen ( TQPen(color1, 2));
+ p->drawLine( x + 2, y + h / 2 - 1,
+ x + w / 2 - 1, y + h - 4 );
+ p->drawLine( x + w / 2 - 1, y + h - 4,
+ x + w, 0);
+ p->setPen( oldPen );
+ }
+ break;
+ }
+ case PE_ExclusiveIndicator:
+ {
+#define TQCOORDARRLEN(x) sizeof(x) / (sizeof(TQCOORD) * 2 )
+ bool down = flags & Style_Down;
+ bool on = flags & Style_On;
+
+ static const TQCOORD pts1[] = { // normal circle
+ 5,0, 8,0, 9,1, 10,1, 11,2, 12,3, 12,4, 13,5,
+ 13,8, 12,9, 12,10, 11,11, 10,12, 9,12, 8,13,
+ 5,13, 4,12, 3,12, 2,11, 1,10, 1,9, 0,8, 0,5,
+ 1,4, 1,3, 2,2, 3,1, 4,1 };
+ static const TQCOORD pts2[] = { // top left shadow
+ 5,1, 8,1, 3,2, 7,2, 2,3, 5,3, 2,4, 4,4,
+ 1,5, 3,5, 1,6, 1,8, 2,6, 2,7 };
+ static const TQCOORD pts3[] = { // bottom right, dark
+ 5,12, 8,12, 7,11, 10,11, 8,10, 11,10,
+ 9,9, 11,9, 10,8, 12,8, 11,7, 11,7,
+ 12,5, 12,7 };
+ static const TQCOORD pts4[] = { // bottom right, light
+ 5,12, 8,12, 7,11, 10,11, 9,10, 11,10,
+ 10,9, 11,9, 11,7, 11,8, 12,5, 12,8 };
+ static const TQCOORD pts5[] = { // check mark
+ 6,4, 8,4, 10,6, 10,8, 8,10, 6,10, 4,8, 4,6 };
+ static const TQCOORD pts6[] = { // check mark extras
+ 4,5, 5,4, 9,4, 10,5, 10,9, 9,10, 5,10, 4,9 };
+ int x, y;
+ x = r.x();
+ y = r.y();
+ p->eraseRect( r );
+ p->setBrush( (down||on) ? cg.brush( TQColorGroup::Dark )
+ : cg.brush( TQColorGroup::Button) );
+ p->setPen( NoPen );
+ p->drawEllipse( x, y, 13, 13 );
+ p->setPen( cg.shadow() );
+ TQPointArray a( TQCOORDARRLEN(pts1), pts1 );
+ a.translate( x, y );
+ p->drawPolyline( a ); // draw normal circle
+ TQColor tc, bc;
+ const TQCOORD *bp;
+ int bl;
+ if ( down || on ) { // pressed down or on
+ tc = cg.dark().dark();
+ bc = cg.light();
+ bp = pts4;
+ bl = TQCOORDARRLEN(pts4);
+ } else { // released
+ tc = cg.light();
+ bc = cg.dark();
+ bp = pts3;
+ bl = TQCOORDARRLEN(pts3);
+ }
+ p->setPen( tc );
+ a.setPoints( TQCOORDARRLEN(pts2), pts2 );
+ a.translate( x, y );
+ p->drawLineSegments( a ); // draw top shadow
+ p->setPen( bc );
+ a.setPoints( bl, bp );
+ a.translate( x, y );
+ p->drawLineSegments( a );
+ if ( on ) { // draw check mark
+ int x1 = x,
+ y1 = y;
+ p->setBrush( cg.foreground() );
+ p->setPen( cg.foreground() );
+ a.setPoints( TQCOORDARRLEN(pts5), pts5 );
+ a.translate( x1, y1 );
+ p->drawPolygon( a );
+ p->setBrush( NoBrush );
+ p->setPen( cg.dark() );
+ a.setPoints( TQCOORDARRLEN(pts6), pts6 );
+ a.translate( x1, y1 );
+ p->drawLineSegments( a );
+ }
+ break;
+ }
+
+ case PE_ExclusiveIndicatorMask:
+ {
+ static const TQCOORD pts1[] = { // normal circle
+ 5,0, 8,0, 9,1, 10,1, 11,2, 12,3, 12,4, 13,5,
+ 13,8, 12,9, 12,10, 11,11, 10,12, 9,12, 8,13,
+ 5,13, 4,12, 3,12, 2,11, 1,10, 1,9, 0,8, 0,5,
+ 1,4, 1,3, 2,2, 3,1, 4,1 };
+ TQPointArray a(TQCOORDARRLEN(pts1), pts1);
+ a.translate(r.x(), r.y());
+ p->setPen(color1);
+ p->setBrush(color1);
+ p->drawPolygon(a);
+ break;
+ }
+ case PE_ScrollBarAddLine:
+ {
+ drawPrimitive( PE_ButtonBevel, p, r, cg,
+ (flags & Style_Enabled) | ((flags & Style_Down)
+ ? Style_Sunken
+ : Style_Raised) );
+ p->setPen( cg.shadow() );
+ p->drawRect( r );
+ drawPrimitive( ((flags & Style_Horizontal) ? PE_ArrowRight
+ : PE_ArrowDown), p, TQRect(r.x() + 2,
+ r.y() + 2,
+ r.width() - 4,
+ r.height() - 4),
+ cg, flags );
+ break;
+ }
+ case PE_ScrollBarSubLine:
+ {
+ drawPrimitive( PE_ButtonBevel, p, r, cg,
+ (flags & Style_Enabled) | ((flags & Style_Down)
+ ? Style_Sunken
+ : Style_Raised) );
+ p->setPen( cg.shadow() );
+ p->drawRect( r );
+ drawPrimitive( ((flags & Style_Horizontal) ? PE_ArrowLeft
+ : PE_ArrowUp ), p, TQRect(r.x() + 2,
+ r.y() + 2,
+ r.width() - 4,
+ r.height() - 4),
+ cg, flags );
+ break;
+ }
+ case PE_ScrollBarAddPage:
+ case PE_ScrollBarSubPage:
+ {
+ TQPen oldPen = p->pen();
+ if ( r.width() < 3 || r.height() < 3 ) {
+ p->fillRect( r, cg.brush(TQColorGroup::Mid) );
+ p->setPen( cg.shadow() );
+ p->drawRect( r );
+ p->setPen( oldPen );
+ } else {
+ int x,
+ y,
+ w,
+ h;
+ r.rect( &x, &y, &w, &h );
+ if ( flags & Style_Horizontal ) {
+ p->fillRect( x + 2, y + 2, w - 2,
+ h - 4,
+ cg.brush(TQColorGroup::Mid) );
+ // the dark side
+ p->setPen( cg.dark().dark() );
+ p->drawLine( x, y, x + w - 1, y );
+ p->setPen( cg.shadow());
+ p->drawLine( x, y, x, y + h - 1 );
+
+ p->setPen( cg.mid().dark());
+ p->drawLine( x + 1, y + 1, x + w - 1,
+ y + 1 );
+ p->drawLine( x + 1, y + 1, x + 1,
+ y + h - 2 );
+
+ // the bright side!
+
+ p->setPen( cg.button());
+ p->drawLine( x + 1, y + h - 2,
+ x + w - 1,
+ y + h - 2 );
+ p->setPen( cg.shadow());
+ p->drawLine( x, y + h - 1,
+ x + w - 1,
+ y + h - 1 );
+
+ } else {
+ p->fillRect( x + 2, y + 2, w - 4,
+ h - 2,
+ cg.brush(TQColorGroup::Mid) );
+
+ // the dark side
+ p->setPen( cg.dark().dark() );
+ p->drawLine( x, y, x + w - 1, y );
+ p->setPen( cg.shadow() );
+ p->drawLine( x, y, x, y + h - 1 );
+
+ p->setPen( cg.mid().dark() );
+ p->drawLine( x + 1, y + 1, x + w - 2,
+ y + 1 );
+ p->drawLine( x + 1, y + 1, x + 1,
+ y + h - 1 );
+
+ // the bright side!
+ p->setPen( cg.button() );
+ p->drawLine( x + w - 2, y + 1,
+ x + w - 2,
+ y + h - 1 );
+
+ p->setPen( cg.shadow() );
+ p->drawLine( x + w - 1, y,
+ x + w - 1,
+ y + h - 1 );
+
+ }
+ }
+ p->setPen( oldPen );
+ break;
+ }
+ case PE_ScrollBarSlider:
+ {
+ TQPoint bo = p->brushOrigin();
+ p->setBrushOrigin( r.topLeft() );
+ drawPrimitive( PE_ButtonBevel, p, r, cg, Style_Raised );
+ p->setBrushOrigin( bo );
+ drawRiffles( p, r.x(), r.y(), r.width(), r.height(), cg,
+ flags & Style_Horizontal );
+ p->setPen( cg.shadow() );
+ p->drawRect( r );
+ if ( flags & Style_HasFocus ) {
+ drawPrimitive( PE_FocusRect, p, TQRect(r.x() + 2, r.y() + 2,
+ r.width() - 5,
+ r.height() - 5 ),
+ cg, flags );
+ }
+ break;
+ }
+ default:
+ TQWindowsStyle::drawPrimitive( pe, p, r, cg, flags, opt );
+ break;
+ }
+
+}
+
+/*!\reimp
+ */
+void TQPlatinumStyle::drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how,
+ const TQStyleOption& opt ) const
+{
+ switch( element ) {
+ case CE_PushButton:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ TQColorGroup myCg( cg );
+ const TQPushButton *btn;
+ int x1, y1, x2, y2;
+ bool useBevelButton;
+ SFlags flags;
+ flags = Style_Default;
+ btn = (const TQPushButton*)widget;
+ p->setBrushOrigin( -widget->backgroundOffset().x(),
+ -widget->backgroundOffset().y() );
+
+ // take care of the flags based on what we know...
+ if ( btn->isDown() )
+ flags |= Style_Down;
+ if ( btn->isOn() )
+ flags |= Style_On;
+ if ( btn->isEnabled() )
+ flags |= Style_Enabled;
+ if ( btn->isDefault() )
+ flags |= Style_Default;
+ if (! btn->isFlat() && !(flags & Style_Down))
+ flags |= Style_Raised;
+
+ r.coords( &x1, &y1, &x2, &y2 );
+
+ p->setPen( cg.foreground() );
+ p->setBrush( TQBrush(cg.button(), NoBrush) );
+
+ TQBrush fill;
+ if ( btn->isDown() ) {
+ fill = cg.brush( TQColorGroup::Dark );
+ // this could be done differently, but this
+ // makes a down Bezel drawn correctly...
+ myCg.setBrush( TQColorGroup::Mid, fill );
+ } else if ( btn->isOn() ) {
+ fill = TQBrush( cg.mid(), Dense4Pattern );
+ myCg.setBrush( TQColorGroup::Mid, fill );
+ }
+ // to quote the old TQPlatinumStlye drawPushButton...
+ // small or square image buttons as well as toggle buttons are
+ // bevel buttons (what a heuristic....)
+ if ( btn->isToggleButton()
+ || ( btn->pixmap() &&
+ (btn->width() * btn->height() < 1600 ||
+ TQABS( btn->width() - btn->height()) < 10 )) )
+ useBevelButton = TRUE;
+ else
+ useBevelButton = FALSE;
+
+ int diw = pixelMetric( PM_ButtonDefaultIndicator, widget );
+ if ( btn->isDefault() ) {
+ x1 += 1;
+ y1 += 1;
+ x2 -= 1;
+ y2 -= 1;
+ TQColorGroup cg2( myCg );
+ SFlags myFlags = flags;
+ // don't draw the default button sunken, unless it's necessary.
+ if ( myFlags & Style_Down )
+ myFlags ^= Style_Down;
+ if ( myFlags & Style_Sunken )
+ myFlags ^= Style_Sunken;
+
+ cg2.setColor( TQColorGroup::Button, cg.mid() );
+ if ( useBevelButton ) {
+ drawPrimitive( PE_ButtonBevel, p, TQRect( x1, y1,
+ x2 - x1 + 1,
+ y2 - y1 + 1 ),
+ myCg, myFlags, opt );
+ } else {
+ drawPrimitive( PE_ButtonCommand, p, TQRect( x1, y1,
+ x2 - x1 + 1,
+ y2 - y1 + 1 ),
+ cg2, myFlags, opt );
+ }
+ }
+
+ if ( btn->isDefault() || btn->autoDefault() ) {
+ x1 += diw;
+ y1 += diw;
+ x2 -= diw;
+ y2 -= diw;
+ }
+
+ if ( !btn->isFlat() || btn->isOn() || btn->isDown() ) {
+ if ( useBevelButton ) {
+ // fix for toggle buttons...
+ if ( flags & (Style_Down | Style_On) )
+ flags |= Style_Sunken;
+ drawPrimitive( PE_ButtonBevel, p, TQRect( x1, y1,
+ x2 - x1 + 1,
+ y2 - y1 + 1 ),
+ myCg, flags, opt );
+ } else {
+
+ drawPrimitive( PE_ButtonCommand, p, TQRect( x1, y1,
+ x2 - x1 + 1,
+ y2 - y1 + 1 ),
+ myCg, flags, opt );
+ }
+ }
+
+
+ if ( p->brush().style() != NoBrush )
+ p->setBrush( NoBrush );
+ break;
+#endif
+ }
+ case CE_PushButtonLabel:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *btn;
+ bool on;
+ int x, y, w, h;
+ SFlags flags;
+ flags = Style_Default;
+ btn = (const TQPushButton*)widget;
+ on = btn->isDown() || btn->isOn();
+ r.rect( &x, &y, &w, &h );
+ if ( btn->isMenuButton() ) {
+ int dx = pixelMetric( PM_MenuButtonIndicator, widget );
+
+ TQColorGroup g = cg;
+ int xx = x + w - dx - 4;
+ int yy = y - 3;
+ int hh = h + 6;
+
+ if ( !on ) {
+ p->setPen( g.mid() );
+ p->drawLine( xx, yy + 2, xx, yy + hh - 3 );
+ p->setPen( g.button() );
+ p->drawLine( xx + 1, yy + 1, xx + 1, yy + hh - 2 );
+ p->setPen( g.light() );
+ p->drawLine( xx + 2, yy + 2, xx + 2, yy + hh - 2 );
+ }
+ if ( btn->isEnabled() )
+ flags |= Style_Enabled;
+ drawPrimitive( PE_ArrowDown, p, TQRect(x + w - dx - 1, y + 2,
+ dx, h - 4),
+ g, flags, opt );
+ w -= dx;
+ }
+#ifndef QT_NO_ICONSET
+ if ( btn->iconSet() && !btn->iconSet()->isNull() ) {
+ TQIconSet::Mode mode = btn->isEnabled()
+ ? TQIconSet::Normal : TQIconSet::Disabled;
+ if ( mode == TQIconSet::Normal && btn->hasFocus() )
+ mode = TQIconSet::Active;
+ TQIconSet::State state = TQIconSet::Off;
+ if ( btn->isToggleButton() && btn->isOn() )
+ state = TQIconSet::On;
+ TQPixmap pixmap = btn->iconSet()->pixmap( TQIconSet::Small,
+ mode, state );
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ p->drawPixmap( x + 2, y + h / 2 - pixh / 2, pixmap );
+ x += pixw + 4;
+ w -= pixw + 4;
+ }
+#endif
+ drawItem( p, TQRect( x, y, w, h ),
+ AlignCenter | ShowPrefix,
+ btn->colorGroup(), btn->isEnabled(),
+ btn->pixmap(), btn->text(), -1,
+ on ? &btn->colorGroup().brightText()
+ : &btn->colorGroup().buttonText() );
+ if ( btn->hasFocus() )
+ drawPrimitive( PE_FocusRect, p,
+ subRect(SR_PushButtonFocusRect, widget),
+ cg, flags );
+ break;
+#endif
+ }
+ default:
+ TQWindowsStyle::drawControl( element, p, widget, r, cg, how, opt );
+ break;
+ }
+}
+
+/*!\reimp
+ */
+void TQPlatinumStyle::drawComplexControl( ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how,
+ SCFlags sub,
+ SCFlags subActive,
+ const TQStyleOption& opt ) const
+{
+ switch ( control ) {
+ case CC_ComboBox:
+ {
+ int x,
+ y,
+ w,
+ h;
+ r.rect( &x, &y, &w, &h );
+ p->fillRect( x + 2, y + 2, w - 4,
+ h - 4, cg.brush(TQColorGroup::Button) );
+ // the bright side
+ p->setPen(cg.shadow());
+ p->drawLine( x, y, x + w - 1, y );
+ p->drawLine( x, y, x, y + h - 1 );
+
+ p->setPen( cg.light() );
+ p->drawLine( x + 1, y + 1,
+ x + w - 2, y + 1 );
+ p->drawLine( x + 1, y + 1,
+ x + 1, y + h - 2 );
+
+ // the dark side!
+
+
+ p->setPen( cg.mid() );
+ p->drawLine( x + 2, y + h - 2,
+ x + w - 2, y + h - 2 );
+ p->drawLine( x + w - 2, y + 2,
+ x + w - 2, y + h - 2 );
+
+ p->setPen (cg.shadow() );
+ p->drawLine( x + 1, y + h - 1,
+ x + w - 1, y + h - 1 );
+ p->drawLine( x + w - 1, y,
+ x + w - 1, y + h - 1 );
+
+ // top left corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x, y );
+ p->drawPoint( x + 1, y );
+ p->drawPoint( x, y + 1 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + 1, y + 1 );
+ p->setPen( white );
+ p->drawPoint( x + 3, y + 3 );
+ // bottom left corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x, y + h - 1 );
+ p->drawPoint( x + 1, y + h - 1 );
+ p->drawPoint( x, y + h - 2 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + 1, y + h - 2 );
+ // top right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x + w - 1, y );
+ p->drawPoint( x + w - 2, y );
+ p->drawPoint( x + w - 1, y + 1 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + w - 2, y + 1 );
+ // bottom right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x + w - 1, y + h - 1 );
+ p->drawPoint( x + w - 2, y + h - 1 );
+ p->drawPoint( x + w - 1, y + h - 2 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x + w - 2, y + h - 2 );
+ p->setPen( cg.dark() );
+ p->drawPoint( x + w - 3, y + h - 3 );
+
+ if ( sub & SC_ComboBoxArrow ) {
+ TQRect rTmp = querySubControlMetrics( CC_ComboBox, widget,
+ SC_ComboBoxArrow, opt );
+ int xx = rTmp.x(),
+ yy = rTmp.y(),
+ ww = rTmp.width(),
+ hh = rTmp.height();
+ // the bright side
+
+ p->setPen( cg.mid() );
+ p->drawLine( xx, yy+2, xx, yy+hh-3 );
+
+ p->setPen( cg.button() );
+ p->drawLine( xx+1, yy+1, xx+ww-2, yy+1 );
+ p->drawLine( xx+1, yy+1, xx+1, yy+hh-2 );
+
+ p->setPen( cg.light() );
+ p->drawLine( xx+2, yy+2, xx+2, yy+hh-2 );
+ p->drawLine( xx+2, yy+2, xx+ww-2, yy+2 );
+
+
+ // the dark side!
+
+ p->setPen( cg.mid() );
+ p->drawLine( xx+3, yy+hh-3 ,xx+ww-3, yy+hh-3 );
+ p->drawLine( xx+ww-3, yy+3, xx+ww-3, yy+hh-3 );
+
+ p->setPen( cg.dark() );
+ p->drawLine( xx+2, yy+hh-2 ,xx+ww-2, yy+hh-2 );
+ p->drawLine( xx+ww-2, yy+2, xx+ww-2, yy+hh-2 );
+
+ p->setPen( cg.shadow() );
+ p->drawLine( xx+1, yy+hh-1,xx+ww-1, yy+hh-1 );
+ p->drawLine( xx+ww-1, yy, xx+ww-1, yy+hh-1 );
+
+ // top right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( xx + ww - 1, yy );
+ p->drawPoint( xx + ww - 2, yy );
+ p->drawPoint( xx + ww - 1, yy + 1 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( xx + ww - 2, yy + 1 );
+ // bottom right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( xx + ww - 1, yy + hh - 1 );
+ p->drawPoint( xx + ww - 2, yy + hh - 1 );
+ p->drawPoint( xx + ww - 1, yy + hh - 2 );
+ p->setPen( cg.shadow() );
+ p->drawPoint( xx + ww - 2, yy + hh - 2 );
+ p->setPen( cg.dark() );
+ p->drawPoint( xx + ww - 3, yy + hh - 3 );
+ p->setPen( cg.mid() );
+ p->drawPoint( xx + ww - 4, yy + hh - 4 );
+
+ // and the arrows
+ p->setPen( cg.foreground() );
+ TQPointArray a ;
+ a.setPoints( 7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2 );
+ a.translate( xx + ww / 2, yy + hh / 2 - 3 );
+ p->drawLineSegments( a, 0, 3 ); // draw arrow
+ p->drawPoint( a[6] );
+ a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 );
+ a.translate( xx + ww / 2, yy + hh / 2 + 2 );
+ p->drawLineSegments( a, 0, 3 ); // draw arrow
+ p->drawPoint( a[6] );
+
+ }
+#ifndef QT_NO_COMBOBOX
+ if ( sub & SC_ComboBoxEditField ) {
+ const TQComboBox *cmb;
+ cmb = (const TQComboBox*)widget;
+ // sadly this is pretty much the windows code, except
+ // for the first fillRect call...
+ TQRect re =
+ TQStyle::visualRect( querySubControlMetrics( CC_ComboBox,
+ widget,
+ SC_ComboBoxEditField ),
+ widget );
+ if ( cmb->hasFocus() && !cmb->editable() )
+ p->fillRect( re.x() + 1, re.y() + 1,
+ re.width() - 2, re.height() - 2,
+ cg.brush( TQColorGroup::Highlight ) );
+
+ if ( cmb->hasFocus() ) {
+ p->setPen( cg.highlightedText() );
+ p->setBackgroundColor( cg.highlight() );
+ } else {
+ p->setPen( cg.text() );
+ p->setBackgroundColor( cg.background() );
+ }
+
+ if ( cmb->hasFocus() && !cmb->editable() ) {
+ TQRect re =
+ TQStyle::visualRect( subRect( SR_ComboBoxFocusRect,
+ cmb ),
+ widget );
+ drawPrimitive( PE_FocusRect, p, re, cg,
+ Style_FocusAtBorder,
+ TQStyleOption(cg.highlight()));
+ }
+ if ( cmb->editable() ) {
+ // need this for the moment...
+ // was the code in comboButton rect
+ TQRect ir( x + 3, y + 3,
+ w - 6 - 16, h - 6 );
+ if ( TQApplication::reverseLayout() )
+ ir.moveBy( 16, 0 );
+ // end comboButtonRect...
+ ir.setRect( ir.left() - 1, ir.top() - 1, ir.width() + 2,
+ ir.height() + 2 );
+ qDrawShadePanel( p, ir, cg, TRUE, 2, 0 );
+ }
+ }
+#endif
+ break;
+ }
+ case CC_Slider:
+ {
+#ifndef QT_NO_SLIDER
+ const TQSlider *slider = (const TQSlider *) widget;
+ int thickness = pixelMetric( PM_SliderControlThickness, widget );
+ int len = pixelMetric( PM_SliderLength, widget );
+ int ticks = slider->tickmarks();
+
+ TQRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
+ opt),
+ handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
+ opt);
+
+ if ((sub & SC_SliderGroove) && groove.isValid()) {
+ p->fillRect( groove, cg.brush(TQColorGroup::Background) );
+
+ int x, y, w, h;
+ int mid = thickness / 2;
+
+ if ( ticks & TQSlider::Above )
+ mid += len / 8;
+ if ( ticks & TQSlider::Below )
+ mid -= len / 8;
+
+ if ( slider->orientation() == Horizontal ) {
+ x = 0;
+ y = groove.y() + mid - 3;
+ w = slider->width();
+ h = 7;
+ } else {
+ x = groove.x() + mid - 3;
+ y = 0;
+ w = 7;
+ h = slider->height();
+ }
+
+ p->fillRect( x, y, w, h, cg.brush( TQColorGroup::Dark ));
+ // the dark side
+ p->setPen( cg.dark() );
+ p->drawLine( x, y, x + w - 1, y );
+ p->drawLine( x, y, x, y + h - 1);
+ p->setPen( cg.shadow() );
+ p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
+ p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
+ // the bright side!
+ p->setPen(cg.shadow());
+ p->drawLine( x + 1, y + h - 2, x + w - 2, y + h - 2 );
+ p->drawLine( x + w - 2, y + 1, x + w - 2, y + h - 2 );
+ p->setPen( cg.light() );
+ p->drawLine( x, y + h - 1, x + w - 1, y + h - 1 );
+ p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 );
+ // top left corner:
+ p->setPen(cg.background());
+ p->drawPoint( x, y );
+ p->drawPoint( x + 1, y );
+ p->drawPoint( x, y + 1 );
+ p->setPen(cg.shadow());
+ p->drawPoint( x + 1, y + 1 );
+ // bottom left corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x, y + h - 1 );
+ p->drawPoint( x + 1, y + h - 1 );
+ p->drawPoint( x, y + h - 2 );
+ p->setPen( cg.light() );
+ p->drawPoint( x + 1, y + h - 2 );
+ // top right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x + w - 1, y );
+ p->drawPoint( x + w - 2, y );
+ p->drawPoint( x + w - 1, y + 1 );
+ p->setPen( cg.dark() );
+ p->drawPoint( x + w - 2, y + 1 );
+ // bottom right corner:
+ p->setPen( cg.background() );
+ p->drawPoint( x + w - 1, y + h - 1 );
+ p->drawPoint( x + w - 2, y + h - 1 );
+ p->drawPoint( x + w - 1, y + h - 2 );
+ p->setPen( cg.light() );
+ p->drawPoint( x + w - 2, y + h - 2 );
+ p->setPen( cg.dark() );
+ p->drawPoint( x + w - 3, y + h - 3 );
+ // ### end slider groove
+
+ if ( how & Style_HasFocus )
+ drawPrimitive( PE_FocusRect, p, groove, cg );
+ }
+
+ if ((sub & SC_SliderHandle) && handle.isValid()) {
+ const TQColor c0 = cg.shadow();
+ const TQColor c1 = cg.dark();
+ const TQColor c3 = cg.light();
+
+ int x1 = handle.x();
+ int x2 = handle.x() + handle.width() - 1;
+ int y1 = handle.y();
+ int y2 = handle.y() + handle.height() - 1;
+ int mx = handle.width() / 2;
+ int my = handle.height() / 2;
+
+ if ( slider->orientation() == Vertical ) {
+ // Background
+ TQBrush oldBrush = p->brush();
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->setPen( NoPen );
+ TQPointArray a(6);
+ a.setPoint( 0, x1 + 1, y1 + 1 );
+ a.setPoint( 1, x2 - my + 2, y1 + 1 );
+ a.setPoint( 2, x2 - 1, y1 + my - 1 );
+ a.setPoint( 3, x2 - 1, y2 - my + 1 );
+ a.setPoint( 4, x2 - my + 2, y2 - 1 );
+ a.setPoint( 5, x1 + 1, y2 - 1 );
+ p->drawPolygon( a );
+ p->setBrush( oldBrush );
+
+ // shadow border
+ p->setPen( c0 );
+ p->drawLine( x1, y1 + 1, x1,y2 - 1 );
+ p->drawLine( x2 - my + 2, y1, x2, y1 + my - 2 );
+ p->drawLine( x2 - my + 2, y2, x2, y1 + my + 2 );
+ p->drawLine( x2, y1 + my - 2, x2, y1 + my + 2 );
+ p->drawLine( x1 + 1, y1, x2 - my + 2, y1 );
+ p->drawLine( x1 + 1, y2, x2 - my + 2, y2 );
+
+ // light shadow
+ p->setPen( c3 );
+ p->drawLine( x1 + 1, y1 + 2, x1 + 1, y2 - 2 );
+ p->drawLine( x1 + 1, y1 + 1, x2 - my + 2, y1 + 1 );
+ p->drawLine( x2 - my + 2, y1 + 1, x2 - 1, y1 + my - 2 );
+
+ // dark shadow
+ p->setPen(c1);
+ p->drawLine( x2 - 1, y1 + my - 2, x2 - 1, y1 + my + 2 );
+ p->drawLine( x2 - my + 2, y2 - 1, x2 - 1, y1 + my + 2 );
+ p->drawLine( x1 + 1, y2 - 1, x2 -my + 2, y2 - 1 );
+
+ drawRiffles( p, handle.x(), handle.y() + 2, handle.width() - 3,
+ handle.height() - 4, cg, TRUE );
+ } else { // Horizontal
+ TQBrush oldBrush = p->brush();
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->setPen( NoPen );
+ TQPointArray a(6);
+ a.setPoint( 0, x2 - 1, y1 + 1 );
+ a.setPoint( 1, x2 - 1, y2 - mx + 2 );
+ a.setPoint( 2, x2 - mx + 1, y2 - 1 );
+ a.setPoint( 3, x1 + mx - 1, y2 - 1 );
+ a.setPoint( 4, x1 + 1, y2 - mx + 2 );
+ a.setPoint( 5, x1 + 1, y1 + 1 );
+ p->drawPolygon( a );
+ p->setBrush( oldBrush );
+
+ // shadow border
+ p->setPen( c0 );
+ p->drawLine( x1 + 1, y1, x2 - 1, y1 );
+ p->drawLine( x1, y2 - mx + 2, x1 + mx - 2, y2 );
+ p->drawLine( x2, y2 - mx + 2, x1 + mx + 2, y2 );
+ p->drawLine( x1 + mx - 2, y2, x1 + mx + 2, y2 );
+ p->drawLine( x1, y1 + 1, x1, y2 - mx + 2 );
+ p->drawLine( x2, y1 + 1, x2, y2 - mx + 2 );
+
+ // light shadow
+ p->setPen(c3);
+ p->drawLine( x1 + 1, y1 + 1, x2 - 1, y1 + 1 );
+ p->drawLine( x1 + 1, y1 + 1, x1 + 1, y2 - mx + 2 );
+
+ // dark shadow
+ p->setPen(c1);
+ p->drawLine( x2 - 1, y1 + 1, x2 - 1, y2 - mx + 2 );
+ p->drawLine( x1 + 1, y2 - mx + 2, x1 + mx - 2, y2 - 1 );
+ p->drawLine( x2 - 1, y2 - mx + 2, x1 + mx + 2, y2 - 1 );
+ p->drawLine( x1 + mx - 2, y2 - 1, x1 + mx + 2, y2 - 1 );
+
+ drawRiffles( p, handle.x() + 2, handle.y(), handle.width() - 4,
+ handle.height() - 5, cg, FALSE );
+ }
+ }
+
+ if ( sub & SC_SliderTickmarks )
+ TQCommonStyle::drawComplexControl( control, p, widget, r,
+ cg, how, SC_SliderTickmarks,
+ subActive, opt );
+#endif
+ break;
+ }
+ default:
+ TQWindowsStyle::drawComplexControl( control, p, widget, r, cg,
+ how, sub, subActive, opt );
+ break;
+ }
+}
+
+
+
+/*!\reimp
+ */
+TQRect TQPlatinumStyle::querySubControlMetrics( ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& opt ) const
+{
+ switch( control ) {
+#ifndef QT_NO_COMBOBOX
+ case CC_ComboBox:
+ const TQComboBox *cb;
+ cb = (const TQComboBox *)widget;
+ switch( sc ) {
+ case SC_ComboBoxArrow: {
+ TQRect ir = cb->rect();
+ int xx;
+ if( TQApplication::reverseLayout() )
+ xx = ir.x();
+ else
+ xx = ir.x() + ir.width() - 20;
+ return TQRect( xx, ir.y(), 20, ir.height()); }
+ default:
+ break;
+ }
+ break;
+#endif
+#ifndef QT_NO_SCROLLBAR
+ case CC_ScrollBar: {
+ const TQScrollBar *sb;
+ sb = (const TQScrollBar *)widget;
+ int sliderStart = sb->sliderStart();
+ int sbextent = pixelMetric( PM_ScrollBarExtent, widget );
+ int maxlen = ((sb->orientation() == TQt::Horizontal) ?
+ sb->width() : sb->height()) - ( sbextent * 2 );
+
+ int sliderlen;
+
+ // calculate length
+ if ( sb->maxValue() != sb->minValue() ) {
+ uint range = sb->maxValue() - sb->minValue();
+ sliderlen = ( sb->pageStep() * maxlen ) /
+ ( range + sb->pageStep() );
+
+ int slidermin = pixelMetric( PM_ScrollBarSliderMin, widget );
+ if ( sliderlen < slidermin || range > INT_MAX / 2 )
+ sliderlen = slidermin;
+ if ( sliderlen > maxlen )
+ sliderlen = maxlen;
+ } else {
+ sliderlen = maxlen;
+ }
+
+ switch ( sc ) {
+ case SC_ScrollBarSubLine:
+ if ( sb->orientation() == TQt::Horizontal ) {
+ int buttonw = TQMIN( sb->width() / 2, sbextent );
+ return TQRect( sb->width() - 2 * buttonw, 0, buttonw, sbextent );
+ } else {
+ int buttonh = TQMIN( sb->height() / 2, sbextent );
+ return TQRect( 0, sb->height() - 2 * buttonh, sbextent, buttonh );
+ }
+ case SC_ScrollBarAddLine:
+ if ( sb->orientation() == TQt::Horizontal ) {
+ int buttonw = TQMIN( sb->width() / 2, sbextent );
+ return TQRect( sb->width() - buttonw, 0, sbextent, buttonw );
+ } else {
+ int buttonh = TQMIN( sb->height() / 2, sbextent );
+ return TQRect(0, sb->height() - buttonh, sbextent, buttonh );
+ }
+ case SC_ScrollBarSubPage:
+ if ( sb->orientation() == TQt::Horizontal )
+ return TQRect( 1, 0, sliderStart, sbextent );
+ return TQRect( 0, 1, sbextent, sliderStart );
+ case SC_ScrollBarAddPage:
+ if ( sb->orientation() == TQt::Horizontal )
+ return TQRect( sliderStart + sliderlen, 0, maxlen - sliderStart - sliderlen, sbextent );
+ return TQRect( 0, sliderStart + sliderlen, sbextent, maxlen - sliderStart - sliderlen );
+ case SC_ScrollBarGroove:
+ if ( sb->orientation() == TQt::Horizontal )
+ return TQRect( 1, 0, sb->width() - sbextent * 2, sb->height() );
+ return TQRect( 0, 1, sb->width(), sb->height() - sbextent * 2 );
+ default:
+ break;
+ }
+ break; }
+#endif
+#ifndef QT_NO_SLIDER
+ case CC_Slider: {
+
+ const TQSlider *slider = (const TQSlider *) widget;
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, widget);
+ int thickness = pixelMetric( PM_SliderControlThickness, widget);
+ int mid = thickness / 2;
+ int ticks = slider->tickmarks();
+ int len = pixelMetric( PM_SliderLength, widget );
+
+ switch ( sc ) {
+ case SC_SliderGroove:
+ if ( ticks & TQSlider::Above )
+ mid += len / 8;
+ if ( ticks & TQSlider::Below )
+ mid -= len / 8;
+ if ( slider->orientation() == TQSlider::Horizontal )
+ return TQRect( 0, tickOffset, slider->width(), thickness );
+ return TQRect( tickOffset, 0, thickness, slider->height() );
+ default:
+ break;
+ }
+ break; }
+#endif
+ default:
+ break;
+ }
+ return TQWindowsStyle::querySubControlMetrics( control, widget, sc, opt );
+}
+
+
+/*!\reimp
+ */
+int TQPlatinumStyle::pixelMetric( PixelMetric metric,
+ const TQWidget *widget ) const
+{
+ int ret;
+ switch( metric ) {
+ case PM_ButtonDefaultIndicator:
+ ret = 3;
+ break;
+ case PM_ButtonShiftHorizontal:
+ case PM_ButtonShiftVertical:
+ ret = 0;
+ break;
+ case PM_IndicatorWidth:
+ ret = 15;
+ break;
+ case PM_IndicatorHeight:
+ ret = 13;
+ break;
+ case PM_ExclusiveIndicatorHeight:
+ case PM_ExclusiveIndicatorWidth:
+ ret = 15;
+ break;
+ case PM_SliderLength:
+ ret = 17;
+ break;
+ case PM_MaximumDragDistance:
+ ret = -1;
+ break;
+ default:
+ ret = TQWindowsStyle::pixelMetric( metric, widget );
+ break;
+ }
+ return ret;
+}
+
+/*!\reimp
+ */
+TQRect TQPlatinumStyle::subRect( SubRect r, const TQWidget *widget ) const
+{
+ TQRect rect;
+ switch ( r ) {
+ case SR_ComboBoxFocusRect:
+ {
+ TQRect tmpR = widget->rect();
+ rect = TQRect( tmpR.x() + 4, tmpR.y() + 4, tmpR.width() - 8 - 16,
+ tmpR.height() - 8 );
+ break;
+ }
+ default:
+ rect = TQWindowsStyle::subRect( r, widget );
+ break;
+ }
+ return rect;
+}
+
+/*!
+ Mixes two colors \a c1 and \a c2 to a new color.
+*/
+TQColor TQPlatinumStyle::mixedColor(const TQColor &c1, const TQColor &c2) const
+{
+ int h1,s1,v1,h2,s2,v2;
+ c1.hsv(&h1,&s1,&v1);
+ c2.hsv(&h2,&s2,&v2);
+ return TQColor( (h1+h2)/2, (s1+s2)/2, (v1+v2)/2, TQColor::Hsv );
+}
+
+/*!
+ Draws the nifty Macintosh decoration used on sliders using painter
+ \a p and colorgroup \a g. \a x, \a y, \a w, \a h and \a horizontal
+ specify the geometry and orientation of the riffles.
+*/
+void TQPlatinumStyle::drawRiffles( TQPainter* p, int x, int y, int w, int h,
+ const TQColorGroup &g, bool horizontal ) const
+{
+ if (!horizontal) {
+ if (h > 20) {
+ y += (h-20)/2 ;
+ h = 20;
+ }
+ if (h > 8) {
+ int n = h / 4;
+ int my = y+h/2-n;
+ int i ;
+ p->setPen(g.light());
+ for (i=0; i<n; i++) {
+ p->drawLine(x+3, my+2*i, x+w-5, my+2*i);
+ }
+ p->setPen(g.dark());
+ my++;
+ for (i=0; i<n; i++) {
+ p->drawLine(x+4, my+2*i, x+w-4, my+2*i);
+ }
+ }
+ }
+ else {
+ if (w > 20) {
+ x += (w-20)/2 ;
+ w = 20;
+ }
+ if (w > 8) {
+ int n = w / 4;
+ int mx = x+w/2-n;
+ int i ;
+ p->setPen(g.light());
+ for (i=0; i<n; i++) {
+ p->drawLine(mx+2*i, y+3, mx + 2*i, y+h-5);
+ }
+ p->setPen(g.dark());
+ mx++;
+ for (i=0; i<n; i++) {
+ p->drawLine(mx+2*i, y+4, mx + 2*i, y+h-4);
+ }
+ }
+ }
+}
+
+
+#endif
diff --git a/src/styles/qplatinumstyle.h b/src/styles/qplatinumstyle.h
new file mode 100644
index 000000000..41083b820
--- /dev/null
+++ b/src/styles/qplatinumstyle.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Definition of Platinum-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQPLATINUMSTYLE_H
+#define TQPLATINUMSTYLE_H
+
+#ifndef QT_H
+#include "qwindowsstyle.h"
+#endif // QT_H
+
+#if !defined(QT_NO_STYLE_PLATINUM) || defined(QT_PLUGIN)
+
+class TQPalette;
+
+#if defined(QT_PLUGIN)
+#define Q_EXPORT_STYLE_PLATINUM
+#else
+#define Q_EXPORT_STYLE_PLATINUM Q_EXPORT
+#endif
+
+class Q_EXPORT_STYLE_PLATINUM TQPlatinumStyle : public TQWindowsStyle
+{
+ Q_OBJECT
+public:
+ TQPlatinumStyle();
+ virtual ~TQPlatinumStyle();
+
+ // new Style Stuff
+ void drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawComplexControl( ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+#ifdef Q_QDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect querySubControlMetrics( ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int pixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const;
+
+ TQRect subRect( SubRect r, const TQWidget *widget ) const;
+
+protected:
+ TQColor mixedColor(const TQColor &, const TQColor &) const;
+ void drawRiffles( TQPainter* p, int x, int y, int w, int h,
+ const TQColorGroup &g, bool horizontal ) const;
+private: // Disabled copy constructor and operator=
+#if defined(Q_DISABLE_COPY)
+ TQPlatinumStyle( const TQPlatinumStyle & );
+ TQPlatinumStyle& operator=( const TQPlatinumStyle & );
+#endif
+};
+
+#endif // QT_NO_STYLE_PLATINUM
+
+#endif // TQPLATINUMSTYLE_H
diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp
new file mode 100644
index 000000000..2ce166ba2
--- /dev/null
+++ b/src/styles/qsgistyle.cpp
@@ -0,0 +1,1468 @@
+/****************************************************************************
+**
+** Implementation of Motif-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qsgistyle.h"
+
+#if !defined(QT_NO_STYLE_SGI) || defined(QT_PLUGIN)
+
+#include "qpopupmenu.h"
+#include "qapplication.h"
+#include "qbutton.h"
+#include "qpainter.h"
+#include "qdrawutil.h"
+#include "qpixmap.h"
+#include "qpalette.h"
+#include "qwidget.h"
+#include "qpushbutton.h"
+#include "qscrollbar.h"
+#include "qcombobox.h"
+#include "qslider.h"
+#include "qtextedit.h"
+#include "qtoolbar.h"
+#include "qlineedit.h"
+#include "qmenubar.h"
+#include <limits.h>
+
+#ifndef QT_NO_SLIDER
+struct SliderLastPosition
+{
+ SliderLastPosition() : rect(0,-1,0,-1), slider(0) {}
+ TQRect rect;
+ const TQSlider* slider;
+};
+#endif
+
+#ifndef QT_NO_SCROLLBAR
+struct ScrollbarLastPosition
+{
+ ScrollbarLastPosition() : rect( 0,-1, 0,-1 ), scrollbar(0) {}
+ TQRect rect;
+ const TQScrollBar *scrollbar;
+};
+#endif
+
+class TQSGIStylePrivate
+{
+public:
+ TQSGIStylePrivate()
+ : hotWidget( 0 ), mousePos( -1, -1 )
+ {
+ }
+
+ const TQWidget *hotWidget;
+ TQPoint mousePos;
+#ifndef QT_NO_SCROLLBAR
+ ScrollbarLastPosition lastScrollbarRect;
+#endif
+#ifndef QT_NO_SLIDER
+ SliderLastPosition lastSliderRect;
+#endif
+};
+
+/*!
+ \class TQSGIStyle qsgistyle.h
+ \brief The TQSGIStyle class provides SGI/Irix look and feel.
+
+ \ingroup appearance
+
+ This class implements the SGI look and feel. It resembles the
+ SGI/Irix Motif GUI style as closely as TQStyle allows.
+*/
+
+/*!
+ Constructs a TQSGIStyle.
+
+ If \a useHighlightCols is FALSE (default value), the style will
+ polish the application's color palette to emulate the Motif way of
+ highlighting, which is a simple inversion between the base and the
+ text color.
+
+ \sa TQMotifStyle::useHighlightColors()
+*/
+TQSGIStyle::TQSGIStyle( bool useHighlightCols ) : TQMotifStyle( useHighlightCols ), isApplicationStyle( 0 )
+{
+ d = new TQSGIStylePrivate;
+}
+
+/*!
+ Destroys the style.
+*/
+TQSGIStyle::~TQSGIStyle()
+{
+ delete d;
+}
+
+/*!
+ \reimp
+
+ Changes some application-wide settings to be SGI-like, e.g. sets a
+ bold italic font for menu options.
+*/
+void
+TQSGIStyle::polish( TQApplication* app)
+{
+ isApplicationStyle = 1;
+ TQMotifStyle::polish( app );
+
+ TQPalette pal = TQApplication::palette();
+ // check this on SGI-Boxes
+ //pal.setColor( TQColorGroup::Background, pal.active().midlight() );
+ if (pal.active().button() == pal.active().background())
+ pal.setColor( TQColorGroup::Button, pal.active().button().dark(120) );
+ // darker basecolor in list-widgets
+ pal.setColor( TQColorGroup::Base, pal.active().base().dark(130) );
+ if (! useHighlightColors() ) {
+ pal.setColor( TQPalette::Active, TQColorGroup::Highlight, pal.active().text() );
+ pal.setColor( TQPalette::Active, TQColorGroup::HighlightedText, pal.active().base() );
+ pal.setColor( TQPalette::Inactive, TQColorGroup::Highlight, pal.inactive().text() );
+ pal.setColor( TQPalette::Inactive, TQColorGroup::HighlightedText, pal.inactive().base() );
+ pal.setColor( TQPalette::Disabled, TQColorGroup::Highlight, pal.disabled().text() );
+ pal.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText, pal.disabled().base() );
+ }
+ TQApplication::setPalette( pal, TRUE );
+
+ // different basecolor and highlighting in Q(Multi)LineEdit
+ pal.setColor( TQColorGroup::Base, TQColor(211,181,181) );
+ pal.setColor( TQPalette::Active, TQColorGroup::Highlight, pal.active().midlight() );
+ pal.setColor( TQPalette::Active, TQColorGroup::HighlightedText, pal.active().text() );
+ pal.setColor( TQPalette::Inactive, TQColorGroup::Highlight, pal.inactive().midlight() );
+ pal.setColor( TQPalette::Inactive, TQColorGroup::HighlightedText, pal.inactive().text() );
+ pal.setColor( TQPalette::Disabled, TQColorGroup::Highlight, pal.disabled().midlight() );
+ pal.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText, pal.disabled().text() );
+
+ TQApplication::setPalette( pal, TRUE, "TQLineEdit" );
+ TQApplication::setPalette( pal, TRUE, "TQTextEdit" );
+ TQApplication::setPalette( pal, TRUE, "TQDateTimeEditBase" );
+
+ pal = TQApplication::palette();
+ pal.setColor( TQColorGroup::Button, pal.active().background() );
+ TQApplication::setPalette( pal, TRUE, "TQMenuBar" );
+ TQApplication::setPalette( pal, TRUE, "TQToolBar" );
+ TQApplication::setPalette( pal, TRUE, "TQPopupMenu" );
+}
+
+/*! \reimp
+*/
+void
+TQSGIStyle::unPolish( TQApplication* /* app */ )
+{
+ TQFont f = TQApplication::font();
+ TQApplication::setFont( f, TRUE ); // get rid of the special fonts for special widget classes
+}
+
+/*!
+ \reimp
+
+ Installs an event filter for several widget classes to enable
+ hovering.
+*/
+void
+TQSGIStyle::polish( TQWidget* w )
+{
+ TQMotifStyle::polish(w);
+
+ if ( !isApplicationStyle ) {
+ TQPalette sgiPal = TQApplication::palette();
+
+ sgiPal.setColor( TQColorGroup::Background, sgiPal.active().midlight() );
+ if (sgiPal.active().button() == sgiPal.active().background())
+ sgiPal.setColor( TQColorGroup::Button, sgiPal.active().button().dark(110) );
+ sgiPal.setColor( TQColorGroup::Base, sgiPal.active().base().dark(130) );
+ if (! useHighlightColors() ) {
+ sgiPal.setColor( TQPalette::Active, TQColorGroup::Highlight, sgiPal.active().text() );
+ sgiPal.setColor( TQPalette::Active, TQColorGroup::HighlightedText, sgiPal.active().base() );
+ sgiPal.setColor( TQPalette::Inactive, TQColorGroup::Highlight, sgiPal.inactive().text() );
+ sgiPal.setColor( TQPalette::Inactive, TQColorGroup::HighlightedText, sgiPal.inactive().base() );
+ sgiPal.setColor( TQPalette::Disabled, TQColorGroup::Highlight, sgiPal.disabled().text() );
+ sgiPal.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText, sgiPal.disabled().base() );
+ }
+
+ if ( ::qt_cast<TQLineEdit*>(w) || ::qt_cast<TQTextEdit*>(w) ) {
+ // different basecolor and highlighting in Q(Multi)LineEdit
+ sgiPal.setColor( TQColorGroup::Base, TQColor(211,181,181) );
+ sgiPal.setColor( TQPalette::Active, TQColorGroup::Highlight, sgiPal.active().midlight() );
+ sgiPal.setColor( TQPalette::Active, TQColorGroup::HighlightedText, sgiPal.active().text() );
+ sgiPal.setColor( TQPalette::Inactive, TQColorGroup::Highlight, sgiPal.inactive().midlight() );
+ sgiPal.setColor( TQPalette::Inactive, TQColorGroup::HighlightedText, sgiPal.inactive().text() );
+ sgiPal.setColor( TQPalette::Disabled, TQColorGroup::Highlight, sgiPal.disabled().midlight() );
+ sgiPal.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText, sgiPal.disabled().text() );
+
+ } else if ( ::qt_cast<TQMenuBar*>(w) || ::qt_cast<TQToolBar*>(w) ) {
+ sgiPal.setColor( TQColorGroup::Button, sgiPal.active().midlight() );
+ }
+
+ w->setPalette( sgiPal );
+ }
+
+ if ( ::qt_cast<TQButton*>(w) || ::qt_cast<TQSlider*>(w) || ::qt_cast<TQScrollBar*>(w) ) {
+ w->installEventFilter( this );
+ w->setMouseTracking( TRUE );
+#ifndef QT_NO_SCROLLBAR
+ if ( ::qt_cast<TQScrollBar*>(w) )
+ w->setBackgroundMode( TQWidget::NoBackground );
+#endif
+ } else if ( ::qt_cast<TQComboBox*>(w) ) {
+ TQFont f = TQApplication::font();
+ f.setBold( TRUE );
+ f.setItalic( TRUE );
+ w->setFont( f );
+#ifndef QT_NO_MENUBAR
+ } else if ( ::qt_cast<TQMenuBar*>(w) ) {
+ ((TQFrame*) w)->setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised);
+ w->setBackgroundMode( TQWidget::PaletteBackground );
+ TQFont f = TQApplication::font();
+ f.setBold( TRUE );
+ f.setItalic( TRUE );
+ w->setFont( f );
+#endif
+#ifndef QT_NO_POPUPMENU
+ } else if ( ::qt_cast<TQPopupMenu*>(w) ) {
+ ((TQFrame*) w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth ) + 1 );
+ TQFont f = TQApplication::font();
+ f.setBold( TRUE );
+ f.setItalic( TRUE );
+ w->setFont( f );
+#endif
+ } else if ( ::qt_cast<TQToolBar*>(w) || w->inherits("TQToolBarSeparator") ) {
+ w->setBackgroundMode( TQWidget::PaletteBackground );
+ }
+}
+
+/*! \reimp */
+void
+TQSGIStyle::unPolish( TQWidget* w )
+{
+ if ( ::qt_cast<TQButton*>(w) || ::qt_cast<TQSlider*>(w) || ::qt_cast<TQScrollBar*>(w) ) {
+ w->removeEventFilter( this );
+#ifndef QT_NO_POPUPMENU
+ } else if ( ::qt_cast<TQPopupMenu*>(w) ) {
+ ((TQFrame*)w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth ) );
+ w->setFont( TQApplication::font() );
+#endif
+#if !defined(QT_NO_MENUBAR) || !defined(QT_NO_COMBOBOX)
+ } else if ( ::qt_cast<TQMenuBar*>(w) || ::qt_cast<TQComboBox*>(w) ) {
+ w->setFont( TQApplication::font() );
+#endif
+ }
+}
+
+/*! \reimp */
+bool TQSGIStyle::eventFilter( TQObject* o, TQEvent* e )
+{
+ if ( !o->isWidgetType() || e->type() == TQEvent::Paint )
+ return TQMotifStyle::eventFilter( o, e );
+
+ TQWidget *widget = (TQWidget*)o;
+
+ switch ( e->type() ) {
+ case TQEvent::MouseButtonPress:
+ {
+#ifndef QT_NO_SCROLLBAR
+ if ( ::qt_cast<TQScrollBar*>(widget) ) {
+ d->lastScrollbarRect.rect = ((TQScrollBar*)widget)->sliderRect();
+ d->lastScrollbarRect.scrollbar = ((TQScrollBar*)widget);
+ widget->repaint( FALSE );
+ } else
+#endif
+ {
+#ifndef QT_NO_SLIDER
+ if ( ::qt_cast<TQSlider*>(widget) ) {
+ d->lastSliderRect.rect = ((TQSlider*)widget)->sliderRect();
+ d->lastSliderRect.slider = ((TQSlider*)widget);
+ widget->repaint( FALSE );
+ }
+#endif
+ }
+ }
+ break;
+
+ case TQEvent::MouseButtonRelease:
+ {
+ if ( 0 ) {
+#ifndef QT_NO_SCROLLBAR
+ } else if ( ::qt_cast<TQScrollBar*>(widget) ) {
+ TQRect oldRect = d->lastScrollbarRect.rect;
+ d->lastScrollbarRect.rect = TQRect( 0, -1, 0, -1 );
+ widget->repaint( oldRect, FALSE );
+#endif
+#ifndef QT_NO_SLIDER
+ } else if ( ::qt_cast<TQSlider*>(widget) ) {
+ TQRect oldRect = d->lastSliderRect.rect;
+ d->lastSliderRect.rect = TQRect( 0, -1, 0, -1 );
+ widget->repaint( oldRect, FALSE );
+#endif
+ }
+ }
+ break;
+
+ case TQEvent::MouseMove:
+ if ( !widget->isActiveWindow() )
+ break;
+ if ( ((TQMouseEvent*)e)->button() )
+ break;
+
+ d->hotWidget = widget;
+ d->mousePos = ((TQMouseEvent*)e)->pos();
+ widget->repaint( FALSE );
+ break;
+
+ case TQEvent::Enter:
+ if ( !widget->isActiveWindow() )
+ break;
+ d->hotWidget = widget;
+ widget->repaint( FALSE );
+ break;
+
+ case TQEvent::Leave:
+ if ( !widget->isActiveWindow() )
+ break;
+ if ( widget == d->hotWidget) {
+ d->hotWidget = 0;
+ widget->repaint( FALSE );
+ }
+ break;
+
+ default:
+ break;
+ }
+ return TQMotifStyle::eventFilter( o, e );
+}
+
+static const int sgiItemFrame = 2; // menu item frame width
+// static const int sgiSepHeight = 1; // separator item height
+static const int sgiItemHMargin = 3; // menu item hor text margin
+static const int sgiItemVMargin = 2; // menu item ver text margin
+static const int sgiArrowHMargin = 6; // arrow horizontal margin
+static const int sgiTabSpacing = 12; // space between text and tab
+// static const int sgiCheckMarkHMargin = 2; // horiz. margins of check mark ### not used?!?
+static const int sgiCheckMarkSpace = 20;
+
+/*! \reimp */
+int TQSGIStyle::pixelMetric( PixelMetric metric, const TQWidget *widget ) const
+{
+ switch ( metric ) {
+ case PM_DefaultFrameWidth:
+ return 2;
+
+ case PM_ButtonDefaultIndicator:
+ return 4;
+
+ case PM_ScrollBarExtent:
+ return 21;
+
+ case PM_IndicatorWidth:
+ case PM_IndicatorHeight:
+ return 14;
+
+ case PM_ExclusiveIndicatorWidth:
+ case PM_ExclusiveIndicatorHeight:
+ return 12;
+
+ case PM_SplitterWidth:
+ return TQMAX( 10, TQApplication::globalStrut().width() );
+
+ default:
+ break;
+ }
+ return TQMotifStyle::pixelMetric( metric, widget );
+}
+
+static void drawPanel( TQPainter *p, int x, int y, int w, int h,
+ const TQColorGroup &g, bool sunken,
+ int lineWidth, const TQBrush* fill)
+{
+ if ( w == 0 || h == 0 )
+ return;
+#if defined(CHECK_RANGE)
+ ASSERT( w > 0 && h > 0 && lineWidth >= 0 );
+#endif
+ TQPen oldPen = p->pen(); // save pen
+ TQPointArray a( 4*lineWidth );
+ if ( sunken )
+ p->setPen( g.dark() );
+ else
+ p->setPen( g.light() );
+ int x1, y1, x2, y2;
+ int i;
+ int n = 0;
+ x1 = x;
+ y1 = y2 = y;
+ x2 = x+w-2;
+ for ( i=0; i<lineWidth; i++ ) { // top shadow
+ a.setPoint( n++, x1, y1++ );
+ a.setPoint( n++, x2--, y2++ );
+ }
+ x2 = x1;
+ y1 = y+h-2;
+ for ( i=0; i<lineWidth; i++ ) { // left shadow
+ a.setPoint( n++, x1++, y1 );
+ a.setPoint( n++, x2++, y2-- );
+ }
+ p->drawLineSegments( a );
+ n = 0;
+ if ( sunken )
+ p->setPen( g.light() );
+ else
+ p->setPen( g.dark() );
+ x1 = x;
+ y1 = y2 = y+h-1;
+ x2 = x+w-1;
+ for ( i=0; i<lineWidth; i++ ) { // bottom shadow
+ a.setPoint( n++, x1++, y1-- );
+ a.setPoint( n++, x2, y2-- );
+ }
+ x1 = x2;
+ y1 = y;
+ y2 = y+h-lineWidth-1;
+ for ( i=0; i<lineWidth; i++ ) { // right shadow
+ a.setPoint( n++, x1--, y1++ );
+ a.setPoint( n++, x2--, y2 );
+ }
+ p->drawLineSegments( a );
+ if ( fill ) { // fill with fill color
+ TQBrush oldBrush = p->brush();
+ p->setPen( TQt::NoPen );
+ p->setBrush( *fill );
+ p->drawRect( x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2 );
+ p->setBrush( oldBrush );
+ }
+ p->setPen( oldPen ); // restore pen
+}
+
+static void drawSeparator( TQPainter *p, int x1, int y1, int x2, int y2,
+ const TQColorGroup &g )
+{
+ TQPen oldPen = p->pen();
+
+ p->setPen( g.midlight() );
+ p->drawLine( x1, y1, x2, y2 );
+ p->setPen( g.shadow() );
+ if ( y2-y1 < x2-x1 )
+ p->drawLine( x1, y1+1, x2, y2+1 );
+ else
+ p->drawLine( x1+1, y1, x2+1, y2 );
+
+ p->setPen( oldPen );
+}
+
+static void drawSGIPrefix( TQPainter *p, int x, int y, TQString* miText )
+{
+ if ( miText && (!!(*miText)) ) {
+ int amp = 0;
+ bool nextAmp = FALSE;
+ while ( ( amp = miText->find( '&', amp ) ) != -1 ) {
+ if ( (uint)amp == miText->length()-1 )
+ return;
+ miText->remove( amp,1 );
+ nextAmp = (*miText)[amp] == '&'; // next time if &&
+
+ if ( !nextAmp ) { // draw special underlining
+ uint ulx = p->fontMetrics().width(*miText, amp);
+
+ uint ulw = p->fontMetrics().width(*miText, amp+1) - ulx;
+
+ p->drawLine( x+ulx, y, x+ulx+ulw, y );
+ p->drawLine( x+ulx, y+1, x+ulx+ulw/2, y+1 );
+ p->drawLine( x+ulx, y+2, x+ulx+ulw/4, y+2 );
+ }
+ amp++;
+ }
+ }
+}
+
+static int get_combo_extra_width( int h, int *return_awh=0 )
+{
+ int awh;
+ if ( h < 8 ) {
+ awh = 6;
+ } else if ( h < 14 ) {
+ awh = h - 2;
+ } else {
+ awh = h/2;
+ }
+ if ( return_awh )
+ *return_awh = awh;
+ return awh*2;
+}
+
+static void get_combo_parameters( const TQRect &r,
+ int &ew, int &awh, int &ax,
+ int &ay, int &sh, int &dh,
+ int &sy )
+{
+ ew = get_combo_extra_width( r.height(), &awh );
+
+ sh = (awh+3)/4;
+ if ( sh < 3 )
+ sh = 3;
+ dh = sh/2 + 1;
+
+ ay = r.y() + (r.height()-awh-sh-dh)/2;
+ if ( ay < 0 ) {
+ //panic mode
+ ay = 0;
+ sy = r.height();
+ } else {
+ sy = ay+awh+dh;
+ }
+ if( TQApplication::reverseLayout() )
+ ax = r.x();
+ else
+ ax = r.x() + r.width() - ew;
+ ax += (ew-awh)/2;
+}
+
+/*! \reimp */
+void TQSGIStyle::drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ const int x = r.x();
+ const int y = r.y();
+ const int w = r.width();
+ const int h = r.height();
+ const bool sunken = flags & ( Style_Sunken | Style_Down | Style_On );
+ const int defaultFrameWidth = pixelMetric( PM_DefaultFrameWidth );
+ bool hot = ( flags & Style_MouseOver ) && ( flags & Style_Enabled );
+
+ switch ( pe ) {
+ case PE_ButtonCommand:
+ {
+ TQBrush fill;
+ if ( hot ) {
+ if ( sunken )
+ fill = cg.brush( TQColorGroup::Dark );
+ else
+ fill = cg.brush( TQColorGroup::Midlight );
+ } else if ( sunken ) {
+ fill = cg.brush( TQColorGroup::Mid );
+ } else {
+ fill = cg.brush( TQColorGroup::Button );
+ }
+
+ drawPanel( p, x, y, w, h, cg, sunken, defaultFrameWidth, &fill );
+ }
+ break;
+
+ case PE_PanelPopup:
+ case PE_ButtonBevel:
+ case PE_ButtonTool:
+ {
+ drawPrimitive( PE_ButtonCommand, p, TQRect( x+1, y+1, w-2, h-2 ), cg, flags, opt );
+
+ TQPen oldPen = p->pen();
+ TQPointArray a;
+
+ // draw twocolored rectangle
+ p->setPen( sunken ? cg.light() : cg.dark().dark(200) );
+ a.setPoints( 3, x, y+h-1, x+w-1, y+h-1, x+w-1, y );
+ p->drawPolyline( a );
+ p->setPen( cg.dark() );
+ a.setPoints( 3, x, y+h-2, x, y, x+w-2, y );
+ p->drawPolyline( a );
+
+ p->setPen( oldPen );
+ }
+ break;
+
+ case PE_ArrowUp:
+ case PE_ArrowDown:
+ case PE_ArrowLeft:
+ case PE_ArrowRight:
+ {
+ TQPointArray a; // arrow polygon
+ switch ( pe ) {
+ case PE_ArrowUp:
+ a.setPoints( 3, 0,-5, -5,4, 4,4 );
+ break;
+ case PE_ArrowDown:
+ a.setPoints( 3, 0,4, -4,-4, 4,-4 );
+ break;
+ case PE_ArrowLeft:
+ a.setPoints( 3, -4,0, 4,-5, 4,4 );
+ break;
+ case PE_ArrowRight:
+ a.setPoints( 3, 4,0, -4,-5, -4,4 );
+ break;
+ default:
+ return;
+ }
+
+ p->save();
+ p->setPen( TQt::NoPen );
+ a.translate( x+w/2, y+h/2 );
+ p->setBrush( flags & Style_Enabled ? cg.dark() : cg.light() );
+ p->drawPolygon( a ); // draw arrow
+ p->restore();
+ }
+ break;
+
+ case PE_Indicator:
+ {
+ TQRect er = r;
+ er.addCoords( 1, 1, -1, -1 );
+ int iflags = flags & ~Style_On;
+ drawPrimitive( PE_ButtonBevel, p, er, cg, iflags, opt );
+ if ( !(flags & TQStyle::Style_Off) ) {
+ er = r;
+ er.addCoords( 1, 2, 1, 1 );
+ drawPrimitive( PE_CheckMark, p, er, cg, flags, opt );
+ }
+ }
+ break;
+
+ case PE_IndicatorMask:
+ {
+ TQPen oldPen = p->pen();
+ TQBrush oldBrush = p->brush();
+
+ p->setPen( TQt::color1 );
+ p->setBrush( TQt::color1 );
+ p->fillRect( x, y, w, h, TQBrush( TQt::color0 ) );
+ TQRect er = r;
+ er.addCoords( 1, 1, -1, -1 );
+ p->fillRect(er, TQBrush(TQt::color1));
+
+ if ( !(flags & TQStyle::Style_Off) ) {
+ er = r;
+ er.addCoords( 1, 2, 1, 1 );
+ static const TQCOORD check_mark[] = {
+ 14,0, 10,0, 11,1, 8,1, 9,2, 7,2, 8,3, 6,3,
+ 7,4, 1,4, 6,5, 1,5, 6,6, 3,6, 5,7, 4,7,
+ 5,8, 5,8, 4,3, 2,3, 3,2, 3,2 };
+
+ TQPointArray amark;
+ amark = TQPointArray( sizeof(check_mark)/(sizeof(TQCOORD)*2), check_mark );
+ amark.translate( er.x()+1, er.y()+1 );
+ p->drawLineSegments( amark );
+ amark.translate( -1, -1 );
+ p->drawLineSegments( amark );
+ }
+
+ p->setBrush( oldBrush );
+ p->setPen( oldPen );
+ }
+ break;
+
+ case PE_CheckMark:
+ {
+ static const TQCOORD check_mark[] = {
+ 14,0, 10,0, 11,1, 8,1, 9,2, 7,2, 8,3, 6,3,
+ 7,4, 1,4, 6,5, 1,5, 6,6, 3,6, 5,7, 4,7,
+ 5,8, 5,8, 4,3, 2,3, 3,2, 3,2 };
+
+ TQPen oldPen = p->pen();
+
+ TQPointArray amark;
+ amark = TQPointArray( sizeof(check_mark)/(sizeof(TQCOORD)*2), check_mark );
+ amark.translate( x+1, y+1 );
+
+ if ( flags & Style_On ) {
+ p->setPen( flags & Style_Enabled ? cg.shadow() : cg.dark() );
+ p->drawLineSegments( amark );
+ amark.translate( -1, -1 );
+ p->setPen( flags & Style_Enabled ? TQColor(255,0,0) : cg.dark() );
+ p->drawLineSegments( amark );
+ p->setPen( oldPen );
+ } else {
+ p->setPen( flags & Style_Enabled ? cg.dark() : cg.mid() );
+ p->drawLineSegments( amark );
+ amark.translate( -1, -1 );
+ p->setPen( flags & Style_Enabled ? TQColor(230,120,120) : cg.dark() );
+ p->drawLineSegments( amark );
+ p->setPen( oldPen );
+ }
+ }
+ break;
+
+ case PE_ExclusiveIndicator:
+ {
+ p->save();
+ p->eraseRect( x, y, w, h );
+ p->translate( x, y );
+
+ p->setPen( cg.button() );
+ p->setBrush( hot ? cg.midlight() : cg.button() );
+ TQPointArray a;
+ a.setPoints( 4, 5,0, 11,6, 6,11, 0,5);
+ p->drawPolygon( a );
+
+ p->setPen( cg.dark() );
+ p->drawLine( 0,5, 5,0 );
+ p->drawLine( 6,0, 11,5 );
+ p->setPen( flags & Style_Down ? cg.light() : cg.dark() );
+ p->drawLine( 11,6, 6,11 );
+ p->drawLine( 5,11, 0,6 );
+ p->drawLine( 2,7, 5,10 );
+ p->drawLine( 6,10, 9,7 );
+ p->setPen( cg.light() );
+ p->drawLine( 2,5, 5,2 );
+
+ if ( flags & Style_On ) {
+ p->setPen( flags & Style_Enabled ? TQt::blue : TQt::darkGray );
+ p->setBrush( flags & Style_Enabled ? TQt::blue : TQt::darkGray );
+ a.setPoints(3, 6,2, 8,4, 6,6 );
+ p->drawPolygon( a );
+ p->setBrush( TQt::NoBrush );
+
+ p->setPen( cg.shadow() );
+ p->drawLine( 7,7, 9,5 );
+ } else {
+ p->drawLine( 6,2, 9,5 );
+ }
+ p->restore();
+ }
+ break;
+
+ case PE_ExclusiveIndicatorMask:
+ {
+ p->save();
+ TQPen oldPen = p->pen();
+ TQBrush oldBrush = p->brush();
+
+ p->setPen( TQt::color1 );
+ p->setBrush( TQt::color1 );
+ TQPointArray a;
+ a.setPoints( 8, 0,5, 5,0, 6,0, 11,5, 11,6, 6,11, 5,11, 0,6 );
+ a.translate( x, y );
+ p->drawPolygon( a );
+
+ p->setBrush( oldBrush );
+ p->setPen( oldPen );
+ p->restore();
+ }
+ break;
+
+ case PE_Panel:
+ {
+ const int lineWidth = opt.isDefault() ? defaultFrameWidth : opt.lineWidth();
+ drawPanel( p, x, y, w, h, cg, flags & (Style_Sunken | Style_Down | Style_On), lineWidth, 0 );
+ if ( lineWidth <= 1 )
+ return;
+
+ // draw extra shadinglines
+ TQPen oldPen = p->pen();
+ p->setPen( cg.midlight() );
+ p->drawLine( x+1, y+h-3, x+1, y+1 );
+ p->drawLine( x+1, y+1, x+w-3, y+1 );
+ p->setPen( cg.mid() );
+ p->drawLine( x+1, y+h-2, x+w-2, y+h-2 );
+ p->drawLine( x+w-2, y+h-2, x+w-2, y+1 );
+ p->setPen(oldPen);
+ }
+ break;
+
+ case PE_ScrollBarSubLine:
+ if ( !r.contains( d->mousePos ) && !(flags & Style_Active) )
+ flags &= ~Style_MouseOver;
+ drawPrimitive( PE_ButtonCommand, p, r, cg, flags, opt );
+ drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
+ p, r, cg, Style_Enabled | flags);
+ break;
+
+ case PE_ScrollBarAddLine:
+ if ( !r.contains( d->mousePos ) )
+ flags &= ~Style_MouseOver;
+ drawPrimitive( PE_ButtonCommand, p, r, cg, flags, opt );
+ drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown),
+ p, r, cg, Style_Enabled | flags);
+ break;
+
+ case PE_ScrollBarSubPage:
+ case PE_ScrollBarAddPage:
+ if ( !r.contains( d->mousePos ) )
+ flags &= ~Style_MouseOver;
+ if ( r.isValid() )
+ qDrawShadePanel( p, x, y, w, h, cg, FALSE, 1, hot ? &cg.brush( TQColorGroup::Midlight ) : &cg.brush( TQColorGroup::Button ) );
+ break;
+
+ case PE_ScrollBarSlider:
+ {
+ if ( !r.isValid() )
+ break;
+ if ( !(r.contains( d->mousePos ) || flags & Style_Active) || !(flags & Style_Enabled ) )
+ flags &= ~Style_MouseOver;
+
+ TQPixmap pm( r.width(), r.height() );
+ TQPainter bp( &pm );
+ drawPrimitive(PE_ButtonBevel, &bp, TQRect(0,0,r.width(),r.height()), cg, flags | Style_Enabled | Style_Raised);
+ if ( flags & Style_Horizontal ) {
+ const int sliderM = r.width() / 2;
+ if ( r.width() > 20 ) {
+ drawSeparator( &bp, sliderM-5, 2, sliderM-5, r.height()-3, cg );
+ drawSeparator( &bp, sliderM+3, 2, sliderM+3, r.height()-3, cg );
+ }
+ if ( r.width() > 10 )
+ drawSeparator( &bp, sliderM-1, 2, sliderM-1, r.height()-3, cg );
+
+ } else {
+ const int sliderM = r.height() / 2;
+ if ( r.height() > 20 ) {
+ drawSeparator( &bp, 2, sliderM-5, r.width()-3, sliderM-5, cg );
+ drawSeparator( &bp, 2, sliderM+3, r.width()-3, sliderM+3, cg );
+ }
+ if ( r.height() > 10 )
+ drawSeparator( &bp, 2, sliderM-1, r.width()-3, sliderM-1, cg );
+ }
+ bp.end();
+ p->drawPixmap( r.x(), r.y(), pm );
+ }
+
+ break;
+
+ case PE_Splitter:
+ {
+ const int motifOffset = 10;
+ int sw = pixelMetric( PM_SplitterWidth );
+ if ( flags & Style_Horizontal ) {
+ int xPos = x + w/2;
+ int kPos = motifOffset;
+ int kSize = sw - 2;
+
+ qDrawShadeLine( p, xPos, kPos + kSize - 1 ,
+ xPos, h, cg );
+
+ drawPrimitive( PE_ButtonBevel, p, TQRect(xPos-sw/2+1, kPos, kSize, kSize+1), cg, flags, opt );
+ qDrawShadeLine( p, xPos+2, 0, xPos, kPos, cg );
+ } else {
+ int yPos = y + h/2;
+ int kPos = w - motifOffset - sw;
+ int kSize = sw - 2;
+
+ qDrawShadeLine( p, 0, yPos, kPos, yPos, cg );
+ drawPrimitive( PE_ButtonBevel, p, TQRect( kPos, yPos-sw/2+1, kSize+1, kSize ), cg, flags, opt );
+ qDrawShadeLine( p, kPos + kSize+1, yPos, w, yPos, cg );
+ }
+ }
+ break;
+
+ default:
+ TQMotifStyle::drawPrimitive( pe, p, r, cg, flags, opt );
+ break;
+ }
+}
+
+/*! \reimp */
+void TQSGIStyle::drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ if ( widget == d->hotWidget )
+ flags |= Style_MouseOver;
+
+ switch ( element ) {
+ case CE_PushButton:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *btn = (TQPushButton*)widget;
+ int x1, y1, x2, y2;
+ r.coords( &x1, &y1, &x2, &y2 );
+
+ p->setPen( cg.foreground() );
+ p->setBrush( TQBrush( cg.button(),TQt::NoBrush ) );
+ p->setBrushOrigin( -widget->backgroundOffset().x(),
+ -widget->backgroundOffset().y() );
+
+ int diw = pixelMetric( TQStyle::PM_ButtonDefaultIndicator );
+ if ( btn->isDefault() || btn->autoDefault() ) {
+ x1 += diw;
+ y1 += diw;
+ x2 -= diw;
+ y2 -= diw;
+ }
+
+ TQPointArray a;
+ if ( btn->isDefault() ) {
+ if ( diw == 0 ) {
+ a.setPoints( 9,
+ x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1,
+ x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1 );
+ p->setPen( cg.shadow() );
+ p->drawPolyline( a );
+ x1 += 2;
+ y1 += 2;
+ x2 -= 2;
+ y2 -= 2;
+ } else {
+ qDrawShadePanel( p, btn->rect(), cg, TRUE );
+ }
+ }
+
+ TQBrush fill = cg.brush( TQColorGroup::Button );
+ if ( !btn->isFlat() || btn->isOn() || btn->isDown() )
+ drawPrimitive( PE_ButtonBevel, p, TQRect( x1, y1, x2-x1+1, y2-y1+1 ), cg, flags, opt );
+
+ if ( p->brush().style() != TQt::NoBrush )
+ p->setBrush( TQt::NoBrush );
+#endif
+ }
+ break;
+
+ case CE_PopupMenuItem:
+ {
+#ifndef QT_NO_POPUPMENU
+ if (! widget || opt.isDefault())
+ break;
+ TQMenuItem *mi = opt.menuItem();
+ if ( !mi )
+ break;
+ const TQPopupMenu *popupmenu = (const TQPopupMenu *) widget;
+ int tab = opt.tabWidth();
+ int maxpmw = opt.maxIconWidth();
+ bool dis = ! (flags & Style_Enabled);
+ bool checkable = popupmenu->isCheckable();
+ bool act = flags & Style_Active;
+ int x, y, w, h;
+
+ r.rect(&x, &y, &w, &h);
+
+ if ( checkable )
+ maxpmw = TQMAX( maxpmw, sgiCheckMarkSpace );
+ int checkcol = maxpmw;
+
+ if (mi && mi->isSeparator() ) {
+ p->setPen( cg.mid() );
+ p->drawLine(x, y, x+w, y );
+ return;
+ }
+
+ int pw = sgiItemFrame;
+
+ if ( act && !dis ) {
+ if ( pixelMetric( PM_DefaultFrameWidth ) > 1 )
+ drawPanel( p, x, y, w, h, cg, FALSE, pw,
+ &cg.brush( TQColorGroup::Light ) );
+ else
+ drawPanel( p, x+1, y+1, w-2, h-2, cg, FALSE, 1,
+ &cg.brush( TQColorGroup::Light ) );
+ } else {
+ p->fillRect( x, y, w, h, cg.brush( TQColorGroup::Button ) );
+ }
+
+ if ( !mi )
+ return;
+
+ if ( mi->isChecked() ) {
+ if ( mi->iconSet() ) {
+ drawPanel( p, x+sgiItemFrame, y+sgiItemFrame, checkcol, h-2*sgiItemFrame,
+ cg, TRUE, 1, &cg.brush( TQColorGroup::Light ) );
+ }
+ } else {
+ if ( !act )
+ p->fillRect( x+sgiItemFrame, y+sgiItemFrame, checkcol, h-2*sgiItemFrame,
+ cg.brush( TQColorGroup::Button ) );
+ }
+
+ if ( mi->iconSet() ) {
+ TQIconSet::Mode mode = TQIconSet::Normal;
+ if ( act && !dis )
+ mode = TQIconSet::Active;
+ TQPixmap pixmap;
+ if ( checkable && mi->isChecked() )
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode, TQIconSet::On );
+ else
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode );
+
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ TQRect cr( x+sgiItemFrame, y+sgiItemFrame, checkcol, h-2*sgiItemFrame );
+ TQRect pmr( 0, 0, pixw, pixh );
+ pmr.moveCenter( cr.center() );
+ p->setPen( cg.text() );
+ p->drawPixmap( pmr.topLeft(), pixmap );
+ } else {
+ if ( checkable ) {
+ SFlags cflags = Style_Default;
+ if (! dis)
+ cflags |= Style_Enabled;
+ if (act)
+ cflags |= Style_On;
+
+ if ( mi->isChecked() ) {
+ TQRect er( x+sgiItemFrame+1, y+sgiItemFrame+3,
+ pixelMetric(PM_IndicatorWidth),
+ pixelMetric(PM_IndicatorHeight) );
+ er.addCoords( 1, 1, -1, -1 );
+ drawPrimitive( PE_ButtonBevel, p, er, cg, cflags, opt );
+ er.addCoords( 0, 1, 1, 1 );
+ drawPrimitive( PE_CheckMark, p, er, cg, cflags | Style_On, opt );
+ }
+ }
+ }
+
+ p->setPen( cg.buttonText() );
+
+ TQColor discol;
+ if ( dis ) {
+ discol = cg.text();
+ p->setPen( discol );
+ }
+
+ int xm = sgiItemFrame + checkcol + sgiItemHMargin;
+
+ if ( mi->custom() ) {
+ int m = sgiItemVMargin;
+ p->save();
+ mi->custom()->paint( p, cg, act, !dis,
+ x+xm, y+m, w-xm-tab+1, h-2*m );
+ p->restore();
+ }
+
+ TQString s = mi->text();
+ if ( !!s ) {
+ int t = s.find( '\t' );
+ int m = sgiItemVMargin;
+ const int text_flags = AlignVCenter | DontClip | SingleLine; //special underline for &x
+
+ TQString miText = s;
+ if ( t>=0 ) {
+ p->drawText(x+w-tab-sgiItemHMargin-sgiItemFrame,
+ y+m, tab, h-2*m, text_flags, miText.mid( t+1 ) );
+ miText = s.mid( 0, t );
+ }
+ TQRect br = p->fontMetrics().boundingRect( x+xm, y+m, w-xm-tab+1, h-2*m,
+ text_flags, mi->text() );
+
+ drawSGIPrefix( p, br.x()+p->fontMetrics().leftBearing(miText[0]),
+ br.y()+br.height()+p->fontMetrics().underlinePos()-2, &miText );
+ p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, miText, miText.length() );
+ } else {
+ if ( mi->pixmap() ) {
+ TQPixmap *pixmap = mi->pixmap();
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( OpaqueMode );
+ p->drawPixmap( x+xm, y+sgiItemFrame, *pixmap );
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( TransparentMode );
+ }
+ }
+ if ( mi->popup() ) {
+ int dim = (h-2*sgiItemFrame) / 2;
+ drawPrimitive( PE_ArrowRight, p, TQRect( x+w-sgiArrowHMargin-sgiItemFrame-dim, y+h/2-dim/2, dim, dim ), cg, flags );
+ }
+#endif
+ }
+ break;
+
+ case CE_MenuBarItem:
+ {
+#ifndef QT_NO_MENUDATA
+ if (opt.isDefault())
+ break;
+
+ TQMenuItem *mi = opt.menuItem();
+
+ bool active = flags & Style_Active;
+ int x, y, w, h;
+ r.rect( &x, &y, &w, &h );
+
+ if ( active ) {
+ p->setPen( TQPen( cg.shadow(), 1) );
+ p->drawRect( x, y, w, h );
+ qDrawShadePanel( p, TQRect(x+1,y+1,w-2,h-2), cg, FALSE, 2,
+ &cg.brush( TQColorGroup::Light ));
+ } else {
+ p->fillRect( x, y, w, h, cg.brush( TQColorGroup::Button ));
+ }
+
+ if ( mi->pixmap() )
+ drawItem( p, r, AlignCenter|DontClip|SingleLine,
+ cg, mi->isEnabled(), mi->pixmap(), "", -1, &cg.buttonText() );
+
+ if ( !!mi->text() ) {
+ TQString* text = new TQString(mi->text());
+ TQRect br = p->fontMetrics().boundingRect( x, y-2, w+1, h,
+ AlignCenter|DontClip|SingleLine|ShowPrefix, mi->text() );
+
+ drawSGIPrefix( p, br.x()+p->fontMetrics().leftBearing((*text)[0]),
+ br.y()+br.height()+p->fontMetrics().underlinePos()-2, text );
+ p->drawText( x, y-2, w+1, h, AlignCenter|DontClip|SingleLine, *text, text->length() );
+ delete text;
+ }
+#endif
+ }
+ break;
+
+ case CE_CheckBox:
+ TQMotifStyle::drawControl( element, p, widget, r, cg, flags, opt );
+ break;
+
+ default:
+ TQMotifStyle::drawControl( element, p, widget, r, cg, flags, opt );
+ break;
+ }
+}
+
+/*! \reimp */
+void TQSGIStyle::drawComplexControl( ComplexControl control,
+ TQPainter *p,
+ const TQWidget* widget,
+ const TQRect& r,
+ const TQColorGroup& cg,
+ SFlags flags,
+ SCFlags sub,
+ SCFlags subActive,
+ const TQStyleOption& opt ) const
+{
+ if ( widget == d->hotWidget )
+ flags |= Style_MouseOver;
+
+ switch ( control ) {
+ case CC_Slider:
+ {
+#ifndef QT_NO_SLIDER
+ const TQSlider * slider = (const TQSlider *) widget;
+
+ TQRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
+ opt),
+ handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
+ opt);
+
+ if ((sub & SC_SliderGroove) && groove.isValid()) {
+ TQRegion region( groove );
+ if ( ( sub & SC_SliderHandle ) && handle.isValid() )
+ region = region.subtract( handle );
+ if ( d->lastSliderRect.slider == slider && d->lastSliderRect.rect.isValid() )
+ region = region.subtract( d->lastSliderRect.rect );
+ p->setClipRegion( region );
+
+ TQRect grooveTop = groove;
+ grooveTop.addCoords( 1, 1, -1, -1 );
+ drawPrimitive( PE_ButtonBevel, p, grooveTop, cg, flags & ~Style_MouseOver, opt );
+
+ if ( flags & Style_HasFocus ) {
+ TQRect fr = subRect( SR_SliderFocusRect, widget );
+ drawPrimitive( PE_FocusRect, p, fr, cg, flags & ~Style_MouseOver );
+ }
+
+ if ( d->lastSliderRect.slider == slider && d->lastSliderRect.rect.isValid() ) {
+ if ( ( sub & SC_SliderHandle ) && handle.isValid() ) {
+ region = widget->rect();
+ region = region.subtract( handle );
+ p->setClipRegion( region );
+ } else {
+ p->setClipping( FALSE );
+ }
+ qDrawShadePanel( p, d->lastSliderRect.rect, cg, TRUE, 1, &cg.brush( TQColorGroup::Dark ) );
+ }
+ p->setClipping( FALSE );
+ }
+
+ if (( sub & SC_SliderHandle ) && handle.isValid()) {
+ if ( flags & Style_MouseOver && !handle.contains( d->mousePos ) && subActive != SC_SliderHandle )
+ flags &= ~Style_MouseOver;
+ drawPrimitive( PE_ButtonBevel, p, handle, cg, flags );
+
+ if ( slider->orientation() == Horizontal ) {
+ TQCOORD mid = handle.x() + handle.width() / 2;
+ qDrawShadeLine( p, mid, handle.y(), mid,
+ handle.y() + handle.height() - 2,
+ cg, TRUE, 1);
+ } else {
+ TQCOORD mid = handle.y() + handle.height() / 2;
+ qDrawShadeLine( p, handle.x(), mid,
+ handle.x() + handle.width() - 2, mid,
+ cg, TRUE, 1);
+ }
+ }
+
+ if ( sub & SC_SliderTickmarks )
+ TQMotifStyle::drawComplexControl( control, p, widget, r, cg, flags,
+ SC_SliderTickmarks, subActive,
+ opt );
+#endif
+ break;
+ }
+ case CC_ComboBox:
+ {
+#ifndef QT_NO_COMBOBOX
+ const TQComboBox * cb = (TQComboBox *) widget;
+
+ if (sub & SC_ComboBoxFrame) {
+ TQRect fr =
+ TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb,
+ SC_ComboBoxFrame ), cb );
+ drawPrimitive( PE_ButtonBevel, p, fr, cg, flags );
+ }
+
+ if ( sub & SC_ComboBoxArrow ) {
+ p->save();
+ TQRect er =
+ TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb, SC_ComboBoxArrow ), cb );
+
+ er.addCoords( 0, 3, 0, 0 );
+
+ drawPrimitive( PE_ArrowDown, p, er, cg, flags | Style_Enabled, opt );
+
+ int awh, ax, ay, sh, sy, dh, ew;
+ get_combo_parameters( widget->rect(), ew, awh, ax, ay, sh, dh, sy );
+
+ TQBrush arrow = cg.brush( TQColorGroup::Dark );
+ p->fillRect( ax, sy-1, awh, sh, arrow );
+
+ p->restore();
+ if ( cb->hasFocus() ) {
+ TQRect re = TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), cb );
+ drawPrimitive( PE_FocusRect, p, re, cg );
+ }
+ }
+ if ( sub & SC_ComboBoxEditField ) {
+ if ( cb->editable() ) {
+ TQRect er =
+ TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb,
+ SC_ComboBoxEditField ), cb );
+ er.addCoords( -1, -1, 1, 1);
+ qDrawShadePanel( p, TQRect( er.x()-1, er.y()-1,
+ er.width()+2, er.height()+2 ),
+ cg, TRUE, 1, &cg.brush( TQColorGroup::Button ) );
+ }
+ }
+#endif
+ p->setPen(cg.buttonText());
+ break;
+ }
+
+ case CC_ScrollBar:
+ {
+#ifndef QT_NO_SCROLLBAR
+ TQScrollBar *scrollbar = (TQScrollBar*)widget;
+ bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue());
+ if ( maxedOut )
+ flags &= ~Style_Enabled;
+
+ TQRect handle = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSlider, opt ), widget );
+
+ if ( sub & SC_ScrollBarGroove ) {
+ }
+ if ( sub & SC_ScrollBarAddLine ) {
+ TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarAddLine, opt ), widget );
+ drawPrimitive( PE_ScrollBarAddLine, p, er, cg, flags, opt );
+ }
+ if ( sub & SC_ScrollBarSubLine ) {
+ TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSubLine, opt ), widget );
+ drawPrimitive( PE_ScrollBarSubLine, p, er, cg, flags, opt );
+ }
+ if ( sub & SC_ScrollBarAddPage ) {
+ TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarAddPage, opt ), widget );
+ TQRegion region( er );
+ if ( d->lastScrollbarRect.scrollbar == scrollbar &&
+ d->lastScrollbarRect.rect.isValid() &&
+ er.intersects( d->lastScrollbarRect.rect ) ) {
+ region = region.subtract( d->lastScrollbarRect.rect );
+ p->setClipRegion( region );
+ }
+ if ( sub & SC_ScrollBarSlider && er.intersects( handle ) ) {
+ region = region.subtract( handle );
+ p->setClipRegion( region );
+ }
+
+ drawPrimitive( PE_ScrollBarAddPage, p, er, cg, flags & ~Style_MouseOver, opt );
+
+ if ( d->lastScrollbarRect.scrollbar == scrollbar &&
+ d->lastScrollbarRect.rect.isValid() &&
+ er.intersects( d->lastScrollbarRect.rect ) ) {
+ if ( sub & SC_ScrollBarSlider && handle.isValid() ) {
+ region = er;
+ region.subtract( handle );
+ p->setClipRegion( region );
+ } else {
+ p->setClipping( FALSE );
+ }
+ qDrawShadePanel( p, d->lastScrollbarRect.rect, cg, TRUE, 1, &cg.brush( TQColorGroup::Dark ) );
+ }
+ p->setClipping( FALSE );
+ }
+ if ( sub & SC_ScrollBarSubPage ) {
+ TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSubPage, opt ), widget );
+ TQRegion region( er );
+ if ( d->lastScrollbarRect.scrollbar == scrollbar &&
+ d->lastScrollbarRect.rect.isValid() &&
+ er.intersects( d->lastScrollbarRect.rect ) ) {
+ region = region.subtract( d->lastScrollbarRect.rect );
+ p->setClipRegion( region );
+ }
+ if ( sub & SC_ScrollBarSlider && er.intersects( handle ) ) {
+ region = region.subtract( handle );
+ p->setClipRegion( region );
+ }
+ drawPrimitive( PE_ScrollBarSubPage, p, er, cg, flags & ~Style_MouseOver, opt );
+ if ( d->lastScrollbarRect.scrollbar == scrollbar &&
+ d->lastScrollbarRect.rect.isValid() &&
+ er.intersects( d->lastScrollbarRect.rect ) ) {
+ if ( sub & SC_ScrollBarSlider && handle.isValid() ) {
+ region = er;
+ region.subtract( handle );
+ p->setClipRegion( region );
+ } else {
+ p->setClipping( FALSE );
+ }
+ qDrawShadePanel( p, d->lastScrollbarRect.rect, cg, TRUE, 1, &cg.brush( TQColorGroup::Dark ) );
+ }
+ p->setClipping( FALSE );
+ }
+ if ( sub & SC_ScrollBarSlider ) {
+ p->setClipping( FALSE );
+ if ( subActive == SC_ScrollBarSlider )
+ flags |= Style_Active;
+
+ drawPrimitive( PE_ScrollBarSlider, p, handle, cg, flags, opt );
+ }
+#endif
+ }
+ break;
+
+ default:
+ TQMotifStyle::drawComplexControl( control, p, widget, r, cg, flags, sub, subActive, opt );
+ break;
+ }
+}
+
+/*!\reimp
+*/
+TQSize TQSGIStyle::sizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& opt ) const
+{
+ TQSize sz(contentsSize);
+
+ switch(contents) {
+ case CT_PopupMenuItem:
+ {
+#ifndef QT_NO_POPUPMENU
+ if (! widget || opt.isDefault())
+ break;
+
+ TQMenuItem *mi = opt.menuItem();
+ sz = TQMotifStyle::sizeFromContents( contents, widget, contentsSize,
+ opt );
+ // SGI checkmark items needs a bit more room
+ const TQPopupMenu *popup = (TQPopupMenu *) widget;
+ if ( popup && popup->isCheckable() )
+ sz.setWidth( sz.width() + 8 );
+ // submenu indicator needs a bit more room
+ if (mi->popup())
+ sz.setWidth( sz.width() + sgiTabSpacing );
+#endif
+ break;
+ }
+ case CT_ComboBox:
+ sz.rwidth() += 30;
+ break;
+
+ default:
+ sz = TQMotifStyle::sizeFromContents( contents, widget, contentsSize, opt );
+ break;
+ }
+
+ return sz;
+}
+
+/*! \reimp */
+TQRect TQSGIStyle::subRect( SubRect r, const TQWidget *widget ) const
+{
+ TQRect rect;
+
+ switch ( r ) {
+ case SR_ComboBoxFocusRect:
+ {
+ int awh, ax, ay, sh, sy, dh, ew;
+ int fw = pixelMetric( PM_DefaultFrameWidth, widget );
+ TQRect tr = widget->rect();
+
+ tr.addCoords( fw, fw, -fw, -fw );
+ get_combo_parameters( tr, ew, awh, ax, ay, sh, dh, sy );
+ rect.setRect(ax-2, ay-2, awh+4, awh+sh+dh+4);
+ }
+ break;
+ default:
+ return TQMotifStyle::subRect( r, widget );
+ }
+
+ return rect;
+}
+
+/*! \reimp */
+TQRect TQSGIStyle::querySubControlMetrics( ComplexControl control,
+ const TQWidget *widget,
+ SubControl sub,
+ const TQStyleOption& opt ) const
+{
+ switch ( control ) {
+ case CC_ComboBox:
+ switch ( sub ) {
+ case SC_ComboBoxFrame:
+ return widget->rect();
+
+ case SC_ComboBoxArrow: {
+ int ew, awh, sh, dh, ax, ay, sy;
+ int fw = pixelMetric( PM_DefaultFrameWidth, widget );
+ TQRect cr = widget->rect();
+ cr.addCoords( fw, fw, -fw, -fw );
+ get_combo_parameters( cr, ew, awh, ax, ay, sh, dh, sy );
+ return TQRect( ax, ay, awh, awh ); }
+
+ case SC_ComboBoxEditField: {
+ int fw = pixelMetric( PM_DefaultFrameWidth, widget );
+ TQRect rect = widget->rect();
+ rect.addCoords( fw, fw, -fw, -fw );
+ int ew = get_combo_extra_width( rect.height() );
+ rect.addCoords( 1, 1, -1-ew, -1 );
+ return rect; }
+
+ default:
+ break;
+ }
+ break;
+ case CC_ScrollBar:
+ return TQCommonStyle::querySubControlMetrics( control, widget, sub, opt );
+ default: break;
+ }
+ return TQMotifStyle::querySubControlMetrics( control, widget, sub, opt );
+}
+
+#endif // QT_NO_STYLE_SGI
diff --git a/src/styles/qsgistyle.h b/src/styles/qsgistyle.h
new file mode 100644
index 000000000..d12a7ebe4
--- /dev/null
+++ b/src/styles/qsgistyle.h
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Definition of SGI-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQSGISTYLE_H
+#define TQSGISTYLE_H
+
+#ifndef QT_H
+#include "qmotifstyle.h"
+#include "qguardedptr.h"
+#include "qwidget.h"
+#endif // QT_H
+
+#if !defined(QT_NO_STYLE_SGI) || defined(QT_PLUGIN)
+
+#if defined(QT_PLUGIN)
+#define Q_EXPORT_STYLE_SGI
+#else
+#define Q_EXPORT_STYLE_SGI Q_EXPORT
+#endif
+
+class TQSGIStylePrivate;
+
+class Q_EXPORT_STYLE_SGI TQSGIStyle: public TQMotifStyle
+{
+ Q_OBJECT
+public:
+ TQSGIStyle( bool useHighlightCols = FALSE );
+ virtual ~TQSGIStyle();
+
+#if !defined(Q_NO_USING_KEYWORD)
+ using TQMotifStyle::polish;
+#endif
+ void polish( TQWidget* );
+ void unPolish( TQWidget* );
+ void polish( TQApplication* );
+ void unPolish( TQApplication* );
+
+ void drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawComplexControl( ComplexControl control,
+ TQPainter *p,
+ const TQWidget* widget,
+ const TQRect& r,
+ const TQColorGroup& cg,
+ SFlags how = Style_Default,
+#ifdef Q_QDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int pixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const;
+
+ TQSize sizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect subRect( SubRect r, const TQWidget *widget ) const;
+ TQRect querySubControlMetrics( ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+protected:
+ bool eventFilter( TQObject*, TQEvent*);
+
+private:
+ TQSGIStylePrivate *d;
+
+ uint isApplicationStyle :1;
+#if defined(Q_DISABLE_COPY)
+ TQSGIStyle( const TQSGIStyle & );
+ TQSGIStyle& operator=( const TQSGIStyle & );
+#endif
+
+};
+
+#endif // QT_NO_STYLE_SGI
+
+#endif // TQSGISTYLE_H
diff --git a/src/styles/qstylefactory.cpp b/src/styles/qstylefactory.cpp
new file mode 100644
index 000000000..05d1b16f2
--- /dev/null
+++ b/src/styles/qstylefactory.cpp
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Implementation of TQStyleFactory class
+**
+** Created : 001103
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qstyleinterface_p.h" // up here for GCC 2.7.* compatibility
+#include "qstylefactory.h"
+
+#ifndef QT_NO_STYLE
+
+#include "qapplication.h"
+#include "qwindowsstyle.h"
+#include "qmotifstyle.h"
+#include "qcdestyle.h"
+#include "qmotifplusstyle.h"
+#include "qplatinumstyle.h"
+#include "qsgistyle.h"
+#include "qcompactstyle.h"
+#ifndef QT_NO_STYLE_WINDOWSXP
+#include "qwindowsxpstyle.h"
+#endif
+#ifndef QT_NO_STYLE_AQUA
+#include "qaquastyle.h"
+#endif
+#ifndef QT_NO_STYLE_POCKETPC
+#include "qpocketpcstyle_wce.h"
+#endif
+
+#if !defined( QT_NO_STYLE_MAC ) && defined( Q_WS_MAC )
+TQString p2qstring(const unsigned char *c); //qglobal.cpp
+#include "qt_mac.h"
+#include "qmacstyle_mac.h"
+#endif
+#include <stdlib.h>
+
+#include <private/qpluginmanager_p.h>
+#ifndef QT_NO_COMPONENT
+class TQStyleFactoryPrivate : public TQObject
+{
+public:
+ TQStyleFactoryPrivate();
+ ~TQStyleFactoryPrivate();
+
+ static TQPluginManager<TQStyleFactoryInterface> *manager;
+};
+
+static TQStyleFactoryPrivate *instance = 0;
+TQPluginManager<TQStyleFactoryInterface> *TQStyleFactoryPrivate::manager = 0;
+
+TQStyleFactoryPrivate::TQStyleFactoryPrivate()
+: TQObject( qApp )
+{
+ manager = new TQPluginManager<TQStyleFactoryInterface>( IID_QStyleFactory, TQApplication::libraryPaths(), "/styles", FALSE );
+}
+
+TQStyleFactoryPrivate::~TQStyleFactoryPrivate()
+{
+ delete manager;
+ manager = 0;
+
+ instance = 0;
+}
+
+#endif //QT_NO_COMPONENT
+
+/*!
+ \class TQStyleFactory qstylefactory.h
+ \brief The TQStyleFactory class creates TQStyle objects.
+
+ The style factory creates a TQStyle object for a given key with
+ TQStyleFactory::create(key).
+
+ The styles are either built-in or dynamically loaded from a style
+ plugin (see \l TQStylePlugin).
+
+ TQStyleFactory::keys() returns a list of valid keys, typically
+ including "Windows", "Motif", "CDE", "MotifPlus", "Platinum",
+ "SGI" and "Compact". Depending on the platform, "WindowsXP",
+ "Aqua" or "Macintosh" may be available.
+*/
+
+/*!
+ Creates a TQStyle object that matches \a key case-insensitively.
+ This is either a built-in style, or a style from a style plugin.
+
+ \sa keys()
+*/
+TQStyle *TQStyleFactory::create( const TQString& key )
+{
+ TQStyle *ret = 0;
+ TQString style = key.lower();
+#ifndef QT_NO_STYLE_WINDOWS
+ if ( style == "windows" )
+ ret = new TQWindowsStyle;
+ else
+#endif
+#ifndef QT_NO_STYLE_WINDOWSXP
+ if ( style == "windowsxp" )
+ ret = new TQWindowsXPStyle;
+ else
+#endif
+#ifndef QT_NO_STYLE_MOTIF
+ if ( style == "motif" )
+ ret = new TQMotifStyle;
+ else
+#endif
+#ifndef QT_NO_STYLE_CDE
+ if ( style == "cde" )
+ ret = new TQCDEStyle;
+ else
+#endif
+#ifndef QT_NO_STYLE_MOTIFPLUS
+ if ( style == "motifplus" )
+ ret = new TQMotifPlusStyle;
+ else
+#endif
+#ifndef QT_NO_STYLE_PLATINUM
+ if ( style == "platinum" )
+ ret = new TQPlatinumStyle;
+ else
+#endif
+#ifndef QT_NO_STYLE_SGI
+ if ( style == "sgi")
+ ret = new TQSGIStyle;
+ else
+#endif
+#ifndef QT_NO_STYLE_COMPACT
+ if ( style == "compact" )
+ ret = new TQCompactStyle;
+ else
+#endif
+#ifndef QT_NO_STYLE_AQUA
+ if ( style == "aqua" )
+ ret = new TQAquaStyle;
+#endif
+#ifndef QT_NO_STYLE_POCKETPC
+ if ( style == "pocketpc" )
+ ret = new TQPocketPCStyle;
+#endif
+#if !defined( QT_NO_STYLE_MAC ) && defined( Q_WS_MAC )
+ if( style.left(9) == "macintosh" )
+ ret = new TQMacStyle;
+#endif
+ { } // Keep these here - they make the #ifdefery above work
+
+#ifndef QT_NO_COMPONENT
+ if(!ret) {
+ if ( !instance )
+ instance = new TQStyleFactoryPrivate;
+
+ TQInterfacePtr<TQStyleFactoryInterface> iface;
+ TQStyleFactoryPrivate::manager->queryInterface( style, &iface );
+
+ if ( iface )
+ ret = iface->create( style );
+ }
+ if(ret)
+ ret->setName(key);
+#endif
+ return ret;
+}
+
+#ifndef QT_NO_STRINGLIST
+/*!
+ Returns the list of keys this factory can create styles for.
+
+ \sa create()
+*/
+TQStringList TQStyleFactory::keys()
+{
+ TQStringList list;
+#ifndef QT_NO_COMPONENT
+ if ( !instance )
+ instance = new TQStyleFactoryPrivate;
+
+ list = TQStyleFactoryPrivate::manager->featureList();
+#endif //QT_NO_COMPONENT
+
+#ifndef QT_NO_STYLE_WINDOWS
+ if ( !list.contains( "Windows" ) )
+ list << "Windows";
+#endif
+#ifndef QT_NO_STYLE_WINDOWSXP
+ if ( !list.contains( "WindowsXP" ) && TQWindowsXPStyle::resolveSymbols() )
+ list << "WindowsXP";
+#endif
+#ifndef QT_NO_STYLE_MOTIF
+ if ( !list.contains( "Motif" ) )
+ list << "Motif";
+#endif
+#ifndef QT_NO_STYLE_CDE
+ if ( !list.contains( "CDE" ) )
+ list << "CDE";
+#endif
+#ifndef QT_NO_STYLE_MOTIFPLUS
+ if ( !list.contains( "MotifPlus" ) )
+ list << "MotifPlus";
+#endif
+#ifndef QT_NO_STYLE_PLATINUM
+ if ( !list.contains( "Platinum" ) )
+ list << "Platinum";
+#endif
+#ifndef QT_NO_STYLE_SGI
+ if ( !list.contains( "SGI" ) )
+ list << "SGI";
+#endif
+#ifndef QT_NO_STYLE_COMPACT
+ if ( !list.contains( "Compact" ) )
+ list << "Compact";
+#endif
+#ifndef QT_NO_STYLE_AQUA
+ if ( !list.contains( "Aqua" ) )
+ list << "Aqua";
+#endif
+#if !defined( QT_NO_STYLE_MAC ) && defined( Q_WS_MAC )
+ TQString mstyle = "Macintosh";
+ Collection c = NewCollection();
+ if (c) {
+ GetTheme(c);
+ Str255 str;
+ long int s = 256;
+ if(!GetCollectionItem(c, kThemeNameTag, 0, &s, &str))
+ mstyle += " (" + p2qstring(str) + ")";
+ }
+ if (!list.contains(mstyle))
+ list << mstyle;
+ DisposeCollection(c);
+#endif
+
+ return list;
+}
+#endif
+#endif // QT_NO_STYLE
diff --git a/src/styles/qstylefactory.h b/src/styles/qstylefactory.h
new file mode 100644
index 000000000..ccb133576
--- /dev/null
+++ b/src/styles/qstylefactory.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** ...
+**
+** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQSTYLEFACTORY_H
+#define TQSTYLEFACTORY_H
+
+#ifndef QT_H
+#include "qstringlist.h"
+#endif // QT_H
+
+#ifndef QT_NO_STYLE
+
+class TQString;
+class TQStyle;
+
+class Q_EXPORT TQStyleFactory
+{
+public:
+#ifndef QT_NO_STRINGLIST
+ static TQStringList keys();
+#endif
+ static TQStyle *create( const TQString& );
+};
+
+#endif //QT_NO_STYLE
+
+#endif //TQSTYLEFACTORY_H
diff --git a/src/styles/qstyleinterface_p.h b/src/styles/qstyleinterface_p.h
new file mode 100644
index 000000000..f636ee420
--- /dev/null
+++ b/src/styles/qstyleinterface_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** ...
+**
+** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQSTYLEINTERFACE_P_H
+#define TQSTYLEINTERFACE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the TQt API. This header file may
+// change from version to version without notice, or even be
+// removed.
+//
+// We mean it.
+//
+//
+
+#ifndef QT_H
+#include <private/qcom_p.h>
+#endif // QT_H
+
+#ifndef QT_NO_STYLE
+#ifndef QT_NO_COMPONENT
+
+class TQStyle;
+
+// {FC1B6EBE-053C-49c1-A483-C377739AB9A5}
+#ifndef IID_QStyleFactory
+#define IID_QStyleFactory TQUuid(0xfc1b6ebe, 0x53c, 0x49c1, 0xa4, 0x83, 0xc3, 0x77, 0x73, 0x9a, 0xb9, 0xa5)
+#endif
+
+struct Q_EXPORT TQStyleFactoryInterface : public TQFeatureListInterface
+{
+ virtual TQStyle* create( const TQString& style ) = 0;
+};
+
+#endif //QT_NO_COMPONENT
+#endif //QT_NO_STYLE
+
+#endif //TQSTYLEINTERFACE_P_H
diff --git a/src/styles/qstyleplugin.cpp b/src/styles/qstyleplugin.cpp
new file mode 100644
index 000000000..3e0b707dc
--- /dev/null
+++ b/src/styles/qstyleplugin.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Implementation of TQSqlDriverPlugin class
+**
+** Created : 010920
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qstyleplugin.h"
+
+#ifndef QT_NO_STYLE
+#ifndef QT_NO_COMPONENT
+
+#include "qstyleinterface_p.h"
+#include "qobjectcleanuphandler.h"
+#include "qstyle.h"
+
+/*!
+ \class TQStylePlugin qstyleplugin.h
+ \brief The TQStylePlugin class provides an abstract base for custom TQStyle plugins.
+
+ \ingroup plugins
+
+ The style plugin is a simple plugin interface that makes it easy
+ to create custom styles that can be loaded dynamically into
+ applications with a TQStyleFactory.
+
+ Writing a style plugin is achieved by subclassing this base class,
+ reimplementing the pure virtual functions keys() and create(), and
+ exporting the class with the \c Q_EXPORT_PLUGIN macro. See the
+ \link plugins-howto.html plugins documentation\endlink for an
+ example.
+*/
+
+/*!
+ \fn TQStringList TQStylePlugin::keys() const
+
+ Returns the list of style keys this plugin supports.
+
+ These keys are usually the class names of the custom styles that
+ are implemented in the plugin.
+
+ \sa create()
+*/
+
+/*!
+ \fn TQStyle* TQStylePlugin::create( const TQString& key )
+
+ Creates and returns a TQStyle object for the style key \a key. The
+ style key is usually the class name of the retquired style.
+
+ \sa keys()
+*/
+
+class TQStylePluginPrivate : public TQStyleFactoryInterface, public TQLibraryInterface
+{
+public:
+ TQStylePluginPrivate( TQStylePlugin *p )
+ : plugin( p )
+ {
+ }
+
+ virtual ~TQStylePluginPrivate();
+
+ TQRESULT queryInterface( const TQUuid &iid, TQUnknownInterface **iface );
+ Q_REFCOUNT;
+
+ TQStringList featureList() const;
+ TQStyle *create( const TQString &key );
+
+ bool init();
+ void cleanup();
+ bool canUnload() const;
+
+private:
+ TQStylePlugin *plugin;
+ TQObjectCleanupHandler styles;
+};
+
+TQRESULT TQStylePluginPrivate::queryInterface( const TQUuid &iid, TQUnknownInterface **iface )
+{
+ *iface = 0;
+
+ if ( iid == IID_QUnknown )
+ *iface = (TQStyleFactoryInterface*)this;
+ else if ( iid == IID_QFeatureList )
+ *iface = (TQFeatureListInterface*)this;
+ else if ( iid == IID_QStyleFactory )
+ *iface = (TQStyleFactoryInterface*)this;
+ else if ( iid == IID_QLibrary )
+ *iface = (TQLibraryInterface*) this;
+ else
+ return TQE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return TQS_OK;
+}
+
+TQStylePluginPrivate::~TQStylePluginPrivate()
+{
+ delete plugin;
+}
+
+TQStringList TQStylePluginPrivate::featureList() const
+{
+ return plugin->keys();
+}
+
+TQStyle *TQStylePluginPrivate::create( const TQString &key )
+{
+ TQStyle *st = plugin->create( key );
+ styles.add( st );
+ return st;
+}
+
+bool TQStylePluginPrivate::init()
+{
+ return TRUE;
+}
+
+void TQStylePluginPrivate::cleanup()
+{
+ styles.clear();
+}
+
+bool TQStylePluginPrivate::canUnload() const
+{
+ return styles.isEmpty();
+}
+
+
+/*!
+ Constructs a style plugin. This is invoked automatically by the
+ \c Q_EXPORT_PLUGIN macro.
+*/
+TQStylePlugin::TQStylePlugin()
+ : TQGPlugin( (TQStyleFactoryInterface*)(d = new TQStylePluginPrivate( this )) )
+{
+}
+
+/*!
+ Destroys the style plugin.
+
+ You never have to call this explicitly. TQt destroys a plugin
+ automatically when it is no longer used.
+*/
+TQStylePlugin::~TQStylePlugin()
+{
+ // don't delete d, as this is deleted by d
+}
+
+#endif // QT_NO_COMPONENT
+#endif // QT_NO_STYLE
diff --git a/src/styles/qstyleplugin.h b/src/styles/qstyleplugin.h
new file mode 100644
index 000000000..0aa264372
--- /dev/null
+++ b/src/styles/qstyleplugin.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Definition of TQStylePlugin class
+**
+** Created : 010920
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQSTYLEPLUGIN_H
+#define TQSTYLEPLUGIN_H
+
+#ifndef QT_H
+#include "qgplugin.h"
+#include "qstringlist.h"
+#endif // QT_H
+
+#ifndef QT_NO_STYLE
+#ifndef QT_NO_COMPONENT
+
+class TQStyle;
+class TQStylePluginPrivate;
+
+class Q_EXPORT TQStylePlugin : public TQGPlugin
+{
+ Q_OBJECT
+public:
+ TQStylePlugin();
+ ~TQStylePlugin();
+
+ virtual TQStringList keys() const = 0;
+ virtual TQStyle *create( const TQString &key ) = 0;
+
+private:
+ TQStylePluginPrivate *d;
+};
+
+#endif // QT_NO_COMPONENT
+#endif // QT_NO_STYLE
+
+#endif // TQSTYLEPLUGIN_H
diff --git a/src/styles/qt_styles.pri b/src/styles/qt_styles.pri
new file mode 100644
index 000000000..8387268c0
--- /dev/null
+++ b/src/styles/qt_styles.pri
@@ -0,0 +1,140 @@
+# Qt styles module
+
+styles {
+ STYLES_P = styles
+ HEADERS +=$$STYLES_H/qstylefactory.h \
+ $$STYLES_P/qstyleinterface_p.h \
+ $$STYLES_H/qstyleplugin.h \
+ $$STYLES_H/qcommonstyle.h
+ SOURCES +=$$STYLES_CPP/qstylefactory.cpp \
+ $$STYLES_CPP/qstyleplugin.cpp \
+ $$STYLES_CPP/qcommonstyle.cpp
+
+ contains( styles, all ) {
+ styles += mac cde motifplus sgi platinum compact interlace windows motif
+ }
+
+ x11|embedded|!macx-*:styles -= mac
+ contains( styles, mac ) {
+ HEADERS +=$$STYLES_H/qmacstyle_mac.h \
+ $$STYLES_H/qmacstylepixmaps_mac_p.h
+ SOURCES +=$$STYLES_CPP/qmacstyle_mac.cpp
+ HEADERS *= $$STYLES_CPP/qaquastyle_p.h
+ SOURCES *= $$STYLES_CPP/qaquastyle_p.cpp
+
+ !contains( styles, windows ) {
+ message( mac retquires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_MAC
+
+ #embedded|!macx-*:styles -= aqua
+ contains( styles, aqua ) {
+ HEADERS += $$STYLES_H/qaquastyle.h
+ SOURCES += $$STYLES_CPP/qaquastyle.cpp
+ HEADERS *= $$STYLES_CPP/qaquastyle_p.h
+ SOURCES *= $$STYLES_CPP/qaquastyle_p.cpp
+
+ !contains( styles, windows ) {
+ message( aqua retquires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_AQUA
+
+ contains( styles, cde ) {
+ HEADERS +=$$STYLES_H/qcdestyle.h
+ SOURCES +=$$STYLES_CPP/qcdestyle.cpp
+
+ !contains( styles, motif ) {
+ message( cde retquires motif )
+ styles += motif
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_CDE
+
+ contains( styles, motifplus ) {
+ HEADERS +=$$STYLES_H/qmotifplusstyle.h
+ SOURCES +=$$STYLES_CPP/qmotifplusstyle.cpp
+ !contains( styles, motif ) {
+ message( motifplus retquires motif )
+ styles += motif
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_MOTIFPLUS
+
+ contains( styles, interlace ) {
+ HEADERS +=$$STYLES_H/qinterlacestyle.h
+ SOURCES +=$$STYLES_CPP/qinterlacestyle.cpp
+ !contains( styles, windows ) {
+ message( interlace retquires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_INTERLACE
+
+ contains( styles, platinum ) {
+ HEADERS +=$$STYLES_H/qplatinumstyle.h
+ SOURCES +=$$STYLES_CPP/qplatinumstyle.cpp
+ !contains( styles, windows ) {
+ message( platinum retquires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_PLATINUM
+
+ contains( styles, windowsxp ) {
+ HEADERS +=$$STYLES_H/qwindowsxpstyle.h
+ SOURCES +=$$STYLES_CPP/qwindowsxpstyle.cpp
+ !contains( styles, windowsxp ) {
+ message( windowsxp retquires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_WINDOWSXP
+
+ contains( styles, sgi ) {
+ HEADERS +=$$STYLES_H/qsgistyle.h
+ SOURCES +=$$STYLES_CPP/qsgistyle.cpp
+ !contains( styles, motif ) {
+ message( sgi retquires motif )
+ styles += motif
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_SGI
+
+ contains( styles, compact ) {
+ HEADERS +=$$STYLES_H/qcompactstyle.h
+ SOURCES +=$$STYLES_CPP/qcompactstyle.cpp
+ !contains( styles, windows ) {
+ message( compact retquires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_COMPACT
+
+ wince-*:styles += pocketpc
+ contains( styles, pocketpc ) {
+ HEADERS +=$$STYLES_H/qpocketpcstyle_wce.h
+ SOURCES +=$$STYLES_CPP/qpocketpcstyle_wce.cpp
+
+ !contains( styles, windows ) {
+ message( pocketpc retquires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += QT_NO_STYLE_POCKETPC
+
+ contains( styles, windows ) {
+ HEADERS +=$$STYLES_H/qwindowsstyle.h
+ SOURCES +=$$STYLES_CPP/qwindowsstyle.cpp
+ }
+ else:DEFINES += QT_NO_STYLE_WINDOWS
+
+ contains( styles, motif ) {
+ HEADERS +=$$STYLES_H/qmotifstyle.h
+ SOURCES +=$$STYLES_CPP/qmotifstyle.cpp
+ }
+ else:DEFINES += QT_NO_STYLE_MOTIF
+}
diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp
new file mode 100644
index 000000000..c0c5533ce
--- /dev/null
+++ b/src/styles/qwindowsstyle.cpp
@@ -0,0 +1,2161 @@
+/****************************************************************************
+**
+** Implementation of Windows-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "qwindowsstyle.h"
+
+#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
+
+#include "qpopupmenu.h"
+#include "qapplication.h"
+#include "qpainter.h"
+#include "qdrawutil.h" // for now
+#include "qpixmap.h" // for now
+#include "qwidget.h"
+#include "qlabel.h"
+#include "qimage.h"
+#include "qpushbutton.h"
+#include "qcombobox.h"
+#include "qlistbox.h"
+#include "qwidget.h"
+#include "qrangecontrol.h"
+#include "qscrollbar.h"
+#include "qslider.h"
+#include "qtabwidget.h"
+#include "qtabbar.h"
+#include "qlistview.h"
+#include "qbitmap.h"
+#include "qcleanuphandler.h"
+#include "qdockwindow.h"
+#include "qobjectlist.h"
+#include "qmenubar.h"
+
+#if defined(Q_WS_WIN)
+#include "qt_windows.h"
+#endif
+
+#include <limits.h>
+
+
+static const int windowsItemFrame = 2; // menu item frame width
+static const int windowsSepHeight = 2; // separator item height
+static const int windowsItemHMargin = 3; // menu item hor text margin
+static const int windowsItemVMargin = 2; // menu item ver text margin
+static const int windowsArrowHMargin = 6; // arrow horizontal margin
+static const int windowsTabSpacing = 12; // space between text and tab
+static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark
+static const int windowsRightBorder = 12; // right border on windows
+static const int windowsCheckMarkWidth = 12; // checkmarks width on windows
+
+static bool use2000style = TRUE;
+
+enum TQSliderDirection { SlUp, SlDown, SlLeft, SlRight };
+
+// A friendly class providing access to TQMenuData's protected member.
+class FriendlyMenuData : public TQMenuData
+{
+ friend class TQWindowsStyle;
+};
+
+// Private class
+class TQWindowsStyle::Private : public TQObject
+{
+public:
+ Private(TQWindowsStyle *parent);
+
+ bool hasSeenAlt(const TQWidget *widget) const;
+ bool altDown() const { return alt_down; }
+
+protected:
+ bool eventFilter(TQObject *o, TQEvent *e);
+
+private:
+ TQPtrList<TQWidget> seenAlt;
+ bool alt_down;
+ int menuBarTimer;
+};
+
+TQWindowsStyle::Private::Private(TQWindowsStyle *parent)
+: TQObject(parent, "TQWindowsStylePrivate"), alt_down(FALSE), menuBarTimer(0)
+{
+}
+
+// Returns true if the toplevel parent of \a widget has seen the Alt-key
+bool TQWindowsStyle::Private::hasSeenAlt(const TQWidget *widget) const
+{
+ widget = widget->topLevelWidget();
+ return seenAlt.contains(widget);
+}
+
+// Records Alt- and Focus events
+bool TQWindowsStyle::Private::eventFilter(TQObject *o, TQEvent *e)
+{
+ if (!o->isWidgetType())
+ return TQObject::eventFilter(o, e);
+
+ TQWidget *widget = ::qt_cast<TQWidget*>(o);
+
+ switch(e->type()) {
+ case TQEvent::KeyPress:
+ if (((TQKeyEvent*)e)->key() == Key_Alt) {
+ widget = widget->topLevelWidget();
+
+ // Alt has been pressed - find all widgets that care
+ TQObjectList *l = widget->queryList("TQWidget");
+ TQObjectListIt it( *l );
+ TQWidget *w;
+ while ( (w = (TQWidget*)it.current()) != 0 ) {
+ ++it;
+ if (w->isTopLevel() || !w->isVisible() ||
+ w->style().styleHint(SH_UnderlineAccelerator, w))
+ l->removeRef(w);
+ }
+ // Update states before repainting
+ seenAlt.append(widget);
+ alt_down = TRUE;
+
+ // Repaint all relevant widgets
+ it.toFirst();
+ while ( (w = (TQWidget*)it.current()) != 0 ) {
+ ++it;
+ w->repaint(FALSE);
+ }
+ delete l;
+ }
+ break;
+ case TQEvent::KeyRelease:
+ if (((TQKeyEvent*)e)->key() == Key_Alt) {
+ widget = widget->topLevelWidget();
+
+ // Update state
+ alt_down = FALSE;
+ // Repaint only menubars
+ TQObjectList *l = widget->queryList("TQMenuBar");
+ TQObjectListIt it( *l );
+ TQMenuBar *menuBar;
+ while ( (menuBar = (TQMenuBar*)it.current()) != 0) {
+ ++it;
+ menuBar->repaint(FALSE);
+ }
+ }
+ break;
+ case TQEvent::FocusIn:
+ case TQEvent::FocusOut:
+ {
+ // Menubars toggle based on focus
+ TQMenuBar *menuBar = ::qt_cast<TQMenuBar*>(o);
+ if (menuBar && !menuBarTimer) // delayed repaint to avoid flicker
+ menuBarTimer = menuBar->startTimer(0);
+ }
+ break;
+ case TQEvent::Close:
+ // Reset widget when closing
+ seenAlt.removeRef(widget);
+ seenAlt.removeRef(widget->topLevelWidget());
+ break;
+ case TQEvent::Timer:
+ {
+ TQMenuBar *menuBar = ::qt_cast<TQMenuBar*>(o);
+ TQTimerEvent *te = (TQTimerEvent*)e;
+ if (menuBar && te->timerId() == menuBarTimer) {
+ menuBar->killTimer(te->timerId());
+ menuBarTimer = 0;
+ menuBar->repaint(FALSE);
+ return TRUE;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return TQObject::eventFilter(o, e);
+}
+
+/*!
+ \class TQWindowsStyle qwindowsstyle.h
+ \brief The TQWindowsStyle class provides a Microsoft Windows-like look and feel.
+
+ \ingroup appearance
+
+ This style is TQt's default GUI style on Windows.
+*/
+
+/*!
+ Constructs a TQWindowsStyle
+*/
+TQWindowsStyle::TQWindowsStyle() : TQCommonStyle(), d(0)
+{
+#if defined(Q_OS_WIN32)
+ use2000style = qWinVersion() != TQt::WV_NT && qWinVersion() != TQt::WV_95;
+#endif
+}
+
+/*! \reimp */
+TQWindowsStyle::~TQWindowsStyle()
+{
+ delete d;
+}
+
+/*! \reimp */
+void TQWindowsStyle::polish(TQApplication *app)
+{
+ // We only need the overhead when shortcuts are sometimes hidden
+ if (!styleHint(SH_UnderlineAccelerator, 0)) {
+ d = new Private(this);
+ app->installEventFilter(d);
+ }
+}
+
+/*! \reimp */
+void TQWindowsStyle::unPolish(TQApplication *)
+{
+ delete d;
+ d = 0;
+}
+
+/*! \reimp */
+void TQWindowsStyle::polish(TQWidget *widget)
+{
+ TQCommonStyle::polish(widget);
+}
+
+/*! \reimp */
+void TQWindowsStyle::unPolish(TQWidget *widget)
+{
+ TQCommonStyle::polish(widget);
+}
+
+/*! \reimp */
+void TQWindowsStyle::polish( TQPalette &pal )
+{
+ TQCommonStyle::polish(pal);
+}
+
+/*! \reimp */
+void TQWindowsStyle::drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ TQRect rr( r );
+ switch (pe) {
+ case PE_ButtonCommand:
+ {
+ TQBrush fill;
+
+ if (! (flags & Style_Down) && (flags & Style_On))
+ fill = TQBrush(cg.light(), Dense4Pattern);
+ else
+ fill = cg.brush(TQColorGroup::Button);
+
+ if (flags & Style_ButtonDefault && flags & Style_Down) {
+ p->setPen(cg.dark());
+ p->setBrush(fill);
+ p->drawRect(r);
+ } else if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
+ qDrawWinButton(p, r, cg, flags & (Style_Sunken | Style_Down |
+ Style_On), &fill);
+ else
+ p->fillRect(r, fill);
+ break;
+ }
+
+ case PE_ButtonBevel:
+ case PE_HeaderSection:
+ {
+ TQBrush fill;
+
+ if (! (flags & Style_Down) && (flags & Style_On))
+ fill = TQBrush(cg.light(), Dense4Pattern);
+ else
+ fill = cg.brush(TQColorGroup::Button);
+
+ if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
+ qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On), &fill);
+ else
+ p->fillRect(r, fill);
+ break;
+ }
+#if defined(Q_WS_WIN)
+ case PE_HeaderArrow:
+ p->save();
+ if ( flags & Style_Up ) { // invert logic to follow Windows style guide
+ TQPointArray pa( 3 );
+ p->setPen( cg.light() );
+ p->drawLine( r.x() + r.width(), r.y(), r.x() + r.width() / 2, r.height() );
+ p->setPen( cg.dark() );
+ pa.setPoint( 0, r.x() + r.width() / 2, r.height() );
+ pa.setPoint( 1, r.x(), r.y() );
+ pa.setPoint( 2, r.x() + r.width(), r.y() );
+ p->drawPolyline( pa );
+ } else {
+ TQPointArray pa( 3 );
+ p->setPen( cg.light() );
+ pa.setPoint( 0, r.x(), r.height() );
+ pa.setPoint( 1, r.x() + r.width(), r.height() );
+ pa.setPoint( 2, r.x() + r.width() / 2, r.y() );
+ p->drawPolyline( pa );
+ p->setPen( cg.dark() );
+ p->drawLine( r.x(), r.height(), r.x() + r.width() / 2, r.y() );
+ }
+ p->restore();
+ break;
+#endif
+
+ case PE_ButtonDefault:
+ p->setPen(cg.shadow());
+ p->drawRect(r);
+ break;
+
+ case PE_ButtonTool:
+ {
+ TQBrush fill;
+ bool stippled = FALSE;
+
+ if (! (flags & (Style_Down | Style_MouseOver)) &&
+ (flags & Style_On) &&
+ use2000style) {
+ fill = TQBrush(cg.light(), Dense4Pattern);
+ stippled = TRUE;
+ } else
+ fill = cg.brush(TQColorGroup::Button);
+
+ if (flags & (Style_Raised | Style_Down | Style_On)) {
+ if (flags & Style_AutoRaise) {
+ qDrawShadePanel(p, r, cg, flags & (Style_Down | Style_On),
+ 1, &fill);
+
+ if (stippled) {
+ p->setPen(cg.button());
+ p->drawRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2);
+ }
+ } else
+ qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On),
+ &fill);
+ } else
+ p->fillRect(r, fill);
+
+ break;
+ }
+
+ case PE_FocusRect:
+ if (opt.isDefault())
+ p->drawWinFocusRect(r);
+ else
+ p->drawWinFocusRect(r, opt.color());
+ break;
+
+ case PE_Indicator:
+ {
+ TQBrush fill;
+ if (flags & Style_NoChange) {
+ TQBrush b = p->brush();
+ TQColor c = p->backgroundColor();
+ p->setBackgroundMode( TransparentMode );
+ p->setBackgroundColor( green );
+ fill = TQBrush(cg.base(), Dense4Pattern);
+ p->setBackgroundColor( c );
+ p->setBrush( b );
+ } else if (flags & Style_Down)
+ fill = cg.brush( TQColorGroup::Button );
+ else if (flags & Style_Enabled)
+ fill = cg.brush( TQColorGroup::Base );
+ else
+ fill = cg.brush( TQColorGroup::Background );
+
+ qDrawWinPanel( p, r, cg, TRUE, &fill );
+
+ if (flags & Style_NoChange )
+ p->setPen( cg.dark() );
+ else
+ p->setPen( cg.text() );
+ } // FALLTHROUGH
+ case PE_CheckListIndicator:
+ if ( pe == PE_CheckListIndicator ) { //since we fall through from PE_Indicator
+ if ( flags & Style_Enabled )
+ p->setPen( TQPen( cg.text(), 1 ) );
+ else
+ p->setPen( TQPen( cg.dark(), 1 ) );
+ if ( flags & Style_NoChange )
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->drawRect( r.x()+1, r.y()+1, 11, 11 );
+ }
+ if (! (flags & Style_Off)) {
+ TQPointArray a( 7*2 );
+ int i, xx, yy;
+ xx = rr.x() + 3;
+ yy = rr.y() + 5;
+
+ for ( i=0; i<3; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy++;
+ }
+
+ yy -= 2;
+ for ( i=3; i<7; i++ ) {
+ a.setPoint( 2*i, xx, yy );
+ a.setPoint( 2*i+1, xx, yy+2 );
+ xx++; yy--;
+ }
+
+ p->drawLineSegments( a );
+ }
+ break;
+
+ case PE_ExclusiveIndicator:
+ {
+#define TQCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2)
+ static const TQCOORD pts1[] = { // dark lines
+ 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
+ static const TQCOORD pts2[] = { // black lines
+ 2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 };
+ static const TQCOORD pts3[] = { // background lines
+ 2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 };
+ static const TQCOORD pts4[] = { // white lines
+ 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
+ 11,4, 10,3, 10,2 };
+ static const TQCOORD pts5[] = { // inner fill
+ 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
+
+ // make sure the indicator is square
+ TQRect ir = r;
+
+ if (r.width() < r.height()) {
+ ir.setTop(r.top() + (r.height() - r.width()) / 2);
+ ir.setHeight(r.width());
+ } else if (r.height() < r.width()) {
+ ir.setLeft(r.left() + (r.width() - r.height()) / 2);
+ ir.setWidth(r.height());
+ }
+
+ p->eraseRect(ir);
+ bool down = flags & Style_Down;
+ bool enabled = flags & Style_Enabled;
+ bool on = flags & Style_On;
+ TQPointArray a;
+ a.setPoints( TQCOORDARRLEN(pts1), pts1 );
+ a.translate( ir.x(), ir.y() );
+ p->setPen( cg.dark() );
+ p->drawPolyline( a );
+ a.setPoints( TQCOORDARRLEN(pts2), pts2 );
+ a.translate( ir.x(), ir.y() );
+ p->setPen( cg.shadow() );
+ p->drawPolyline( a );
+ a.setPoints( TQCOORDARRLEN(pts3), pts3 );
+ a.translate( ir.x(), ir.y() );
+ p->setPen( cg.midlight() );
+ p->drawPolyline( a );
+ a.setPoints( TQCOORDARRLEN(pts4), pts4 );
+ a.translate( ir.x(), ir.y() );
+ p->setPen( cg.light() );
+ p->drawPolyline( a );
+ a.setPoints( TQCOORDARRLEN(pts5), pts5 );
+ a.translate( ir.x(), ir.y() );
+ TQColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
+ p->setPen( fillColor );
+ p->setBrush( fillColor ) ;
+ p->drawPolygon( a );
+ if ( on ) {
+ p->setPen( NoPen );
+ p->setBrush( cg.text() );
+ p->drawRect( ir.x() + 5, ir.y() + 4, 2, 4 );
+ p->drawRect( ir.x() + 4, ir.y() + 5, 4, 2 );
+ }
+ break;
+ }
+
+ case PE_Panel:
+ case PE_PanelPopup:
+ {
+ int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth)
+ : opt.lineWidth();
+
+ if (lw == 2) {
+ TQColorGroup popupCG = cg;
+ if ( pe == PE_PanelPopup ) {
+ popupCG.setColor( TQColorGroup::Light, cg.background() );
+ popupCG.setColor( TQColorGroup::Midlight, cg.light() );
+ }
+ qDrawWinPanel(p, r, popupCG, flags & Style_Sunken);
+ } else {
+ TQCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt);
+ }
+ break;
+ }
+
+ case PE_Splitter:
+ {
+ TQPen oldPen = p->pen();
+ p->setPen( cg.light() );
+ if ( flags & Style_Horizontal ) {
+ p->drawLine( r.x() + 1, r.y(), r.x() + 1, r.height() );
+ p->setPen( cg.dark() );
+ p->drawLine( r.x(), r.y(), r.x(), r.height() );
+ p->drawLine( r.right()-1, r.y(), r.right()-1, r.height() );
+ p->setPen( cg.shadow() );
+ p->drawLine( r.right(), r.y(), r.right(), r.height() );
+ } else {
+ p->drawLine( r.x(), r.y() + 1, r.width(), r.y() + 1 );
+ p->setPen( cg.dark() );
+ p->drawLine( r.x(), r.bottom() - 1, r.width(), r.bottom() - 1 );
+ p->setPen( cg.shadow() );
+ p->drawLine( r.x(), r.bottom(), r.width(), r.bottom() );
+ }
+ p->setPen( oldPen );
+ break;
+ }
+ case PE_DockWindowResizeHandle:
+ {
+ TQPen oldPen = p->pen();
+ p->setPen( cg.light() );
+ if ( flags & Style_Horizontal ) {
+ p->drawLine( r.x(), r.y(), r.width(), r.y() );
+ p->setPen( cg.dark() );
+ p->drawLine( r.x(), r.bottom() - 1, r.width(), r.bottom() - 1 );
+ p->setPen( cg.shadow() );
+ p->drawLine( r.x(), r.bottom(), r.width(), r.bottom() );
+ } else {
+ p->drawLine( r.x(), r.y(), r.x(), r.height() );
+ p->setPen( cg.dark() );
+ p->drawLine( r.right()-1, r.y(), r.right()-1, r.height() );
+ p->setPen( cg.shadow() );
+ p->drawLine( r.right(), r.y(), r.right(), r.height() );
+ }
+ p->setPen( oldPen );
+ break;
+ }
+
+ case PE_ScrollBarSubLine:
+ if (use2000style) {
+ if (flags & Style_Down) {
+ p->setPen( cg.dark() );
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->drawRect( r );
+ } else
+ drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
+ } else
+ drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
+ ((flags & Style_Down) ? Style_Down : Style_Raised));
+
+ drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
+ p, r, cg, flags);
+ break;
+
+ case PE_ScrollBarAddLine:
+ if (use2000style) {
+ if (flags & Style_Down) {
+ p->setPen( cg.dark() );
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->drawRect( r );
+ } else
+ drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
+ } else
+ drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
+ ((flags & Style_Down) ? Style_Down : Style_Raised));
+
+ drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown),
+ p, r, cg, flags);
+ break;
+
+ case PE_ScrollBarAddPage:
+ case PE_ScrollBarSubPage:
+ {
+ TQBrush br;
+ TQColor c = p->backgroundColor();
+
+ p->setPen(NoPen);
+ p->setBackgroundMode(OpaqueMode);
+
+ if (flags & Style_Down) {
+ br = TQBrush(cg.shadow(), Dense4Pattern);
+ p->setBackgroundColor( cg.dark() );
+ p->setBrush( TQBrush(cg.shadow(), Dense4Pattern) );
+ } else {
+ br = (cg.brush(TQColorGroup::Light).pixmap() ?
+ cg.brush(TQColorGroup::Light) :
+ TQBrush(cg.light(), Dense4Pattern));
+ p->setBrush(br);
+ }
+
+ p->drawRect(r);
+ p->setBackgroundColor(c);
+ break;
+ }
+
+ case PE_ScrollBarSlider:
+ if (! (flags & Style_Enabled)) {
+ TQBrush br = (cg.brush(TQColorGroup::Light).pixmap() ?
+ cg.brush(TQColorGroup::Light) :
+ TQBrush(cg.light(), Dense4Pattern));
+ p->setPen(NoPen);
+ p->setBrush(br);
+ p->setBackgroundMode(OpaqueMode);
+ p->drawRect(r);
+ } else
+ drawPrimitive(PE_ButtonBevel, p, r, cg, Style_Enabled | Style_Raised);
+ break;
+
+ case PE_WindowFrame:
+ {
+ TQColorGroup popupCG = cg;
+ popupCG.setColor( TQColorGroup::Light, cg.background() );
+ popupCG.setColor( TQColorGroup::Midlight, cg.light() );
+ qDrawWinPanel(p, r, popupCG, flags & Style_Sunken);
+ }
+ break;
+
+ default:
+ if (pe >= PE_ArrowUp && pe <= PE_ArrowLeft) {
+ TQPointArray a;
+
+ switch ( pe ) {
+ case PE_ArrowUp:
+ a.setPoints( 7, -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2 );
+ break;
+
+ case PE_ArrowDown:
+ a.setPoints( 7, -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1 );
+ break;
+
+ case PE_ArrowRight:
+ a.setPoints( 7, -2,-3, -2,3, -1,-2, -1,2, 0,-1, 0,1, 1,0 );
+ break;
+
+ case PE_ArrowLeft:
+ a.setPoints( 7, 0,-3, 0,3, -1,-2, -1,2, -2,-1, -2,1, -3,0 );
+ break;
+
+ default:
+ break;
+ }
+
+ if (a.isNull())
+ return;
+
+ p->save();
+ if ( flags & Style_Down )
+ p->translate( pixelMetric( PM_ButtonShiftHorizontal ),
+ pixelMetric( PM_ButtonShiftVertical ) );
+
+ if ( flags & Style_Enabled ) {
+ a.translate( r.x() + r.width() / 2, r.y() + r.height() / 2 );
+ p->setPen( cg.buttonText() );
+ p->drawLineSegments( a, 0, 3 ); // draw arrow
+ p->drawPoint( a[6] );
+ } else {
+ a.translate( r.x() + r.width() / 2 + 1, r.y() + r.height() / 2 + 1 );
+ p->setPen( cg.light() );
+ p->drawLineSegments( a, 0, 3 ); // draw arrow
+ p->drawPoint( a[6] );
+ a.translate( -1, -1 );
+ p->setPen( cg.mid() );
+ p->drawLineSegments( a, 0, 3 ); // draw arrow
+ p->drawPoint( a[6] );
+ }
+ p->restore();
+ } else
+ TQCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt);
+ }
+}
+
+
+/*!
+ \reimp
+*/
+void TQWindowsStyle::drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch (element) {
+#ifndef QT_NO_TABBAR
+ case CE_TabBarTab:
+ {
+ if ( !widget || !widget->parentWidget() || !opt.tab() )
+ break;
+
+ const TQTabBar * tb = (const TQTabBar *) widget;
+ const TQTab * t = opt.tab();
+ bool selected = flags & Style_Selected;
+ bool lastTab = (tb->indexOf( t->identifier() ) == tb->count()-1) ?
+ TRUE : FALSE;
+ TQRect r2( r );
+ if ( tb->shape() == TQTabBar::RoundedAbove ) {
+ p->setPen( cg.midlight() );
+
+ p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
+ p->setPen( cg.light() );
+ p->drawLine( r2.left(), r2.bottom()-1, r2.right(), r2.bottom()-1 );
+ if ( r2.left() == 0 )
+ p->drawPoint( tb->rect().bottomLeft() );
+
+ if ( selected ) {
+ p->fillRect( TQRect( r2.left()+1, r2.bottom()-1, r2.width()-3, 2),
+ cg.brush( TQColorGroup::Background ));
+ p->setPen( cg.background() );
+ p->drawLine( r2.left()+1, r2.bottom(), r2.left()+1, r2.top()+2 );
+ p->setPen( cg.light() );
+ } else {
+ p->setPen( cg.light() );
+ r2.setRect( r2.left() + 2, r2.top() + 2,
+ r2.width() - 4, r2.height() - 2 );
+ }
+
+ int x1, x2;
+ x1 = r2.left();
+ x2 = r2.right() - 2;
+ p->drawLine( x1, r2.bottom()-1, x1, r2.top() + 2 );
+ x1++;
+ p->drawPoint( x1, r2.top() + 1 );
+ x1++;
+ p->drawLine( x1, r2.top(), x2, r2.top() );
+ if ( r2.left() > 0 ) {
+ p->setPen( cg.midlight() );
+ }
+ x1 = r2.left();
+ p->drawPoint( x1, r2.bottom());
+
+ p->setPen( cg.midlight() );
+ x1++;
+ p->drawLine( x1, r2.bottom(), x1, r2.top() + 2 );
+ x1++;
+ p->drawLine( x1, r2.top()+1, x2, r2.top()+1 );
+
+ p->setPen( cg.dark() );
+ x2 = r2.right() - 1;
+ p->drawLine( x2, r2.top() + 2, x2, r2.bottom() - 1 +
+ (selected ? 1:-1) );
+ p->setPen( cg.shadow() );
+ p->drawPoint( x2, r2.top() + 1 );
+ p->drawPoint( x2, r2.top() + 1 );
+ x2++;
+ p->drawLine( x2, r2.top() + 2, x2, r2.bottom() -
+ (selected ? (lastTab ? 0:1) :2));
+ } else if ( tb->shape() == TQTabBar::RoundedBelow ) {
+ bool rightAligned = styleHint( SH_TabBar_Alignment, tb ) == AlignRight;
+ bool firstTab = tb->indexOf( t->identifier() ) == 0;
+ if ( selected ) {
+ p->fillRect( TQRect( r2.left()+1, r2.top(), r2.width()-3, 1),
+ cg.brush( TQColorGroup::Background ));
+ p->setPen( cg.background() );
+ p->drawLine( r2.left()+1, r2.top(), r2.left()+1, r2.bottom()-2 );
+ p->setPen( cg.dark() );
+ } else {
+ p->setPen( cg.shadow() );
+ p->drawLine( r2.left() +
+ (rightAligned && firstTab ? 0 : 1),
+ r2.top() + 1,
+ r2.right() - (lastTab ? 0 : 2),
+ r2.top() + 1 );
+
+ if ( rightAligned && lastTab )
+ p->drawPoint( r2.right(), r2.top() );
+ p->setPen( cg.dark() );
+ p->drawLine( r2.left(), r2.top(), r2.right() - 1,
+ r2.top() );
+ r2.setRect( r2.left() + 2, r2.top(),
+ r2.width() - 4, r2.height() - 2 );
+ }
+
+ p->drawLine( r2.right() - 1, r2.top() + (selected ? 0: 2),
+ r2.right() - 1, r2.bottom() - 2 );
+ p->drawPoint( r2.right() - 2, r2.bottom() - 2 );
+ p->drawLine( r2.right() - 2, r2.bottom() - 1,
+ r2.left() + 1, r2.bottom() - 1 );
+
+ p->setPen( cg.midlight() );
+ p->drawLine( r2.left() + 1, r2.bottom() - 2,
+ r2.left() + 1, r2.top() + (selected ? 0 : 2) );
+
+ p->setPen( cg.shadow() );
+ p->drawLine( r2.right(),
+ r2.top() + (lastTab && rightAligned &&
+ selected) ? 0 : 1,
+ r2.right(), r2.bottom() - 1 );
+ p->drawPoint( r2.right() - 1, r2.bottom() - 1 );
+ p->drawLine( r2.right() - 1, r2.bottom(),
+ r2.left() + 2, r2.bottom() );
+
+ p->setPen( cg.light() );
+ p->drawLine( r2.left(), r2.top() + (selected ? 0 : 2),
+ r2.left(), r2.bottom() - 2 );
+ } else {
+ TQCommonStyle::drawControl(element, p, widget, r, cg, flags, opt);
+ }
+ break;
+ }
+#endif // QT_NO_TABBAR
+ case CE_ToolBoxTab:
+ {
+ qDrawShadePanel( p, r, cg, flags & (Style_Sunken | Style_Down | Style_On) , 1,
+ &cg.brush(TQColorGroup::Button));
+ break;
+ }
+
+#ifndef QT_NO_POPUPMENU
+ case CE_PopupMenuItem:
+ {
+ if (! widget || opt.isDefault())
+ break;
+
+ const TQPopupMenu *popupmenu = (const TQPopupMenu *) widget;
+ TQMenuItem *mi = opt.menuItem();
+ if ( !mi )
+ break;
+
+ int tab = opt.tabWidth();
+ int maxpmw = opt.maxIconWidth();
+ bool dis = !(flags&Style_Enabled);
+ bool checkable = popupmenu->isCheckable();
+ bool act = flags & Style_Active;
+ int x, y, w, h;
+
+ r.rect(&x, &y, &w, &h);
+
+ if ( checkable ) {
+ // space for the checkmarks
+ if (use2000style)
+ maxpmw = TQMAX( maxpmw, 20 );
+ else
+ maxpmw = TQMAX( maxpmw, 12 );
+ }
+
+ int checkcol = maxpmw;
+
+ if ( mi && mi->isSeparator() ) { // draw separator
+ p->setPen( cg.dark() );
+ p->drawLine( x, y, x+w, y );
+ p->setPen( cg.light() );
+ p->drawLine( x, y+1, x+w, y+1 );
+ return;
+ }
+
+ TQBrush fill = (act ?
+ cg.brush( TQColorGroup::Highlight ) :
+ cg.brush( TQColorGroup::Button ));
+ p->fillRect( x, y, w, h, fill);
+
+ if ( !mi )
+ return;
+
+ int xpos = x;
+ TQRect vrect = visualRect( TQRect( xpos, y, checkcol, h ), r );
+ int xvis = vrect.x();
+ if ( mi->isChecked() ) {
+ if ( act && !dis )
+ qDrawShadePanel( p, xvis, y, checkcol, h,
+ cg, TRUE, 1, &cg.brush( TQColorGroup::Button ) );
+ else {
+ TQBrush fill( cg.light(), Dense4Pattern );
+ // set the brush origin for the hash pattern to the x/y coordinate
+ // of the menu item's checkmark... this way, the check marks have
+ // a consistent look
+ TQPoint origin = p->brushOrigin();
+ p->setBrushOrigin( xvis, y );
+ qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1,
+ &fill );
+ // restore the previous brush origin
+ p->setBrushOrigin( origin );
+ }
+ } else if (! act)
+ p->fillRect(xvis, y, checkcol , h, cg.brush( TQColorGroup::Button ));
+
+ if ( mi->iconSet() ) { // draw iconset
+ TQIconSet::Mode mode = dis ? TQIconSet::Disabled : TQIconSet::Normal;
+ if (act && !dis )
+ mode = TQIconSet::Active;
+ TQPixmap pixmap;
+ if ( checkable && mi->isChecked() )
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode, TQIconSet::On );
+ else
+ pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode );
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ if ( act && !dis && !mi->isChecked() )
+ qDrawShadePanel( p, xvis, y, checkcol, h, cg, FALSE, 1,
+ &cg.brush( TQColorGroup::Button ) );
+ TQRect pmr( 0, 0, pixw, pixh );
+ pmr.moveCenter( vrect.center() );
+ p->setPen( cg.text() );
+ p->drawPixmap( pmr.topLeft(), pixmap );
+
+ fill = (act ?
+ cg.brush( TQColorGroup::Highlight ) :
+ cg.brush( TQColorGroup::Button ));
+ int xp = xpos + checkcol + 1;
+ p->fillRect( visualRect( TQRect( xp, y, w - checkcol - 1, h ), r ), fill);
+ } else if ( checkable ) { // just "checking"...
+ if ( mi->isChecked() ) {
+ int xp = xpos + windowsItemFrame;
+
+ SFlags cflags = Style_Default;
+ if (! dis)
+ cflags |= Style_Enabled;
+ if (act)
+ cflags |= Style_On;
+
+ drawPrimitive(PE_CheckMark, p,
+ visualRect( TQRect(xp, y + windowsItemFrame,
+ checkcol - 2*windowsItemFrame,
+ h - 2*windowsItemFrame), r ), cg, cflags);
+ }
+ }
+
+ p->setPen( act ? cg.highlightedText() : cg.buttonText() );
+
+ TQColor discol;
+ if ( dis ) {
+ discol = cg.text();
+ p->setPen( discol );
+ }
+
+ int xm = windowsItemFrame + checkcol + windowsItemHMargin;
+ xpos += xm;
+
+ vrect = visualRect( TQRect( xpos, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin ), r );
+ xvis = vrect.x();
+ if ( mi->custom() ) {
+ p->save();
+ if ( dis && !act ) {
+ p->setPen( cg.light() );
+ mi->custom()->paint( p, cg, act, !dis,
+ xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin );
+ p->setPen( discol );
+ }
+ mi->custom()->paint( p, cg, act, !dis,
+ xvis, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin );
+ p->restore();
+ }
+ TQString s = mi->text();
+ if ( !s.isNull() ) { // draw text
+ int t = s.find( '\t' );
+ int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
+ if (!styleHint(SH_UnderlineAccelerator, widget))
+ text_flags |= NoAccel;
+ text_flags |= (TQApplication::reverseLayout() ? AlignRight : AlignLeft );
+ if ( t >= 0 ) { // draw tab text
+ int xp = x + w - tab - windowsItemHMargin - windowsItemFrame + 1;
+ if ( use2000style )
+ xp -= 20;
+ else
+ xp -= windowsRightBorder;
+ int xoff = visualRect( TQRect( xp, y+windowsItemVMargin, tab, h-2*windowsItemVMargin ), r ).x();
+ if ( dis && !act ) {
+ p->setPen( cg.light() );
+ p->drawText( xoff+1, y+windowsItemVMargin+1, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ));
+ p->setPen( discol );
+ }
+ p->drawText( xoff, y+windowsItemVMargin, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ) );
+ s = s.left( t );
+ }
+ if ( dis && !act ) {
+ p->setPen( cg.light() );
+ p->drawText( xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
+ p->setPen( discol );
+ }
+ p->drawText( xvis, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
+ } else if ( mi->pixmap() ) { // draw pixmap
+ TQPixmap *pixmap = mi->pixmap();
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( OpaqueMode );
+ p->drawPixmap( xvis, y+windowsItemFrame, *pixmap );
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( TransparentMode );
+ }
+ if ( mi->popup() ) { // draw sub menu arrow
+ int dim = (h-2*windowsItemFrame) / 2;
+ PrimitiveElement arrow;
+ arrow = ( TQApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight );
+ xpos = x+w - windowsArrowHMargin - windowsItemFrame - dim;
+ vrect = visualRect( TQRect(xpos, y + h / 2 - dim / 2, dim, dim), r );
+ if ( act ) {
+ TQColorGroup g2 = cg;
+ g2.setColor( TQColorGroup::ButtonText, g2.highlightedText() );
+ drawPrimitive(arrow, p, vrect,
+ g2, dis ? Style_Default : Style_Enabled);
+ } else {
+ drawPrimitive(arrow, p, vrect,
+ cg, dis ? Style_Default : Style_Enabled );
+ }
+ }
+
+ break;
+ }
+#endif
+
+ case CE_MenuBarItem:
+ {
+ bool active = flags & Style_Active;
+ bool hasFocus = flags & Style_HasFocus;
+ bool down = flags & Style_Down;
+ TQRect pr = r;
+
+ p->fillRect( r, cg.brush( TQColorGroup::Button ) );
+ if ( active || hasFocus ) {
+ TQBrush b = cg.brush( TQColorGroup::Button );
+ if ( active && down )
+ p->setBrushOrigin(p->brushOrigin() + TQPoint(1,1));
+ if ( active && hasFocus )
+ qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(),
+ cg, active && down, 1, 0, &b );
+ if ( active && down ) {
+ pr.moveBy( pixelMetric(PM_ButtonShiftHorizontal, widget),
+ pixelMetric(PM_ButtonShiftVertical, widget) );
+ p->setBrushOrigin(p->brushOrigin() - TQPoint(1,1));
+ }
+ }
+ TQCommonStyle::drawControl(element, p, widget, pr, cg, flags, opt);
+ break;
+ }
+
+ default:
+ TQCommonStyle::drawControl(element, p, widget, r, cg, flags, opt);
+ }
+}
+
+
+/*!
+ \reimp
+*/
+int TQWindowsStyle::pixelMetric(PixelMetric metric, const TQWidget *widget) const
+{
+ int ret;
+
+ switch (metric) {
+ case PM_ButtonDefaultIndicator:
+ case PM_ButtonShiftHorizontal:
+ case PM_ButtonShiftVertical:
+ ret = 1;
+ break;
+
+ case PM_MaximumDragDistance:
+ ret = 60;
+ break;
+
+#ifndef QT_NO_SLIDER
+ case PM_SliderLength:
+ ret = 11;
+ break;
+
+ // Returns the number of pixels to use for the business part of the
+ // slider (i.e., the non-tickmark portion). The remaining space is shared
+ // equally between the tickmark regions.
+ case PM_SliderControlThickness:
+ {
+ const TQSlider * sl = (const TQSlider *) widget;
+ int space = (sl->orientation() == Horizontal) ? sl->height()
+ : sl->width();
+ int ticks = sl->tickmarks();
+ int n = 0;
+ if ( ticks & TQSlider::Above ) n++;
+ if ( ticks & TQSlider::Below ) n++;
+ if ( !n ) {
+ ret = space;
+ break;
+ }
+
+ int thick = 6; // Magic constant to get 5 + 16 + 5
+ if ( ticks != TQSlider::Both && ticks != TQSlider::NoMarks )
+ thick += pixelMetric( PM_SliderLength, sl ) / 4;
+
+ space -= thick;
+ //### the two sides may be unequal in size
+ if ( space > 0 )
+ thick += (space * 2) / (n + 2);
+ ret = thick;
+ break;
+ }
+#endif // QT_NO_SLIDER
+
+ case PM_MenuBarFrameWidth:
+ ret = 0;
+ break;
+
+#if defined(Q_WS_WIN)
+ case PM_TitleBarHeight:
+ if ( widget && ( widget->testWFlags( WStyle_Tool ) || ::qt_cast<TQDockWindow*>(widget) ) ) {
+ // MS always use one less than they say
+#if defined(Q_OS_TEMP)
+ ret = GetSystemMetrics( SM_CYCAPTION ) - 1;
+#else
+ ret = GetSystemMetrics( SM_CYSMCAPTION ) - 1;
+#endif
+ } else {
+ ret = GetSystemMetrics( SM_CYCAPTION ) - 1;
+ }
+ break;
+
+ case PM_ScrollBarExtent:
+ {
+#ifndef Q_OS_TEMP
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = sizeof(NONCLIENTMETRICS);
+ if ( SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0 ) )
+ ret = TQMAX( ncm.iScrollHeight, ncm.iScrollWidth );
+ else
+#endif
+ ret = TQCommonStyle::pixelMetric( metric, widget );
+ }
+ break;
+#endif
+
+ case PM_SplitterWidth:
+ ret = TQMAX( 6, TQApplication::globalStrut().width() );
+ break;
+
+#if defined(Q_WS_WIN)
+ case PM_MDIFrameWidth:
+ ret = GetSystemMetrics(SM_CYFRAME);
+ break;
+#endif
+
+ default:
+ ret = TQCommonStyle::pixelMetric(metric, widget);
+ break;
+ }
+
+ return ret;
+}
+
+
+/*!
+ \reimp
+*/
+TQSize TQWindowsStyle::sizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& opt ) const
+{
+ TQSize sz(contentsSize);
+
+ switch (contents) {
+ case CT_PushButton:
+ {
+#ifndef QT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ sz = TQCommonStyle::sizeFromContents(contents, widget, contentsSize, opt);
+ int w = sz.width(), h = sz.height();
+
+ int defwidth = 0;
+ if (button->isDefault() || button->autoDefault())
+ defwidth = 2*pixelMetric( PM_ButtonDefaultIndicator, widget );
+
+ if (w < 80+defwidth && !button->pixmap())
+ w = 80+defwidth;
+ if (h < 23+defwidth)
+ h = 23+defwidth;
+
+ sz = TQSize(w, h);
+#endif
+ break;
+ }
+
+ case CT_PopupMenuItem:
+ {
+#ifndef QT_NO_POPUPMENU
+ if (! widget || opt.isDefault())
+ break;
+
+ const TQPopupMenu *popup = (const TQPopupMenu *) widget;
+ bool checkable = popup->isCheckable();
+ TQMenuItem *mi = opt.menuItem();
+ int maxpmw = opt.maxIconWidth();
+ int w = sz.width(), h = sz.height();
+
+ if (mi->custom()) {
+ w = mi->custom()->sizeHint().width();
+ h = mi->custom()->sizeHint().height();
+ if (! mi->custom()->fullSpan())
+ h += 2*windowsItemVMargin + 2*windowsItemFrame;
+ } else if ( mi->widget() ) {
+ } else if (mi->isSeparator()) {
+ w = 10; // arbitrary
+ h = windowsSepHeight;
+ } else {
+ if (mi->pixmap())
+ h = TQMAX(h, mi->pixmap()->height() + 2*windowsItemFrame);
+ else if (! mi->text().isNull())
+ h = TQMAX(h, popup->fontMetrics().height() + 2*windowsItemVMargin +
+ 2*windowsItemFrame);
+
+ if (mi->iconSet() != 0)
+ h = TQMAX(h, mi->iconSet()->pixmap(TQIconSet::Small,
+ TQIconSet::Normal).height() +
+ 2*windowsItemFrame);
+ }
+
+ if (! mi->text().isNull() && mi->text().find('\t') >= 0) {
+ if ( use2000style )
+ w += 20;
+ else
+ w += windowsTabSpacing;
+ } else if (mi->popup()) {
+ w += 2*windowsArrowHMargin;
+ }
+
+ if (use2000style) {
+ if (checkable && maxpmw < 20)
+ w += 20 - maxpmw;
+ } else {
+ if (checkable && maxpmw < windowsCheckMarkWidth)
+ w += windowsCheckMarkWidth - maxpmw;
+ }
+ if (checkable || maxpmw > 0)
+ w += windowsCheckMarkHMargin;
+ if (use2000style)
+ w += 20;
+ else
+ w += windowsRightBorder;
+
+ sz = TQSize(w, h);
+#endif
+ break;
+ }
+
+ default:
+ sz = TQCommonStyle::sizeFromContents(contents, widget, sz, opt);
+ break;
+ }
+
+ return sz;
+}
+
+/*! \reimp
+*/
+void TQWindowsStyle::polishPopupMenu( TQPopupMenu* p)
+{
+#ifndef QT_NO_POPUPMENU
+ if ( !p->testWState( WState_Polished ) )
+ p->setCheckable( TRUE );
+#endif
+}
+
+#ifndef QT_NO_IMAGEIO_XPM
+static const char * const qt_close_xpm[] = {
+"12 12 2 1",
+"# c #000000",
+". c None",
+"............",
+"............",
+"..##....##..",
+"...##..##...",
+"....####....",
+".....##.....",
+"....####....",
+"...##..##...",
+"..##....##..",
+"............",
+"............",
+"............"};
+
+static const char * const qt_maximize_xpm[]={
+"12 12 2 1",
+"# c #000000",
+". c None",
+"............",
+".#########..",
+".#########..",
+".#.......#..",
+".#.......#..",
+".#.......#..",
+".#.......#..",
+".#.......#..",
+".#.......#..",
+".#########..",
+"............",
+"............"};
+
+
+static const char * const qt_minimize_xpm[] = {
+"12 12 2 1",
+"# c #000000",
+". c None",
+"............",
+"............",
+"............",
+"............",
+"............",
+"............",
+"............",
+"............",
+"..######....",
+"..######....",
+"............",
+"............"};
+
+static const char * const qt_normalizeup_xpm[] = {
+"12 12 2 1",
+"# c #000000",
+". c None",
+"............",
+"....######..",
+"....######..",
+"....#....#..",
+"..######.#..",
+"..######.#..",
+"..#....###..",
+"..#....#....",
+"..#....#....",
+"..######....",
+"............",
+"............"};
+
+
+static const char * const qt_shade_xpm[] = {
+"12 12 2 1",
+"# c #000000",
+". c None",
+"............",
+"............",
+"............",
+"............",
+"............",
+".....#......",
+"....###.....",
+"...#####....",
+"..#######...",
+"............",
+"............",
+"............"};
+
+static const char * const qt_unshade_xpm[] = {
+"12 12 2 1",
+"# c #000000",
+". c None",
+"............",
+"............",
+"............",
+"............",
+"..#######...",
+"...#####....",
+"....###.....",
+".....#......",
+"............",
+"............",
+"............",
+"............"};
+
+static const char * dock_window_close_xpm[] = {
+"8 8 2 1",
+"# c #000000",
+". c None",
+"........",
+".##..##.",
+"..####..",
+"...##...",
+"..####..",
+".##..##.",
+"........",
+"........"};
+
+/* XPM */
+static const char * const information_xpm[]={
+"32 32 5 1",
+". c None",
+"c c #000000",
+"* c #999999",
+"a c #ffffff",
+"b c #0000ff",
+"...........********.............",
+"........***aaaaaaaa***..........",
+"......**aaaaaaaaaaaaaa**........",
+".....*aaaaaaaaaaaaaaaaaa*.......",
+"....*aaaaaaaabbbbaaaaaaaac......",
+"...*aaaaaaaabbbbbbaaaaaaaac.....",
+"..*aaaaaaaaabbbbbbaaaaaaaaac....",
+".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
+".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
+"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
+"*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
+".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
+"..*aaaaaaaaaabbbbbaaaaaaaaac***.",
+"...caaaaaaabbbbbbbbbaaaaaac****.",
+"....caaaaaaaaaaaaaaaaaaaac****..",
+".....caaaaaaaaaaaaaaaaaac****...",
+"......ccaaaaaaaaaaaaaacc****....",
+".......*cccaaaaaaaaccc*****.....",
+"........***cccaaaac*******......",
+"..........****caaac*****........",
+".............*caaac**...........",
+"...............caac**...........",
+"................cac**...........",
+".................cc**...........",
+"..................***...........",
+"...................**..........."};
+/* XPM */
+static const char* const warning_xpm[]={
+"32 32 4 1",
+". c None",
+"a c #ffff00",
+"* c #000000",
+"b c #999999",
+".............***................",
+"............*aaa*...............",
+"...........*aaaaa*b.............",
+"...........*aaaaa*bb............",
+"..........*aaaaaaa*bb...........",
+"..........*aaaaaaa*bb...........",
+".........*aaaaaaaaa*bb..........",
+".........*aaaaaaaaa*bb..........",
+"........*aaaaaaaaaaa*bb.........",
+"........*aaaa***aaaa*bb.........",
+".......*aaaa*****aaaa*bb........",
+".......*aaaa*****aaaa*bb........",
+"......*aaaaa*****aaaaa*bb.......",
+"......*aaaaa*****aaaaa*bb.......",
+".....*aaaaaa*****aaaaaa*bb......",
+".....*aaaaaa*****aaaaaa*bb......",
+"....*aaaaaaaa***aaaaaaaa*bb.....",
+"....*aaaaaaaa***aaaaaaaa*bb.....",
+"...*aaaaaaaaa***aaaaaaaaa*bb....",
+"...*aaaaaaaaaa*aaaaaaaaaa*bb....",
+"..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
+"..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
+".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
+".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
+"*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
+"*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
+"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
+"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
+".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
+"..*************************bbbbb",
+"....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
+".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
+/* XPM */
+static const char* const critical_xpm[]={
+"32 32 4 1",
+". c None",
+"a c #999999",
+"* c #ff0000",
+"b c #ffffff",
+"...........********.............",
+".........************...........",
+".......****************.........",
+"......******************........",
+".....********************a......",
+"....**********************a.....",
+"...************************a....",
+"..*******b**********b*******a...",
+"..******bbb********bbb******a...",
+".******bbbbb******bbbbb******a..",
+".*******bbbbb****bbbbb*******a..",
+"*********bbbbb**bbbbb*********a.",
+"**********bbbbbbbbbb**********a.",
+"***********bbbbbbbb***********aa",
+"************bbbbbb************aa",
+"************bbbbbb************aa",
+"***********bbbbbbbb***********aa",
+"**********bbbbbbbbbb**********aa",
+"*********bbbbb**bbbbb*********aa",
+".*******bbbbb****bbbbb*******aa.",
+".******bbbbb******bbbbb******aa.",
+"..******bbb********bbb******aaa.",
+"..*******b**********b*******aa..",
+"...************************aaa..",
+"....**********************aaa...",
+"....a********************aaa....",
+".....a******************aaa.....",
+"......a****************aaa......",
+".......aa************aaaa.......",
+".........aa********aaaaa........",
+"...........aaaaaaaaaaa..........",
+".............aaaaaaa............"};
+/* XPM */
+static const char *const question_xpm[] = {
+"32 32 5 1",
+". c None",
+"c c #000000",
+"* c #999999",
+"a c #ffffff",
+"b c #0000ff",
+"...........********.............",
+"........***aaaaaaaa***..........",
+"......**aaaaaaaaaaaaaa**........",
+".....*aaaaaaaaaaaaaaaaaa*.......",
+"....*aaaaaaaaaaaaaaaaaaaac......",
+"...*aaaaaaaabbbbbbaaaaaaaac.....",
+"..*aaaaaaaabaaabbbbaaaaaaaac....",
+".*aaaaaaaabbaaaabbbbaaaaaaaac...",
+".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
+"*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
+"*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
+"*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
+"*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
+"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
+"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
+"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
+".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
+".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
+"..*aaaaaaaaaabbbbaaaaaaaaaac***.",
+"...caaaaaaaaaabbaaaaaaaaaac****.",
+"....caaaaaaaaaaaaaaaaaaaac****..",
+".....caaaaaaaaaaaaaaaaaac****...",
+"......ccaaaaaaaaaaaaaacc****....",
+".......*cccaaaaaaaaccc*****.....",
+"........***cccaaaac*******......",
+"..........****caaac*****........",
+".............*caaac**...........",
+"...............caac**...........",
+"................cac**...........",
+".................cc**...........",
+"..................***...........",
+"...................**...........",
+};
+#endif //QT_NO_IMAGEIO_XPM
+
+/*!
+ \reimp
+ */
+TQPixmap TQWindowsStyle::stylePixmap(StylePixmap stylepixmap,
+ const TQWidget *widget,
+ const TQStyleOption& opt) const
+{
+#ifndef QT_NO_IMAGEIO_XPM
+ switch (stylepixmap) {
+ case SP_TitleBarShadeButton:
+ return TQPixmap( (const char **)qt_shade_xpm );
+ case SP_TitleBarUnshadeButton:
+ return TQPixmap( (const char **)qt_unshade_xpm );
+ case SP_TitleBarNormalButton:
+ return TQPixmap( (const char **)qt_normalizeup_xpm );
+ case SP_TitleBarMinButton:
+ return TQPixmap( (const char **)qt_minimize_xpm );
+ case SP_TitleBarMaxButton:
+ return TQPixmap( (const char **)qt_maximize_xpm );
+ case SP_TitleBarCloseButton:
+ return TQPixmap( (const char **)qt_close_xpm );
+ case SP_DockWindowCloseButton:
+ return TQPixmap( (const char **)dock_window_close_xpm );
+ case SP_MessageBoxInformation:
+ return TQPixmap( (const char **)information_xpm);
+ case SP_MessageBoxWarning:
+ return TQPixmap( (const char **)warning_xpm );
+ case SP_MessageBoxCritical:
+ return TQPixmap( (const char **)critical_xpm );
+ case SP_MessageBoxQuestion:
+ return TQPixmap( (const char **)question_xpm );
+ default:
+ break;
+ }
+#endif //QT_NO_IMAGEIO_XPM
+ return TQCommonStyle::stylePixmap(stylepixmap, widget, opt);
+}
+
+/*!\reimp
+*/
+void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ SCFlags sub,
+ SCFlags subActive,
+ const TQStyleOption& opt ) const
+{
+ switch (ctrl) {
+#ifndef QT_NO_LISTVIEW
+ case CC_ListView:
+ {
+ if ( sub & SC_ListView ) {
+ TQCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub, subActive, opt );
+ }
+ if ( sub & ( SC_ListViewBranch | SC_ListViewExpand ) ) {
+ if (opt.isDefault())
+ break;
+
+ TQListViewItem *item = opt.listViewItem(),
+ *child = item->firstChild();
+
+ int y = r.y();
+ int c;
+ int dotoffset = 0;
+ TQPointArray dotlines;
+ if ( subActive == (uint)SC_All && sub == SC_ListViewExpand ) {
+ c = 2;
+ dotlines.resize(2);
+ dotlines[0] = TQPoint( r.right(), r.top() );
+ dotlines[1] = TQPoint( r.right(), r.bottom() );
+ } else {
+ int linetop = 0, linebot = 0;
+ // each branch needs at most two lines, ie. four end points
+ dotoffset = (item->itemPos() + item->height() - y) %2;
+ dotlines.resize( item->childCount() * 4 );
+ c = 0;
+
+ // skip the stuff above the exposed rectangle
+ while ( child && y + child->height() <= 0 ) {
+ y += child->totalHeight();
+ child = child->nextSibling();
+ }
+
+ int bx = r.width() / 2;
+
+ // paint stuff in the magical area
+ TQListView* v = item->listView();
+ while ( child && y < r.height() ) {
+ if (child->isVisible()) {
+ int lh;
+ if ( !item->multiLinesEnabled() )
+ lh = child->height();
+ else
+ lh = p->fontMetrics().height() + 2 * v->itemMargin();
+ lh = TQMAX( lh, TQApplication::globalStrut().height() );
+ if ( lh % 2 > 0 )
+ lh++;
+ linebot = y + lh/2;
+ if ( (child->isExpandable() || child->childCount()) &&
+ (child->height() > 0) ) {
+ // needs a box
+ p->setPen( cg.mid() );
+ p->drawRect( bx-4, linebot-4, 9, 9 );
+ // plus or minus
+ p->setPen( cg.text() );
+ p->drawLine( bx - 2, linebot, bx + 2, linebot );
+ if ( !child->isOpen() )
+ p->drawLine( bx, linebot - 2, bx, linebot + 2 );
+ // dotlinery
+ p->setPen( cg.mid() );
+ dotlines[c++] = TQPoint( bx, linetop );
+ dotlines[c++] = TQPoint( bx, linebot - 4 );
+ dotlines[c++] = TQPoint( bx + 5, linebot );
+ dotlines[c++] = TQPoint( r.width(), linebot );
+ linetop = linebot + 5;
+ } else {
+ // just dotlinery
+ dotlines[c++] = TQPoint( bx+1, linebot -1);
+ dotlines[c++] = TQPoint( r.width(), linebot -1);
+ }
+ y += child->totalHeight();
+ }
+ child = child->nextSibling();
+ }
+
+ // Expand line height to edge of rectangle if there's any
+ // visible child below
+ while ( child && child->height() <= 0)
+ child = child->nextSibling();
+ if ( child )
+ linebot = r.height();
+
+ if ( linetop < linebot ) {
+ dotlines[c++] = TQPoint( bx, linetop );
+ dotlines[c++] = TQPoint( bx, linebot );
+ }
+ }
+ p->setPen( cg.text() );
+
+ static TQBitmap *verticalLine = 0, *horizontalLine = 0;
+ static TQCleanupHandler<TQBitmap> qlv_cleanup_bitmap;
+ if ( !verticalLine ) {
+ // make 128*1 and 1*128 bitmaps that can be used for
+ // drawing the right sort of lines.
+ verticalLine = new TQBitmap( 1, 129, TRUE );
+ horizontalLine = new TQBitmap( 128, 1, TRUE );
+ TQPointArray a( 64 );
+ TQPainter p;
+ p.begin( verticalLine );
+ int i;
+ for( i=0; i<64; i++ )
+ a.setPoint( i, 0, i*2+1 );
+ p.setPen( color1 );
+ p.drawPoints( a );
+ p.end();
+ TQApplication::flushX();
+ verticalLine->setMask( *verticalLine );
+ p.begin( horizontalLine );
+ for( i=0; i<64; i++ )
+ a.setPoint( i, i*2+1, 0 );
+ p.setPen( color1 );
+ p.drawPoints( a );
+ p.end();
+ TQApplication::flushX();
+ horizontalLine->setMask( *horizontalLine );
+ qlv_cleanup_bitmap.add( &verticalLine );
+ qlv_cleanup_bitmap.add( &horizontalLine );
+ }
+
+ int line; // index into dotlines
+ if ( sub & SC_ListViewBranch ) for( line = 0; line < c; line += 2 ) {
+ // assumptions here: lines are horizontal or vertical.
+ // lines always start with the numerically lowest
+ // coordinate.
+
+ // point ... relevant coordinate of current point
+ // end ..... same coordinate of the end of the current line
+ // other ... the other coordinate of the current point/line
+ if ( dotlines[line].y() == dotlines[line+1].y() ) {
+ int end = dotlines[line+1].x();
+ int point = dotlines[line].x();
+ int other = dotlines[line].y();
+ while( point < end ) {
+ int i = 128;
+ if ( i+point > end )
+ i = end-point;
+ p->drawPixmap( point, other, *horizontalLine,
+ 0, 0, i, 1 );
+ point += i;
+ }
+ } else {
+ int end = dotlines[line+1].y();
+ int point = dotlines[line].y();
+ int other = dotlines[line].x();
+ int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0;
+ while( point < end ) {
+ int i = 128;
+ if ( i+point > end )
+ i = end-point;
+ p->drawPixmap( other, point, *verticalLine,
+ 0, pixmapoffset, 1, i );
+ point += i;
+ }
+ }
+ }
+ }
+ }
+ break;
+#endif //QT_NO_LISTVIEW
+
+#ifndef QT_NO_COMBOBOX
+ case CC_ComboBox:
+ if ( sub & SC_ComboBoxArrow ) {
+ SFlags flags = Style_Default;
+
+ qDrawWinPanel( p, r, cg, TRUE, widget->isEnabled() ?
+ &cg.brush( TQColorGroup::Base ):
+ &cg.brush( TQColorGroup::Background ) );
+
+ TQRect ar =
+ TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
+ SC_ComboBoxArrow ), widget );
+ if ( subActive == SC_ComboBoxArrow ) {
+ p->setPen( cg.dark() );
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->drawRect( ar );
+ } else
+ qDrawWinPanel( p, ar, cg, FALSE,
+ &cg.brush( TQColorGroup::Button ) );
+
+ ar.addCoords( 2, 2, -2, -2 );
+ if ( widget->isEnabled() )
+ flags |= Style_Enabled;
+
+ if ( subActive == SC_ComboBoxArrow ) {
+ flags |= Style_Sunken;
+ }
+ drawPrimitive( PE_ArrowDown, p, ar, cg, flags );
+ }
+
+ if ( sub & SC_ComboBoxEditField ) {
+ const TQComboBox * cb = (const TQComboBox *) widget;
+ TQRect re =
+ TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
+ SC_ComboBoxEditField ), widget );
+ if ( cb->hasFocus() && !cb->editable() )
+ p->fillRect( re.x(), re.y(), re.width(), re.height(),
+ cg.brush( TQColorGroup::Highlight ) );
+
+ if ( cb->hasFocus() ) {
+ p->setPen( cg.highlightedText() );
+ p->setBackgroundColor( cg.highlight() );
+
+ } else {
+ p->setPen( cg.text() );
+ p->setBackgroundColor( cg.background() );
+ }
+
+ if ( cb->hasFocus() && !cb->editable() ) {
+ TQRect re =
+ TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), widget );
+ drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, TQStyleOption(cg.highlight()));
+ }
+ }
+
+ break;
+#endif // QT_NO_COMBOBOX
+
+#ifndef QT_NO_SLIDER
+ case CC_Slider:
+ {
+ const TQSlider *sl = (const TQSlider *) widget;
+ int thickness = pixelMetric( PM_SliderControlThickness, widget );
+ int len = pixelMetric( PM_SliderLength, widget );
+ int ticks = sl->tickmarks();
+
+ TQRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
+ opt),
+ handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
+ opt);
+
+ if ((sub & SC_SliderGroove) && groove.isValid()) {
+ int mid = thickness / 2;
+
+ if ( ticks & TQSlider::Above )
+ mid += len / 8;
+ if ( ticks & TQSlider::Below )
+ mid -= len / 8;
+
+ p->setPen( cg.shadow() );
+ if ( sl->orientation() == Horizontal ) {
+ qDrawWinPanel( p, groove.x(), groove.y() + mid - 2,
+ groove.width(), 4, cg, TRUE );
+ p->drawLine( groove.x() + 1, groove.y() + mid - 1,
+ groove.x() + groove.width() - 3, groove.y() + mid - 1 );
+ } else {
+ qDrawWinPanel( p, groove.x() + mid - 2, groove.y(),
+ 4, groove.height(), cg, TRUE );
+ p->drawLine( groove.x() + mid - 1, groove.y() + 1,
+ groove.x() + mid - 1,
+ groove.y() + groove.height() - 3 );
+ }
+ }
+
+ if (sub & SC_SliderTickmarks)
+ TQCommonStyle::drawComplexControl(ctrl, p, widget, r, cg, flags,
+ SC_SliderTickmarks, subActive,
+ opt );
+
+ if ( sub & SC_SliderHandle ) {
+ // 4444440
+ // 4333310
+ // 4322210
+ // 4322210
+ // 4322210
+ // 4322210
+ // *43210*
+ // **410**
+ // ***0***
+ const TQColor c0 = cg.shadow();
+ const TQColor c1 = cg.dark();
+ // const TQColor c2 = g.button();
+ const TQColor c3 = cg.midlight();
+ const TQColor c4 = cg.light();
+
+ int x = handle.x(), y = handle.y(),
+ wi = handle.width(), he = handle.height();
+
+ int x1 = x;
+ int x2 = x+wi-1;
+ int y1 = y;
+ int y2 = y+he-1;
+
+ Orientation orient = sl->orientation();
+ bool tickAbove = sl->tickmarks() == TQSlider::Above;
+ bool tickBelow = sl->tickmarks() == TQSlider::Below;
+
+ p->fillRect( x, y, wi, he, cg.brush( TQColorGroup::Background ) );
+
+ if ( flags & Style_HasFocus ) {
+ TQRect re = subRect( SR_SliderFocusRect, sl );
+ drawPrimitive( PE_FocusRect, p, re, cg );
+ }
+
+ if ( (tickAbove && tickBelow) || (!tickAbove && !tickBelow) ) {
+ qDrawWinButton( p, TQRect(x,y,wi,he), cg, FALSE,
+ &cg.brush( TQColorGroup::Button ) );
+ return;
+ }
+
+ TQSliderDirection dir;
+
+ if ( orient == Horizontal )
+ if ( tickAbove )
+ dir = SlUp;
+ else
+ dir = SlDown;
+ else
+ if ( tickAbove )
+ dir = SlLeft;
+ else
+ dir = SlRight;
+
+ TQPointArray a;
+
+ int d = 0;
+ switch ( dir ) {
+ case SlUp:
+ y1 = y1 + wi/2;
+ d = (wi + 1) / 2 - 1;
+ a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d );
+ break;
+ case SlDown:
+ y2 = y2 - wi/2;
+ d = (wi + 1) / 2 - 1;
+ a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1 );
+ break;
+ case SlLeft:
+ d = (he + 1) / 2 - 1;
+ x1 = x1 + he/2;
+ a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
+ break;
+ case SlRight:
+ d = (he + 1) / 2 - 1;
+ x2 = x2 - he/2;
+ a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1 );
+ break;
+ }
+
+ TQBrush oldBrush = p->brush();
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->setPen( NoPen );
+ p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
+ p->drawPolygon( a );
+ p->setBrush( oldBrush );
+
+ if ( dir != SlUp ) {
+ p->setPen( c4 );
+ p->drawLine( x1, y1, x2, y1 );
+ p->setPen( c3 );
+ p->drawLine( x1, y1+1, x2, y1+1 );
+ }
+ if ( dir != SlLeft ) {
+ p->setPen( c3 );
+ p->drawLine( x1+1, y1+1, x1+1, y2 );
+ p->setPen( c4 );
+ p->drawLine( x1, y1, x1, y2 );
+ }
+ if ( dir != SlRight ) {
+ p->setPen( c0 );
+ p->drawLine( x2, y1, x2, y2 );
+ p->setPen( c1 );
+ p->drawLine( x2-1, y1+1, x2-1, y2-1 );
+ }
+ if ( dir != SlDown ) {
+ p->setPen( c0 );
+ p->drawLine( x1, y2, x2, y2 );
+ p->setPen( c1 );
+ p->drawLine( x1+1, y2-1, x2-1, y2-1 );
+ }
+
+ switch ( dir ) {
+ case SlUp:
+ p->setPen( c4 );
+ p->drawLine( x1, y1, x1+d, y1-d);
+ p->setPen( c0 );
+ d = wi - d - 1;
+ p->drawLine( x2, y1, x2-d, y1-d);
+ d--;
+ p->setPen( c3 );
+ p->drawLine( x1+1, y1, x1+1+d, y1-d );
+ p->setPen( c1 );
+ p->drawLine( x2-1, y1, x2-1-d, y1-d);
+ break;
+ case SlDown:
+ p->setPen( c4 );
+ p->drawLine( x1, y2, x1+d, y2+d);
+ p->setPen( c0 );
+ d = wi - d - 1;
+ p->drawLine( x2, y2, x2-d, y2+d);
+ d--;
+ p->setPen( c3 );
+ p->drawLine( x1+1, y2, x1+1+d, y2+d );
+ p->setPen( c1 );
+ p->drawLine( x2-1, y2, x2-1-d, y2+d);
+ break;
+ case SlLeft:
+ p->setPen( c4 );
+ p->drawLine( x1, y1, x1-d, y1+d);
+ p->setPen( c0 );
+ d = he - d - 1;
+ p->drawLine( x1, y2, x1-d, y2-d);
+ d--;
+ p->setPen( c3 );
+ p->drawLine( x1, y1+1, x1-d, y1+1+d );
+ p->setPen( c1 );
+ p->drawLine( x1, y2-1, x1-d, y2-1-d);
+ break;
+ case SlRight:
+ p->setPen( c4 );
+ p->drawLine( x2, y1, x2+d, y1+d);
+ p->setPen( c0 );
+ d = he - d - 1;
+ p->drawLine( x2, y2, x2+d, y2-d);
+ d--;
+ p->setPen( c3 );
+ p->drawLine( x2, y1+1, x2+d, y1+1+d );
+ p->setPen( c1 );
+ p->drawLine( x2, y2-1, x2+d, y2-1-d);
+ break;
+ }
+ }
+
+ break;
+ }
+#endif // QT_NO_SLIDER
+
+ default:
+ TQCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub,
+ subActive, opt );
+ break;
+ }
+}
+
+
+/*! \reimp */
+int TQWindowsStyle::styleHint( StyleHint hint,
+ const TQWidget *widget,
+ const TQStyleOption &opt,
+ TQStyleHintReturn *returnData ) const
+{
+ int ret;
+
+ switch (hint) {
+ case SH_EtchDisabledText:
+ case SH_Slider_SnapToValue:
+ case SH_PrintDialog_RightAlignButtons:
+ case SH_MainWindow_SpaceBelowMenuBar:
+ case SH_FontDialog_SelectAssociatedText:
+ case SH_PopupMenu_AllowActiveAndDisabled:
+ case SH_MenuBar_AltKeyNavigation:
+ case SH_MenuBar_MouseTracking:
+ case SH_PopupMenu_MouseTracking:
+ case SH_ComboBox_ListMouseTracking:
+ case SH_ScrollBar_StopMouseOverSlider:
+ ret = 1;
+ break;
+
+ case SH_ItemView_ChangeHighlightOnFocus:
+#if defined(Q_WS_WIN)
+ if ( qWinVersion() != WV_95 && qWinVersion() != WV_NT )
+ ret = 1;
+ else
+#endif
+ ret = 0;
+ break;
+
+ case SH_ToolBox_SelectedPageTitleBold:
+ ret = 0;
+ break;
+
+#if defined(Q_WS_WIN)
+ case SH_UnderlineAccelerator:
+ ret = 1;
+ if ( qWinVersion() != WV_95 && qWinVersion() != WV_98 && qWinVersion() != WV_NT ) {
+ BOOL cues;
+ SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
+ ret = cues ? 1 : 0;
+ // Do nothing if we always paint underlines
+ if (!ret && widget && d) {
+ TQMenuBar *menuBar = ::qt_cast<TQMenuBar*>(widget);
+ TQPopupMenu *popupMenu = 0;
+ if (!menuBar)
+ popupMenu = ::qt_cast<TQPopupMenu*>(widget);
+
+ // If we paint a menubar draw underlines if it has focus, or if alt is down,
+ // or if a popup menu belonging to the menubar is active and paints underlines
+ if (menuBar) {
+ if (menuBar->hasFocus()) {
+ ret = 1;
+ } else if (d->altDown()) {
+ ret = 1;
+ } else if (qApp->focusWidget() && qApp->focusWidget()->isPopup()) {
+ popupMenu = ::qt_cast<TQPopupMenu*>(qApp->focusWidget());
+ TQMenuData *pm = popupMenu ? (TQMenuData*)popupMenu->qt_cast("TQMenuData") : 0;
+ if (pm && ((FriendlyMenuData*)pm)->parentMenu == menuBar) {
+ if (d->hasSeenAlt(menuBar))
+ ret = 1;
+ }
+ }
+ // If we paint a popup menu draw underlines if the respective menubar does
+ } else if (popupMenu) {
+ TQMenuData *pm = (TQMenuData*)popupMenu->qt_cast("TQMenuData");
+ while (pm) {
+ if (((FriendlyMenuData*)pm)->isMenuBar) {
+ menuBar = (TQMenuBar*)pm;
+ if (d->hasSeenAlt(menuBar))
+ ret = 1;
+ break;
+ }
+ pm = ((FriendlyMenuData*)pm)->parentMenu;
+ }
+ // Otherwise draw underlines if the toplevel widget has seen an alt-press
+ } else if (d->hasSeenAlt(widget)) {
+ ret = 1;
+ }
+ }
+
+ }
+ break;
+#endif
+
+ default:
+ ret = TQCommonStyle::styleHint(hint, widget, opt, returnData);
+ break;
+ }
+
+ return ret;
+}
+
+/*! \reimp */
+TQRect TQWindowsStyle::subRect(SubRect r, const TQWidget *widget) const
+{
+ TQRect rect;
+
+ switch (r) {
+#ifndef QT_NO_SLIDER
+ case SR_SliderFocusRect:
+ {
+ rect = widget->rect();
+ break;
+ }
+#endif // QT_NO_SLIDER
+ case SR_ToolBoxTabContents:
+ rect = widget->rect();
+ break;
+ default:
+ rect = TQCommonStyle::subRect( r, widget );
+ break;
+ }
+
+ return rect;
+}
+
+#endif
diff --git a/src/styles/qwindowsstyle.h b/src/styles/qwindowsstyle.h
new file mode 100644
index 000000000..1a6f4c27a
--- /dev/null
+++ b/src/styles/qwindowsstyle.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Definition of Windows-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of the widgets module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQWINDOWSSTYLE_H
+#define TQWINDOWSSTYLE_H
+
+#ifndef QT_H
+#include "qcommonstyle.h"
+#endif // QT_H
+
+#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
+
+#if defined(QT_PLUGIN)
+#define Q_EXPORT_STYLE_WINDOWS
+#else
+#define Q_EXPORT_STYLE_WINDOWS Q_EXPORT
+#endif
+
+
+class Q_EXPORT_STYLE_WINDOWS TQWindowsStyle : public TQCommonStyle
+{
+ Q_OBJECT
+public:
+ TQWindowsStyle();
+ ~TQWindowsStyle();
+
+ void polish(TQApplication*);
+ void unPolish(TQApplication*);
+
+ void polish(TQWidget*);
+ void unPolish(TQWidget*);
+
+ void polish( TQPalette & );
+
+ virtual void polishPopupMenu( TQPopupMenu* );
+
+ // new stuff
+ void drawPrimitive( PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void drawComplexControl( ComplexControl control,
+ TQPainter* p,
+ const TQWidget* widget,
+ const TQRect& r,
+ const TQColorGroup& cg,
+ SFlags flags = Style_Default,
+#ifdef Q_QDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int pixelMetric( PixelMetric metric,
+ const TQWidget *widget = 0 ) const;
+
+ TQSize sizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int styleHint(StyleHint sh, const TQWidget *, const TQStyleOption & = TQStyleOption::Default,
+ TQStyleHintReturn* = 0) const;
+
+ TQPixmap stylePixmap( StylePixmap stylepixmap,
+ const TQWidget *widget = 0,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect subRect( SubRect r, const TQWidget *widget ) const;
+
+
+private:
+ class Private;
+ Private *d;
+
+ // Disabled copy constructor and operator=
+#if defined(Q_DISABLE_COPY)
+ TQWindowsStyle( const TQWindowsStyle & );
+ TQWindowsStyle& operator=( const TQWindowsStyle & );
+#endif
+};
+
+#endif // QT_NO_STYLE_WINDOWS
+
+#endif // TQWINDOWSSTYLE_H