]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_picker.i
add Create to wxDocParentFrame
[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 %property(InternalMargin, GetInternalMargin, SetInternalMargin, doc="See `GetInternalMargin` and `SetInternalMargin`");
124 %property(PickerCtrl, GetPickerCtrl, doc="See `GetPickerCtrl`");
125 %property(PickerCtrlProportion, GetPickerCtrlProportion, SetPickerCtrlProportion, doc="See `GetPickerCtrlProportion` and `SetPickerCtrlProportion`");
126 %property(TextCtrl, GetTextCtrl, doc="See `GetTextCtrl`");
127 %property(TextCtrlProportion, GetTextCtrlProportion, SetTextCtrlProportion, doc="See `GetTextCtrlProportion` and `SetTextCtrlProportion`");
128
129 %property(TextCtrlGrowable, IsTextCtrlGrowable, SetTextCtrlGrowable, doc="See `IsTextCtrlGrowable` and `SetTextCtrlGrowable`");
130 %property(PickerCtrlGrowable, IsPickerCtrlGrowable, SetPickerCtrlGrowable, doc="See `IsPickerCtrlGrowable` and `SetPickerCtrlGrowable`");
131
132 };
133
134 //---------------------------------------------------------------------------
135 %newgroup
136
137 MAKE_CONST_WXSTRING(ColourPickerCtrlNameStr);
138
139 enum {
140 wxCLRP_SHOW_LABEL,
141 wxCLRP_USE_TEXTCTRL,
142 wxCLRP_DEFAULT_STYLE,
143 };
144
145
146 MustHaveApp(wxColourPickerCtrl);
147 DocStr(wxColourPickerCtrl,
148 "This control allows the user to select a colour. The generic
149 implementation is a button which brings up a `wx.ColourDialog` when
150 clicked. Native implementations may differ but this is usually a
151 (small) widget which give access to the colour-chooser dialog.",
152
153 "
154 Window Styles
155 -------------
156 ====================== ============================================
157 wx.CLRP_DEFAULT Default style.
158 wx.CLRP_USE_TEXTCTRL Creates a text control to the left of the
159 picker button which is completely managed
160 by the `wx.ColourPickerCtrl` and which can
161 be used by the user to specify a colour.
162 The text control is automatically synchronized
163 with the button's value. Use functions defined in
164 `wx.PickerBase` to modify the text control.
165 wx.CLRP_SHOW_LABEL Shows the colour in HTML form (AABBCC) as the
166 colour button label (instead of no label at all).
167 ====================== ============================================
168
169 Events
170 ------
171 ======================== ==========================================
172 EVT_COLOURPICKER_CHANGED The user changed the colour selected in the
173 control either using the button or using the
174 text control (see wx.CLRP_USE_TEXTCTRL; note
175 that in this case the event is fired only if
176 the user's input is valid, i.e. recognizable).
177 ======================== ==========================================
178 ");
179
180 class wxColourPickerCtrl : public wxPickerBase
181 {
182 public:
183 %pythonAppend wxColourPickerCtrl "self._setOORInfo(self)"
184 %pythonAppend wxColourPickerCtrl() ""
185
186 wxColourPickerCtrl(wxWindow *parent, wxWindowID id=-1,
187 const wxColour& col = *wxBLACK,
188 const wxPoint& pos = wxDefaultPosition,
189 const wxSize& size = wxDefaultSize,
190 long style = wxCLRP_DEFAULT_STYLE,
191 const wxValidator& validator = wxDefaultValidator,
192 const wxString& name = wxPyColourPickerCtrlNameStr);
193 %RenameCtor(PreColourPickerCtrl, wxColourPickerCtrl());
194
195 bool Create(wxWindow *parent, wxWindowID id,
196 const wxColour& col = *wxBLACK,
197 const wxPoint& pos = wxDefaultPosition,
198 const wxSize& size = wxDefaultSize,
199 long style = wxCLRP_DEFAULT_STYLE,
200 const wxValidator& validator = wxDefaultValidator,
201 const wxString& name = wxPyColourPickerCtrlNameStr);
202
203
204 DocDeclStr(
205 wxColour , GetColour() const,
206 "Returns the currently selected colour.", "");
207
208
209 DocDeclStr(
210 void , SetColour(const wxColour& col),
211 "Set the displayed colour.", "");
212
213 %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
214 };
215
216
217
218 %constant wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED;
219 %pythoncode {
220 EVT_COLOURPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_COLOURPICKER_CHANGED, 1 )
221 }
222
223 class wxColourPickerEvent : public wxCommandEvent
224 {
225 public:
226 wxColourPickerEvent(wxObject *generator, int id, const wxColour &col);
227
228 wxColour GetColour() const;
229 void SetColour(const wxColour &c);
230
231 %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
232 };
233
234
235 //---------------------------------------------------------------------------
236 %newgroup
237
238 MAKE_CONST_WXSTRING(FilePickerCtrlNameStr);
239 MAKE_CONST_WXSTRING(FileSelectorPromptStr);
240 MAKE_CONST_WXSTRING(DirPickerCtrlNameStr);
241 MAKE_CONST_WXSTRING(DirSelectorPromptStr);
242 MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
243
244
245 enum {
246 wxFLP_OPEN,
247 wxFLP_SAVE,
248 wxFLP_OVERWRITE_PROMPT,
249 wxFLP_FILE_MUST_EXIST,
250 wxFLP_CHANGE_DIR,
251 wxDIRP_DIR_MUST_EXIST,
252 wxDIRP_CHANGE_DIR,
253
254 wxFLP_USE_TEXTCTRL,
255 wxFLP_DEFAULT_STYLE,
256
257 wxDIRP_USE_TEXTCTRL,
258 wxDIRP_DEFAULT_STYLE,
259 };
260
261
262
263 MustHaveApp(wxFilePickerCtrl);
264 DocStr(wxFilePickerCtrl,
265 "", "");
266
267 class wxFilePickerCtrl : public wxPickerBase
268 {
269 public:
270 %pythonAppend wxFilePickerCtrl "self._setOORInfo(self)"
271 %pythonAppend wxFilePickerCtrl() ""
272
273 wxFilePickerCtrl(wxWindow *parent,
274 wxWindowID id=-1,
275 const wxString& path = wxPyEmptyString,
276 const wxString& message = wxPyFileSelectorPromptStr,
277 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
278 const wxPoint& pos = wxDefaultPosition,
279 const wxSize& size = wxDefaultSize,
280 long style = wxFLP_DEFAULT_STYLE,
281 const wxValidator& validator = wxDefaultValidator,
282 const wxString& name = wxPyFilePickerCtrlNameStr);
283 %RenameCtor(PreFilePickerCtrl, wxFilePickerCtrl());
284
285 bool Create(wxWindow *parent,
286 wxWindowID id=-1,
287 const wxString& path = wxPyEmptyString,
288 const wxString& message = wxPyFileSelectorPromptStr,
289 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
290 const wxPoint& pos = wxDefaultPosition,
291 const wxSize& size = wxDefaultSize,
292 long style = wxFLP_DEFAULT_STYLE,
293 const wxValidator& validator = wxDefaultValidator,
294 const wxString& name = wxPyFilePickerCtrlNameStr);
295
296 wxString GetPath() const;
297 void SetPath(const wxString &str);
298
299 // return true if the given path is valid for this control
300 bool CheckPath(const wxString& path) const;
301
302 // Returns the filtered value currently placed in the text control (if present).
303 wxString GetTextCtrlValue() const;
304
305 %property(Path, GetPath, SetPath, doc="See `GetPath` and `SetPath`");
306 %property(TextCtrlValue, GetTextCtrlValue, doc="See `GetTextCtrlValue`");
307 };
308
309
310
311
312 MustHaveApp(wxDirPickerCtrl);
313 DocStr(wxDirPickerCtrl,
314 "", "");
315
316 class wxDirPickerCtrl : public wxPickerBase
317 {
318 public:
319 %pythonAppend wxDirPickerCtrl "self._setOORInfo(self)"
320 %pythonAppend wxDirPickerCtrl() ""
321
322 wxDirPickerCtrl(wxWindow *parent, wxWindowID id=-1,
323 const wxString& path = wxPyEmptyString,
324 const wxString& message = wxPyDirSelectorPromptStr,
325 const wxPoint& pos = wxDefaultPosition,
326 const wxSize& size = wxDefaultSize,
327 long style = wxDIRP_DEFAULT_STYLE,
328 const wxValidator& validator = wxDefaultValidator,
329 const wxString& name = wxPyDirPickerCtrlNameStr);
330 %RenameCtor(PreDirPickerCtrl, wxDirPickerCtrl());
331
332 bool Create(wxWindow *parent, wxWindowID id=-1,
333 const wxString& path = wxPyEmptyString,
334 const wxString& message = wxPyDirSelectorPromptStr,
335 const wxPoint& pos = wxDefaultPosition,
336 const wxSize& size = wxDefaultSize,
337 long style = wxDIRP_DEFAULT_STYLE,
338 const wxValidator& validator = wxDefaultValidator,
339 const wxString& name = wxPyDirPickerCtrlNameStr);
340
341 wxString GetPath() const;
342 void SetPath(const wxString &str);
343
344 // return true if the given path is valid for this control
345 bool CheckPath(const wxString& path) const;
346
347 // Returns the filtered value currently placed in the text control (if present).
348 wxString GetTextCtrlValue() const;
349
350 %property(Path, GetPath, SetPath, doc="See `GetPath` and `SetPath`");
351 %property(TextCtrlValue, GetTextCtrlValue, doc="See `GetTextCtrlValue`");
352
353 };
354
355
356 %constant wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
357 %constant wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
358
359 %pythoncode {
360 EVT_FILEPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FILEPICKER_CHANGED, 1 )
361 EVT_DIRPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_DIRPICKER_CHANGED, 1 )
362 }
363
364 class wxFileDirPickerEvent : public wxCommandEvent
365 {
366 public:
367 wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path);
368
369 wxString GetPath() const { return m_path; }
370 void SetPath(const wxString &p) { m_path = p; }
371
372 %property(Path, GetPath, SetPath, doc="See `GetPath` and `SetPath`");
373 };
374
375
376 //---------------------------------------------------------------------------
377 %newgroup
378
379 MAKE_CONST_WXSTRING(FontPickerCtrlNameStr);
380
381 enum {
382 wxFNTP_FONTDESC_AS_LABEL,
383 wxFNTP_USEFONT_FOR_LABEL,
384 wxFNTP_USE_TEXTCTRL,
385 wxFNTP_DEFAULT_STYLE,
386 };
387
388
389 MustHaveApp(wxFontPickerCtrl);
390 DocStr(wxFontPickerCtrl,
391 "", "");
392
393
394 class wxFontPickerCtrl : public wxPickerBase
395 {
396 public:
397 %pythonAppend wxFontPickerCtrl "self._setOORInfo(self)"
398 %pythonAppend wxFontPickerCtrl() ""
399
400
401 wxFontPickerCtrl(wxWindow *parent,
402 wxWindowID id=-1,
403 const wxFont& initial = *wxNORMAL_FONT,
404 const wxPoint& pos = wxDefaultPosition,
405 const wxSize& size = wxDefaultSize,
406 long style = wxFNTP_DEFAULT_STYLE,
407 const wxValidator& validator = wxDefaultValidator,
408 const wxString& name = wxPyFontPickerCtrlNameStr);
409 %RenameCtor(PreFontPickerCtrl, wxFontPickerCtrl());
410
411 bool Create(wxWindow *parent,
412 wxWindowID id=-1,
413 const wxFont& initial = *wxNORMAL_FONT,
414 const wxPoint& pos = wxDefaultPosition,
415 const wxSize& size = wxDefaultSize,
416 long style = wxFNTP_DEFAULT_STYLE,
417 const wxValidator& validator = wxDefaultValidator,
418 const wxString& name = wxPyFontPickerCtrlNameStr);
419
420
421 // get the font chosen
422 wxFont GetSelectedFont() const;
423
424 // sets currently displayed font
425 void SetSelectedFont(const wxFont& f);
426
427 // set/get the max pointsize
428 void SetMaxPointSize(unsigned int max);
429 unsigned int GetMaxPointSize() const;
430
431 %property(MaxPointSize, GetMaxPointSize, SetMaxPointSize, doc="See `GetMaxPointSize` and `SetMaxPointSize`");
432 %property(SelectedFont, GetSelectedFont, SetSelectedFont, doc="See `GetSelectedFont` and `SetSelectedFont`");
433 };
434
435
436 %constant wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
437
438 %pythoncode {
439 EVT_FONTPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FONTPICKER_CHANGED, 1 )
440 }
441
442
443 class wxFontPickerEvent : public wxCommandEvent
444 {
445 public:
446 wxFontPickerEvent(wxObject *generator, int id, const wxFont &f);
447
448 wxFont GetFont() const;
449 void SetFont(const wxFont &c);
450
451 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
452 };
453
454 //---------------------------------------------------------------------------