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(),
124 //---------------------------------------------------------------------------
127 MAKE_CONST_WXSTRING(ColourPickerCtrlNameStr);
132 wxCLRP_DEFAULT_STYLE,
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.",
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 ====================== ============================================
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 ======================== ==========================================
170 class wxColourPickerCtrl : public wxPickerBase
173 %pythonAppend wxColourPickerCtrl "self._setOORInfo(self)"
174 %pythonAppend wxColourPickerCtrl() ""
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());
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);
195 wxColour , GetColour() const,
196 "Returns the currently selected colour.", "");
200 void , SetColour(const wxColour& col),
201 "Set the displayed colour.", "");
207 %constant wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED;
209 EVT_COLOURPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_COLOURPICKER_CHANGED, 1 )
212 class wxColourPickerEvent : public wxCommandEvent
215 wxColourPickerEvent(wxObject *generator, int id, const wxColour &col);
217 wxColour GetColour() const;
218 void SetColour(const wxColour &c);
222 //---------------------------------------------------------------------------
225 MAKE_CONST_WXSTRING(FilePickerCtrlNameStr);
226 MAKE_CONST_WXSTRING(FileSelectorPromptStr);
227 MAKE_CONST_WXSTRING(DirPickerCtrlNameStr);
228 MAKE_CONST_WXSTRING(DirSelectorPromptStr);
229 MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
235 wxFLP_OVERWRITE_PROMPT,
236 wxFLP_FILE_MUST_EXIST,
238 wxDIRP_DIR_MUST_EXIST,
245 wxDIRP_DEFAULT_STYLE,
250 MustHaveApp(wxFilePickerCtrl);
251 DocStr(wxFilePickerCtrl,
254 class wxFilePickerCtrl : public wxPickerBase
257 %pythonAppend wxFilePickerCtrl "self._setOORInfo(self)"
258 %pythonAppend wxFilePickerCtrl() ""
260 wxFilePickerCtrl(wxWindow *parent,
262 const wxString& path = wxPyEmptyString,
263 const wxString& message = wxPyFileSelectorPromptStr,
264 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
265 const wxPoint& pos = wxDefaultPosition,
266 const wxSize& size = wxDefaultSize,
267 long style = wxFLP_DEFAULT_STYLE,
268 const wxValidator& validator = wxDefaultValidator,
269 const wxString& name = wxPyFilePickerCtrlNameStr);
270 %RenameCtor(PreFilePickerCtrl, wxFilePickerCtrl());
272 bool Create(wxWindow *parent,
274 const wxString& path = wxPyEmptyString,
275 const wxString& message = wxPyFileSelectorPromptStr,
276 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
277 const wxPoint& pos = wxDefaultPosition,
278 const wxSize& size = wxDefaultSize,
279 long style = wxFLP_DEFAULT_STYLE,
280 const wxValidator& validator = wxDefaultValidator,
281 const wxString& name = wxPyFilePickerCtrlNameStr);
283 wxString GetPath() const;
284 void SetPath(const wxString &str);
286 // return true if the given path is valid for this control
287 bool CheckPath(const wxString& path) const;
289 // Returns the filtered value currently placed in the text control (if present).
290 wxString GetTextCtrlValue() const;
297 MustHaveApp(wxDirPickerCtrl);
298 DocStr(wxDirPickerCtrl,
301 class wxDirPickerCtrl : public wxPickerBase
304 %pythonAppend wxDirPickerCtrl "self._setOORInfo(self)"
305 %pythonAppend wxDirPickerCtrl() ""
307 wxDirPickerCtrl(wxWindow *parent, wxWindowID id=-1,
308 const wxString& path = wxPyEmptyString,
309 const wxString& message = wxPyDirSelectorPromptStr,
310 const wxPoint& pos = wxDefaultPosition,
311 const wxSize& size = wxDefaultSize,
312 long style = wxDIRP_DEFAULT_STYLE,
313 const wxValidator& validator = wxDefaultValidator,
314 const wxString& name = wxPyDirPickerCtrlNameStr);
315 %RenameCtor(PreDirPickerCtrl, wxDirPickerCtrl());
317 bool Create(wxWindow *parent, wxWindowID id=-1,
318 const wxString& path = wxPyEmptyString,
319 const wxString& message = wxPyDirSelectorPromptStr,
320 const wxPoint& pos = wxDefaultPosition,
321 const wxSize& size = wxDefaultSize,
322 long style = wxDIRP_DEFAULT_STYLE,
323 const wxValidator& validator = wxDefaultValidator,
324 const wxString& name = wxPyDirPickerCtrlNameStr);
326 wxString GetPath() const;
327 void SetPath(const wxString &str);
329 // return true if the given path is valid for this control
330 bool CheckPath(const wxString& path) const;
332 // Returns the filtered value currently placed in the text control (if present).
333 wxString GetTextCtrlValue() const;
337 %constant wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
338 %constant wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
341 EVT_FILEPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FILEPICKER_CHANGED, 1 )
342 EVT_DIRPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_DIRPICKER_CHANGED, 1 )
345 class wxFileDirPickerEvent : public wxCommandEvent
348 wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path);
350 wxString GetPath() const { return m_path; }
351 void SetPath(const wxString &p) { m_path = p; }
355 //---------------------------------------------------------------------------
358 MAKE_CONST_WXSTRING(FontPickerCtrlNameStr);
361 wxFNTP_FONTDESC_AS_LABEL,
362 wxFNTP_USEFONT_FOR_LABEL,
364 wxFNTP_DEFAULT_STYLE,
368 MustHaveApp(wxFontPickerCtrl);
369 DocStr(wxFontPickerCtrl,
373 class wxFontPickerCtrl : public wxPickerBase
376 %pythonAppend wxFontPickerCtrl "self._setOORInfo(self)"
377 %pythonAppend wxFontPickerCtrl() ""
380 wxFontPickerCtrl(wxWindow *parent,
382 const wxFont& initial = *wxNORMAL_FONT,
383 const wxPoint& pos = wxDefaultPosition,
384 const wxSize& size = wxDefaultSize,
385 long style = wxFNTP_DEFAULT_STYLE,
386 const wxValidator& validator = wxDefaultValidator,
387 const wxString& name = wxPyFontPickerCtrlNameStr);
388 %RenameCtor(PreFontPickerCtrl, wxFontPickerCtrl());
390 bool Create(wxWindow *parent,
392 const wxFont& initial = *wxNORMAL_FONT,
393 const wxPoint& pos = wxDefaultPosition,
394 const wxSize& size = wxDefaultSize,
395 long style = wxFNTP_DEFAULT_STYLE,
396 const wxValidator& validator = wxDefaultValidator,
397 const wxString& name = wxPyFontPickerCtrlNameStr);
400 // get the font chosen
401 wxFont GetSelectedFont() const;
403 // sets currently displayed font
404 void SetSelectedFont(const wxFont& f);
406 // set/get the max pointsize
407 void SetMaxPointSize(unsigned int max);
408 unsigned int GetMaxPointSize() const;
412 %constant wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
415 EVT_FONTPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FONTPICKER_CHANGED, 1 )
419 class wxFontPickerEvent : public wxCommandEvent
422 wxFontPickerEvent(wxObject *generator, int id, const wxFont &f);
424 wxFont GetFont() const;
425 void SetFont(const wxFont &c);
428 //---------------------------------------------------------------------------