]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_picker.i
Added wrappers for the Picker controls.
[wxWidgets.git] / wxPython / src / _picker.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _picker.i
3 // Purpose: SWIG interface for Colour, Dir, File, Font picker controls
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 6-June-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 //---------------------------------------------------------------------------
17 %newgroup
18
19 %{
20 #include <wx/pickerbase.h>
21 #include <wx/clrpicker.h>
22 #include <wx/filepicker.h>
23 #include <wx/fontpicker.h>
24 %}
25
26
27 enum {
28 wxPB_USE_TEXTCTRL,
29 };
30
31
32 DocStr(wxPickerBase,
33 "Base abstract class for all pickers which support an auxiliary text
34 control. This class handles all positioning and sizing of the text
35 control like a an horizontal `wx.BoxSizer` would do, with the text
36 control on the left of the picker button and the proportion of the
37 picker fixed to value 1.", "");
38
39 class wxPickerBase : public wxControl
40 {
41 public:
42 // This class is an ABC, can't be instantiated from Python.
43 //wxPickerBase() : m_text(NULL), m_picker(NULL),
44 // m_margin(5), m_textProportion(2) {}
45 //virtual ~wxPickerBase();
46
47
48 // if present, intercepts wxPB_USE_TEXTCTRL style and creates the text control
49 // The 3rd argument is the initial wxString to display in the text control
50 bool CreateBase(wxWindow *parent, wxWindowID id,
51 const wxString& text = wxEmptyString,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize, long style = 0,
54 const wxValidator& validator = wxDefaultValidator,
55 const wxString& name = wxButtonNameStr);
56
57
58
59 DocDeclStr(
60 void , SetInternalMargin(int newmargin),
61 "Sets the margin (in pixels) between the picker and the text control.", "");
62
63 DocDeclStr(
64 int , GetInternalMargin() const,
65 "Returns the margin (in pixels) between the picker and the text
66 control.", "");
67
68
69 DocDeclStr(
70 void , SetTextCtrlProportion(int prop),
71 "Sets the proportion between the text control and the picker button.
72 This is used to set relative sizes of the text contorl and the picker.
73 The value passed to this function must be >= 1.", "");
74
75 DocDeclStr(
76 int , GetTextCtrlProportion() const,
77 "Returns the proportion between the text control and the picker.", "");
78
79
80 DocDeclStr(
81 bool , HasTextCtrl() const,
82 "Returns true if this class has a valid text control (i.e. if the
83 wx.PB_USE_TEXTCTRL style was given when creating this control).", "");
84
85 DocDeclStr(
86 wxTextCtrl *, GetTextCtrl(),
87 "Returns a pointer to the text control handled by this class or None if
88 the wx.PB_USE_TEXTCTRL style was not specified when this control was
89 created.
90
91 Very important: the contents of the text control could be containing
92 an invalid representation of the entity which can be chosen through
93 the picker (e.g. the user entered an invalid colour syntax because of
94 a typo). Thus you should never parse the content of the textctrl to
95 get the user's input; rather use the derived-class getter
96 (e.g. `wx.ColourPickerCtrl.GetColour`, `wx.FilePickerCtrl.GetPath`,
97 etc).", "");
98
99 DocDeclStr(
100 wxControl *, GetPickerCtrl(),
101 "", "");
102
103 };
104
105 //---------------------------------------------------------------------------
106 %newgroup
107
108 MAKE_CONST_WXSTRING(ColourPickerCtrlNameStr);
109
110 enum {
111 wxCLRP_SHOW_LABEL,
112 wxCLRP_USE_TEXTCTRL,
113 wxCLRP_DEFAULT_STYLE,
114 };
115
116
117 MustHaveApp(wxColourPickerCtrl);
118 DocStr(wxColourPickerCtrl,
119 "This control allows the user to select a colour. The generic
120 implementation is a button which brings up a `wx.ColourDialog` when
121 clicked. Native implementations may differ but this is usually a
122 (small) widget which give access to the colour-chooser dialog.",
123
124 "
125 Window Styles
126 -------------
127 ====================== ============================================
128 wx.CLRP_DEFAULT Default style.
129 wx.CLRP_USE_TEXTCTRL Creates a text control to the left of the
130 picker button which is completely managed
131 by the `wx.ColourPickerCtrl` and which can
132 be used by the user to specify a colour.
133 The text control is automatically synchronized
134 with the button's value. Use functions defined in
135 `wx.PickerBase` to modify the text control.
136 wx.CLRP_SHOW_LABEL Shows the colour in HTML form (AABBCC) as the
137 colour button label (instead of no label at all).
138 ====================== ============================================
139
140 Events
141 ------
142 ======================== ==========================================
143 EVT_COLOURPICKER_CHANGED The user changed the colour selected in the
144 control either using the button or using the
145 text control (see wx.CLRP_USE_TEXTCTRL; note
146 that in this case the event is fired only if
147 the user's input is valid, i.e. recognizable).
148 ======================== ==========================================
149 ");
150
151 class wxColourPickerCtrl : public wxPickerBase
152 {
153 public:
154 %pythonAppend wxColourPickerCtrl "self._setOORInfo(self)"
155 %pythonAppend wxColourPickerCtrl() ""
156
157 wxColourPickerCtrl(wxWindow *parent, wxWindowID id=-1,
158 const wxColour& col = *wxBLACK,
159 const wxPoint& pos = wxDefaultPosition,
160 const wxSize& size = wxDefaultSize,
161 long style = wxCLRP_DEFAULT_STYLE,
162 const wxValidator& validator = wxDefaultValidator,
163 const wxString& name = wxPyColourPickerCtrlNameStr);
164 %RenameCtor(PreColourPickerCtrl, wxColourPickerCtrl());
165
166 bool Create(wxWindow *parent, wxWindowID id,
167 const wxColour& col = *wxBLACK,
168 const wxPoint& pos = wxDefaultPosition,
169 const wxSize& size = wxDefaultSize,
170 long style = wxCLRP_DEFAULT_STYLE,
171 const wxValidator& validator = wxDefaultValidator,
172 const wxString& name = wxPyColourPickerCtrlNameStr);
173
174
175 DocDeclStr(
176 wxColour , GetColour() const,
177 "Returns the currently selected colour.", "");
178
179
180 DocDeclStr(
181 void , SetColour(const wxColour& col),
182 "Set the displayed colour.", "");
183
184 };
185
186
187
188 %constant wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED;
189 %pythoncode {
190 EVT_COLOURPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_COLOURPICKER_CHANGED, 1 )
191 }
192
193 class wxColourPickerEvent : public wxCommandEvent
194 {
195 public:
196 wxColourPickerEvent(wxObject *generator, int id, const wxColour &col);
197
198 wxColour GetColour() const;
199 void SetColour(const wxColour &c);
200 };
201
202
203 //---------------------------------------------------------------------------
204 %newgroup
205
206 MAKE_CONST_WXSTRING(FilePickerCtrlNameStr);
207 MAKE_CONST_WXSTRING(FileSelectorPromptStr);
208 MAKE_CONST_WXSTRING(DirPickerCtrlNameStr);
209 MAKE_CONST_WXSTRING(DirSelectorPromptStr);
210 MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
211
212
213 enum {
214 wxFLP_OPEN,
215 wxFLP_SAVE,
216 wxFLP_OVERWRITE_PROMPT,
217 wxFLP_FILE_MUST_EXIST,
218 wxFLP_CHANGE_DIR,
219 wxDIRP_DIR_MUST_EXIST,
220 wxDIRP_CHANGE_DIR,
221
222 wxFLP_USE_TEXTCTRL,
223 wxFLP_DEFAULT_STYLE,
224
225 wxDIRP_USE_TEXTCTRL,
226 wxDIRP_DEFAULT_STYLE,
227 };
228
229
230
231 MustHaveApp(wxFilePickerCtrl);
232 DocStr(wxFilePickerCtrl,
233 "", "");
234
235 class wxFilePickerCtrl : public wxPickerBase
236 {
237 public:
238 %pythonAppend wxFilePickerCtrl "self._setOORInfo(self)"
239 %pythonAppend wxFilePickerCtrl() ""
240
241 wxFilePickerCtrl(wxWindow *parent,
242 wxWindowID id=-1,
243 const wxString& path = wxPyEmptyString,
244 const wxString& message = wxPyFileSelectorPromptStr,
245 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
246 const wxPoint& pos = wxDefaultPosition,
247 const wxSize& size = wxDefaultSize,
248 long style = wxFLP_DEFAULT_STYLE,
249 const wxValidator& validator = wxDefaultValidator,
250 const wxString& name = wxPyFilePickerCtrlNameStr);
251 %RenameCtor(PreFilePickerCtrl, wxFilePickerCtrl());
252
253 bool Create(wxWindow *parent,
254 wxWindowID id=-1,
255 const wxString& path = wxPyEmptyString,
256 const wxString& message = wxPyFileSelectorPromptStr,
257 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
258 const wxPoint& pos = wxDefaultPosition,
259 const wxSize& size = wxDefaultSize,
260 long style = wxFLP_DEFAULT_STYLE,
261 const wxValidator& validator = wxDefaultValidator,
262 const wxString& name = wxPyFilePickerCtrlNameStr);
263
264 wxString GetPath() const;
265 void SetPath(const wxString &str);
266
267 };
268
269
270
271
272 MustHaveApp(wxDirPickerCtrl);
273 DocStr(wxDirPickerCtrl,
274 "", "");
275
276 class wxDirPickerCtrl : public wxPickerBase
277 {
278 public:
279 %pythonAppend wxDirPickerCtrl "self._setOORInfo(self)"
280 %pythonAppend wxDirPickerCtrl() ""
281
282 wxDirPickerCtrl(wxWindow *parent, wxWindowID id=-1,
283 const wxString& path = wxPyEmptyString,
284 const wxString& message = wxPyDirSelectorPromptStr,
285 const wxPoint& pos = wxDefaultPosition,
286 const wxSize& size = wxDefaultSize,
287 long style = wxDIRP_DEFAULT_STYLE,
288 const wxValidator& validator = wxDefaultValidator,
289 const wxString& name = wxPyDirPickerCtrlNameStr);
290 %RenameCtor(PreDirPickerCtrl, wxDirPickerCtrl());
291
292 bool Create(wxWindow *parent, wxWindowID id=-1,
293 const wxString& path = wxPyEmptyString,
294 const wxString& message = wxPyDirSelectorPromptStr,
295 const wxPoint& pos = wxDefaultPosition,
296 const wxSize& size = wxDefaultSize,
297 long style = wxDIRP_DEFAULT_STYLE,
298 const wxValidator& validator = wxDefaultValidator,
299 const wxString& name = wxPyDirPickerCtrlNameStr);
300
301 wxString GetPath() const;
302 void SetPath(const wxString &str);
303 };
304
305
306 %constant wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
307 %constant wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
308
309 %pythoncode {
310 EVT_FILEPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FILEPICKER_CHANGED, 1 )
311 EVT_DIRPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_DIRPICKER_CHANGED, 1 )
312 }
313
314 class wxFileDirPickerEvent : public wxCommandEvent
315 {
316 public:
317 wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path);
318
319 wxString GetPath() const { return m_path; }
320 void SetPath(const wxString &p) { m_path = p; }
321 };
322
323
324 //---------------------------------------------------------------------------
325 %newgroup
326
327 MAKE_CONST_WXSTRING(FontPickerCtrlNameStr);
328
329 enum {
330 wxFNTP_FONTDESC_AS_LABEL,
331 wxFNTP_USEFONT_FOR_LABEL,
332 wxFNTP_USE_TEXTCTRL,
333 wxFNTP_DEFAULT_STYLE,
334 };
335
336
337 MustHaveApp(wxFontPickerCtrl);
338 DocStr(wxFontPickerCtrl,
339 "", "");
340
341
342 class wxFontPickerCtrl : public wxPickerBase
343 {
344 public:
345 %pythonAppend wxFontPickerCtrl "self._setOORInfo(self)"
346 %pythonAppend wxFontPickerCtrl() ""
347
348
349 wxFontPickerCtrl(wxWindow *parent,
350 wxWindowID id=-1,
351 const wxFont& initial = *wxNORMAL_FONT,
352 const wxPoint& pos = wxDefaultPosition,
353 const wxSize& size = wxDefaultSize,
354 long style = wxFNTP_DEFAULT_STYLE,
355 const wxValidator& validator = wxDefaultValidator,
356 const wxString& name = wxPyFontPickerCtrlNameStr);
357 %RenameCtor(PreFontPickerCtrl, wxFontPickerCtrl());
358
359 bool Create(wxWindow *parent,
360 wxWindowID id=-1,
361 const wxFont& initial = *wxNORMAL_FONT,
362 const wxPoint& pos = wxDefaultPosition,
363 const wxSize& size = wxDefaultSize,
364 long style = wxFNTP_DEFAULT_STYLE,
365 const wxValidator& validator = wxDefaultValidator,
366 const wxString& name = wxPyFontPickerCtrlNameStr);
367
368
369 // get the font chosen
370 wxFont GetSelectedFont() const;
371
372 // sets currently displayed font
373 void SetSelectedFont(const wxFont& f);
374
375 // set/get the max pointsize
376 void SetMaxPointSize(unsigned int max);
377 unsigned int GetMaxPointSize() const;
378 };
379
380
381 %constant wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
382
383 %pythoncode {
384 EVT_FONTPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FONTPICKER_CHANGED, 1 )
385 }
386
387
388 class wxFontPickerEvent : public wxCommandEvent
389 {
390 public:
391 wxFontPickerEvent(wxObject *generator, int id, const wxFont &f);
392
393 wxFont GetFont() const;
394 void SetFont(const wxFont &c);
395 };
396
397 //---------------------------------------------------------------------------