X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/88c23b64c7cc5ea6f6e2841ba40cc81bf943c27a..bab4b13d392e0c9663c2c5a09f0dcbc77344ec05:/src/generic/srchctlg.cpp?ds=sidebyside diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 9efb1aed4a..49b469f033 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -134,6 +134,24 @@ public: return m_descriptiveText; } + + // provide access to the base class protected methods to wxSearchCtrl which + // needs to forward to them + void DoSetValue(const wxString& value, int flags) + { + wxTextCtrl::DoSetValue(value, flags); + } + + bool DoLoadFile(const wxString& file, int fileType) + { + return wxTextCtrl::DoLoadFile(file, fileType); + } + + bool DoSaveFile(const wxString& file, int fileType) + { + return wxTextCtrl::DoSaveFile(file, fileType); + } + protected: void OnText(wxCommandEvent& eventText) { @@ -228,11 +246,13 @@ protected: m_search->SetFocus(); +#if wxUSE_MENUS if ( m_eventType == wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN ) { // this happens automatically, just like on Mac OS X m_search->PopupSearchMenu(); } +#endif // wxUSE_MENUS } void OnPaint(wxPaintEvent&) @@ -294,17 +314,21 @@ wxSearchCtrl::wxSearchCtrl(wxWindow *parent, wxWindowID id, void wxSearchCtrl::Init() { - m_text = 0; - m_searchButton = 0; - m_cancelButton = 0; - m_menu = 0; + m_text = NULL; + m_searchButton = NULL; + m_cancelButton = NULL; +#if wxUSE_MENUS + m_menu = NULL; +#endif // wxUSE_MENUS m_searchButtonVisible = true; m_cancelButtonVisible = false; - m_searchMenuBitmapUser = false; m_searchBitmapUser = false; m_cancelBitmapUser = false; +#if wxUSE_MENUS + m_searchMenuBitmapUser = false; +#endif // wxUSE_MENUS } bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, @@ -319,10 +343,17 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, style &= ~wxBORDER_MASK; #ifdef __WXGTK__ style |= wxBORDER_SUNKEN; +#elif defined(__WXMSW__) + // Don't set the style explicitly, let GetDefaultBorder() work it out, unless + // we will get a sunken border (e.g. on Windows 200) in which case we must + // override with a simple border. + if (GetDefaultBorder() == wxBORDER_SUNKEN) + style |= wxBORDER_SIMPLE; #else style |= wxBORDER_SIMPLE; #endif - if ( !wxTextCtrlBase::Create(parent, id, pos, size, style, validator, name) ) + if ( !wxSearchCtrlBaseBaseClass::Create(parent, id, pos, size, + style, validator, name) ) { return false; } @@ -330,8 +361,6 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, m_text = new wxSearchTextCtrl(this, value, style & ~wxBORDER_MASK); m_text->SetDescriptiveText(_("Search")); - wxSize sizeText = m_text->GetBestSize(); - m_searchButton = new wxSearchButton(this, wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, m_searchBitmap); @@ -359,11 +388,15 @@ wxSearchCtrl::~wxSearchCtrl() delete m_text; delete m_searchButton; delete m_cancelButton; +#if wxUSE_MENUS delete m_menu; +#endif // wxUSE_MENUS } // search control specific interfaces +#if wxUSE_MENUS + void wxSearchCtrl::SetMenu( wxMenu* menu ) { if ( menu == m_menu ) @@ -397,6 +430,8 @@ wxMenu* wxSearchCtrl::GetMenu() return m_menu; } +#endif // wxUSE_MENUS + void wxSearchCtrl::ShowSearchButton( bool show ) { if ( m_searchButtonVisible == show ) @@ -459,7 +494,7 @@ wxSize wxSearchCtrl::DoGetBestSize() const wxSize sizeCancel(0,0); int searchMargin = 0; int cancelMargin = 0; - if ( m_searchButtonVisible || m_menu ) + if ( m_searchButtonVisible || HasMenu() ) { sizeSearch = m_searchButton->GetBestSize(); searchMargin = MARGIN; @@ -502,7 +537,7 @@ void wxSearchCtrl::LayoutControls(int x, int y, int width, int height) wxSize sizeCancel(0,0); int searchMargin = 0; int cancelMargin = 0; - if ( m_searchButtonVisible || m_menu ) + if ( m_searchButtonVisible || HasMenu() ) { sizeSearch = m_searchButton->GetBestSize(); searchMargin = MARGIN; @@ -512,7 +547,7 @@ void wxSearchCtrl::LayoutControls(int x, int y, int width, int height) sizeCancel = m_cancelButton->GetBestSize(); cancelMargin = MARGIN; } - m_searchButton->Show( m_searchButtonVisible || m_menu ); + m_searchButton->Show( m_searchButtonVisible || HasMenu() ); m_cancelButton->Show( m_cancelButtonVisible ); if ( sizeSearch.x + sizeCancel.x > width ) @@ -522,7 +557,7 @@ void wxSearchCtrl::LayoutControls(int x, int y, int width, int height) searchMargin = 0; cancelMargin = 0; } - wxCoord textWidth = width - sizeSearch.x - sizeCancel.x - searchMargin - cancelMargin; + wxCoord textWidth = width - sizeSearch.x - sizeCancel.x - searchMargin - cancelMargin - 1; // position the subcontrols inside the client area @@ -810,7 +845,7 @@ void wxSearchCtrl::SetSearchBitmap( const wxBitmap& bitmap ) m_searchBitmapUser = bitmap.Ok(); if ( m_searchBitmapUser ) { - if ( m_searchButton && !m_menu ) + if ( m_searchButton && !HasMenu() ) { m_searchButton->SetBitmapLabel( m_searchBitmap ); } @@ -822,6 +857,8 @@ void wxSearchCtrl::SetSearchBitmap( const wxBitmap& bitmap ) } } +#if wxUSE_MENUS + void wxSearchCtrl::SetSearchMenuBitmap( const wxBitmap& bitmap ) { m_searchMenuBitmap = bitmap; @@ -840,6 +877,8 @@ void wxSearchCtrl::SetSearchMenuBitmap( const wxBitmap& bitmap ) } } +#endif // wxUSE_MENUS + void wxSearchCtrl::SetCancelBitmap( const wxBitmap& bitmap ) { m_cancelBitmap = bitmap; @@ -877,9 +916,17 @@ wxTextCtrl& operator<<(const wxChar c); void wxSearchCtrl::DoSetValue(const wxString& value, int flags) { - m_text->ChangeValue( value ); - if ( flags & SetValue_SendEvent ) - SendTextUpdatedEvent(); + m_text->DoSetValue(value, flags); +} + +bool wxSearchCtrl::DoLoadFile(const wxString& file, int fileType) +{ + return m_text->DoLoadFile(file, fileType); +} + +bool wxSearchCtrl::DoSaveFile(const wxString& file, int fileType) +{ + return m_text->DoSaveFile(file, fileType); } // do the window-specific processing after processing the update event @@ -1121,7 +1168,7 @@ void wxSearchCtrl::RecalcBitmaps() ) { m_searchBitmap = RenderSearchBitmap(bitmapWidth,bitmapHeight,false); - if ( !m_menu ) + if ( !HasMenu() ) { m_searchButton->SetBitmapLabel(m_searchBitmap); } @@ -1129,6 +1176,7 @@ void wxSearchCtrl::RecalcBitmaps() // else this bitmap was set by user, don't alter } +#if wxUSE_MENUS if ( !m_searchMenuBitmapUser ) { if ( @@ -1145,6 +1193,7 @@ void wxSearchCtrl::RecalcBitmaps() } // else this bitmap was set by user, don't alter } +#endif // wxUSE_MENUS if ( !m_cancelBitmapUser ) { @@ -1154,7 +1203,7 @@ void wxSearchCtrl::RecalcBitmaps() m_cancelBitmap.GetWidth() != bitmapHeight ) { - m_cancelBitmap = RenderCancelBitmap(bitmapHeight-BORDER,bitmapHeight-BORDER); // square + m_cancelBitmap = RenderCancelBitmap(bitmapHeight-BORDER-1,bitmapHeight-BORDER-1); // square m_cancelButton->SetBitmapLabel(m_cancelBitmap); } // else this bitmap was set by user, don't alter @@ -1181,6 +1230,8 @@ void wxSearchCtrl::OnSize( wxSizeEvent& WXUNUSED(event) ) LayoutControls(0, 0, width, height); } +#if wxUSE_MENUS + void wxSearchCtrl::PopupSearchMenu() { if ( m_menu ) @@ -1190,6 +1241,8 @@ void wxSearchCtrl::PopupSearchMenu() } } +#endif // wxUSE_MENUS + #endif // !wxUSE_NATIVE_SEARCH_CONTROL #endif // wxUSE_SEARCHCTRL