Simplify wxSearchCtrl::DoGetBestClientSize()

This commit is contained in:
Maarten Bent
2019-11-03 17:14:17 +01:00
parent 82668e1e85
commit ced00c6231

View File

@@ -452,28 +452,21 @@ wxString wxSearchCtrl::GetDescriptiveText() const
wxSize wxSearchCtrl::DoGetBestClientSize() const wxSize wxSearchCtrl::DoGetBestClientSize() const
{ {
wxSize sizeText = m_text->GetBestSize(); wxSize size = m_text->GetBestSize();
wxSize sizeSearch(0,0);
wxSize sizeCancel(0,0);
int searchMargin = 0;
int cancelMargin = 0;
if ( IsSearchButtonVisible() ) if ( IsSearchButtonVisible() )
{ {
sizeSearch = m_searchButton->GetBestSize(); size.x += m_searchButton->GetBestSize().x + FromDIP(MARGIN);
searchMargin = FromDIP(MARGIN);
} }
if ( IsCancelButtonVisible() ) if ( IsCancelButtonVisible() )
{ {
sizeCancel = m_cancelButton->GetBestSize(); size.x += m_cancelButton->GetBestSize().x + FromDIP(MARGIN);
cancelMargin = FromDIP(MARGIN);
} }
int horizontalBorder = FromDIP(1) + ( sizeText.y - sizeText.y * 14 / 21 ) / 2; int horizontalBorder = FromDIP(1) + (size.y - size.y * 14 / 21 ) / 2;
size.x += 2 * horizontalBorder;
// buttons are square and equal to the height of the text control return size;
int height = sizeText.y;
return wxSize(sizeSearch.x + searchMargin + sizeText.x + cancelMargin + sizeCancel.x + 2*horizontalBorder,
height);
} }
void wxSearchCtrl::LayoutControls() void wxSearchCtrl::LayoutControls()