From: Vadim Zeitlin Date: Sun, 2 Oct 2011 11:28:40 +0000 (+0000) Subject: Restore correct wxSearchCtrl size in wxMSW after wxTextCtrl changes. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a166dbbab57ac04eedebef727ab5a66dfacc41de?ds=inline Restore correct wxSearchCtrl size in wxMSW after wxTextCtrl changes. The code in generic wxSearchCtrl implementation was broken by the changes of r69066 which deccreased the best height of border-less text controls. Ideally we should probably change wxSearchCtrl::LayoutControls() to not be sensitive at all to the exact value returned from wxTextCtrl::GetBestSize() and just always centre everything vertically but this doesn't look simple to do with the current code so just override wxSearchTextCtrl::DoGetBestSize() to return the same size as wxTextCtrl used to return before to fix this for now. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69284 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 8efca10640..7310b9158a 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -114,6 +114,32 @@ protected: m_search->GetEventHandler()->ProcessEvent(event); } +#ifdef __WXMSW__ + // We increase the text control height to be the same as for the controls + // with border as this is what we actually need here because even though + // this control itself is borderless, it's inside wxSearchCtrl which does + // have the border and so should have the same height as the normal text + // entries with border. + // + // This is a bit ugly and it would arguably be better to use whatever size + // the base class version returns and just centre the text vertically in + // the search control but I failed to modify the code in LayoutControls() + // to do this easily and as there is much in that code I don't understand + // (notably what is the logic for buttons sizing?) I prefer to not touch it + // at all. + virtual wxSize DoGetBestSize() const + { + const long flags = GetWindowStyleFlag(); + wxSearchTextCtrl* const self = const_cast(this); + + self->SetWindowStyleFlag((flags & ~wxBORDER_MASK) | wxBORDER_DEFAULT); + const wxSize size = wxTextCtrl::DoGetBestSize(); + self->SetWindowStyleFlag(flags); + + return size; + } +#endif // __WXMSW__ + private: wxSearchCtrl* m_search;