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.", "");
72 bool , IsTextCtrlGrowable() const,
76 void , SetTextCtrlGrowable(bool grow = true),
81 bool , IsPickerCtrlGrowable() const,
85 void , SetPickerCtrlGrowable(bool grow = true),
90 bool , HasTextCtrl() const,
91 "Returns true if this class has a valid text control (i.e. if the
92 wx.PB_USE_TEXTCTRL style was given when creating this control).", "");
95 wxTextCtrl *, GetTextCtrl(),
96 "Returns a pointer to the text control handled by this class or None if
97 the wx.PB_USE_TEXTCTRL style was not specified when this control was
100 Very important: the contents of the text control could be containing
101 an invalid representation of the entity which can be chosen through
102 the picker (e.g. the user entered an invalid colour syntax because of
103 a typo). Thus you should never parse the content of the textctrl to
104 get the user's input; rather use the derived-class getter
105 (e.g. `wx.ColourPickerCtrl.GetColour`, `wx.FilePickerCtrl.GetPath`,
109 wxControl *, GetPickerCtrl(),
114 //---------------------------------------------------------------------------
117 MAKE_CONST_WXSTRING(ColourPickerCtrlNameStr);
122 wxCLRP_DEFAULT_STYLE,
126 MustHaveApp(wxColourPickerCtrl);
127 DocStr(wxColourPickerCtrl,
128 "This control allows the user to select a colour. The generic
129 implementation is a button which brings up a `wx.ColourDialog` when
130 clicked. Native implementations may differ but this is usually a
131 (small) widget which give access to the colour-chooser dialog.",
136 ====================== ============================================
137 wx.CLRP_DEFAULT Default style.
138 wx.CLRP_USE_TEXTCTRL Creates a text control to the left of the
139 picker button which is completely managed
140 by the `wx.ColourPickerCtrl` and which can
141 be used by the user to specify a colour.
142 The text control is automatically synchronized
143 with the button's value. Use functions defined in
144 `wx.PickerBase` to modify the text control.
145 wx.CLRP_SHOW_LABEL Shows the colour in HTML form (AABBCC) as the
146 colour button label (instead of no label at all).
147 ====================== ============================================
151 ======================== ==========================================
152 EVT_COLOURPICKER_CHANGED The user changed the colour selected in the
153 control either using the button or using the
154 text control (see wx.CLRP_USE_TEXTCTRL; note
155 that in this case the event is fired only if
156 the user's input is valid, i.e. recognizable).
157 ======================== ==========================================
160 class wxColourPickerCtrl : public wxPickerBase
163 %pythonAppend wxColourPickerCtrl "self._setOORInfo(self)"
164 %pythonAppend wxColourPickerCtrl() ""
166 wxColourPickerCtrl(wxWindow *parent, wxWindowID id=-1,
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 %RenameCtor(PreColourPickerCtrl, wxColourPickerCtrl());
175 bool Create(wxWindow *parent, wxWindowID id,
176 const wxColour& col = *wxBLACK,
177 const wxPoint& pos = wxDefaultPosition,
178 const wxSize& size = wxDefaultSize,
179 long style = wxCLRP_DEFAULT_STYLE,
180 const wxValidator& validator = wxDefaultValidator,
181 const wxString& name = wxPyColourPickerCtrlNameStr);
185 wxColour , GetColour() const,
186 "Returns the currently selected colour.", "");
190 void , SetColour(const wxColour& col),
191 "Set the displayed colour.", "");
197 %constant wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED;
199 EVT_COLOURPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_COLOURPICKER_CHANGED, 1 )
202 class wxColourPickerEvent : public wxCommandEvent
205 wxColourPickerEvent(wxObject *generator, int id, const wxColour &col);
207 wxColour GetColour() const;
208 void SetColour(const wxColour &c);
212 //---------------------------------------------------------------------------
215 MAKE_CONST_WXSTRING(FilePickerCtrlNameStr);
216 MAKE_CONST_WXSTRING(FileSelectorPromptStr);
217 MAKE_CONST_WXSTRING(DirPickerCtrlNameStr);
218 MAKE_CONST_WXSTRING(DirSelectorPromptStr);
219 MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
225 wxFLP_OVERWRITE_PROMPT,
226 wxFLP_FILE_MUST_EXIST,
228 wxDIRP_DIR_MUST_EXIST,
235 wxDIRP_DEFAULT_STYLE,
240 MustHaveApp(wxFilePickerCtrl);
241 DocStr(wxFilePickerCtrl,
244 class wxFilePickerCtrl : public wxPickerBase
247 %pythonAppend wxFilePickerCtrl "self._setOORInfo(self)"
248 %pythonAppend wxFilePickerCtrl() ""
250 wxFilePickerCtrl(wxWindow *parent,
252 const wxString& path = wxPyEmptyString,
253 const wxString& message = wxPyFileSelectorPromptStr,
254 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
255 const wxPoint& pos = wxDefaultPosition,
256 const wxSize& size = wxDefaultSize,
257 long style = wxFLP_DEFAULT_STYLE,
258 const wxValidator& validator = wxDefaultValidator,
259 const wxString& name = wxPyFilePickerCtrlNameStr);
260 %RenameCtor(PreFilePickerCtrl, wxFilePickerCtrl());
262 bool Create(wxWindow *parent,
264 const wxString& path = wxPyEmptyString,
265 const wxString& message = wxPyFileSelectorPromptStr,
266 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
267 const wxPoint& pos = wxDefaultPosition,
268 const wxSize& size = wxDefaultSize,
269 long style = wxFLP_DEFAULT_STYLE,
270 const wxValidator& validator = wxDefaultValidator,
271 const wxString& name = wxPyFilePickerCtrlNameStr);
273 wxString GetPath() const;
274 void SetPath(const wxString &str);
276 // return true if the given path is valid for this control
277 bool CheckPath(const wxString& path) const;
279 // Returns the filtered value currently placed in the text control (if present).
280 wxString GetTextCtrlValue() const;
287 MustHaveApp(wxDirPickerCtrl);
288 DocStr(wxDirPickerCtrl,
291 class wxDirPickerCtrl : public wxPickerBase
294 %pythonAppend wxDirPickerCtrl "self._setOORInfo(self)"
295 %pythonAppend wxDirPickerCtrl() ""
297 wxDirPickerCtrl(wxWindow *parent, wxWindowID id=-1,
298 const wxString& path = wxPyEmptyString,
299 const wxString& message = wxPyDirSelectorPromptStr,
300 const wxPoint& pos = wxDefaultPosition,
301 const wxSize& size = wxDefaultSize,
302 long style = wxDIRP_DEFAULT_STYLE,
303 const wxValidator& validator = wxDefaultValidator,
304 const wxString& name = wxPyDirPickerCtrlNameStr);
305 %RenameCtor(PreDirPickerCtrl, wxDirPickerCtrl());
307 bool Create(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);
316 wxString GetPath() const;
317 void SetPath(const wxString &str);
319 // return true if the given path is valid for this control
320 bool CheckPath(const wxString& path) const;
322 // Returns the filtered value currently placed in the text control (if present).
323 wxString GetTextCtrlValue() const;
327 %constant wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
328 %constant wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
331 EVT_FILEPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FILEPICKER_CHANGED, 1 )
332 EVT_DIRPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_DIRPICKER_CHANGED, 1 )
335 class wxFileDirPickerEvent : public wxCommandEvent
338 wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path);
340 wxString GetPath() const { return m_path; }
341 void SetPath(const wxString &p) { m_path = p; }
345 //---------------------------------------------------------------------------
348 MAKE_CONST_WXSTRING(FontPickerCtrlNameStr);
351 wxFNTP_FONTDESC_AS_LABEL,
352 wxFNTP_USEFONT_FOR_LABEL,
354 wxFNTP_DEFAULT_STYLE,
358 MustHaveApp(wxFontPickerCtrl);
359 DocStr(wxFontPickerCtrl,
363 class wxFontPickerCtrl : public wxPickerBase
366 %pythonAppend wxFontPickerCtrl "self._setOORInfo(self)"
367 %pythonAppend wxFontPickerCtrl() ""
370 wxFontPickerCtrl(wxWindow *parent,
372 const wxFont& initial = *wxNORMAL_FONT,
373 const wxPoint& pos = wxDefaultPosition,
374 const wxSize& size = wxDefaultSize,
375 long style = wxFNTP_DEFAULT_STYLE,
376 const wxValidator& validator = wxDefaultValidator,
377 const wxString& name = wxPyFontPickerCtrlNameStr);
378 %RenameCtor(PreFontPickerCtrl, wxFontPickerCtrl());
380 bool Create(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);
390 // get the font chosen
391 wxFont GetSelectedFont() const;
393 // sets currently displayed font
394 void SetSelectedFont(const wxFont& f);
396 // set/get the max pointsize
397 void SetMaxPointSize(unsigned int max);
398 unsigned int GetMaxPointSize() const;
402 %constant wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
405 EVT_FONTPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FONTPICKER_CHANGED, 1 )
409 class wxFontPickerEvent : public wxCommandEvent
412 wxFontPickerEvent(wxObject *generator, int id, const wxFont &f);
414 wxFont GetFont() const;
415 void SetFont(const wxFont &c);
418 //---------------------------------------------------------------------------