Change interpretation of font height in wxMSW to mean character height.
Accept both positive and negative height values in wxFont::SetPixelSize() in wxMSW and map them both to a negative height when passing to MSW API in order to request mapping against the character height and not the total cell height. For positive heights this is more consistent with the other ports and also expectations of people using this function. We keep the possibility to use the negative heights inly for compatibility with the existing code which worked around the (incorrect) interpretation of the positive height as cell heights in the previous wxMSW versions by passing a negative height explicitly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62566 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
aa2444bd9e
commit
5414d62e3a
@ -95,6 +95,15 @@ Changes in behaviour not resulting in compilation errors, please read this!
|
||||
sizes of the sizer items to be in the same proportion as the items
|
||||
proportions to return to the old behaviour.
|
||||
|
||||
- Interpretation of font height in pixels parameter has changed in wxFont
|
||||
ctor and SetPixelSize() in wxMSW: it is now used as character height and not
|
||||
the total cell height. If you previously used negative height to explicitly
|
||||
request character height matching, you may now change your code to use
|
||||
positive value (passing negative height still works but is undocumented and
|
||||
deprecated). If you used positive height before you should retest your code
|
||||
to check if the changes correspond to your expectations. And if you do need
|
||||
the old behaviour please contact us at wx-dev to let us know about it!
|
||||
|
||||
- wxWindow::Freeze/Thaw() are not virtual any more, if you overrode them in
|
||||
your code you need to override DoFreeze/DoThaw() instead now.
|
||||
|
||||
|
@ -216,6 +216,9 @@ public:
|
||||
|
||||
void SetPixelSize(const wxSize& pixelSize)
|
||||
{
|
||||
wxCHECK_RET( pixelSize.GetWidth() >= 0, "negative font width" );
|
||||
wxCHECK_RET( pixelSize.GetHeight() != 0, "zero font height" );
|
||||
|
||||
Free();
|
||||
|
||||
m_nativeFontInfo.SetPixelSize(pixelSize);
|
||||
@ -503,13 +506,16 @@ void wxNativeFontInfo::SetPointSize(int pointsize)
|
||||
|
||||
void wxNativeFontInfo::SetPixelSize(const wxSize& pixelSize)
|
||||
{
|
||||
// NOTE: although the MSW port allows for negative pixel size heights,
|
||||
// other ports don't and since it's a very useful feature assert
|
||||
// here if we get a negative height:
|
||||
wxCHECK_RET( pixelSize.GetWidth() >= 0 && pixelSize.GetHeight() > 0,
|
||||
"Negative values for the pixel size or zero pixel height are not allowed" );
|
||||
|
||||
lf.lfHeight = pixelSize.GetHeight();
|
||||
// MSW accepts both positive and negative heights here but they mean
|
||||
// different things: positive specifies the cell height while negative
|
||||
// specifies the character height. We used to just pass the value to MSW
|
||||
// unchanged but changed the behaviour for positive values in 2.9.1 to
|
||||
// match other ports and, more importantly, the expected behaviour. So now
|
||||
// passing the negative height doesn't make sense at all any more but we
|
||||
// still accept it for compatibility with the existing code which worked
|
||||
// around the wrong interpretation of the height argument in older wxMSW
|
||||
// versions by passing a negative value explicitly itself.
|
||||
lf.lfHeight = -abs(pixelSize.GetHeight());
|
||||
lf.lfWidth = pixelSize.GetWidth();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user