Also do LayoutControls from EVT_SIZE handler

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43945 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2006-12-12 00:53:52 +00:00
parent 4ed51f4d1c
commit af1f44f17e
2 changed files with 13 additions and 1 deletions

View File

@ -212,7 +212,8 @@ protected:
virtual void OnSearchButton( wxCommandEvent& event );
void OnSetFocus( wxFocusEvent& event );
void OnSize( wxSizeEvent& event );
private:
friend class wxSearchButton;

View File

@ -167,6 +167,7 @@ END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase)
EVT_SEARCHCTRL_SEARCH_BTN(wxID_ANY, wxSearchCtrl::OnSearchButton)
EVT_SET_FOCUS(wxSearchCtrl::OnSetFocus)
EVT_SIZE(wxSearchCtrl::OnSize)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase)
@ -383,6 +384,9 @@ void wxSearchCtrl::DoMoveWindow(int x, int y, int width, int height)
void wxSearchCtrl::LayoutControls(int x, int y, int width, int height)
{
if ( !m_text )
return;
wxSize sizeText = m_text->GetBestSize();
// make room for the search menu & clear button
int horizontalBorder = 1 + ( sizeText.y - sizeText.y * 14 / 21 ) / 2;
@ -1054,6 +1058,13 @@ void wxSearchCtrl::OnSetFocus( wxFocusEvent& /*event*/ )
}
}
void wxSearchCtrl::OnSize( wxSizeEvent& event )
{
int width, height;
GetSize(&width, &height);
LayoutControls(0, 0, width, height);
}
void wxSearchCtrl::PopupSearchMenu()
{
if ( m_menu )