diff options
author | Alessandro Portale <aportale@trolltech.com> | 2009-05-28 11:49:08 (GMT) |
---|---|---|
committer | Alessandro Portale <aportale@trolltech.com> | 2009-05-28 11:49:08 (GMT) |
commit | 1ee484031d2a240bd7019753e83bb473ea9891de (patch) | |
tree | a3dbde228d49159ecac8ca2f2c55eb41a60616ec /src | |
parent | 131d8f90aa2991866884a896fdebcc05a020a905 (diff) | |
download | Qt-1ee484031d2a240bd7019753e83bb473ea9891de.zip Qt-1ee484031d2a240bd7019753e83bb473ea9891de.tar.gz Qt-1ee484031d2a240bd7019753e83bb473ea9891de.tar.bz2 |
Enabled QtS60Style background filling also for _simulated, by moving
some code to qs60style.cpp. De-duplicated some code in
qt_s60_fill_background.
The unused QT_S60STYLE_LAYOUTDATA_SIMULATED had to go, too.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 23 | ||||
-rw-r--r-- | src/gui/styles/qs60style.cpp | 55 | ||||
-rw-r--r-- | src/gui/styles/qs60style_p.h | 2 | ||||
-rw-r--r-- | src/gui/styles/qs60style_simulated.cpp | 23 | ||||
-rw-r--r-- | src/gui/styles/qs60style_symbian.cpp | 52 | ||||
-rw-r--r-- | src/gui/styles/styles.pri | 1 |
6 files changed, 65 insertions, 91 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index dae4179..4fcedb4 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2046,17 +2046,20 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoin // Defined in qmacstyle_mac.cpp extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush); qt_mac_fill_background(painter, rgn, offset, brush); -#elif defined(Q_WS_S60) - // Defined in qs60style_symbian.cpp - extern void qt_s60_fill_background(QPainter *painter, const QRegion &rgn, - const QPoint &offset, const QBrush &brush); - qt_s60_fill_background(painter, rgn, offset, brush); #else - const QRegion translated = rgn.translated(offset); - const QRect rect(translated.boundingRect()); - painter->setClipRegion(translated); - painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); -#endif +#if !defined(QT_NO_STYLE_S60) + // Defined in qs60style.cpp + extern bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, + const QPoint &offset, const QBrush &brush); + if (!qt_s60_fill_background(painter, rgn, offset, brush)) +#endif // !defined(QT_NO_STYLE_S60) + { + const QRegion translated = rgn.translated(offset); + const QRect rect(translated.boundingRect()); + painter->setClipRegion(translated); + painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); + } +#endif // Q_WS_MAC } else { const QVector<QRect> &rects = rgn.rects(); for (int i = 0; i < rects.size(); ++i) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 5f7c083..b066967 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -57,7 +57,6 @@ const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFl static const QByteArray propertyKeyLayouts = "layouts"; static const QByteArray propertyKeyCurrentlayout = "currentlayout"; -#if defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { // *** generated layout data *** {240,320,1,14,true,QLatin1String("QVGA Landscape Mirrored")}, @@ -93,7 +92,6 @@ const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { }; const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; -#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) // theme background texture QPixmap *QS60StylePrivate::m_background = 0; @@ -119,6 +117,11 @@ static const int frameElementsCount = const int KNotFound = -1; +QS60StylePrivate::~QS60StylePrivate() +{ + deleteBackground(); +} + void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, const QRect &rect, SkinElementFlags flags) { @@ -252,10 +255,18 @@ void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part, drawPart(part, painter, rect, flags); } +short QS60StylePrivate::pixelMetric(int metric) +{ + Q_ASSERT(metric < MAX_PIXELMETRICS); + const short returnValue = m_pmPointer[metric]; + if (returnValue==-909) + return -1; + return returnValue; +} + void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value) { if (name == propertyKeyCurrentlayout) { -#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) static const QStringList layouts = styleProperty(propertyKeyLayouts).toStringList(); const QString layout = value.toString(); Q_ASSERT(layouts.contains(layout)); @@ -265,24 +276,17 @@ void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value) clearCaches(); refreshUI(); return; -#else - qFatal("Cannot set static layout. Dynamic layouts are used!"); -#endif } } QVariant QS60StylePrivate::styleProperty(const char *name) const { if (name == propertyKeyLayouts) { -#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) static QStringList layouts; if (layouts.isEmpty()) for (int i = 0; i < QS60StylePrivate::m_numberOfLayouts; i++) layouts.append(QS60StylePrivate::m_layoutHeaders[i].layoutName); return layouts; -#else - qFatal("Cannot return list of 'canned' static layouts. Dynamic layouts are used!"); -#endif } return QVariant(); } @@ -575,13 +579,10 @@ int QS60StylePrivate::focusRectPenWidth() return pixelMetric(QS60Style::PM_DefaultFrameWidth); } -#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) void QS60StylePrivate::setCurrentLayout(int index) { m_pmPointer = data[index]; } -#endif - void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart, QPainter *painter, const QRect &rect, SkinElementFlags flags) @@ -2185,7 +2186,6 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const metricValue = QCommonStyle::pixelMetric(metric, option, widget); if (metric == PM_SubMenuOverlap && widget){ - const int widgetWidth = widget->width(); const QMenu *menu = qobject_cast<const QMenu *>(widget); if (menu && menu->activeAction() && menu->activeAction()->menu()) { const int menuWidth = menu->activeAction()->menu()->sizeHint().width(); @@ -2415,11 +2415,12 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple ret = QCommonStyle::subControlRect(control, option, scontrol, widget); switch (scontrol) { case SC_GroupBoxCheckBox: //fallthrough - case SC_GroupBoxLabel: + case SC_GroupBoxLabel: { //slightly indent text and boxes, so that dialog border does not mess with them. const int horizontalSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); ret.adjust(2,horizontalSpacing-3,0,0); + } break; case SC_GroupBoxFrame: { const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget); @@ -2685,6 +2686,7 @@ void QS60Style::polish(QApplication *application) void QS60Style::unpolish(QApplication *application) { + Q_UNUSED(application) QPalette newPalette = qApp->style()->standardPalette(); application->setPalette(newPalette); QApplicationPrivate::setSystemPalette(originalPalette); @@ -2787,6 +2789,29 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); } +extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); + +bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, + const QBrush &brush) +{ + const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture()); + if (backgroundTexture.cacheKey() != brush.texture().cacheKey()) + return false; + + const QPaintDevice *target = painter->device(); + if (target->devType() == QInternal::Widget) { + const QWidget *widget = static_cast<const QWidget *>(target); + const QRegion translated = rgn.translated(offset); + const QVector<QRect> &rects = translated.rects(); + for (int i = 0; i < rects.size(); ++i) { + const QRect rect(rects.at(i)); + painter->drawPixmap(rect.topLeft(), backgroundTexture, + rect.translated(qt_s60_fill_background_offset(widget))); + } + } + return true; +} + QT_END_NAMESPACE #endif // QT_NO_STYLE_S60 || QT_PLUGIN diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index bedff58..22b01f6 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -388,7 +388,6 @@ public: static int focusRectPenWidth(); -#if defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) static const layoutHeader m_layoutHeaders[]; static const short data[][MAX_PIXELMETRICS]; @@ -398,7 +397,6 @@ public: static short const *m_pmPointer; // number of layouts supported by the style static const int m_numberOfLayouts; -#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) mutable QHash<QPair<QS60StyleEnums::FontCategories , int>, QFont> m_mappedFontsCache; mutable QHash<QS60StylePrivate::SkinFrameElements, QColor> m_colorCache; diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 3edc874..b6ad0ac 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -42,19 +42,6 @@ QS60StylePrivate::QS60StylePrivate() setCurrentLayout(0); } -QS60StylePrivate::~QS60StylePrivate() -{ -} - -short QS60StylePrivate::pixelMetric(int metric) -{ - Q_ASSERT(metric < MAX_PIXELMETRICS); - const short returnValue = m_pmPointer[metric]; - if (returnValue==-909) - return -1; - return returnValue; -} - QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, int index, const QStyleOption *option) { @@ -194,7 +181,7 @@ QVariant QS60StylePrivate::styleProperty_specific(const char *name) const QPixmap QS60StylePrivate::backgroundTexture() { if (!m_background) { - const QSize size = QApplication::activeWindow()?QApplication::activeWindow()->size():QSize(100, 100); + const QSize size = QApplication::desktop()->screen()->size(); QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size); m_background = new QPixmap(background); } @@ -216,7 +203,6 @@ bool QS60StylePrivate::isToolBarBackground() return true; } - QFont QS60StylePrivate::s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize) { QFont result; @@ -281,6 +267,13 @@ void QS60Style::setS60Theme(const QHash<QString, QPicture> &parts, QS60StyleModeSpecifics::m_partPictures = parts; QS60StyleModeSpecifics::m_colors = colors; d->clearCaches(QS60StylePrivate::CC_ThemeChange); + d->setBackgroundTexture(qApp); +} + +QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) +{ + Q_UNUSED(targetWidget) + return QPoint(); } QT_END_NAMESPACE diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_symbian.cpp index f860842..ddee4ba 100644 --- a/src/gui/styles/qs60style_symbian.cpp +++ b/src/gui/styles/qs60style_symbian.cpp @@ -593,30 +593,11 @@ bool QS60StylePrivate::isToolBarBackground() return (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); } -void qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, - const QBrush &brush) +QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) { - const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture()); - if (backgroundTexture.cacheKey() == brush.texture().cacheKey()) { - const QPaintDevice *target = painter->device(); - if (target->devType() == QInternal::Widget) { - const QWidget *widget = static_cast<const QWidget *>(target); - CCoeControl *control = widget->effectiveWinId(); - TPoint globalPos = control ? control->PositionRelativeToScreen() : TPoint(0,0); - const QRegion translated = rgn.translated(offset); - const QVector<QRect> &rects = translated.rects(); - for (int i = 0; i < rects.size(); ++i) { - const QRect rect(rects.at(i)); - painter->drawPixmap(rect.topLeft(), backgroundTexture, - rect.translated(globalPos.iX, globalPos.iY)); - } - } - } else { - const QRegion translated = rgn.translated(offset); - const QRect rect(translated.boundingRect()); - painter->setClipRegion(translated); - painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); - } + CCoeControl *control = targetWidget->effectiveWinId(); + TPoint globalPos = control ? control->PositionRelativeToScreen() : TPoint(0,0); + return QPoint(globalPos.iX, globalPos.iY); } QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL( @@ -939,7 +920,6 @@ QFont QS60StylePrivate::s60Font_specific( return result; } -#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED void QS60StylePrivate::setActiveLayout() { const QSize activeScreenSize(screenSize()); @@ -979,19 +959,11 @@ void QS60StylePrivate::setActiveLayout() m_pmPointer = data[activeLayoutIndex]; } -#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED QS60StylePrivate::QS60StylePrivate() { -#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED // No need to set active layout, if dynamic metrics API is available setActiveLayout(); -#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED -} - -QS60StylePrivate::~QS60StylePrivate() -{ - deleteBackground(); } void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value) @@ -1011,20 +983,6 @@ QVariant QS60StylePrivate::styleProperty_specific(const char *name) const return styleProperty(name); } -short QS60StylePrivate::pixelMetric(int metric) -{ -#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED - Q_ASSERT(metric < MAX_PIXELMETRICS); - const short returnValue = m_pmPointer[metric]; - if (returnValue==-909) - return -1; - return returnValue; -#else - //todo - call the pixelmetrics API directly - return 0; -#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED -} - QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, int index, const QStyleOption *option) { @@ -1343,9 +1301,7 @@ void QS60Style::handleDynamicLayoutVariantSwitch() { Q_D(QS60Style); d->clearCaches(QS60StylePrivate::CC_LayoutChange); -#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED d->setActiveLayout(); -#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED d->refreshUI(); d->setBackgroundTexture(qApp); foreach (QWidget *widget, QApplication::allWidgets()) diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index 9aa170e..b0e9f21 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -160,7 +160,6 @@ contains( styles, s60 ) { styles/qs60style.h \ styles/qs60style_p.h SOURCES += styles/qs60style.cpp - DEFINES += QT_S60STYLE_LAYOUTDATA_SIMULATED symbian { SOURCES += styles/qs60style_symbian.cpp # TODO: fix the following LIBS hack. Line 1 is for armv5, 2 for winscw |