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