summaryrefslogtreecommitdiffstats
path: root/tqtinterface/qt4/src/styles
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:17:53 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:17:53 -0500
commitdda8474928bd7276e1fad8fb7a601e7c83ff2bc2 (patch)
tree7f83910598b33b12730035f086df20b5a53ab99c /tqtinterface/qt4/src/styles
parent6260b6178868c03aab1644bf93b0ef043654bdb0 (diff)
downloadexperimental-dda8474928bd7276e1fad8fb7a601e7c83ff2bc2.tar.gz
experimental-dda8474928bd7276e1fad8fb7a601e7c83ff2bc2.zip
Added TQt4 HEAD
Diffstat (limited to 'tqtinterface/qt4/src/styles')
-rw-r--r--tqtinterface/qt4/src/styles/qt_styles.pri140
-rw-r--r--tqtinterface/qt4/src/styles/tqcdestyle.cpp367
-rw-r--r--tqtinterface/qt4/src/styles/tqcdestyle.h86
-rw-r--r--tqtinterface/qt4/src/styles/tqcommonstyle.cpp2726
-rw-r--r--tqtinterface/qt4/src/styles/tqcommonstyle.h154
-rw-r--r--tqtinterface/qt4/src/styles/tqcompactstyle.cpp321
-rw-r--r--tqtinterface/qt4/src/styles/tqcompactstyle.h75
-rw-r--r--tqtinterface/qt4/src/styles/tqinterlacestyle.cpp805
-rw-r--r--tqtinterface/qt4/src/styles/tqinterlacestyle.h107
-rw-r--r--tqtinterface/qt4/src/styles/tqmotifplusstyle.cpp1586
-rw-r--r--tqtinterface/qt4/src/styles/tqmotifplusstyle.h124
-rw-r--r--tqtinterface/qt4/src/styles/tqmotifstyle.cpp2367
-rw-r--r--tqtinterface/qt4/src/styles/tqmotifstyle.h136
-rw-r--r--tqtinterface/qt4/src/styles/tqplatinumstyle.cpp1557
-rw-r--r--tqtinterface/qt4/src/styles/tqplatinumstyle.h117
-rw-r--r--tqtinterface/qt4/src/styles/tqsgistyle.cpp1470
-rw-r--r--tqtinterface/qt4/src/styles/tqsgistyle.h133
-rw-r--r--tqtinterface/qt4/src/styles/tqstylefactory.cpp268
-rw-r--r--tqtinterface/qt4/src/styles/tqstylefactory.h62
-rw-r--r--tqtinterface/qt4/src/styles/tqstyleinterface_p.h76
-rw-r--r--tqtinterface/qt4/src/styles/tqstyleplugin.cpp185
-rw-r--r--tqtinterface/qt4/src/styles/tqstyleplugin.h72
-rw-r--r--tqtinterface/qt4/src/styles/tqwindowsstyle.cpp2166
-rw-r--r--tqtinterface/qt4/src/styles/tqwindowsstyle.h134
24 files changed, 15234 insertions, 0 deletions
diff --git a/tqtinterface/qt4/src/styles/qt_styles.pri b/tqtinterface/qt4/src/styles/qt_styles.pri
new file mode 100644
index 0000000..baf36d5
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/qt_styles.pri
@@ -0,0 +1,140 @@
+# Qt styles module
+
+styles {
+ STYLES_P = styles
+ HEADERS +=$$STYLES_H/tqstylefactory.h \
+ $$STYLES_P/tqstyleinterface_p.h \
+ $$STYLES_H/tqstyleplugin.h \
+ $$STYLES_H/tqcommonstyle.h
+ SOURCES +=$$STYLES_CPP/tqstylefactory.cpp \
+ $$STYLES_CPP/tqstyleplugin.cpp \
+ $$STYLES_CPP/tqcommonstyle.cpp
+
+ tqcontains( styles, all ) {
+ styles += mac cde motifplus sgi platinum compact interlace windows motif
+ }
+
+ x11|embedded|!macx-*:styles -= mac
+ tqcontains( styles, mac ) {
+ HEADERS +=$$STYLES_H/tqmacstyle_mac.h \
+ $$STYLES_H/tqmacstylepixmaps_mac_p.h
+ SOURCES +=$$STYLES_CPP/tqmacstyle_mac.cpp
+ HEADERS *= $$STYLES_CPP/tqaquastyle_p.h
+ SOURCES *= $$STYLES_CPP/tqaquastyle_p.cpp
+
+ !tqcontains( styles, windows ) {
+ message( mac requires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_MAC
+
+ #embedded|!macx-*:styles -= aqua
+ tqcontains( styles, aqua ) {
+ HEADERS += $$STYLES_H/tqaquastyle.h
+ SOURCES += $$STYLES_CPP/tqaquastyle.cpp
+ HEADERS *= $$STYLES_CPP/tqaquastyle_p.h
+ SOURCES *= $$STYLES_CPP/tqaquastyle_p.cpp
+
+ !tqcontains( styles, windows ) {
+ message( aqua requires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_AQUA
+
+ tqcontains( styles, cde ) {
+ HEADERS +=$$STYLES_H/tqcdestyle.h
+ SOURCES +=$$STYLES_CPP/tqcdestyle.cpp
+
+ !tqcontains( styles, motif ) {
+ message( cde requires motif )
+ styles += motif
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_CDE
+
+ tqcontains( styles, motifplus ) {
+ HEADERS +=$$STYLES_H/tqmotifplusstyle.h
+ SOURCES +=$$STYLES_CPP/tqmotifplusstyle.cpp
+ !tqcontains( styles, motif ) {
+ message( motifplus requires motif )
+ styles += motif
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_MOTIFPLUS
+
+ tqcontains( styles, interlace ) {
+ HEADERS +=$$STYLES_H/tqinterlacestyle.h
+ SOURCES +=$$STYLES_CPP/tqinterlacestyle.cpp
+ !tqcontains( styles, windows ) {
+ message( interlace requires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_INTERLACE
+
+ tqcontains( styles, platinum ) {
+ HEADERS +=$$STYLES_H/tqplatinumstyle.h
+ SOURCES +=$$STYLES_CPP/tqplatinumstyle.cpp
+ !tqcontains( styles, windows ) {
+ message( platinum requires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_PLATINUM
+
+ tqcontains( styles, windowsxp ) {
+ HEADERS +=$$STYLES_H/tqwindowsxpstyle.h
+ SOURCES +=$$STYLES_CPP/tqwindowsxpstyle.cpp
+ !tqcontains( styles, windowsxp ) {
+ message( windowsxp requires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_WINDOWSXP
+
+ tqcontains( styles, sgi ) {
+ HEADERS +=$$STYLES_H/tqsgistyle.h
+ SOURCES +=$$STYLES_CPP/tqsgistyle.cpp
+ !tqcontains( styles, motif ) {
+ message( sgi requires motif )
+ styles += motif
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_SGI
+
+ tqcontains( styles, compact ) {
+ HEADERS +=$$STYLES_H/tqcompactstyle.h
+ SOURCES +=$$STYLES_CPP/tqcompactstyle.cpp
+ !tqcontains( styles, windows ) {
+ message( compact requires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_COMPACT
+
+ wince-*:styles += pocketpc
+ tqcontains( styles, pocketpc ) {
+ HEADERS +=$$STYLES_H/tqpocketpcstyle_wce.h
+ SOURCES +=$$STYLES_CPP/tqpocketpcstyle_wce.cpp
+
+ !tqcontains( styles, windows ) {
+ message( pocketpc requires windows )
+ styles += windows
+ }
+ }
+ else:DEFINES += TQT_NO_STYLE_POCKETPC
+
+ tqcontains( styles, windows ) {
+ HEADERS +=$$STYLES_H/tqwindowsstyle.h
+ SOURCES +=$$STYLES_CPP/tqwindowsstyle.cpp
+ }
+ else:DEFINES += TQT_NO_STYLE_WINDOWS
+
+ tqcontains( styles, motif ) {
+ HEADERS +=$$STYLES_H/tqmotifstyle.h
+ SOURCES +=$$STYLES_CPP/tqmotifstyle.cpp
+ }
+ else:DEFINES += TQT_NO_STYLE_MOTIF
+}
diff --git a/tqtinterface/qt4/src/styles/tqcdestyle.cpp b/tqtinterface/qt4/src/styles/tqcdestyle.cpp
new file mode 100644
index 0000000..8dda161
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqcdestyle.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 requirements 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 "tqcdestyle.h"
+
+#if !defined(TQT_NO_STYLE_CDE) || defined(TQT_PLUGIN)
+
+#include "tqpainter.h"
+#include "tqdrawutil.h"
+#include "tqbutton.h"
+#include <limits.h>
+
+/*!
+ \class TQCDEStyle tqcdestyle.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 quite 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::tqpixelMetric( 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::tqpixelMetric( metric, widget );
+ break;
+ }
+ return ret;
+}
+
+/*! \reimp
+*/
+void TQCDEStyle::tqdrawControl( 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::tqdrawControl( element, p, widget, r, cg, how, opt );
+ break;
+ }
+ default:
+ TQMotifStyle::tqdrawControl( element, p, widget, r, cg, how, opt );
+ break;
+ }
+
+
+}
+
+/*! \reimp
+*/
+void TQCDEStyle::tqdrawPrimitiveBase( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch( pe ) {
+ case PE_Indicator: {
+#ifndef TQT_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, tqpixelMetric( 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(Qt::color1);
+ p->setBrush(Qt::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->tqworldMatrix();
+ TQPen pen( Qt::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( Qt::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::tqdrawPrimitive( pe, p, r, cg, flags, opt );
+ }
+}
+
+#endif
diff --git a/tqtinterface/qt4/src/styles/tqcdestyle.h b/tqtinterface/qt4/src/styles/tqcdestyle.h
new file mode 100644
index 0000000..e248082
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqcdestyle.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 requirements 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 TQT_H
+#include "tqmotifstyle.h"
+#endif // TQT_H
+
+#if !defined(TQT_NO_STYLE_CDE) || defined(TQT_PLUGIN)
+
+#if defined(TQT_PLUGIN)
+#define TQ_EXPORT_STYLE_CDE
+#else
+#define TQ_EXPORT_STYLE_CDE TQ_EXPORT
+#endif
+
+class TQ_EXPORT_STYLE_CDE TQCDEStyle : public TQMotifStyle
+{
+ TQ_OBJECT
+public:
+
+ TQCDEStyle( bool useHighlightCols = FALSE );
+ virtual ~TQCDEStyle();
+
+ int tqpixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const;
+
+ void tqdrawControl( ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawPrimitiveBase( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+};
+
+#endif // TQT_NO_STYLE_CDE
+
+#endif // TQCDESTYLE_H
diff --git a/tqtinterface/qt4/src/styles/tqcommonstyle.cpp b/tqtinterface/qt4/src/styles/tqcommonstyle.cpp
new file mode 100644
index 0000000..c69fea7
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqcommonstyle.cpp
@@ -0,0 +1,2726 @@
+/****************************************************************************
+**
+** 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 requirements 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 "tqcommonstyle.h"
+
+#ifndef TQT_NO_STYLE
+
+#include "tqmenubar.h"
+#include "tqapplication.h"
+#include "tqpainter.h"
+#include "tqdrawutil.h"
+#include "tqpixmap.h"
+#include "tqpushbutton.h"
+#include "tqtabbar.h"
+#include "tqscrollbar.h"
+#include "tqtoolbutton.h"
+#include "tqtoolbar.h"
+#include "tqdockarea.h"
+#include "tqheader.h"
+#include "tqspinbox.h"
+#include "tqrangecontrol.h"
+#include "tqgroupbox.h"
+#include "tqslider.h"
+#include "tqlistview.h"
+#include "tqcheckbox.h"
+#include "tqradiobutton.h"
+#include "tqbitmap.h"
+#include "tqprogressbar.h"
+#include "private/tqdialogbuttons_p.h"
+#include <limits.h>
+#include <tqpixmap.h>
+#include "../widgets/tqtitlebar_p.h"
+#include <tqtoolbox.h>
+
+/*!
+ \class TQCommonStyle tqcommonstyle.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::tqitemRect() 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::tqdrawPrimitive( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ activePainter = p;
+
+ switch (pe) {
+#ifndef TQT_NO_LISTVIEW
+ case TQStyle::PE_CheckListController: {
+ p->drawPixmap(r, TQPixmap((const char **)check_list_controller_xpm));
+ break; }
+ case TQStyle::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->tqpalette().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( TQt::NoPen );
+ p->setBrush( cg.text() );
+ p->drawRect( x+5, y+4, 2, 4 );
+ p->drawRect( x+4, y+5, 4, 2 );
+ }
+ break; }
+ case TQStyle::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->tqpalette().color( TQPalette::Disabled, TQColorGroup::Text ),
+ 2 ) );
+ bool parentControl = FALSE;
+ if ( item->tqparent() && item->tqparent()->rtti() == 1 &&
+ ((TQCheckListItem*) item->tqparent())->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 TQStyle::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 TQStyle::PE_StatusBarSection:
+ qDrawShadeRect( p, r, cg, TRUE, 1, 0, 0 );
+ break;
+
+ case TQStyle::PE_ButtonCommand:
+ case TQStyle::PE_ButtonBevel:
+ case TQStyle::PE_ButtonTool:
+ case TQStyle::PE_ButtonDropDown:
+ case TQStyle::PE_HeaderSection:
+ qDrawShadePanel(p, r, cg, flags & (Style_Sunken | Style_Down | Style_On) , 1,
+ &cg.brush(TQColorGroup::Button));
+ break;
+
+ case TQStyle::PE_Separator:
+ qDrawShadeLine( p, r.left(), r.top(), r.right(), r.bottom(), cg,
+ flags & Style_Sunken, 1, 0);
+ break;
+
+ case TQStyle::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 TQStyle::PE_SpinWidgetPlus:
+ case TQStyle::PE_SpinWidgetMinus: {
+ p->save();
+ int fw = tqpixelMetric( 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 == TQStyle::PE_SpinWidgetPlus )
+ p->drawLine( ( x+w / 2 ) - 1, y + ymarg,
+ ( x+w / 2 ) - 1, y + ymarg + length - 1 );
+ p->restore();
+ break; }
+
+ case TQStyle::PE_SpinWidgetUp:
+ case TQStyle::PE_SpinWidgetDown: {
+ int fw = tqpixelMetric( 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 == TQStyle::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 = tqpixelMetric(PM_ButtonShiftHorizontal);
+ bsy = tqpixelMetric(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 TQStyle::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 TQStyle::PE_IndicatorMask: {
+ p->fillRect(r, Qt::color1);
+ break; }
+
+ case TQStyle::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 TQStyle::PE_ExclusiveIndicatorMask: {
+ p->setPen(Qt::color1);
+ p->setBrush(Qt::color1);
+ p->drawEllipse(r);
+ break; }
+
+ case TQStyle::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 TQStyle::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 TQStyle::PE_Panel:
+ case TQStyle::PE_PanelPopup: {
+ int lw = opt.isDefault() ? tqpixelMetric(PM_DefaultFrameWidth)
+ : opt.lineWidth();
+
+ qDrawShadePanel(p, r, cg, (flags & Style_Sunken), lw);
+ break; }
+
+ case TQStyle::PE_PanelDockWindow: {
+ int lw = opt.isDefault() ? tqpixelMetric(PM_DockWindowFrameWidth)
+ : opt.lineWidth();
+
+ qDrawShadePanel(p, r, cg, FALSE, lw);
+ break; }
+
+ case TQStyle::PE_PanelMenuBar: {
+ int lw = opt.isDefault() ? tqpixelMetric(PM_MenuBarFrameWidth)
+ : opt.lineWidth();
+
+ qDrawShadePanel(p, r, cg, FALSE, lw, &cg.brush(TQColorGroup::Button));
+ break; }
+
+ case TQStyle::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 TQStyle::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 TQStyle::PE_PanelGroupBox: //We really do not need TQStyle::PE_GroupBoxFrame anymore, nasty holdover ###
+ tqdrawPrimitive( TQStyle::PE_GroupBoxFrame, p, r, cg, flags, opt );
+ break;
+ case TQStyle::PE_GroupBoxFrame: {
+#ifndef TQT_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 TQStyle::PE_ProgressBarChunk:
+ p->fillRect( r.x(), r.y() + 3, r.width() -2, r.height() - 6,
+ cg.brush(TQColorGroup::Highlight));
+ break;
+
+ case TQStyle::PE_PanelLineEdit:
+ case TQStyle::PE_PanelTabWidget:
+ case TQStyle::PE_WindowFrame:
+ tqdrawPrimitive( TQStyle::PE_Panel, p, r, cg, flags, opt );
+ break;
+
+ case TQStyle::PE_RubberBand:
+ tqdrawPrimitive(TQStyle::PE_FocusRect, p, r, cg, flags, opt);
+ break;
+ default:
+ break;
+ }
+
+ activePainter = 0;
+}
+
+/*! \reimp */
+void TQCommonStyle::tqdrawControl( TQ_ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+#if defined(TQT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::tqdrawControl: 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 TQT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ TQRect br = r;
+ int dbi = tqpixelMetric(PM_ButtonDefaultIndicator, widget);
+
+ if (button->isDefault() || button->autoDefault()) {
+ if ( button->isDefault())
+ tqdrawPrimitive(TQStyle::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() );
+ tqdrawPrimitive(TQStyle::PE_ButtonCommand, p, br, cg, flags);
+ p->restore();
+#endif
+ break;
+ }
+
+ case CE_PushButtonLabel:
+ {
+#ifndef TQT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ TQRect ir = r;
+
+ if (button->isDown() || button->isOn()) {
+ flags |= Style_Sunken;
+ ir.moveBy(tqpixelMetric(PM_ButtonShiftHorizontal, widget),
+ tqpixelMetric(PM_ButtonShiftVertical, widget));
+ }
+
+ if (button->isMenuButton()) {
+ int mbi = tqpixelMetric(PM_MenuButtonIndicator, widget);
+ TQRect ar(ir.right() - mbi, ir.y() + 2, mbi - 4, ir.height() - 4);
+ tqdrawPrimitive(TQStyle::PE_ArrowDown, p, ar, cg, flags, opt);
+ ir.setWidth(ir.width() - mbi);
+ }
+
+ int tf=TQt::AlignVCenter | TQt::ShowPrefix;
+ if (!tqstyleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ tf |= TQt::NoAccel;
+
+#ifndef TQT_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 |= TQt::AlignLeft;
+ else if (button->pixmap())
+ tf |= TQt::AlignHCenter;
+ } else
+#endif //TQT_NO_ICONSET
+ tf |= TQt::AlignHCenter;
+ drawItem(p, ir, tf, cg,
+ flags & Style_Enabled, button->pixmap(), button->text(),
+ button->text().length(), TQT_TQCOLOR_CONST(&(cg.buttonText())) );
+
+ if (flags & Style_HasFocus)
+ tqdrawPrimitive(TQStyle::PE_FocusRect, p, subRect(SR_PushButtonFocusRect, widget),
+ cg, flags);
+#endif
+ break;
+ }
+
+ case CE_CheckBox:
+ tqdrawPrimitive(TQStyle::PE_Indicator, p, r, cg, flags, opt);
+ break;
+
+ case CE_CheckBoxLabel:
+ {
+#ifndef TQT_NO_CHECKBOX
+ const TQCheckBox *checkbox = (const TQCheckBox *) widget;
+
+ int tqalignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
+ if (!tqstyleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ tqalignment |= TQt::NoAccel;
+
+ drawItem(p, r, tqalignment | TQt::AlignVCenter | TQt::ShowPrefix, cg,
+ flags & Style_Enabled, checkbox->pixmap(), checkbox->text());
+
+ if (flags & Style_HasFocus) {
+ TQRect fr = tqvisualRect(subRect(SR_CheckBoxFocusRect, widget), widget);
+ tqdrawPrimitive(TQStyle::PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CE_RadioButton:
+ tqdrawPrimitive(TQStyle::PE_ExclusiveIndicator, p, r, cg, flags, opt);
+ break;
+
+ case CE_RadioButtonLabel:
+ {
+#ifndef TQT_NO_RADIOBUTTON
+ const TQRadioButton *radiobutton = (const TQRadioButton *) widget;
+
+ int tqalignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
+ if (!tqstyleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ tqalignment |= TQt::NoAccel;
+ drawItem(p, r, tqalignment | TQt::AlignVCenter | TQt::ShowPrefix, cg,
+ flags & Style_Enabled, radiobutton->pixmap(), radiobutton->text());
+
+ if (flags & Style_HasFocus) {
+ TQRect fr = tqvisualRect(subRect(SR_RadioButtonFocusRect, widget), widget);
+ tqdrawPrimitive(TQStyle::PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+#ifndef TQT_NO_TABBAR
+ case CE_TabBarTab:
+ {
+ const TQTabBar * tb = (const TQTabBar *) widget;
+
+ if ( tb->tqshape() == TQTabBar::TriangularAbove ||
+ tb->tqshape() == 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->tqshape() == 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( TQt::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() -
+ tqpixelMetric( TQStyle::PM_DefaultFrameWidth, tb ) );
+
+ int tqalignment = TQt::AlignCenter | TQt::ShowPrefix;
+ if (!tqstyleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ tqalignment |= TQt::NoAccel;
+ drawItem( p, tr, tqalignment, cg,
+ flags & Style_Enabled, 0, t->text() );
+
+ if ( (flags & Style_HasFocus) && !t->text().isEmpty() )
+ tqdrawPrimitive( TQStyle::PE_FocusRect, p, r, cg );
+ break;
+ }
+#endif // TQT_NO_TABBAR
+#ifndef TQT_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( TQt::NoBrush );
+ break;
+ }
+#endif // TQT_NO_TOOLBOX
+ case CE_ProgressBarGroove:
+ qDrawShadePanel(p, r, cg, TRUE, 1, &cg.brush(TQColorGroup::Background));
+ break;
+
+#ifndef TQT_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->tqpalette().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 = tqpixelMetric(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++) {
+ tqdrawPrimitive( TQStyle::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;
+ tqdrawPrimitive( TQStyle::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, TQt::AlignCenter | TQt::SingleLine, cg, flags & Style_Enabled, 0,
+ progressbar->progressString(), -1, pcolor );
+ }
+ break;
+#endif // TQT_NO_PROGRESSBAR
+
+ case CE_MenuBarItem:
+ {
+#ifndef TQT_NO_MENUDATA
+ if (opt.isDefault())
+ break;
+
+ TQMenuItem *mi = opt.menuItem();
+ int tqalignment = TQt::AlignCenter|TQt::ShowPrefix|TQt::DontClip|TQt::SingleLine;
+ if (!tqstyleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ tqalignment |= TQt::NoAccel;
+ drawItem( p, r, tqalignment, cg,
+ flags & Style_Enabled, mi->pixmap(), mi->text(), -1,
+ TQT_TQCOLOR_CONST(&cg.buttonText()) );
+#endif
+ break;
+ }
+
+#ifndef TQT_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 = tqpixelMetric(PM_ButtonShiftHorizontal, widget);
+ shiftY = tqpixelMetric(PM_ButtonShiftVertical, widget);
+ }
+
+ if (!opt.isDefault()) {
+ PrimitiveElement pe;
+ switch (arrowType) {
+ case TQt::LeftArrow: pe = TQStyle::PE_ArrowLeft; break;
+ case TQt::RightArrow: pe = TQStyle::PE_ArrowRight; break;
+ case TQt::UpArrow: pe = TQStyle::PE_ArrowUp; break;
+ default:
+ case TQt::DownArrow: pe = TQStyle::PE_ArrowDown; break;
+ }
+
+ rect.moveBy(shiftX, shiftY);
+ tqdrawPrimitive(pe, p, rect, cg, flags, opt);
+ } else {
+ TQColor btext = toolbutton->paletteForegroundColor();
+
+ if (toolbutton->iconSet().isNull() &&
+ ! toolbutton->text().isNull() &&
+ ! toolbutton->usesTextLabel()) {
+ int tqalignment = TQt::AlignCenter | TQt::ShowPrefix;
+ if (!tqstyleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ tqalignment |= TQt::NoAccel;
+
+ rect.moveBy(shiftX, shiftY);
+ drawItem(p, rect, tqalignment, 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 tqalignment = TQt::ShowPrefix;
+ if (!tqstyleHint(SH_UnderlineAccelerator, widget, TQStyleOption::Default, 0))
+ tqalignment |= TQt::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, TQt::AlignCenter, cg, TRUE, &pm, TQString::null );
+ tqalignment |= TQt::AlignCenter;
+ } else {
+ pr.setWidth( pm.width() + 8 );
+ tr.addCoords( pr.right(), 0, 0, 0 );
+ pr.moveBy(shiftX, shiftY);
+
+ drawItem( p, pr, TQt::AlignCenter, cg, TRUE, &pm, TQString::null );
+ tqalignment |= TQt::AlignLeft | TQt::AlignVCenter;
+ }
+
+ tr.moveBy(shiftX, shiftY);
+ drawItem( p, tr, tqalignment, cg,
+ flags & Style_Enabled, 0, toolbutton->textLabel(),
+ toolbutton->textLabel().length(), &btext);
+ } else {
+ rect.moveBy(shiftX, shiftY);
+ drawItem( p, rect, TQt::AlignCenter, cg, TRUE, &pm, TQString::null );
+ }
+ }
+ }
+
+ break;
+ }
+#endif // TQT_NO_TOOLBUTTON
+#ifndef TQT_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, TQt::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, TQt::AlignVCenter, cg, flags & Style_Enabled,
+ 0, header->label( section ), -1, TQT_TQCOLOR_CONST(&(cg.buttonText())) );
+ }
+#endif // TQT_NO_HEADER
+ default:
+ break;
+ }
+
+ activePainter = 0;
+}
+
+/*! \reimp */
+void TQCommonStyle::tqdrawControlMask( TQ_ControlElement control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQStyleOption& opt ) const
+{
+ TQ_UNUSED(widget);
+
+ activePainter = p;
+
+ TQColorGroup cg(Qt::color1,Qt::color1,Qt::color1,Qt::color1,Qt::color1,Qt::color1,Qt::color1,Qt::color1,Qt::color0);
+
+ switch (control) {
+ case CE_PushButton:
+ tqdrawPrimitive(TQStyle::PE_ButtonCommand, p, r, cg, Style_Default, opt);
+ break;
+
+ case CE_CheckBox:
+ tqdrawPrimitive(TQStyle::PE_IndicatorMask, p, r, cg, Style_Default, opt);
+ break;
+
+ case CE_RadioButton:
+ tqdrawPrimitive(TQStyle::PE_ExclusiveIndicatorMask, p, r, cg, Style_Default, opt);
+ break;
+
+ default:
+ p->fillRect(r, Qt::color1);
+ break;
+ }
+
+ activePainter = 0;
+}
+
+/*! \reimp */
+TQRect TQCommonStyle::subRect(SubRect r, const TQWidget *widget) const
+{
+#if defined(TQT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::subRect: widget parameter cannot be zero!");
+ return TQRect();
+ }
+#endif
+
+ TQRect rect, wrect(widget->rect());
+
+ switch (r) {
+#ifndef TQT_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 = tqpixelMetric(PM_DialogButtonsButtonWidth, widget),
+ bheight = tqpixelMetric(PM_DialogButtonsButtonHeight, widget),
+ bspace = tqpixelMetric(PM_DialogButtonsSeparator, widget),
+ fw = tqpixelMetric(PM_DefaultFrameWidth, widget);
+ const TQDialogButtons *dbtns = (const TQDialogButtons *) widget;
+ int start = fw;
+ if(dbtns->orientation() == Qt::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->tqsizeHint(btns[i]);
+ int mwidth = TQMAX(bwidth, szH.width()), mheight = TQMAX(bheight, szH.height());
+ if(dbtns->orientation() == Qt::Horizontal) {
+ start -= mwidth;
+ if(cnt)
+ start -= bspace;
+ } else if(cnt) {
+ start += mheight;
+ start += bspace;
+ }
+ cnt++;
+ if(btns[i] == srch) {
+ if(dbtns->orientation() == Qt::Horizontal)
+ return TQRect(start, wrect.bottom() - fw - mheight, mwidth, mheight);
+ else
+ return TQRect(fw, start, mwidth, mheight);
+ }
+ }
+ }
+ if(r == SR_DialogButtonCustom) {
+ if(dbtns->orientation() == Qt::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 //TQT_NO_DIALOGBUTTONS
+ case SR_PushButtonContents:
+ {
+#ifndef TQT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ int dx1, dx2;
+
+ dx1 = tqpixelMetric(PM_DefaultFrameWidth, widget);
+ if (button->isDefault() || button->autoDefault())
+ dx1 += tqpixelMetric(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 TQT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ int dbw1 = 0, dbw2 = 0;
+ if (button->isDefault() || button->autoDefault()) {
+ dbw1 = tqpixelMetric(PM_ButtonDefaultIndicator, widget);
+ dbw2 = dbw1 * 2;
+ }
+
+ int dfw1 = tqpixelMetric(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 = tqpixelMetric( PM_IndicatorHeight, widget );
+ rect.setRect(0, ( wrect.height() - h ) / 2,
+ tqpixelMetric( PM_IndicatorWidth, widget ), h );
+ break;
+ }
+
+ case SR_CheckBoxContents:
+ {
+#ifndef TQT_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 TQT_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 = tqitemRect((activePainter ? activePainter : p),
+ cr, TQt::AlignLeft | TQt::AlignVCenter | TQt::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 = tqpixelMetric( PM_ExclusiveIndicatorHeight, widget );
+ rect.setRect(0, ( wrect.height() - h ) / 2,
+ tqpixelMetric( 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 TQT_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 = tqitemRect((activePainter ? activePainter : p),
+ cr, TQt::AlignLeft | TQt::AlignVCenter | TQt::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 TQT_NO_SLIDER
+ case SR_SliderFocusRect:
+ {
+ const TQSlider * sl = (const TQSlider *) widget;
+ int tickOffset = tqpixelMetric( PM_SliderTickmarkOffset, sl );
+ int thickness = tqpixelMetric( PM_SliderControlThickness, sl );
+
+ if ( sl->orientation() == Qt::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 // TQT_NO_SLIDER
+
+#ifndef TQT_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() == Qt::Horizontal )
+ rect.setRect(0, 15, widget->width(), widget->height() - 15);
+ else
+ rect.setRect(0, 1, widget->width() - 15, widget->height() - 1);
+ }
+ break;
+ }
+#endif // TQT_NO_MAINWINDOW
+
+ case SR_ProgressBarGroove:
+ case SR_ProgressBarContents:
+ {
+#ifndef TQT_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 TQT_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 TQT_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 // TQT_NO_RANGECONTROL
+
+/*! \reimp */
+void TQCommonStyle::tqdrawComplexControl( TQ_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(TQT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::tqdrawComplexControl: widget parameter cannot be zero!");
+ return;
+ }
+#endif
+
+ activePainter = p;
+
+ switch (control) {
+#ifndef TQT_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())
+ tqdrawPrimitive(TQStyle::PE_ScrollBarSubLine, p, subline, cg,
+ (SFlags)(((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarSubLine) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : 0)));
+ if ((controls & SC_ScrollBarAddLine) && addline.isValid())
+ tqdrawPrimitive(TQStyle::PE_ScrollBarAddLine, p, addline, cg,
+ (SFlags)(((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarAddLine) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : 0)));
+ if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
+ tqdrawPrimitive(TQStyle::PE_ScrollBarSubPage, p, subpage, cg,
+ (SFlags)(((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarSubPage) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : 0)));
+ if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
+ tqdrawPrimitive(TQStyle::PE_ScrollBarAddPage, p, addpage, cg,
+ (SFlags)(((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarAddPage) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : 0)));
+ if ((controls & SC_ScrollBarFirst) && first.isValid())
+ tqdrawPrimitive(TQStyle::PE_ScrollBarFirst, p, first, cg,
+ (SFlags)(((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarFirst) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : 0)));
+ if ((controls & SC_ScrollBarLast) && last.isValid())
+ tqdrawPrimitive(TQStyle::PE_ScrollBarLast, p, last, cg,
+ (SFlags)(((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarLast) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : 0)));
+ if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
+ tqdrawPrimitive(TQStyle::PE_ScrollBarSlider, p, slider, cg,
+ (SFlags)(((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarSlider) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::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);
+ tqdrawPrimitive(TQStyle::PE_FocusRect, p, fr, cg, Style_Default);
+ }
+ }
+
+ break;
+ }
+#endif // TQT_NO_SCROLLBAR
+
+#ifndef TQT_NO_TOOLBUTTON
+ case CC_ToolButton:
+ {
+ const TQToolButton *toolbutton = (const TQToolButton *) widget;
+
+ TQColorGroup c = cg;
+ if ( toolbutton->backgroundMode() != TQt::PaletteButton )
+ c.setBrush( TQColorGroup::Button,
+ toolbutton->paletteBackgroundColor() );
+ TQRect button, menuarea;
+ button = tqvisualRect( querySubControlMetrics(control, widget, SC_ToolButton, opt), widget );
+ menuarea = tqvisualRect( 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)) {
+ tqdrawPrimitive(TQStyle::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))
+ tqdrawPrimitive(TQStyle::PE_ButtonDropDown, p, menuarea, c, mflags, opt);
+ tqdrawPrimitive(TQStyle::PE_ArrowDown, p, menuarea, c, mflags, opt);
+ }
+
+ if (toolbutton->hasFocus() && !toolbutton->focusProxy()) {
+ TQRect fr = toolbutton->rect();
+ fr.addCoords(3, 3, -3, -3);
+ tqdrawPrimitive(TQStyle::PE_FocusRect, p, fr, c);
+ }
+
+ break;
+ }
+#endif // TQT_NO_TOOLBUTTON
+
+#ifndef TQT_NO_TITLEBAR
+ case CC_TitleBar:
+ {
+ const TQTitleBar *titlebar = (const TQTitleBar *) widget;
+ if ( controls & SC_TitleBarLabel ) {
+ TQColorGroup cgroup = titlebar->usesActiveColor() ?
+ titlebar->tqpalette().active() : titlebar->tqpalette().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 = tqvisualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarLabel ), widget );
+
+ p->setPen( cgroup.highlightedText() );
+ p->drawText(ir.x()+2, ir.y(), ir.width()-2, ir.height(),
+ TQt::AlignAuto | TQt::AlignVCenter | TQt::SingleLine, titlebar->visibleText() );
+ }
+
+ TQRect ir;
+ bool down = FALSE;
+ TQPixmap pm;
+
+ if ( controls & SC_TitleBarCloseButton ) {
+ ir = tqvisualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarCloseButton ), widget );
+ down = active & SC_TitleBarCloseButton;
+ if ( widget->testWFlags( TQt::WStyle_Tool )
+#ifndef TQT_NO_MAINWINDOW
+ || ::tqqt_cast<TQDockWindow*>(widget)
+#endif
+ )
+ pm = stylePixmap(SP_DockWindowCloseButton, widget);
+ else
+ pm = stylePixmap(SP_TitleBarCloseButton, widget);
+ tqdrawPrimitive(TQStyle::PE_ButtonTool, p, ir, titlebar->tqcolorGroup(),
+ down ? Style_Down : Style_Raised);
+
+ p->save();
+ if( down )
+ p->translate( tqpixelMetric(PM_ButtonShiftHorizontal, widget),
+ tqpixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, TQt::AlignCenter, titlebar->tqcolorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+
+ if ( titlebar->window() ) {
+ if ( controls & SC_TitleBarMaxButton ) {
+ ir = tqvisualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarMaxButton ), widget );
+
+ down = active & SC_TitleBarMaxButton;
+ pm = TQPixmap(stylePixmap(SP_TitleBarMaxButton, widget));
+ tqdrawPrimitive(TQStyle::PE_ButtonTool, p, ir, titlebar->tqcolorGroup(),
+ down ? Style_Down : Style_Raised);
+
+ p->save();
+ if( down )
+ p->translate( tqpixelMetric(PM_ButtonShiftHorizontal, widget),
+ tqpixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, TQt::AlignCenter, titlebar->tqcolorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+
+ if ( controls & SC_TitleBarNormalButton || controls & SC_TitleBarMinButton ) {
+ ir = tqvisualRect( 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));
+ tqdrawPrimitive(TQStyle::PE_ButtonTool, p, ir, titlebar->tqcolorGroup(),
+ down ? Style_Down : Style_Raised);
+
+ p->save();
+ if( down )
+ p->translate( tqpixelMetric(PM_ButtonShiftHorizontal, widget),
+ tqpixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, TQt::AlignCenter, titlebar->tqcolorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+
+ if ( controls & SC_TitleBarShadeButton ) {
+ ir = tqvisualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarShadeButton ), widget );
+
+ down = active & SC_TitleBarShadeButton;
+ pm = TQPixmap(stylePixmap(SP_TitleBarShadeButton, widget));
+ tqdrawPrimitive(TQStyle::PE_ButtonTool, p, ir, titlebar->tqcolorGroup(),
+ down ? Style_Down : Style_Raised);
+ p->save();
+ if( down )
+ p->translate( tqpixelMetric(PM_ButtonShiftHorizontal, widget),
+ tqpixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, TQt::AlignCenter, titlebar->tqcolorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+
+ if ( controls & SC_TitleBarUnshadeButton ) {
+ ir = tqvisualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarUnshadeButton ), widget );
+
+ down = active & SC_TitleBarUnshadeButton;
+ pm = TQPixmap(stylePixmap(SP_TitleBarUnshadeButton, widget));
+ tqdrawPrimitive(TQStyle::PE_ButtonTool, p, ir, titlebar->tqcolorGroup(),
+ down ? Style_Down : Style_Raised);
+ p->save();
+ if( down )
+ p->translate( tqpixelMetric(PM_ButtonShiftHorizontal, widget),
+ tqpixelMetric(PM_ButtonShiftVertical, widget) );
+ drawItem( p, ir, TQt::AlignCenter, titlebar->tqcolorGroup(), TRUE, &pm, TQString::null );
+ p->restore();
+ }
+ }
+#ifndef TQT_NO_WIDGET_TOPEXTRA
+ if ( controls & SC_TitleBarSysMenu ) {
+ if ( titlebar->icon() ) {
+ ir = tqvisualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarSysMenu ), widget );
+ drawItem( p, ir, TQt::AlignCenter, titlebar->tqcolorGroup(), TRUE, titlebar->icon(), TQString::null );
+ }
+ }
+#endif
+ break;
+ }
+#endif //TQT_NO_TITLEBAR
+
+ case CC_SpinWidget: {
+#ifndef TQT_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 = TQStyle::PE_SpinWidgetPlus;
+ else
+ pe = TQStyle::PE_SpinWidgetUp;
+
+ TQRect re = sw->upRect();
+ TQColorGroup ucg = sw->isUpEnabled() ? cg : sw->tqpalette().disabled();
+ tqdrawPrimitive(TQStyle::PE_ButtonBevel, p, re, ucg, flags);
+ tqdrawPrimitive(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 = TQStyle::PE_SpinWidgetMinus;
+ else
+ pe = TQStyle::PE_SpinWidgetDown;
+
+ TQRect re = sw->downRect();
+ TQColorGroup dcg = sw->isDownEnabled() ? cg : sw->tqpalette().disabled();
+ tqdrawPrimitive(TQStyle::PE_ButtonBevel, p, re, dcg, flags);
+ tqdrawPrimitive(pe, p, re, dcg, flags);
+ }
+#endif
+ break; }
+
+#ifndef TQT_NO_SLIDER
+ case CC_Slider:
+ switch ( controls ) {
+ case SC_SliderTickmarks: {
+ const TQSlider * sl = (const TQSlider *) widget;
+ int tickOffset = tqpixelMetric( PM_SliderTickmarkOffset, sl );
+ int ticks = sl->tickmarks();
+ int thickness = tqpixelMetric( PM_SliderControlThickness, sl );
+ int len = tqpixelMetric( PM_SliderLength, sl );
+ int available = tqpixelMetric( 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() == Qt::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() == Qt::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 // TQT_NO_SLIDER
+#ifndef TQT_NO_LISTVIEW
+ case CC_ListView:
+ if ( controls & SC_ListView ) {
+ TQListView *listview = (TQListView*)widget;
+ p->fillRect( r, listview->viewport()->backgroundBrush() );
+ }
+ break;
+#endif //TQT_NO_LISTVIEW
+ default:
+ break;
+ }
+
+ activePainter = 0;
+}
+
+
+/*! \reimp */
+void TQCommonStyle::tqdrawComplexControlMask( TQ_ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQStyleOption& opt ) const
+{
+ TQ_UNUSED(control);
+ TQ_UNUSED(widget);
+ TQ_UNUSED(opt);
+
+ p->fillRect(r, Qt::color1);
+}
+
+
+/*! \reimp */
+TQRect TQCommonStyle::querySubControlMetrics( TQ_ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption &opt ) const
+{
+#if defined(TQT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::querySubControlMetrics: widget parameter cannot be zero!");
+ return TQRect();
+ }
+#endif
+
+ switch ( control ) {
+ case CC_SpinWidget: {
+ int fw = tqpixelMetric( 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 TQT_NO_SCROLLBAR
+ case CC_ScrollBar: {
+ const TQScrollBar *scrollbar = (const TQScrollBar *) widget;
+ int sliderstart = 0;
+ int sbextent = tqpixelMetric(PM_ScrollBarExtent, widget);
+ int maxlen = ((scrollbar->orientation() == Qt::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 = (TQ_LLONG(scrollbar->pageStep()) * maxlen) / (range + scrollbar->pageStep());
+
+ int slidermin = tqpixelMetric( 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() == Qt::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() == Qt::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() == Qt::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() == Qt::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() == Qt::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() == Qt::Horizontal)
+ return TQRect(sliderstart, 0, sliderlen, sbextent);
+ return TQRect(0, sliderstart, sbextent, sliderlen);
+
+ default: break;
+ }
+
+ break; }
+#endif // TQT_NO_SCROLLBAR
+
+#ifndef TQT_NO_SLIDER
+ case CC_Slider: {
+ const TQSlider * sl = (const TQSlider *) widget;
+ int tickOffset = tqpixelMetric( PM_SliderTickmarkOffset, sl );
+ int thickness = tqpixelMetric( PM_SliderControlThickness, sl );
+
+ switch ( sc ) {
+ case SC_SliderHandle: {
+ int sliderPos = 0;
+ int len = tqpixelMetric( PM_SliderLength, sl );
+
+ sliderPos = sl->sliderStart();
+
+ if ( sl->orientation() == Qt::Horizontal )
+ return TQRect( sliderPos, tickOffset, len, thickness );
+ return TQRect( tickOffset, sliderPos, thickness, len ); }
+ case SC_SliderGroove: {
+ if ( sl->orientation() == Qt::Horizontal )
+ return TQRect( 0, tickOffset, sl->width(), thickness );
+ return TQRect( tickOffset, 0, thickness, sl->height() ); }
+
+ default:
+ break;
+ }
+ break; }
+#endif // TQT_NO_SLIDER
+
+#if !defined(TQT_NO_TOOLBUTTON) && !defined(TQT_NO_POPUPMENU)
+ case CC_ToolButton: {
+ const TQToolButton *toolbutton = (const TQToolButton *) widget;
+ int mbi = tqpixelMetric(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 // TQT_NO_TOOLBUTTON && TQT_NO_POPUPMENU
+
+#ifndef TQT_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( TQt::WStyle_Tool ) ) {
+ if ( titlebar->testWFlags( TQt::WStyle_SysMenu ) )
+ ir.addCoords( 0, 0, -controlHeight-3, 0 );
+ if ( titlebar->testWFlags( TQt::WStyle_MinMax ) )
+ ir.addCoords( 0, 0, -controlHeight-2, 0 );
+ } else {
+ if ( titlebar->testWFlags( TQt::WStyle_SysMenu ) )
+ ir.addCoords( controlHeight+3, 0, -controlHeight-3, 0 );
+ if ( titlebar->testWFlags( TQt::WStyle_Minimize ) )
+ ir.addCoords( 0, 0, -controlHeight-2, 0 );
+ if ( titlebar->testWFlags( TQt::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( TQt::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 //TQT_NO_TITLEBAR
+
+ default:
+ break;
+ }
+ return TQRect();
+}
+
+
+/*! \reimp */
+TQStyle::SubControl TQCommonStyle::querySubControl(TQ_ComplexControl control,
+ const TQWidget *widget,
+ const TQPoint &pos,
+ const TQStyleOption& opt ) const
+{
+ SubControl ret = SC_None;
+
+ switch (control) {
+#ifndef TQT_NO_LISTVIEW
+ case CC_ListView:
+ {
+ if(pos.x() >= 0 && pos.x() <
+ opt.listViewItem()->listView()->treeStepSize())
+ ret = SC_ListViewExpand;
+ break;
+ }
+#endif
+#ifndef TQT_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.tqcontains(pos))
+ ret = (TQStyle::SubControl) ctrl;
+
+ ctrl <<= 1;
+ }
+
+ break;
+ }
+#endif
+ case CC_TitleBar:
+ {
+#ifndef TQT_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 = tqvisualRect( querySubControlMetrics( control, widget, (TQStyle::SubControl) ctrl, opt ), widget );
+ if (r.isValid() && r.tqcontains(pos))
+ ret = (TQStyle::SubControl) ctrl;
+
+ ctrl <<= 1;
+ }
+ if ( titlebar->window() ) {
+ if (titlebar->testWFlags( TQt::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::tqpixelMetric(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( TQt::WStyle_Tool ) ) {
+ ret = TQMAX( widget->fontMetrics().lineSpacing(), 16 );
+#ifndef TQT_NO_MAINWINDOW
+ } else if ( ::tqqt_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 TQT_NO_SCROLLBAR
+ case PM_ScrollBarExtent:
+ if ( !widget ) {
+ ret = 16;
+ } else {
+ const TQScrollBar *bar = (const TQScrollBar*)widget;
+ int s = bar->orientation() == Qt::Horizontal ?
+ TQApplication::globalStrut().height()
+ : TQApplication::globalStrut().width();
+ ret = TQMAX( 16, s );
+ }
+ break;
+#endif
+ case PM_MaximumDragDistance:
+ ret = -1;
+ break;
+
+#ifndef TQT_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() == Qt::Horizontal) ? sl->height() :
+ sl->width();
+ int thickness = tqpixelMetric( 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() == Qt::Horizontal )
+ ret = sl->width() - tqpixelMetric( PM_SliderLength, sl );
+ else
+ ret = sl->height() - tqpixelMetric( PM_SliderLength, sl );
+ break;
+ }
+#endif // TQT_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 TQT_NO_TABBAR
+ case PM_TabBarTabVSpace:
+ {
+ const TQTabBar * tb = (const TQTabBar *) widget;
+ if ( tb && ( tb->tqshape() == TQTabBar::RoundedAbove ||
+ tb->tqshape() == 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::tqsizeFromContents(ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& opt ) const
+{
+ TQSize sz(contentsSize);
+
+#if defined(TQT_CHECK_STATE)
+ if (! widget) {
+ qWarning("TQCommonStyle::tqsizeFromContents: widget parameter cannot be zero!");
+ return sz;
+ }
+#endif
+
+ switch (contents) {
+#ifndef TQT_NO_DIALOGBUTTONS
+ case CT_DialogButtons: {
+ const TQDialogButtons *dbtns = (const TQDialogButtons *)widget;
+ int w = contentsSize.width(), h = contentsSize.height();
+ const int bwidth = tqpixelMetric(PM_DialogButtonsButtonWidth, widget),
+ bspace = tqpixelMetric(PM_DialogButtonsSeparator, widget),
+ bheight = tqpixelMetric(PM_DialogButtonsButtonHeight, widget);
+ if(dbtns->orientation() == Qt::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->tqsizeHint(btns[i]);
+ int mwidth = TQMAX(bwidth, szH.width()), mheight = TQMAX(bheight, szH.height());
+ if(dbtns->orientation() == Qt::Horizontal)
+ h = TQMAX(h, mheight);
+ else
+ w = TQMAX(w, mwidth);
+
+ if(cnt)
+ w += bspace;
+ cnt++;
+ if(dbtns->orientation() == Qt::Horizontal)
+ w += mwidth;
+ else
+ h += mheight;
+ }
+ }
+ const int fw = tqpixelMetric(PM_DefaultFrameWidth, widget) * 2;
+ sz = TQSize(w + fw, h + fw);
+ break; }
+#endif //TQT_NO_DIALOGBUTTONS
+ case CT_PushButton:
+ {
+#ifndef TQT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ int w = contentsSize.width(),
+ h = contentsSize.height(),
+ bm = tqpixelMetric(PM_ButtonMargin, widget),
+ fw = tqpixelMetric(PM_DefaultFrameWidth, widget) * 2;
+
+ w += bm + fw;
+ h += bm + fw;
+
+ if (button->isDefault() || button->autoDefault()) {
+ int dbw = tqpixelMetric(PM_ButtonDefaultIndicator, widget) * 2;
+ w += dbw;
+ h += dbw;
+ }
+
+ sz = TQSize(w, h);
+#endif
+ break;
+ }
+
+ case CT_CheckBox:
+ {
+#ifndef TQT_NO_CHECKBOX
+ const TQCheckBox *checkbox = (const TQCheckBox *) widget;
+ TQRect irect = subRect(SR_CheckBoxIndicator, widget);
+ int h = tqpixelMetric( 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 TQT_NO_RADIOBUTTON
+ const TQRadioButton *radiobutton = (const TQRadioButton *) widget;
+ TQRect irect = subRect(SR_RadioButtonIndicator, widget);
+ int h = tqpixelMetric( 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 = tqpixelMetric(PM_DefaultFrameWidth, widget) * 2;
+ sz = TQSize(sz.width() + dfw + 21, sz.height() + dfw );
+ break;
+ }
+
+ case CT_PopupMenuItem:
+ {
+#ifndef TQT_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()->tqsizeHint().width();
+ h = mi->custom()->tqsizeHint().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().tqfind('\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::tqstyleHint(TQ_StyleHint sh, const TQWidget * w, const TQStyleOption &, TQStyleHintReturn *) const
+{
+ int ret;
+
+ switch (sh) {
+#ifndef TQT_NO_DIALOGBUTTONS
+ case SH_DialogButtons_DefaultButton:
+ ret = TQDialogButtons::Accept;
+ break;
+#endif
+ case SH_GroupBox_TextLabelVerticalAlignment:
+ ret = TQt::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 = TQt::WindowsStyle;
+ break;
+
+ case SH_ScrollBar_BackgroundMode:
+ ret = TQt::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 // TQT_NO_STYLE
diff --git a/tqtinterface/qt4/src/styles/tqcommonstyle.h b/tqtinterface/qt4/src/styles/tqcommonstyle.h
new file mode 100644
index 0000000..ef01d89
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqcommonstyle.h
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Definition of TQCommonStyle class
+**
+** Created : 980616
+**
+** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
+**
+** 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 requirements 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 TQT_H
+#include "tqstyle.h"
+#endif // TQT_H
+
+#ifndef TQT_NO_STYLE
+
+class TQ_EXPORT TQCommonStyle: public TQStyle
+{
+ TQ_OBJECT
+
+public:
+ TQCommonStyle();
+ ~TQCommonStyle();
+
+ // Compatibility functions
+ // For example, a TQt application may call tqdrawPrimitive with a ControlElement parameter
+ // TQt "knows" that the application should have called tqdrawControl instead, and translates accordingly.
+ inline void tqdrawPrimitive( TQ_ControlElement element, TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, const TQStyleOption &opt = TQStyleOption::Default ) const {
+ TQ_UNUSED(r);
+ TQ_UNUSED(cg);
+ TQ_UNUSED(flags);
+ drawControl((QStyle::ControlElement)(int)element, &opt, p, 0); // [FIXME] What should widget really be? I imagine 0 is *wrong*!!!
+ }
+ inline void tqdrawPrimitive( TQ_ComplexControl element, TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, const TQStyleOption &opt = TQStyleOption::Default ) const {
+ TQ_UNUSED(r);
+ TQ_UNUSED(cg);
+ TQ_UNUSED(flags);
+ drawComplexControl((QStyle::ComplexControl)(int)element, 0, p, 0); // [FIXME] What should widget and complexcontrol really be? I imagine 0 is *wrong*!!!
+ }
+ inline void tqdrawPrimitive( TQ_ControlElement element, TQPainter *p, const TQRect &r, const TQColorGroup &cg, int flags, const TQStyleOption &opt = TQStyleOption::Default ) const { tqdrawPrimitive( element, p, r, cg, (SFlags)flags, opt); }
+
+ void tqdrawPrimitive( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawControl( TQ_ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawControlMask( TQ_ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect subRect( SubRect r, const TQWidget *widget ) const;
+
+ void tqdrawComplexControl( TQ_ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+#ifdef TQ_TQDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawComplexControlMask( TQ_ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect querySubControlMetrics( TQ_ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ SubControl querySubControl( TQ_ComplexControl control,
+ const TQWidget *widget,
+ const TQPoint &pos,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int tqpixelMetric( PixelMetric m, const TQWidget *widget = 0 ) const;
+
+ TQSize tqsizeFromContents( ContentsType s,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int tqstyleHint(TQ_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(TQ_DISABLE_COPY)
+ TQCommonStyle( const TQCommonStyle & );
+ TQCommonStyle &operator=( const TQCommonStyle & );
+#endif
+};
+
+
+
+#endif // TQT_NO_STYLE
+
+#endif // TQCOMMONSTYLE_H
diff --git a/tqtinterface/qt4/src/styles/tqcompactstyle.cpp b/tqtinterface/qt4/src/styles/tqcompactstyle.cpp
new file mode 100644
index 0000000..44cd711
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqcompactstyle.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 requirements 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 "tqcompactstyle.h"
+
+#if !defined(TQT_NO_STYLE_COMPACT) || defined(TQT_PLUGIN)
+
+#include "tqfontmetrics.h"
+#include "tqpalette.h"
+#include "tqpainter.h"
+#include "tqdrawutil.h"
+#include "tqmenudata.h"
+#include "tqpopupmenu.h"
+
+TQCompactStyle::TQCompactStyle()
+: TQWindowsStyle()
+{
+}
+
+/*! \reimp */
+int TQCompactStyle::tqpixelMetric( 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::tqpixelMetric( 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().tqfind('\t') >= 0 ) // string tqcontains 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()->tqsizeHint().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::tqdrawControl( 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.tqfind( '\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::tqdrawControl( element, p, widget, r, g, flags, opt );
+ break;
+ }
+}
+
+#endif
diff --git a/tqtinterface/qt4/src/styles/tqcompactstyle.h b/tqtinterface/qt4/src/styles/tqcompactstyle.h
new file mode 100644
index 0000000..24c7b3a
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqcompactstyle.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 requirements 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 TQT_H
+#include "tqwindowsstyle.h"
+#endif // TQT_H
+
+#if !defined(TQT_NO_STYLE_COMPACT) || defined(TQT_PLUGIN)
+
+#if defined(TQT_PLUGIN)
+#define TQ_EXPORT_STYLE_COMPACT
+#else
+#define TQ_EXPORT_STYLE_COMPACT TQ_EXPORT
+#endif
+
+class TQ_EXPORT_STYLE_COMPACT TQCompactStyle : public TQWindowsStyle
+{
+public:
+ TQCompactStyle();
+
+ int tqpixelMetric( PixelMetric metric, const TQWidget *widget = 0 );
+
+ void tqdrawControl( 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(TQ_DISABLE_COPY)
+ TQCompactStyle( const TQCompactStyle & );
+ TQCompactStyle& operator=( const TQCompactStyle & );
+#endif
+};
+
+#endif // TQT_NO_STYLE_WINDOWS
+
+#endif // TQCOMPACTSTYLE_H
diff --git a/tqtinterface/qt4/src/styles/tqinterlacestyle.cpp b/tqtinterface/qt4/src/styles/tqinterlacestyle.cpp
new file mode 100644
index 0000000..042f099
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqinterlacestyle.cpp
@@ -0,0 +1,805 @@
+/****************************************************************************
+**
+** Implementation of TQInterlaceStyle class
+**
+** Created : 010122
+**
+** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
+**
+** 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 requirements 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 "tqinterlacestyle.h"
+
+#if !defined(TQT_NO_STYLE_INTERLACE) || defined(TQT_PLUGIN)
+
+#include "tqapplication.h"
+#include "tqpainter.h"
+#include "tqdrawutil.h" // for now
+#include "tqpalette.h" // for now
+#include "tqwidget.h"
+#include "tqlabel.h"
+#include "tqpushbutton.h"
+#include "tqwidget.h"
+#include "tqrangecontrol.h"
+#include "tqscrollbar.h"
+#include "tqlistbox.h"
+
+#include <limits.h>
+
+/*!
+ \class TQInterlaceStyle tqinterlacestyle.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 transtqparent 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 transtqparent 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->tqcolorGroup();
+ 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->tqcolorGroup();
+ const TQColor *col = &btn->tqcolorGroup().buttonText();
+ if ( (btn->isDown() || btn->isOn()) )
+ col = &btn->tqcolorGroup().brightText();
+ else if ( !btn->isEnabled() )
+ col = &btn->tqcolorGroup().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->tqcolorGroup();
+
+ 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 // TQT_NO_STYLE_INTERLACE
+
+#endif
diff --git a/tqtinterface/qt4/src/styles/tqinterlacestyle.h b/tqtinterface/qt4/src/styles/tqinterlacestyle.h
new file mode 100644
index 0000000..a0e4af5
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqinterlacestyle.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Implementation of TQInterlaceStyle widget class
+**
+** Created : 010122
+**
+** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
+**
+** 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 requirements 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 TQT_H
+#include "tqmotifstyle.h"
+#endif // TQT_H
+
+#if !defined(TQT_NO_STYLE_INTERLACE) || defined(TQT_PLUGIN)
+
+#include "tqpalette.h"
+
+class TQ_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 // TQT_NO_STYLE_INTERLACE
+
+#endif
+#endif
diff --git a/tqtinterface/qt4/src/styles/tqmotifplusstyle.cpp b/tqtinterface/qt4/src/styles/tqmotifplusstyle.cpp
new file mode 100644
index 0000000..bef75db
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqmotifplusstyle.cpp
@@ -0,0 +1,1586 @@
+/****************************************************************************
+**
+** 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 requirements 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 "tqmotifplusstyle.h"
+
+#if !defined(TQT_NO_STYLE_MOTIFPLUS) || defined(TQT_PLUGIN)
+
+#include "tqmenubar.h"
+#include "tqapplication.h"
+#include "tqpainter.h"
+#include "tqpalette.h"
+#include "tqframe.h"
+#include "tqpushbutton.h"
+#include "tqcheckbox.h"
+#include "tqradiobutton.h"
+#include "tqcombobox.h"
+#include "tqlineedit.h"
+#include "tqspinbox.h"
+#include "tqslider.h"
+#include "tqdrawutil.h"
+#include "tqscrollbar.h"
+#include "tqtabbar.h"
+#include "tqtoolbar.h"
+#include "tqguardedptr.h"
+#include "tqlayout.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 tqmotifplusstyle.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 TQT_NO_FRAME
+ if (::tqqt_cast<TQFrame*>(widget) && ((TQFrame *) widget)->frameStyle() == TQFrame::Panel)
+ ((TQFrame *) widget)->setFrameStyle(TQFrame::WinPanel);
+#endif
+
+#ifndef TQT_NO_MENUBAR
+ if (::tqqt_cast<TQMenuBar*>(widget) && ((TQMenuBar *) widget)->frameStyle() != TQFrame::NoFrame)
+ ((TQMenuBar *) widget)->setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised);
+#endif
+
+#ifndef TQT_NO_TOOLBAR
+ if (::tqqt_cast<TQToolBar*>(widget))
+ widget->tqlayout()->setMargin(2);
+#endif
+ if (useHoveringHighlight) {
+ if (::tqqt_cast<TQButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget))
+ widget->installEventFilter(this);
+
+ if (::tqqt_cast<TQScrollBar*>(widget) || ::tqqt_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::tqpixelMetric(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::tqpixelMetric(metric, widget);
+ break;
+ }
+
+ return ret;
+}
+
+
+/*! \reimp */
+void TQMotifPlusStyle::tqdrawPrimitiveBase( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch (pe) {
+#ifndef USE_QT4
+ case PE_HeaderSection:
+#endif // USE_QT4
+
+ 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:
+ tqdrawPrimitive(PE_ArrowUp, p, r, cg, flags, opt);
+ break;
+
+ case PE_SpinWidgetDown:
+ tqdrawPrimitive(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(TQt::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(TQt::black);
+ p->drawLine(x + w - 1, y + h - 1, x + (w / 2), y);
+
+ if (down)
+ p->setPen(TQt::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(TQt::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(TQt::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(TQt::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(TQt::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(TQt::black);
+ p->drawLine(x + w - 1, y + h - 1, x + w - 1, y);
+
+ if (down)
+ p->setPen(TQt::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(TQt::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(TQt::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(TQt::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::tqdrawPrimitive(pe, p, r, cg, flags, opt);
+ break;
+ }
+}
+
+
+/*! \reimp
+*/
+void TQMotifPlusStyle::tqdrawControl( TQ_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 TQT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ TQRect br = r;
+ int dbi = tqpixelMetric(PM_ButtonDefaultIndicator, widget);
+
+ if (button->isDefault() || button->autoDefault()) {
+ if (button->isDefault())
+ drawMotifPlusShade(p, br, cg, TRUE, FALSE,
+ &TQT_TQBRUSH_OBJECT(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() );
+ tqdrawPrimitive(PE_ButtonCommand, p, br, cg, flags);
+ p->restore();
+#endif
+ break;
+ }
+
+ case CE_CheckBoxLabel:
+ {
+#ifndef TQT_NO_CHECKBOX
+ const TQCheckBox *checkbox = (const TQCheckBox *) widget;
+
+ if (flags & Style_MouseOver) {
+ TQRegion r(checkbox->rect());
+ r -= tqvisualRect(subRect(SR_CheckBoxIndicator, widget), widget);
+ p->setClipRegion(r);
+ p->fillRect(checkbox->rect(), cg.brush(TQColorGroup::Midlight));
+ p->setClipping(FALSE);
+ }
+
+ int tqalignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
+ drawItem(p, r, tqalignment | TQt::AlignVCenter | TQt::ShowPrefix, cg,
+ flags & Style_Enabled, checkbox->pixmap(), checkbox->text());
+
+ if (checkbox->hasFocus()) {
+ TQRect fr = tqvisualRect(subRect(SR_CheckBoxFocusRect, widget), widget);
+ tqdrawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CE_RadioButtonLabel:
+ {
+#ifndef TQT_NO_RADIOBUTTON
+ const TQRadioButton *radiobutton = (const TQRadioButton *) widget;
+
+ if (flags & Style_MouseOver) {
+ TQRegion r(radiobutton->rect());
+ r -= tqvisualRect(subRect(SR_RadioButtonIndicator, widget), widget);
+ p->setClipRegion(r);
+ p->fillRect(radiobutton->rect(), cg.brush(TQColorGroup::Midlight));
+ p->setClipping(FALSE);
+ }
+
+ int tqalignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
+ drawItem(p, r, tqalignment | TQt::AlignVCenter | TQt::ShowPrefix, cg,
+ flags & Style_Enabled, radiobutton->pixmap(), radiobutton->text());
+
+ if (radiobutton->hasFocus()) {
+ TQRect fr = tqvisualRect(subRect(SR_RadioButtonFocusRect, widget), widget);
+ tqdrawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CE_MenuBarItem:
+ {
+#ifndef TQT_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, TQt::AlignCenter | TQt::ShowPrefix | TQt::DontClip | TQt::SingleLine,
+ cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1,
+ TQT_TQCOLOR_CONST(&cg.buttonText()));
+#endif
+ break;
+ }
+
+
+#ifndef TQT_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 = tqvisualRect( 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;
+
+ tqdrawPrimitive(PE_CheckMark, p, vrect, cg, cflags);
+ }
+ }
+
+ p->setPen( cg.buttonText() );
+
+ TQColor discol;
+ if (dis) {
+ discol = cg.text();
+ p->setPen( discol );
+ }
+
+ vrect = tqvisualRect( 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.tqfind( '\t' );
+ int m = 2;
+ int text_flags = TQt::AlignVCenter|TQt::ShowPrefix | TQt::DontClip | TQt::SingleLine;
+ text_flags |= (TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft );
+ if ( t >= 0 ) { // draw tab text
+ TQRect vr = tqvisualRect( 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(Qt::OpaqueMode);
+ TQRect vr = tqvisualRect( 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(Qt::TransparentMode);
+ }
+
+ if (mi->popup()) {
+ int hh = h / 2;
+ TQStyle::PrimitiveElement arrow = (TQApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight);
+ vrect = tqvisualRect( TQRect(x + w - hh - 6, y + (hh / 2), hh, hh), r );
+ tqdrawPrimitive(arrow, p,
+ vrect, cg,
+ ((act && !dis) ?
+ Style_Down : Style_Default) |
+ ((!dis) ? Style_Enabled : Style_Default));
+ }
+ break;
+ }
+#endif // TQT_NO_POPUPMENU
+
+ case CE_TabBarTab:
+ {
+#ifndef TQT_NO_TABBAR
+ const TQTabBar *tabbar = (const TQTabBar *) widget;
+ bool selected = flags & Style_Selected;
+
+ TQColorGroup g = tabbar->tqcolorGroup();
+ TQPen oldpen = p->pen();
+ TQRect fr(r);
+
+ if (! selected) {
+ if (tabbar->tqshape() == TQTabBar::RoundedAbove ||
+ tabbar->tqshape() == 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->tqshape() == 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(TQt::black);
+ p->drawLine(fr.right(), fr.top() + 1,
+ fr.right(), fr.bottom() - 1);
+ } else if (tabbar->tqshape() == 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(TQt::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::tqdrawControl(element, p, widget, r, cg, flags, opt);
+
+ p->setPen(oldpen);
+#endif
+ break;
+ }
+
+ default:
+ TQMotifStyle::tqdrawControl(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 TQT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ int dfi = tqpixelMetric(PM_ButtonDefaultIndicator, widget);
+
+ rect = button->rect();
+ if (button->isDefault() || button->autoDefault())
+ rect.addCoords(dfi, dfi, -dfi, -dfi);
+#endif
+ break;
+ }
+
+ case SR_CheckBoxIndicator:
+ {
+ int h = tqpixelMetric( PM_IndicatorHeight );
+ rect.setRect(( widget->rect().height() - h ) / 2,
+ ( widget->rect().height() - h ) / 2,
+ tqpixelMetric( PM_IndicatorWidth ), h );
+ break;
+ }
+
+ case SR_RadioButtonIndicator:
+ {
+ int h = tqpixelMetric( PM_ExclusiveIndicatorHeight );
+ rect.setRect( ( widget->rect().height() - h ) / 2,
+ ( widget->rect().height() - h ) / 2,
+ tqpixelMetric( PM_ExclusiveIndicatorWidth ), h );
+ break;
+ }
+
+ case SR_CheckBoxFocusRect:
+ case SR_RadioButtonFocusRect:
+ rect = widget->rect();
+ break;
+
+ case SR_ComboBoxFocusRect:
+ {
+#ifndef TQT_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 TQT_NO_SLIDER
+ const TQSlider *slider = (const TQSlider *) widget;
+ int tickOffset = tqpixelMetric( PM_SliderTickmarkOffset, widget );
+ int thickness = tqpixelMetric( PM_SliderControlThickness, widget );
+ int x, y, wi, he;
+
+ if ( slider->orientation() == Qt::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::tqdrawComplexControl(TQ_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 TQT_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.tqcontains(singleton->mousePos)) {
+ skipUpdate =
+ (singleton->scrollbarElement == SC_ScrollBarAddLine);
+ singleton->scrollbarElement = SC_ScrollBarAddLine;
+ } else if (subline.tqcontains(singleton->mousePos)) {
+ skipUpdate =
+ (singleton->scrollbarElement == SC_ScrollBarSubLine);
+ singleton->scrollbarElement = SC_ScrollBarSubLine;
+ } else if (slider.tqcontains(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,
+ &TQT_TQBRUSH_OBJECT(cg.brush(TQColorGroup::Mid)));
+
+ if ((controls & SC_ScrollBarSubLine) && subline.isValid())
+ tqdrawPrimitive(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() == Qt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarAddLine) && addline.isValid())
+ tqdrawPrimitive(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() == Qt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
+ tqdrawPrimitive(PE_ScrollBarSubPage, p, subpage, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarSubPage) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
+ tqdrawPrimitive(PE_ScrollBarAddPage, p, addpage, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarAddPage) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarFirst) && first.isValid())
+ tqdrawPrimitive(PE_ScrollBarFirst, p, first, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarFirst) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarLast) && last.isValid())
+ tqdrawPrimitive(PE_ScrollBarLast, p, last, cg,
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((active == SC_ScrollBarLast) ?
+ Style_Down : Style_Default) |
+ ((scrollbar->orientation() == Qt::Horizontal) ?
+ Style_Horizontal : Style_Default));
+ if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
+ tqdrawPrimitive(PE_ScrollBarSlider, p, slider, cg,
+ ((active == SC_ScrollBarSlider ||
+ singleton->scrollbarElement == SC_ScrollBarSlider) ?
+ Style_MouseOver: Style_Default) |
+ ((maxedOut) ? Style_Default : Style_Enabled) |
+ ((scrollbar->orientation() == Qt::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);
+ tqdrawPrimitive(PE_FocusRect, p, fr, cg, Style_Default);
+ }
+ }
+#endif
+ break;
+ }
+
+ case CC_ComboBox:
+ {
+#ifndef TQT_NO_COMBOBOX
+ const TQComboBox *combobox = (const TQComboBox *) widget;
+
+ TQRect editfield, arrow;
+ editfield =
+ tqvisualRect(querySubControlMetrics(CC_ComboBox,
+ combobox,
+ SC_ComboBoxEditField,
+ opt), widget);
+ arrow =
+ tqvisualRect(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() ?
+ &TQT_TQBRUSH_OBJECT(cg.brush(TQColorGroup::Base)) :
+ &TQT_TQBRUSH_OBJECT(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;
+ tqdrawPrimitive(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 = tqvisualRect(subRect(SR_ComboBoxFocusRect, widget), widget);
+ tqdrawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CC_SpinWidget:
+ {
+#ifndef TQT_NO_SPINWIDGET
+ const TQSpinWidget * sw = (const TQSpinWidget *) widget;
+ SFlags flags = Style_Default;
+
+ if (controls & SC_SpinWidgetFrame)
+ drawMotifPlusShade(p, r, cg, TRUE, FALSE, &TQT_TQBRUSH_OBJECT(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->tqpalette().disabled();
+ tqdrawPrimitive(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->tqpalette().disabled();
+ tqdrawPrimitive(pe, p, re, dcg, flags);
+ }
+#endif
+ break;
+ }
+
+ case CC_Slider:
+ {
+#ifndef TQT_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,
+ &TQT_TQBRUSH_OBJECT(cg.brush(TQColorGroup::Mid)));
+
+ if ( flags & Style_HasFocus ) {
+ TQRect fr = subRect( SR_SliderFocusRect, widget );
+ tqdrawPrimitive( PE_FocusRect, p, fr, cg, flags );
+ }
+ }
+
+ if ((controls & SC_SliderHandle) && handle.isValid()) {
+ if ((mouseover && handle.tqcontains(singleton->mousePos)) ||
+ singleton->sliderActive)
+ flags |= Style_MouseOver;
+ else
+ flags &= ~Style_MouseOver;
+ tqdrawPrimitive(PE_ButtonBevel, p, handle, cg, flags | Style_Raised);
+
+ if ( slider->orientation() == Qt::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::tqdrawComplexControl(control, p, widget, r, cg, flags,
+ SC_SliderTickmarks, active, opt);
+#endif
+ break;
+ }
+
+ default:
+ TQMotifStyle::tqdrawComplexControl(control, p, widget, r, cg, flags,
+ controls, active, opt);
+ }
+}
+
+
+/*! \reimp
+*/
+TQRect TQMotifPlusStyle::querySubControlMetrics(TQ_ComplexControl control,
+ const TQWidget *widget,
+ SubControl subcontrol,
+ const TQStyleOption& opt) const
+{
+ switch (control) {
+ case CC_SpinWidget: {
+ int fw = tqpixelMetric( 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 TQT_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 TQT_NO_SLIDER
+ case CC_Slider: {
+
+ if (subcontrol == SC_SliderHandle) {
+ const TQSlider *slider = (const TQSlider *) widget;
+ int tickOffset = tqpixelMetric( PM_SliderTickmarkOffset, widget );
+ int thickness = tqpixelMetric( PM_SliderControlThickness, widget );
+ int len = tqpixelMetric( PM_SliderLength, widget ) + 2;
+ int sliderPos = slider->sliderStart();
+ int motifBorder = 2;
+
+ if ( slider->orientation() == Qt::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 (!::tqqt_cast<TQSlider*>(object))
+ break;
+
+ singleton->sliderActive = TRUE;
+ break;
+ }
+
+ case TQEvent::MouseButtonRelease:
+ {
+ singleton->mousePressed = FALSE;
+
+ if (!::tqqt_cast<TQSlider*>(object))
+ break;
+
+ singleton->sliderActive = FALSE;
+ ((TQWidget *) object)->tqrepaint(FALSE);
+ break;
+ }
+
+ case TQEvent::Enter:
+ {
+ if (! object->isWidgetType())
+ break;
+
+ singleton->hoverWidget = (TQWidget *) object;
+ if (! singleton->hoverWidget->isEnabled()) {
+ singleton->hoverWidget = 0;
+ break;
+ }
+ singleton->hoverWidget->tqrepaint(FALSE);
+ break;
+ }
+
+ case TQEvent::Leave:
+ {
+ if (object != TQT_TQOBJECT(singleton->hoverWidget))
+ break;
+ TQWidget *w = singleton->hoverWidget;
+ singleton->hoverWidget = 0;
+ w->tqrepaint(FALSE);
+ break;
+ }
+
+ case TQEvent::MouseMove:
+ {
+ if (! object->isWidgetType() || object != TQT_TQOBJECT(singleton->hoverWidget))
+ break;
+
+ if (!::tqqt_cast<TQScrollBar*>(object) && ! ::tqqt_cast<TQSlider*>(object))
+ break;
+
+ singleton->mousePos = ((TQMouseEvent *) event)->pos();
+ if (! singleton->mousePressed) {
+ singleton->hovering = TRUE;
+ singleton->hoverWidget->tqrepaint(FALSE);
+ singleton->hovering = FALSE;
+ }
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return TQMotifStyle::eventFilter(object, event);
+}
+
+
+/*! \reimp */
+int TQMotifPlusStyle::tqstyleHint(TQ_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::tqstyleHint(hint, widget, opt, returnData);
+ break;
+ }
+ return ret;
+}
+
+
+#endif // TQT_NO_STYLE_MOTIFPLUS
diff --git a/tqtinterface/qt4/src/styles/tqmotifplusstyle.h b/tqtinterface/qt4/src/styles/tqmotifplusstyle.h
new file mode 100644
index 0000000..0336f60
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqmotifplusstyle.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 requirements 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 TQT_H
+#include "tqmotifstyle.h"
+#endif // TQT_H
+
+#if !defined(TQT_NO_STYLE_MOTIFPLUS) || defined(TQT_PLUGIN)
+
+#if defined(TQT_PLUGIN)
+#define TQ_EXPORT_STYLE_MOTIFPLUS
+#else
+#define TQ_EXPORT_STYLE_MOTIFPLUS TQ_EXPORT
+#endif
+
+class TQ_EXPORT_STYLE_MOTIFPLUS TQMotifPlusStyle : public TQMotifStyle
+{
+ TQ_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 tqdrawPrimitiveBase( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawControl( TQ_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 tqdrawComplexControl(TQ_ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+#ifdef TQ_TQDOC
+ SCFlags controls = SC_All,
+#else
+ SCFlags controls = (uint)SC_All,
+#endif
+ SCFlags active = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect querySubControlMetrics(TQ_ComplexControl control,
+ const TQWidget *widget,
+ SubControl subcontrol,
+ const TQStyleOption& = TQStyleOption::Default) const;
+
+ int tqpixelMetric(PixelMetric metric, const TQWidget *widget = 0) const;
+
+ int tqstyleHint(TQ_StyleHint sh, const TQWidget *, const TQStyleOption & = TQStyleOption::Default,
+ TQStyleHintReturn* = 0) const;
+
+protected:
+ bool eventFilter(TQObject *, TQEvent *);
+
+
+private:
+ bool useHoveringHighlight;
+};
+
+
+#endif // TQT_NO_STYLE_MOTIFPLUS
+
+#endif // TQMOTIFPLUSSTYLE_H
diff --git a/tqtinterface/qt4/src/styles/tqmotifstyle.cpp b/tqtinterface/qt4/src/styles/tqmotifstyle.cpp
new file mode 100644
index 0000000..257c0ad
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqmotifstyle.cpp
@@ -0,0 +1,2367 @@
+/****************************************************************************
+**
+** 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 requirements 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 "tqmotifstyle.h"
+
+#if !defined(TQT_NO_STYLE_MOTIF) || defined(TQT_PLUGIN)
+
+#include "tqpopupmenu.h"
+#include "tqapplication.h"
+#include "tqpainter.h"
+#include "tqdrawutil.h"
+#include "tqpixmap.h"
+#include "tqpalette.h"
+#include "tqwidget.h"
+#include "tqpushbutton.h"
+#include "tqscrollbar.h"
+#include "tqtabbar.h"
+#include "tqtabwidget.h"
+#include "tqlistview.h"
+#include "tqsplitter.h"
+#include "tqslider.h"
+#include "tqcombobox.h"
+#include "tqdockwindow.h"
+#include "tqdockarea.h"
+#include "tqprogressbar.h"
+#include "tqimage.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 tqmotifstyle.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::tqdrawPrimitiveBase( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch( pe ) {
+#ifndef TQT_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->tqpalette().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 quite 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()->tqpalette().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:
+#ifndef USE_QT4 // [FIXME]
+ case PE_HeaderSection:
+#endif // USE_QT4
+ qDrawShadePanel( p, r, cg, bool(flags & (Style_Down | Style_On )),
+ tqpixelMetric(PM_DefaultFrameWidth),
+ &cg.brush(TQColorGroup::Button) );
+ break;
+
+ case PE_Indicator: {
+#ifndef TQT_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,
+ tqpixelMetric(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( Qt::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( Qt::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(Qt::color1);
+ p->setBrush(Qt::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 TQT_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( Qt::NoPen );
+ TQBrush brush = cg.brush( flags & Style_Enabled ? TQColorGroup::Button :
+ TQColorGroup::Mid );
+ p->setPen( pen );
+ p->setBrush( brush );
+ p->drawPolygon( bFill );
+ p->setBrush( Qt::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 = tqpixelMetric( 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 = tqpixelMetric( 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 = tqpixelMetric(PM_ButtonShiftHorizontal);
+ bsy = tqpixelMetric(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
+
+#ifndef USE_QT4 // [FIXME]
+ case PE_DockWindowResizeHandle:
+#endif // USE_QT4
+ {
+ const int motifOffset = 10;
+ int sw = tqpixelMetric( 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;
+ }
+
+#ifndef USE_QT4 // [FIXME]
+ 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 = tqpixelMetric(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;
+ }
+#endif // USE_QT4
+
+ case PE_ScrollBarSubLine:
+ tqdrawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
+ p, r, cg, Style_Enabled | flags);
+ break;
+
+ case PE_ScrollBarAddLine:
+ tqdrawPrimitive(((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:
+ tqdrawPrimitive(PE_ButtonBevel, p, r, cg,
+ (flags | Style_Raised) & ~Style_Down);
+ break;
+
+#ifndef USE_QT4 // [FIXME]
+ case PE_ProgressBarChunk:
+ p->fillRect( r.x(), r.y() + 2, r.width() - 2,
+ r.height() - 4, cg.brush(TQColorGroup::Highlight));
+ break;
+#endif // USE_QT4
+
+ default:
+ TQCommonStyle::tqdrawPrimitive( pe, p, r, cg, flags, opt );
+ break;
+ }
+}
+
+
+/*!\reimp
+*/
+void TQMotifStyle::tqdrawControl( TQ_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 TQT_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(), Qt::NoBrush ) );
+ diw = tqpixelMetric( 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(), Qt::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() );
+ tqdrawPrimitive( PE_ButtonCommand, p,
+ tmp, newCg,
+ flags );
+ p->restore();
+ }
+ if ( p->brush().style() != Qt::NoBrush )
+ p->setBrush( Qt::NoBrush );
+#endif
+ break;
+ }
+
+ case CE_TabBarTab:
+ {
+#ifndef TQT_NO_TABBAR
+ if ( !widget || !widget->parentWidget() || !opt.tab() )
+ break;
+
+ const TQTabBar * tb = (const TQTabBar *) widget;
+ const TQTab * t = opt.tab();
+
+ int dfw = tqpixelMetric( PM_DefaultFrameWidth, tb );
+ bool selected = flags & Style_Selected;
+ int o = dfw > 1 ? 1 : 0;
+ bool lastTab = FALSE;
+
+ TQRect r2( r );
+ if ( tb->tqshape() == TQTabBar::RoundedAbove ) {
+ if ( tqstyleHint( SH_TabBar_Alignment, tb ) == TQt::AlignRight &&
+ tb->indexOf( t->identifier() ) == tb->count()-1 )
+ lastTab = TRUE;
+
+ if ( o ) {
+ p->setPen( tb->tqcolorGroup().light() );
+ p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
+ p->setPen( tb->tqcolorGroup().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->tqcolorGroup().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->tqpalette().active().brush( TQColorGroup::Background ));
+ p->setPen( tb->tqcolorGroup().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->tqcolorGroup().light() );
+ } else {
+ p->setPen( tb->tqcolorGroup().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->tqcolorGroup().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->tqshape() == TQTabBar::RoundedBelow ) {
+ if ( tqstyleHint( SH_TabBar_Alignment, tb ) == TQt::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->tqpalette().active().brush( TQColorGroup::Background ));
+ p->setPen( tb->tqcolorGroup().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->tqcolorGroup().dark() );
+ } else {
+ p->setPen( tb->tqcolorGroup().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->tqcolorGroup().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::tqdrawControl( element, p, widget, r, cg, flags, opt );
+ }
+#endif
+ break;
+ }
+
+ case CE_ProgressBarGroove:
+ qDrawShadePanel(p, r, cg, TRUE, 2);
+ break;
+
+ case CE_ProgressBarLabel:
+ {
+#ifndef TQT_NO_PROGRESSBAR
+ const TQProgressBar * pb = (const TQProgressBar *) widget;
+ const int unit_width = tqpixelMetric( 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, TQt::AlignCenter | TQt::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, TQt::AlignCenter | TQt::SingleLine, pb->progressString() );
+ }
+ } else {
+ p->setPen( cg.text() );
+ p->drawText( r, TQt::AlignCenter | TQt::SingleLine, pb->progressString() );
+ }
+ }
+#endif
+ break;
+ }
+
+#ifndef TQT_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 (tqpixelMetric( 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 = tqvisualRect( 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;
+
+ tqdrawPrimitive(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 = tqvisualRect( 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.tqfind( '\t' );
+ int m = motifItemVMargin;
+ int text_flags = TQt::AlignVCenter|TQt::ShowPrefix | TQt::DontClip | TQt::SingleLine;
+ text_flags |= (TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft );
+ if ( t >= 0 ) { // draw tab text
+ TQRect vr = tqvisualRect( 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( Qt::OpaqueMode );
+ p->drawPixmap( xvis, y+motifItemFrame, *pixmap );
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( Qt::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 = tqvisualRect( TQRect(x+w - motifArrowHMargin - motifItemFrame - dim,
+ y+h/2-dim/2, dim, dim), r );
+ if ( act )
+ tqdrawPrimitive(arrow, p, vr, cg,
+ (Style_Down |
+ (dis ? Style_Default : Style_Enabled)) );
+ else
+ tqdrawPrimitive(arrow, p, vr, cg,
+ (dis ? Style_Default : Style_Enabled));
+ }
+
+ break;
+ }
+#endif // TQT_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::tqdrawControl( element, p, widget, r, cg, flags, opt );
+ break;
+ }
+
+ default:
+ TQCommonStyle::tqdrawControl( 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::tqdrawComplexControl( TQ_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,
+ tqpixelMetric( PM_DefaultFrameWidth) );
+
+ if ( sub & SC_SpinWidgetUp || sub & SC_SpinWidgetDown ) {
+ if ( sub & SC_SpinWidgetUp )
+ drawSub |= SC_SpinWidgetUp;
+ if ( sub & SC_SpinWidgetDown )
+ drawSub |= SC_SpinWidgetDown;
+
+ TQCommonStyle::tqdrawComplexControl( control, p, widget, r, cg, flags,
+ drawSub, subActive, opt );
+ }
+ break; }
+
+ case CC_Slider:
+ {
+#ifndef TQT_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 );
+ tqdrawPrimitive( PE_FocusRect, p, fr, cg );
+ }
+ }
+
+ if (( sub & SC_SliderHandle ) && handle.isValid()) {
+ tqdrawPrimitive( PE_ButtonBevel, p, handle, cg );
+
+ if ( slider->orientation() == Qt::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::tqdrawComplexControl( control, p, widget, r, cg, flags,
+ SC_SliderTickmarks, subActive,
+ opt );
+#endif
+ break;
+ }
+
+ case CC_ComboBox:
+#ifndef TQT_NO_COMBOBOX
+ if ( sub & SC_ComboBoxArrow ) {
+ const TQComboBox * cb = (const TQComboBox *) widget;
+ int awh, ax, ay, sh, sy, dh, ew;
+ int fw = tqpixelMetric( PM_DefaultFrameWidth, cb);
+
+ tqdrawPrimitive( PE_ButtonCommand, p, r, cg, flags );
+ TQRect ar = TQStyle::tqvisualRect( querySubControlMetrics( CC_ComboBox, cb, SC_ComboBoxArrow,
+ opt ), cb );
+ tqdrawPrimitive( 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::tqvisualRect( subRect( SR_ComboBoxFocusRect, cb ), cb );
+ tqdrawPrimitive( PE_FocusRect, p, re, cg );
+ }
+ }
+
+ if ( sub & SC_ComboBoxEditField ) {
+ TQComboBox * cb = (TQComboBox *) widget;
+ if ( cb->editable() ) {
+ TQRect er = TQStyle::tqvisualRect( 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,
+ tqpixelMetric(PM_DefaultFrameWidth, widget),
+ &cg.brush(TQColorGroup::Mid));
+ TQCommonStyle::tqdrawComplexControl(control, p, widget, r, cg, flags, sub,
+ subActive, opt);
+ break;
+ }
+
+#ifndef TQT_NO_LISTVIEW
+ case CC_ListView:
+ {
+ if ( sub & SC_ListView ) {
+ TQCommonStyle::tqdrawComplexControl( 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( Qt::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 // TQT_NO_LISTVIEW
+
+ default:
+ TQCommonStyle::tqdrawComplexControl( control, p, widget, r, cg, flags,
+ sub, subActive, opt );
+ }
+}
+
+
+/*! \reimp */
+int TQMotifStyle::tqpixelMetric( 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 TQT_NO_SLIDER
+ const TQSlider * sl = (const TQSlider *) widget;
+ int space = (sl->orientation() == Qt::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 TQT_NO_SLIDER
+ const TQSlider * sl = (const TQSlider *) widget;
+ if ( sl->orientation() == Qt::Horizontal )
+ ret = sl->width() - tqpixelMetric( PM_SliderLength, sl ) - 6;
+ else
+ ret = sl->height() - tqpixelMetric( 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::tqpixelMetric( metric, widget );
+ break;
+ }
+ return ret;
+}
+
+
+/*!\reimp
+*/
+TQRect TQMotifStyle::querySubControlMetrics( TQ_ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& opt ) const
+{
+ switch ( control ) {
+ case CC_SpinWidget: {
+ if ( !widget )
+ return TQRect();
+ int fw = tqpixelMetric( 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 TQT_NO_SLIDER
+ case CC_Slider: {
+ if (sc == SC_SliderHandle) {
+ const TQSlider * sl = (const TQSlider *) widget;
+ int tickOffset = tqpixelMetric( PM_SliderTickmarkOffset, sl );
+ int thickness = tqpixelMetric( PM_SliderControlThickness, sl );
+ int sliderPos = sl->sliderStart();
+ int len = tqpixelMetric( PM_SliderLength, sl );
+ int motifBorder = 3;
+
+ if ( sl->orientation() == Qt::Horizontal )
+ return TQRect( sliderPos + motifBorder, tickOffset + motifBorder, len,
+ thickness - 2*motifBorder );
+ return TQRect( tickOffset + motifBorder, sliderPos + motifBorder,
+ thickness - 2*motifBorder, len );
+ }
+ break; }
+#endif
+
+#ifndef TQT_NO_SCROLLBAR
+ case CC_ScrollBar: {
+ if (! widget)
+ return TQRect();
+
+ const TQScrollBar *scrollbar = (const TQScrollBar *) widget;
+ int sliderstart = scrollbar->sliderStart();
+ int sbextent = tqpixelMetric(PM_ScrollBarExtent, widget);
+ int fw = tqpixelMetric(PM_DefaultFrameWidth, widget);
+ int buttonw = sbextent - (fw * 2);
+ int buttonh = sbextent - (fw * 2);
+ int maxlen = ((scrollbar->orientation() == Qt::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() == Qt::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() == Qt::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() == Qt::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() == Qt::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() == Qt::Horizontal)
+ return TQRect(buttonw + fw, fw, maxlen, buttonw);
+ return TQRect(fw, buttonw + fw, buttonw, maxlen);
+
+ case SC_ScrollBarSlider:
+ if (scrollbar->orientation() == Qt::Horizontal)
+ return TQRect(sliderstart, fw, sliderlen, buttonw);
+ return TQRect(fw, sliderstart, buttonw, sliderlen);
+
+ default:
+ break;
+ }
+ break; }
+#endif
+
+#ifndef TQT_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 = tqpixelMetric( 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 = tqpixelMetric( 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::tqsizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& opt ) const
+{
+ TQSize sz(contentsSize);
+
+ switch(contents) {
+ case CT_PushButton:
+ {
+#ifndef TQT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ sz = TQCommonStyle::tqsizeFromContents(contents, widget, contentsSize, opt);
+ if ((button->isDefault() || button->autoDefault()) &&
+ sz.width() < 80 && ! button->pixmap())
+ sz.setWidth(80);
+#endif
+ break;
+ }
+
+ case CT_PopupMenuItem:
+ {
+#ifndef TQT_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()->tqsizeHint().width();
+ h = mi->custom()->tqsizeHint().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().tqfind('\t') >= 0 )
+ // string tqcontains 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::tqsizeFromContents( 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 = tqpixelMetric( 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 TQT_NO_MAINWINDOW
+ if ( !widget || !widget->tqparent() )
+ break;
+
+ const TQDockWindow * dw = (const TQDockWindow *) widget->tqparent();
+ if ( !dw->area() || !dw->isCloseEnabled() )
+ rect.setRect( 0, 0, widget->width(), widget->height() );
+ else {
+ if ( dw->area()->orientation() == Qt::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 TQT_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 TQT_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 TQT_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 TQT_NO_POPUPMENU
+ if ( !p->testWState( TQt::WState_Polished ) )
+ p->setCheckable( FALSE );
+#endif
+}
+
+
+#ifndef TQT_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 TQT_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::tqpalette().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::tqstyleHint(TQ_StyleHint hint,
+ const TQWidget *widget,
+ const TQStyleOption &opt,
+ TQStyleHintReturn *returnData) const
+{
+ int ret;
+
+ switch (hint) {
+ case SH_GUIStyle:
+ ret = TQt::MotifStyle;
+ break;
+
+ case SH_ScrollBar_BackgroundMode:
+ ret = TQt::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 = TQt::AlignAuto | TQt::AlignVCenter;
+ break;
+
+ case SH_ItemView_ChangeHighlightOnFocus:
+ ret = 0;
+ break;
+
+ default:
+ ret = TQCommonStyle::tqstyleHint(hint, widget, opt, returnData);
+ break;
+ }
+
+ return ret;
+}
+
+
+#endif
diff --git a/tqtinterface/qt4/src/styles/tqmotifstyle.h b/tqtinterface/qt4/src/styles/tqmotifstyle.h
new file mode 100644
index 0000000..f5d6a52
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqmotifstyle.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 requirements 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 TQT_H
+#include "tqcommonstyle.h"
+#endif // TQT_H
+
+#if !defined(TQT_NO_STYLE_MOTIF) || defined(TQT_PLUGIN)
+
+class TQPalette;
+
+#if defined(TQT_PLUGIN)
+#define TQ_EXPORT_STYLE_MOTIF
+#else
+#define TQ_EXPORT_STYLE_MOTIF TQ_EXPORT
+#endif
+
+
+class TQ_EXPORT_STYLE_MOTIF TQMotifStyle : public TQCommonStyle
+{
+ TQ_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 tqdrawPrimitiveBase( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawControl( TQ_ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawComplexControl( TQ_ComplexControl control,
+ TQPainter *p,
+ const TQWidget* widget,
+ const TQRect& r,
+ const TQColorGroup& cg,
+ SFlags how = Style_Default,
+#ifdef TQ_TQDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect querySubControlMetrics( TQ_ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int tqpixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const;
+
+ TQSize tqsizeFromContents( 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 tqstyleHint(TQ_StyleHint sh, const TQWidget *, const TQStyleOption & = TQStyleOption::Default,
+ TQStyleHintReturn* = 0) const;
+
+private:
+ bool highlightCols;
+
+ // Disabled copy constructor and operator=
+#if defined(TQ_DISABLE_COPY)
+ TQMotifStyle( const TQMotifStyle & );
+ TQMotifStyle& operator=( const TQMotifStyle & );
+#endif
+};
+
+#endif // TQT_NO_STYLE_MOTIF
+
+#endif // TQMOTIFSTYLE_H
diff --git a/tqtinterface/qt4/src/styles/tqplatinumstyle.cpp b/tqtinterface/qt4/src/styles/tqplatinumstyle.cpp
new file mode 100644
index 0000000..2be69b0
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqplatinumstyle.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 requirements 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 "tqplatinumstyle.h"
+
+#if !defined(TQT_NO_STYLE_PLATINUM) || defined(TQT_PLUGIN)
+
+#include "tqapplication.h"
+#include "tqcombobox.h"
+#include "tqdrawutil.h"
+#include "tqpainter.h"
+#include "tqpalette.h"
+#include "tqpixmap.h"
+#include "tqpushbutton.h"
+#include "tqscrollbar.h"
+#include "tqslider.h"
+#include <limits.h>
+
+/*!
+ \class TQPlatinumStyle tqplatinumstyle.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::tqdrawPrimitiveBase( TQ_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;
+ tqdrawPrimitive( 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;
+
+ // quick 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 );
+ tqdrawPrimitive( 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( Qt::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:
+ {
+ tqdrawPrimitive( 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, Qt::color1);
+ if ( flags & Style_Off ) {
+ TQPen oldPen = p->pen();
+ p->setPen ( TQPen(Qt::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( Qt::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( Qt::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(Qt::color1);
+ p->setBrush(Qt::color1);
+ p->drawPolygon(a);
+ break;
+ }
+ case PE_ScrollBarAddLine:
+ {
+ tqdrawPrimitive( PE_ButtonBevel, p, r, cg,
+ (flags & Style_Enabled) | ((flags & Style_Down)
+ ? Style_Sunken
+ : Style_Raised) );
+ p->setPen( cg.shadow() );
+ p->drawRect( r );
+ tqdrawPrimitive( ((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:
+ {
+ tqdrawPrimitive( PE_ButtonBevel, p, r, cg,
+ (flags & Style_Enabled) | ((flags & Style_Down)
+ ? Style_Sunken
+ : Style_Raised) );
+ p->setPen( cg.shadow() );
+ p->drawRect( r );
+ tqdrawPrimitive( ((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() );
+ tqdrawPrimitive( 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 ) {
+ tqdrawPrimitive( PE_FocusRect, p, TQRect(r.x() + 2, r.y() + 2,
+ r.width() - 5,
+ r.height() - 5 ),
+ cg, flags );
+ }
+ break;
+ }
+ default:
+ TQWindowsStyle::tqdrawPrimitive( pe, p, r, cg, flags, opt );
+ break;
+ }
+
+}
+
+/*!\reimp
+ */
+void TQPlatinumStyle::tqdrawControl( TQ_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 TQT_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(), Qt::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(), Qt::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 = tqpixelMetric( 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 ) {
+ tqdrawPrimitive( PE_ButtonBevel, p, TQRect( x1, y1,
+ x2 - x1 + 1,
+ y2 - y1 + 1 ),
+ myCg, myFlags, opt );
+ } else {
+ tqdrawPrimitive( 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;
+ tqdrawPrimitive( PE_ButtonBevel, p, TQRect( x1, y1,
+ x2 - x1 + 1,
+ y2 - y1 + 1 ),
+ myCg, flags, opt );
+ } else {
+
+ tqdrawPrimitive( PE_ButtonCommand, p, TQRect( x1, y1,
+ x2 - x1 + 1,
+ y2 - y1 + 1 ),
+ myCg, flags, opt );
+ }
+ }
+
+
+ if ( p->brush().style() != Qt::NoBrush )
+ p->setBrush( Qt::NoBrush );
+ break;
+#endif
+ }
+ case CE_PushButtonLabel:
+ {
+#ifndef TQT_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 = tqpixelMetric( 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;
+ tqdrawPrimitive( PE_ArrowDown, p, TQRect(x + w - dx - 1, y + 2,
+ dx, h - 4),
+ g, flags, opt );
+ w -= dx;
+ }
+#ifndef TQT_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 ),
+ TQt::AlignCenter | TQt::ShowPrefix,
+ btn->tqcolorGroup(), btn->isEnabled(),
+ btn->pixmap(), btn->text(), -1,
+ on ? TQT_TQCOLOR_CONST(&btn->tqcolorGroup().brightText())
+ : TQT_TQCOLOR_CONST(&btn->tqcolorGroup().buttonText()) );
+ if ( btn->hasFocus() )
+ tqdrawPrimitive( PE_FocusRect, p,
+ subRect(SR_PushButtonFocusRect, widget),
+ cg, flags );
+ break;
+#endif
+ }
+ default:
+ TQWindowsStyle::tqdrawControl( element, p, widget, r, cg, how, opt );
+ break;
+ }
+}
+
+/*!\reimp
+ */
+void TQPlatinumStyle::tqdrawComplexControl( TQ_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( Qt::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 TQT_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::tqvisualRect( 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::tqvisualRect( subRect( SR_ComboBoxFocusRect,
+ cmb ),
+ widget );
+ tqdrawPrimitive( 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 TQT_NO_SLIDER
+ const TQSlider *slider = (const TQSlider *) widget;
+ int thickness = tqpixelMetric( PM_SliderControlThickness, widget );
+ int len = tqpixelMetric( 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() == Qt::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 )
+ tqdrawPrimitive( 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() == Qt::Vertical ) {
+ // Background
+ TQBrush oldBrush = p->brush();
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->setPen( Qt::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 { // Qt::Horizontal
+ TQBrush oldBrush = p->brush();
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->setPen( Qt::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::tqdrawComplexControl( control, p, widget, r,
+ cg, how, SC_SliderTickmarks,
+ subActive, opt );
+#endif
+ break;
+ }
+ default:
+ TQWindowsStyle::tqdrawComplexControl( control, p, widget, r, cg,
+ how, sub, subActive, opt );
+ break;
+ }
+}
+
+
+
+/*!\reimp
+ */
+TQRect TQPlatinumStyle::querySubControlMetrics( TQ_ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& opt ) const
+{
+ switch( control ) {
+#ifndef TQT_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 TQT_NO_SCROLLBAR
+ case CC_ScrollBar: {
+ const TQScrollBar *sb;
+ sb = (const TQScrollBar *)widget;
+ int sliderStart = sb->sliderStart();
+ int sbextent = tqpixelMetric( PM_ScrollBarExtent, widget );
+ int maxlen = ((sb->orientation() == Qt::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 = tqpixelMetric( 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() == Qt::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() == Qt::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() == Qt::Horizontal )
+ return TQRect( 1, 0, sliderStart, sbextent );
+ return TQRect( 0, 1, sbextent, sliderStart );
+ case SC_ScrollBarAddPage:
+ if ( sb->orientation() == Qt::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() == Qt::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 TQT_NO_SLIDER
+ case CC_Slider: {
+
+ const TQSlider *slider = (const TQSlider *) widget;
+ int tickOffset = tqpixelMetric( PM_SliderTickmarkOffset, widget);
+ int thickness = tqpixelMetric( PM_SliderControlThickness, widget);
+ int mid = thickness / 2;
+ int ticks = slider->tickmarks();
+ int len = tqpixelMetric( 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() == Qt::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::tqpixelMetric( 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::tqpixelMetric( 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 tqgeometry 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/tqtinterface/qt4/src/styles/tqplatinumstyle.h b/tqtinterface/qt4/src/styles/tqplatinumstyle.h
new file mode 100644
index 0000000..0d53eb3
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqplatinumstyle.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 requirements 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 TQT_H
+#include "tqwindowsstyle.h"
+#endif // TQT_H
+
+#if !defined(TQT_NO_STYLE_PLATINUM) || defined(TQT_PLUGIN)
+
+class TQPalette;
+
+#if defined(TQT_PLUGIN)
+#define TQ_EXPORT_STYLE_PLATINUM
+#else
+#define TQ_EXPORT_STYLE_PLATINUM TQ_EXPORT
+#endif
+
+class TQ_EXPORT_STYLE_PLATINUM TQPlatinumStyle : public TQWindowsStyle
+{
+ TQ_OBJECT
+public:
+ TQPlatinumStyle();
+ virtual ~TQPlatinumStyle();
+
+ // new Style Stuff
+ void tqdrawPrimitiveBase( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawControl( TQ_ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawComplexControl( TQ_ComplexControl control,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+#ifdef TQ_TQDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect querySubControlMetrics( TQ_ComplexControl control,
+ const TQWidget *widget,
+ SubControl sc,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int tqpixelMetric( 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(TQ_DISABLE_COPY)
+ TQPlatinumStyle( const TQPlatinumStyle & );
+ TQPlatinumStyle& operator=( const TQPlatinumStyle & );
+#endif
+};
+
+#endif // TQT_NO_STYLE_PLATINUM
+
+#endif // TQPLATINUMSTYLE_H
diff --git a/tqtinterface/qt4/src/styles/tqsgistyle.cpp b/tqtinterface/qt4/src/styles/tqsgistyle.cpp
new file mode 100644
index 0000000..6b8a17b
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqsgistyle.cpp
@@ -0,0 +1,1470 @@
+/****************************************************************************
+**
+** 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 requirements 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 "tqsgistyle.h"
+
+#if !defined(TQT_NO_STYLE_SGI) || defined(TQT_PLUGIN)
+
+#include "tqpopupmenu.h"
+#include "tqapplication.h"
+#include "tqbutton.h"
+#include "tqpainter.h"
+#include "tqdrawutil.h"
+#include "tqpixmap.h"
+#include "tqpalette.h"
+#include "tqwidget.h"
+#include "tqpushbutton.h"
+#include "tqscrollbar.h"
+#include "tqcombobox.h"
+#include "tqslider.h"
+#include "tqtextedit.h"
+#include "tqtoolbar.h"
+#include "tqlineedit.h"
+#include "tqmenubar.h"
+#include <limits.h>
+
+#ifndef TQT_NO_SLIDER
+struct SliderLastPosition
+{
+ SliderLastPosition() : rect(0,-1,0,-1), slider(0) {}
+ TQRect rect;
+ const TQSlider* slider;
+};
+#endif
+
+#ifndef TQT_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 TQT_NO_SCROLLBAR
+ ScrollbarLastPosition lastScrollbarRect;
+#endif
+#ifndef TQT_NO_SLIDER
+ SliderLastPosition lastSliderRect;
+#endif
+};
+
+/*!
+ \class TQSGIStyle tqsgistyle.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::tqsetPalette( 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::tqsetPalette( pal, TRUE, "TQLineEdit" );
+ TQApplication::tqsetPalette( pal, TRUE, "TQTextEdit" );
+ TQApplication::tqsetPalette( pal, TRUE, "TQDateTimeEditBase" );
+
+ pal = TQApplication::palette();
+ pal.setColor( TQColorGroup::Button, pal.active().background() );
+ TQApplication::tqsetPalette( pal, TRUE, "TQMenuBar" );
+ TQApplication::tqsetPalette( pal, TRUE, "TQToolBar" );
+ TQApplication::tqsetPalette( pal, TRUE, "TQPopupMenu" );
+}
+
+/*! \reimp
+*/
+void
+TQSGIStyle::unPolish( TQApplication* /* app */ )
+{
+ TQFont f = TQApplication::font();
+ TQApplication::tqsetFont( 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 ( ::tqqt_cast<TQLineEdit*>(w) || ::tqqt_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 ( ::tqqt_cast<TQMenuBar*>(w) || ::tqqt_cast<TQToolBar*>(w) ) {
+ sgiPal.setColor( TQColorGroup::Button, sgiPal.active().midlight() );
+ }
+
+ w->setPalette( sgiPal );
+ }
+
+ if ( ::tqqt_cast<TQButton*>(w) || ::tqqt_cast<TQSlider*>(w) || ::tqqt_cast<TQScrollBar*>(w) ) {
+ w->installEventFilter( this );
+ w->setMouseTracking( TRUE );
+#ifndef TQT_NO_SCROLLBAR
+ if ( ::tqqt_cast<TQScrollBar*>(w) )
+ w->setBackgroundMode( TQt::NoBackground );
+#endif
+ } else if ( ::tqqt_cast<TQComboBox*>(w) ) {
+ TQFont f = TQApplication::font();
+ f.setBold( TRUE );
+ f.setItalic( TRUE );
+ w->setFont( f );
+#ifndef TQT_NO_MENUBAR
+ } else if ( ::tqqt_cast<TQMenuBar*>(w) ) {
+ ((TQFrame*) w)->setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised);
+ w->setBackgroundMode( TQt::PaletteBackground );
+ TQFont f = TQApplication::font();
+ f.setBold( TRUE );
+ f.setItalic( TRUE );
+ w->setFont( f );
+#endif
+#ifndef TQT_NO_POPUPMENU
+ } else if ( ::tqqt_cast<TQPopupMenu*>(w) ) {
+ ((TQFrame*) w)->setLineWidth( tqpixelMetric( PM_DefaultFrameWidth ) + 1 );
+ TQFont f = TQApplication::font();
+ f.setBold( TRUE );
+ f.setItalic( TRUE );
+ w->setFont( f );
+#endif
+ } else if ( ::tqqt_cast<TQToolBar*>(w) || w->inherits("TQToolBarSeparator") ) {
+ w->setBackgroundMode( TQt::PaletteBackground );
+ }
+}
+
+/*! \reimp */
+void
+TQSGIStyle::unPolish( TQWidget* w )
+{
+ if ( ::tqqt_cast<TQButton*>(w) || ::tqqt_cast<TQSlider*>(w) || ::tqqt_cast<TQScrollBar*>(w) ) {
+ w->removeEventFilter( this );
+#ifndef TQT_NO_POPUPMENU
+ } else if ( ::tqqt_cast<TQPopupMenu*>(w) ) {
+ ((TQFrame*)w)->setLineWidth( tqpixelMetric( PM_DefaultFrameWidth ) );
+ w->setFont( TQApplication::font() );
+#endif
+#if !defined(TQT_NO_MENUBAR) || !defined(TQT_NO_COMBOBOX)
+ } else if ( ::tqqt_cast<TQMenuBar*>(w) || ::tqqt_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 TQT_NO_SCROLLBAR
+ if ( ::tqqt_cast<TQScrollBar*>(widget) ) {
+ d->lastScrollbarRect.rect = ((TQScrollBar*)widget)->sliderRect();
+ d->lastScrollbarRect.scrollbar = ((TQScrollBar*)widget);
+ widget->tqrepaint( FALSE );
+ } else
+#endif
+ {
+#ifndef TQT_NO_SLIDER
+ if ( ::tqqt_cast<TQSlider*>(widget) ) {
+ d->lastSliderRect.rect = ((TQSlider*)widget)->sliderRect();
+ d->lastSliderRect.slider = ((TQSlider*)widget);
+ widget->tqrepaint( FALSE );
+ }
+#endif
+ }
+ }
+ break;
+
+ case TQEvent::MouseButtonRelease:
+ {
+ if ( 0 ) {
+#ifndef TQT_NO_SCROLLBAR
+ } else if ( ::tqqt_cast<TQScrollBar*>(widget) ) {
+ TQRect oldRect = d->lastScrollbarRect.rect;
+ d->lastScrollbarRect.rect = TQRect( 0, -1, 0, -1 );
+ widget->tqrepaint( oldRect, FALSE );
+#endif
+#ifndef TQT_NO_SLIDER
+ } else if ( ::tqqt_cast<TQSlider*>(widget) ) {
+ TQRect oldRect = d->lastSliderRect.rect;
+ d->lastSliderRect.rect = TQRect( 0, -1, 0, -1 );
+ widget->tqrepaint( 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->tqrepaint( FALSE );
+ break;
+
+ case TQEvent::Enter:
+ if ( !widget->isActiveWindow() )
+ break;
+ d->hotWidget = widget;
+ widget->tqrepaint( FALSE );
+ break;
+
+ case TQEvent::Leave:
+ if ( !widget->isActiveWindow() )
+ break;
+ if ( widget == d->hotWidget) {
+ d->hotWidget = 0;
+ widget->tqrepaint( 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::tqpixelMetric( 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::tqpixelMetric( 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->tqfind( '&', 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::tqdrawPrimitiveBase( TQ_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 = tqpixelMetric( 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:
+ {
+ tqdrawPrimitive( 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() : TQT_TQCOLOR_OBJECT(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;
+ tqdrawPrimitive( PE_ButtonBevel, p, er, cg, (QStyle::StateFlag)iflags, opt );
+ if ( !(flags & TQStyle::Style_Off) ) {
+ er = r;
+ er.addCoords( 1, 2, 1, 1 );
+ tqdrawPrimitive( 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;
+
+#ifndef USE_QT4 // [FIXME]
+ 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;
+#endif // USE_QT4
+
+ 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.tqcontains( d->mousePos ) && !(flags & Style_Active) )
+ flags &= ~Style_MouseOver;
+ tqdrawPrimitive( PE_ButtonCommand, p, r, cg, flags, opt );
+ tqdrawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
+ p, r, cg, Style_Enabled | flags);
+ break;
+
+ case PE_ScrollBarAddLine:
+ if ( !r.tqcontains( d->mousePos ) )
+ flags &= ~Style_MouseOver;
+ tqdrawPrimitive( PE_ButtonCommand, p, r, cg, flags, opt );
+ tqdrawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown),
+ p, r, cg, Style_Enabled | flags);
+ break;
+
+ case PE_ScrollBarSubPage:
+ case PE_ScrollBarAddPage:
+ if ( !r.tqcontains( 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.tqcontains( d->mousePos ) || flags & Style_Active) || !(flags & Style_Enabled ) )
+ flags &= ~Style_MouseOver;
+
+ TQPixmap pm( r.width(), r.height() );
+ TQPainter bp( &pm );
+ tqdrawPrimitive(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 = tqpixelMetric( 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 );
+
+ tqdrawPrimitive( 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 );
+ tqdrawPrimitive( 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::tqdrawPrimitive( pe, p, r, cg, flags, opt );
+ break;
+ }
+}
+
+/*! \reimp */
+void TQSGIStyle::tqdrawControl( TQ_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 TQT_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(), Qt::NoBrush ) );
+ p->setBrushOrigin( -widget->backgroundOffset().x(),
+ -widget->backgroundOffset().y() );
+
+ int diw = tqpixelMetric( 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() )
+ tqdrawPrimitive( 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 TQT_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 ( tqpixelMetric( PM_DefaultFrameWidth ) > 1 )
+ drawPanel( p, x, y, w, h, cg, FALSE, pw,
+ &TQT_TQBRUSH_OBJECT(cg.brush( TQColorGroup::Light )) );
+ else
+ drawPanel( p, x+1, y+1, w-2, h-2, cg, FALSE, 1,
+ &TQT_TQBRUSH_OBJECT(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, &TQT_TQBRUSH_OBJECT(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,
+ tqpixelMetric(PM_IndicatorWidth),
+ tqpixelMetric(PM_IndicatorHeight) );
+ er.addCoords( 1, 1, -1, -1 );
+ tqdrawPrimitive( PE_ButtonBevel, p, er, cg, cflags, opt );
+ er.addCoords( 0, 1, 1, 1 );
+ tqdrawPrimitive( 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.tqfind( '\t' );
+ int m = sgiItemVMargin;
+ const int text_flags = TQt::AlignVCenter | TQt::DontClip | TQt::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( Qt::OpaqueMode );
+ p->drawPixmap( x+xm, y+sgiItemFrame, *pixmap );
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( Qt::TransparentMode );
+ }
+ }
+ if ( mi->popup() ) {
+ int dim = (h-2*sgiItemFrame) / 2;
+ tqdrawPrimitive( PE_ArrowRight, p, TQRect( x+w-sgiArrowHMargin-sgiItemFrame-dim, y+h/2-dim/2, dim, dim ), cg, flags );
+ }
+#endif
+ }
+ break;
+
+ case CE_MenuBarItem:
+ {
+#ifndef TQT_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, TQt::AlignCenter|TQt::DontClip|TQt::SingleLine,
+ cg, mi->isEnabled(), mi->pixmap(), "", -1, TQT_TQCOLOR_CONST(&cg.buttonText()) );
+
+ if ( !!mi->text() ) {
+ TQString* text = new TQString(mi->text());
+ TQRect br = p->fontMetrics().boundingRect( x, y-2, w+1, h,
+ TQt::AlignCenter|TQt::DontClip|TQt::SingleLine|TQt::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, TQt::AlignCenter|TQt::DontClip|TQt::SingleLine, *text, text->length() );
+ delete text;
+ }
+#endif
+ }
+ break;
+
+ case CE_CheckBox:
+ TQMotifStyle::tqdrawControl( element, p, widget, r, cg, flags, opt );
+ break;
+
+ default:
+ TQMotifStyle::tqdrawControl( element, p, widget, r, cg, flags, opt );
+ break;
+ }
+}
+
+/*! \reimp */
+void TQSGIStyle::tqdrawComplexControl( TQ_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 TQT_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 );
+ tqdrawPrimitive( PE_ButtonBevel, p, grooveTop, cg, flags & ~Style_MouseOver, opt );
+
+ if ( flags & Style_HasFocus ) {
+ TQRect fr = subRect( SR_SliderFocusRect, widget );
+ tqdrawPrimitive( 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.tqcontains( d->mousePos ) && subActive != SC_SliderHandle )
+ flags &= ~Style_MouseOver;
+ tqdrawPrimitive( PE_ButtonBevel, p, handle, cg, flags );
+
+ if ( slider->orientation() == Qt::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::tqdrawComplexControl( control, p, widget, r, cg, flags,
+ SC_SliderTickmarks, subActive,
+ opt );
+#endif
+ break;
+ }
+ case CC_ComboBox:
+ {
+#ifndef TQT_NO_COMBOBOX
+ const TQComboBox * cb = (TQComboBox *) widget;
+
+ if (sub & SC_ComboBoxFrame) {
+ TQRect fr =
+ TQStyle::tqvisualRect( querySubControlMetrics( CC_ComboBox, cb,
+ SC_ComboBoxFrame ), cb );
+ tqdrawPrimitive( PE_ButtonBevel, p, fr, cg, flags );
+ }
+
+ if ( sub & SC_ComboBoxArrow ) {
+ p->save();
+ TQRect er =
+ TQStyle::tqvisualRect( querySubControlMetrics( CC_ComboBox, cb, SC_ComboBoxArrow ), cb );
+
+ er.addCoords( 0, 3, 0, 0 );
+
+ tqdrawPrimitive( 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::tqvisualRect( subRect( SR_ComboBoxFocusRect, cb ), cb );
+ tqdrawPrimitive( PE_FocusRect, p, re, cg );
+ }
+ }
+ if ( sub & SC_ComboBoxEditField ) {
+ if ( cb->editable() ) {
+ TQRect er =
+ TQStyle::tqvisualRect( 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 TQT_NO_SCROLLBAR
+ TQScrollBar *scrollbar = (TQScrollBar*)widget;
+ bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue());
+ if ( maxedOut )
+ flags &= ~Style_Enabled;
+
+ TQRect handle = TQStyle::tqvisualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSlider, opt ), widget );
+
+ if ( sub & SC_ScrollBarGroove ) {
+ }
+ if ( sub & SC_ScrollBarAddLine ) {
+ TQRect er = TQStyle::tqvisualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarAddLine, opt ), widget );
+ tqdrawPrimitive( PE_ScrollBarAddLine, p, er, cg, flags, opt );
+ }
+ if ( sub & SC_ScrollBarSubLine ) {
+ TQRect er = TQStyle::tqvisualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSubLine, opt ), widget );
+ tqdrawPrimitive( PE_ScrollBarSubLine, p, er, cg, flags, opt );
+ }
+ if ( sub & SC_ScrollBarAddPage ) {
+ TQRect er = TQStyle::tqvisualRect( 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 );
+ }
+
+ tqdrawPrimitive( 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::tqvisualRect( 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 );
+ }
+ tqdrawPrimitive( 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;
+
+ tqdrawPrimitive( PE_ScrollBarSlider, p, handle, cg, flags, opt );
+ }
+#endif
+ }
+ break;
+
+ default:
+ TQMotifStyle::tqdrawComplexControl( control, p, widget, r, cg, flags, sub, subActive, opt );
+ break;
+ }
+}
+
+/*!\reimp
+*/
+TQSize TQSGIStyle::tqsizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& opt ) const
+{
+ TQSize sz(contentsSize);
+
+ switch(contents) {
+ case CT_PopupMenuItem:
+ {
+#ifndef TQT_NO_POPUPMENU
+ if (! widget || opt.isDefault())
+ break;
+
+ TQMenuItem *mi = opt.menuItem();
+ sz = TQMotifStyle::tqsizeFromContents( 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::tqsizeFromContents( 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 = tqpixelMetric( 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( TQ_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 = tqpixelMetric( 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 = tqpixelMetric( 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 // TQT_NO_STYLE_SGI
diff --git a/tqtinterface/qt4/src/styles/tqsgistyle.h b/tqtinterface/qt4/src/styles/tqsgistyle.h
new file mode 100644
index 0000000..5ae9889
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqsgistyle.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 requirements 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 TQT_H
+#include "tqmotifstyle.h"
+#include "tqguardedptr.h"
+#include "tqwidget.h"
+#endif // TQT_H
+
+#if !defined(TQT_NO_STYLE_SGI) || defined(TQT_PLUGIN)
+
+#if defined(TQT_PLUGIN)
+#define TQ_EXPORT_STYLE_SGI
+#else
+#define TQ_EXPORT_STYLE_SGI TQ_EXPORT
+#endif
+
+class TQSGIStylePrivate;
+
+class TQ_EXPORT_STYLE_SGI TQSGIStyle: public TQMotifStyle
+{
+ TQ_OBJECT
+public:
+ TQSGIStyle( bool useHighlightCols = FALSE );
+ virtual ~TQSGIStyle();
+
+#if !defined(TQ_NO_USING_KEYWORD)
+ using TQMotifStyle::polish;
+#endif
+ void polish( TQWidget* );
+ void unPolish( TQWidget* );
+ void polish( TQApplication* );
+ void unPolish( TQApplication* );
+
+ void tqdrawPrimitiveBase( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawControl( TQ_ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags how = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawComplexControl( TQ_ComplexControl control,
+ TQPainter *p,
+ const TQWidget* widget,
+ const TQRect& r,
+ const TQColorGroup& cg,
+ SFlags how = Style_Default,
+#ifdef TQ_TQDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int tqpixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const;
+
+ TQSize tqsizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ TQRect subRect( SubRect r, const TQWidget *widget ) const;
+ TQRect querySubControlMetrics( TQ_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(TQ_DISABLE_COPY)
+ TQSGIStyle( const TQSGIStyle & );
+ TQSGIStyle& operator=( const TQSGIStyle & );
+#endif
+
+};
+
+#endif // TQT_NO_STYLE_SGI
+
+#endif // TQSGISTYLE_H
diff --git a/tqtinterface/qt4/src/styles/tqstylefactory.cpp b/tqtinterface/qt4/src/styles/tqstylefactory.cpp
new file mode 100644
index 0000000..42f1c2f
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqstylefactory.cpp
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Implementation of TQStyleFactory class
+**
+** Created : 001103
+**
+** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
+**
+** 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 requirements 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 "tqstyleinterface_p.h" // up here for GCC 2.7.* compatibility
+#include "tqstylefactory.h"
+
+#ifndef TQT_NO_STYLE
+
+#include "tqapplication.h"
+#include "tqwindowsstyle.h"
+#include "tqmotifstyle.h"
+#include "tqcdestyle.h"
+#include "tqmotifplusstyle.h"
+#include "tqplatinumstyle.h"
+#include "tqsgistyle.h"
+#include "tqcompactstyle.h"
+#ifndef TQT_NO_STYLE_WINDOWSXP
+#include "tqwindowsxpstyle.h"
+#endif
+#ifndef TQT_NO_STYLE_AQUA
+#include "tqaquastyle.h"
+#endif
+#ifndef TQT_NO_STYLE_POCKETPC
+#include "tqpocketpcstyle_wce.h"
+#endif
+
+#if !defined( TQT_NO_STYLE_MAC ) && defined( TQ_WS_MAC )
+TQString p2qstring(const unsigned char *c); //qglobal.cpp
+#include "tqt_mac.h"
+#include "tqmacstyle_mac.h"
+#endif
+#include <stdlib.h>
+
+#include <private/tqpluginmanager_p.h>
+#ifndef TQT_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( tqApp )
+{
+ manager = new TQPluginManager<TQStyleFactoryInterface>( IID_TQStyleFactory, TQApplication::libraryPaths(), "/styles", FALSE );
+}
+
+TQStyleFactoryPrivate::~TQStyleFactoryPrivate()
+{
+ delete manager;
+ manager = 0;
+
+ instance = 0;
+}
+
+#endif //TQT_NO_COMPONENT
+
+/*!
+ \class TQStyleFactory tqstylefactory.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 TQT_NO_STYLE_WINDOWS
+ if ( style == "windows" )
+ ret = new TQWindowsStyle;
+ else
+#endif
+#ifndef TQT_NO_STYLE_WINDOWSXP
+ if ( style == "windowsxp" )
+ ret = new TQWindowsXPStyle;
+ else
+#endif
+#ifndef TQT_NO_STYLE_MOTIF
+ if ( style == "motif" )
+ ret = new TQMotifStyle;
+ else
+#endif
+#ifndef TQT_NO_STYLE_CDE
+ if ( style == "cde" )
+ ret = new TQCDEStyle;
+ else
+#endif
+#ifndef TQT_NO_STYLE_MOTIFPLUS
+ if ( style == "motifplus" )
+ ret = new TQMotifPlusStyle;
+ else
+#endif
+#ifndef TQT_NO_STYLE_PLATINUM
+ if ( style == "platinum" )
+ ret = new TQPlatinumStyle;
+ else
+#endif
+#ifndef TQT_NO_STYLE_SGI
+ if ( style == "sgi")
+ ret = new TQSGIStyle;
+ else
+#endif
+#ifndef TQT_NO_STYLE_COMPACT
+ if ( style == "compact" )
+ ret = new TQCompactStyle;
+ else
+#endif
+#ifndef TQT_NO_STYLE_AQUA
+ if ( style == "aqua" )
+ ret = new TQAquaStyle;
+#endif
+#ifndef TQT_NO_STYLE_POCKETPC
+ if ( style == "pocketpc" )
+ ret = new TQPocketPCStyle;
+#endif
+#if !defined( TQT_NO_STYLE_MAC ) && defined( TQ_WS_MAC )
+ if( style.left(9) == "macintosh" )
+ ret = new TQMacStyle;
+#endif
+ { } // Keep these here - they make the #ifdefery above work
+
+#ifndef TQT_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)
+ TQT_TQOBJECT(ret)->setName(key);
+#endif
+ return ret;
+}
+
+#ifndef TQT_NO_STRINGLIST
+/*!
+ Returns the list of keys this factory can create styles for.
+
+ \sa create()
+*/
+TQStringList TQStyleFactory::keys()
+{
+ TQStringList list;
+#ifndef TQT_NO_COMPONENT
+ if ( !instance )
+ instance = new TQStyleFactoryPrivate;
+
+ list = TQStyleFactoryPrivate::manager->featureList();
+#endif //TQT_NO_COMPONENT
+
+#ifndef TQT_NO_STYLE_WINDOWS
+ if ( !list.tqcontains( "Windows" ) )
+ list << "Windows";
+#endif
+#ifndef TQT_NO_STYLE_WINDOWSXP
+ if ( !list.tqcontains( "WindowsXP" ) && TQWindowsXPStyle::resolveSymbols() )
+ list << "WindowsXP";
+#endif
+#ifndef TQT_NO_STYLE_MOTIF
+ if ( !list.tqcontains( "Motif" ) )
+ list << "Motif";
+#endif
+#ifndef TQT_NO_STYLE_CDE
+ if ( !list.tqcontains( "CDE" ) )
+ list << "CDE";
+#endif
+#ifndef TQT_NO_STYLE_MOTIFPLUS
+ if ( !list.tqcontains( "MotifPlus" ) )
+ list << "MotifPlus";
+#endif
+#ifndef TQT_NO_STYLE_PLATINUM
+ if ( !list.tqcontains( "Platinum" ) )
+ list << "Platinum";
+#endif
+#ifndef TQT_NO_STYLE_SGI
+ if ( !list.tqcontains( "SGI" ) )
+ list << "SGI";
+#endif
+#ifndef TQT_NO_STYLE_COMPACT
+ if ( !list.tqcontains( "Compact" ) )
+ list << "Compact";
+#endif
+#ifndef TQT_NO_STYLE_ATQUA
+ if ( !list.tqcontains( "Aqua" ) )
+ list << "Aqua";
+#endif
+#if !defined( TQT_NO_STYLE_MAC ) && defined( TQ_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.tqcontains(mstyle))
+ list << mstyle;
+ DisposeCollection(c);
+#endif
+
+ return list;
+}
+#endif
+#endif // TQT_NO_STYLE
diff --git a/tqtinterface/qt4/src/styles/tqstylefactory.h b/tqtinterface/qt4/src/styles/tqstylefactory.h
new file mode 100644
index 0000000..0b9a37d
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqstylefactory.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 requirements 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 TQT_H
+#include "tqstringlist.h"
+#endif // TQT_H
+
+#ifndef TQT_NO_STYLE
+
+class TQString;
+class TQStyle;
+
+class TQ_EXPORT TQStyleFactory
+{
+public:
+#ifndef TQT_NO_STRINGLIST
+ static TQStringList keys();
+#endif
+ static TQStyle *create( const TQString& );
+};
+
+#endif //TQT_NO_STYLE
+
+#endif //TQSTYLEFACTORY_H
diff --git a/tqtinterface/qt4/src/styles/tqstyleinterface_p.h b/tqtinterface/qt4/src/styles/tqstyleinterface_p.h
new file mode 100644
index 0000000..6b401c2
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqstyleinterface_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 requirements 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 TQT_H
+#include <private/tqcom_p.h>
+#endif // TQT_H
+
+#ifndef TQT_NO_STYLE
+#ifndef TQT_NO_COMPONENT
+
+class TQStyle;
+
+// {FC1B6EBE-053C-49c1-A483-C377739AB9A5}
+#ifndef IID_TQStyleFactory
+#define IID_TQStyleFactory TQUuid(0xfc1b6ebe, 0x53c, 0x49c1, 0xa4, 0x83, 0xc3, 0x77, 0x73, 0x9a, 0xb9, 0xa5)
+#endif
+
+struct TQ_EXPORT TQStyleFactoryInterface : public TQFeatureListInterface
+{
+ virtual TQStyle* create( const TQString& style ) = 0;
+};
+
+#endif //TQT_NO_COMPONENT
+#endif //TQT_NO_STYLE
+
+#endif //TQSTYLEINTERFACE_P_H
diff --git a/tqtinterface/qt4/src/styles/tqstyleplugin.cpp b/tqtinterface/qt4/src/styles/tqstyleplugin.cpp
new file mode 100644
index 0000000..970d4bb
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqstyleplugin.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 requirements 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 "tqstyleplugin.h"
+
+#ifndef TQT_NO_STYLE
+#ifndef TQT_NO_COMPONENT
+
+#include "tqstyleinterface_p.h"
+#include "tqobjectcleanuphandler.h"
+#include "tqstyle.h"
+
+/*!
+ \class TQStylePlugin tqstyleplugin.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 TQ_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 required style.
+
+ \sa keys()
+*/
+
+class TQStylePluginPrivate : public TQStyleFactoryInterface, public TQLibraryInterface
+{
+public:
+ TQStylePluginPrivate( TQStylePlugin *p )
+ : plugin( p )
+ {
+ }
+
+ virtual ~TQStylePluginPrivate();
+
+ TQRESULT queryInterface( const TQUuid &iid, TQUnknownInterface **iface );
+ TQ_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_TQUnknown )
+ *iface = (TQStyleFactoryInterface*)this;
+ else if ( iid == IID_TQFeatureList )
+ *iface = (TQFeatureListInterface*)this;
+ else if ( iid == IID_TQStyleFactory )
+ *iface = (TQStyleFactoryInterface*)this;
+ else if ( iid == IID_TQLibrary )
+ *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( TQT_TQOBJECT(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 TQ_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 // TQT_NO_COMPONENT
+#endif // TQT_NO_STYLE
diff --git a/tqtinterface/qt4/src/styles/tqstyleplugin.h b/tqtinterface/qt4/src/styles/tqstyleplugin.h
new file mode 100644
index 0000000..713eae9
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqstyleplugin.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 requirements 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 TQT_H
+#include "tqgplugin.h"
+#include "tqstringlist.h"
+#endif // TQT_H
+
+#ifndef TQT_NO_STYLE
+#ifndef TQT_NO_COMPONENT
+
+class TQStyle;
+class TQStylePluginPrivate;
+
+class TQ_EXPORT TQStylePlugin : public TQGPlugin
+{
+ TQ_OBJECT
+public:
+ TQStylePlugin();
+ ~TQStylePlugin();
+
+ virtual TQStringList keys() const = 0;
+ virtual TQStyle *create( const TQString &key ) = 0;
+
+private:
+ TQStylePluginPrivate *d;
+};
+
+#endif // TQT_NO_COMPONENT
+#endif // TQT_NO_STYLE
+
+#endif // TQSTYLEPLUGIN_H
diff --git a/tqtinterface/qt4/src/styles/tqwindowsstyle.cpp b/tqtinterface/qt4/src/styles/tqwindowsstyle.cpp
new file mode 100644
index 0000000..aa65a5b
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqwindowsstyle.cpp
@@ -0,0 +1,2166 @@
+/****************************************************************************
+**
+** 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 requirements 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 "tqwindowsstyle.h"
+
+#if !defined(TQT_NO_STYLE_WINDOWS) || defined(TQT_PLUGIN)
+
+#include "tqpopupmenu.h"
+#include "tqapplication.h"
+#include "tqpainter.h"
+#include "tqdrawutil.h" // for now
+#include "tqpixmap.h" // for now
+#include "tqwidget.h"
+#include "tqbrush.h"
+#include "tqlabel.h"
+#include "tqimage.h"
+#include "tqpushbutton.h"
+#include "tqcombobox.h"
+#include "tqlistbox.h"
+#include "tqwidget.h"
+#include "tqrangecontrol.h"
+#include "tqscrollbar.h"
+#include "tqslider.h"
+#include "tqtabwidget.h"
+#include "tqtabbar.h"
+#include "tqlistview.h"
+#include "tqbitmap.h"
+#include "tqcleanuphandler.h"
+#include "tqdockwindow.h"
+#include "tqobjectlist.h"
+#include "tqmenubar.h"
+
+#if defined(TQ_WS_WIN)
+#include "tqt_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 *tqparent);
+
+ 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 *tqparent)
+: TQObject(tqparent, "TQWindowsStylePrivate"), alt_down(FALSE), menuBarTimer(0)
+{
+}
+
+// Returns true if the toplevel tqparent of \a widget has seen the Alt-key
+bool TQWindowsStyle::Private::hasSeenAlt(const TQWidget *widget) const
+{
+ widget = widget->tqtopLevelWidget();
+ return seenAlt.tqcontains(widget);
+}
+
+// Records Alt- and Focus events
+bool TQWindowsStyle::Private::eventFilter(TQObject *o, TQEvent *e)
+{
+ if (!o->isWidgetType())
+ return TQObject::eventFilter(o, e);
+
+ TQWidget *widget = ::tqqt_cast<TQWidget*>(o);
+
+ switch(e->type()) {
+ case TQEvent::KeyPress:
+ if (((TQKeyEvent*)e)->key() == Qt::Key_Alt) {
+ widget = widget->tqtopLevelWidget();
+
+ // Alt has been pressed - tqfind 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->tqstyle().tqstyleHint(SH_UnderlineAccelerator, w))
+ l->removeRef(TQT_TQOBJECT(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->tqrepaint(FALSE);
+ }
+ delete l;
+ }
+ break;
+ case TQEvent::KeyRelease:
+ if (((TQKeyEvent*)e)->key() == Qt::Key_Alt) {
+ widget = widget->tqtopLevelWidget();
+
+ // 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->tqrepaint(FALSE);
+ }
+ }
+ break;
+ case TQEvent::FocusIn:
+ case TQEvent::FocusOut:
+ {
+ // Menubars toggle based on focus
+ TQMenuBar *menuBar = ::tqqt_cast<TQMenuBar*>(o);
+ if (menuBar && !menuBarTimer) // delayed tqrepaint to avoid flicker
+ menuBarTimer = menuBar->startTimer(0);
+ }
+ break;
+ case TQEvent::Close:
+ // Reset widget when closing
+ seenAlt.removeRef(TQT_TQWIDGET(widget));
+ seenAlt.removeRef(TQT_TQWIDGET(widget->tqtopLevelWidget()));
+ break;
+ case TQEvent::Timer:
+ {
+ TQMenuBar *menuBar = ::tqqt_cast<TQMenuBar*>(o);
+ TQTimerEvent *te = (TQTimerEvent*)e;
+ if (menuBar && te->timerId() == menuBarTimer) {
+ menuBar->killTimer(te->timerId());
+ menuBarTimer = 0;
+ menuBar->tqrepaint(FALSE);
+ return TRUE;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return TQObject::eventFilter(o, e);
+}
+
+/*!
+ \class TQWindowsStyle tqwindowsstyle.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(TQ_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 (!tqstyleHint(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::tqdrawPrimitiveBase( TQ_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(), Qt::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(), Qt::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(TQ_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(), Qt::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);
+#ifndef USE_QT4 // [FIXME]
+ else
+ p->drawWinFocusRect(r, opt.color());
+#endif // USE_QT4
+ break;
+
+ case PE_Indicator:
+ {
+ TQBrush fill;
+ if (flags & Style_NoChange) {
+ TQBrush b = p->brush();
+ TQColor c = p->backgroundColor();
+ p->setBackgroundMode( Qt::TransparentMode );
+ p->setBackgroundColor( Qt::green );
+ fill = TQBrush(cg.base(), Qt::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( Qt::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() ? tqpixelMetric(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::tqdrawPrimitive(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;
+ }
+#ifndef USE_QT4 // [FIXME]
+ 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;
+ }
+#endif // USE_QT4
+
+ case PE_ScrollBarSubLine:
+ if (use2000style) {
+ if (flags & Style_Down) {
+ p->setPen( cg.dark() );
+ p->setBrush( cg.brush( TQColorGroup::Button ) );
+ p->drawRect( r );
+ } else
+ tqdrawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
+ } else
+ tqdrawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
+ ((flags & Style_Down) ? Style_Down : Style_Raised));
+
+ tqdrawPrimitive(((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
+ tqdrawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
+ } else
+ tqdrawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
+ ((flags & Style_Down) ? Style_Down : Style_Raised));
+
+ tqdrawPrimitive(((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(Qt::NoPen);
+ p->setBackgroundMode(Qt::OpaqueMode);
+
+ if (flags & Style_Down) {
+ br = TQBrush(cg.shadow(), Qt::Dense4Pattern);
+ p->setBackgroundColor( cg.dark() );
+ p->setBrush( TQBrush(cg.shadow(), Qt::Dense4Pattern) );
+ } else {
+ br = (TQT_TQBRUSH_OBJECT(cg.brush(TQColorGroup::Light)).pixmap() ?
+ cg.brush(TQColorGroup::Light) :
+ TQBrush(cg.light(), Qt::Dense4Pattern));
+ p->setBrush(br);
+ }
+
+ p->drawRect(r);
+ p->setBackgroundColor(c);
+ break;
+ }
+
+ case PE_ScrollBarSlider:
+ if (! (flags & Style_Enabled)) {
+ TQBrush br = (TQT_TQBRUSH_OBJECT(cg.brush(TQColorGroup::Light)).pixmap() ?
+ cg.brush(TQColorGroup::Light) :
+ TQBrush(cg.light(), Qt::Dense4Pattern));
+ p->setPen(Qt::NoPen);
+ p->setBrush(br);
+ p->setBackgroundMode(Qt::OpaqueMode);
+ p->drawRect(r);
+ } else
+ tqdrawPrimitive(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( tqpixelMetric( PM_ButtonShiftHorizontal ),
+ tqpixelMetric( 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::tqdrawPrimitive(pe, p, r, cg, flags, opt);
+ }
+}
+
+
+/*!
+ \reimp
+*/
+void TQWindowsStyle::tqdrawControl( TQ_ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags,
+ const TQStyleOption& opt ) const
+{
+ switch (element) {
+#ifndef TQT_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->tqshape() == 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->tqshape() == TQTabBar::RoundedBelow ) {
+ bool rightAligned = tqstyleHint( SH_TabBar_Alignment, tb ) == TQt::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::tqdrawControl(element, p, widget, r, cg, flags, opt);
+ }
+ break;
+ }
+#endif // TQT_NO_TABBAR
+ case CE_ToolBoxTab:
+ {
+ qDrawShadePanel( p, r, cg, flags & (Style_Sunken | Style_Down | Style_On) , 1,
+ &cg.brush(TQColorGroup::Button));
+ break;
+ }
+
+#ifndef TQT_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 = tqvisualRect( 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(), Qt::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( tqvisualRect( 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;
+
+ tqdrawPrimitive(PE_CheckMark, p,
+ tqvisualRect( 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 = tqvisualRect( 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.tqfind( '\t' );
+ int text_flags = TQt::AlignVCenter|TQt::ShowPrefix | TQt::DontClip | TQt::SingleLine;
+ if (!tqstyleHint(SH_UnderlineAccelerator, widget))
+ text_flags |= TQt::NoAccel;
+ text_flags |= (TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft );
+ if ( t >= 0 ) { // draw tab text
+ int xp = x + w - tab - windowsItemHMargin - windowsItemFrame + 1;
+ if ( use2000style )
+ xp -= 20;
+ else
+ xp -= windowsRightBorder;
+ int xoff = tqvisualRect( 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( Qt::OpaqueMode );
+ p->drawPixmap( xvis, y+windowsItemFrame, *pixmap );
+ if ( pixmap->depth() == 1 )
+ p->setBackgroundMode( Qt::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 = tqvisualRect( TQRect(xpos, y + h / 2 - dim / 2, dim, dim), r );
+ if ( act ) {
+ TQColorGroup g2 = cg;
+ g2.setColor( TQColorGroup::ButtonText, g2.highlightedText() );
+ tqdrawPrimitive(arrow, p, vrect,
+ g2, dis ? Style_Default : Style_Enabled);
+ } else {
+ tqdrawPrimitive(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( tqpixelMetric(PM_ButtonShiftHorizontal, widget),
+ tqpixelMetric(PM_ButtonShiftVertical, widget) );
+ p->setBrushOrigin(p->brushOrigin() - TQPoint(1,1));
+ }
+ }
+ TQCommonStyle::tqdrawControl(element, p, widget, pr, cg, flags, opt);
+ break;
+ }
+
+ default:
+ TQCommonStyle::tqdrawControl(element, p, widget, r, cg, flags, opt);
+ }
+}
+
+
+/*!
+ \reimp
+*/
+int TQWindowsStyle::tqpixelMetric(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 TQT_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() == Qt::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 += tqpixelMetric( 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 // TQT_NO_SLIDER
+
+ case PM_MenuBarFrameWidth:
+ ret = 0;
+ break;
+
+#if defined(TQ_WS_WIN)
+ case PM_TitleBarHeight:
+ if ( widget && ( widget->testWFlags( WStyle_Tool ) || ::tqqt_cast<TQDockWindow*>(widget) ) ) {
+ // MS always use one less than they say
+#if defined(TQ_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 TQ_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::tqpixelMetric( metric, widget );
+ }
+ break;
+#endif
+
+ case PM_SplitterWidth:
+ ret = TQMAX( 6, TQApplication::globalStrut().width() );
+ break;
+
+#if defined(TQ_WS_WIN)
+ case PM_MDIFrameWidth:
+ ret = GetSystemMetrics(SM_CYFRAME);
+ break;
+#endif
+
+ default:
+ ret = TQCommonStyle::tqpixelMetric(metric, widget);
+ break;
+ }
+
+ return ret;
+}
+
+
+/*!
+ \reimp
+*/
+TQSize TQWindowsStyle::tqsizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& opt ) const
+{
+ TQSize sz(contentsSize);
+
+ switch (contents) {
+ case CT_PushButton:
+ {
+#ifndef TQT_NO_PUSHBUTTON
+ const TQPushButton *button = (const TQPushButton *) widget;
+ sz = TQCommonStyle::tqsizeFromContents(contents, widget, contentsSize, opt);
+ int w = sz.width(), h = sz.height();
+
+ int defwidth = 0;
+ if (button->isDefault() || button->autoDefault())
+ defwidth = 2*tqpixelMetric( 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 TQT_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()->tqsizeHint().width();
+ h = mi->custom()->tqsizeHint().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().tqfind('\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::tqsizeFromContents(contents, widget, sz, opt);
+ break;
+ }
+
+ return sz;
+}
+
+/*! \reimp
+*/
+void TQWindowsStyle::polishPopupMenu( TQPopupMenu* p)
+{
+#ifndef TQT_NO_POPUPMENU
+ if ( !p->testWState( TQt::WState_Polished ) )
+ p->setCheckable( TRUE );
+#endif
+}
+
+#ifndef TQT_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 //TQT_NO_IMAGEIO_XPM
+
+/*!
+ \reimp
+ */
+TQPixmap TQWindowsStyle::stylePixmap(StylePixmap stylepixmap,
+ const TQWidget *widget,
+ const TQStyleOption& opt) const
+{
+#ifndef TQT_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 //TQT_NO_IMAGEIO_XPM
+ return TQCommonStyle::stylePixmap(stylepixmap, widget, opt);
+}
+
+/*!\reimp
+*/
+void TQWindowsStyle::tqdrawComplexControl( TQ_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 TQT_NO_LISTVIEW
+ case CC_ListView:
+ {
+ if ( sub & SC_ListView ) {
+ TQCommonStyle::tqdrawComplexControl( 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( Qt::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( Qt::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 //TQT_NO_LISTVIEW
+
+#ifndef TQT_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::tqvisualRect( 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;
+ }
+ tqdrawPrimitive( PE_ArrowDown, p, ar, cg, flags );
+ }
+
+ if ( sub & SC_ComboBoxEditField ) {
+ const TQComboBox * cb = (const TQComboBox *) widget;
+ TQRect re =
+ TQStyle::tqvisualRect( 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::tqvisualRect( subRect( SR_ComboBoxFocusRect, cb ), widget );
+ tqdrawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, TQStyleOption(cg.highlight()));
+ }
+ }
+
+ break;
+#endif // TQT_NO_COMBOBOX
+
+#ifndef TQT_NO_SLIDER
+ case CC_Slider:
+ {
+ const TQSlider *sl = (const TQSlider *) widget;
+ int thickness = tqpixelMetric( PM_SliderControlThickness, widget );
+ int len = tqpixelMetric( 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() == Qt::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::tqdrawComplexControl(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;
+
+ Qt::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 );
+ tqdrawPrimitive( 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 == Qt::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( Qt::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 // TQT_NO_SLIDER
+
+ default:
+ TQCommonStyle::tqdrawComplexControl( ctrl, p, widget, r, cg, flags, sub,
+ subActive, opt );
+ break;
+ }
+}
+
+
+/*! \reimp */
+int TQWindowsStyle::tqstyleHint( TQ_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(TQ_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(TQ_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 = ::tqqt_cast<TQMenuBar*>(widget);
+ TQPopupMenu *popupMenu = 0;
+ if (!menuBar)
+ popupMenu = ::tqqt_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 (tqApp->tqfocusWidget() && tqApp->tqfocusWidget()->isPopup()) {
+ popupMenu = ::tqqt_cast<TQPopupMenu*>(tqApp->tqfocusWidget());
+ TQMenuData *pm = popupMenu ? (TQMenuData*)popupMenu->tqqt_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->tqqt_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::tqstyleHint(hint, widget, opt, returnData);
+ break;
+ }
+
+ return ret;
+}
+
+/*! \reimp */
+TQRect TQWindowsStyle::subRect(SubRect r, const TQWidget *widget) const
+{
+ TQRect rect;
+
+ switch (r) {
+#ifndef TQT_NO_SLIDER
+ case SR_SliderFocusRect:
+ {
+ rect = widget->rect();
+ break;
+ }
+#endif // TQT_NO_SLIDER
+ case SR_ToolBoxTabContents:
+ rect = widget->rect();
+ break;
+ default:
+ rect = TQCommonStyle::subRect( r, widget );
+ break;
+ }
+
+ return rect;
+}
+
+#endif
diff --git a/tqtinterface/qt4/src/styles/tqwindowsstyle.h b/tqtinterface/qt4/src/styles/tqwindowsstyle.h
new file mode 100644
index 0000000..a5a6fe9
--- /dev/null
+++ b/tqtinterface/qt4/src/styles/tqwindowsstyle.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Definition of Windows-like style class
+**
+** Created : 981231
+**
+** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
+**
+** 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 requirements 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 TQT_H
+#include "tqcommonstyle.h"
+#endif // TQT_H
+
+#if !defined(TQT_NO_STYLE_WINDOWS) || defined(TQT_PLUGIN)
+
+#if defined(TQT_PLUGIN)
+#define TQ_EXPORT_STYLE_WINDOWS
+#else
+#define TQ_EXPORT_STYLE_WINDOWS TQ_EXPORT
+#endif
+
+
+class TQ_EXPORT_STYLE_WINDOWS TQWindowsStyle : public TQCommonStyle
+{
+ TQ_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 tqdrawPrimitiveBase( TQ_PrimitiveElement pe,
+ TQPainter *p,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawControl( TQ_ControlElement element,
+ TQPainter *p,
+ const TQWidget *widget,
+ const TQRect &r,
+ const TQColorGroup &cg,
+ SFlags flags = Style_Default,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ void tqdrawComplexControl( TQ_ComplexControl control,
+ TQPainter* p,
+ const TQWidget* widget,
+ const TQRect& r,
+ const TQColorGroup& cg,
+ SFlags flags = Style_Default,
+#ifdef TQ_TQDOC
+ SCFlags sub = SC_All,
+#else
+ SCFlags sub = (uint)SC_All,
+#endif
+ SCFlags subActive = SC_None,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int tqpixelMetric( PixelMetric metric,
+ const TQWidget *widget = 0 ) const;
+
+ TQSize tqsizeFromContents( ContentsType contents,
+ const TQWidget *widget,
+ const TQSize &contentsSize,
+ const TQStyleOption& = TQStyleOption::Default ) const;
+
+ int tqstyleHint(TQ_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(TQ_DISABLE_COPY)
+ TQWindowsStyle( const TQWindowsStyle & );
+ TQWindowsStyle& operator=( const TQWindowsStyle & );
+#endif
+};
+
+#endif // TQT_NO_STYLE_WINDOWS
+
+#endif // TQWINDOWSSTYLE_H