]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/srchctlg.cpp
fix attribute memory leak in wxGrid::ShowCellEditControl() (patch 1629949)
[wxWidgets.git] / src / generic / srchctlg.cpp
index d622f78795e7d083f3e39779d50797b00c4c17a3..8edf081475bc4d447085167c66849921d386deab 100644 (file)
@@ -165,8 +165,9 @@ BEGIN_EVENT_TABLE(wxSearchButton, wxControl)
 END_EVENT_TABLE()
 
 BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase)
-    EVT_SEARCHCTRL_SEARCH(wxID_ANY, wxSearchCtrl::OnSearchButton)
+    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)
@@ -223,7 +224,11 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
             const wxValidator& validator,
             const wxString& name)
 {
+#ifdef __WXGTK__
+    if ( !wxTextCtrlBase::Create(parent, id, pos, size, wxSUNKEN_BORDER | style, validator, name) )
+#else
     if ( !wxTextCtrlBase::Create(parent, id, pos, size, wxSIMPLE_BORDER | style, validator, name) )
+#endif
     {
         return false;
     }
@@ -383,6 +388,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;
@@ -420,7 +428,10 @@ void wxSearchCtrl::LayoutControls(int x, int y, int width, int height)
     // position the subcontrols inside the client area
 
     m_searchButton->SetSize(x, y + ICON_OFFSET, sizeSearch.x, height);
-    m_text->SetSize(x + sizeSearch.x + searchMargin, y + ICON_OFFSET, textWidth, height);
+    m_text->SetSize( x + sizeSearch.x + searchMargin, 
+                     y + ICON_OFFSET - BORDER,
+                     textWidth, 
+                     height);
     m_cancelButton->SetSize(x + sizeSearch.x + searchMargin + textWidth + cancelMargin,
                             y + ICON_OFFSET, sizeCancel.x, height);
 }
@@ -1054,6 +1065,13 @@ void wxSearchCtrl::OnSetFocus( wxFocusEvent& /*event*/ )
     }
 }
 
+void wxSearchCtrl::OnSize( wxSizeEvent& WXUNUSED(event) )
+{
+    int width, height;
+    GetSize(&width, &height);
+    LayoutControls(0, 0, width, height);
+}
+
 void wxSearchCtrl::PopupSearchMenu()
 {
     if ( m_menu )