1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for Colour, Dir, File, Font picker controls
7 // Created: 6-June-2006
9 // Copyright: (c) 2006 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
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.", "");
31 class wxPickerBase : public wxControl
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();
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);
52 void , SetInternalMargin(int newmargin),
53 "Sets the margin (in pixels) between the picker and the text control.", "");
56 int , GetInternalMargin() const,
57 "Returns the margin (in pixels) between the picker and the text
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.", "");
68 int , GetTextCtrlProportion() const,
69 "Returns the proportion between the text control and the picker.", "");
73 void , SetPickerCtrlProportion(int prop),
74 "Sets the proportion value of the picker.", "");
77 int , GetPickerCtrlProportion() const,
78 "Gets the proportion value of the picker.", "");
82 bool , IsTextCtrlGrowable() const,
86 void , SetTextCtrlGrowable(bool grow = true),
91 bool , IsPickerCtrlGrowable() const,
95 void , SetPickerCtrlGrowable(bool grow = true),
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).", "");
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
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`,
119 wxControl *, GetPickerCtrl(),
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`");
129 %property(TextCtrlGrowable, IsTextCtrlGrowable, SetTextCtrlGrowable, doc="See `IsTextCtrlGrowable` and `SetTextCtrlGrowable`");
130 %property(PickerCtrlGrowable, IsPickerCtrlGrowable, SetPickerCtrlGrowable, doc="See `IsPickerCtrlGrowable` and `SetPickerCtrlGrowable`");
134 //---------------------------------------------------------------------------
137 MAKE_CONST_WXSTRING(ColourPickerCtrlNameStr);
142 wxCLRP_DEFAULT_STYLE,
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.",
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 ====================== ============================================
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 ======================== ==========================================
180 class wxColourPickerCtrl : public wxPickerBase
183 %pythonAppend wxColourPickerCtrl "self._setOORInfo(self)"
184 %pythonAppend wxColourPickerCtrl() ""
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());
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);
205 wxColour , GetColour() const,
206 "Returns the currently selected colour.", "");
210 void , SetColour(const wxColour& col),
211 "Set the displayed colour.", "");
213 %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
218 %constant wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED;
220 EVT_COLOURPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_COLOURPICKER_CHANGED, 1 )
223 class wxColourPickerEvent : public wxCommandEvent
226 wxColourPickerEvent(wxObject *generator, int id, const wxColour &col);
228 wxColour GetColour() const;
229 void SetColour(const wxColour &c);
231 %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
235 //---------------------------------------------------------------------------
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);
248 wxFLP_OVERWRITE_PROMPT,
249 wxFLP_FILE_MUST_EXIST,
251 wxDIRP_DIR_MUST_EXIST,
258 wxDIRP_DEFAULT_STYLE,
263 MustHaveApp(wxFilePickerCtrl);
264 DocStr(wxFilePickerCtrl,
267 class wxFilePickerCtrl : public wxPickerBase
270 %pythonAppend wxFilePickerCtrl "self._setOORInfo(self)"
271 %pythonAppend wxFilePickerCtrl() ""
273 wxFilePickerCtrl(wxWindow *parent,
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());
285 bool Create(wxWindow *parent,
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);
296 wxString GetPath() const;
297 void SetPath(const wxString &str);
299 // return true if the given path is valid for this control
300 bool CheckPath(const wxString& path) const;
302 // Returns the filtered value currently placed in the text control (if present).
303 wxString GetTextCtrlValue() const;
305 %property(Path, GetPath, SetPath, doc="See `GetPath` and `SetPath`");
306 %property(TextCtrlValue, GetTextCtrlValue, doc="See `GetTextCtrlValue`");
312 MustHaveApp(wxDirPickerCtrl);
313 DocStr(wxDirPickerCtrl,
316 class wxDirPickerCtrl : public wxPickerBase
319 %pythonAppend wxDirPickerCtrl "self._setOORInfo(self)"
320 %pythonAppend wxDirPickerCtrl() ""
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());
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);
341 wxString GetPath() const;
342 void SetPath(const wxString &str);
344 // return true if the given path is valid for this control
345 bool CheckPath(const wxString& path) const;
347 // Returns the filtered value currently placed in the text control (if present).
348 wxString GetTextCtrlValue() const;
350 %property(Path, GetPath, SetPath, doc="See `GetPath` and `SetPath`");
351 %property(TextCtrlValue, GetTextCtrlValue, doc="See `GetTextCtrlValue`");
356 %constant wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
357 %constant wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
360 EVT_FILEPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FILEPICKER_CHANGED, 1 )
361 EVT_DIRPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_DIRPICKER_CHANGED, 1 )
364 class wxFileDirPickerEvent : public wxCommandEvent
367 wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path);
369 wxString GetPath() const { return m_path; }
370 void SetPath(const wxString &p) { m_path = p; }
372 %property(Path, GetPath, SetPath, doc="See `GetPath` and `SetPath`");
376 //---------------------------------------------------------------------------
379 MAKE_CONST_WXSTRING(FontPickerCtrlNameStr);
382 wxFNTP_FONTDESC_AS_LABEL,
383 wxFNTP_USEFONT_FOR_LABEL,
385 wxFNTP_DEFAULT_STYLE,
389 MustHaveApp(wxFontPickerCtrl);
390 DocStr(wxFontPickerCtrl,
394 class wxFontPickerCtrl : public wxPickerBase
397 %pythonAppend wxFontPickerCtrl "self._setOORInfo(self)"
398 %pythonAppend wxFontPickerCtrl() ""
401 wxFontPickerCtrl(wxWindow *parent,
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());
411 bool Create(wxWindow *parent,
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);
421 // get the font chosen
422 wxFont GetSelectedFont() const;
424 // sets currently displayed font
425 void SetSelectedFont(const wxFont& f);
427 // set/get the max pointsize
428 void SetMaxPointSize(unsigned int max);
429 unsigned int GetMaxPointSize() const;
431 %property(MaxPointSize, GetMaxPointSize, SetMaxPointSize, doc="See `GetMaxPointSize` and `SetMaxPointSize`");
432 %property(SelectedFont, GetSelectedFont, SetSelectedFont, doc="See `GetSelectedFont` and `SetSelectedFont`");
436 %constant wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
439 EVT_FONTPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FONTPICKER_CHANGED, 1 )
443 class wxFontPickerEvent : public wxCommandEvent
446 wxFontPickerEvent(wxObject *generator, int id, const wxFont &f);
448 wxFont GetFont() const;
449 void SetFont(const wxFont &c);
451 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
454 //---------------------------------------------------------------------------