1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxSearchCtrl
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
11 A search control is a composite control with a search button, a text
12 control, and a cancel button.
15 @style{wxTE_PROCESS_ENTER}
16 The control will generate the event @c wxEVT_TEXT_ENTER
17 (otherwise pressing Enter key is either processed internally by the
18 control or used for navigation between dialog controls).
19 @style{wxTE_PROCESS_TAB}
20 The control will receive @c wxEVT_CHAR events for TAB pressed -
21 normally, TAB is used for passing to the next control in a dialog
22 instead. For the control created with this style, you can still use
23 Ctrl-Enter to pass to the next control from the keyboard.
24 @style{wxTE_NOHIDESEL}
25 By default, the Windows text control doesn't show the selection
26 when it doesn't have focus - use this style to force it to always
27 show it. It doesn't do anything under other platforms.
29 The text in the control will be left-justified (default).
31 The text in the control will be centered (currently wxMSW and
34 The text in the control will be right-justified (currently wxMSW
36 @style{wxTE_CAPITALIZE}
37 On PocketPC and Smartphone, causes the first letter to be
41 @beginEventEmissionTable{wxCommandEvent}
42 To retrieve actual search queries, use EVT_TEXT and EVT_TEXT_ENTER events,
43 just as you would with wxTextCtrl.
44 @event{EVT_SEARCHCTRL_SEARCH_BTN(id, func)}
45 Respond to a @c wxEVT_SEARCHCTRL_SEARCH_BTN event, generated when the
46 search button is clicked. Note that this does not initiate a search on
47 its own, you need to perform the appropriate action in your event
48 handler. You may use @code event.GetString() @endcode to retrieve the
49 string to search for in the event handler code.
50 @event{EVT_SEARCHCTRL_CANCEL_BTN(id, func)}
51 Respond to a @c wxEVT_SEARCHCTRL_CANCEL_BTN event, generated when the
52 cancel button is clicked.
57 @appearance{searchctrl}
59 @see wxTextCtrl::Create, wxValidator
61 class wxSearchCtrl
: public wxTextCtrl
70 Constructor, creating and showing a text control.
73 Parent window. Should not be @NULL.
75 Control identifier. A value of -1 denotes a default value.
79 Text control position.
83 Window style. See wxSearchCtrl.
89 @see wxTextCtrl::Create, wxValidator
91 wxSearchCtrl(wxWindow
* parent
, wxWindowID id
,
92 const wxString
& value
= wxEmptyString
,
93 const wxPoint
& pos
= wxDefaultPosition
,
94 const wxSize
& size
= wxDefaultSize
,
96 const wxValidator
& validator
= wxDefaultValidator
,
97 const wxString
& name
= wxSearchCtrlNameStr
);
100 Destructor, destroying the search control.
102 virtual ~wxSearchCtrl();
105 bool Create(wxWindow
* parent
, wxWindowID id
,
106 const wxString
& value
= wxEmptyString
,
107 const wxPoint
& pos
= wxDefaultPosition
,
108 const wxSize
& size
= wxDefaultSize
,
110 const wxValidator
& validator
= wxDefaultValidator
,
111 const wxString
& name
= wxSearchCtrlNameStr
);
114 Returns a pointer to the search control's menu object or @NULL if there is no
117 virtual wxMenu
* GetMenu();
120 Returns the search button visibility value.
121 If there is a menu attached, the search button will be visible regardless of
122 the search button visibility value.
124 This always returns @false in Mac OS X v10.3
126 virtual bool IsSearchButtonVisible() const;
129 Returns the cancel button's visibility state.
131 virtual bool IsCancelButtonVisible() const;
134 Sets the search control's menu object.
135 If there is already a menu associated with the search control it is deleted.
138 Menu to attach to the search control.
140 virtual void SetMenu(wxMenu
* menu
);
143 Shows or hides the cancel button.
145 virtual void ShowCancelButton(bool show
);
148 Sets the search button visibility value on the search control.
149 If there is a menu attached, the search button will be visible regardless of
150 the search button visibility value.
152 This has no effect in Mac OS X v10.3
154 virtual void ShowSearchButton(bool show
);
157 Set the text to be displayed in the search control when the user has
158 not yet typed anything in it.
160 void SetDescriptiveText(const wxString
& text
);
163 Return the text displayed when there is not yet any user input.
165 wxString
GetDescriptiveText() const;
169 wxEventType wxEVT_SEARCHCTRL_CANCEL_BTN
;
170 wxEventType wxEVT_SEARCHCTRL_SEARCH_BTN
;