Handle all pixel values in XRC as being DPI-independent.
Pixel values in XRC can never be correct for high resolution displays, unlike the pixel values passed to wxWidgets API, which could be already adjusted to account for the resolution or obtained from resolution-dependent text metrics, so scale them by the factor appropriate for the current resolution automatically.
This commit is contained in:
@@ -37,6 +37,9 @@ Changes in behaviour which may result in build errors
|
|||||||
3.1.0: (released 2014-xx-xx)
|
3.1.0: (released 2014-xx-xx)
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
- Many improvements for high DPI monitors support, notably XRC now interprets
|
||||||
|
all pixel values as being in resolution-independent pixels.
|
||||||
|
|
||||||
- wxQt branch implementing Qt5-based port of wxWidgets API was merged into
|
- wxQt branch implementing Qt5-based port of wxWidgets API was merged into
|
||||||
the trunk (Mariano Reingart, Google Summer of Code project).
|
the trunk (Mariano Reingart, Google Summer of Code project).
|
||||||
|
|
||||||
|
@@ -246,8 +246,10 @@ Some examples:
|
|||||||
|
|
||||||
@subsection overview_xrcformat_type_size Size
|
@subsection overview_xrcformat_type_size Size
|
||||||
|
|
||||||
Sizes and positions have the form of string with two comma-separated integer
|
Sizes and positions can be expressed in either @ref wxWindow::FromDIP()
|
||||||
components, with optional "d" suffix. Semi-formally:
|
"DPI-independent pixel values" or in @ref wxWindow::ConvertDialogToPixels()
|
||||||
|
"dialog units". The former is the default, to use the latter "d" suffix can be
|
||||||
|
added. Semi-formally the format is:
|
||||||
|
|
||||||
size := x "," y ["d"]
|
size := x "," y ["d"]
|
||||||
|
|
||||||
@@ -255,9 +257,6 @@ where x and y are integers. Either of the components (or both) may be "-1" to
|
|||||||
signify default value. As a shortcut, empty string is equivalent to "-1,-1"
|
signify default value. As a shortcut, empty string is equivalent to "-1,-1"
|
||||||
(= wxDefaultSize or wxDefaultPosition).
|
(= wxDefaultSize or wxDefaultPosition).
|
||||||
|
|
||||||
When the "d" suffix is used, integer values are interpreted as
|
|
||||||
@ref wxWindow::ConvertDialogToPixels() "dialog units" in the parent window.
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
@code
|
@code
|
||||||
42,-1
|
42,-1
|
||||||
@@ -274,7 +273,8 @@ Same as @ref overview_xrcformat_type_size.
|
|||||||
|
|
||||||
Similarly to @ref overview_xrcformat_type_size "sizes", dimensions are expressed
|
Similarly to @ref overview_xrcformat_type_size "sizes", dimensions are expressed
|
||||||
as integers with optional "d" suffix. When "d" suffix is used, the integer
|
as integers with optional "d" suffix. When "d" suffix is used, the integer
|
||||||
preceding it is interpreted as dialog units in the parent window.
|
preceding it is interpreted as dialog units in the parent window, otherwise
|
||||||
|
it's a DPI-independent pixel value.
|
||||||
|
|
||||||
|
|
||||||
@subsection overview_xrcformat_type_text Text
|
@subsection overview_xrcformat_type_text Text
|
||||||
|
@@ -2125,11 +2125,11 @@ ParseValueInPixels(wxXmlResourceHandlerImpl* impl,
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( inDLU )
|
|
||||||
{
|
|
||||||
if ( !windowToUse )
|
if ( !windowToUse )
|
||||||
windowToUse = impl->GetParentAsWindow();
|
windowToUse = impl->GetParentAsWindow();
|
||||||
|
|
||||||
|
if ( inDLU )
|
||||||
|
{
|
||||||
if ( !windowToUse )
|
if ( !windowToUse )
|
||||||
{
|
{
|
||||||
impl->ReportParamError
|
impl->ReportParamError
|
||||||
@@ -2143,6 +2143,10 @@ ParseValueInPixels(wxXmlResourceHandlerImpl* impl,
|
|||||||
|
|
||||||
XRCConvertFromDLU(windowToUse, value);
|
XRCConvertFromDLU(windowToUse, value);
|
||||||
}
|
}
|
||||||
|
else // The value is in resolution-independent pixels.
|
||||||
|
{
|
||||||
|
value = wxWindow::FromDIP(value, windowToUse);
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user