]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_srchctrl.i
All platforms have the same GLCanvas API now
[wxWidgets.git] / wxPython / src / _srchctrl.i
CommitLineData
3f7f284d
RD
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
3f7f284d
RD
15//---------------------------------------------------------------------------
16%newgroup
17
18MAKE_CONST_WXSTRING(SearchCtrlNameStr);
19
20
8fb69159
RD
21%{
22#if !defined(wxUSE_SEARCHCTRL) || !wxUSE_SEARCHCTRL
23// define a dummy class for builds that don't have wxSearchCtrl
24
25enum {
4ed51f4d
RD
26 wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,
27 wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN
8fb69159
RD
28};
29
30class wxSearchCtrl : public wxTextCtrl
31{
32public:
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; }
6646ca90
RD
61
62 virtual void SetDescriptiveText(const wxString& text);
63 virtual wxString GetDescriptiveText() const;
8fb69159
RD
64};
65#endif
66%}
67
68
69
70// Now define the class for SWIG
71
3f7f284d 72MustHaveApp(wxSearchCtrl);
8fb69159
RD
73DocStr(wxSearchCtrl,
74"A search control is a composite of a `wx.TextCtrl` with optional
75bitmap buttons and a drop-down menu. Controls like this can typically
76be found on a toolbar of applications that support some form of search
e6239913 77functionality. On the Mac this control is implemented using the
8fb69159
RD
78native HISearchField control, on the other platforms a generic control
79is used, although that may change in the future as more platforms
80introduce native search widgets.
81
82If you wish to use a drop-down menu with your wx.SearchCtrl then you
83will need to manage its content and handle the menu events yourself,
84but 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.
86This gives you the flexibility to use the drop-down menu however you
87wish, such as for a history of searches, or as a way to select
88different kinds of searches. The ToolBar.py sample in the demo shows
89one way to do this.
90
91Since the control derives from `wx.TextCtrl` it is convenient to use
92the styles and events designed for `wx.TextCtrl`. For example you can
93use the ``wx.TE_PROCESS_ENTER`` style and catch the
94``wx.EVT_TEXT_ENTER`` event to know when the user has pressed the
95Enter key in the control and wishes to start a search.
96", "
97
98Events
99-------
4ed51f4d
RD
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 ========================= =========================================
8fb69159 108");
3f7f284d
RD
109
110
111class wxSearchCtrl : public wxTextCtrl
112{
113public:
114 %pythonAppend wxSearchCtrl "self._setOORInfo(self)";
115 %pythonAppend wxSearchCtrl() "";
116
117 wxSearchCtrl(wxWindow *parent, wxWindowID id=-1,
8fb69159
RD
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);
3f7f284d
RD
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
8fb69159
RD
139 DocDeclStr(
140 virtual void , SetMenu( wxMenu* menu ),
141 "Sets the search control's menu object. If there is already a menu
142associated 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
147is 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
154there is a menu attached, the search button will be visible regardless
155of the search button visibility value. This has no effect in Mac OS X
156v10.3", "");
157
158 DocDeclStr(
159 virtual bool , IsSearchButtonVisible() const,
160 "Returns the search button visibility value. If there is a menu
161attached, the search button will be visible regardless of the search
162button visibility value. This always returns false in Mac OS X v10.3", "");
3f7f284d 163
8fb69159
RD
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
3f7f284d 172
6646ca90
RD
173 DocDeclStr(
174 virtual void , SetDescriptiveText(const wxString& text),
175 "Set the text to be displayed when the user has not yet typed anything
176in 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
181in the control.", "");
182
183
8fb69159
RD
184 DocStr(SetSearchBitmap,
185 "Sets the bitmap to use for the search button. This currently does not
186work on the Mac.", "");
187 DocStr(SetSearchMenuBitmap,
188 "Sets the bitmap to use for the search button when there is a drop-down
189menu associated with the search control. This currently does not work
190on the Mac.", "");
191 DocStr(SetCancelBitmap,
192 "Sets the bitmap to use for the cancel button. This currently does not
193work on the Mac.", "");
6646ca90 194
8fb69159 195
3f7f284d
RD
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);
0a95d336
KO
210 %property(SearchButtonVisible, IsSearchButtonVisible, ShowSearchButton);
211 %property(CancelButtonVisible, IsCancelButtonVisible, ShowCancelButton);
6646ca90 212 %property(DescriptiveText, GetDescriptiveText, SetDescriptiveText);
3f7f284d
RD
213};
214
215
216
217
c60122bf
KO
218%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN;
219%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN;
3f7f284d
RD
220
221%pythoncode {
c60122bf
KO
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)
3f7f284d
RD
224}
225
226//---------------------------------------------------------------------------
227