]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_srchctrl.i
Put a separator between the controls
[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 {
26 wxEVT_COMMAND_SEARCHCTRL_CANCEL,
27 wxEVT_COMMAND_SEARCHCTRL_SEARCH
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; }
61};
62#endif
63%}
64
65
66
67// Now define the class for SWIG
68
3f7f284d 69MustHaveApp(wxSearchCtrl);
8fb69159
RD
70DocStr(wxSearchCtrl,
71"A search control is a composite of a `wx.TextCtrl` with optional
72bitmap buttons and a drop-down menu. Controls like this can typically
73be found on a toolbar of applications that support some form of search
74functionality. On the Mac this control is implemneted using the
75native HISearchField control, on the other platforms a generic control
76is used, although that may change in the future as more platforms
77introduce native search widgets.
78
79If you wish to use a drop-down menu with your wx.SearchCtrl then you
80will need to manage its content and handle the menu events yourself,
81but this is an easy thing to do. Simply build the menu, pass it to
82`SetMenu`, and also bind a handler for a range of EVT_MENU events.
83This gives you the flexibility to use the drop-down menu however you
84wish, such as for a history of searches, or as a way to select
85different kinds of searches. The ToolBar.py sample in the demo shows
86one way to do this.
87
88Since the control derives from `wx.TextCtrl` it is convenient to use
89the styles and events designed for `wx.TextCtrl`. For example you can
90use the ``wx.TE_PROCESS_ENTER`` style and catch the
91``wx.EVT_TEXT_ENTER`` event to know when the user has pressed the
92Enter key in the control and wishes to start a search.
93", "
94
95Events
96-------
97 ====================== =========================================
98 EVT_SEARCHCTRL_SEARCH Sent when the search icon is clicked
99 EVT_SEARCHCTRL_CANCEL Sent when the cancel icon is clicked
100 EVT_TEXT Sent when the text changes
101 EVT_TEXT_ENTER Sent when the RETURN/ENTER key is pressed
102 in the search control and the control has
103 the wx.TE_PROCESS_ENTER style flag set.
104 ====================== =========================================
105");
3f7f284d
RD
106
107
108class wxSearchCtrl : public wxTextCtrl
109{
110public:
111 %pythonAppend wxSearchCtrl "self._setOORInfo(self)";
112 %pythonAppend wxSearchCtrl() "";
113
114 wxSearchCtrl(wxWindow *parent, wxWindowID id=-1,
8fb69159
RD
115 const wxString& value = wxEmptyString,
116 const wxPoint& pos = wxDefaultPosition,
117 const wxSize& size = wxDefaultSize,
118 long style = 0,
119 const wxValidator& validator = wxDefaultValidator,
120 const wxString& name = wxPySearchCtrlNameStr);
3f7f284d
RD
121
122 DocCtorStrName(
123 wxSearchCtrl(),
124 "Precreate a wx.SearchCtrl for 2-phase creation.", "",
125 PreSearchCtrl);
126
127 bool Create(wxWindow *parent, wxWindowID id=-1,
128 const wxString& value = wxEmptyString,
129 const wxPoint& pos = wxDefaultPosition,
130 const wxSize& size = wxDefaultSize,
131 long style = 0,
132 const wxValidator& validator = wxDefaultValidator,
133 const wxString& name = wxPySearchCtrlNameStr);
134
135
8fb69159
RD
136 DocDeclStr(
137 virtual void , SetMenu( wxMenu* menu ),
138 "Sets the search control's menu object. If there is already a menu
139associated with the search control it is deleted.", "");
140
141 DocDeclStr(
142 virtual wxMenu* , GetMenu(),
143 "Returns a pointer to the search control's menu object or None if there
144is no menu attached.", "");
145
146
147
148 DocDeclStr(
149 virtual void , ShowSearchButton( bool show ),
150 "Sets the search button visibility value on the search control. If
151there is a menu attached, the search button will be visible regardless
152of the search button visibility value. This has no effect in Mac OS X
153v10.3", "");
154
155 DocDeclStr(
156 virtual bool , IsSearchButtonVisible() const,
157 "Returns the search button visibility value. If there is a menu
158attached, the search button will be visible regardless of the search
159button visibility value. This always returns false in Mac OS X v10.3", "");
3f7f284d 160
8fb69159
RD
161 DocDeclStr(
162 virtual void , ShowCancelButton( bool show ),
163 "Shows or hides the cancel button.", "");
164
165 DocDeclStr(
166 virtual bool , IsCancelButtonVisible() const,
167 "Indicates whether the cancel button is visible. ", "");
168
3f7f284d 169
8fb69159
RD
170 DocStr(SetSearchBitmap,
171 "Sets the bitmap to use for the search button. This currently does not
172work on the Mac.", "");
173 DocStr(SetSearchMenuBitmap,
174 "Sets the bitmap to use for the search button when there is a drop-down
175menu associated with the search control. This currently does not work
176on the Mac.", "");
177 DocStr(SetCancelBitmap,
178 "Sets the bitmap to use for the cancel button. This currently does not
179work on the Mac.", "");
180
3f7f284d
RD
181#ifdef __WXMAC__
182 %extend {
183 void SetSearchBitmap( const wxBitmap& ) {}
184 void SetSearchMenuBitmap( const wxBitmap& ) {}
185 void SetCancelBitmap( const wxBitmap& ) {}
186 }
187#else
188 void SetSearchBitmap( const wxBitmap& bitmap );
189 void SetSearchMenuBitmap( const wxBitmap& bitmap );
190 void SetCancelBitmap( const wxBitmap& bitmap );
191#endif
192
193
194 %property(Menu, GetMenu, SetMenu);
0a95d336
KO
195 %property(SearchButtonVisible, IsSearchButtonVisible, ShowSearchButton);
196 %property(CancelButtonVisible, IsCancelButtonVisible, ShowCancelButton);
3f7f284d
RD
197};
198
199
200
201
c60122bf
KO
202%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN;
203%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN;
3f7f284d
RD
204
205%pythoncode {
c60122bf
KO
206 EVT_SEARCHCTRL_CANCEL_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, 1)
207 EVT_SEARCHCTRL_SEARCH_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, 1)
3f7f284d
RD
208}
209
210//---------------------------------------------------------------------------
211