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 //---------------------------------------------------------------------------
20 #include <wx/pickerbase.h>
21 #include <wx/clrpicker.h>
22 #include <wx/filepicker.h>
23 #include <wx/fontpicker.h>
33 "Base abstract class for all pickers which support an auxiliary text
34 control. This class handles all positioning and sizing of the text
35 control like a an horizontal `wx.BoxSizer` would do, with the text
36 control on the left of the picker button and the proportion of the
37 picker fixed to value 1.", "");
39 class wxPickerBase : public wxControl
42 // This class is an ABC, can't be instantiated from Python.
43 //wxPickerBase() : m_text(NULL), m_picker(NULL),
44 // m_margin(5), m_textProportion(2) {}
45 //virtual ~wxPickerBase();
48 // if present, intercepts wxPB_USE_TEXTCTRL style and creates the text control
49 // The 3rd argument is the initial wxString to display in the text control
50 bool CreateBase(wxWindow *parent, wxWindowID id,
51 const wxString& text = wxEmptyString,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize, long style = 0,
54 const wxValidator& validator = wxDefaultValidator,
55 const wxString& name = wxButtonNameStr);
60 void , SetInternalMargin(int newmargin),
61 "Sets the margin (in pixels) between the picker and the text control.", "");
64 int , GetInternalMargin() const,
65 "Returns the margin (in pixels) between the picker and the text
70 void , SetTextCtrlProportion(int prop),
71 "Sets the proportion between the text control and the picker button.
72 This is used to set relative sizes of the text contorl and the picker.
73 The value passed to this function must be >= 1.", "");
76 int , GetTextCtrlProportion() const,
77 "Returns the proportion between the text control and the picker.", "");
81 bool , HasTextCtrl() const,
82 "Returns true if this class has a valid text control (i.e. if the
83 wx.PB_USE_TEXTCTRL style was given when creating this control).", "");
86 wxTextCtrl *, GetTextCtrl(),
87 "Returns a pointer to the text control handled by this class or None if
88 the wx.PB_USE_TEXTCTRL style was not specified when this control was
91 Very important: the contents of the text control could be containing
92 an invalid representation of the entity which can be chosen through
93 the picker (e.g. the user entered an invalid colour syntax because of
94 a typo). Thus you should never parse the content of the textctrl to
95 get the user's input; rather use the derived-class getter
96 (e.g. `wx.ColourPickerCtrl.GetColour`, `wx.FilePickerCtrl.GetPath`,
100 wxControl *, GetPickerCtrl(),
105 //---------------------------------------------------------------------------
108 MAKE_CONST_WXSTRING(ColourPickerCtrlNameStr);
113 wxCLRP_DEFAULT_STYLE,
117 MustHaveApp(wxColourPickerCtrl);
118 DocStr(wxColourPickerCtrl,
119 "This control allows the user to select a colour. The generic
120 implementation is a button which brings up a `wx.ColourDialog` when
121 clicked. Native implementations may differ but this is usually a
122 (small) widget which give access to the colour-chooser dialog.",
127 ====================== ============================================
128 wx.CLRP_DEFAULT Default style.
129 wx.CLRP_USE_TEXTCTRL Creates a text control to the left of the
130 picker button which is completely managed
131 by the `wx.ColourPickerCtrl` and which can
132 be used by the user to specify a colour.
133 The text control is automatically synchronized
134 with the button's value. Use functions defined in
135 `wx.PickerBase` to modify the text control.
136 wx.CLRP_SHOW_LABEL Shows the colour in HTML form (AABBCC) as the
137 colour button label (instead of no label at all).
138 ====================== ============================================
142 ======================== ==========================================
143 EVT_COLOURPICKER_CHANGED The user changed the colour selected in the
144 control either using the button or using the
145 text control (see wx.CLRP_USE_TEXTCTRL; note
146 that in this case the event is fired only if
147 the user's input is valid, i.e. recognizable).
148 ======================== ==========================================
151 class wxColourPickerCtrl : public wxPickerBase
154 %pythonAppend wxColourPickerCtrl "self._setOORInfo(self)"
155 %pythonAppend wxColourPickerCtrl() ""
157 wxColourPickerCtrl(wxWindow *parent, wxWindowID id=-1,
158 const wxColour& col = *wxBLACK,
159 const wxPoint& pos = wxDefaultPosition,
160 const wxSize& size = wxDefaultSize,
161 long style = wxCLRP_DEFAULT_STYLE,
162 const wxValidator& validator = wxDefaultValidator,
163 const wxString& name = wxPyColourPickerCtrlNameStr);
164 %RenameCtor(PreColourPickerCtrl, wxColourPickerCtrl());
166 bool Create(wxWindow *parent, wxWindowID id,
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);
176 wxColour , GetColour() const,
177 "Returns the currently selected colour.", "");
181 void , SetColour(const wxColour& col),
182 "Set the displayed colour.", "");
188 %constant wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED;
190 EVT_COLOURPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_COLOURPICKER_CHANGED, 1 )
193 class wxColourPickerEvent : public wxCommandEvent
196 wxColourPickerEvent(wxObject *generator, int id, const wxColour &col);
198 wxColour GetColour() const;
199 void SetColour(const wxColour &c);
203 //---------------------------------------------------------------------------
206 MAKE_CONST_WXSTRING(FilePickerCtrlNameStr);
207 MAKE_CONST_WXSTRING(FileSelectorPromptStr);
208 MAKE_CONST_WXSTRING(DirPickerCtrlNameStr);
209 MAKE_CONST_WXSTRING(DirSelectorPromptStr);
210 MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
216 wxFLP_OVERWRITE_PROMPT,
217 wxFLP_FILE_MUST_EXIST,
219 wxDIRP_DIR_MUST_EXIST,
226 wxDIRP_DEFAULT_STYLE,
231 MustHaveApp(wxFilePickerCtrl);
232 DocStr(wxFilePickerCtrl,
235 class wxFilePickerCtrl : public wxPickerBase
238 %pythonAppend wxFilePickerCtrl "self._setOORInfo(self)"
239 %pythonAppend wxFilePickerCtrl() ""
241 wxFilePickerCtrl(wxWindow *parent,
243 const wxString& path = wxPyEmptyString,
244 const wxString& message = wxPyFileSelectorPromptStr,
245 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
246 const wxPoint& pos = wxDefaultPosition,
247 const wxSize& size = wxDefaultSize,
248 long style = wxFLP_DEFAULT_STYLE,
249 const wxValidator& validator = wxDefaultValidator,
250 const wxString& name = wxPyFilePickerCtrlNameStr);
251 %RenameCtor(PreFilePickerCtrl, wxFilePickerCtrl());
253 bool Create(wxWindow *parent,
255 const wxString& path = wxPyEmptyString,
256 const wxString& message = wxPyFileSelectorPromptStr,
257 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
258 const wxPoint& pos = wxDefaultPosition,
259 const wxSize& size = wxDefaultSize,
260 long style = wxFLP_DEFAULT_STYLE,
261 const wxValidator& validator = wxDefaultValidator,
262 const wxString& name = wxPyFilePickerCtrlNameStr);
264 wxString GetPath() const;
265 void SetPath(const wxString &str);
272 MustHaveApp(wxDirPickerCtrl);
273 DocStr(wxDirPickerCtrl,
276 class wxDirPickerCtrl : public wxPickerBase
279 %pythonAppend wxDirPickerCtrl "self._setOORInfo(self)"
280 %pythonAppend wxDirPickerCtrl() ""
282 wxDirPickerCtrl(wxWindow *parent, wxWindowID id=-1,
283 const wxString& path = wxPyEmptyString,
284 const wxString& message = wxPyDirSelectorPromptStr,
285 const wxPoint& pos = wxDefaultPosition,
286 const wxSize& size = wxDefaultSize,
287 long style = wxDIRP_DEFAULT_STYLE,
288 const wxValidator& validator = wxDefaultValidator,
289 const wxString& name = wxPyDirPickerCtrlNameStr);
290 %RenameCtor(PreDirPickerCtrl, wxDirPickerCtrl());
292 bool Create(wxWindow *parent, wxWindowID id=-1,
293 const wxString& path = wxPyEmptyString,
294 const wxString& message = wxPyDirSelectorPromptStr,
295 const wxPoint& pos = wxDefaultPosition,
296 const wxSize& size = wxDefaultSize,
297 long style = wxDIRP_DEFAULT_STYLE,
298 const wxValidator& validator = wxDefaultValidator,
299 const wxString& name = wxPyDirPickerCtrlNameStr);
301 wxString GetPath() const;
302 void SetPath(const wxString &str);
306 %constant wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
307 %constant wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
310 EVT_FILEPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FILEPICKER_CHANGED, 1 )
311 EVT_DIRPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_DIRPICKER_CHANGED, 1 )
314 class wxFileDirPickerEvent : public wxCommandEvent
317 wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path);
319 wxString GetPath() const { return m_path; }
320 void SetPath(const wxString &p) { m_path = p; }
324 //---------------------------------------------------------------------------
327 MAKE_CONST_WXSTRING(FontPickerCtrlNameStr);
330 wxFNTP_FONTDESC_AS_LABEL,
331 wxFNTP_USEFONT_FOR_LABEL,
333 wxFNTP_DEFAULT_STYLE,
337 MustHaveApp(wxFontPickerCtrl);
338 DocStr(wxFontPickerCtrl,
342 class wxFontPickerCtrl : public wxPickerBase
345 %pythonAppend wxFontPickerCtrl "self._setOORInfo(self)"
346 %pythonAppend wxFontPickerCtrl() ""
349 wxFontPickerCtrl(wxWindow *parent,
351 const wxFont& initial = *wxNORMAL_FONT,
352 const wxPoint& pos = wxDefaultPosition,
353 const wxSize& size = wxDefaultSize,
354 long style = wxFNTP_DEFAULT_STYLE,
355 const wxValidator& validator = wxDefaultValidator,
356 const wxString& name = wxPyFontPickerCtrlNameStr);
357 %RenameCtor(PreFontPickerCtrl, wxFontPickerCtrl());
359 bool Create(wxWindow *parent,
361 const wxFont& initial = *wxNORMAL_FONT,
362 const wxPoint& pos = wxDefaultPosition,
363 const wxSize& size = wxDefaultSize,
364 long style = wxFNTP_DEFAULT_STYLE,
365 const wxValidator& validator = wxDefaultValidator,
366 const wxString& name = wxPyFontPickerCtrlNameStr);
369 // get the font chosen
370 wxFont GetSelectedFont() const;
372 // sets currently displayed font
373 void SetSelectedFont(const wxFont& f);
375 // set/get the max pointsize
376 void SetMaxPointSize(unsigned int max);
377 unsigned int GetMaxPointSize() const;
381 %constant wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
384 EVT_FONTPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FONTPICKER_CHANGED, 1 )
388 class wxFontPickerEvent : public wxCommandEvent
391 wxFontPickerEvent(wxObject *generator, int id, const wxFont &f);
393 wxFont GetFont() const;
394 void SetFont(const wxFont &c);
397 //---------------------------------------------------------------------------