summaryrefslogtreecommitdiff
path: root/library/lightstyle.cpp
Side-by-side diff
Diffstat (limited to 'library/lightstyle.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/lightstyle.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/library/lightstyle.cpp b/library/lightstyle.cpp
index f18bdca..3bd1623 100644
--- a/library/lightstyle.cpp
+++ b/library/lightstyle.cpp
@@ -1,70 +1,70 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "lightstyle.h"
-#if QT_VERSION < 300
+#if QT_VERSION < 0x030000
#define INCLUDE_MENUITEM_DEF
#include "qmenubar.h"
#include "qapplication.h"
#include "qpainter.h"
#include "qpalette.h"
#include "qframe.h"
#include "qpushbutton.h"
#include "qdrawutil.h"
#include "qscrollbar.h"
#include "qtabbar.h"
#include "qguardedptr.h"
#include "qlayout.h"
#include "qlineedit.h"
class LightStylePrivate
{
public:
LightStylePrivate()
: hoverWidget(0), ref(1), savePalette(0)
{
}
QGuardedPtr<QWidget> hoverWidget;
QPalette oldPalette, hoverPalette;
int ref;
QPoint mousePos;
QPalette *savePalette;
};
static LightStylePrivate *singleton = 0;
LightStyle::LightStyle()
: QWindowsStyle()
{
if (! singleton) {
singleton = new LightStylePrivate;
QPalette pal = QApplication::palette();
singleton->oldPalette = pal;
QColor bg = pal.color(QPalette::Active, QColorGroup::Background);
QColor prelight;
if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128)
@@ -114,114 +114,114 @@ QSize LightStyle::scrollBarExtent() const
int LightStyle::buttonDefaultIndicatorWidth() const
{
return 2;
}
int LightStyle::sliderThickness() const
{
return 16;
}
int LightStyle::sliderLength() const
{
return 13;
}
int LightStyle::buttonMargin() const
{
return 4;
}
QSize LightStyle::exclusiveIndicatorSize() const
{
return QSize(13, 13);
}
int LightStyle::defaultFrameWidth() const
{
return 2;
}
QSize LightStyle::indicatorSize() const
{
return QSize(13, 13);
}
void LightStyle::polish(QWidget *widget)
{
if (widget->inherits("QPushButton"))
widget->installEventFilter(this);
-#if QT_VERSION >= 300
+#if QT_VERSION >= 0x030000
if (widget->inherits("QLineEdit")) {
QLineEdit *lineedit = (QLineEdit *) widget;
lineedit->setFrameShape(QFrame::StyledPanel);
lineedit->setLineWidth(2);
}
#endif
QWindowsStyle::polish(widget);
}
void LightStyle::unPolish(QWidget *widget)
{
if (widget->inherits("QPushButton"))
widget->removeEventFilter(this);
-#if QT_VERSION >= 300
+#if QT_VERSION >= 0x030000
if (widget->inherits("QLineEdit")) {
QLineEdit *lineedit = (QLineEdit *) widget;
lineedit->setLineWidth(1);
lineedit->setFrameShape(QFrame::WinPanel);
}
#endif
QWindowsStyle::unPolish(widget);
}
void LightStyle::polish(QApplication *app)
{
QPalette pal = app->palette();
QColorGroup active(pal.color(QPalette::Active,
QColorGroup::Foreground), // foreground
pal.color(QPalette::Active,
QColorGroup::Button), // button
pal.color(QPalette::Active,
QColorGroup::Background).light(), // light
pal.color(QPalette::Active,
QColorGroup::Background).dark(175), // dark
pal.color(QPalette::Active,
QColorGroup::Background).dark(110), // mid
pal.color(QPalette::Active,
QColorGroup::Text), // text
pal.color(QPalette::Active,
QColorGroup::BrightText), // bright text
pal.color(QPalette::Active,
QColorGroup::Base), // base
pal.color(QPalette::Active,
QColorGroup::Background)), // background
disabled(pal.color(QPalette::Disabled,
QColorGroup::Foreground), // foreground
pal.color(QPalette::Disabled,
QColorGroup::Button), // button
pal.color(QPalette::Disabled,
QColorGroup::Background).light(), // light
pal.color(QPalette::Disabled,
QColorGroup::Background).dark(), // dark
pal.color(QPalette::Disabled,
QColorGroup::Background).dark(110), // mid
pal.color(QPalette::Disabled,
QColorGroup::Text), // text
pal.color(QPalette::Disabled,
@@ -369,114 +369,114 @@ void LightStyle::drawButton(QPainter *p, int x, int y, int w, int h,
p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left
p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top
if (sunken)
p->setPen(g.light());
else
p->setPen(g.mid());
p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1
p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1
p->restore();
}
void LightStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g,
bool sunken, const QBrush *fill)
{
drawButton(p, x, y, w, h, g, sunken, fill);
}
void LightStyle::getButtonShift(int &x, int &y) const
{
x = y = 0;
}
void LightStyle::drawComboButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool,
bool editable, bool,
const QBrush *fill)
{
drawButton(p, x, y, w, h, g, FALSE, fill);
if (editable) {
QRect r = comboButtonRect(x, y, w, h);
qDrawShadePanel(p, r.x() - 1, r.y() - 1,
r.width() + defaultFrameWidth(),
r.height() + defaultFrameWidth(),
g, TRUE);
}
int indent = ((y + h) / 2) - 3;
int xpos = x;
-#if QT_VERSION >= 300
+#if QT_VERSION >= 0x030000
if( QApplication::reverseLayout() )
xpos += indent;
else
#endif
xpos += w - indent - 5;
drawArrow(p, Qt::DownArrow, TRUE, xpos, indent, 5, 5, g, TRUE, fill);
}
QRect LightStyle::comboButtonRect( int x, int y, int w, int h ) const
{
QRect r(x + 3, y + 3, w - 6, h - 6);
int indent = ((y + h) / 2) - 3;
r.setRight(r.right() - indent - 10);
-#if QT_VERSION >= 300
+#if QT_VERSION >= 0x030000
if( QApplication::reverseLayout() )
r.moveBy( indent + 10, 0 );
#endif
return r;
}
QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h ) const
{
return comboButtonRect(x, y, w, h);
}
void LightStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
int lw, const QBrush *fill)
{
if (lw >= 2) {
if ( fill )
p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill);
QPen oldpen = p->pen();
// frame
p->setPen(g.dark());
p->drawLine(x, y + 2, x, y + h - 3); // left
p->drawLine(x + 2, y, x + w - 3, y); // top
p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right
p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom
p->drawPoint(x + 1, y + 1);
p->drawPoint(x + 1, y + h - 2);
p->drawPoint(x + w - 2, y + 1);
p->drawPoint(x + w - 2, y + h - 2);
// bevel
if (sunken)
p->setPen(g.mid());
else
p->setPen(g.light());
p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left
p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top
if (sunken)
p->setPen(g.light());
else
p->setPen(g.mid());