summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qwindowsxpstyle_p_p.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-08-29 17:38:25 +0200
committerFriedemann Kleint <Friedemann.Kleint@digia.com>2014-09-05 12:14:23 +0200
commit176bd1edfadcb68b914a27de75502edeb1081253 (patch)
tree828d63a130e4f3bcfc6427ee4c79a8b5ec7f0464 /src/widgets/styles/qwindowsxpstyle_p_p.h
parentb858e7af4fefeed051f5a7e0795872fd1b834220 (diff)
Windows styles: Add device pixel scaling for system metrics.
Metrics obtained from the system must be scaled down when device pixel ration scaling is in effect. Factor out functions to return the device pixel values which might still be used for drawing. Task-number: QTBUG-38993 Task-number: QTBUG-38858 Change-Id: I6b90629e4979436bbb46f8c1fa1ee2253ada7ece Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
Diffstat (limited to 'src/widgets/styles/qwindowsxpstyle_p_p.h')
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p_p.h68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h
index 190055b24b..0ead58393f 100644
--- a/src/widgets/styles/qwindowsxpstyle_p_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p_p.h
@@ -219,9 +219,19 @@ public:
HRGN mask(QWidget *widget);
HTHEME handle();
- RECT toRECT(const QRect &qr);
+ static RECT toRECT(const QRect &qr);
bool isValid();
+ QSize size();
+ QMargins margins(const QRect &rect, int propId = TMT_CONTENTMARGINS);
+ QMargins margins(int propId = TMT_CONTENTMARGINS);
+
+ static QSize themeSize(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, int part = 0, int state = 0);
+ static QMargins themeMargins(const QRect &rect, const QWidget *w = 0, QPainter *p = 0, int themeIn = -1,
+ int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS);
+ static QMargins themeMargins(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1,
+ int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS);
+
const QWidget *widget;
QPainter *painter;
@@ -374,6 +384,8 @@ public:
~QWindowsXPStylePrivate()
{ cleanup(); }
+ static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0);
+
static HWND winId(const QWidget *widget);
void init(bool force = false);
@@ -432,6 +444,60 @@ private:
static HTHEME m_themes[NThemes];
};
+inline QSize XPThemeData::size()
+{
+ QSize result(0, 0);
+ if (isValid()) {
+ SIZE size;
+ if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemePartSize(handle(), 0, partId, stateId, 0, TS_TRUE, &size)))
+ result = QSize(size.cx, size.cy);
+ }
+ return result;
+}
+
+inline QMargins XPThemeData::margins(const QRect &qRect, int propId)
+{
+ QMargins result(0, 0, 0 ,0);
+ if (isValid()) {
+ MARGINS margins;
+ RECT rect = XPThemeData::toRECT(qRect);
+ if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemeMargins(handle(), 0, partId, stateId, propId, &rect, &margins)))
+ result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
+ }
+ return result;
+}
+
+inline QMargins XPThemeData::margins(int propId)
+{
+ QMargins result(0, 0, 0 ,0);
+ if (isValid()) {
+ MARGINS margins;
+ if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemeMargins(handle(), 0, partId, stateId, propId, NULL, &margins)))
+ result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
+ }
+ return result;
+}
+
+inline QSize XPThemeData::themeSize(const QWidget *w, QPainter *p, int themeIn, int part, int state)
+{
+ XPThemeData theme(w, p, themeIn, part, state);
+ return theme.size();
+}
+
+inline QMargins XPThemeData::themeMargins(const QRect &rect, const QWidget *w, QPainter *p, int themeIn,
+ int part, int state, int propId)
+{
+ XPThemeData theme(w, p, themeIn, part, state);
+ return theme.margins(rect, propId);
+}
+
+inline QMargins XPThemeData::themeMargins(const QWidget *w, QPainter *p, int themeIn,
+ int part, int state, int propId)
+{
+ XPThemeData theme(w, p, themeIn, part, state);
+ return theme.margins(propId);
+}
+
#endif // QT_NO_STYLE_WINDOWS
QT_END_NAMESPACE