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 bool , HasTextCtrl() const,
74 "Returns true if this class has a valid text control (i.e. if the
75 wx.PB_USE_TEXTCTRL style was given when creating this control).", "");
78 wxTextCtrl *, GetTextCtrl(),
79 "Returns a pointer to the text control handled by this class or None if
80 the wx.PB_USE_TEXTCTRL style was not specified when this control was
83 Very important: the contents of the text control could be containing
84 an invalid representation of the entity which can be chosen through
85 the picker (e.g. the user entered an invalid colour syntax because of
86 a typo). Thus you should never parse the content of the textctrl to
87 get the user's input; rather use the derived-class getter
88 (e.g. `wx.ColourPickerCtrl.GetColour`, `wx.FilePickerCtrl.GetPath`,
92 wxControl *, GetPickerCtrl(),
97 //---------------------------------------------------------------------------
100 MAKE_CONST_WXSTRING(ColourPickerCtrlNameStr);
105 wxCLRP_DEFAULT_STYLE,
109 MustHaveApp(wxColourPickerCtrl);
110 DocStr(wxColourPickerCtrl,
111 "This control allows the user to select a colour. The generic
112 implementation is a button which brings up a `wx.ColourDialog` when
113 clicked. Native implementations may differ but this is usually a
114 (small) widget which give access to the colour-chooser dialog.",
119 ====================== ============================================
120 wx.CLRP_DEFAULT Default style.
121 wx.CLRP_USE_TEXTCTRL Creates a text control to the left of the
122 picker button which is completely managed
123 by the `wx.ColourPickerCtrl` and which can
124 be used by the user to specify a colour.
125 The text control is automatically synchronized
126 with the button's value. Use functions defined in
127 `wx.PickerBase` to modify the text control.
128 wx.CLRP_SHOW_LABEL Shows the colour in HTML form (AABBCC) as the
129 colour button label (instead of no label at all).
130 ====================== ============================================
134 ======================== ==========================================
135 EVT_COLOURPICKER_CHANGED The user changed the colour selected in the
136 control either using the button or using the
137 text control (see wx.CLRP_USE_TEXTCTRL; note
138 that in this case the event is fired only if
139 the user's input is valid, i.e. recognizable).
140 ======================== ==========================================
143 class wxColourPickerCtrl : public wxPickerBase
146 %pythonAppend wxColourPickerCtrl "self._setOORInfo(self)"
147 %pythonAppend wxColourPickerCtrl() ""
149 wxColourPickerCtrl(wxWindow *parent, wxWindowID id=-1,
150 const wxColour& col = *wxBLACK,
151 const wxPoint& pos = wxDefaultPosition,
152 const wxSize& size = wxDefaultSize,
153 long style = wxCLRP_DEFAULT_STYLE,
154 const wxValidator& validator = wxDefaultValidator,
155 const wxString& name = wxPyColourPickerCtrlNameStr);
156 %RenameCtor(PreColourPickerCtrl, wxColourPickerCtrl());
158 bool Create(wxWindow *parent, wxWindowID id,
159 const wxColour& col = *wxBLACK,
160 const wxPoint& pos = wxDefaultPosition,
161 const wxSize& size = wxDefaultSize,
162 long style = wxCLRP_DEFAULT_STYLE,
163 const wxValidator& validator = wxDefaultValidator,
164 const wxString& name = wxPyColourPickerCtrlNameStr);
168 wxColour , GetColour() const,
169 "Returns the currently selected colour.", "");
173 void , SetColour(const wxColour& col),
174 "Set the displayed colour.", "");
180 %constant wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED;
182 EVT_COLOURPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_COLOURPICKER_CHANGED, 1 )
185 class wxColourPickerEvent : public wxCommandEvent
188 wxColourPickerEvent(wxObject *generator, int id, const wxColour &col);
190 wxColour GetColour() const;
191 void SetColour(const wxColour &c);
195 //---------------------------------------------------------------------------
198 MAKE_CONST_WXSTRING(FilePickerCtrlNameStr);
199 MAKE_CONST_WXSTRING(FileSelectorPromptStr);
200 MAKE_CONST_WXSTRING(DirPickerCtrlNameStr);
201 MAKE_CONST_WXSTRING(DirSelectorPromptStr);
202 MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
208 wxFLP_OVERWRITE_PROMPT,
209 wxFLP_FILE_MUST_EXIST,
211 wxDIRP_DIR_MUST_EXIST,
218 wxDIRP_DEFAULT_STYLE,
223 MustHaveApp(wxFilePickerCtrl);
224 DocStr(wxFilePickerCtrl,
227 class wxFilePickerCtrl : public wxPickerBase
230 %pythonAppend wxFilePickerCtrl "self._setOORInfo(self)"
231 %pythonAppend wxFilePickerCtrl() ""
233 wxFilePickerCtrl(wxWindow *parent,
235 const wxString& path = wxPyEmptyString,
236 const wxString& message = wxPyFileSelectorPromptStr,
237 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
238 const wxPoint& pos = wxDefaultPosition,
239 const wxSize& size = wxDefaultSize,
240 long style = wxFLP_DEFAULT_STYLE,
241 const wxValidator& validator = wxDefaultValidator,
242 const wxString& name = wxPyFilePickerCtrlNameStr);
243 %RenameCtor(PreFilePickerCtrl, wxFilePickerCtrl());
245 bool Create(wxWindow *parent,
247 const wxString& path = wxPyEmptyString,
248 const wxString& message = wxPyFileSelectorPromptStr,
249 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
250 const wxPoint& pos = wxDefaultPosition,
251 const wxSize& size = wxDefaultSize,
252 long style = wxFLP_DEFAULT_STYLE,
253 const wxValidator& validator = wxDefaultValidator,
254 const wxString& name = wxPyFilePickerCtrlNameStr);
256 wxString GetPath() const;
257 void SetPath(const wxString &str);
264 MustHaveApp(wxDirPickerCtrl);
265 DocStr(wxDirPickerCtrl,
268 class wxDirPickerCtrl : public wxPickerBase
271 %pythonAppend wxDirPickerCtrl "self._setOORInfo(self)"
272 %pythonAppend wxDirPickerCtrl() ""
274 wxDirPickerCtrl(wxWindow *parent, wxWindowID id=-1,
275 const wxString& path = wxPyEmptyString,
276 const wxString& message = wxPyDirSelectorPromptStr,
277 const wxPoint& pos = wxDefaultPosition,
278 const wxSize& size = wxDefaultSize,
279 long style = wxDIRP_DEFAULT_STYLE,
280 const wxValidator& validator = wxDefaultValidator,
281 const wxString& name = wxPyDirPickerCtrlNameStr);
282 %RenameCtor(PreDirPickerCtrl, wxDirPickerCtrl());
284 bool Create(wxWindow *parent, wxWindowID id=-1,
285 const wxString& path = wxPyEmptyString,
286 const wxString& message = wxPyDirSelectorPromptStr,
287 const wxPoint& pos = wxDefaultPosition,
288 const wxSize& size = wxDefaultSize,
289 long style = wxDIRP_DEFAULT_STYLE,
290 const wxValidator& validator = wxDefaultValidator,
291 const wxString& name = wxPyDirPickerCtrlNameStr);
293 wxString GetPath() const;
294 void SetPath(const wxString &str);
298 %constant wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
299 %constant wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
302 EVT_FILEPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FILEPICKER_CHANGED, 1 )
303 EVT_DIRPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_DIRPICKER_CHANGED, 1 )
306 class wxFileDirPickerEvent : public wxCommandEvent
309 wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path);
311 wxString GetPath() const { return m_path; }
312 void SetPath(const wxString &p) { m_path = p; }
316 //---------------------------------------------------------------------------
319 MAKE_CONST_WXSTRING(FontPickerCtrlNameStr);
322 wxFNTP_FONTDESC_AS_LABEL,
323 wxFNTP_USEFONT_FOR_LABEL,
325 wxFNTP_DEFAULT_STYLE,
329 MustHaveApp(wxFontPickerCtrl);
330 DocStr(wxFontPickerCtrl,
334 class wxFontPickerCtrl : public wxPickerBase
337 %pythonAppend wxFontPickerCtrl "self._setOORInfo(self)"
338 %pythonAppend wxFontPickerCtrl() ""
341 wxFontPickerCtrl(wxWindow *parent,
343 const wxFont& initial = *wxNORMAL_FONT,
344 const wxPoint& pos = wxDefaultPosition,
345 const wxSize& size = wxDefaultSize,
346 long style = wxFNTP_DEFAULT_STYLE,
347 const wxValidator& validator = wxDefaultValidator,
348 const wxString& name = wxPyFontPickerCtrlNameStr);
349 %RenameCtor(PreFontPickerCtrl, wxFontPickerCtrl());
351 bool Create(wxWindow *parent,
353 const wxFont& initial = *wxNORMAL_FONT,
354 const wxPoint& pos = wxDefaultPosition,
355 const wxSize& size = wxDefaultSize,
356 long style = wxFNTP_DEFAULT_STYLE,
357 const wxValidator& validator = wxDefaultValidator,
358 const wxString& name = wxPyFontPickerCtrlNameStr);
361 // get the font chosen
362 wxFont GetSelectedFont() const;
364 // sets currently displayed font
365 void SetSelectedFont(const wxFont& f);
367 // set/get the max pointsize
368 void SetMaxPointSize(unsigned int max);
369 unsigned int GetMaxPointSize() const;
373 %constant wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
376 EVT_FONTPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FONTPICKER_CHANGED, 1 )
380 class wxFontPickerEvent : public wxCommandEvent
383 wxFontPickerEvent(wxObject *generator, int id, const wxFont &f);
385 wxFont GetFont() const;
386 void SetFont(const wxFont &c);
389 //---------------------------------------------------------------------------