summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qs60style.cpp72
-rw-r--r--src/gui/styles/qs60style.h8
-rw-r--r--src/gui/styles/qs60style_stub.cpp131
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp25
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp4
-rw-r--r--src/gui/styles/styles.pri4
6 files changed, 178 insertions, 66 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 45bcc00..e28403b 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -1765,52 +1765,31 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget);
QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget);
- //todo: move the vertical spacing stuff into subElementRect
- const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing);
QStyleOptionMenuItem optionCheckBox;
//Regardless of checkbox visibility, make room for it, this mirrors native implementation,
//where text and icon placement is static regardless of content of menu item.
- const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing);
optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem);
optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth));
optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight));
+
+ const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing);
+ //The vertical spacing is doubled; it needs one spacing to separate checkbox from
+ //highlight and then it needs one to separate it whatever is shown after it (text/icon/both).
+ const int moveByX = optionCheckBox.rect.width() + 2 * vSpacing;
optionCheckBox.rect.moveCenter(QPoint(
- optionCheckBox.rect.center().x(),
+ optionCheckBox.rect.center().x() + moveByX >> 1,
menuItem->rect.center().y()));
- const int moveByX = optionCheckBox.rect.width() + vSpacing +
- pixelMetric(PM_DefaultFrameWidth);
- if (optionMenuItem.direction == Qt::LeftToRight) {
- if (iconRect.isValid()) {
- iconRect.translate(moveByX, 0);
- iconRect.setWidth(iconRect.width() + vSpacing);
- }
- if (textRect.isValid()) {
- textRect.translate(moveByX, 0);
- textRect.setWidth(textRect.width() - moveByX - vSpacing);
- }
- optionCheckBox.rect.translate(vSpacing + pixelMetric(PM_DefaultFrameWidth), hSpacing >> 1);
- } else {
- if (textRect.isValid())
- textRect.setWidth(textRect.width() - moveByX);
- if (iconRect.isValid()) {
- iconRect.setWidth(iconRect.width() + vSpacing);
- iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0);
- }
+
+ if (optionMenuItem.direction != Qt::LeftToRight)
optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0);
- }
+
const bool selected = (option->state & State_Selected) && (option->state & State_Enabled);
if (selected) {
- const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2;
- int start; int end;
- if (QApplication::layoutDirection() == Qt::LeftToRight) {
- start = optionMenuItem.rect.left() + spacing;
- end = qMax(textRect.right(), iconRect.right() + spacing);
- } else {
- start = qMax(spacing, qMin(textRect.left(), iconRect.left() - spacing));
- end = optionMenuItem.rect.right() - spacing;
- }
+ const int spacing = ignoreCheckMark ? (vSpacing + QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth)) : 0;
+ const int start = optionMenuItem.rect.left() + spacing;
+ const int end = optionMenuItem.rect.right() - spacing;
//-1 adjustment to avoid highlight being on top of possible separator item
const QRect highlightRect = QRect(
QPoint(start, option->rect.top()),
@@ -3025,20 +3004,38 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
pixelMetric(PM_SmallIconSize, opt, widget);
ret = menuItem->rect;
+ QRect checkBoxRect = checkable ? menuItem->rect : QRect();
+ if (checkable) {
+ checkBoxRect.setWidth(pixelMetric(PM_IndicatorWidth));
+ checkBoxRect.setHeight(pixelMetric(PM_IndicatorHeight));
+ }
+
+ const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing);
+ //The vertical spacing is doubled; it needs one spacing to separate checkbox from
+ //highlight and then it needs one to separate it whatever is shown after it (text/icon/both).
+ const int moveByX = checkBoxRect.width() + 2 * vSpacing;
+
if (element == SE_ItemViewItemDecoration) {
if (menuItem->icon.isNull()) {
ret = QRect();
} else {
if (menuItem->direction == Qt::RightToLeft)
- ret.translate(ret.width() - indicatorWidth, 0);
+ ret.translate(ret.width() - indicatorWidth - moveByX, 0);
+ else
+ ret.translate(moveByX, 0);
ret.setWidth(indicatorWidth);
}
} else {
- if (!menuItem->icon.isNull())
+ if (!menuItem->icon.isNull()) {
if (menuItem->direction == Qt::LeftToRight)
ret.adjust(indicatorWidth, 0, 0, 0);
else
ret.adjust(0, 0, -indicatorWidth, 0);
+ }
+ if (menuItem->direction == Qt::LeftToRight)
+ ret.adjust(moveByX, 0, 0, 0);
+ else
+ ret.adjust(0, 0, -moveByX, 0);
// Make room for submenu indicator
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){
@@ -3116,6 +3113,11 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
case SE_CheckBoxFocusRect:
ret = opt->rect;
break;
+ case SE_ProgressBarLabel:
+ case SE_ProgressBarContents:
+ case SE_ProgressBarGroove:
+ ret = opt->rect;
+ break;
default:
ret = QCommonStyle::subElementRect(element, opt, widget);
}
diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h
index c878538..f588d9f 100644
--- a/src/gui/styles/qs60style.h
+++ b/src/gui/styles/qs60style.h
@@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-#if !defined(QT_NO_STYLE_S60)
-
//Public custom pixel metrics values.
//These can be used to fetch custom pixel metric value from outside QS60Style.
enum {
@@ -91,14 +89,14 @@ public:
#endif
bool event(QEvent *e);
-#ifndef Q_WS_S60
+#ifndef Q_OS_SYMBIAN
static QStringList partKeys();
static QStringList colorListKeys();
void setS60Theme(const QHash<QString, QPicture> &parts,
const QHash<QPair<QString , int>, QColor> &colors);
bool loadS60ThemeFromBlob(const QString &blobFile);
bool saveS60ThemeToBlob(const QString &blobFile) const;
-#endif // !Q_WS_S60
+#endif // !Q_OS_SYMBIAN
protected Q_SLOTS:
QIcon standardIconImplementation(
@@ -113,8 +111,6 @@ private:
friend class QApplicationPrivate;
};
-#endif // QT_NO_STYLE_S60
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/styles/qs60style_stub.cpp b/src/gui/styles/qs60style_stub.cpp
new file mode 100644
index 0000000..a3a5b9d
--- /dev/null
+++ b/src/gui/styles/qs60style_stub.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qs60style.h"
+#include "qdebug.h"
+
+#if defined(QT_NO_STYLE_S60)
+QT_BEGIN_NAMESPACE
+
+QS60Style::QS60Style()
+{
+ qWarning() << "QS60Style stub created";
+}
+
+QS60Style::~QS60Style()
+{
+}
+
+void QS60Style::drawComplexControl(ComplexControl , const QStyleOptionComplex *, QPainter *, const QWidget *) const
+{
+}
+
+void QS60Style::drawControl(ControlElement , const QStyleOption *, QPainter *, const QWidget *) const
+{
+}
+
+void QS60Style::drawPrimitive(PrimitiveElement , const QStyleOption *, QPainter *, const QWidget *) const
+{
+}
+
+int QS60Style::pixelMetric(PixelMetric , const QStyleOption *, const QWidget *) const
+{
+ return 0;
+}
+
+QSize QS60Style::sizeFromContents(ContentsType , const QStyleOption *, const QSize &, const QWidget *) const
+{
+ return QSize();
+}
+
+int QS60Style::styleHint(StyleHint , const QStyleOption *, const QWidget *, QStyleHintReturn *) const
+{
+ return 0;
+}
+
+QRect QS60Style::subControlRect(ComplexControl , const QStyleOptionComplex *, SubControl , const QWidget *) const
+{
+ return QRect();
+}
+
+QRect QS60Style::subElementRect(SubElement , const QStyleOption *, const QWidget *) const
+{
+ return QRect();
+}
+
+void QS60Style::polish(QWidget *)
+{
+}
+
+void QS60Style::unpolish(QWidget *)
+{
+}
+
+void QS60Style::polish(QApplication *)
+{
+}
+
+void QS60Style::unpolish(QApplication *)
+{
+}
+
+bool QS60Style::event(QEvent *)
+{
+ return false;
+}
+
+QIcon QS60Style::standardIconImplementation(StandardPixmap , const QStyleOption *, const QWidget *) const
+{
+ return QIcon();
+}
+
+void QS60Style::timerEvent(QTimerEvent *)
+{
+}
+
+bool QS60Style::eventFilter(QObject *, QEvent *)
+{
+ return false;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_STYLE_S60
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp
index 67a7b85..8511592 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/gui/styles/qwindowsvistastyle.cpp
@@ -1926,30 +1926,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption
return QWindowsStyle::sizeFromContents(type, option, size, widget);
QSize sz(size);
-
- QSize newSize = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
switch (type) {
- case CT_LineEdit:
- case CT_ComboBox:
- {
- HTHEME theme = pOpenThemeData(0, L"Button");
- MARGINS borderSize;
- if (theme) {
- int result = pGetThemeMargins(theme,
- NULL,
- BP_PUSHBUTTON,
- PBS_NORMAL,
- TMT_CONTENTMARGINS,
- NULL,
- &borderSize);
- if (result == S_OK) {
- sz += QSize(borderSize.cxLeftWidth + borderSize.cxRightWidth - 2,
- borderSize.cyBottomHeight + borderSize.cyTopHeight - 2);
- }
- sz += QSize(23, 0); //arrow button
- }
- }
- return sz;
case CT_MenuItem:
sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
int minimumHeight;
@@ -1990,7 +1967,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption
default:
break;
}
- return newSize;
+ return QWindowsXPStyle::sizeFromContents(type, option, size, widget);
}
/*!
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index efb1224..8743807 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -3678,7 +3678,9 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
sz += QSize(borderSize.cxLeftWidth + borderSize.cxRightWidth - 2,
borderSize.cyBottomHeight + borderSize.cyTopHeight - 2);
}
- sz += QSize(23, 0); //arrow button
+ const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1);
+ sz += QSize(qMax(pixelMetric(QStyle::PM_ScrollBarExtent, option, widget)
+ + textMargins, 23), 0); //arrow button
}
}
break;
diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri
index 0a96272..b22a908 100644
--- a/src/gui/styles/styles.pri
+++ b/src/gui/styles/styles.pri
@@ -182,5 +182,9 @@ contains( styles, s60 ):contains(QT_CONFIG, s60) {
RESOURCES += styles/qstyle_s60_simulated.qrc
}
} else {
+ symbian {
+ HEADERS += styles/qs60style.h
+ SOURCES += styles/qs60style_stub.cpp
+ }
DEFINES += QT_NO_STYLE_S60
}