Make default wxSizer border DPI-aware.

Scale the (still hard-coded) border in pixels by the content scale factor for
the platforms where this needs to be done, i.e. not wxGTK nor wxOSX where the
underlying toolkit already does it.
This commit is contained in:
Vadim Zeitlin
2015-03-24 23:39:40 +01:00
parent 277b848364
commit af01ef1bb0
4 changed files with 57 additions and 3 deletions

View File

@@ -117,10 +117,21 @@ public:
// GNOME HIG says to use 6px as the base unit:
// http://library.gnome.org/devel/hig-book/stable/design-window.html.en
return 6;
#else
// FIXME: default border size shouldn't be hardcoded and at the very
// least they should depend on the current font size
#elif defined(__WXMAC__)
// Not sure if this is really the correct size for the border.
return 5;
#else
// For the other platforms, we need to scale raw pixel values using the
// current DPI, do it once (and cache the result) in another function.
#define wxNEEDS_BORDER_IN_PX
// We don't react to dynamic DPI changes, so we can cache the values of
// the border in on-screen pixels after computing it once. This
// could/should change in the future.
if ( !ms_defaultBorderInPx )
ms_defaultBorderInPx = DoGetDefaultBorderInPx();
return ms_defaultBorderInPx;
#endif
#else
return 0;
@@ -222,6 +233,12 @@ public:
int GetBorderInPixels() const { return m_borderInPixels; }
private:
#ifdef wxNEEDS_BORDER_IN_PX
static int DoGetDefaultBorderInPx();
static int ms_defaultBorderInPx;
#endif // wxNEEDS_BORDER_IN_PX
int m_proportion;
int m_flags;
int m_borderInPixels;