]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_srchctrl.i
made main toolbar bitmaps 24x24
[wxWidgets.git] / wxPython / src / _srchctrl.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _srchctrl.i
3 // Purpose: SWIG interface for wxSearchCtrl
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 9-Dec-2006
8 // RCS-ID: $Id$
9 // Copyright: (c) 2006 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15 //---------------------------------------------------------------------------
16 %newgroup
17
18 MAKE_CONST_WXSTRING(SearchCtrlNameStr);
19
20
21 %{
22 #if !defined(wxUSE_SEARCHCTRL) || !wxUSE_SEARCHCTRL
23 // define a dummy class for builds that don't have wxSearchCtrl
24
25 enum {
26 wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,
27 wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN
28 };
29
30 class wxSearchCtrl : public wxTextCtrl
31 {
32 public:
33 wxSearchCtrl() { wxPyRaiseNotImplemented(); }
34 wxSearchCtrl(wxWindow*, wxWindowID,
35 const wxString&,
36 const wxPoint&,
37 const wxSize&,
38 long style,
39 const wxValidator&,
40 const wxString& name)
41 { wxPyRaiseNotImplemented(); }
42
43 bool Create( wxWindow*, wxWindowID,
44 const wxString&,
45 const wxPoint&,
46 const wxSize&,
47 long style,
48 const wxValidator&,
49 const wxString& name) {}
50
51 virtual void SetMenu( wxMenu* ) {}
52 virtual wxMenu* GetMenu() { return NULL; }
53
54 // get/set search options
55 // ----------------------
56 virtual void ShowSearchButton( bool ) {}
57 virtual bool IsSearchButtonVisible() const { return false; }
58
59 virtual void ShowCancelButton( bool ) {}
60 virtual bool IsCancelButtonVisible() const { return false; }
61
62 virtual void SetDescriptiveText(const wxString& text);
63 virtual wxString GetDescriptiveText() const;
64 };
65 #endif
66 %}
67
68
69
70 // Now define the class for SWIG
71
72 MustHaveApp(wxSearchCtrl);
73 DocStr(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.
81
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
89 one way to do this.
90
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.
96 ", "
97
98 Events
99 -------
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 ========================= =========================================
108 ");
109
110
111 class wxSearchCtrl : public wxTextCtrl
112 {
113 public:
114 %pythonAppend wxSearchCtrl "self._setOORInfo(self)";
115 %pythonAppend wxSearchCtrl() "";
116
117 wxSearchCtrl(wxWindow *parent, wxWindowID id=-1,
118 const wxString& value = wxEmptyString,
119 const wxPoint& pos = wxDefaultPosition,
120 const wxSize& size = wxDefaultSize,
121 long style = 0,
122 const wxValidator& validator = wxDefaultValidator,
123 const wxString& name = wxPySearchCtrlNameStr);
124
125 DocCtorStrName(
126 wxSearchCtrl(),
127 "Precreate a wx.SearchCtrl for 2-phase creation.", "",
128 PreSearchCtrl);
129
130 bool Create(wxWindow *parent, wxWindowID id=-1,
131 const wxString& value = wxEmptyString,
132 const wxPoint& pos = wxDefaultPosition,
133 const wxSize& size = wxDefaultSize,
134 long style = 0,
135 const wxValidator& validator = wxDefaultValidator,
136 const wxString& name = wxPySearchCtrlNameStr);
137
138
139 DocDeclStr(
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.", "");
143
144 DocDeclStr(
145 virtual wxMenu* , GetMenu(),
146 "Returns a pointer to the search control's menu object or None if there
147 is no menu attached.", "");
148
149
150
151 DocDeclStr(
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
156 v10.3", "");
157
158 DocDeclStr(
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", "");
163
164 DocDeclStr(
165 virtual void , ShowCancelButton( bool show ),
166 "Shows or hides the cancel button.", "");
167
168 DocDeclStr(
169 virtual bool , IsCancelButtonVisible() const,
170 "Indicates whether the cancel button is visible. ", "");
171
172
173 DocDeclStr(
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.", "");
177
178 DocDeclStr(
179 virtual wxString , GetDescriptiveText() const,
180 "Get the text to be displayed when the user has not yet typed anything
181 in the control.", "");
182
183
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
190 on the Mac.", "");
191 DocStr(SetCancelBitmap,
192 "Sets the bitmap to use for the cancel button. This currently does not
193 work on the Mac.", "");
194
195
196 #ifdef __WXMAC__
197 %extend {
198 void SetSearchBitmap( const wxBitmap& ) {}
199 void SetSearchMenuBitmap( const wxBitmap& ) {}
200 void SetCancelBitmap( const wxBitmap& ) {}
201 }
202 #else
203 void SetSearchBitmap( const wxBitmap& bitmap );
204 void SetSearchMenuBitmap( const wxBitmap& bitmap );
205 void SetCancelBitmap( const wxBitmap& bitmap );
206 #endif
207
208
209 %property(Menu, GetMenu, SetMenu);
210 %property(SearchButtonVisible, IsSearchButtonVisible, ShowSearchButton);
211 %property(CancelButtonVisible, IsCancelButtonVisible, ShowCancelButton);
212 %property(DescriptiveText, GetDescriptiveText, SetDescriptiveText);
213 };
214
215
216
217
218 %constant wxEventType wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN;
219 %constant wxEventType wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN;
220
221 %pythoncode {
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)
224 }
225
226 //---------------------------------------------------------------------------
227