Merge branch 'search-desctext'

wxSearchCtrl fixes for wxMSW and add "hint" property to its XRC handler.

See https://github.com/wxWidgets/wxWidgets/pull/691
This commit is contained in:
Vadim Zeitlin
2018-01-28 16:14:10 +01:00
8 changed files with 17 additions and 8 deletions

View File

@@ -176,6 +176,7 @@ All (GUI):
- Add wxFontPickerCtrl::SetMinPointSize() (Andreas Falkenhahn). - Add wxFontPickerCtrl::SetMinPointSize() (Andreas Falkenhahn).
- Add Set/GetFooter/Text/Icon() to wxRichMessageDialog (Tobias Taschner) - Add Set/GetFooter/Text/Icon() to wxRichMessageDialog (Tobias Taschner)
- Add wxFloatingPointValidator::SetFactor(). - Add wxFloatingPointValidator::SetFactor().
- Add "hint" property to wxSearchCtrl XRC handler.
wxGTK: wxGTK:

View File

@@ -1950,6 +1950,9 @@ child and the second one for right/bottom child window.
@hdr3col{property, type, description} @hdr3col{property, type, description}
@row3col{value, @ref overview_xrcformat_type_text, @row3col{value, @ref overview_xrcformat_type_text,
Initial value of the control (default: empty).} Initial value of the control (default: empty).}
@row3col{hint, @ref overview_xrcformat_type_text,
Descriptive text shown in the empty control (default: "Search"). This
property is new since wxWidgets 3.1.1.}
@endTable @endTable

View File

@@ -61,9 +61,8 @@ public:
virtual void ShowCancelButton( bool show ) wxOVERRIDE; virtual void ShowCancelButton( bool show ) wxOVERRIDE;
virtual bool IsCancelButtonVisible() const wxOVERRIDE; virtual bool IsCancelButtonVisible() const wxOVERRIDE;
// TODO: In 2.9 these should probably be virtual, and declared in the base class... virtual void SetDescriptiveText(const wxString& text) wxOVERRIDE;
void SetDescriptiveText(const wxString& text); virtual wxString GetDescriptiveText() const wxOVERRIDE;
wxString GetDescriptiveText() const;
// accessors // accessors
// --------- // ---------

View File

@@ -54,9 +54,8 @@ public:
virtual void ShowCancelButton( bool show ) wxOVERRIDE; virtual void ShowCancelButton( bool show ) wxOVERRIDE;
virtual bool IsCancelButtonVisible() const wxOVERRIDE; virtual bool IsCancelButtonVisible() const wxOVERRIDE;
// TODO: In 2.9 these should probably be virtual, and declared in the base class... virtual void SetDescriptiveText(const wxString& text) wxOVERRIDE;
void SetDescriptiveText(const wxString& text); virtual wxString GetDescriptiveText() const wxOVERRIDE;
wxString GetDescriptiveText() const;
virtual bool HandleSearchFieldSearchHit() ; virtual bool HandleSearchFieldSearchHit() ;
virtual bool HandleSearchFieldCancelHit() ; virtual bool HandleSearchFieldCancelHit() ;

View File

@@ -68,6 +68,9 @@ public:
virtual void ShowCancelButton( bool show ) = 0; virtual void ShowCancelButton( bool show ) = 0;
virtual bool IsCancelButtonVisible() const = 0; virtual bool IsCancelButtonVisible() const = 0;
virtual void SetDescriptiveText(const wxString& text) = 0;
virtual wxString GetDescriptiveText() const = 0;
private: private:
// implement wxTextEntry pure virtual method // implement wxTextEntry pure virtual method
virtual wxWindow *GetEditableWindow() wxOVERRIDE { return this; } virtual wxWindow *GetEditableWindow() wxOVERRIDE { return this; }

View File

@@ -49,7 +49,7 @@ class wxSearchTextCtrl : public wxTextCtrl
public: public:
wxSearchTextCtrl(wxSearchCtrl *search, const wxString& value, int style) wxSearchTextCtrl(wxSearchCtrl *search, const wxString& value, int style)
: wxTextCtrl(search, wxID_ANY, value, wxDefaultPosition, wxDefaultSize, : wxTextCtrl(search, wxID_ANY, value, wxDefaultPosition, wxDefaultSize,
(style & ~wxBORDER_MASK) | wxNO_BORDER) (style & ~wxBORDER_MASK) | wxNO_BORDER | wxTE_PROCESS_ENTER)
{ {
m_search = search; m_search = search;

View File

@@ -2078,7 +2078,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
// forces at the moment unfortunately // forces at the moment unfortunately
if ( !(m_windowStyle & wxTE_PROCESS_TAB)) if ( !(m_windowStyle & wxTE_PROCESS_TAB))
{ {
if ( FindFocus() == this ) if ( ::GetFocus() == GetHwnd() )
{ {
int flags = 0; int flags = 0;
if (!event.ShiftDown()) if (!event.ShiftDown())

View File

@@ -49,6 +49,10 @@ wxObject *wxSearchCtrlXmlHandler::DoCreateResource()
SetupWindow(ctrl); SetupWindow(ctrl);
const wxString& hint = GetText(wxS("hint"));
if ( !hint.empty() )
ctrl->SetDescriptiveText(hint);
return ctrl; return ctrl;
} }