Improvements for wxTextCtrl, wxSearchCtrl, wxButton when using
non-default DPI.

See https://github.com/wxWidgets/wxWidgets/pull/1634
This commit is contained in:
Vadim Zeitlin
2019-11-13 15:47:59 +01:00
7 changed files with 105 additions and 71 deletions

View File

@@ -91,12 +91,13 @@ WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
// Return the height of a native text control corresponding to the given
// character height (as returned by GetCharHeight() or wxGetCharSize()).
//
// The wxWindow parameter must be valid and used for getting the DPI.
inline int wxGetEditHeightFromCharHeight(int cy, const wxWindow* w)
// The wxWindow parameter is currently not used but should still be valid.
inline int wxGetEditHeightFromCharHeight(int cy, const wxWindow* WXUNUSED(w))
{
// The value 8 here is empiric, i.e. it's not necessarily correct, but
// seems to work relatively well.
return cy + w->FromDIP(8);
// Don't use FromDIP(8), this seems not needed.
return cy + 8;
}
// Compatibility macro used in the existing code. It assumes that it's called

View File

@@ -244,6 +244,9 @@ protected:
#if wxUSE_RICHEDIT
virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) wxOVERRIDE;
// Apply m_richDPIscale zoom to rich control.
void MSWSetRichZoom();
// Apply the character-related parts of wxTextAttr to the given selection
// or the entire control if start == end == -1.
//
@@ -265,6 +268,10 @@ protected:
// (although not directly: 1 is for 1.0, 2 is for either 2.0 or 3.0 as we
// can't nor really need to distinguish between them and 4 is for 4.1)
int m_verRichEdit;
// Rich text controls need temporary scaling when they are created on a
// display with non-system DPI.
float m_richDPIscale;
#endif // wxUSE_RICHEDIT
// number of EN_UPDATE events sent by Windows when we change the controls