1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for wxSearchCtrl
9 // Copyright: (c) 2006 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
15 //---------------------------------------------------------------------------
18 MAKE_CONST_WXSTRING(SearchCtrlNameStr);
22 #if !defined(wxUSE_SEARCHCTRL) || !wxUSE_SEARCHCTRL
23 // define a dummy class for builds that don't have wxSearchCtrl
26 wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,
27 wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN
30 class wxSearchCtrl : public wxTextCtrl
33 wxSearchCtrl() { wxPyRaiseNotImplemented(); }
34 wxSearchCtrl(wxWindow*, wxWindowID,
41 { wxPyRaiseNotImplemented(); }
43 bool Create( wxWindow*, wxWindowID,
49 const wxString& name) {}
51 virtual void SetMenu( wxMenu* ) {}
52 virtual wxMenu* GetMenu() { return NULL; }
54 // get/set search options
55 // ----------------------
56 virtual void ShowSearchButton( bool ) {}
57 virtual bool IsSearchButtonVisible() const { return false; }
59 virtual void ShowCancelButton( bool ) {}
60 virtual bool IsCancelButtonVisible() const { return false; }
62 virtual void SetDescriptiveText(const wxString& text);
63 virtual wxString GetDescriptiveText() const;
70 // Now define the class for SWIG
72 MustHaveApp(wxSearchCtrl);
74 "A search control is a composite of a `wx.TextCtrl` with optional
75 bitmap buttons and a drop-down menu. Controls like this can typically
76 be found on a toolbar of applications that support some form of search
77 functionality. On the Mac this control is implemented using the
78 native HISearchField control, on the other platforms a generic control
79 is used, although that may change in the future as more platforms
80 introduce native search widgets.
82 If you wish to use a drop-down menu with your wx.SearchCtrl then you
83 will need to manage its content and handle the menu events yourself,
84 but this is an easy thing to do. Simply build the menu, pass it to
85 `SetMenu`, and also bind a handler for a range of EVT_MENU events.
86 This gives you the flexibility to use the drop-down menu however you
87 wish, such as for a history of searches, or as a way to select
88 different kinds of searches. The ToolBar.py sample in the demo shows
91 Since the control derives from `wx.TextCtrl` it is convenient to use
92 the styles and events designed for `wx.TextCtrl`. For example you can
93 use the ``wx.TE_PROCESS_ENTER`` style and catch the
94 ``wx.EVT_TEXT_ENTER`` event to know when the user has pressed the
95 Enter key in the control and wishes to start a search.
100 ========================= =========================================
101 EVT_SEARCHCTRL_SEARCH_BTN Sent when the search icon is clicked
102 EVT_SEARCHCTRL_CANCEL_BTN Sent when the cancel icon is clicked
103 EVT_TEXT Sent when the text changes
104 EVT_TEXT_ENTER Sent when the RETURN/ENTER key is pressed
105 in the search control and the control has
106 the wx.TE_PROCESS_ENTER style flag set.
107 ========================= =========================================
111 class wxSearchCtrl : public wxTextCtrl
114 %pythonAppend wxSearchCtrl "self._setOORInfo(self)";
115 %pythonAppend wxSearchCtrl() "";
117 wxSearchCtrl(wxWindow *parent, wxWindowID id=-1,
118 const wxString& value = wxEmptyString,
119 const wxPoint& pos = wxDefaultPosition,
120 const wxSize& size = wxDefaultSize,
122 const wxValidator& validator = wxDefaultValidator,
123 const wxString& name = wxPySearchCtrlNameStr);
127 "Precreate a wx.SearchCtrl for 2-phase creation.", "",
130 bool Create(wxWindow *parent, wxWindowID id=-1,
131 const wxString& value = wxEmptyString,
132 const wxPoint& pos = wxDefaultPosition,
133 const wxSize& size = wxDefaultSize,
135 const wxValidator& validator = wxDefaultValidator,
136 const wxString& name = wxPySearchCtrlNameStr);
140 virtual void , SetMenu( wxMenu* menu ),
141 "Sets the search control's menu object. If there is already a menu
142 associated with the search control it is deleted.", "");
145 virtual wxMenu* , GetMenu(),
146 "Returns a pointer to the search control's menu object or None if there
147 is no menu attached.", "");
152 virtual void , ShowSearchButton( bool show ),
153 "Sets the search button visibility value on the search control. If
154 there is a menu attached, the search button will be visible regardless
155 of the search button visibility value. This has no effect in Mac OS X
159 virtual bool , IsSearchButtonVisible() const,
160 "Returns the search button visibility value. If there is a menu
161 attached, the search button will be visible regardless of the search
162 button visibility value. This always returns false in Mac OS X v10.3", "");
165 virtual void , ShowCancelButton( bool show ),
166 "Shows or hides the cancel button.", "");
169 virtual bool , IsCancelButtonVisible() const,
170 "Indicates whether the cancel button is visible. ", "");
174 virtual void , SetDescriptiveText(const wxString& text),
175 "Set the text to be displayed when the user has not yet typed anything
176 in the control.", "");
179 virtual wxString , GetDescriptiveText() const,
180 "Get the text to be displayed when the user has not yet typed anything
181 in the control.", "");
184 DocStr(SetSearchBitmap,
185 "Sets the bitmap to use for the search button. This currently does not
186 work on the Mac.", "");
187 DocStr(SetSearchMenuBitmap,
188 "Sets the bitmap to use for the search button when there is a drop-down
189 menu associated with the search control. This currently does not work
191 DocStr(SetCancelBitmap,
192 "Sets the bitmap to use for the cancel button. This currently does not
193 work on the Mac.", "");
198 void SetSearchBitmap( const wxBitmap& ) {}
199 void SetSearchMenuBitmap( const wxBitmap& ) {}
200 void SetCancelBitmap( const wxBitmap& ) {}
203 void SetSearchBitmap( const wxBitmap& bitmap );
204 void SetSearchMenuBitmap( const wxBitmap& bitmap );
205 void SetCancelBitmap( const wxBitmap& bitmap );
209 %property(Menu, GetMenu, SetMenu);
210 %property(SearchButtonVisible, IsSearchButtonVisible, ShowSearchButton);
211 %property(CancelButtonVisible, IsCancelButtonVisible, ShowCancelButton);
212 %property(DescriptiveText, GetDescriptiveText, SetDescriptiveText);
218 %constant wxEventType wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN;
219 %constant wxEventType wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN;
222 EVT_SEARCHCTRL_CANCEL_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, 1)
223 EVT_SEARCHCTRL_SEARCH_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, 1)
226 //---------------------------------------------------------------------------