Added wxWindow::ToDIP functionality.
This commit is contained in:
@@ -979,6 +979,21 @@ public:
|
|||||||
wxPoint FromDIP(const wxPoint& pt) const { return FromDIP(pt, this); }
|
wxPoint FromDIP(const wxPoint& pt) const { return FromDIP(pt, this); }
|
||||||
int FromDIP(int d) const { return FromDIP(d, this); }
|
int FromDIP(int d) const { return FromDIP(d, this); }
|
||||||
|
|
||||||
|
static wxSize ToDIP(const wxSize& sz, const wxWindowBase* w);
|
||||||
|
static wxPoint ToDIP(const wxPoint& pt, const wxWindowBase* w)
|
||||||
|
{
|
||||||
|
const wxSize sz = ToDIP(wxSize(pt.x, pt.y), w);
|
||||||
|
return wxPoint(sz.x, sz.y);
|
||||||
|
}
|
||||||
|
static int ToDIP(int d, const wxWindowBase* w)
|
||||||
|
{
|
||||||
|
return ToDIP(wxSize(d, 0), w).x;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize ToDIP(const wxSize& sz) const { return ToDIP(sz, this); }
|
||||||
|
wxPoint ToDIP(const wxPoint& pt) const { return ToDIP(pt, this); }
|
||||||
|
int ToDIP(int d) const { return ToDIP(d, this); }
|
||||||
|
|
||||||
|
|
||||||
// Dialog units are based on the size of the current font.
|
// Dialog units are based on the size of the current font.
|
||||||
|
|
||||||
|
@@ -2878,6 +2878,18 @@ wxWindowBase::FromDIP(const wxSize& sz, const wxWindowBase* WXUNUSED(w))
|
|||||||
sz.y == -1 ? -1 : wxMulDivInt32(sz.y, dpi.y, BASELINE_DPI));
|
sz.y == -1 ? -1 : wxMulDivInt32(sz.y, dpi.y, BASELINE_DPI));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
wxSize
|
||||||
|
wxWindowBase::ToDIP(const wxSize& sz, const wxWindowBase* WXUNUSED(w))
|
||||||
|
{
|
||||||
|
const wxSize dpi = wxScreenDC().GetPPI();
|
||||||
|
|
||||||
|
// Take care to not scale -1 because it has a special meaning of
|
||||||
|
// "unspecified" which should be preserved.
|
||||||
|
return wxSize(sz.x == -1 ? -1 : wxMulDivInt32(sz.x, BASELINE_DPI, dpi.x),
|
||||||
|
sz.y == -1 ? -1 : wxMulDivInt32(sz.y, BASELINE_DPI, dpi.y));
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !wxHAVE_DPI_INDEPENDENT_PIXELS
|
#endif // !wxHAVE_DPI_INDEPENDENT_PIXELS
|
||||||
|
|
||||||
// Windows' computes dialog units using average character width over upper-
|
// Windows' computes dialog units using average character width over upper-
|
||||||
|
Reference in New Issue
Block a user