]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_picker.i
Added missing platform constants
[wxWidgets.git] / wxPython / src / _picker.i
CommitLineData
d211a853
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _picker.i
3// Purpose: SWIG interface for Colour, Dir, File, Font picker controls
4//
5// Author: Robin Dunn
6//
7// Created: 6-June-2006
8// RCS-ID: $Id$
9// Copyright: (c) 2006 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17%newgroup
18
d211a853
RD
19enum {
20 wxPB_USE_TEXTCTRL,
21 };
22
23
24DocStr(wxPickerBase,
25"Base abstract class for all pickers which support an auxiliary text
26control. This class handles all positioning and sizing of the text
27control like a an horizontal `wx.BoxSizer` would do, with the text
28control on the left of the picker button and the proportion of the
29picker fixed to value 1.", "");
30
31class wxPickerBase : public wxControl
32{
33public:
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();
38
39
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);
48
49
50
51 DocDeclStr(
52 void , SetInternalMargin(int newmargin),
53 "Sets the margin (in pixels) between the picker and the text control.", "");
54
55 DocDeclStr(
56 int , GetInternalMargin() const,
57 "Returns the margin (in pixels) between the picker and the text
58control.", "");
59
60
61 DocDeclStr(
62 void , SetTextCtrlProportion(int prop),
63 "Sets the proportion between the text control and the picker button.
64This is used to set relative sizes of the text contorl and the picker.
65The value passed to this function must be >= 1.", "");
66
67 DocDeclStr(
68 int , GetTextCtrlProportion() const,
69 "Returns the proportion between the text control and the picker.", "");
70
71
72 DocDeclStr(
73 bool , HasTextCtrl() const,
74 "Returns true if this class has a valid text control (i.e. if the
75wx.PB_USE_TEXTCTRL style was given when creating this control).", "");
76
77 DocDeclStr(
78 wxTextCtrl *, GetTextCtrl(),
79 "Returns a pointer to the text control handled by this class or None if
80the wx.PB_USE_TEXTCTRL style was not specified when this control was
81created.
82
83Very important: the contents of the text control could be containing
84an invalid representation of the entity which can be chosen through
85the picker (e.g. the user entered an invalid colour syntax because of
86a typo). Thus you should never parse the content of the textctrl to
87get the user's input; rather use the derived-class getter
88(e.g. `wx.ColourPickerCtrl.GetColour`, `wx.FilePickerCtrl.GetPath`,
89etc).", "");
90
91 DocDeclStr(
92 wxControl *, GetPickerCtrl(),
93 "", "");
94
95};
96
97//---------------------------------------------------------------------------
98%newgroup
99
100MAKE_CONST_WXSTRING(ColourPickerCtrlNameStr);
101
102enum {
103 wxCLRP_SHOW_LABEL,
104 wxCLRP_USE_TEXTCTRL,
105 wxCLRP_DEFAULT_STYLE,
106};
107
108
109MustHaveApp(wxColourPickerCtrl);
110DocStr(wxColourPickerCtrl,
111"This control allows the user to select a colour. The generic
112implementation is a button which brings up a `wx.ColourDialog` when
113clicked. Native implementations may differ but this is usually a
114(small) widget which give access to the colour-chooser dialog.",
115
116"
117Window Styles
118-------------
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 ====================== ============================================
131
132Events
133------
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 ======================== ==========================================
141");
142
143class wxColourPickerCtrl : public wxPickerBase
144{
145public:
146 %pythonAppend wxColourPickerCtrl "self._setOORInfo(self)"
147 %pythonAppend wxColourPickerCtrl() ""
148
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());
157
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);
165
166
167 DocDeclStr(
168 wxColour , GetColour() const,
169 "Returns the currently selected colour.", "");
170
171
172 DocDeclStr(
173 void , SetColour(const wxColour& col),
174 "Set the displayed colour.", "");
175
176};
177
178
179
180%constant wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED;
181%pythoncode {
182 EVT_COLOURPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_COLOURPICKER_CHANGED, 1 )
183}
184
185class wxColourPickerEvent : public wxCommandEvent
186{
187public:
188 wxColourPickerEvent(wxObject *generator, int id, const wxColour &col);
189
190 wxColour GetColour() const;
191 void SetColour(const wxColour &c);
192};
193
194
195//---------------------------------------------------------------------------
196%newgroup
197
198MAKE_CONST_WXSTRING(FilePickerCtrlNameStr);
199MAKE_CONST_WXSTRING(FileSelectorPromptStr);
200MAKE_CONST_WXSTRING(DirPickerCtrlNameStr);
201MAKE_CONST_WXSTRING(DirSelectorPromptStr);
202MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
203
204
205enum {
206 wxFLP_OPEN,
207 wxFLP_SAVE,
208 wxFLP_OVERWRITE_PROMPT,
209 wxFLP_FILE_MUST_EXIST,
210 wxFLP_CHANGE_DIR,
211 wxDIRP_DIR_MUST_EXIST,
212 wxDIRP_CHANGE_DIR,
213
214 wxFLP_USE_TEXTCTRL,
215 wxFLP_DEFAULT_STYLE,
216
217 wxDIRP_USE_TEXTCTRL,
218 wxDIRP_DEFAULT_STYLE,
219};
220
221
222
223MustHaveApp(wxFilePickerCtrl);
224DocStr(wxFilePickerCtrl,
225 "", "");
226
227class wxFilePickerCtrl : public wxPickerBase
228{
229public:
230 %pythonAppend wxFilePickerCtrl "self._setOORInfo(self)"
231 %pythonAppend wxFilePickerCtrl() ""
232
233 wxFilePickerCtrl(wxWindow *parent,
234 wxWindowID id=-1,
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());
244
245 bool Create(wxWindow *parent,
246 wxWindowID id=-1,
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);
255
256 wxString GetPath() const;
257 void SetPath(const wxString &str);
258
259};
260
261
262
263
264MustHaveApp(wxDirPickerCtrl);
265DocStr(wxDirPickerCtrl,
266 "", "");
267
268class wxDirPickerCtrl : public wxPickerBase
269{
270public:
271 %pythonAppend wxDirPickerCtrl "self._setOORInfo(self)"
272 %pythonAppend wxDirPickerCtrl() ""
273
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());
283
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);
292
293 wxString GetPath() const;
294 void SetPath(const wxString &str);
295};
296
297
298%constant wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
299%constant wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
300
301%pythoncode {
302EVT_FILEPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FILEPICKER_CHANGED, 1 )
303EVT_DIRPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_DIRPICKER_CHANGED, 1 )
304}
305
306class wxFileDirPickerEvent : public wxCommandEvent
307{
308public:
309 wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path);
310
311 wxString GetPath() const { return m_path; }
312 void SetPath(const wxString &p) { m_path = p; }
313};
314
315
316//---------------------------------------------------------------------------
317%newgroup
318
319MAKE_CONST_WXSTRING(FontPickerCtrlNameStr);
320
321enum {
322 wxFNTP_FONTDESC_AS_LABEL,
323 wxFNTP_USEFONT_FOR_LABEL,
324 wxFNTP_USE_TEXTCTRL,
325 wxFNTP_DEFAULT_STYLE,
326};
327
328
329MustHaveApp(wxFontPickerCtrl);
330DocStr(wxFontPickerCtrl,
331 "", "");
332
333
334class wxFontPickerCtrl : public wxPickerBase
335{
336public:
337 %pythonAppend wxFontPickerCtrl "self._setOORInfo(self)"
338 %pythonAppend wxFontPickerCtrl() ""
339
340
341 wxFontPickerCtrl(wxWindow *parent,
342 wxWindowID id=-1,
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());
350
351 bool Create(wxWindow *parent,
352 wxWindowID id=-1,
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);
359
360
361 // get the font chosen
362 wxFont GetSelectedFont() const;
363
364 // sets currently displayed font
365 void SetSelectedFont(const wxFont& f);
366
367 // set/get the max pointsize
368 void SetMaxPointSize(unsigned int max);
369 unsigned int GetMaxPointSize() const;
370};
371
372
373%constant wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
374
375%pythoncode {
376EVT_FONTPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FONTPICKER_CHANGED, 1 )
377}
378
379
380class wxFontPickerEvent : public wxCommandEvent
381{
382public:
383 wxFontPickerEvent(wxObject *generator, int id, const wxFont &f);
384
385 wxFont GetFont() const;
386 void SetFont(const wxFont &c);
387};
388
389//---------------------------------------------------------------------------