summaryrefslogtreecommitdiffstats
path: root/styles
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit8b2aa1b5301ab60368a03e36df4ff5216726e87d (patch)
tree36163d4ee667c23b5cf232df2f3004cd0a76202a /styles
downloadtdeartwork-8b2aa1b5301ab60368a03e36df4ff5216726e87d.tar.gz
tdeartwork-8b2aa1b5301ab60368a03e36df4ff5216726e87d.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeartwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'styles')
-rw-r--r--styles/Makefile.am1
-rw-r--r--styles/dotnet/Makefile.am32
-rw-r--r--styles/dotnet/README9
-rw-r--r--styles/dotnet/dotnet.cpp2076
-rw-r--r--styles/dotnet/dotnet.h145
-rw-r--r--styles/dotnet/dotnet.themerc118
-rw-r--r--styles/phase/Makefile.am22
-rw-r--r--styles/phase/bitmaps.h67
-rw-r--r--styles/phase/config/Makefile.am12
-rw-r--r--styles/phase/config/phasestyleconfig.cpp111
-rw-r--r--styles/phase/config/phasestyleconfig.h56
-rw-r--r--styles/phase/config/styledialog.ui70
-rw-r--r--styles/phase/phase.themerc86
-rw-r--r--styles/phase/phasestyle.cpp2512
-rw-r--r--styles/phase/phasestyle.h182
15 files changed, 5499 insertions, 0 deletions
diff --git a/styles/Makefile.am b/styles/Makefile.am
new file mode 100644
index 00000000..8518ce8b
--- /dev/null
+++ b/styles/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = dotnet phase
diff --git a/styles/dotnet/Makefile.am b/styles/dotnet/Makefile.am
new file mode 100644
index 00000000..4c80bfaf
--- /dev/null
+++ b/styles/dotnet/Makefile.am
@@ -0,0 +1,32 @@
+
+# This file is part of the KDE libraries
+# Copyright (C) 1997 Matthias Kalle Dalheimer ([email protected])
+# (C) 1997 Stephan Kulow ([email protected])
+
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this library; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+AM_CPPFLAGS = -DQT_PLUGIN
+METASOURCES = AUTO
+
+INCLUDES = $(all_includes)
+noinst_HEADERS = dotnet.h
+kde_style_LTLIBRARIES = dotnet.la
+dotnet_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
+dotnet_la_LIBADD = -lkdefx
+dotnet_la_SOURCES = dotnet.cpp
+
+themercdir = $(kde_datadir)/kstyle/themes
+themerc_DATA = dotnet.themerc
diff --git a/styles/dotnet/README b/styles/dotnet/README
new file mode 100644
index 00000000..18007ab6
--- /dev/null
+++ b/styles/dotnet/README
@@ -0,0 +1,9 @@
+To make this your default style without having to recompile kdelibs:
+
+Create a $KDEHOME/share/config/kstylerc with the following lines.
+[KDE]
+WidgetStyle=dotNET
+
+That's it. Easy, eh?
+
+-clee
diff --git a/styles/dotnet/dotnet.cpp b/styles/dotnet/dotnet.cpp
new file mode 100644
index 00000000..6eeb7c41
--- /dev/null
+++ b/styles/dotnet/dotnet.cpp
@@ -0,0 +1,2076 @@
+/*
+ * KDE3 dotNET Style (version 1.5)
+ * Copyright (C) 2001-2002, Chris Lee <[email protected]>
+ * Carsten Pfeiffer <[email protected]>
+ * Karol Szwed <[email protected]>
+ *
+ * Drawing routines completely reimplemented from KDE3 HighColor, which was
+ * originally based on some stuff from the KDE2 HighColor.
+ * Includes portions of framework code from KDE3 HighColor,
+ * (C) 2001-2002 Karol Szwed <[email protected]>,
+ * (C) 2001-2002 Fredrik H�lund <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#include <qstyleplugin.h>
+#include <qstylefactory.h>
+#include <qpointarray.h>
+#include <qpainter.h>
+#include <qtabbar.h>
+#include <qtabwidget.h>
+#include <qprogressbar.h>
+#include <qcombobox.h>
+#include <qlistbox.h>
+#include <qscrollbar.h>
+#include <qpushbutton.h>
+#include <qtoolbutton.h>
+#include <qtoolbar.h>
+#include <qmenubar.h>
+#include <qpopupmenu.h>
+#include <qdrawutil.h>
+#include <qapplication.h>
+#include <qvariant.h>
+#include <qpixmapcache.h>
+#include <qslider.h>
+#include <qsettings.h>
+#include <kpixmap.h>
+
+#include "dotnet.h"
+#include "dotnet.moc"
+
+/* This code registers the style with QStyleFactory, which makes it possible
+ * for any code that uses QStyle to find out about it. */
+// -- Style Plugin Interface -------------------------
+class dotNETstylePlugin : public QStylePlugin
+{
+ public:
+ dotNETstylePlugin() {}
+ ~dotNETstylePlugin() {}
+
+ QStringList keys() const {
+ return QStringList() << "dotNET";
+ }
+
+ QStyle* create( const QString& key ) {
+ if (key == "dotnet")
+ return new dotNETstyle;
+ return 0;
+ }
+};
+
+KDE_Q_EXPORT_PLUGIN( dotNETstylePlugin )
+
+// ---------------------------------------------------
+
+dotNETstyle::dotNETstyle() : KStyle( AllowMenuTransparency ), kickerMode(false)
+{
+ winstyle = 0L;
+ winstyle = QStyleFactory::create("Windows");
+ if (winstyle == 0L) {
+ // We don't have the Windows style, neither builtin nor as a plugin.
+ // Use any style rather than crashing.
+ winstyle = QStyleFactory::create("B3");
+ }
+
+ if (qApp->inherits("KApplication")) {
+ connect( qApp, SIGNAL( kdisplayPaletteChanged() ), SLOT( paletteChanged() ));
+ }
+
+ QSettings settings;
+ pseudo3D = settings.readBoolEntry("/KStyle/Settings/Pseudo3D", true);
+ roundedCorners = settings.readBoolEntry("/KStyle/Settings/RoundedCorners", true);
+ useTextShadows = settings.readBoolEntry("/KStyle/Settings/UseTextShadows", false);
+ reverseLayout = QApplication::QApplication::reverseLayout();
+}
+
+
+dotNETstyle::~dotNETstyle()
+{
+}
+
+bool dotNETstyle::inheritsKHTML(const QWidget* w) const
+{
+ if (w->parentWidget(true) && w->parentWidget(true)->parentWidget(true) && w->parentWidget(true)->parentWidget(true)->parentWidget(true) && w->parentWidget(true)->parentWidget(true)->parentWidget(true)->inherits("KHTMLView")) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void dotNETstyle::polish(QWidget* widget)
+{
+ if (!qstrcmp(qApp->argv()[0], "kicker") || widget->inherits("Kicker"))
+ kickerMode = true;
+
+ if (widget->isTopLevel())
+ return;
+
+// we can't simply set a palette -- upon color-theme changes, we have
+// to update the palette again.
+ bool extraPalette = false;
+
+ if (widget->inherits("QComboBox") && !inheritsKHTML(widget)) {
+ widget->installEventFilter (this);
+ updatePalette( (QComboBox*) widget );
+ extraPalette = true;
+ } else {
+ winstyle->polish(widget);
+ }
+
+// This code is disabled until Carsten explains to me why it's supposed to
+// be here. It breaks dynamically changing the color from KControl and does
+// other bad things (see bug #54569)
+/*
+ if (!widget->ownPalette()) {
+ if (widget->inherits("QToolBar")) {
+ updatePalette( (QToolBar*) widget );
+ extraPalette = true;
+ } else if (widget->inherits("QMenuBar")) {
+ updatePalette( (QMenuBar*) widget );
+ extraPalette = true;
+ }
+ }
+*/
+}
+
+void dotNETstyle::unPolish(QWidget* widget)
+{
+ winstyle->unPolish(widget);
+
+ if (widget->inherits("QComboBox") && !inheritsKHTML(widget)) {
+ widget->removeEventFilter (this);
+ }
+}
+
+void dotNETstyle::renderMenuBlendPixmap(KPixmap &pix,
+ const QColorGroup &cg,
+ const QPopupMenu *popup) const
+{
+ QPainter p( &pix );
+ if (QApplication::reverseLayout()) {
+ p.fillRect( popup->frameRect().width()-22, 0, 22, pix.height(), cg.mid() );
+ p.fillRect( 0, 0, popup->frameRect().width()-22, pix.height(), cg.background().light() );
+ } else {
+ p.fillRect( 0, 0, pix.width(), pix.height(), cg.background().light() );
+ p.fillRect( popup->frameRect().left() + 1, 0, 22, pix.height(), cg.mid() );
+ }
+}
+
+/* This is the code that renders 90+% of the buttons in dotNET.
+ * Changing the code here will most likely affect EVERYTHING.
+ * If you want to modify the style, this is a good place to start.
+ * Also, take a look at the sizeMetric function and play with the
+ * widths that things return for different Frame elements.
+ */
+void dotNETstyle::renderButton(QPainter *p,
+ const QRect &r,
+ const QColorGroup &g,
+ bool sunken,
+ bool corners) const
+{
+ if (sunken) {
+ p->setPen(g.highlight().dark());
+ p->setBrush(g.highlight());
+ p->drawRect(r);
+ } else {
+ int x, y, w, h;
+ r.rect(&x, &y, &w, &h);
+
+ if (pseudo3D) {
+ if (roundedCorners) {
+ const QCOORD iCorners[] = { x, y + h - 2, x, y + 1, x + 1, y, x + w - 2, y, x + w - 1, y + 1, x + w - 1, y + h - 2, x + w - 2, y + h - 1, x + 1, y + h - 1 };
+ p->fillRect(x+1, y+1, w-2, h-2, g.button());
+ p->setPen(g.button().dark());
+ p->drawLineSegments(QPointArray(8, iCorners));
+ if (corners) {
+ const QCOORD cPixels[] = { x, y, x + w - 1, y, x + w - 1, y + h - 1, x, y + h - 1 };
+ p->setPen(g.button());
+ p->drawPoints(QPointArray(4, cPixels));
+ }
+ } else {
+ p->setPen(g.button().dark());
+ p->setBrush(g.button());
+ p->drawRect(r);
+ }
+
+ const QCOORD oCorners[] = { x + 1, y + h - 2, x + 1, y + 1, x + w - 2, y + 1, x + w - 2, y + h - 2 };
+ const QPointArray outline(4, oCorners);
+ p->setPen(g.button().dark(115));
+ p->setBrush(QBrush::NoBrush);
+ p->drawConvexPolygon(outline);
+ p->setPen(g.button().light());
+ p->drawPolyline(outline, 0, 3);
+ } else {
+ p->setPen(g.button().dark());
+ p->setBrush(g.button());
+ p->drawRect(r);
+ p->setPen(g.button().light());
+ p->drawLine(x, y + h - 1, x, y);
+ p->drawLine(x, y, x + w - 1, y);
+ }
+ }
+}
+
+/* This is the code that renders the slider handles on scrollbars. It draws
+ * them just like normal buttons, by calling renderButton, but it also adds
+ * very subtle grips to the slider handle.
+ */
+void dotNETstyle::renderSlider(QPainter *p,
+ const QRect &r,
+ const QColorGroup &g) const
+{
+ int x, y, w, h;
+ int offset = 6;
+ int llx, lly, urx, ury;
+
+ r.rect(&x,&y,&w,&h);
+
+ llx = (x + (w/2) - 4);
+ lly = (y + (h/2) + 3);
+ urx = (x + (w/2) + 2);
+ ury = (y + (h/2) - 3);
+
+ renderButton(p, r, g, false, true);
+
+ p->save();
+
+ if (h > 15 && w > 15) {
+ p->setPen(g.background().dark(120));
+ p->drawLine(llx, lly, urx, ury);
+ if (h > 35) {
+ p->translate(0, offset);
+ p->drawLine(llx, lly, urx, ury);
+ p->translate(0, -(offset * 2));
+ p->drawLine(llx, lly, urx, ury);
+ p->translate(0, offset);
+ }
+
+ if (w > 35) {
+ p->translate(offset, 0);
+ p->drawLine(llx, lly, urx, ury);
+ p->translate(-(offset * 2), 0);
+ p->drawLine(llx, lly, urx, ury);
+ p->translate(offset, 0);
+ }
+
+ p->setPen(g.background().light());
+ p->translate(0, 1);
+ p->drawLine(llx, lly, urx, ury);
+ if (h > 35) {
+ p->translate(0, offset);
+ p->drawLine(llx, lly, urx, ury);
+ p->translate(0, -(offset * 2));
+ p->drawLine(llx, lly, urx, ury);
+ p->translate(0, offset);
+ }
+
+ if (w > 35) {
+ p->translate(offset, 0);
+ p->drawLine(llx, lly, urx, ury);
+ p->translate(-(offset * 2), 0);
+ p->drawLine(llx, lly, urx, ury);
+ p->translate(offset, 0);
+ }
+ }
+
+ p->restore();
+}
+
+/* This function does the rendering for most of the panels in dotNET.
+ * The QCOORD stuff is used to provide the slightly-rounded corners.
+ * Changing this function will have pretty widespread effects. Also a good
+ * place to start if you're looking to make your own style.
+ */
+void dotNETstyle::renderPanel(QPainter *p,
+ const QRect &r,
+ const QColorGroup &g,
+ bool sunken,
+ bool thick) const
+{
+ int x, x2, y, y2, w, h;
+ r.rect(&x,&y,&w,&h);
+ r.coords(&x, &y, &x2, &y2);
+
+ p->save();
+
+ if (pseudo3D) {
+ const QCOORD oCorners[] = { x, y2, x, y, x2, y, x2, y2 };
+ const QCOORD iCorners[] = { x+1, y2-1, x+1, y+1, x2-1, y+1, x2-1, y2-1 };
+ p->setPen(g.background().dark());
+ p->drawConvexPolygon(QPointArray(4, oCorners));
+
+ if (thick) {
+ p->setPen(g.background().dark(115));
+ p->drawConvexPolygon(QPointArray(4, iCorners));
+ p->setPen(g.background().light());
+
+ if (sunken) {
+ p->drawLine(w-2, h-2, x+1, h-2);
+ p->drawLine(w-2, h-2, w-2, y+1);
+ } else {
+ p->drawLine(x+1, y+1, x+1, h-2);
+ p->drawLine(x+1, y+1, w-2, y+1);
+ }
+ }
+
+ if (roundedCorners) {
+ p->setPen(g.background());
+ p->drawPoints(QPointArray(4, oCorners));
+ }
+ } else {
+ if (sunken) {
+ const QCOORD corners[] = { x2, y, x2, y2, x, y2, x, y };
+ p->setPen(g.background().dark());
+ p->drawConvexPolygon(QPointArray(4, corners));
+ p->setPen(g.background().light());
+ p->drawPolyline(QPointArray(4, corners), 0, 3);
+ } else {
+ const QCOORD corners[] = { x, y2, x, y, x2, y, x2, y2 };
+ p->setPen(g.background().dark());
+ p->drawPolygon(QPointArray(4, corners));
+ p->setPen(g.background().light());
+ p->drawPolyline(QPointArray(4, corners), 0, 3);
+ }
+ }
+
+ if (kickerMode) {
+ // Stolen wholesale from Keramik. I don't like it, but oh well.
+ if (!thick) {
+ if (sunken) {
+ const QCOORD corners[] = { x2, y, x2, y2, x, y2, x, y };
+ p->setPen(g.background().dark());
+ p->drawConvexPolygon(QPointArray(4, corners));
+ p->setPen(g.background().light());
+ p->drawPolyline(QPointArray(4, corners), 0, 3);
+ } else {
+ const QCOORD corners[] = { x, y2, x, y, x2, y, x2, y2 };
+ p->setPen(g.background().dark());
+ p->drawPolygon(QPointArray(4, corners));
+ p->setPen(g.background().light());
+ p->drawPolyline(QPointArray(4, corners), 0, 3);
+ }
+ }
+ }
+
+ p->restore();
+}
+
+
+void dotNETstyle::drawKStylePrimitive(KStylePrimitive kpe,
+ QPainter *p,
+ const QWidget* widget,
+ const QRect &r,
+ const QColorGroup &cg,
+ SFlags flags,
+ const QStyleOption& opt) const
+{
+// SLIDER
+// ------
+ switch( kpe ) {
+ case KPE_SliderGroove: {
+ const QSlider* slider = (const QSlider*)widget;
+ int x, y, w, h;
+ r.rect(&x, &y, &w, &h);
+ bool horizontal = slider->orientation() == Horizontal;
+ int gcenter = (horizontal ? h : w) / 2;
+
+ if (horizontal) {
+ gcenter += y;
+ p->setPen (cg.background().dark());
+ p->drawLine(x, gcenter, x+w, gcenter);
+ gcenter++;
+ p->setPen (cg.background().light());
+ p->drawLine(x, gcenter, x + w, gcenter);
+ } else {
+ gcenter += x;
+ p->setPen (cg.background().dark());
+ p->drawLine(gcenter, y, gcenter, y + h);
+ gcenter++;
+ p->setPen (cg.background().light());
+ p->drawLine(gcenter, y, gcenter, y + h);
+ }
+ break;
+ }
+
+ case KPE_SliderHandle: {
+ renderButton(p, r, cg);
+ break;
+ }
+
+ default:
+ KStyle::drawKStylePrimitive(kpe, p, widget, r, cg, flags, opt);
+ }
+}
+
+
+// This function draws primitive elements as well as their masks.
+void dotNETstyle::drawPrimitive(PrimitiveElement pe,
+ QPainter *p,
+ const QRect &r,
+ const QColorGroup &cg,
+ SFlags flags,
+ const QStyleOption &opt ) const
+{
+ bool down = flags & Style_Down;
+ bool on = flags & Style_On;
+ bool sunken = flags & Style_Sunken;
+ bool horiz = flags & Style_Horizontal;
+
+ int x, x2, y, y2, w, h;
+ r.rect(&x, &y, &w, &h);
+ r.coords(&x, &y, &x2, &y2);
+
+ switch(pe) {
+ // BUTTONS
+ // -------
+ case PE_ButtonBevel:
+ case PE_ButtonTool:
+ case PE_ButtonDropDown:
+ case PE_HeaderSection:
+ case PE_ButtonCommand: {
+
+ if (on || down) {
+ renderButton(p, r, cg, true);
+ p->setPen( cg.highlightedText() );
+ } else {
+ renderButton(p, r, cg, false, true);
+ }
+
+ break;
+ }
+
+ case PE_ButtonDefault: {
+ QRect sr = r;
+ p->setPen(QPen::NoPen);
+ p->setBrush(cg.background().dark(105));
+ p->drawRoundRect(sr, 25, 25);
+ p->setBrush(cg.background().dark(110));
+ sr.setCoords(sr.x() + 1, sr.y() + 1, sr.width() - 2, sr.height() - 2);
+ p->drawRoundRect(sr, 25, 25);
+ p->setBrush(cg.background().dark(115));
+ sr.setCoords(sr.x() + 1, sr.y() + 1, sr.width() - 2, sr.height() - 2);
+ p->drawRoundRect(sr, 25, 25);
+ break;
+ }
+
+ case PE_ScrollBarSlider: {
+ renderSlider(p, r, cg);
+ break;
+ }
+
+ case PE_ScrollBarAddPage:
+ case PE_ScrollBarSubPage: {
+ // draw double buffered to avoid flicker...
+ QPixmap buffer(2,2);
+ QRect br(buffer.rect() );
+ QPainter bp(&buffer);
+
+ if (on || down) {
+ bp.fillRect(br, QBrush(cg.mid().dark()));
+ } else {
+ bp.fillRect(br, QBrush(cg.background()));
+ }
+ bp.fillRect(br, QBrush(cg.background().light(), Dense4Pattern));
+
+ bp.end();
+ p->drawTiledPixmap(r, buffer);
+
+ break;
+ }
+
+ // SCROLLBAR BUTTONS
+ // -----------------
+ case PE_ScrollBarSubLine: {
+ drawPrimitive(PE_ButtonBevel, p, r, cg, flags);
+ p->setPen(down ? cg.highlightedText() : cg.foreground());
+ drawPrimitive((horiz ? PE_ArrowLeft : PE_ArrowUp), p, r, cg, flags);
+ break;
+ }
+
+ case PE_ScrollBarAddLine: {
+ drawPrimitive(PE_ButtonBevel, p, r, cg, flags);
+ p->setPen(down ? cg.highlightedText() : cg.foreground());
+ drawPrimitive((horiz ? PE_ArrowRight : PE_ArrowDown), p, r, cg, flags);
+ break;
+ }
+
+ // CHECKBOXES
+ // ----------
+ case PE_Indicator: {
+ p->setPen(cg.background().dark());
+ p->setBrush(flags & Style_Enabled ? cg.light() : cg.background());
+ p->drawRect(r);
+ p->setPen(cg.background().dark(115));
+ p->drawLine(x + 1, y + 1, w - 2, y + 1);
+ p->drawLine(x + 1, y + 1, x + 1, h - 2);
+
+ if (pseudo3D && roundedCorners) {
+ const QCOORD corners[] = { x, y, x, y2, x2, y, x2, y2 };
+ p->setPen(cg.background());
+ p->drawPoints(QPointArray(4, corners));
+ }
+
+ break;
+ }
+
+ case PE_IndicatorMask: {
+ p->fillRect (r, color1);
+
+ if (roundedCorners) {
+ p->setPen (color0);
+ p->drawPoint(r.topLeft());
+ p->drawPoint(r.topRight());
+ p->drawPoint(r.bottomLeft());
+ p->drawPoint(r.bottomRight());
+ }
+ break;
+ }
+
+ // RADIOBUTTONS
+ // ------------
+ case PE_ExclusiveIndicator: {
+ const QCOORD outline[] = { 0, 7, 0, 5, 1, 4, 1, 3, 2, 2, 3, 1, 4, 1, 5, 0, 7, 0, 8, 1, 9, 1, 10, 2, 11, 3, 11, 4, 12, 5, 12, 7, 11, 8, 11, 9, 10, 10, 9, 11, 8, 11, 7, 12, 5, 12, 4, 11, 3, 11, 2, 10, 1, 9, 1, 8 };
+ const QCOORD indark[] = { 1, 7, 1, 6, 1, 5, 2, 4, 2, 3, 3, 2, 4, 2, 5, 1, 6, 1, 7, 1 };
+
+ p->fillRect(r, cg.background());
+ p->setPen(cg.background().dark());
+ p->setBrush(flags & Style_Enabled ? cg.light() : cg.background());
+ p->drawPolygon(QPointArray(28, outline));
+ p->setPen(cg.background().dark(115));
+ p->drawPoints(QPointArray(10, indark));
+ break;
+ }
+
+ case PE_ExclusiveIndicatorMask: {
+ const QCOORD outline[] = { 0, 7, 0, 5, 1, 4, 1, 3, 2, 2, 3, 1, 4, 1, 5, 0, 7, 0, 8, 1, 9, 1, 10, 2, 11, 3, 11, 4, 12, 5, 12, 7, 11, 8, 11, 9, 10, 10, 9, 11, 8, 11, 7, 12, 5, 12, 4, 11, 3, 11, 2, 10, 1, 9, 1, 8 };
+ p->fillRect(r, color0);
+ p->setPen(color1);
+ p->setBrush(color1);
+ p->translate(r.x(), r.y());
+ p->drawPolygon(QPointArray(28, outline));
+ p->translate(-r.x(), -r.y());
+ break;
+ }
+
+ // GENERAL PANELS
+ // --------------
+ case PE_Splitter: {
+ int k;
+ p->fillRect(r, cg.background());
+ p->setBrush(cg.background().dark());
+
+ if (horiz) {
+ for (k = r.center().y() - 9; k < r.center().y() + 9; k += 3) {
+ p->drawLine(x + 2, k, w - 2, k);
+ }
+ } else {
+ for (k = r.center().x() - 9; k < r.center().x() + 9; k += 3) {
+ p->drawLine(k, y + 2, k, h - 2);
+ }
+ }
+
+ break;
+ }
+
+ case PE_PanelGroupBox:
+ case PE_GroupBoxFrame: {
+ p->setPen(cg.background().dark());
+ p->setBrush(cg.background());
+ p->drawRect(r);
+
+ if (pseudo3D && roundedCorners) {
+ const QCOORD corners[] = { x, y, x, y2, x2, y, x2, y2 };
+ p->setPen(cg.background());
+ p->drawPoints(QPointArray(4, corners));
+ }
+ break;
+ }
+
+ case PE_WindowFrame:
+ case PE_Panel: {
+ renderPanel(p, r, cg, sunken, false);
+ break;
+ }
+
+ case PE_PanelLineEdit: {
+ renderPanel(p, r, cg, true, true);
+ break;
+ }
+
+ case PE_StatusBarSection: {
+ renderPanel(p, r, cg, true, false);
+ break;
+ }
+
+ case PE_TabBarBase: // Still not sure what this one does
+ case PE_PanelTabWidget: {
+ renderPanel(p, r, cg, sunken);
+ break;
+ }
+
+ case PE_PanelPopup: {
+ p->setPen(cg.shadow());
+ p->drawRect(r);
+ break;
+ }
+
+ // MENU / TOOLBAR PANEL
+ // --------------------
+ case PE_PanelMenuBar: // Menu
+ case PE_PanelDockWindow: { // Toolbar
+ p->setPen(cg.button());
+ p->drawRect(r);
+ break;
+ }
+
+ // TOOLBAR/DOCK WINDOW HANDLE
+ // --------------------------
+ case PE_DockWindowResizeHandle: {
+ renderButton(p, r, cg);
+ break;
+ }
+
+ case PE_DockWindowHandle: {
+ int k;
+
+ p->fillRect(r, cg.button());
+ p->setPen(cg.button().dark());
+
+ if (horiz) {
+ for (k = r.center().y() - 9; k < r.center().y() + 9; k += 3) {
+ p->drawLine(x + 2, k, w - 2, k);
+ }
+ } else {
+ for (k = r.center().x() - 9; k < r.center().x() + 9; k += 3) {
+ p->drawLine(k, y + 2, k, h - 2);
+ }
+ }
+
+ break;
+ }
+
+ // TOOLBAR SEPARATOR
+ // -----------------
+ case PE_DockWindowSeparator: {
+ break;
+ }
+
+ case PE_CheckMark: {
+ int x = r.center().x() - 3, y = r.center().y() - 3;
+ const QCOORD check[] = { x, y + 2, x, y + 4, x + 2, y + 6, x + 6, y + 2, x + 6, y, x + 2, y + 4 };
+ const QPointArray a(6, check);
+
+ p->setPen(flags & Style_Down ? cg.highlight() : p->pen());
+ p->setBrush(flags & Style_Down ? cg.highlight() : p->pen().color());
+ p->drawPolygon(a);
+
+ break;
+ }
+
+ case PE_SpinWidgetUp:
+ case PE_SpinWidgetDown:
+ case PE_HeaderArrow:
+ case PE_ArrowUp:
+ case PE_ArrowDown:
+ case PE_ArrowLeft:
+ case PE_ArrowRight: {
+ QPointArray a;
+
+ switch (pe) {
+ case PE_SpinWidgetUp:
+ case PE_ArrowUp: {
+ a.setPoints(7, u_arrow);
+ break;
+ }
+ case PE_SpinWidgetDown:
+ case PE_ArrowDown: {
+ a.setPoints(7, d_arrow);
+ break;
+ }
+ case PE_ArrowLeft: {
+ a.setPoints(7, l_arrow);
+ break;
+ }
+ case PE_ArrowRight: {
+ a.setPoints(7, r_arrow);
+ break;
+ }
+ default: {
+ if (flags & Style_Up) {
+ a.setPoints(7, u_arrow);
+ } else {
+ a.setPoints(7, d_arrow);
+ }
+ }
+ }
+
+ p->save();
+
+ if (flags & Style_Down) {
+ p->translate(pixelMetric(PM_ButtonShiftHorizontal),
+ pixelMetric(PM_ButtonShiftVertical));
+ }
+
+ if (flags & Style_Enabled) {
+ a.translate((r.x() + r.width()/2), (r.y() + r.height()/2));
+ if (p->pen() == QPen::NoPen) {
+ p->setPen(cg.buttonText());
+ }
+ p->drawLineSegments(a, 0, 3);
+ p->drawPoint(a[6]);
+ } else {
+ a.translate((r.x() + r.width()/2)+1, (r.y() + r.height()/2)+1);
+ if (p->pen() == QPen::NoPen) {
+ p->setPen(cg.highlightedText());
+ }
+ p->drawLineSegments(a, 0, 3);
+ p->drawPoint(a[6]);
+
+ a.translate(-1,-1);
+ if (p->pen() == QPen::NoPen) {
+ p->setPen(cg.mid());
+ }
+ p->drawLineSegments(a, 0, 3);
+ p->drawPoint(a[6]);
+ }
+
+ p->restore();
+ break;
+ }
+
+ default: {
+ return KStyle::drawPrimitive(pe, p, r, cg, flags, opt);
+ }
+ }
+}
+
+
+void dotNETstyle::drawControl(ControlElement element,
+ QPainter *p,
+ const QWidget *widget,
+ const QRect &r,
+ const QColorGroup &cg,
+ SFlags flags,
+ const QStyleOption& opt) const
+{
+ switch (element) {
+ // CHECKBOXES
+ // ----------
+ case CE_CheckBox: {
+ drawPrimitive(PE_Indicator, p, r, cg, flags);
+ if (flags & Style_On || flags & Style_Down) {
+ p->setPen(cg.foreground());
+ drawPrimitive(PE_CheckMark, p, r, cg, flags);
+ }
+ break;
+ }
+
+ // PROGRESSBAR
+ // -----------
+ case CE_ProgressBarGroove: {
+ renderPanel(p, r, cg, true, false);
+ break;
+ }
+
+ case CE_ProgressBarContents: {
+ const QProgressBar *pb = (const QProgressBar *)widget;
+
+ if (pb->totalSteps()) {
+ int x, y, w, h;
+ double percent = (double)pb->progress() / (double)pb->totalSteps();
+
+ r.rect(&x, &y, &w, &h);
+
+ p->fillRect(x + 1, y + 1, w - 2, h - 2, cg.background().light());
+
+ if (QApplication::reverseLayout()) {
+ x += w - ((int)(w * percent));
+ y += 1; h -= 2;
+ w = ((int)(w * percent)) - 2;
+ } else {
+ x += 1; y += 1; h -= 2;
+ w = (int)(w * percent) - 2;
+ }
+
+ p->fillRect(x, y, w, h, cg.highlight());
+
+ if (pb->progress() < pb->totalSteps()) {
+ p->setPen(cg.background().dark(115));
+ if (QApplication::reverseLayout()) {
+ p->drawLine(x - 1, y, x - 1, h);
+ } else {
+ p->drawLine(x + w, y, x + w, h);
+ }
+ }
+
+ if (pseudo3D) {
+ QPointArray corners;
+ if (QApplication::reverseLayout()) {
+ const QCOORD c[] = { x, h, x, y, x + w, y, x + w, h };
+ corners = QPointArray(4, c);
+ } else {
+ const QCOORD c[] = { x, h, x, y, w, y, w, h };
+ corners = QPointArray(4, c);
+ }
+ p->setPen(cg.highlight().dark(120));
+ p->drawConvexPolygon(corners);
+ p->setPen(cg.highlight().light(120));
+ p->drawPolyline(corners, 0, 3);
+ if (roundedCorners) {
+ p->setPen(cg.background().dark());
+ p->drawPoints(corners);
+ }
+ }
+ }
+ break;
+ }
+
+ // RADIOBUTTONS
+ // ------------
+ case CE_RadioButton: {
+ drawPrimitive(PE_ExclusiveIndicator, p, r, cg, flags);
+
+ if (flags & Style_On || flags & Style_Down) {
+ QCOORD center[] = { 4, 5, 4, 7, 5, 8, 7, 8, 8, 7, 8, 5, 7, 4, 5, 4 };
+ QPointArray c(8, center);
+ p->setPen(flags & Style_Down ? cg.highlight() : cg.text());
+ p->setBrush(flags & Style_Down ? cg.highlight() : cg.text());
+ p->drawPolygon(c);
+ }
+ break;
+ }
+
+ // TABS
+ // ----
+ case CE_TabBarTab: {
+ const QTabBar *tb = (const QTabBar *) widget;
+ bool cornerWidget = false;
+ QTabBar::Shape tbs = tb->shape();
+ bool selected = flags & Style_Selected;
+ int x, x2, y, y2, w, h;
+ r.rect(&x, &y, &w, &h);
+ r.coords(&x, &y, &x2, &y2);
+
+ if (tb->parent()->inherits("QTabWidget")) {
+ const QTabWidget *tw = (const QTabWidget *)tb->parent();
+ QWidget *cw = tw->cornerWidget(Qt::TopLeft);
+ if (cw) {
+ cornerWidget = true;
+ }
+ }
+
+ switch (tbs) {
+ case QTabBar::RoundedAbove: {
+ y2 -= 1;
+ if (pseudo3D) {
+ p->setPen(cg.background().dark());
+ if (selected) {
+ const QCOORD oCorners[] = { x, y2, x, y, x2, y, x2, y2 };
+ p->drawPolyline(QPointArray(4, oCorners));
+
+ if (roundedCorners) {
+ p->setPen(cg.background());
+ p->drawPoints(QPointArray(4, oCorners), 1, 2);
+ }
+
+ p->setPen(cg.background().dark(115));
+ /* Right inner border */
+ p->drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);
+ p->setPen(cg.background().light());
+ /* Top inner border */
+ p->drawLine(x + 1, y + 1, x + w - 2, y + 1);
+ /* Left inner border */
+ p->drawLine(x + 1, y + 1, x + 1, y + h - 1);
+ } else {
+ QRect r2(x+1, y+3, w-2, h-5);
+ p->fillRect(r2, cg.mid().light(105));
+
+ const QCOORD oCorners[] = { x, y2, x, y + 2, x2, y + 2, x2, y2 };
+ p->drawPolyline(QPointArray(4, oCorners));
+
+ p->setPen(cg.background());
+
+ /* hack where the rounded corners sometimes go away */
+ if (roundedCorners) {
+ p->drawPoint(x + w - 1, y + 2);
+ }
+
+ p->setPen(cg.background().light());
+ /* Top of underlying tabbar-widget */
+ p->drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+ p->setPen(cg.background().dark());
+ /* Top of underlying tabbar-widget */
+ p->drawLine(x, y + h - 2, x + w - 1, y + h - 2);
+ /* Outer right border */
+ p->drawLine(x + w - 1, y + 3, x + w - 1, y + h - 2);
+ }
+
+ if (opt.tab()->identifier() == 0 && !cornerWidget) {
+ p->setPen(cg.background().dark());
+ p->drawPoint(x, y + h - 1);
+ }
+ } else {
+ p->setPen(cg.background().dark());
+ if (selected) {
+ p->drawLine(x + w - 1, y, x + w - 1, y + h - 2);
+ p->setPen(cg.background().light());
+ p->drawLine(x, y, x + w - 1, y);
+ p->drawLine(x, y, x, y + h - 1);
+ p->setPen(cg.background().dark(115));
+ p->drawLine(x + w - 2, y + 1, x + w - 2, y + h - 3);
+ } else {
+ QRect r2(x + 1, y + 3, w - 2, h - 4);
+ p->fillRect(r2, cg.mid());
+
+ p->setPen(cg.background().light());
+ p->drawLine(x, y + 2, x + w - 1, y + 2);
+ p->drawLine(x, y + 2, x, y + h - 1);
+ p->drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+
+ p->setPen(cg.mid().dark(115));
+ p->drawLine(x + w - 2, y + 3, x + w - 2, y + h - 3);
+ }
+ }
+
+ break;
+ }
+
+ case QTabBar::RoundedBelow: {
+ if (pseudo3D) {
+ p->setPen(cg.background().dark());
+ if (selected) {
+ const QCOORD oCorners[] = { x, y + 1, x, y2, x2, y2, x2, y + 1 };
+ p->drawPolyline(QPointArray(4, oCorners));
+
+ p->setPen(cg.background().dark(115));
+ p->drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
+ /* Right inner border */
+ p->drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);
+ p->setPen(cg.background().light());
+ /* Left inner border */
+ p->drawLine(x + 1, y, x + 1, y + h - 2);
+ } else {
+ y2 -= 2;
+ const QCOORD oCorners[] = { x, y, x, y2, x2, y2, x2, y };
+ QRect r2(x + 1, y + 2, w - 2, h - 5);
+ p->fillRect(r2, cg.mid().light(105));
+
+ p->drawPolyline(QPointArray(4, oCorners));
+
+ p->setPen(cg.mid().dark(115));
+ /* Inner right border */
+ p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 4);
+ p->drawLine(x + 1, y + h - 4, x + w - 2, y + h - 4);
+
+ p->setPen(cg.background().dark(115));
+ /* Top of underlying tabbar-widget */
+ p->drawLine(x, y, x + w - 1, y);
+ p->setPen(cg.background().dark());
+ /* Top of underlying tabbar-widget */
+ p->drawLine(x, y + 1, x + w - 1, y + 1);
+ /* Outer right border */
+ p->drawLine(x + w - 1, y + 3, x + w - 1, y + h - 2);
+
+ /* hack where the rounded corners sometimes go away */
+ if (roundedCorners) {
+ p->setPen(cg.background());
+ p->drawPoint(x + w - 1, y + h - 3);
+ p->drawPoint(x + w - 1, y + h - 2);
+ }
+ }
+
+ if (opt.tab()->identifier() == 0 && !cornerWidget) {
+ p->setPen(cg.background().dark());
+ p->drawPoint(x, y);
+ }
+ } else {
+ if (selected) {
+ p->setPen(cg.background().light());
+ p->drawLine(x, y, x, y + h - 1);
+
+ p->setPen(cg.background().dark());
+ p->drawLine(x + w - 1, y, x + w - 1, y + h - 1);
+ p->drawLine(x, y + h-1, x + w - 1, y + h - 1);
+ } else {
+ QRect r2(x, y + 1, w - 1, h - 4);
+ p->fillRect(r2, cg.mid());
+
+ p->setPen(cg.background().dark());
+ p->drawLine(x, y, x + w - 1, y);
+
+ p->setPen(cg.mid().dark(115));
+ p->drawLine(x + w - 2, y + 1, x + w - 2, y + h - 5);
+ p->drawLine(x, y + h - 4, x + w - 1, y + h - 4);
+ }
+ }
+ break;
+ }
+
+ default:
+ winstyle->drawControl(element, p, widget, r, cg, flags, opt);
+ }
+
+ break;
+ }
+
+ case CE_TabBarLabel: {
+ const int text_flags = AlignVCenter | AlignHCenter | ShowPrefix |
+ DontClip | SingleLine;
+
+ p->save();
+
+ if (useTextShadows) {
+ p->setPen(cg.background().dark(115));
+ p->drawText(r.x()+1, r.y()+1, r.width(), r.height(), text_flags, opt.tab()->text());
+ }
+
+ p->setPen(flags & Style_Enabled ? cg.foreground() : cg.mid().dark());
+
+ if (!flags & Style_Selected) {
+ p->translate(pixelMetric(PM_ButtonShiftHorizontal),
+ pixelMetric(PM_ButtonShiftVertical));
+ }
+
+ p->drawText(r, text_flags, opt.tab()->text());
+
+ if (flags & Style_HasFocus)
+ drawPrimitive(PE_FocusRect, p, r, cg);
+
+ p->restore();
+ break;
+ }
+
+ case CE_PushButton: {
+ QPushButton *button = (QPushButton *)widget;
+ QRect br = r;
+ bool btnDefault = button->isDefault();
+
+ static int di = pixelMetric(PM_ButtonDefaultIndicator);
+ br.addCoords(di, di, -di, -di);
+
+ if (btnDefault) {
+ drawPrimitive(PE_ButtonDefault, p, r, cg, flags);
+ }
+
+ drawPrimitive(PE_ButtonBevel, p, br, cg, flags);
+ break;
+ }
+
+ case CE_PushButtonLabel: {
+ const QPushButton *pb = (const QPushButton *)widget;
+ const bool enabled = flags & Style_Enabled;
+ const int text_flags = AlignVCenter | AlignHCenter | ShowPrefix |
+ DontClip | SingleLine;
+ QRect ur(r);
+
+ if (flags & Style_Down) {
+ p->translate(pixelMetric(PM_ButtonShiftHorizontal),
+ pixelMetric(PM_ButtonShiftVertical));
+ }
+
+ if (!pb->text().isEmpty() && (flags & Style_ButtonDefault)) {
+ p->setFont(QFont(p->font().family(), p->font().pointSize(), 75));
+ }
+
+ if (pb->iconSet() && !pb->iconSet()->isNull()) {
+ QIconSet::Mode mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
+ QPixmap pixmap = pb->iconSet()->pixmap(QIconSet::Small, mode);
+
+ if (!pb->text().isEmpty())
+ {
+ const int TextToIconMargin = 3;
+ int length = pixmap.width() + TextToIconMargin
+ + p->fontMetrics().size(ShowPrefix, pb->text()).width();
+ int offset = (r.width() - length)/2;
+
+ p->drawPixmap( r.x() + offset, r.y() + r.height() / 2 - pixmap.height() / 2, pixmap );
+ ur.addCoords(offset + pixmap.width() + TextToIconMargin, 0, -offset, 0);
+ }
+ else
+ {
+ if (!pb->pixmap())
+ p->drawPixmap(r.x() + r.width()/2 - pixmap.width()/2, r.y() + r.height() / 2 - pixmap.height() / 2,
+ pixmap);
+ else //icon + pixmap. Ugh.
+ p->drawPixmap(r.x() + pb->isDefault() ? 8 : 4 , r.y() + r.height() / 2 - pixmap.height() / 2, pixmap);
+ }
+ }
+
+ if (pb->pixmap() && !pb->text()) {
+ QRect pr(0, 0, pb->pixmap()->width(), pb->pixmap()->height());
+ pr.moveCenter(r.center());
+ p->drawPixmap(pr.topLeft(), *pb->pixmap());
+ }
+
+ if (useTextShadows && !pb->text().isEmpty() && enabled) {
+ p->setPen((flags & Style_Down ? cg.highlight().dark(135) : cg.background().dark(115)));
+ p->drawText(ur.x()+1, ur.y()+1, ur.width(), ur.height(), text_flags, pb->text());
+ }
+
+ if (!pb->text().isEmpty()) {
+ p->setPen(enabled ? cg.foreground() : pb->palette().disabled().buttonText());
+ p->drawText(ur, text_flags, pb->text());
+ }
+
+ if ( flags & Style_HasFocus )
+ drawPrimitive( PE_FocusRect, p,
+ visualRect( subRect( SR_PushButtonFocusRect, widget ), widget ),
+ cg, flags );
+
+ break;
+ }
+
+ // MENUBAR ITEM (sunken panel on mouse over)
+ // -----------------------------------------
+ case CE_MenuBarItem: {
+ QMenuItem *mi = opt.menuItem();
+ bool active = flags & Style_Active;
+ bool focused = flags & Style_HasFocus;
+ bool down = flags & Style_Down;
+ const int text_flags =
+ AlignVCenter | AlignHCenter | ShowPrefix | DontClip | SingleLine;
+ int x, x2, y, y2;
+ r.coords(&x, &y, &x2, &y2);
+
+ if (active && focused) {
+ p->setBrush(cg.highlight());
+ p->setPen(down ? cg.highlight().light() : cg.highlight().dark());
+ p->drawRect(r);
+ if (pseudo3D && roundedCorners && !down) {
+ const QCOORD corners[] = { x, y2, x, y, x2, y, x2, y2 };
+ p->setPen(cg.background());
+ p->drawPoints(QPointArray(4, corners));
+ }
+
+ if (down) {
+ p->setBrush(cg.background().light());
+ p->setPen(cg.background().dark());
+ p->drawRect(r);
+ p->setPen(cg.background().light());
+ p->drawLine(x+1, y2, x2-1, y2);
+ if (pseudo3D && roundedCorners) {
+ p->setPen(cg.background());
+ p->drawPoint(x, y);
+ p->drawPoint(x2, y);
+ }
+ }
+ }
+
+ if (useTextShadows) {
+ p->setPen((active && focused && !down ? cg.highlight().dark(135) : cg.background().dark(115)));
+ p->drawText(r.x() + 1, r.y() + 1, r.width(), r.height(), text_flags, mi->text());
+ }
+ p->setPen((active && focused && !down ? cg.highlightedText() : cg.foreground()));
+ p->drawText(r, text_flags, mi->text());
+ break;
+ }
+
+ // POPUPMENU ITEM (highlighted on mouseover)
+ // ------------------------------------------
+ case CE_PopupMenuItem: {
+ QMenuItem *mi = opt.menuItem();
+
+ if (!mi) {
+ return;
+ }
+
+ const QPopupMenu *pum = (const QPopupMenu *) widget;
+ static const int itemFrame = 2;
+ static const int itemHMargin = 3;
+ static const int itemVMargin = 3;
+ static const int arrowHMargin = 6;
+ static const int rightBorder = 20;
+ const int tab = opt.tabWidth();
+
+ int checkcol = QMAX(opt.maxIconWidth(), 26);
+ int x, x2, y, y2, w, h;
+ r.rect(&x, &y, &w, &h);
+ r.coords(&x, &y, &x2, &y2);
+
+ bool active = flags & Style_Active;
+ bool disabled = !mi->isEnabled();
+ bool checkable = pum->isCheckable();
+
+ int xpos = x;
+ int xm = itemFrame + checkcol + itemHMargin;
+
+ if (pum->erasePixmap() && !pum->erasePixmap()->isNull()) {
+ p->drawPixmap( x, y, *pum->erasePixmap(), x, y, w, h );
+ } else {
+ if (!QApplication::reverseLayout()) {
+ p->fillRect( x, y, 22, h, cg.mid() );
+ p->fillRect( x + 22, y, w - 22, h, cg.background().light() );
+ } else { // i wonder why exactly +1 (diego)
+ p->fillRect( w-22, y, 22+1, h, cg.mid() );
+ p->fillRect( x, y, w - 22, h, cg.background().light() );
+ }
+ }
+
+ if (mi->isSeparator()) {
+ p->setPen(cg.mid());
+ if (!QApplication::reverseLayout())
+ p->drawLine(x + opt.maxIconWidth() + 6, y, x + w, y);
+ else
+ p->drawLine(w - (x + opt.maxIconWidth() + 6), y,
+ x, y);
+ return;
+ }
+
+ if (active && !disabled) {
+ p->setBrush(cg.highlight());
+ p->fillRect(x + 2, y + 2, w - 4, h - 4, cg.highlight());
+ p->setPen(cg.highlight().dark());
+ if (pseudo3D && roundedCorners) {
+ const QCOORD segments[] = { x+2, y+1, x2-2, y+1, x2-1, y+2, x2-1, y2-2, x2-2, y2-1, x+2, y2-1, x+1, y2-2, x+1, y+2 };
+ const QCOORD icorners[] = { x+2, y+2, x2-2, y+2, x2-2,y2-2, x+2, y2-2 };
+ p->drawLineSegments(QPointArray(8, segments));
+ p->drawPoints(QPointArray(4, icorners));
+ } else {
+ const QCOORD corners[] = { x+1, y2-1, x+1, y+1, x2-1, y+1, x2-1, y2-1 };
+ p->drawConvexPolygon(QPointArray(4, corners));
+ }
+ p->setPen(cg.highlightedText());
+ }
+
+ if (mi->iconSet()) {
+ p->save();
+ QIconSet::Mode mode =
+ disabled ? QIconSet::Disabled : QIconSet::Normal;
+ QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode);
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+
+ QRect cr(xpos, y, opt.maxIconWidth(), h);
+ QRect pmr(0, 0, pixw, pixh);
+ pmr.moveCenter(cr.center());
+
+ if (QApplication::reverseLayout())
+ pmr = visualRect( pmr, r );
+
+ p->setPen(cg.highlightedText());
+ p->drawPixmap(pmr.topLeft(), pixmap);
+ p->restore();
+ }
+
+ p->setPen(active ? cg.highlightedText() : cg.buttonText());
+
+ xpos += xm;
+
+ if (mi->custom()) {
+ int m = itemVMargin;
+ p->setPen(cg.foreground());
+ mi->custom()->paint(p, cg, active, !disabled, x+xm, y+m, w-xm-tab+1, h-2*m);
+ return;
+ } else {
+ QString s = mi->text();
+ if(!s.isNull()) {
+ int t = s.find('\t');
+ int m = itemVMargin;
+
+ int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
+
+ if (active && !disabled) {
+ p->setPen(cg.highlightedText());
+ } else if (disabled) {
+ p->setPen(cg.mid().light(110));
+ } else {
+ p->setPen(cg.text());
+ }
+
+ if (t >= 0) {
+ int xp;
+ xp = x + w - tab - rightBorder - itemHMargin - itemFrame + 1;
+
+ QRect rr = QRect(xp, y+m, tab, h-(2*m));
+ if (QApplication::reverseLayout())
+ rr = visualRect(rr, r);
+
+ if (useTextShadows) {
+ QPen op = p->pen();
+ p->setPen(active && !disabled ? cg.highlight().dark(130) : cg.background().dark(115));
+ p->drawText(rr.x() + 1, rr.y() + 1, rr.width(), rr.height(), text_flags, s.mid(t+1));
+ p->setPen(op);
+ }
+
+ p->drawText(rr, text_flags, s.mid(t+1));
+ s = s.left(t);
+ }
+
+ QRect rr = QRect(xpos, y+m, w-xm-tab+1, h-(2*m));
+ if (QApplication::reverseLayout()) {
+ rr = visualRect(rr, r);
+ text_flags |= AlignRight;
+ }
+
+ if (useTextShadows) {
+ QPen op = p->pen();
+ p->setPen(active && !disabled ? cg.highlight().dark(130) : cg.background().dark(115));
+ p->drawText(rr.x() + 1, rr.y() + 1, rr.width(), rr.height(), text_flags, s);
+ p->setPen(op);
+ }
+
+ p->drawText(rr, text_flags, s);
+ } else if (mi->pixmap()) {
+ QPixmap *pixmap = mi->pixmap();
+ if (pixmap->depth() == 1) {
+ p->setBackgroundMode(OpaqueMode);
+ }
+ p->drawPixmap(xpos, y, *pixmap);
+ if (pixmap->depth() == 1) {
+ p->setBackgroundMode(TransparentMode);
+ }
+ }
+ }
+
+ if (mi->popup()) {
+ int dim = pixelMetric(PM_MenuButtonIndicator);
+
+ xpos = x+w - arrowHMargin - 2*itemFrame - dim;
+
+ if (active && !disabled)
+ p->setPen(cg.highlightedText());
+ else
+ p->setPen(cg.text());
+
+
+ QRect rr = QRect(xpos, y + h/2 - dim/2, dim, dim);
+ if (QApplication::reverseLayout())
+ rr = visualRect( rr, r );
+ drawPrimitive((QApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight), p, rr, cg, Style_Enabled);
+ }
+
+ if (checkable) {
+ if (mi->isChecked()) {
+ int xp = x;
+
+ SFlags cflags = Style_Default;
+
+ if (!disabled)
+ cflags |= Style_Enabled;
+ else
+ cflags |= Style_On;
+
+ QRect rr = QRect( xp + 6, y + 6, 16, h - 6 );
+ if (QApplication::reverseLayout())
+ rr = visualRect( rr, r );
+
+ drawPrimitive(PE_CheckMark, p, rr, cg, cflags);
+ }
+ }
+
+ break;
+ }
+
+ // Menu and dockwindow empty space
+ //
+ case CE_DockWindowEmptyArea:
+ case CE_MenuBarEmptyArea:
+ p->fillRect(r, cg.button());
+ break;
+ default:
+ winstyle->drawControl(element, p, widget, r, cg, flags, opt);
+ }
+}
+
+void dotNETstyle::drawControlMask(ControlElement element,
+ QPainter *p,
+ const QWidget *w,
+ const QRect &r,
+ const QStyleOption &opt) const
+{
+ switch (element) {
+ case CE_PushButton: {
+ if (pseudo3D && roundedCorners) {
+ int x1, y1, x2, y2;
+ r.coords (&x1, &y1, &x2, &y2);
+ QCOORD corners[] = { x1, y1, x2, y1, x1, y2, x2, y2 };
+ p->fillRect (r, color1);
+ p->setPen (color0);
+ p->drawPoints (QPointArray (4, corners));
+ } else {
+ // Just fill the entire thing
+ p->fillRect (r, color1);
+ }
+ break;
+ }
+
+ default: {
+ KStyle::drawControlMask (element, p, w, r, opt);
+ }
+ }
+}
+
+void dotNETstyle::drawComplexControlMask(ComplexControl c,
+ QPainter *p,
+ const QWidget *w,
+ const QRect &r,
+ const QStyleOption &o) const
+{
+ switch (c) {
+ case CC_ComboBox: {
+ if (pseudo3D && roundedCorners) {
+ int x1, y1, x2, y2;
+ r.coords (&x1, &y1, &x2, &y2);
+ QCOORD corners[] = { x1, y1, x2, y1, x1, y2, x2, y2 };
+ p->fillRect (r, color1);
+ p->setPen (color0);
+ p->drawPoints (QPointArray (4, corners));
+ } else {
+ // Just fill the entire thing
+ p->fillRect (r, color1);
+ }
+ break;
+ }
+ default: {
+ KStyle::drawComplexControlMask (c, p, w, r, o);
+ }
+ }
+}
+
+void dotNETstyle::drawComplexControl(ComplexControl control,
+ QPainter *p,
+ const QWidget *widget,
+ const QRect &r,
+ const QColorGroup &cg,
+ SFlags flags,
+ SCFlags controls,
+ SCFlags active,
+ const QStyleOption& opt) const
+{
+ switch(control) {
+ // COMBOBOX
+ // --------
+ case CC_ComboBox: {
+ int x, y, w, h;
+ const QComboBox *cb = (const QComboBox *)widget;
+ r.rect(&x, &y, &w, &h);
+
+ if (active & Style_Sunken)
+ flags |= Style_Sunken;
+
+ static const unsigned char downarrow_bits[] = {
+ 0x7f, 0xbe, 0x9c, 0x08, 0x00, 0x00, 0x00, 0x28,
+ 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xb8
+ };
+
+ static const unsigned int handle_width = 15;
+ static const unsigned int handle_offset = handle_width + 1;
+
+ QBitmap downArrow = QBitmap(7, 4, downarrow_bits, true);
+ downArrow.setMask(downArrow);
+
+ cb->editable() ? p->fillRect(x + 1, y + 1, w - 2, h - 2, cg.base()) : p->fillRect(x + 1, y + 1, w - 2, h - 2, cg.light());
+
+ renderPanel(p, r, cg, true, true);
+
+ p->save();
+ // Draw the box on the right.
+ if (cb->listBox() && cb->listBox()->isVisible()) {
+ p->setPen(cg.highlight());
+ p->setBrush(cg.highlight().light());
+ } else if (flags & Style_HasFocus) {
+ p->setPen(cg.highlight().dark());
+ p->setBrush(cg.highlight());
+ } else {
+ p->setPen(cg.dark());
+ p->setBrush(cg.midlight());
+ }
+
+ QRect hr = (pseudo3D ? QRect(w - handle_offset - 1, y, handle_width + 2, h) : QRect(w - handle_offset - 1, y + 1, handle_width + 2, h - 1));
+ if (QApplication::reverseLayout()) { hr = visualRect(hr, r); }
+
+ p->drawRect(hr);
+ p->setBrush(NoBrush);
+ QRect rr = (pseudo3D ? QRect(x + 1, y + 1, w - 2, h - 2) : QRect(x + 1, y + 1, w - 1, h - 1));
+
+ if (QApplication::reverseLayout()) { rr = visualRect( rr, r ); }
+
+ if (flags & Style_HasFocus || cg.highlight() == cg.midlight() ||
+ (cb->listBox() && cb->listBox()->isVisible())) {
+ p->drawRect(rr);
+ }
+
+ if (pseudo3D && !((active & Style_Sunken) ||
+ (cb->listBox() && cb->listBox()->isVisible()))) {
+ p->save();
+ p->setBrush(NoBrush);
+ QColor test = ((flags & Style_HasFocus) ? cg.highlight() : cg.midlight());
+ p->setPen(test.dark());
+ p->drawRect(hr);
+ hr.moveBy(1,1);
+ hr.setSize(QSize(hr.width() -2, hr.height() -2));
+ QPointArray ca(3);
+ ca.setPoint(0, hr.topRight());
+ ca.setPoint(1, hr.bottomRight());
+ ca.setPoint(2, hr.bottomLeft());
+ p->setPen(test.dark(120));
+ p->drawPolyline(ca);
+ p->setPen(test.light(120));
+ ca.setPoint(1, hr.topLeft());
+ p->drawPolyline(ca);
+ p->restore();
+ }
+
+ if (pseudo3D && roundedCorners) {
+ p->setPen(cg.background());
+ p->drawPoint(r.topRight());
+ p->drawPoint(r.bottomRight());
+ p->setPen(cg.background().dark());
+ hr.moveBy(-1,-1);
+ hr.setSize(QSize(hr.width() + 2, hr.height() + 2));
+ p->drawPoint(hr.topLeft());
+ p->drawPoint(hr.bottomLeft());
+ }
+
+ if ((active && cb->hasFocus()) || (cb->listBox() && cb->listBox()->isVisible())) {
+ p->setPen(cg.highlightedText());
+ } else {
+ p->setPen(cg.text());
+ }
+
+ QRect cr(w - handle_offset, y, handle_width, h - 2);
+ QRect pmr(0, 0, 7, 4);
+ pmr.moveCenter(cr.center());
+ if (QApplication::reverseLayout()) {
+ pmr = visualRect( pmr, r );
+ }
+
+ p->drawPixmap(pmr.topLeft(), downArrow);
+
+ p->restore();
+ break;
+ }
+
+ // TOOLBUTTON
+ // ----------
+ case CC_ToolButton: {
+ const QToolButton *tb = (const QToolButton *) widget;
+
+ QRect button, menuarea;
+ button = querySubControlMetrics(control, widget, SC_ToolButton, opt);
+ menuarea = querySubControlMetrics(control, widget, SC_ToolButtonMenu, opt);
+
+ SFlags bflags = flags,
+ mflags = flags;
+
+ if (active & SC_ToolButton)
+ bflags |= Style_Down;
+
+ if (active & SC_ToolButtonMenu)
+ mflags |= Style_Down;
+
+ if (controls & SC_ToolButton) {
+ // If we're pressed, on, or raised...
+ if (bflags & (Style_Down | Style_On | Style_Raised)) {
+ drawPrimitive(PE_ButtonTool, p, button, cg, bflags, opt);
+ } else if (tb->parentWidget() &&
+ tb->parentWidget()->backgroundPixmap() &&
+ !tb->parentWidget()->backgroundPixmap()->isNull()) {
+ QPixmap pixmap = *(tb->parentWidget()->backgroundPixmap());
+ p->drawTiledPixmap( r, pixmap, tb->pos() );
+ }
+ }
+
+ // Draw a toolbutton menu indicator if required
+ if (controls & SC_ToolButtonMenu) {
+ if (mflags & (Style_Down | Style_On | Style_Raised)) {
+ drawPrimitive(PE_ButtonDropDown, p, menuarea, cg, mflags, opt);
+ }
+ drawPrimitive(PE_ArrowDown, p, menuarea, cg, mflags, opt);
+ }
+
+ if (tb->hasFocus() && !tb->focusProxy()) {
+ QRect fr = tb->rect();
+ fr.addCoords(2, 2, -2, -2);
+ drawPrimitive(PE_FocusRect, p, fr, cg);
+ }
+
+ break;
+ }
+
+ // SPINWIDGETS
+ // -----------
+ case CC_SpinWidget: {
+ const QSpinWidget *sw = (const QSpinWidget *) widget;
+ SFlags flags;
+ PrimitiveElement pe;
+
+ QRect swf = querySubControlMetrics(control, sw, SC_SpinWidgetFrame);
+ swf = visualRect( swf, sw );
+
+ if (controls & SC_SpinWidgetFrame) {
+ // Don't draw the WindowsStyle thick frame.
+ renderPanel(p, swf, cg, true, false);
+ }
+
+ 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() == QSpinWidget::PlusMinus)
+ pe = PE_SpinWidgetPlus;
+ else
+ pe = PE_SpinWidgetUp;
+
+ QRect re = sw->upRect();
+ QColorGroup ucg = sw->isUpEnabled() ? cg : sw->palette().disabled();
+ p->fillRect(re.x() + 1, re.y() + 1, re.width() - 2, re.height() - 1, flags & Style_Raised ? ucg.background() : ucg.highlight());
+ if (pseudo3D) {
+ const QCOORD corners[] = { re.x(), re.bottom(), re.x(), re.y() + 1, re.x() + 1, re.y(), re.right() - 1, re.y(), re.right(), re.y() + 1, re.right(), re.bottom() };
+ p->setPen(flags & Style_Raised ? ucg.background().dark() : ucg.highlight());
+ p->drawLineSegments(QPointArray(6, corners));
+ p->setPen(flags & Style_Raised ? ucg.background().light() : ucg.highlight());
+ p->drawLine(re.x() + 1, re.y() + 1, re.x() + 1, re.bottom());
+ p->drawLine(re.x() + 1, re.y() + 1, re.right()-1, re.y() + 1);
+ p->setPen(flags & Style_Raised ? ucg.background().dark(115) : ucg.highlight());
+ p->drawLine(re.right()-1, re.y() + 2, re.right()-1, re.bottom());
+ } else {
+ }
+ re.setX(re.x() + 1);
+ p->setPen(flags & Style_Raised ? ucg.foreground() : ucg.highlightedText());
+ drawPrimitive(pe, p, re, ucg, flags);
+ }
+
+ if (controls & SC_SpinWidgetDown) {
+ flags = Style_Default | Style_Enabled;
+ if (active == SC_SpinWidgetDown) {
+ flags |= Style_On;
+ flags |= Style_Sunken;
+ } else
+ flags |= Style_Raised;
+
+ if (sw->buttonSymbols() == QSpinWidget::PlusMinus)
+ pe = PE_SpinWidgetMinus;
+ else
+ pe = PE_SpinWidgetDown;
+
+ QRect re = sw->downRect();
+ QColorGroup dcg = sw->isDownEnabled() ? cg : sw->palette().disabled();
+ p->fillRect(re.x() + 1, re.y(), re.width() - 2, re.height() - 1, flags & Style_Raised ? dcg.background() : dcg.highlight());
+ if (pseudo3D) {
+ const QCOORD corners[] = {
+ re.x(), re.top(),
+ re.x(), re.bottom(),
+ re.x() + 1, re.y() + re.height(),
+ re.right() - 1, re.y() + re.height(),
+ re.right(), re.bottom(),
+ re.right(), re.y()
+ };
+ p->setPen(flags & Style_Raised ? dcg.background().dark() : dcg.highlight());
+ p->drawLineSegments(QPointArray(6, corners));
+ p->setPen(flags & Style_Raised ? dcg.background().light() : dcg.highlight());
+ p->drawLine(re.x() + 1, re.y(), re.x() + 1, re.bottom());
+ p->setPen(flags & Style_Raised ? dcg.background().dark(115) : dcg.highlight());
+ p->drawLine(re.x() + 2, re.bottom(), re.right()-1, re.bottom());
+ p->drawLine(re.right()-1, re.y(), re.right()-1, re.bottom());
+ } else {
+ }
+ p->setPen(flags & Style_Raised ? dcg.foreground() : dcg.highlightedText());
+ re.setX(re.x() + 1);
+ drawPrimitive(pe, p, re, dcg, flags);
+ }
+
+ break;
+ }
+
+ default:
+ KStyle::drawComplexControl(control, p, widget,
+ r, cg, flags, controls,
+ active, opt);
+ break;
+ }
+}
+
+
+QRect dotNETstyle::subRect(SubRect r, const QWidget *widget) const
+{
+// Don't use KStyles progressbar subrect
+ switch (r) {
+ case SR_ComboBoxFocusRect: {
+ return querySubControlMetrics( CC_ComboBox, widget, SC_ComboBoxEditField );
+ }
+
+ case SR_PushButtonFocusRect: {
+ QRect rect = widget->rect();
+ int margin = pixelMetric(PM_ButtonDefaultIndicator, widget) + pixelMetric(PM_DefaultFrameWidth, widget) + 2;
+
+ rect.addCoords(margin, margin, -margin, -margin);
+ return rect;
+ }
+
+ case SR_ProgressBarGroove:
+ case SR_ProgressBarContents:
+ case SR_ProgressBarLabel: {
+ return winstyle->subRect(r, widget);
+ }
+ default: {
+ return KStyle::subRect(r, widget);
+ }
+ }
+}
+
+QRect dotNETstyle::querySubControlMetrics(ComplexControl control,
+ const QWidget *widget,
+ SubControl subcontrol,
+ const QStyleOption &opt) const
+{
+ if (!widget) {
+ return QRect();
+ }
+
+ QRect r(widget->rect());
+ switch (control) {
+ case CC_ComboBox: {
+ switch (subcontrol) {
+ case SC_ComboBoxEditField: {
+ return QRect(r.x() + 2, r.y() + 2, r.width() - 19, r.height() - 4);
+ }
+ default: {
+ return KStyle::querySubControlMetrics(control, widget, subcontrol, opt);
+ }
+ }
+ break;
+ }
+
+ case CC_SpinWidget: {
+ int fw = pixelMetric(PM_SpinBoxFrameWidth, widget);
+ QSize bs;
+ bs.setHeight(QMAX(8, widget->height()/2));
+ bs.setWidth(QMIN(bs.height() * 8 / 5, widget->width() / 4));
+
+ int y = fw;
+ int x, lx, rx;
+ x = widget->width() - y - bs.width();
+ lx = fw;
+ rx = x - fw;
+
+ switch (subcontrol) {
+ case SC_SpinWidgetUp: {
+ return QRect(x, y-1, bs.width(), bs.height());
+ }
+ case SC_SpinWidgetDown: {
+ return QRect(x, y + bs.height()-1, bs.width(), bs.height());
+ }
+ case SC_SpinWidgetFrame: {
+ return QRect(0, 0, widget->width() - (bs.width() + 2), widget->height());
+ }
+ case SC_SpinWidgetEditField: {
+ return QRect(lx, fw, widget->width() - (bs.width() + 4), widget->height() - 2 * fw);
+ }
+ case SC_SpinWidgetButtonField: {
+ return QRect(x, y, bs.width(), widget->height() - 2 * fw);
+ }
+ default: {
+ }
+ }
+ break;
+ }
+ default: {
+ }
+ }
+ return KStyle::querySubControlMetrics(control, widget, subcontrol, opt);
+}
+
+int dotNETstyle::pixelMetric(PixelMetric m, const QWidget *widget) const
+{
+ switch(m) {
+ // TABS
+ // ----
+ case PM_TabBarTabVSpace: {
+ const QTabBar * tb = (const QTabBar *) widget;
+ if (tb->shape() == QTabBar::RoundedAbove ||
+ tb->shape() == QTabBar::RoundedBelow)
+ return 12;
+ else
+ return 0;
+ }
+
+ case PM_TabBarTabOverlap: {
+ const QTabBar* tb = (const QTabBar*)widget;
+ if (tb->shape() != QTabBar::RoundedAbove &&
+ tb->shape() != QTabBar::RoundedBelow)
+ return 3; // Leave standard size alone
+ else
+ return 1; // Change size for our tabs only
+ }
+
+ // SPLITTERS
+ // ---------
+ case PM_SplitterWidth: {
+ return 6;
+ }
+
+ // PROGRESSBARS
+ // ------------
+ case PM_ProgressBarChunkWidth:
+ return 9;
+
+ // SLIDER
+ // ------
+ case PM_SliderLength:
+ return 11;
+
+ // MENU INDICATOR
+ // --------------
+ case PM_MenuButtonIndicator:
+ return 8;
+
+ // HEADER INDICATOR
+ // ----------------
+ case PM_HeaderMarkSize:
+ return 1;
+
+ // CHECKBOXES / RADIO BUTTONS
+ // --------------------------
+ case PM_ExclusiveIndicatorWidth: // Radiobutton size
+ case PM_ExclusiveIndicatorHeight: // 13x13
+ case PM_IndicatorWidth: // Checkbox size
+ case PM_IndicatorHeight: // 13x13
+ return 13;
+
+ // FRAMES
+ // ------
+ case PM_SpinBoxFrameWidth:
+ return 1;
+
+ case PM_MenuBarFrameWidth:
+ return 0;
+
+ case PM_DefaultFrameWidth: {
+ if (!pseudo3D) {
+ return 1;
+ } else {
+ if (widget &&
+ (widget->inherits("QPopupMenu") ||
+ widget->inherits("QMenuBar") ||
+ widget->inherits("QRangeControl") ||
+ widget->inherits("QScrollView"))) {
+ return 1;
+ } else {
+ return 2;
+ }
+ }
+ }
+
+ case PM_ButtonDefaultIndicator: {
+ return 3;
+ }
+
+ case PM_ButtonShiftVertical:
+ case PM_ButtonShiftHorizontal: {
+ return 1;
+ }
+
+ default:
+ return KStyle::pixelMetric(m, widget);
+ }
+}
+
+
+QSize dotNETstyle::sizeFromContents(ContentsType t,
+ const QWidget *widget,
+ const QSize &s,
+ const QStyleOption &opt) const
+{
+ switch (t) {
+
+ case CT_PopupMenuItem: {
+ if (!widget || opt.isDefault())
+ break;
+
+ const QPopupMenu *popup = (const QPopupMenu *)widget;
+ QMenuItem *mi = opt.menuItem();
+ int maxpmw = opt.maxIconWidth();
+ int w = s.width(), h = s.height();
+ bool checkable = popup->isCheckable();
+
+ if (mi->custom()) {
+ w = mi->custom()->sizeHint().width();
+ h = mi->custom()->sizeHint().height();
+ } else if (mi->widget()) {
+ // don't change the size in this case.
+ } else if (mi->isSeparator()) {
+ w = 10;
+ h = 1;
+ } else {
+ if (mi->pixmap()) {
+ h = QMAX(h, mi->pixmap()->height() + 8);
+ }
+
+ h = QMAX(h, widget->fontMetrics().height() + 10);
+
+ if (mi->iconSet()) {
+ h = QMAX(h, mi->iconSet()->pixmap(QIconSet::Small, QIconSet::Normal).height() + 8);
+ }
+ }
+
+ if (!mi->text().isNull()) {
+ if ((mi->text().find('\t') >= 0) || mi->popup()) {
+ w += 20;
+ }
+ }
+
+ if (maxpmw) {
+ w += maxpmw;
+ }
+ if (checkable && maxpmw < 20) {
+ w += 20 - maxpmw;
+ }
+ if (checkable || maxpmw > 0) {
+ w += 2;
+ }
+
+ w += 20;
+
+ return QSize(w, h);
+ }
+
+ case CT_PushButton: {
+ const QPushButton* button = (const QPushButton*) widget;
+ int w = s.width();
+ int h = s.height();
+ int bm = pixelMetric( PM_ButtonMargin, widget );
+ int fw = pixelMetric( PM_DefaultFrameWidth, widget ) * 2;
+
+ //We use bold font sometimes, so that make take more space than Qt allocated.
+ QFontMetrics origFM = button->fontMetrics();
+ QFontMetrics boldFM = QFontMetrics(QFont(button->font().family(), button->font().pointSize(), 75));
+ int origTextWidth = origFM.size(ShowPrefix, button->text()).width();
+ int boldTextWidth = boldFM.size(ShowPrefix, button->text()).width();
+
+ if (boldTextWidth > origTextWidth) //this might not happen in particular when text is empty
+ w += boldTextWidth - origTextWidth;
+
+ w += bm + fw;
+ h += bm + fw;
+
+ // Ensure we stick to standard width and heights.
+ if ( button->isDefault() || button->autoDefault() ) {
+ if ( w < 80 && !button->pixmap() )
+ w = 80;
+ }
+
+ // Compensate for default indicator. Doing it for all widgets lets us
+ // workaround changes in auto-default behavior in KDialogBase in 3.3
+ int di = pixelMetric( PM_ButtonDefaultIndicator );
+ w += di * 2;
+ h += di * 2;
+
+ if ( h < 22 )
+ h = 22;
+ return QSize( w, h );
+ }
+
+ case CT_ComboBox: {
+ int arrow = 21;
+ return QSize(s.width() + arrow, QMAX(s.height() + 4, 16));
+ }
+
+ default:
+ return KStyle::sizeFromContents (t, widget, s, opt);
+ }
+
+ return KStyle::sizeFromContents (t, widget, s, opt);
+// return winstyle->sizeFromContents(t, widget, s, opt);
+}
+
+void dotNETstyle::paletteChanged()
+{
+ QComboBox *combo = 0L;
+ QMenuBar *menuBar = 0L;
+ QToolBar *toolBar = 0L;
+ QWidget *widget = 0L;
+
+ QValueListIterator<QWidget*> it = m_widgets.begin();
+ for ( ; it != m_widgets.end(); ++it ) {
+ widget = *it;
+ if ((combo = dynamic_cast<QComboBox*>( widget )))
+ updatePalette( combo );
+ else if ((toolBar = dynamic_cast<QToolBar*>( widget )))
+ updatePalette( toolBar );
+ else if ((menuBar = dynamic_cast<QMenuBar*>( widget )))
+ updatePalette( menuBar );
+ }
+}
+
+void dotNETstyle::updatePalette( QComboBox *combo )
+{
+ QPalette pal = QApplication::palette();
+ pal.setColor(QColorGroup::Dark,
+ pal.active().color(QColorGroup::Base));
+ pal.setColor(QColorGroup::Midlight,
+ pal.active().color(QColorGroup::Background));
+ combo->setPalette(pal);
+}
+
+void dotNETstyle::updatePalette( QToolBar *bar )
+{
+ QPalette pal = QApplication::palette();
+ pal.setColor(QColorGroup::Button,
+ pal.active().color(QColorGroup::Background));
+ bar->setPalette(pal);
+}
+
+void dotNETstyle::updatePalette( QMenuBar *bar )
+{
+ QPalette pal = QApplication::palette();
+ pal.setColor(QColorGroup::Button,
+ pal.active().color(QColorGroup::Background));
+ bar->setPalette(pal);
+}
+
+void dotNETstyle::slotDestroyed()
+{
+ m_widgets.remove( (QWidget*) sender() );
+}
+
+bool dotNETstyle::eventFilter(QObject *obj, QEvent *ev)
+{
+ if (obj->inherits("QComboBox")) {
+ if (ev->type() == QEvent::Enter) {
+ QWidget *btn = (QWidget *)obj;
+ if (btn->isEnabled()) {
+ QPalette pal = btn->palette();
+ pal.setColor(QColorGroup::Dark,
+ pal.active().color(QColorGroup::Highlight).dark());
+ pal.setColor(QColorGroup::Midlight,
+ pal.active().color(QColorGroup::Highlight));
+ btn->setPalette(pal);
+ }
+ } else if (ev->type() == QEvent::Leave) {
+ QWidget *btn = (QWidget *)obj;
+ QPalette pal = btn->palette();
+ pal.setColor(QColorGroup::Dark,
+ pal.active().color(QColorGroup::Base));
+ pal.setColor(QColorGroup::Midlight,
+ pal.active().color(QColorGroup::Background));
+ btn->setPalette(pal);
+ }
+ } else if (obj->inherits("QButton")) {
+ QWidget *btn = (QWidget *)obj;
+ QPalette pal = btn->palette();
+ pal.setColor(QColorGroup::Button,
+ pal.active().color(QColorGroup::Background));
+ btn->setPalette(pal);
+ }
+
+ return false;
+}
+
+// vim: noet ts=4 sw=4
diff --git a/styles/dotnet/dotnet.h b/styles/dotnet/dotnet.h
new file mode 100644
index 00000000..dce41e97
--- /dev/null
+++ b/styles/dotnet/dotnet.h
@@ -0,0 +1,145 @@
+/*
+ * $Id$
+ *
+ * Copyright 2001, Chris Lee <[email protected]>
+ * Originally copied from the KDE3 HighColor style, modified to fit mine.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __DOTNET_H
+#define __DOTNET_H
+
+#include <kstyle.h>
+#include <qbitmap.h>
+
+#define u_arrow -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2
+#define d_arrow -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1
+#define l_arrow 0,-3, 0,3,-1,-2,-1,2,-2,-1,-2,1,-3,0
+#define r_arrow -2,-3,-2,3,-1,-2, -1,2,0,-1,0,1,1,0
+
+#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
+
+class dotNETstyle : public KStyle
+{
+ Q_OBJECT
+
+public:
+ dotNETstyle();
+ virtual ~dotNETstyle();
+
+ bool inheritsKHTML( const QWidget* widget ) const;
+ void polish( QWidget* widget );
+ void unPolish( QWidget* widget );
+
+ void renderMenuBlendPixmap( KPixmap&, const QColorGroup&, const QPopupMenu * ) const;
+
+ void drawKStylePrimitive( KStylePrimitive kpe,
+ QPainter* p,
+ const QWidget* widget,
+ const QRect &r,
+ const QColorGroup &cg,
+ SFlags flags = Style_Default,
+ const QStyleOption& = QStyleOption::Default ) const;
+
+ void drawPrimitive( PrimitiveElement pe,
+ QPainter *p,
+ const QRect &r,
+ const QColorGroup &cg,
+ SFlags flags = Style_Default,
+ const QStyleOption &opt = QStyleOption::Default ) const;
+
+ void drawControl( ControlElement element,
+ QPainter *p,
+ const QWidget *widget,
+ const QRect &r,
+ const QColorGroup &cg,
+ SFlags flags = Style_Default,
+ const QStyleOption& = QStyleOption::Default ) const;
+
+ void drawControlMask( ControlElement, QPainter *, const QWidget *, const QRect &, const QStyleOption &) const;
+
+ void drawComplexControl( ComplexControl control,
+ QPainter *p,
+ const QWidget *widget,
+ const QRect &r,
+ const QColorGroup &cg,
+ SFlags flags = Style_Default,
+ SCFlags controls = SC_All,
+ SCFlags active = SC_None,
+ const QStyleOption& = QStyleOption::Default ) const;
+
+ int pixelMetric( PixelMetric m,
+ const QWidget *widget = 0 ) const;
+
+ QRect subRect( SubRect r,
+ const QWidget *widget ) const;
+
+ QRect querySubControlMetrics( ComplexControl control,
+ const QWidget *widget,
+ SubControl subcontrol,
+ const QStyleOption &opt = QStyleOption::Default ) const;
+
+ void drawComplexControlMask(QStyle::ComplexControl c,
+ QPainter *p,
+ const QWidget *w,
+ const QRect &r,
+ const QStyleOption &o=QStyleOption::Default) const;
+
+ QSize sizeFromContents(QStyle::ContentsType t,
+ const QWidget *w,
+ const QSize &s,
+ const QStyleOption &o) const;
+
+protected:
+ void renderButton(QPainter *p,
+ const QRect &r,
+ const QColorGroup &g,
+ bool sunken = false,
+ bool corners = false) const;
+
+ void renderPanel(QPainter *p,
+ const QRect &r,
+ const QColorGroup &g,
+ bool sunken = true,
+ bool thick = true) const;
+
+ void renderSlider(QPainter *p,
+ const QRect &r,
+ const QColorGroup &g) const;
+ bool eventFilter(QObject *, QEvent *);
+
+ void updatePalette( QComboBox * );
+ void updatePalette( QToolBar * );
+ void updatePalette( QMenuBar * );
+
+protected slots:
+ void slotDestroyed();
+ void paletteChanged();
+
+private:
+// Disable copy constructor and = operator
+ dotNETstyle( const dotNETstyle & );
+ dotNETstyle& operator=( const dotNETstyle & );
+ QStyle *winstyle;
+
+ bool pseudo3D, useTextShadows, roundedCorners, reverseLayout, kickerMode;
+
+ QValueList<QWidget*> m_widgets;
+};
+
+#endif
+
+// vim: set noet ts=4 sw=4:
diff --git a/styles/dotnet/dotnet.themerc b/styles/dotnet/dotnet.themerc
new file mode 100644
index 00000000..b7e5fde8
--- /dev/null
+++ b/styles/dotnet/dotnet.themerc
@@ -0,0 +1,118 @@
+[Misc]
+Name=.NET style
+Name[af]=.Net styl
+Name[br]=Giz .NET
+Name[bs]=.NET stil
+Name[ca]=Estil .NET
+Name[cs]=Styl .NET
+Name[cy]=Arddull .NET
+Name[da]=.NET-stil
+Name[de]=.NET-Stil
+Name[el]=Στυλ .NET
+Name[eo]=.NET-stilo
+Name[es]=Estilo .NET
+Name[et]=.NET stiil
+Name[eu]=.NET estiloa
+Name[fa]=سبک .NET
+Name[fi]=.NET-tyyli
+Name[fo]=.NET-snið
+Name[fr]=Style .NET
+Name[fy]=.NET-styl
+Name[ga]=Stíl .NET
+Name[gl]=Estilo .NET
+Name[he]=סגנון .NET
+Name[hi]=.NET शैली
+Name[hu]=.NET-stílus
+Name[is]=.NET stíll
+Name[it]=Stile .NET
+Name[ja]=.NET スタイル
+Name[ka]=.NET სტილი
+Name[lt]=.NET stilius
+Name[lv]=.NET stils
+Name[mk]=Стил .NET
+Name[mt]=Stil .NET
+Name[nb]=.NET-stil
+Name[nds]=.NET-Stil
+Name[ne]=.NET शैली
+Name[nl]=.NET-stijl
+Name[nn]=.NET-stil
+Name[pa]=.NET ਸ਼ੈਲੀ
+Name[pl]=Styl .NET
+Name[pt]=Estilo .NET
+Name[pt_BR]=Estilos Web
+Name[ro]=Stil .NET
+Name[ru]=Стиль .NET
+Name[sk]=Štýl .NET
+Name[sl]=Slog .NET
+Name[sr]=.NET стил
+Name[sr@Latn]=.NET stil
+Name[sv]=.NET-stil
+Name[ta]=.NET வித
+Name[tg]=Намуди .NET
+Name[th]=รูปแบบ .NET
+Name[tr]=.NET stili
+Name[uk]=Стиль ".NET"
+Name[ven]=Tshitaela tsha .NET
+Name[vi]=Kiểu .NET
+Name[xh]=Uhlobo lo Mnatha
+Name[zh_CN]=.NET 风格
+Name[zh_TW]=.NET 風格
+Name[zu]=.NET uhlobo
+Comment=Fast, clean, and minimalistic.
+Comment[af]=Vinnige, maak skoon, en minimalisties.
+Comment[bg]=Семпъл и изчистен стил, изискващ малко ресурси
+Comment[bs]=Brz, čist i minimalističan.
+Comment[ca]=Ràpid, net i minimalista.
+Comment[cs]=Rychlé, úhledné a minimalistické
+Comment[cy]=Cyflym, glan a lleiafsymiol.
+Comment[da]=Hurtig, ren og minimalistisk.
+Comment[de]=Schnell, sauber, minimalistisch
+Comment[el]=Γρήγορο, καθαρό, και μινιμαλιστικό.
+Comment[es]=Rápido, limpio y minimalista.
+Comment[et]=Kiire, lihtne ja minimalistlik
+Comment[eu]=Azkarra, garbia, eta minimalista.
+Comment[fa]=سریع، تمییز، و حداقل.
+Comment[fi]=Pieni, puhdas ja minimalistinen
+Comment[fo]=Skjótt og smátt.
+Comment[fr]=Rapide et dépouillé
+Comment[fy]=Fluch,skjin en minimalistysk
+Comment[gl]=Rápido, limpo e minimalista.
+Comment[he]=מהיר, נקי, ומינימליסטי.
+Comment[hi]=तेज, साफ तथा कम-से-कम
+Comment[hu]=Gyors, jól átlátható, egyszerű stílus
+Comment[is]=Hratt, einfalt, og naumhyggja.
+Comment[it]=Veloce, semplice e minimalistico
+Comment[ja]=速い, クリーン, ミニマリズム
+Comment[ka]=სწრაფი, სუფთა და სადა
+Comment[lt]=Greitas, švarus ir minimalistinis
+Comment[lv]=Ātrs, tīrs un minimāls.
+Comment[mk]=Брз, чист и минималистички.
+Comment[ms]=Cepat, bersih, dan minimalistik.
+Comment[mt]=Jgħaġġel, nadif u minimalist
+Comment[nb]=Rask, ren og minimal.
+Comment[nds]=Gau, oprüümt, minimaal.
+Comment[ne]=छिटो, सफा,र गौण
+Comment[nl]=Snel,schoon en minimalistisch
+Comment[nn]=Rask, enkel og minimalistisk.
+Comment[pl]=Szybki, bez przepychu wręcz minimalistyczny
+Comment[pt]=Rápido, limpo e minimalista.
+Comment[pt_BR]=Rápido, limpo, e minimalista.
+Comment[ro]=Rapid, clar şi minimal.
+Comment[ru]=Быстрая, простая и лёгкая
+Comment[sk]=Rýchly, jednoduchý a minimalistický.
+Comment[sl]=Hiter, čist in minimalističen slog
+Comment[sr]=Брз, чисти и минималистички
+Comment[sr@Latn]=Brz, čisti i minimalistički
+Comment[sv]=Snabb, ren och minimal
+Comment[ta]= வேகமான, சுத்தமான, குறைச்சலாக
+Comment[tg]=Тез, тоза ва сабук.
+Comment[th]=เร็ว, สะอาด และดูเรียบง่าย
+Comment[tr]=Hızlı ve küçük.
+Comment[uk]=Швидка, акуратна і без надміру.
+Comment[ven]=U tavhanya, u kulumaga, nau fhungudzanyana
+Comment[vi]=Nhanh, sạch, và gọn nhẹ
+Comment[zh_CN]=快速、整洁而且极简化。
+Comment[zh_TW]=快速,清楚和極簡化
+Comment[zu]=Okusheshayo,okuhlanzekile kanye nokuyingcosana.
+[KDE]
+WidgetStyle=dotNET
diff --git a/styles/phase/Makefile.am b/styles/phase/Makefile.am
new file mode 100644
index 00000000..47d15577
--- /dev/null
+++ b/styles/phase/Makefile.am
@@ -0,0 +1,22 @@
+AUTOMAKE_OPTIONS = foreign
+
+SUBDIRS = config
+
+KDE_CXXFLAGS = -DQT_PLUGIN
+
+INCLUDES = $(all_includes)
+
+styledir = $(kde_datadir)/kstyle/themes
+style_DATA = phase.themerc
+
+EXTRA_DIST = $(style_DATA)
+
+noinst_HEADERS = phasestyle.h bitmaps.h
+
+kde_style_LTLIBRARIES = phasestyle.la
+phasestyle_la_SOURCES = phasestyle.cpp
+phasestyle_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
+phasestyle_la_LIBADD = -lkdefx -lkdecore
+phasestyle_la_METASOURCES = AUTO
+
+DISTCLEANFILES = $(phasestyle_la_METASOURCES)
diff --git a/styles/phase/bitmaps.h b/styles/phase/bitmaps.h
new file mode 100644
index 00000000..d1b8c712
--- /dev/null
+++ b/styles/phase/bitmaps.h
@@ -0,0 +1,67 @@
+//////////////////////////////////////////////////////////////////////////////
+// bitmaps.h
+// -------------------
+// Bitmaps for Phase style
+// -------------------
+// Copyright (c) 2004 David Johnson
+// Please see the phasestyle.h file for copyright and license information.
+//////////////////////////////////////////////////////////////////////////////
+
+// Note: the "light" bits are drawn with midlight color
+
+// Arrows (6x6)
+
+static QBitmap uarrow;
+static const unsigned char uarrow_bits[] = {
+ 0x00, 0x0c, 0x1e, 0x3f, 0x3f, 0x00};
+
+static QBitmap darrow;
+static const unsigned char darrow_bits[] = {
+ 0x00, 0x3f, 0x3f, 0x1e, 0x0c, 0x00};
+
+static QBitmap larrow;
+static const unsigned char larrow_bits[] = {
+ 0x18, 0x1c, 0x1e, 0x1e, 0x1c, 0x18};
+
+static QBitmap rarrow;
+static const unsigned char rarrow_bits[] = {
+ 0x06, 0x0e, 0x1e, 0x1e, 0x0e, 0x06};
+
+// plus/minus "arrows"
+
+static QBitmap bplus;
+static const unsigned char bplus_bits[] = {
+ 0x0c, 0x0c, 0x3f, 0x3f, 0x0c, 0x0c};
+
+static QBitmap bminus;
+static const unsigned char bminus_bits[] = {
+ 0x00, 0x00, 0x3f, 0x3f, 0x00, 0x00};
+
+// checkmark (9x9)
+
+static QBitmap bcheck;
+static const unsigned char bcheck_bits[] = {
+ 0x00, 0x00, 0x80, 0x01, 0xc0, 0x01, 0xe0, 0x00, 0x73, 0x00, 0x3f, 0x00,
+ 0x1e, 0x00, 0x0c, 0x00, 0x00, 0x00};
+
+// expander arrows (9x9)
+
+static QBitmap dexpand;
+static const unsigned char dexpand_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static QBitmap rexpand;
+static const unsigned char rexpand_bits[] = {
+ 0x04, 0x00, 0x0c, 0x00, 0x1c, 0x00, 0x3c, 0x00, 0x7c, 0x00, 0x3c, 0x00,
+ 0x1c, 0x00, 0x0c, 0x00, 0x04, 0x00};
+
+// scrollbar doodads (4x4)
+
+static QBitmap doodad_mid;
+static const unsigned char doodad_mid_bits[] = {
+ 0x07, 0x01, 0x01, 0x00};
+
+static QBitmap doodad_light;
+static const unsigned char doodad_light_bits[] = {
+ 0x00, 0x08, 0x08, 0x0e};
diff --git a/styles/phase/config/Makefile.am b/styles/phase/config/Makefile.am
new file mode 100644
index 00000000..725d15a3
--- /dev/null
+++ b/styles/phase/config/Makefile.am
@@ -0,0 +1,12 @@
+INCLUDES = $(all_includes)
+
+noinst_HEADERS = phasestyleconfig.h
+
+kde_module_LTLIBRARIES = kstyle_phase_config.la
+kstyle_phase_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
+kstyle_phase_config_la_LIBADD = $(LIB_KDEUI)
+kstyle_phase_config_la_SOURCES = phasestyleconfig.cpp styledialog.ui
+kstyle_phase_config_la_METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kstyle_phase_config.pot
diff --git a/styles/phase/config/phasestyleconfig.cpp b/styles/phase/config/phasestyleconfig.cpp
new file mode 100644
index 00000000..8543214c
--- /dev/null
+++ b/styles/phase/config/phasestyleconfig.cpp
@@ -0,0 +1,111 @@
+//////////////////////////////////////////////////////////////////////////////
+// phasestyleconfig.cpp
+// -------------------
+// Config dialog for Phase widget style
+// -------------------
+// Copyright (c) 2004 David Johnson <[email protected]>
+// Please see the header file for copyright and license information.
+//////////////////////////////////////////////////////////////////////////////
+
+#include <qsettings.h>
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qwhatsthis.h>
+#include <klocale.h>
+#include <kglobal.h>
+
+#include "phasestyleconfig.h"
+#include "styledialog.h"
+
+//////////////////////////////////////////////////////////////////////////////
+// PhaseStyleConfig Class //
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+// PhaseStyleConfig()
+// ----------------
+// Constructor
+
+PhaseStyleConfig::PhaseStyleConfig(QWidget* parent) : StyleDialog(parent)
+{
+ KGlobal::locale()->insertCatalogue("kstyle_phase_config");
+
+ QSettings settings;
+ oldgradients =
+ settings.readBoolEntry("/phasestyle/Settings/gradients", true);
+ gradients->setChecked(oldgradients);
+ oldhighlights =
+ settings.readBoolEntry("/phasestyle/Settings/highlights", true);
+ highlights->setChecked(oldhighlights);
+
+ // connections
+ connect(gradients, SIGNAL(toggled(bool)),
+ this, SLOT(updateChanged()));
+ connect(highlights, SIGNAL(toggled(bool)),
+ this, SLOT(updateChanged()));
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ~PhaseStyleConfig()
+// -----------------
+// Destructor
+
+PhaseStyleConfig::~PhaseStyleConfig()
+{
+ KGlobal::locale()->removeCatalogue("kstyle_phase_config");
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// selectionChanged()
+// ------------------
+// Selection has changed
+
+void PhaseStyleConfig::updateChanged()
+{
+ bool update = false;
+
+ if ((gradients->isChecked() != oldgradients) ||
+ (highlights->isChecked() != oldhighlights)) {
+ update = true;
+ }
+
+ emit changed(update);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// save()
+// ------
+// Save the settings
+
+void PhaseStyleConfig::save()
+{
+ QSettings settings;
+ settings.writeEntry("/phasestyle/Settings/gradients",
+ gradients->isChecked());
+ settings.writeEntry("/phasestyle/Settings/highlights",
+ highlights->isChecked());
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// defaults()
+// ----------
+// Set to the defaults
+
+void PhaseStyleConfig::defaults()
+{
+ gradients->setChecked(true);
+ highlights->setChecked(true);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Plugin Stuff //
+//////////////////////////////////////////////////////////////////////////////
+
+extern "C"
+{
+ KDE_EXPORT QObject* allocate_kstyle_config(QWidget* parent) {
+ return(new PhaseStyleConfig(parent));
+ }
+}
+
+#include "phasestyleconfig.moc"
diff --git a/styles/phase/config/phasestyleconfig.h b/styles/phase/config/phasestyleconfig.h
new file mode 100644
index 00000000..8f15531c
--- /dev/null
+++ b/styles/phase/config/phasestyleconfig.h
@@ -0,0 +1,56 @@
+//////////////////////////////////////////////////////////////////////////////
+// phasestyleconfig.h
+// -------------------
+// Config dialog for Phase widget style
+// -------------------
+// Copyright (c) 2004 David Johnson <[email protected]>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef PHASESTYLECONFIG_H
+#define PHASESTYLECONFIG_H
+
+#include "styledialog.h"
+
+class KConfig;
+
+class PhaseStyleConfig : public StyleDialog
+{
+ Q_OBJECT
+public:
+ PhaseStyleConfig(QWidget* parent);
+ ~PhaseStyleConfig();
+
+signals:
+ void changed(bool);
+
+public slots:
+ void save();
+ void defaults();
+
+protected slots:
+ void updateChanged();
+
+private:
+ bool oldgradients;
+ bool oldhighlights;
+};
+
+#endif // PHASESTYLECONFIG_H
diff --git a/styles/phase/config/styledialog.ui b/styles/phase/config/styledialog.ui
new file mode 100644
index 00000000..2015003e
--- /dev/null
+++ b/styles/phase/config/styledialog.ui
@@ -0,0 +1,70 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>StyleDialog</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>StyleDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>217</width>
+ <height>103</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Style Dialog</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>stylebox</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="title">
+ <string>Style Settings</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>gradients</cstring>
+ </property>
+ <property name="text">
+ <string>Use &amp;gradients</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This option will draw buttons and several other widgets using a gradient texture</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>highlights</cstring>
+ </property>
+ <property name="text">
+ <string>Highlight on &amp;mouse hover</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This option will highlight buttons and several other widgets when the mouse cursor is over them</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+</widget>
+<tabstops>
+ <tabstop>gradients</tabstop>
+ <tabstop>highlights</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/styles/phase/phase.themerc b/styles/phase/phase.themerc
new file mode 100644
index 00000000..80856bc5
--- /dev/null
+++ b/styles/phase/phase.themerc
@@ -0,0 +1,86 @@
+[Misc]
+Name=Phase
+Name[br]=Prantadoù
+Name[ca]=Fase
+Name[el]=Φάση
+Name[eo]=Fazo
+Name[es]=Fase
+Name[et]=Faas
+Name[eu]=Fasea
+Name[fa]=گام
+Name[fi]=Vaihe
+Name[fy]=Faze
+Name[ga]=Pas
+Name[he]=קרני לייזר
+Name[hi]=फेज़
+Name[is]=Fasi
+Name[it]=Fase
+Name[ja]=位相
+Name[ka]=ფაზა
+Name[mk]=Фаза
+Name[ms]=Fasa
+Name[nb]=Fase
+Name[nds]=Phaas
+Name[ne]=चरण
+Name[nn]=Fase
+Name[pa]=ਪੜਾਅ
+Name[pl]=Faza
+Name[ru]=Фаза
+Name[sl]=Faza
+Name[sr]=Фаза
+Name[sr@Latn]=Faza
+Name[sv]=Fas
+Name[ta]=பகுதி
+Name[tr]=Faz
+Name[uk]=Фаза
+Name[vi]=Pha
+Name[zh_TW]=相
+ConfigPage=kstyle_phase_config
+Comment=Clean classical look
+Comment[bg]=Семпъл и изчистен стил
+Comment[bs]=Jednostavan klasični stil
+Comment[ca]=Un estil clàssic i net
+Comment[cs]=Klasický čistý vzhled
+Comment[da]=Rent klassisk udseende
+Comment[de]=Ein einfaches und klares Aussehen
+Comment[el]=Ένα απλό και κλασσικό στυλ
+Comment[es]=Un estilo clásico y claro
+Comment[et]=Lihtne klassikaline välimus
+Comment[eu]=Itxura garbi klasikoa
+Comment[fa]=ظاهر کلاسیک واضح
+Comment[fi]=Puhdas perinteinen tyyli
+Comment[fr]=Un style simple et propre
+Comment[fy]=In klassyk en moai uterlik
+Comment[gl]=Apariencia sinxela e clásica
+Comment[he]=סגנון פשוט ונקי
+Comment[hi]=साफ शास्त्रीय रूप
+Comment[hu]=Tiszta, egyszerű stílus
+Comment[is]=Einfaldur og hreinlegur stíll
+Comment[it]=Orologio classico
+Comment[ja]=単純で清潔なスタイル
+Comment[ka]=სადა და კლასიკური სტილი
+Comment[mk]=Чист класичен изглед
+Comment[ms]=Rupa klasik bersih
+Comment[nb]=Enkelt klassisk utseende
+Comment[nds]=Oprüümt klass'sch Utsehn
+Comment[ne]=सफा उत्कृष्ट ढाँचा
+Comment[nl]=Een klassiek en schoon uiterlijk
+Comment[nn]=Enkel og klassisk utsjånad
+Comment[pa]=ਸਾਫ਼ ਟਕਸਾਲੀ ਦਿੱਖ
+Comment[pl]=Czysty, klasyczny wygląd
+Comment[pt]=Um estilo clássico limpo
+Comment[pt_BR]=Uma aprência clássica limpa
+Comment[ru]=Простой классический стиль
+Comment[sk]=Jednoduchý klasický vzhľad
+Comment[sl]=Čist klasičen izgled
+Comment[sr]=Чист класичан изглед
+Comment[sr@Latn]=Čist klasičan izgled
+Comment[sv]=Ren och klassisk stil
+Comment[ta]=விசேஷ பார்வையைத் துடை
+Comment[tr]=Temiz ve klasik bir görünüm
+Comment[uk]=Акуратний, класичний стиль
+Comment[vi]=Sạch, kiểu dáng truyền thống
+Comment[zh_CN]=简洁经典的外观
+Comment[zh_TW]=乾淨的傳統外觀
+[KDE]
+WidgetStyle=Phase
diff --git a/styles/phase/phasestyle.cpp b/styles/phase/phasestyle.cpp
new file mode 100644
index 00000000..7ce112b2
--- /dev/null
+++ b/styles/phase/phasestyle.cpp
@@ -0,0 +1,2512 @@
+//////////////////////////////////////////////////////////////////////////////
+// phasestyle.cpp
+// -------------------
+// Qt/KDE widget style
+// -------------------
+// Copyright (c) 2004 David Johnson
+// Please see the header file for copyright and license information.
+//////////////////////////////////////////////////////////////////////////////
+//
+// Some miscellaneous notes
+//
+// Reimplemented scrollbar metric and drawing routines from KStyle to allow
+// better placement of subcontrols. This is because the subcontrols slightly
+// overlap to share part of their border.
+//
+// Menu and toolbars are painted with the background color by default. This
+// differs from the Qt default of giving them PaletteButton backgrounds.
+// Menubars have normal gradients, toolbars have reverse.
+//
+// Some toolbars are not part of a QMainWindows, such as in a KDE file dialog.
+// In these cases we treat the toolbar as "floating" and paint it flat.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <kdrawutil.h>
+#include <kpixmap.h>
+#include <kpixmapeffect.h>
+
+#include <qapplication.h>
+#include <qintdict.h>
+#include <qpainter.h>
+#include <qpointarray.h>
+#include <qsettings.h>
+#include <qstyleplugin.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qheader.h>
+#include <qmainwindow.h>
+#include <qmenubar.h>
+#include <qpopupmenu.h>
+#include <qprogressbar.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qscrollbar.h>
+#include <qslider.h>
+#include <qsplitter.h>
+#include <qtabbar.h>
+#include <qtabwidget.h>
+#include <qtoolbar.h>
+#include <qtoolbox.h>
+#include <qtoolbutton.h>
+
+#include "phasestyle.h"
+#include "bitmaps.h"
+
+static const char* QSPLITTERHANDLE = "QSplitterHandle";
+static const char* QTOOLBAREXTENSION = "QToolBarExtensionWidget";
+static const char* KTOOLBARWIDGET = "kde toolbar widget";
+
+// some convenient constants
+static const int ITEMFRAME = 1; // menu stuff
+static const int ITEMHMARGIN = 3;
+static const int ITEMVMARGIN = 0;
+static const int ARROWMARGIN = 6;
+static const int RIGHTBORDER = 6;
+static const int MINICONSIZE = 16;
+static const int CHECKSIZE = 9;
+static const int MAXGRADIENTSIZE = 64;
+
+static unsigned contrast = 110;
+
+
+//////////////////////////////////////////////////////////////////////////////
+// Construction, Destruction, Initialization //
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+// PhaseStyle()
+// -----------
+// Constructor
+
+PhaseStyle::PhaseStyle()
+ : KStyle(FilledFrameWorkaround | AllowMenuTransparency,
+ ThreeButtonScrollBar), hover_(0), hovertab_(0),
+ gradients_(QPixmap::defaultDepth() > 8), kicker_(false)
+{
+ QSettings settings;
+ if (gradients_) { // don't bother setting if already false
+ gradients_ =
+ settings.readBoolEntry("/phasestyle/Settings/gradients", true);
+ contrast = 100 + settings.readNumEntry("/Qt/KDE/contrast", 5);
+ }
+ highlights_ =
+ settings.readBoolEntry("/phasestyle/Settings/highlights", true);
+
+ gradients = new QMap<unsigned int, QIntDict<GradientSet> >;
+
+ reverse_ = QApplication::reverseLayout();
+
+ // create bitmaps
+ uarrow = QBitmap(6, 6, uarrow_bits, true);
+ uarrow.setMask(uarrow);
+ darrow = QBitmap(6, 6, darrow_bits, true);
+ darrow.setMask(darrow);
+ larrow = QBitmap(6, 6, larrow_bits, true);
+ larrow.setMask(larrow);
+ rarrow = QBitmap(6, 6, rarrow_bits, true);
+ rarrow.setMask(rarrow);
+ bplus = QBitmap(6, 6, bplus_bits, true);
+ bplus.setMask(bplus);
+ bminus = QBitmap(6, 6, bminus_bits, true);
+ bminus.setMask(bminus);
+ bcheck = QBitmap(9, 9, bcheck_bits, true);
+ bcheck.setMask(bcheck);
+ dexpand = QBitmap(9, 9, dexpand_bits, true);
+ dexpand.setMask(dexpand);
+ rexpand = QBitmap(9, 9, rexpand_bits, true);
+ rexpand.setMask(rexpand);
+ doodad_mid = QBitmap(4, 4, doodad_mid_bits, true);
+ doodad_light = QBitmap(4, 4, doodad_light_bits, true);
+}
+
+PhaseStyle::~PhaseStyle()
+{
+ delete gradients;
+ gradients = 0;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Polishing //
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+// polish()
+// --------
+// Initialize application specific
+
+void PhaseStyle::polish(QApplication* app)
+{
+ if (!qstrcmp(app->argv()[0], "kicker")) kicker_ = true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// polish()
+// --------
+// Initialize the appearance of a widget
+
+void PhaseStyle::polish(QWidget *widget)
+{
+ if (::qt_cast<QMenuBar*>(widget) ||
+ ::qt_cast<QPopupMenu*>(widget)) {
+ // anti-flicker optimization
+ widget->setBackgroundMode(NoBackground);
+ } else if (::qt_cast<QFrame*>(widget) ||
+ widget->inherits(QTOOLBAREXTENSION) ||
+ (!qstrcmp(widget->name(), KTOOLBARWIDGET))) {
+ // needs special handling on paint events
+ widget->installEventFilter(this);
+ } else if (highlights_ &&
+ (::qt_cast<QPushButton*>(widget) ||
+ ::qt_cast<QComboBox*>(widget) ||
+ ::qt_cast<QSpinWidget*>(widget) ||
+ ::qt_cast<QCheckBox*>(widget) ||
+ ::qt_cast<QRadioButton*>(widget) ||
+ ::qt_cast<QSlider*>(widget) ||
+ widget->inherits(QSPLITTERHANDLE))) {
+ // mouseover highlighting
+ widget->installEventFilter(this);
+ } else if (highlights_ && ::qt_cast<QTabBar*>(widget)) {
+ // highlighting needing mouse tracking
+ widget->setMouseTracking(true);
+ widget->installEventFilter(this);
+ }
+
+ KStyle::polish(widget);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// polish()
+// --------
+// Initialize the palette
+
+void PhaseStyle::polish(QPalette &pal)
+{
+ // clear out gradients on a color change
+ gradients->clear();
+
+ // lighten up a bit, so the look is not so "crisp"
+ if (QPixmap::defaultDepth() > 8) { // but not on low color displays
+ pal.setColor(QPalette::Disabled, QColorGroup::Dark,
+ pal.color(QPalette::Disabled, QColorGroup::Dark).light(contrast));
+ pal.setColor(QPalette::Active, QColorGroup::Dark,
+ pal.color(QPalette::Active, QColorGroup::Dark).light(contrast));
+ pal.setColor(QPalette::Inactive, QColorGroup::Dark,
+ pal.color(QPalette::Inactive, QColorGroup::Dark).light(contrast));
+ }
+
+ QStyle::polish(pal);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// unPolish()
+// ----------
+// Undo the initialization of a widget's appearance
+
+void PhaseStyle::unPolish(QWidget *widget)
+{
+ if (::qt_cast<QMenuBar*>(widget) ||
+ ::qt_cast<QPopupMenu*>(widget)) {
+ widget->setBackgroundMode(PaletteBackground);
+ } else if (::qt_cast<QFrame*>(widget) ||
+ widget->inherits(QTOOLBAREXTENSION) ||
+ (!qstrcmp(widget->name(), KTOOLBARWIDGET))) {
+ widget->removeEventFilter(this);
+ } else if (highlights_ && // highlighting
+ (::qt_cast<QPushButton*>(widget) ||
+ ::qt_cast<QComboBox*>(widget) ||
+ ::qt_cast<QSpinWidget*>(widget) ||
+ ::qt_cast<QCheckBox*>(widget) ||
+ ::qt_cast<QRadioButton*>(widget) ||
+ ::qt_cast<QSlider*>(widget) ||
+ widget->inherits(QSPLITTERHANDLE))) {
+ widget->removeEventFilter(this);
+ } else if (highlights_ && ::qt_cast<QTabBar*>(widget)) {
+ widget->setMouseTracking(false);
+ widget->removeEventFilter(this);
+ }
+
+ KStyle::unPolish(widget);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Drawing //
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+// drawPhaseGradient()
+// ------------------
+// Draw gradient
+
+void PhaseStyle::drawPhaseGradient(QPainter *painter,
+ const QRect &rect,
+ QColor color,
+ bool horizontal,
+ int px, int py,
+ int pw, int ph,
+ bool reverse) const
+{
+ if (!gradients_) {
+ painter->fillRect(rect, color);
+ return;
+ }
+
+ // px, py, pw, ph used for parent-relative pixmaps
+ int size;
+ if (horizontal)
+ size = (pw > 0) ? pw : rect.width();
+ else
+ size = (ph > 0) ? ph : rect.height();
+
+ if (size > MAXGRADIENTSIZE) { // keep it sensible
+ painter->fillRect(rect, color);
+ } else {
+ // lazy allocation
+ GradientSet *set = (*gradients)[color.rgb()][size];
+ if (!set) {
+ set = new GradientSet(color, size);
+ (*gradients)[color.rgb()].setAutoDelete(true);
+ (*gradients)[color.rgb()].insert(size, set);
+ }
+ painter->drawTiledPixmap(rect, *set->gradient(horizontal, reverse),
+ QPoint(px, py));
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawPhaseBevel()
+// ----------------
+// Draw the basic Phase bevel
+
+void PhaseStyle::drawPhaseBevel(QPainter *painter,
+ int x, int y, int w, int h,
+ const QColorGroup &group,
+ const QColor &fill,
+ bool sunken,
+ bool horizontal,
+ bool reverse) const
+{
+ int x2 = x + w - 1;
+ int y2 = y + h - 1;
+ painter->save();
+
+ painter->setPen(group.dark());
+ painter->drawRect(x, y, w, h);
+
+ painter->setPen(sunken ? group.mid() : group.midlight());
+ painter->drawLine(x+1, y+1, x2-2, y+1);
+ painter->drawLine(x+1, y+2, x+1, y2-2);
+
+ painter->setPen(sunken ? group.midlight() : group.mid());
+ painter->drawLine(x+2, y2-1, x2-1, y2-1);
+ painter->drawLine(x2-1, y+2, x2-1, y2-2);
+
+ painter->setPen(group.button());
+ painter->drawPoint(x+1, y2-1);
+ painter->drawPoint(x2-1, y+1);
+
+ if (sunken) {
+ // sunken bevels don't get gradients
+ painter->fillRect(x+2, y+2, w-4, h-4, fill);
+ } else {
+ drawPhaseGradient(painter, QRect(x+2, y+2, w-4, h-4), fill,
+ horizontal, 0, 0, w-4, h-4, reverse);
+ }
+ painter->restore();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawPhaseButton()
+// ----------------
+// Draw the basic Phase button
+
+void PhaseStyle::drawPhaseButton(QPainter *painter,
+ int x, int y, int w, int h,
+ const QColorGroup &group,
+ const QColor &fill,
+ bool sunken) const
+{
+ int x2 = x + w - 1;
+ int y2 = y + h - 1;
+
+ painter->setPen(group.midlight());
+ painter->drawLine(x+1, y2, x2, y2);
+ painter->drawLine(x2, y+1, x2, y2-1);
+
+ painter->setPen(group.mid());
+ painter->drawLine(x, y, x2-1, y);
+ painter->drawLine(x, y+1, x, y2-1);
+
+ painter->setPen(group.button());
+ painter->drawPoint(x, y2);
+ painter->drawPoint(x2, y);
+
+ drawPhaseBevel(painter, x+1, y+1, w-2, h-2, group, fill,
+ sunken, false, false);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawPhasePanel()
+// ----------------
+// Draw the basic Phase panel
+
+void PhaseStyle::drawPhasePanel(QPainter *painter,
+ int x, int y, int w, int h,
+ const QColorGroup &group,
+ bool sunken,
+ const QBrush *fill) const
+{
+ int x2 = x + w - 1;
+ int y2 = y + h - 1;
+ painter->save();
+
+ if (sunken) {
+ painter->setPen(group.dark());
+ painter->drawRect(x+1, y+1, w-2, h-2);
+ painter->setPen(group.midlight());
+ painter->drawLine(x+1, y2, x2, y2);
+ painter->drawLine(x2, y+1, x2, y2-1);
+ painter->setPen(group.mid());
+ painter->drawLine(x, y, x, y2-1);
+ painter->drawLine(x+1, y, x2-1, y);
+ painter->setPen(group.background());
+ painter->drawPoint(x, y2);
+ painter->drawPoint(x2, y);
+ } else {
+ painter->setPen(group.dark());
+ painter->drawRect(x, y, w, h);
+ painter->setPen(group.midlight());
+ painter->drawLine(x+1, y+1, x2-2, y+1);
+ painter->drawLine(x+1, y+2, x+1, y2-2);
+ painter->setPen(group.mid());
+ painter->drawLine(x+2, y2-1, x2-1, y2-1);
+ painter->drawLine(x2-1, y+2, x2-1, y2-2);
+ painter->setPen(group.background());
+ painter->drawPoint(x+1, y2-1);
+ painter->drawPoint(x2-1, y+1);
+ }
+
+ if (fill) {
+ painter->fillRect(x+2, y+2, w-4, h-4, fill->color());
+ }
+ painter->restore();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawPhaseTab()
+// -------------
+// Draw a Phase style tab
+
+void PhaseStyle::drawPhaseTab(QPainter *painter,
+ int x, int y, int w, int h,
+ const QColorGroup &group,
+ const QTabBar *bar,
+ const QStyleOption &option,
+ SFlags flags) const
+{
+ const QTabWidget *tabwidget;
+ bool selected = (flags & Style_Selected);
+ bool edge; // tab is at edge of bar
+ const int x2 = x + w - 1;
+ const int y2 = y + h - 1;
+
+ painter->save();
+
+ // what position is the tab?
+ if ((bar->count() == 1)
+ || (bar->indexOf(option.tab()->identifier()) == 0)) {
+ edge = true;
+ } else {
+ edge = false;
+ }
+
+ switch (QTabBar::Shape(bar->shape())) {
+ case QTabBar::RoundedAbove:
+ case QTabBar::TriangularAbove: {
+ // is there a corner widget?
+ tabwidget = ::qt_cast<QTabWidget*>(bar->parent());
+ if (edge && tabwidget
+ && tabwidget->cornerWidget(reverse_ ?
+ Qt::TopRight : Qt::TopLeft)) {
+ edge = false;
+ }
+
+ if (!selected) { // shorten
+ y += 2; h -= 2;
+ }
+ if (selected) {
+ painter->setPen(Qt::NoPen);
+ painter->fillRect(x+1, y+1, w-1, h-1,
+ group.brush(QColorGroup::Background));
+ } else {
+ drawPhaseGradient(painter, QRect(x+1, y+1, w-1, h-2),
+ (flags & Style_MouseOver)
+ ? group.background()
+ : group.background().dark(contrast),
+ false, 0, 0, 0, h*2, false);
+ }
+
+ // draw tab
+ painter->setPen(group.dark());
+ painter->drawLine(x, y, x, y2-2);
+ painter->drawLine(x+1, y, x2, y);
+ painter->drawLine(x2, y+1, x2, y2-2);
+
+ painter->setPen(group.mid());
+ painter->drawLine(x2-1, y+2, x2-1, y2-2);
+
+ painter->setPen(group.midlight());
+ painter->drawLine(x+1, y+1, x2-2, y+1);
+ if ((selected) || edge) painter->drawLine(x+1, y+2, x+1, y2-2);
+
+ // finish off bottom
+ if (selected) {
+ painter->setPen(group.dark());
+ painter->drawPoint(x, y2-1);
+ painter->drawPoint(x2, y2-1);
+
+ painter->setPen(group.midlight());
+ painter->drawPoint(x, y2);
+ painter->drawLine(x+1, y2-1, x+1, y2);
+ painter->drawPoint(x2, y2);
+
+ painter->setPen(group.mid());
+ painter->drawPoint(x2-1, y2-1);
+
+ if (!reverse_ && edge) {
+ painter->setPen(group.dark());
+ painter->drawLine(x, y2-1, x, y2);
+ painter->setPen(group.midlight());
+ painter->drawPoint(x+1, y2);
+ }
+ } else {
+ painter->setPen(group.dark());
+ painter->drawLine(x, y2-1, x2, y2-1);
+
+ painter->setPen(group.midlight());
+ painter->drawLine(x, y2, x2, y2);
+
+ if (!reverse_ && edge) {
+ painter->setPen(group.dark());
+ painter->drawLine(x, y2-1, x, y2);
+ }
+ }
+ if (reverse_ && edge) {
+ painter->setPen(group.dark());
+ painter->drawPoint(x2, y2);
+ painter->setPen(selected ? group.mid() : group.background());
+ painter->drawPoint(x2-1, y2);
+ }
+ break;
+ }
+
+ case QTabBar::RoundedBelow:
+ case QTabBar::TriangularBelow: {
+ // is there a corner widget?
+ tabwidget = ::qt_cast<QTabWidget*>(bar->parent());
+ if (edge && tabwidget
+ && tabwidget->cornerWidget(reverse_ ?
+ Qt::BottomRight : Qt::BottomLeft)) {
+ edge = false;
+ }
+
+ painter->setBrush((selected || (flags & Style_MouseOver))
+ ? group.background()
+ : group.background().dark(contrast));
+ painter->setPen(Qt::NoPen);
+ painter->fillRect(x+1, y+1, w-1, h-1, painter->brush());
+
+ // draw tab
+ painter->setPen(group.dark());
+ painter->drawLine(x, y+1, x, y2);
+ painter->drawLine(x+1, y2, x2, y2);
+ painter->drawLine(x2, y+1, x2, y2-1);
+
+ painter->setPen(group.mid());
+ painter->drawLine(x2-1, y+1, x2-1, y2-1);
+ painter->drawLine(x+2, y2-1, x2-1, y2-1);
+ painter->drawPoint(x, y);
+ painter->drawPoint(x2, y);
+
+ if ((selected) || edge) {
+ painter->setPen(group.midlight());
+ painter->drawLine(x+1, y+1, x+1, y2-2);
+ }
+
+ // finish off top
+ if (selected) {
+ if (!reverse_ && edge) {
+ painter->setPen(group.dark());
+ painter->drawPoint(x, y);
+ painter->setPen(group.midlight());
+ painter->drawPoint(x+1, y);
+ }
+ } else {
+ painter->setPen(group.dark());
+ painter->drawLine(x, y+1, x2, y+1);
+
+ painter->setPen(group.mid());
+ painter->drawLine(x, y, x2, y);
+
+ if (!reverse_ && edge) {
+ painter->setPen(group.dark());
+ painter->drawPoint(x, y);
+ }
+ }
+ if (reverse_ && edge) {
+ painter->setPen(group.dark());
+ painter->drawPoint(x2, y);
+ painter->setPen(group.mid());
+ painter->drawPoint(x2-1, y);
+ }
+ break;
+ }
+ }
+ painter->restore();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawPrimitive()
+// ---------------
+// Draw the primitive element
+
+void PhaseStyle::drawPrimitive(PrimitiveElement element,
+ QPainter *painter,
+ const QRect &rect,
+ const QColorGroup &group,
+ SFlags flags,
+ const QStyleOption &option) const
+{
+ // common locals
+ bool down = flags & Style_Down;
+ bool on = flags & Style_On;
+ bool depress = (down || on);
+ bool enabled = flags & Style_Enabled;
+ bool horiz = flags & Style_Horizontal;
+ bool mouseover = highlights_ && (flags & Style_MouseOver);
+ int x, y, w, h, x2, y2, n, cx, cy;
+ QPointArray parray;
+ QWidget* widget;
+
+ rect.rect(&x, &y, &w, &h);
+ x2 = rect.right();
+ y2 = rect.bottom();
+
+ switch(element) {
+ case PE_ButtonBevel:
+ case PE_ButtonDefault:
+ case PE_ButtonDropDown:
+ case PE_ButtonTool:
+ drawPhaseBevel(painter, x,y,w,h, group, group.button(),
+ depress, false, false);
+ break;
+
+ case PE_ButtonCommand:
+ drawPhaseButton(painter, x, y, w, h, group,
+ mouseover ?
+ group.button().light(contrast) :
+ group.button(), depress);
+ break;
+
+ case PE_FocusRect: {
+ QPen old = painter->pen();
+ painter->setPen(group.highlight().dark(contrast));
+
+ painter->drawRect(rect);
+
+ painter->setPen(old);
+ break;
+ }
+
+ case PE_HeaderSection: {
+ // covers kicker taskbar buttons and menu titles
+ QHeader* header = dynamic_cast<QHeader*>(painter->device());
+ widget =dynamic_cast<QWidget*>(painter->device());
+
+ if (header) {
+ horiz = (header->orientation() == Horizontal);
+ } else {
+ horiz = true;
+ }
+
+ if ((widget) && ((widget->inherits("QPopupMenu")) ||
+ (widget->inherits("KPopupTitle")))) {
+ // kicker/kdesktop menu titles
+ drawPhaseBevel(painter, x,y,w,h,
+ group, group.background(), depress, !horiz);
+ } else if (kicker_) {
+ // taskbar buttons (assuming no normal headers used in kicker)
+ if (depress) {
+ painter->setPen(group.dark());
+ painter->setBrush(group.brush(QColorGroup::Mid));
+ painter->drawRect(x-1, y-1, w+1, h+1);
+ }
+ else {
+ drawPhaseBevel(painter, x-1, y-1, w+1, h+1,
+ group, group.button(), false, !horiz, true);
+ }
+ } else {
+ // other headers
+ if (depress) {
+ painter->setPen(group.dark());
+ painter->setBrush(group.brush(QColorGroup::Mid));
+ painter->drawRect(x-1, y-1, w+1, h+1);
+ }
+ else {
+ drawPhaseBevel(painter, x-1, y-1, w+1, h+1, group,
+ group.background(), false, !horiz, true);
+ }
+ }
+ break;
+ }
+
+ case PE_HeaderArrow:
+ if (flags & Style_Up)
+ drawPrimitive(PE_ArrowUp, painter, rect, group, Style_Enabled);
+ else
+ drawPrimitive(PE_ArrowDown, painter, rect, group, Style_Enabled);
+ break;
+
+ case PE_ScrollBarAddPage:
+ case PE_ScrollBarSubPage:
+ if (h) { // has a height, thus visible
+ painter->fillRect(rect, group.mid());
+ painter->setPen(group.dark());
+ if (horiz) { // vertical
+ painter->drawLine(x, y, x2, y);
+ painter->drawLine(x, y2, x2, y2);
+ } else { // horizontal
+ painter->drawLine(x, y, x, y2);
+ painter->drawLine(x2, y, x2, y2);
+ }
+ }
+ break;
+
+ case PE_ScrollBarAddLine:
+ case PE_ScrollBarSubLine: {
+ drawPhaseBevel(painter, x, y, w, h,
+ group, group.button(), down, !horiz, true);
+
+ PrimitiveElement arrow = ((horiz) ?
+ ((element == PE_ScrollBarAddLine) ?
+ PE_ArrowRight : PE_ArrowLeft) :
+ ((element == PE_ScrollBarAddLine) ?
+ PE_ArrowDown : PE_ArrowUp));
+ if (down) { // shift arrow
+ switch (arrow) {
+ case PE_ArrowRight: x++; break;
+ case PE_ArrowLeft: x--; break;
+ case PE_ArrowDown: y++; break;
+ case PE_ArrowUp: y--; break;
+ default: break;
+ }
+ }
+
+ drawPrimitive(arrow, painter, QRect(x,y,h,w), group, flags);
+ break;
+ }
+
+ case PE_ScrollBarSlider:
+ drawPhaseBevel(painter, x, y, w, h, group, group.button(),
+ false, !horiz, true);
+ // draw doodads
+ cx = x + w/2 - 2; cy = y + h/2 - 2;
+ if (horiz && (w >=20)) {
+ for (n = -5; n <= 5; n += 5) {
+ kColorBitmaps(painter, group, cx+n, cy,
+ 0, &doodad_mid, &doodad_light, 0, 0, 0);
+ }
+ } else if (!horiz && (h >= 20)) {
+ for (n = -5; n <= 5; n += 5) {
+ kColorBitmaps(painter, group, cx, cy+n,
+ 0, &doodad_mid, &doodad_light, 0, 0, 0);
+ }
+ }
+ break;
+
+ case PE_Indicator:
+ drawPhasePanel(painter, x+1, y+1, w-2, h-2, group, true, enabled ?
+ &group.brush(QColorGroup::Base) :
+ &group.brush(QColorGroup::Background));
+
+ if (on) {
+ painter->setPen(mouseover
+ ? group.highlight().dark(contrast)
+ : group.dark());
+ painter->drawRect(x+4, y+4, w-8, h-8);
+ painter->fillRect(x+5, y+5, w-10, h-10,
+ group.brush(QColorGroup::Highlight));
+ } else if (mouseover) {
+ painter->setPen(group.highlight().dark(contrast));
+ painter->drawRect(x+4, y+4, w-8, h-8);
+ }
+ break;
+
+ case PE_IndicatorMask:
+ painter->fillRect(x+1, y+1, w-2, h-2, Qt::color1);
+ painter->setPen(Qt::color0);
+ break;
+
+ case PE_ExclusiveIndicator: {
+ // note that this requires an even size from pixelMetric
+ cx = (x + x2) / 2;
+ cy = (y + y2) / 2;
+
+ painter->setBrush(enabled
+ ? group.brush(QColorGroup::Base)
+ : group.brush(QColorGroup::Background));
+
+ painter->setPen(group.dark());
+ parray.putPoints(0, 8,
+ x+1,cy+1, x+1,cy, cx,y+1, cx+1,y+1,
+ x2-1,cy, x2-1,cy+1, cx+1,y2-1, cx,y2-1);
+ painter->drawConvexPolygon(parray, 0, 8);
+
+ painter->setPen(group.mid());
+ parray.putPoints(0, 4, x,cy, cx,y, cx+1,y, x2,cy);
+ painter->drawPolyline(parray, 0, 4);
+ painter->setPen(group.midlight());
+ parray.putPoints(0, 4, x2,cy+1, cx+1,y2, cx,y2, x,cy+1);
+ painter->drawPolyline(parray, 0, 4);
+
+ if (on) {
+ painter->setBrush(group.brush(QColorGroup::Highlight));
+ painter->setPen(mouseover
+ ? group.highlight().dark(contrast)
+ : group.dark());
+ parray.putPoints(0, 8,
+ x+4,cy+1, x+4,cy, cx,y+4, cx+1,y+4,
+ x2-4,cy, x2-4,cy+1, cx+1,y2-4, cx,y2-4);
+ painter->drawConvexPolygon(parray, 0, 8);
+ } else if (mouseover) {
+ painter->setPen(group.highlight().dark(contrast));
+ parray.putPoints(0, 9,
+ x+4,cy+1, x+4,cy, cx,y+4, cx+1,y+4,
+ x2-4,cy, x2-4,cy+1, cx+1,y2-4, cx,y2-4,
+ x+4,cy+1);
+ painter->drawPolyline(parray, 0, 9);
+ }
+ break;
+ }
+
+ case PE_ExclusiveIndicatorMask:
+ cx = (x + x2) / 2;
+ cy = (y + y2) / 2;
+ painter->setBrush(Qt::color1);
+ painter->setPen(Qt::color1);
+ parray.putPoints(0, 8,
+ x,cy+1, x,cy, cx,y, cx+1,y,
+ x2,cy, x2,cy+1, cx+1,y2, cx,y2);
+ painter->drawConvexPolygon(parray, 0, 8);
+ painter->setPen(Qt::color0);
+ break;
+
+ case PE_DockWindowResizeHandle:
+ drawPhasePanel(painter, x, y, w, h, group, false,
+ &group.brush(QColorGroup::Background));
+ break;
+
+ case PE_Splitter:
+ cx = x + w/2 - 2; cy = y + h/2 - 2;
+ painter->fillRect(rect,
+ (hover_ == painter->device())
+ ? group.background().light(contrast)
+ : group.background());
+
+ if (!horiz && (w >=20)) {
+ for (n = -5; n <= 5; n += 5) {
+ kColorBitmaps(painter, group, cx+n, cy,
+ 0, &doodad_mid, &doodad_light, 0, 0, 0);
+ }
+ } else if (horiz && (h >= 20)) {
+ for (n = -5; n <= 5; n += 5) {
+ kColorBitmaps(painter, group, cx, cy+n,
+ 0, &doodad_mid, &doodad_light, 0, 0, 0);
+ }
+ }
+ break;
+
+ case PE_Panel:
+ case PE_PanelLineEdit:
+ case PE_PanelTabWidget:
+ case PE_TabBarBase:
+ drawPhasePanel(painter, x, y, w, h, group, flags & Style_Sunken);
+ break;
+
+ case PE_PanelPopup:
+ case PE_WindowFrame:
+ drawPhasePanel(painter, x, y, w, h, group, false);
+ break;
+
+ case PE_GroupBoxFrame:
+ case PE_PanelGroupBox:
+ painter->setPen(group.dark());
+ painter->drawRect(rect);
+ break;
+
+ case PE_Separator:
+ painter->setPen(group.dark());
+ if (w < h)
+ painter->drawLine(w/2, y, w/2, y2);
+ else
+ painter->drawLine(x, h/2, x2, h/2);
+ break;
+
+ case PE_StatusBarSection:
+ painter->setPen(group.mid());
+ painter->drawLine(x, y, x2-1, y);
+ painter->drawLine(x, y+1, x, y2-1);
+ painter->setPen(group.midlight());
+ painter->drawLine(x+1, y2, x2, y2);
+ painter->drawLine(x2, y+1, x2, y2-1);
+ break;
+
+ case PE_PanelMenuBar:
+ case PE_PanelDockWindow:
+ if (kicker_ && (w == 2)) { // kicker handle separator
+ painter->setPen(group.mid());
+ painter->drawLine(x, y, x, y2);
+ painter->setPen(group.midlight());
+ painter->drawLine(x+1, y, x+1, y2);
+ } else if (kicker_ && (h == 2)) { // kicker handle separator
+ painter->setPen(group.mid());
+ painter->drawLine(x, y, x2, y);
+ painter->setPen(group.midlight());
+ painter->drawLine(x, y+1, x2, y+1);
+ } else {
+ --x; --y; ++w; ++h; // adjust rect so we can use bevel
+ drawPhaseBevel(painter, x, y, w, h,
+ group, group.background(), false, (w < h),
+ (element==PE_PanelDockWindow) ? true : false);
+ }
+ break;
+
+ case PE_DockWindowSeparator: {
+ widget = dynamic_cast<QWidget*>(painter->device());
+ bool flat = true;
+
+ if (widget && widget->parent() &&
+ widget->parent()->inherits("QToolBar")) {
+ QToolBar *toolbar = ::qt_cast<QToolBar*>(widget->parent());
+ if (toolbar) {
+ // toolbar not floating or in a QMainWindow
+ flat = flatToolbar(toolbar);
+ }
+ }
+
+ if (flat)
+ painter->fillRect(rect, group.background());
+ else
+ drawPhaseGradient(painter, rect, group.background(),
+ !(horiz), 0, 0, -1, -1, true);
+
+ if (horiz) {
+ int cx = w/2 - 1;
+ painter->setPen(group.mid());
+ painter->drawLine(cx, 0, cx, h-2);
+ if (!flat) painter->drawLine(0, h-1, w-1, h-1);
+
+ painter->setPen(group.midlight());
+ painter->drawLine(cx+1, 0, cx+1, h-2);
+ } else {
+ int cy = h/2 - 1;
+ painter->setPen(group.mid());
+ painter->drawLine(0, cy, w-2, cy);
+ if (!flat) painter->drawLine(w-1, 0, w-1, h-1);
+
+ painter->setPen(group.midlight());
+ painter->drawLine(0, cy+1, w-2, cy+1);
+ }
+ break;
+ }
+
+ case PE_SizeGrip: {
+ int sw = QMIN(h, w) - 1;
+ y = y2 - sw;
+
+ if (reverse_) {
+ x2 = x + sw;
+ for (int n = 0; n < 4; ++n) {
+ painter->setPen(group.dark());
+ painter->drawLine(x, y, x2, y2);
+ painter->setPen(group.midlight());
+ painter->drawLine(x, y+1, x2-1, y2);
+ y += 3;;
+ x2 -= 3;;
+ }
+ } else {
+ x = x2 - sw;
+ for (int n = 0; n < 4; ++n) {
+ painter->setPen(group.dark());
+ painter->drawLine(x, y2, x2, y);
+ painter->setPen(group.midlight());
+ painter->drawLine(x+1, y2, x2, y+1);
+ x += 3;
+ y += 3;
+ }
+ }
+
+ break;
+ }
+
+ case PE_CheckMark:
+ painter->setPen(group.text());
+ painter->drawPixmap(x+w/2-4, y+h/2-4, bcheck);
+ break;
+
+ case PE_SpinWidgetPlus:
+ case PE_SpinWidgetMinus:
+ if (enabled)
+ painter->setPen((flags & Style_Sunken)
+ ? group.midlight() : group.dark());
+ else
+ painter->setPen(group.mid());
+ painter->drawPixmap(x+w/2-3, y+h/2-3,
+ (element==PE_SpinWidgetPlus) ? bplus : bminus);
+ break;
+
+ case PE_SpinWidgetUp:
+ case PE_ArrowUp:
+ if (flags & Style_Enabled)
+ painter->setPen((flags & Style_Sunken)
+ ? group.midlight() : group.dark());
+ else
+ painter->setPen(group.mid());
+ painter->drawPixmap(x+w/2-3, y+h/2-3, uarrow);
+ break;
+
+ case PE_SpinWidgetDown:
+ case PE_ArrowDown:
+ if (enabled) painter->setPen((flags & Style_Sunken)
+ ? group.midlight() : group.dark());
+ else painter->setPen(group.mid());
+ painter->drawPixmap(x+w/2-3, y+h/2-3, darrow);
+ break;
+
+ case PE_ArrowLeft:
+ if (enabled) painter->setPen((flags & Style_Sunken)
+ ? group.midlight() : group.dark());
+ else painter->setPen(group.mid());
+ painter->drawPixmap(x+w/2-3, y+h/2-3, larrow);
+ break;
+
+ case PE_ArrowRight:
+ if (enabled) painter->setPen((flags & Style_Sunken)
+ ? group.midlight() : group.dark());
+ else painter->setPen(group.mid());
+ painter->drawPixmap(x+w/2-3, y+h/2-3, rarrow);
+ break;
+
+ default:
+ KStyle::drawPrimitive(element, painter, rect, group, flags, option);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawKStylePrimitive()
+// ---------------------
+// Draw the element
+
+void PhaseStyle::drawKStylePrimitive(KStylePrimitive element,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QColorGroup &group,
+ SFlags flags,
+ const QStyleOption &option) const
+{
+ bool horiz = flags & Style_Horizontal;
+ int x, y, w, h, x2, y2, n, cx, cy;
+
+ rect.rect(&x, &y, &w, &h);
+ x2 = rect.right();
+ y2 = rect.bottom();
+ cx = x + w/2;
+ cy = y + h/2;
+
+ switch (element) {
+ case KPE_ToolBarHandle:
+ cx-=2; cy-=2;
+ drawPhaseGradient(painter, rect, group.background(),
+ !horiz, 0, 0, w-1, h-1, true);
+ if (horiz) {
+ for (n = -5; n <= 5; n += 5) {
+ kColorBitmaps(painter, group, cx, cy+n,
+ 0, &doodad_mid, &doodad_light, 0, 0, 0);
+ }
+ painter->setPen(group.mid());
+ painter->drawLine(x, y2, x2, y2);
+ } else {
+ for (n = -5; n <= 5; n += 5) {
+ kColorBitmaps(painter, group, cx+n, cy,
+ 0, &doodad_mid, &doodad_light, 0, 0, 0);
+ }
+ painter->setPen(group.mid());
+ painter->drawLine(x2, y, x2, y2);
+ }
+ break;
+
+ //case KPE_DockWindowHandle:
+ case KPE_GeneralHandle:
+ cx-=2; cy-=2;
+ painter->fillRect(rect, group.brush(QColorGroup::Background));
+
+ if (horiz) {
+ for (n = -5; n <= 5; n += 5) {
+ kColorBitmaps(painter, group, cx, cy+n,
+ 0, &doodad_mid, &doodad_light, 0, 0, 0);
+ }
+ } else {
+ for (n = -5; n <= 5; n += 5) {
+ kColorBitmaps(painter, group, cx+n, cy,
+ 0, &doodad_mid, &doodad_light, 0, 0, 0);
+ }
+ }
+ break;
+
+ case KPE_ListViewExpander:
+ painter->setPen(group.mid());
+ if (flags & Style_On) {
+ painter->drawPixmap(x+w/2-4, y+h/2-4, rexpand);
+ } else {
+ painter->drawPixmap(x+w/2-4, y+h/2-4, dexpand);
+ }
+ break;
+
+ case KPE_ListViewBranch:
+ painter->setPen(group.mid());
+ if (flags & Style_Horizontal) {
+ painter->drawLine(x, cy, x2, cy);
+ } else {
+ painter->drawLine(cx, y, cx, y2);
+ }
+ break;
+
+ case KPE_SliderGroove: {
+ const QSlider* slider = ::qt_cast<const QSlider*>(widget);
+ if (slider) {
+ if (slider->orientation() == Horizontal) {
+ y = cy - 3;
+ h = 7;
+ } else {
+ x = cx - 3;
+ w = 7;
+ }
+ }
+ drawPhasePanel(painter, x, y, w, h, group, true,
+ &group.brush(QColorGroup::Mid));
+ break;
+ }
+
+ case KPE_SliderHandle: {
+ const QSlider* slider = ::qt_cast<const QSlider*>(widget);
+ if (slider) {
+ QColor color = (widget==hover_)
+ ? group.button().light(contrast)
+ : group.button();
+ if (slider->orientation() == Horizontal) {
+ drawPhaseBevel(painter, cx-5, y, 6, h, group, color,
+ false, false, false);
+ drawPhaseBevel(painter, cx, y, 6, h, group, color,
+ false, false, false);
+ } else {
+ drawPhaseBevel(painter, x, cy-5, w, 6, group, color,
+ false, true, false);
+ drawPhaseBevel(painter, x, cy, w, 6, group, color,
+ false, true, false);
+ }
+ }
+ break;
+ }
+
+ default:
+ KStyle::drawKStylePrimitive(element, painter, widget, rect,
+ group, flags, option);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawControl()
+// -------------
+// Draw the control
+
+void PhaseStyle::drawControl(ControlElement element,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QColorGroup &group,
+ SFlags flags,
+ const QStyleOption &option) const
+{
+ bool active, enabled, depress;
+ int x, y, w, h, x2, y2, dx;
+ QMenuItem *mi;
+ QIconSet::Mode mode;
+ QIconSet::State state;
+ QPixmap pixmap;
+
+ rect.rect(&x, &y, &w, &h);
+ x2 = rect.right();
+ y2 = rect.bottom();
+
+ switch (element) {
+ case CE_PushButton: {
+ depress = flags & (Style_Down | Style_On);
+ int bd = pixelMetric(PM_ButtonDefaultIndicator, widget) + 1;
+
+ if ((flags & Style_ButtonDefault) && !depress) {
+ drawPhasePanel(painter, x, y, w, h, group, true,
+ &group.brush(QColorGroup::Mid));
+ drawPhaseBevel(painter, x+bd, y+bd, w-bd*2, h-bd*2, group,
+ (widget==hover_)
+ ? group.button().light(contrast)
+ : group.button(),
+ false, false, false);
+ } else {
+ drawPhaseButton(painter, x, y, w, h, group,
+ (widget==hover_)
+ ? group.button().light(contrast)
+ : group.button(), depress);
+ }
+
+ if (flags & Style_HasFocus) { // draw focus
+ drawPrimitive(PE_FocusRect, painter,
+ subRect(SR_PushButtonFocusRect, widget),
+ group, flags);
+ }
+ break;
+ }
+
+ case CE_PushButtonLabel: {
+ const QPushButton* button = ::qt_cast<const QPushButton*>(widget);
+ if (!button) {
+ KStyle::drawControl(element, painter, widget, rect, group,
+ flags, option);
+ return;
+ }
+ active = button->isOn() || button->isDown();
+
+ if (active) { // shift contents
+ x++; y++;
+ flags |= Style_Sunken;
+ }
+
+ if (button->isMenuButton()) { // menu indicator
+ int dx = pixelMetric(PM_MenuButtonIndicator, widget);
+ drawPrimitive(PE_ArrowDown, painter,
+ QRect(x+w-dx-2, y+2, dx, h-4),
+ group, flags, option);
+ w -= dx;
+ }
+
+ if (button->iconSet() && !button->iconSet()->isNull()) { // draw icon
+ if (button->isEnabled()) {
+ if (button->hasFocus()) {
+ mode = QIconSet::Active;
+ } else {
+ mode = QIconSet::Normal;
+ }
+ } else {
+ mode = QIconSet::Disabled;
+ }
+
+ if (button->isToggleButton() && button->isOn()) {
+ state = QIconSet::On;
+ } else {
+ state = QIconSet::Off;
+ }
+
+ pixmap = button->iconSet()->pixmap(QIconSet::Small, mode, state);
+ if (button->text().isEmpty() && !button->pixmap()) {
+ painter->drawPixmap(x+w/2 - pixmap.width()/2,
+ y+h/2 - pixmap.height()/2, pixmap);
+ } else {
+ painter->drawPixmap(x+4, y+h/2 - pixmap.height()/2, pixmap);
+ }
+ x += pixmap.width() + 4;
+ w -= pixmap.width() + 4;
+ }
+
+ if (active || button->isDefault()) { // default button
+ for(int n=0; n<2; n++) {
+ drawItem(painter, QRect(x+n, y, w, h),
+ AlignCenter | ShowPrefix,
+ button->colorGroup(),
+ button->isEnabled(),
+ button->pixmap(),
+ button->text(), -1,
+ (button->isEnabled()) ?
+ &button->colorGroup().buttonText() :
+ &button->colorGroup().mid());
+ }
+ } else { // normal button
+ drawItem(painter, QRect(x, y, w, h),
+ AlignCenter | ShowPrefix,
+ button->colorGroup(),
+ button->isEnabled(),
+ button->pixmap(),
+ button->text(), -1,
+ (button->isEnabled()) ?
+ &button->colorGroup().buttonText() :
+ &button->colorGroup().mid());
+ }
+ break;
+ }
+
+ case CE_CheckBoxLabel:
+ case CE_RadioButtonLabel: {
+ const QButton *b = ::qt_cast<const QButton*>(widget);
+ if (!b) return;
+
+ int alignment = reverse_ ? AlignRight : AlignLeft;
+ drawItem(painter, rect, alignment | AlignVCenter | ShowPrefix,
+ group, flags & Style_Enabled, b->pixmap(), b->text());
+
+ // only draw focus if content (forms on html won't)
+ if ((flags & Style_HasFocus) && ((!b->text().isNull()) || b->pixmap())) {
+ drawPrimitive(PE_FocusRect, painter,
+ visualRect(subRect(SR_RadioButtonFocusRect,
+ widget), widget),
+ group, flags);
+ }
+ break;
+ }
+
+ case CE_DockWindowEmptyArea: {
+ const QToolBar *tb = ::qt_cast<const QToolBar*>(widget);
+ if (tb) {
+ // toolbar not floating or in a QMainWindow
+ if (flatToolbar(tb)) {
+ if (tb->backgroundMode() == PaletteButton)
+ // force default button color to background color
+ painter->fillRect(rect, group.background());
+ else
+ painter->fillRect(rect, tb->paletteBackgroundColor());
+ }
+ }
+ break;
+ }
+
+ case CE_MenuBarEmptyArea:
+ drawPhaseGradient(painter, QRect(x, y, w, h), group.background(),
+ (w<h), 0, 0, 0, 0, false);
+ break;
+
+ case CE_MenuBarItem: {
+ const QMenuBar *mbar = ::qt_cast<const QMenuBar*>(widget);
+ if (!mbar) {
+ KStyle::drawControl(element, painter, widget, rect, group,
+ flags, option);
+ return;
+ }
+ mi = option.menuItem();
+ QRect prect = mbar->rect();
+
+ if ((flags & Style_Active) && (flags & Style_HasFocus)) {
+ if (flags & Style_Down) {
+ drawPhasePanel(painter, x, y, w, h, group, true,
+ &group.brush(QColorGroup::Background));
+ } else {
+ drawPhaseBevel(painter, x, y, w, h,
+ group, group.background(),
+ false, false, false);
+ }
+ } else {
+ drawPhaseGradient(painter, rect, group.background(), false, x, y,
+ prect.width()-2, prect.height()-2, false);
+ }
+ drawItem(painter, rect,
+ AlignCenter | AlignVCenter |
+ DontClip | ShowPrefix | SingleLine,
+ group, flags & Style_Enabled,
+ mi->pixmap(), mi->text());
+ break;
+ }
+
+ case CE_PopupMenuItem: {
+ const QPopupMenu *popup = ::qt_cast<const QPopupMenu*>(widget);
+ if (!popup) {
+ KStyle::drawControl(element, painter, widget, rect, group,
+ flags, option);
+ return;
+ }
+
+ mi = option.menuItem();
+ if (!mi) {
+ painter->fillRect(rect, group.button());
+ break;
+ }
+
+ int tabwidth = option.tabWidth();
+ int checkwidth = option.maxIconWidth();
+ bool checkable = popup->isCheckable();
+ bool etchtext = styleHint(SH_EtchDisabledText);
+ active = flags & Style_Active;
+ enabled = mi->isEnabled();
+ QRect vrect;
+
+ if (checkable) checkwidth = QMAX(checkwidth, 20);
+
+ // draw background
+ if (active && enabled) {
+ painter->fillRect(x, y, w, h, group.highlight());
+ } else if (widget->erasePixmap() &&
+ !widget->erasePixmap()->isNull()) {
+ painter->drawPixmap(x, y, *widget->erasePixmap(), x, y, w, h);
+ } else {
+ painter->fillRect(x, y, w, h, group.background());
+ }
+
+ // draw separator
+ if (mi->isSeparator()) {
+ painter->setPen(group.dark());
+ painter->drawLine(x+checkwidth+1, y+1, x2-checkwidth-1, y+1);
+ painter->setPen(group.mid());
+ painter->drawLine(x+checkwidth, y, x2-checkwidth-1, y);
+ painter->drawPoint(x+checkwidth, y+1);
+ painter->setPen(group.midlight());
+ painter->drawLine(x+checkwidth+1, y2, x2-checkwidth, y2);
+ painter->drawPoint(x2-checkwidth, y2-1);
+ break;
+ }
+
+ // draw icon
+ if (mi->iconSet() && !mi->isChecked()) {
+ if (active)
+ mode = enabled ? QIconSet::Active : QIconSet::Disabled;
+ else
+ mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
+
+ pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode);
+ QRect pmrect(0, 0, pixmap.width(), pixmap.height());
+ vrect = visualRect(QRect(x, y, checkwidth, h), rect);
+ pmrect.moveCenter(vrect.center());
+ painter->drawPixmap(pmrect.topLeft(), pixmap);
+ }
+
+ // draw check
+ if (mi->isChecked()) {
+ int cx = reverse_ ? x+w - checkwidth : x;
+ drawPrimitive(PE_CheckMark, painter,
+ QRect(cx + ITEMFRAME, y + ITEMFRAME,
+ checkwidth - ITEMFRAME*2, h - ITEMFRAME*2),
+ group, Style_Default |
+ (active ? Style_Enabled : Style_On));
+ }
+
+ // draw text
+ int xm = ITEMFRAME + checkwidth + ITEMHMARGIN;
+ int xp = reverse_ ?
+ x + tabwidth + RIGHTBORDER + ITEMHMARGIN + ITEMFRAME - 1 :
+ x + xm;
+ int offset = reverse_ ? -1 : 1;
+ int tw = w - xm - tabwidth - ARROWMARGIN - ITEMHMARGIN * 3
+ - ITEMFRAME + 1;
+
+ painter->setPen(enabled ? (active ? group.highlightedText() :
+ group.buttonText()) : group.mid());
+
+ if (mi->custom()) { // draws own label
+ painter->save();
+ if (etchtext && !enabled && !active) {
+ painter->setPen(group.light());
+ mi->custom()->paint(painter, group, active, enabled,
+ xp+offset, y+ITEMVMARGIN+1,
+ tw, h-2*ITEMVMARGIN);
+ painter->setPen(group.mid());
+ }
+ mi->custom()->paint(painter, group, active, enabled,
+ xp, y+ITEMVMARGIN, tw, h-2*ITEMVMARGIN);
+ painter->restore();
+ }
+ else { // draw label
+ QString text = mi->text();
+
+ if (!text.isNull()) {
+ int t = text.find('\t');
+ int tflags = AlignVCenter | DontClip |
+ ShowPrefix | SingleLine |
+ (reverse_ ? AlignRight : AlignLeft);
+
+ if (t >= 0) {
+ int tabx = reverse_ ?
+ x + RIGHTBORDER + ITEMHMARGIN + ITEMFRAME :
+ x + w - tabwidth - RIGHTBORDER - ITEMHMARGIN
+ - ITEMFRAME;
+
+ // draw right label (accerator)
+ if (etchtext && !enabled) { // etched
+ painter->setPen(group.light());
+ painter->drawText(tabx+offset, y+ITEMVMARGIN+1,
+ tabwidth, h-2*ITEMVMARGIN,
+ tflags, text.mid(t+1));
+ painter->setPen(group.mid());
+ }
+ painter->drawText(tabx, y+ITEMVMARGIN,
+ tabwidth, h-2*ITEMVMARGIN,
+ tflags, text.mid(t+1));
+ text = text.left(t);
+ }
+
+ // draw left label
+ if (etchtext && !enabled) { // etched
+ painter->setPen(group.light());
+ painter->drawText(xp+offset, y+ITEMVMARGIN+1,
+ tw, h-2*ITEMVMARGIN,
+ tflags, text, t);
+ painter->setPen(group.mid());
+ }
+ painter->drawText(xp, y+ITEMVMARGIN,
+ tw, h-2*ITEMVMARGIN,
+ tflags, text, t);
+ }
+ else if (mi->pixmap()) { // pixmap as label
+ pixmap = *mi->pixmap();
+ if (pixmap.depth() == 1)
+ painter->setBackgroundMode(OpaqueMode);
+
+ dx = ((w - pixmap.width()) / 2) + ((w - pixmap.width()) % 2);
+ painter->drawPixmap(x+dx, y+ITEMFRAME, pixmap);
+
+ if (pixmap.depth() == 1)
+ painter->setBackgroundMode(TransparentMode);
+ }
+ }
+
+ if (mi->popup()) { // draw submenu arrow
+ PrimitiveElement arrow = reverse_ ? PE_ArrowLeft : PE_ArrowRight;
+ int dim = (h-2*ITEMFRAME) / 2;
+ vrect = visualRect(QRect(x + w - ARROWMARGIN - ITEMFRAME - dim,
+ y + h / 2 - dim / 2, dim, dim), rect);
+ drawPrimitive(arrow, painter, vrect, group,
+ enabled ? Style_Enabled : Style_Default);
+ }
+ break;
+ }
+
+ case CE_TabBarTab: {
+ const QTabBar* tab = ::qt_cast<const QTabBar*>(widget);
+ if (tab) {
+ if ((widget == hover_) && (option.tab() == hovertab_)) {
+ flags |= Style_MouseOver;
+ }
+ // this guy can get complicated, we we do it elsewhere
+ drawPhaseTab(painter, x, y, w, h, group, tab, option,
+ flags);
+ } else { // not a tabbar
+ KStyle::drawControl(element, painter, widget, rect, group,
+ flags, option);
+ return;
+ }
+ break;
+ }
+
+ case CE_ProgressBarGroove: {
+ drawPhasePanel(painter, x, y, w, h, group, true,
+ &group.brush(QColorGroup::Base));
+ break;
+ }
+
+ case CE_ProgressBarContents: {
+ const QProgressBar* pbar = ::qt_cast<const QProgressBar*>(widget);
+ if (!pbar) {
+ KStyle::drawControl(element, painter, widget, rect, group,
+ flags, option);
+ return;
+ }
+ subRect(SR_ProgressBarContents, widget).rect(&x, &y, &w, &h);
+
+ painter->setBrush(group.brush(QColorGroup::Highlight));
+ painter->setPen(group.dark());
+
+ if (!pbar->totalSteps()) {
+ // busy indicator
+ int bar = pixelMetric(PM_ProgressBarChunkWidth, widget) + 2;
+ int progress = pbar->progress() % ((w-bar) * 2);
+ if (progress > (w-bar)) progress = 2 * (w-bar) - progress;
+ painter->drawRect(x+progress+1, y+1, bar-2, h-2);
+ } else {
+ double progress = static_cast<double>(pbar->progress()) /
+ static_cast<double>(pbar->totalSteps());
+ dx = static_cast<int>(w * progress);
+ if (dx < 4) break;
+ if (reverse_) x += w - dx;
+ painter->drawRect(x+1, y+1, dx-2, h-2);
+ }
+ break;
+ }
+
+#if (QT_VERSION >= 0x030200)
+ case CE_ToolBoxTab: {
+ const QToolBox *box = ::qt_cast<const QToolBox*>(widget);
+ if (!box) {
+ KStyle::drawControl(element, painter, widget, rect, group,
+ flags, option);
+ return;
+ }
+
+ const int rx = x2 - 20;
+ const int cx = rx - h + 1;
+
+ QPointArray parray(6);
+ parray.putPoints(0, 6,
+ x-1,y, cx,y, rx-2,y2-2, x2+1,y2-2,
+ x2+1,y2+2, x-1,y2+2);
+
+ if (box->currentItem() && (flags & Style_Selected)) {
+ painter->setPen(group.dark());
+ painter->setBrush(box->currentItem()->paletteBackgroundColor());
+ painter->drawConvexPolygon(parray, 0, 6);
+ painter->setBrush(NoBrush);
+ } else {
+ painter->setClipRegion(parray, QPainter::CoordPainter);
+ drawPhaseGradient(painter, rect,
+ group.background(),
+ false, 0, 0, 0, h*2, false);
+ painter->setClipping(false);
+ painter->drawPolyline(parray, 0, 4);
+ }
+
+ parray.putPoints(0, 4, x,y+1, cx,y+1, rx-2,y2-1, x2,y2-1);
+ painter->setPen(group.midlight());
+ painter->drawPolyline(parray, 0, 4);
+
+ break;
+ }
+#endif
+
+ default:
+ KStyle::drawControl(element, painter, widget, rect, group,
+ flags, option);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawControlMask()
+// -----------------
+// Draw a bitmask for the element
+
+void PhaseStyle::drawControlMask(ControlElement element,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QStyleOption &option) const
+{
+ switch (element) {
+ case CE_PushButton:
+ painter->fillRect(rect, Qt::color1);
+ painter->setPen(Qt::color0);
+ break;
+
+ default:
+ KStyle::drawControlMask(element, painter, widget, rect, option);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawComplexControl()
+// --------------------
+// Draw a complex control
+
+void PhaseStyle::drawComplexControl(ComplexControl control,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QColorGroup &group,
+ SFlags flags,
+ SCFlags controls,
+ SCFlags active,
+ const QStyleOption &option) const
+{
+ bool down = flags & Style_Down;
+ bool on = flags & Style_On;
+ bool raised = flags & Style_Raised;
+ bool sunken = flags & Style_Sunken;
+ QRect subrect;
+ int x, y, w, h, x2, y2;
+ rect.rect(&x, &y, &w, &h);
+
+ switch (control) {
+ case CC_ComboBox: {
+ const QComboBox * combo = ::qt_cast<const QComboBox*>(widget);
+ if (!combo) {
+ KStyle::drawComplexControl(control, painter, widget, rect, group,
+ flags, controls, active, option);
+ return;
+ }
+
+ sunken = (active == SC_ComboBoxArrow);
+ drawPhaseButton(painter, x, y, w, h, group,
+ (widget==hover_)
+ ? group.button().light(contrast)
+ : group.button(), sunken);
+
+ if (controls & SC_ComboBoxArrow) { // draw arrow box
+ subrect = visualRect(querySubControlMetrics(CC_ComboBox, widget,
+ SC_ComboBoxArrow), widget);
+
+ subrect.rect(&x, &y, &w, &h);
+ int slot = QMAX(h/4, 6) + (h % 2);
+ drawPhasePanel(painter, x+3, y+(h/2)-(slot/2), w-6,
+ slot, group, true,
+ sunken ? &group.brush(QColorGroup::Midlight)
+ : &group.brush(QColorGroup::Mid));
+ }
+
+ if (controls & SC_ComboBoxEditField) { // draw edit box
+ if (combo->editable()) { // editable box
+ subrect = visualRect(querySubControlMetrics(CC_ComboBox,
+ widget, SC_ComboBoxEditField), widget);
+ x2 = subrect.right(); y2 = subrect.bottom();
+ painter->setPen(group.dark());
+ painter->drawLine(x2+1, y, x2+1, y2);
+ painter->setPen(group.midlight());
+ painter->drawLine(x2+2, y, x2+2, y2-1);
+ painter->setPen(group.button());
+ painter->drawPoint(x2+2, y2);
+ } else if (combo->hasFocus()) { // non editable box
+ subrect = visualRect(subRect(SR_ComboBoxFocusRect,
+ combo), widget);
+ drawPrimitive(PE_FocusRect, painter, subrect, group,
+ Style_FocusAtBorder,
+ QStyleOption(group.highlight()));
+ }
+ }
+
+ painter->setPen(group.buttonText()); // for subsequent text
+ break;
+ }
+
+ case CC_ScrollBar: {
+ // always a three button scrollbar
+ const QScrollBar *sb = ::qt_cast<const QScrollBar*>(widget);
+ if (!sb) {
+ KStyle::drawComplexControl(control, painter, widget, rect, group,
+ flags, controls, active, option);
+ return;
+ }
+
+ QRect srect;
+ bool horizontal = (sb->orientation() == Qt::Horizontal);
+ SFlags scrollflags = (horizontal ? Style_Horizontal : Style_Default);
+
+ if (sb->minValue() == sb->maxValue()) scrollflags |= Style_Default;
+ else scrollflags |= Style_Enabled;
+
+ // addline
+ if (controls & SC_ScrollBarAddLine) {
+ srect = querySubControlMetrics(control, widget,
+ SC_ScrollBarAddLine, option);
+ if (srect.isValid())
+ drawPrimitive(PE_ScrollBarAddLine, painter, srect, group,
+ scrollflags | ((active == SC_ScrollBarAddLine)
+ ? Style_Down : Style_Default));
+ }
+
+ // subline (two of them)
+ if (controls & SC_ScrollBarSubLine) {
+ // top/left subline
+ srect = querySubControlMetrics(control, widget,
+ SC_ScrollBarSubLine, option);
+ if (srect.isValid())
+ drawPrimitive(PE_ScrollBarSubLine, painter, srect, group,
+ scrollflags | ((active == SC_ScrollBarSubLine)
+ ? Style_Down : Style_Default));
+ // bottom/right subline
+ srect = querySubControlMetrics(control, widget,
+ SC_ScrollBarAddLine, option);
+ if (srect.isValid()) {
+ if (horizontal) srect.moveBy(-srect.width()+1, 0);
+ else srect.moveBy(0, -srect.height()+1);
+ drawPrimitive(PE_ScrollBarSubLine, painter, srect, group,
+ scrollflags | ((active == SC_ScrollBarSubLine)
+ ? Style_Down : Style_Default));
+ }
+ }
+
+ // addpage
+ if (controls & SC_ScrollBarAddPage) {
+ srect = querySubControlMetrics(control, widget,
+ SC_ScrollBarAddPage, option);
+ if (srect.isValid()) {
+ if (horizontal) srect.addCoords(1, 0, 1, 0);
+ else srect.addCoords(0, 1, 0, 1);
+ drawPrimitive(PE_ScrollBarAddPage, painter, srect, group,
+ scrollflags | ((active == SC_ScrollBarAddPage)
+ ? Style_Down : Style_Default));
+ }
+ }
+
+ // subpage
+ if (controls & SC_ScrollBarSubPage) {
+ srect = querySubControlMetrics(control, widget,
+ SC_ScrollBarSubPage, option);
+ if (srect.isValid()) {
+ drawPrimitive(PE_ScrollBarSubPage, painter, srect, group,
+ scrollflags | ((active == SC_ScrollBarSubPage)
+ ? Style_Down : Style_Default));
+ }
+ }
+
+ // slider
+ if (controls & SC_ScrollBarSlider) {
+ if (sb->minValue() == sb->maxValue()) {
+ // maxed out
+ srect = querySubControlMetrics(control, widget,
+ SC_ScrollBarGroove, option);
+ } else {
+ srect = querySubControlMetrics(control, widget,
+ SC_ScrollBarSlider, option);
+ }
+ if (srect.isValid()) {
+ if (horizontal) srect.addCoords(0, 0, 1, 0);
+ else srect.addCoords(0, 0, 0, 1);
+ drawPrimitive(PE_ScrollBarSlider, painter, srect, group,
+ scrollflags | ((active == SC_ScrollBarSlider)
+ ? Style_Down : Style_Default));
+ // focus
+ if (sb->hasFocus()) {
+ srect.addCoords(2, 2, -2, -2);
+ drawPrimitive(PE_FocusRect, painter, srect, group,
+ Style_Default);
+ }
+ }
+ }
+ break;
+ }
+
+ case CC_SpinWidget: {
+ const QSpinWidget *spin = ::qt_cast<const QSpinWidget*>(widget);
+ if (!spin) {
+ KStyle::drawComplexControl(control, painter, widget, rect, group,
+ flags, controls, active, option);
+ return;
+ }
+
+ PrimitiveElement element;
+
+ // draw frame
+ if (controls & SC_SpinWidgetFrame) {
+ drawPhasePanel(painter, x, y, w, h, group, true, NULL);
+ }
+
+ // draw button field
+ if (controls & SC_SpinWidgetButtonField) {
+ subrect = querySubControlMetrics(CC_SpinWidget, widget,
+ SC_SpinWidgetButtonField,
+ option);
+ if (reverse_) subrect.moveLeft(spin->upRect().left());
+ drawPhaseBevel(painter, subrect.x(), subrect.y(),
+ subrect.width(), subrect.height(), group,
+ (widget==hover_)
+ ? group.button().light(contrast)
+ : group.button(), false, false, false);
+ }
+
+ // draw up arrow
+ if (controls & SC_SpinWidgetUp) {
+ subrect = spin->upRect();
+
+ sunken = (active == SC_SpinWidgetUp);
+ if (spin->buttonSymbols() == QSpinWidget::PlusMinus)
+ element = PE_SpinWidgetPlus;
+ else
+ element = PE_SpinWidgetUp;
+
+ drawPrimitive(element, painter, subrect, group, flags
+ | ((active == SC_SpinWidgetUp)
+ ? Style_On | Style_Sunken : Style_Raised));
+ }
+
+ // draw down button
+ if (controls & SC_SpinWidgetDown) {
+ subrect = spin->downRect();
+
+ sunken = (active == SC_SpinWidgetDown);
+ if (spin->buttonSymbols() == QSpinWidget::PlusMinus)
+ element = PE_SpinWidgetMinus;
+ else
+ element = PE_SpinWidgetDown;
+
+ drawPrimitive(element, painter, subrect, group, flags
+ | ((active == SC_SpinWidgetDown)
+ ? Style_On | Style_Sunken : Style_Raised));
+ }
+ break;
+ }
+
+ case CC_ToolButton: {
+ const QToolButton *btn = ::qt_cast<const QToolButton*>(widget);
+ if (!btn) {
+ KStyle::drawComplexControl(control, painter, widget, rect, group,
+ flags, controls, active, option);
+ return;
+ }
+
+ QToolBar *toolbar;
+ bool horiz = true;
+ bool normal = !(down || on || raised); // normal button state
+
+ x2 = rect.right();
+ y2 = rect.bottom();
+
+ // check for QToolBar parent
+ if (btn->parent() && btn->parent()->inherits("QToolBar")) {
+ toolbar = ::qt_cast<QToolBar*>(btn->parent());
+ if (toolbar) {
+ horiz = (toolbar->orientation() == Qt::Horizontal);
+ if (normal) { // draw background
+ if (flatToolbar(toolbar)) {
+ // toolbar not floating or in a QMainWindow
+ painter->fillRect(rect, group.background());
+ } else {
+ drawPhaseGradient(painter, rect, group.background(),
+ !horiz, 0, 0,
+ toolbar->width()-3,
+ toolbar->height()-3, true);
+ painter->setPen(group.mid());
+ if (horiz) {
+ painter->drawLine(x, y2, x2, y2);
+ } else {
+ painter->drawLine(x2, y, x2, y2);
+ }
+ }
+ }
+ }
+ }
+ // check for QToolBarExtensionWidget parent
+ else if (btn->parent() &&
+ btn->parent()->inherits(QTOOLBAREXTENSION)) {
+ QWidget *extension;
+ if ((extension = ::qt_cast<QWidget*>(btn->parent()))) {
+ toolbar = ::qt_cast<QToolBar*>(extension->parent());
+ if (toolbar) {
+ horiz = (toolbar->orientation() == Qt::Horizontal);
+ if (normal) { // draw background
+ drawPhaseGradient(painter, rect, group.background(),
+ !horiz, 0, 0, toolbar->width()-3,
+ toolbar->height()-3, true);
+ }
+ }
+ }
+ }
+ // check for background pixmap
+ else if (normal && btn->parentWidget() &&
+ btn->parentWidget()->backgroundPixmap() &&
+ !btn->parentWidget()->backgroundPixmap()->isNull()) {
+ QPixmap pixmap = *(btn->parentWidget()->backgroundPixmap());
+ painter->drawTiledPixmap(rect, pixmap, btn->pos());
+ }
+ // everything else
+ else if (normal) {
+ // toolbutton not on a toolbar
+ painter->fillRect(rect, group.background());
+ }
+
+ // now draw active buttons
+ if (down || on) {
+ drawPhasePanel(painter, x, y, w, h, group, true,
+ &group.brush(QColorGroup::Button));
+ } else if (raised) {
+ drawPhaseBevel(painter, x, y, w, h, group, group.button(),
+ false, !horiz, true);
+ }
+ painter->setPen(group.text());
+ break;
+ }
+
+ default:
+ KStyle::drawComplexControl(control, painter, widget, rect, group,
+ flags, controls, active, option);
+ break;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// drawComplexControlMask()
+// ------------------------
+// Draw a bitmask for the control
+
+void PhaseStyle::drawComplexControlMask(ComplexControl control,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QStyleOption &option) const
+{
+ switch (control) {
+ case CC_ComboBox:
+ case CC_ToolButton: {
+ painter->fillRect(rect, Qt::color1);
+ painter->setPen(Qt::color0);
+ break;
+ }
+
+ default:
+ KStyle::drawComplexControlMask(control,painter,widget,rect,option);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// pixelMetric()
+// -------------
+// Get the pixel metric for metric
+
+int PhaseStyle::pixelMetric(PixelMetric metric, const QWidget *widget) const
+{
+ // not using widget's font, so that all metrics are uniform
+ int em = QMAX(QApplication::fontMetrics().strikeOutPos() * 3, 17);
+
+ switch (metric) {
+ case PM_DefaultFrameWidth:
+ return 2;
+
+ case PM_ButtonDefaultIndicator: // size of default indicator
+ return 2;
+
+ case PM_ButtonMargin: // Space betweeen frame and label
+ return 3;
+
+ case PM_TabBarTabOverlap: // Amount of tab overlap
+ return 1;
+
+ case PM_TabBarTabHSpace: // extra tab spacing
+ return 24;
+
+ case PM_TabBarTabVSpace:
+ if (const QTabBar *tb = ::qt_cast<const QTabBar*>(widget)) {
+ if (tb->shape() == QTabBar::RoundedAbove) {
+ return 10;
+ } else {
+ return 6;
+ }
+ }
+ return 0;
+
+ case PM_ExclusiveIndicatorWidth: // radiobutton size
+ case PM_ExclusiveIndicatorHeight:
+ case PM_IndicatorWidth: // checkbox size
+ case PM_IndicatorHeight:
+ case PM_CheckListButtonSize: // checkbox size in qlistview items
+ case PM_ScrollBarExtent: // base width of a vertical scrollbar
+ return em & 0xfffe;
+
+ case PM_SplitterWidth: // width of spitter
+ return (em / 3) & 0xfffe;
+
+ case PM_ScrollBarSliderMin: // minimum length of slider
+ return em * 2;
+
+ case PM_SliderThickness: // slider thickness
+ case PM_SliderControlThickness:
+ return em;
+
+ default:
+ return KStyle::pixelMetric(metric, widget);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// subRect()
+// ---------
+// Return subrect for the widget in logical coordinates
+
+QRect PhaseStyle::subRect(SubRect rect, const QWidget *widget) const
+{
+ switch (rect) {
+ case SR_ComboBoxFocusRect: {
+ QRect r = querySubControlMetrics(CC_ComboBox, widget,
+ SC_ComboBoxEditField);
+ r.addCoords(1, 1,-1,-1);
+ return r;
+ }
+
+ default:
+ return KStyle::subRect(rect, widget);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// querySubControlMetrics()
+// ------------------------
+// Get metrics for subcontrols of complex controls
+
+QRect PhaseStyle::querySubControlMetrics(ComplexControl control,
+ const QWidget *widget,
+ SubControl subcontrol,
+ const QStyleOption &option) const
+{
+ QRect rect;
+
+ const int fw = pixelMetric(PM_DefaultFrameWidth, widget);
+ int w = widget->width(), h = widget->height();
+ int xc;
+
+ switch (control) {
+
+ case CC_ComboBox: {
+ xc = h; // position between edit and arrow
+
+ switch (subcontrol) {
+ case SC_ComboBoxFrame: // total combobox area
+ rect = widget->rect();
+ break;
+
+ case SC_ComboBoxArrow: // the right side
+ rect.setRect(w-xc, fw, xc-fw, h-(fw*2));
+ break;
+
+ case SC_ComboBoxEditField: // the left side
+ rect.setRect(fw, fw, w-xc-fw-1, h-(fw*2));
+ break;
+
+ case SC_ComboBoxListBoxPopup: // the list popup box
+ rect = option.rect();
+ break;
+
+ default:
+ break;
+ }
+ break;
+ }
+
+ case CC_ScrollBar: {
+ const QScrollBar *sb = ::qt_cast<const QScrollBar*>(widget);
+ if (!sb) break;
+
+ bool horizontal = (sb->orientation() == Qt::Horizontal);
+ rect = KStyle::querySubControlMetrics(control, widget,
+ subcontrol, option);
+
+ // adjust the standard metrics so controls can "overlap"
+ if (subcontrol == SC_ScrollBarGroove) {
+ if (horizontal) rect.addCoords(-1, 0, 1, 0);
+ else rect.addCoords(0, -1, 0, 1);
+ }
+ break;
+ }
+
+ case CC_SpinWidget: {
+ bool odd = widget->height() % 2;
+ xc = (h * 3 / 4) + odd; // position between edit and arrows
+
+ switch (subcontrol) {
+ case SC_SpinWidgetButtonField:
+ rect.setRect(w-xc, 1, xc-1, h-2);
+ break;
+
+ case SC_SpinWidgetEditField:
+ rect.setRect(fw, fw, w-xc-fw, h-(fw*2));
+ break;
+
+ case SC_SpinWidgetFrame:
+ rect = widget->rect();
+ break;
+
+ case SC_SpinWidgetUp:
+ rect.setRect(w-xc, (h/2)-(odd ? 6 : 7), xc-1, 6);
+ break;
+
+ case SC_SpinWidgetDown:
+ rect.setRect(w-xc, (h/2)+1, xc-1, odd ? 7 : 6);
+ break;
+
+ default:
+ break;
+ }
+ break;
+ }
+
+ default:
+ rect = KStyle::querySubControlMetrics(control, widget, subcontrol,
+ option);
+ }
+
+ return rect;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// sizeFromContents()
+// ------------------
+// Returns the size of widget based on the contentsize
+
+QSize PhaseStyle::sizeFromContents(ContentsType contents,
+ const QWidget* widget,
+ const QSize &contentsize,
+ const QStyleOption &option ) const
+{
+ int w = contentsize.width();
+ int h = contentsize.height();
+
+ switch (contents) {
+ case CT_PushButton: {
+ const QPushButton* button = ::qt_cast<const QPushButton*>(widget);
+ if (!button) {
+ return KStyle::sizeFromContents(contents, widget, contentsize,
+ option);
+ }
+ int margin = pixelMetric(PM_ButtonMargin, widget)
+ + pixelMetric(PM_DefaultFrameWidth, widget) + 4;
+
+ w += margin + 6; // add room for bold font
+ h += margin;
+
+ // standard width and heights
+ if (button->isDefault() || button->autoDefault()) {
+ if (w < 80 && !button->pixmap()) w = 80;
+ }
+ if (h < 22) h = 22;
+ return QSize(w, h);
+ }
+
+ case CT_PopupMenuItem: {
+ if (!widget || option.isDefault()) return contentsize;
+ const QPopupMenu *popup = ::qt_cast<const QPopupMenu*>(widget);
+ if (!popup) {
+ return KStyle::sizeFromContents(contents, widget, contentsize,
+ option);
+ }
+ QMenuItem *item = option.menuItem();
+
+ if (item->custom()) {
+ w = item->custom()->sizeHint().width();
+ h = item->custom()->sizeHint().height();
+ if (!item->custom()->fullSpan())
+ h += ITEMVMARGIN*2 + ITEMFRAME*2;
+ } else if (item->widget()) { // a menu item that is a widget
+ w = contentsize.width();
+ h = contentsize.height();
+ } else if (item->isSeparator()) {
+ w = h = 3;
+ } else {
+ if (item->pixmap()) {
+ h = QMAX(h, item->pixmap()->height() + ITEMFRAME*2);
+ } else {
+ h = QMAX(h, MINICONSIZE + ITEMFRAME*2);
+ h = QMAX(h, popup->fontMetrics().height()
+ + ITEMVMARGIN*2 + ITEMFRAME*2);
+ }
+ if (item->iconSet())
+ h = QMAX(h, item->iconSet()->
+ pixmap(QIconSet::Small, QIconSet::Normal).height()
+ + ITEMFRAME*2);
+ }
+
+ if (!item->text().isNull() && item->text().find('\t') >= 0)
+ w += 12;
+ else if (item->popup())
+ w += 2 * ARROWMARGIN;
+
+ if (option.maxIconWidth() || popup->isCheckable()) {
+ w += QMAX(option.maxIconWidth(),
+ QIconSet::iconSize(QIconSet::Small).width())
+ + ITEMHMARGIN*2;
+ }
+ w += RIGHTBORDER;
+ return QSize(w, h);
+ }
+
+ default:
+ return KStyle::sizeFromContents(contents, widget, contentsize,
+ option);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Miscellaneous //
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+// flatToolbar()
+// -------------
+// Is the toolbar "flat"
+
+bool PhaseStyle::flatToolbar(const QToolBar *toolbar) const
+{
+ if (!toolbar) return true; // not on a toolbar
+ if (!toolbar->isMovingEnabled()) return true; // immobile toolbars are flat
+ if (!toolbar->area()) return true; // not docked
+ if (toolbar->place() == QDockWindow::OutsideDock) return true; // ditto
+ if (!toolbar->mainWindow()) return true; // not in a main window
+ return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eventFilter()
+// -------------
+// Grab events we are interested in. Most of this routine is to handle the
+// exceptions to the normal styling rules.
+
+bool PhaseStyle::eventFilter(QObject *object, QEvent *event)
+{
+ if (KStyle::eventFilter(object, event)) return true;
+ if (!object->isWidgetType()) return false;
+
+ bool horiz;
+ int x, y, w, h;
+ QFrame *frame;
+ QToolBar *toolbar;
+ QWidget *widget;
+
+ // painting events
+ if (event->type() == QEvent::Paint) {
+ // make sure we do the most specific stuff first
+
+ // KDE Toolbar Widget
+ // patch by Daniel Brownlees <[email protected]>
+ if (object->parent() && !qstrcmp(object->name(), KTOOLBARWIDGET)) {
+ if (0 == (widget = ::qt_cast<QWidget*>(object))) return false;
+ QWidget *parent = ::qt_cast<QWidget*>(object->parent());
+ int px = widget->x(), py = widget->y();
+ // find the toolbar
+ while (parent && parent->parent()
+ && !::qt_cast<QToolBar*>(parent)) {
+ px += parent->x();
+ py += parent->y();
+ parent = ::qt_cast<QWidget*>(parent->parent());
+ }
+ if (!parent) return false;
+ widget->rect().rect(&x, &y, &w, &h);
+ QRect prect = parent->rect();
+
+ toolbar = ::qt_cast<QToolBar*>(parent);
+ horiz = (toolbar) ? (toolbar->orientation() == Qt::Horizontal)
+ : (prect.height() < prect.width());
+ QPainter painter(widget);
+ if (flatToolbar(toolbar)) {
+ painter.fillRect(widget->rect(),
+ parent->colorGroup().background());
+ } else {
+ drawPhaseGradient(&painter, widget->rect(),
+ parent->colorGroup().background(),
+ !horiz, px, py,
+ prect.width(), prect.height(), true);
+ if (horiz && (h==prect.height()-2)) {
+ painter.setPen(parent->colorGroup().mid());
+ painter.drawLine(x, h-1, w-1, h-1);
+ } else if (!horiz && (w==prect.width()-2)) {
+ painter.setPen(parent->colorGroup().mid());
+ painter.drawLine(w-1, y, w-1, h-1);
+ }
+ }
+ }
+
+ // QToolBarExtensionWidget
+ else if (object && object->isWidgetType() && object->parent() &&
+ (toolbar = ::qt_cast<QToolBar*>(object->parent()))) {
+ if (0 == (widget = ::qt_cast<QWidget*>(object))) return false;
+ horiz = (toolbar->orientation() == Qt::Horizontal);
+ QPainter painter(widget);
+ widget->rect().rect(&x, &y, &w, &h);
+ // draw the extension
+ drawPhaseGradient(&painter, widget->rect(),
+ toolbar->colorGroup().background(),
+ !horiz, x, y, w-1, h-1, true);
+ if (horiz) {
+ painter.setPen(toolbar->colorGroup().dark());
+ painter.drawLine(w-1, 0, w-1, h-1);
+ painter.setPen(toolbar->colorGroup().mid());
+ painter.drawLine(w-2, 0, w-2, h-2);
+ painter.drawLine(x, h-1, w-2, h-1);
+ painter.drawLine(x, y, x, h-2);
+ painter.setPen(toolbar->colorGroup().midlight());
+ painter.drawLine(x+1, y, x+1, h-2);
+ } else {
+ painter.setPen(toolbar->colorGroup().dark());
+ painter.drawLine(0, h-1, w-1, h-1);
+ painter.setPen(toolbar->colorGroup().mid());
+ painter.drawLine(0, h-2, w-2, h-2);
+ painter.drawLine(w-1, y, w-1, h-2);
+ painter.drawLine(x, y, w-2, y);
+ painter.setPen(toolbar->colorGroup().midlight());
+ painter.drawLine(x, y+1, w-2, y+1);
+ }
+ }
+
+ // QFrame lines (do this guy last)
+ else if (0 != (frame = ::qt_cast<QFrame*>(object))) {
+ QFrame::Shape shape = frame->frameShape();
+ switch (shape) {
+ case QFrame::HLine:
+ case QFrame::VLine: {
+ // NOTE: assuming lines have no content
+ QPainter painter(frame);
+ frame->rect().rect(&x, &y, &w, &h);
+ painter.setPen(frame->colorGroup().dark());
+ if (shape == QFrame::HLine) {
+ painter.drawLine(0, h/2, w, h/2);
+ } else if (shape == QFrame::VLine) {
+ painter.drawLine(w/2, 0, w/2, h);
+ }
+ return true;
+ }
+ default:
+ break;
+ }
+ }
+
+ } else if (highlights_) { // "mouseover" events
+ if (::qt_cast<QPushButton*>(object) ||
+ ::qt_cast<QComboBox*>(object) ||
+ ::qt_cast<QSpinWidget*>(object) ||
+ ::qt_cast<QCheckBox*>(object) ||
+ ::qt_cast<QRadioButton*>(object) ||
+ ::qt_cast<QSlider*>(object) ||
+ object->inherits(QSPLITTERHANDLE)) {
+ if (event->type() == QEvent::Enter) {
+ if (0 != (widget = ::qt_cast<QWidget*>(object)) &&
+ widget->isEnabled()) {
+ hover_ = widget;
+ widget->repaint(false);
+ }
+ } else if (event->type() == QEvent::Leave) {
+ if (0 != (widget = ::qt_cast<QWidget*>(object))) {
+ hover_ = 0;
+ widget->repaint(false);
+ }
+ }
+ } else if (::qt_cast<QTabBar*>(object)) { // special case for qtabbar
+ if (event->type() == QEvent::Enter) {
+ if (0 != (widget = ::qt_cast<QWidget*>(object)) &&
+ widget->isEnabled()) {
+ hover_ = widget;
+ hovertab_ = 0;;
+ widget->repaint(false);
+ }
+ } else if (event->type() == QEvent::Leave) {
+ if (0 != (widget = ::qt_cast<QWidget*>(object))) {
+ hover_ = 0;
+ hovertab_ = 0;;
+ widget->repaint(false);
+ }
+ } else if (event->type() == QEvent::MouseMove) {
+ QTabBar *tabbar;
+ if (0 != (tabbar = ::qt_cast<QTabBar*>(object))) {
+ QMouseEvent *me;
+ if (0 != (me = dynamic_cast<QMouseEvent*>(event))) {
+ QTab *tab = tabbar->selectTab(me->pos());
+ if (hovertab_ != tab) {
+ hovertab_ = tab;
+ tabbar->repaint(false);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// GradientSet //
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+// GradientSet()
+// -------------
+// Constructor
+
+GradientSet::GradientSet(const QColor &color, int size)
+ : color_(color), size_(size)
+{
+ for (int n=0; n<GradientTypeCount; ++n) set[n] = 0;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ~GradientSet()
+// --------------
+// Destructor
+
+GradientSet::~GradientSet()
+{
+ for (int n=0; n<GradientTypeCount; ++n) if (set[n]) delete set[n];
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// gradient()
+// ----------
+// Return the appropriate gradient pixmap
+
+KPixmap* GradientSet::gradient(bool horizontal, bool reverse)
+{
+ GradientType type;
+
+ if (horizontal) {
+ type = (reverse) ? HorizontalReverse : Horizontal;
+ } else {
+ type = (reverse) ? VerticalReverse : Vertical;
+ }
+
+ // lazy allocate
+ if (!set[type]) {
+ set[type] = new KPixmap();
+ switch (type) {
+ case Horizontal:
+ set[type]->resize(size_, 16);
+ KPixmapEffect::gradient(*set[type],
+ color_.light(contrast),
+ color_.dark(contrast),
+ KPixmapEffect::HorizontalGradient);
+ break;
+
+ case HorizontalReverse:
+ set[type]->resize(size_, 16);
+ KPixmapEffect::gradient(*set[type],
+ color_.dark(contrast),
+ color_.light(contrast),
+ KPixmapEffect::HorizontalGradient);
+ break;
+
+ case Vertical:
+ set[type]->resize(16, size_);
+ KPixmapEffect::gradient(*set[type],
+ color_.light(contrast),
+ color_.dark(contrast),
+ KPixmapEffect::VerticalGradient);
+ break;
+
+ case VerticalReverse:
+ set[type]->resize(16, size_);
+ KPixmapEffect::gradient(*set[type],
+ color_.dark(contrast),
+ color_.light(contrast),
+ KPixmapEffect::VerticalGradient);
+ break;
+
+ default:
+ break;
+ }
+ }
+ return (set[type]);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Plugin Stuff //
+//////////////////////////////////////////////////////////////////////////////
+
+class PhaseStylePlugin : public QStylePlugin
+{
+ public:
+ PhaseStylePlugin();
+ QStringList keys() const;
+ QStyle *create(const QString &key);
+};
+
+PhaseStylePlugin::PhaseStylePlugin() : QStylePlugin() { ; }
+
+QStringList PhaseStylePlugin::keys() const
+{
+ return QStringList() << "Phase";
+}
+
+QStyle* PhaseStylePlugin::create(const QString& key)
+{
+ if (key.lower() == "phase")
+ return new PhaseStyle();
+ return 0;
+}
+
+KDE_Q_EXPORT_PLUGIN(PhaseStylePlugin)
+
+#include "phasestyle.moc"
diff --git a/styles/phase/phasestyle.h b/styles/phase/phasestyle.h
new file mode 100644
index 00000000..f8d4b7e0
--- /dev/null
+++ b/styles/phase/phasestyle.h
@@ -0,0 +1,182 @@
+//////////////////////////////////////////////////////////////////////////////
+// phasestyle.h
+// -------------------
+// Qt/KDE widget style
+// -------------------
+// Copyright (c) 2004 David Johnson <[email protected]>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef PHASESTYLE_H
+#define PHASESTYLE_H
+
+#include <kstyle.h>
+#include <qcolor.h>
+
+class KPixmap;
+
+class GradientSet
+{
+public:
+ enum GradientType {
+ Horizontal,
+ Vertical,
+ HorizontalReverse,
+ VerticalReverse,
+ GradientTypeCount
+ };
+
+ GradientSet(const QColor &color, int size);
+ ~GradientSet();
+
+ KPixmap* gradient(bool horizontal, bool reverse);
+
+private:
+ KPixmap *set[GradientTypeCount];
+ QColor color_;
+ int size_;
+};
+
+class PhaseStyle : public KStyle
+{
+ Q_OBJECT
+public:
+ PhaseStyle();
+ virtual ~PhaseStyle();
+
+ void polish(QApplication* app);
+ void polish(QWidget *widget);
+ void polish(QPalette &pal);
+ void unPolish(QWidget *widget);
+
+ void drawPrimitive(PrimitiveElement element,
+ QPainter *painter,
+ const QRect &rect,
+ const QColorGroup &group,
+ SFlags flags = Style_Default,
+ const QStyleOption &option = QStyleOption::Default) const;
+
+ void drawKStylePrimitive(KStylePrimitive element,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QColorGroup &group,
+ SFlags flags = Style_Default,
+ const QStyleOption &option = QStyleOption::Default) const;
+
+ void drawControl(ControlElement element,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QColorGroup &group,
+ SFlags flags = Style_Default,
+ const QStyleOption &option = QStyleOption::Default) const;
+
+ void drawControlMask(ControlElement element,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QStyleOption &option = QStyleOption::Default) const;
+
+ void drawComplexControl(ComplexControl control,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QColorGroup &group,
+ SFlags flags = Style_Default,
+ SCFlags controls = SC_All,
+ SCFlags active = SC_None,
+ const QStyleOption &option = QStyleOption::Default) const;
+
+ void drawComplexControlMask(ComplexControl control,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QStyleOption &option = QStyleOption::Default) const;
+
+ int pixelMetric(PixelMetric metric,
+ const QWidget *widget = 0) const;
+
+ QRect subRect(SubRect rect, const QWidget *widget) const;
+
+ QRect querySubControlMetrics(ComplexControl control,
+ const QWidget *widget,
+ SubControl subcontrol,
+ const QStyleOption &option = QStyleOption::Default) const;
+
+ QSize sizeFromContents(ContentsType contents,
+ const QWidget *widget,
+ const QSize &contentsize,
+ const QStyleOption& option = QStyleOption::Default) const;
+
+private:
+ PhaseStyle(const PhaseStyle &);
+ PhaseStyle& operator=(const PhaseStyle &);
+
+ void drawPhaseBevel(QPainter *painter,
+ int x, int y, int w, int h,
+ const QColorGroup &group,
+ const QColor &fill,
+ bool sunken=false,
+ bool horizontal=true,
+ bool reverse=false) const;
+
+ void drawPhaseButton(QPainter *painter,
+ int x, int y, int w, int h,
+ const QColorGroup &group,
+ const QColor &fill,
+ bool sunken=false) const;
+
+ void drawPhasePanel(QPainter *painter,
+ int x, int y, int w, int h,
+ const QColorGroup &group,
+ bool sunken=false,
+ const QBrush *fill=NULL) const;
+
+ void drawPhaseTab(QPainter *painter,
+ int x, int y, int w, int h,
+ const QColorGroup &group,
+ const QTabBar *bar,
+ const QStyleOption &option,
+ const SFlags flags) const;
+
+ void drawPhaseGradient(QPainter *painter,
+ const QRect &rect,
+ QColor color,
+ bool horizontal,
+ int px=0, int py=0,
+ int pw=-1, int ph=-1,
+ bool reverse=false) const;
+
+ bool flatToolbar(const QToolBar *toolbar) const;
+
+ bool eventFilter(QObject *object, QEvent *event);
+
+private:
+ QWidget *hover_;
+ QTab *hovertab_;
+ QMap<unsigned int, QIntDict<GradientSet> > * gradients;
+ bool gradients_;
+ bool highlights_;
+ bool reverse_;
+ bool kicker_;
+};
+
+#endif // PHASESTYLE_H