]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_picker.i
out typemap for wxMemorySize
[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
9718662d
RD
71 DocDeclStr(
72 bool , IsTextCtrlGrowable() const,
73 "", "");
74
75 DocDeclStr(
76 void , SetTextCtrlGrowable(bool grow = true),
77 "", "");
78
79
80 DocDeclStr(
81 bool , IsPickerCtrlGrowable() const,
82 "", "");
83
84 DocDeclStr(
85 void , SetPickerCtrlGrowable(bool grow = true),
86 "", "");
87
d211a853
RD
88
89 DocDeclStr(
90 bool , HasTextCtrl() const,
91 "Returns true if this class has a valid text control (i.e. if the
92wx.PB_USE_TEXTCTRL style was given when creating this control).", "");
93
94 DocDeclStr(
95 wxTextCtrl *, GetTextCtrl(),
96 "Returns a pointer to the text control handled by this class or None if
97the wx.PB_USE_TEXTCTRL style was not specified when this control was
98created.
99
100Very important: the contents of the text control could be containing
101an invalid representation of the entity which can be chosen through
102the picker (e.g. the user entered an invalid colour syntax because of
103a typo). Thus you should never parse the content of the textctrl to
104get the user's input; rather use the derived-class getter
105(e.g. `wx.ColourPickerCtrl.GetColour`, `wx.FilePickerCtrl.GetPath`,
106etc).", "");
107
108 DocDeclStr(
109 wxControl *, GetPickerCtrl(),
110 "", "");
111
112};
113
114//---------------------------------------------------------------------------
115%newgroup
116
117MAKE_CONST_WXSTRING(ColourPickerCtrlNameStr);
118
119enum {
120 wxCLRP_SHOW_LABEL,
121 wxCLRP_USE_TEXTCTRL,
122 wxCLRP_DEFAULT_STYLE,
123};
124
125
126MustHaveApp(wxColourPickerCtrl);
127DocStr(wxColourPickerCtrl,
128"This control allows the user to select a colour. The generic
129implementation is a button which brings up a `wx.ColourDialog` when
130clicked. Native implementations may differ but this is usually a
131(small) widget which give access to the colour-chooser dialog.",
132
133"
134Window Styles
135-------------
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 ====================== ============================================
148
149Events
150------
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 ======================== ==========================================
158");
159
160class wxColourPickerCtrl : public wxPickerBase
161{
162public:
163 %pythonAppend wxColourPickerCtrl "self._setOORInfo(self)"
164 %pythonAppend wxColourPickerCtrl() ""
165
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());
174
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);
182
183
184 DocDeclStr(
185 wxColour , GetColour() const,
186 "Returns the currently selected colour.", "");
187
188
189 DocDeclStr(
190 void , SetColour(const wxColour& col),
191 "Set the displayed colour.", "");
192
193};
194
195
196
197%constant wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED;
198%pythoncode {
199 EVT_COLOURPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_COLOURPICKER_CHANGED, 1 )
200}
201
202class wxColourPickerEvent : public wxCommandEvent
203{
204public:
205 wxColourPickerEvent(wxObject *generator, int id, const wxColour &col);
206
207 wxColour GetColour() const;
208 void SetColour(const wxColour &c);
209};
210
211
212//---------------------------------------------------------------------------
213%newgroup
214
215MAKE_CONST_WXSTRING(FilePickerCtrlNameStr);
216MAKE_CONST_WXSTRING(FileSelectorPromptStr);
217MAKE_CONST_WXSTRING(DirPickerCtrlNameStr);
218MAKE_CONST_WXSTRING(DirSelectorPromptStr);
219MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
220
221
222enum {
223 wxFLP_OPEN,
224 wxFLP_SAVE,
225 wxFLP_OVERWRITE_PROMPT,
226 wxFLP_FILE_MUST_EXIST,
227 wxFLP_CHANGE_DIR,
228 wxDIRP_DIR_MUST_EXIST,
229 wxDIRP_CHANGE_DIR,
230
231 wxFLP_USE_TEXTCTRL,
232 wxFLP_DEFAULT_STYLE,
233
234 wxDIRP_USE_TEXTCTRL,
235 wxDIRP_DEFAULT_STYLE,
236};
237
238
239
240MustHaveApp(wxFilePickerCtrl);
241DocStr(wxFilePickerCtrl,
242 "", "");
243
244class wxFilePickerCtrl : public wxPickerBase
245{
246public:
247 %pythonAppend wxFilePickerCtrl "self._setOORInfo(self)"
248 %pythonAppend wxFilePickerCtrl() ""
249
250 wxFilePickerCtrl(wxWindow *parent,
251 wxWindowID id=-1,
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());
261
262 bool Create(wxWindow *parent,
263 wxWindowID id=-1,
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);
272
273 wxString GetPath() const;
274 void SetPath(const wxString &str);
275
9718662d
RD
276 // return true if the given path is valid for this control
277 bool CheckPath(const wxString& path) const;
278
279 // Returns the filtered value currently placed in the text control (if present).
280 wxString GetTextCtrlValue() const;
281
d211a853
RD
282};
283
284
285
286
287MustHaveApp(wxDirPickerCtrl);
288DocStr(wxDirPickerCtrl,
289 "", "");
290
291class wxDirPickerCtrl : public wxPickerBase
292{
293public:
294 %pythonAppend wxDirPickerCtrl "self._setOORInfo(self)"
295 %pythonAppend wxDirPickerCtrl() ""
296
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());
306
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);
315
316 wxString GetPath() const;
317 void SetPath(const wxString &str);
9718662d
RD
318
319 // return true if the given path is valid for this control
320 bool CheckPath(const wxString& path) const;
321
322 // Returns the filtered value currently placed in the text control (if present).
323 wxString GetTextCtrlValue() const;
d211a853
RD
324};
325
326
327%constant wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
328%constant wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
329
330%pythoncode {
331EVT_FILEPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FILEPICKER_CHANGED, 1 )
332EVT_DIRPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_DIRPICKER_CHANGED, 1 )
333}
334
335class wxFileDirPickerEvent : public wxCommandEvent
336{
337public:
338 wxFileDirPickerEvent(wxEventType type, wxObject *generator, int id, const wxString &path);
339
340 wxString GetPath() const { return m_path; }
341 void SetPath(const wxString &p) { m_path = p; }
342};
343
344
345//---------------------------------------------------------------------------
346%newgroup
347
348MAKE_CONST_WXSTRING(FontPickerCtrlNameStr);
349
350enum {
351 wxFNTP_FONTDESC_AS_LABEL,
352 wxFNTP_USEFONT_FOR_LABEL,
353 wxFNTP_USE_TEXTCTRL,
354 wxFNTP_DEFAULT_STYLE,
355};
356
357
358MustHaveApp(wxFontPickerCtrl);
359DocStr(wxFontPickerCtrl,
360 "", "");
361
362
363class wxFontPickerCtrl : public wxPickerBase
364{
365public:
366 %pythonAppend wxFontPickerCtrl "self._setOORInfo(self)"
367 %pythonAppend wxFontPickerCtrl() ""
368
369
370 wxFontPickerCtrl(wxWindow *parent,
371 wxWindowID id=-1,
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());
379
380 bool Create(wxWindow *parent,
381 wxWindowID id=-1,
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
389
390 // get the font chosen
391 wxFont GetSelectedFont() const;
392
393 // sets currently displayed font
394 void SetSelectedFont(const wxFont& f);
395
396 // set/get the max pointsize
397 void SetMaxPointSize(unsigned int max);
398 unsigned int GetMaxPointSize() const;
399};
400
401
402%constant wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
403
404%pythoncode {
405EVT_FONTPICKER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_FONTPICKER_CHANGED, 1 )
406}
407
408
409class wxFontPickerEvent : public wxCommandEvent
410{
411public:
412 wxFontPickerEvent(wxObject *generator, int id, const wxFont &f);
413
414 wxFont GetFont() const;
415 void SetFont(const wxFont &c);
416};
417
418//---------------------------------------------------------------------------