From 669c8042fa78c539cdefec87c85bce91e561871d Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 22 Mar 2010 14:59:25 +0200 Subject: Custom pixel metric values cannot be inquired from outside the class This is due that a) custom values are internal and not exposed b) values use different format - they are indexes for internal data[] table and not according to QStyle documentation for pixel metrics. Task-number: QTBUG-9247 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 7 +++++++ src/gui/styles/qs60style.h | 9 +++++++++ src/gui/styles/qs60style_p.h | 3 +++ 3 files changed, 19 insertions(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 750e19f..ed2074a 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -307,6 +307,13 @@ void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part, short QS60StylePrivate::pixelMetric(int metric) { + //If it is a custom value, need to strip away the base to map to internal + //pixel metric value table + if (metric & QStyle::PM_CustomBase) { + metric -= QStyle::PM_CustomBase; + metric += MAX_NON_CUSTOM_PIXELMETRICS - 1; + } + Q_ASSERT(metric < MAX_PIXELMETRICS); const short returnValue = m_pmPointer[metric]; return returnValue; diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index 82cc21c..af17843 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -52,6 +52,15 @@ 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 { + PM_FrameCornerWidth = QStyle::PM_CustomBase + 1, + PM_FrameCornerHeight, + PM_BoldLineWidth, + PM_ThinLineWidth + }; + class QS60StylePrivate; class Q_GUI_EXPORT QS60Style : public QCommonStyle diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 16d82e7..84f50ea 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -61,12 +61,15 @@ QT_BEGIN_NAMESPACE const int MAX_NON_CUSTOM_PIXELMETRICS = 92; const int CUSTOMVALUESCOUNT = 4; + +//internal custom pixel metrics values, these map to entry in data[] table enum { PM_Custom_FrameCornerWidth = MAX_NON_CUSTOM_PIXELMETRICS, PM_Custom_FrameCornerHeight, PM_Custom_BoldLineWidth, PM_Custom_ThinLineWidth }; + const int MAX_PIXELMETRICS = MAX_NON_CUSTOM_PIXELMETRICS + CUSTOMVALUESCOUNT; typedef struct { -- cgit v0.12