]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_cmndlgs.i
Remove crash due to reference being kept after object destroyed
[wxWidgets.git] / wxPython / src / _cmndlgs.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _cmndlgs.i
3 // Purpose: SWIG interface for the "Common Dialog" classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 25-July-1998
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17 %newgroup
18
19 MAKE_CONST_WXSTRING(FileSelectorPromptStr);
20 MAKE_CONST_WXSTRING(DirSelectorPromptStr);
21 MAKE_CONST_WXSTRING(DirDialogNameStr);
22 MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
23 MAKE_CONST_WXSTRING(GetTextFromUserPromptStr);
24 MAKE_CONST_WXSTRING(MessageBoxCaptionStr);
25
26 //---------------------------------------------------------------------------
27
28
29 DocStr(wxColourData,
30 "This class holds a variety of information related to colour dialogs.");
31
32 class wxColourData : public wxObject {
33 public:
34 DocCtorStr(
35 wxColourData(),
36 "Constructor, sets default values.");
37
38 ~wxColourData();
39
40
41 DocDeclStr(
42 bool , GetChooseFull(),
43 "Under Windows, determines whether the Windows colour dialog will display\n"
44 "the full dialog with custom colour selection controls. Has no meaning\n"
45 "under other platforms. The default value is true.");
46
47 DocDeclStr(
48 wxColour , GetColour(),
49 "Gets the colour (pre)selected by the dialog.");
50
51 DocDeclStr(
52 wxColour , GetCustomColour(int i),
53 "Gets the i'th custom colour associated with the colour dialog. i should\n"
54 "be an integer between 0 and 15. The default custom colours are all white.");
55
56 DocDeclStr(
57 void , SetChooseFull(int flag),
58 "Under Windows, tells the Windows colour dialog to display the full dialog\n"
59 "with custom colour selection controls. Under other platforms, has no effect.\n"
60 "The default value is true.");
61
62 DocDeclStr(
63 void , SetColour(const wxColour& colour),
64 "Sets the default colour for the colour dialog. The default colour is black.");
65
66 DocDeclStr(
67 void , SetCustomColour(int i, const wxColour& colour),
68 "Sets the i'th custom colour for the colour dialog. i should be an integer\n"
69 "between 0 and 15. The default custom colours are all white.");
70
71 };
72
73
74 DocStr(wxColourDialog,
75 "This class represents the colour chooser dialog.");
76
77 class wxColourDialog : public wxDialog {
78 public:
79 %pythonAppend wxColourDialog "self._setOORInfo(self)"
80
81 DocCtorStr(
82 wxColourDialog(wxWindow* parent, wxColourData* data = NULL),
83 "Constructor. Pass a parent window, and optionally a ColourData, which\n"
84 "will be copied to the colour dialog's internal ColourData instance.");
85
86 DocDeclStr(
87 wxColourData& , GetColourData(),
88 "Returns a reference to the ColourData used by the dialog.");
89 };
90
91
92 //--------------------------------------------------------------------------------
93
94
95 DocStr(wxDirDialog,
96 "This class represents the directory chooser dialog.");
97
98 RefDoc(wxDirDialog, "
99 Styles
100 wxDD_NEW_DIR_BUTTON Add \"Create new directory\" button and allow
101 directory names to be editable. On Windows the new
102 directory button is only available with recent
103 versions of the common dialogs.");
104
105 class wxDirDialog : public wxDialog {
106 public:
107 %pythonAppend wxDirDialog "self._setOORInfo(self)"
108
109 DocCtorStr(
110 wxDirDialog(wxWindow* parent,
111 const wxString& message = wxPyDirSelectorPromptStr,
112 const wxString& defaultPath = wxPyEmptyString,
113 long style = 0,
114 const wxPoint& pos = wxDefaultPosition,
115 const wxSize& size = wxDefaultSize,
116 const wxString& name = wxPyDirDialogNameStr),
117 "Constructor. Use ShowModal method to show the dialog.");
118
119
120 DocDeclStr(
121 wxString , GetPath(),
122 "Returns the default or user-selected path.");
123
124 DocDeclStr(
125 wxString , GetMessage(),
126 "Returns the message that will be displayed on the dialog.");
127
128 DocDeclStr(
129 long , GetStyle(),
130 "Returns the dialog style.");
131
132 DocDeclStr(
133 void , SetMessage(const wxString& message),
134 "Sets the message that will be displayed on the dialog.");
135
136 DocDeclStr(
137 void , SetPath(const wxString& path),
138 "Sets the default path.");
139
140 };
141
142
143 //---------------------------------------------------------------------------
144
145 DocStr(wxFileDialog,
146 "This class represents the file chooser dialog.");
147
148 RefDoc(wxFileDialog, "
149 In Windows, this is the common file selector dialog. In X, this is a file
150 selector box with somewhat less functionality. The path and filename are
151 distinct elements of a full file pathname. If path is \"\", the current
152 directory will be used. If filename is \"\", no default filename will be
153 supplied. The wildcard determines what files are displayed in the file
154 selector, and file extension supplies a type extension for the required
155 filename.
156
157 Both the X and Windows versions implement a wildcard filter. Typing a filename
158 containing wildcards (*, ?) in the filename text item, and clicking on Ok,
159 will result in only those files matching the pattern being displayed. The
160 wildcard may be a specification for multiple types of file with a description
161 for each, such as:
162
163 \"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif\"
164
165 Styles
166 wx.OPEN This is an open dialog.
167
168 wx.SAVE This is a save dialog.
169
170 wx.HIDE_READONLY For open dialog only: hide the checkbox allowing to
171 open the file in read-only mode.
172
173 wx.OVERWRITE_PROMPT For save dialog only: prompt for a confirmation if a
174 file will be overwritten.
175
176 wx.MULTIPLE For open dialog only: allows selecting multiple files.
177
178 wx.CHANGE_DIR Change the current working directory to the directory
179 where the file(s) chosen by the user are.
180 ");
181
182
183
184 class wxFileDialog : public wxDialog {
185 public:
186 %pythonAppend wxFileDialog "self._setOORInfo(self)"
187
188 DocCtorStr(
189 wxFileDialog(wxWindow* parent,
190 const wxString& message = wxPyFileSelectorPromptStr,
191 const wxString& defaultDir = wxPyEmptyString,
192 const wxString& defaultFile = wxPyEmptyString,
193 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
194 long style = 0,
195 const wxPoint& pos = wxDefaultPosition),
196 "Constructor. Use ShowModal method to show the dialog.");
197
198
199 DocDeclStr(
200 void , SetMessage(const wxString& message),
201 "Sets the message that will be displayed on the dialog.");
202
203 DocDeclStr(
204 void , SetPath(const wxString& path),
205 "Sets the path (the combined directory and filename that will\n"
206 "be returned when the dialog is dismissed).");
207
208 DocDeclStr(
209 void , SetDirectory(const wxString& dir),
210 "Sets the default directory.");
211
212 DocDeclStr(
213 void , SetFilename(const wxString& name),
214 "Sets the default filename.");
215
216 DocDeclStr(
217 void , SetWildcard(const wxString& wildCard),
218 "Sets the wildcard, which can contain multiple file types, for example:\n"
219 " \"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif\"");
220
221 DocDeclStr(
222 void , SetStyle(long style),
223 "Sets the dialog style.");
224
225 DocDeclStr(
226 void , SetFilterIndex(int filterIndex),
227 "Sets the default filter index, starting from zero.");
228
229
230 DocDeclStr(
231 wxString , GetMessage() const,
232 "Returns the message that will be displayed on the dialog.");
233
234 DocDeclStr(
235 wxString , GetPath() const,
236 "Returns the full path (directory and filename) of the selected file.");
237
238 DocDeclStr(
239 wxString , GetDirectory() const,
240 "Returns the default directory.");
241
242 DocDeclStr(
243 wxString , GetFilename() const,
244 "Returns the default filename.");
245
246 DocDeclStr(
247 wxString , GetWildcard() const,
248 "Returns the file dialog wildcard.");
249
250 DocDeclStr(
251 long , GetStyle() const,
252 "Returns the dialog style.");
253
254 DocDeclStr(
255 int , GetFilterIndex() const,
256 "Returns the index into the list of filters supplied, optionally, in\n"
257 "the wildcard parameter. Before the dialog is shown, this is the index\n"
258 "which will be used when the dialog is first displayed. After the dialog\n"
259 "is shown, this is the index selected by the user.");
260
261
262 DocStr(GetFilenames,
263 "Returns a list of filenames chosen in the dialog. This function should\n"
264 "only be used with the dialogs which have wx.MULTIPLE style, use\n"
265 "GetFilename for the others.");
266
267 DocStr(GetPaths,
268 "Fills the array paths with the full paths of the files chosen. This\n"
269 "function should only be used with the dialogs which have wx.MULTIPLE style,\n"
270 "use GetPath for the others.");
271
272 %extend {
273 PyObject* GetFilenames() {
274 wxArrayString arr;
275 self->GetFilenames(arr);
276 return wxArrayString2PyList_helper(arr);
277 }
278
279 PyObject* GetPaths() {
280 wxArrayString arr;
281 self->GetPaths(arr);
282 return wxArrayString2PyList_helper(arr);
283 }
284 }
285
286 // TODO
287 // // Utility functions
288
289 // // Parses the wildCard, returning the number of filters.
290 // // Returns 0 if none or if there's a problem,
291 // // The arrays will contain an equal number of items found before the error.
292 // // wildCard is in the form:
293 // // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
294 // static int ParseWildcard(const wxString& wildCard,
295 // wxArrayString& descriptions,
296 // wxArrayString& filters);
297
298 // // Append first extension to filePath from a ';' separated extensionList
299 // // if filePath = "path/foo.bar" just return it as is
300 // // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
301 // // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
302 // static wxString AppendExtension(const wxString &filePath,
303 // const wxString &extensionList);
304
305
306 };
307
308
309 //---------------------------------------------------------------------------
310
311 enum { wxCHOICEDLG_STYLE };
312
313 class wxMultiChoiceDialog : public wxDialog
314 {
315 public:
316 %pythonAppend wxMultiChoiceDialog "self._setOORInfo(self)"
317
318 wxMultiChoiceDialog(wxWindow *parent,
319 const wxString& message,
320 const wxString& caption,
321 int choices=0, wxString* choices_array,
322 long style = wxCHOICEDLG_STYLE,
323 const wxPoint& pos = wxDefaultPosition);
324
325 void SetSelections(const wxArrayInt& selections);
326
327 // wxArrayInt GetSelections() const;
328 %extend {
329 PyObject* GetSelections() {
330 return wxArrayInt2PyList_helper(self->GetSelections());
331 }
332 }
333 };
334
335
336 //---------------------------------------------------------------------------
337
338 class wxSingleChoiceDialog : public wxDialog {
339 public:
340 %pythonAppend wxSingleChoiceDialog "self._setOORInfo(self)"
341
342 %extend {
343 // TODO: ignoring clientData for now... FIX THIS
344 // SWIG is messing up the &/*'s for some reason.
345 wxSingleChoiceDialog(wxWindow* parent,
346 const wxString& message,
347 const wxString& caption,
348 int choices, wxString* choices_array,
349 //char** clientData = NULL,
350 long style = wxCHOICEDLG_STYLE,
351 const wxPoint& pos = wxDefaultPosition) {
352 return new wxSingleChoiceDialog(parent, message, caption,
353 choices, choices_array, NULL, style, pos);
354 }
355 }
356
357 int GetSelection();
358 wxString GetStringSelection();
359 void SetSelection(int sel);
360 int ShowModal();
361 };
362
363
364 //---------------------------------------------------------------------------
365
366 class wxTextEntryDialog : public wxDialog {
367 public:
368 %pythonAppend wxTextEntryDialog "self._setOORInfo(self)"
369
370 wxTextEntryDialog(wxWindow* parent,
371 const wxString& message,
372 const wxString& caption = wxPyGetTextFromUserPromptStr,
373 const wxString& defaultValue = wxPyEmptyString,
374 long style = wxOK | wxCANCEL | wxCENTRE,
375 const wxPoint& pos = wxDefaultPosition);
376
377 wxString GetValue();
378 void SetValue(const wxString& value);
379 int ShowModal();
380 };
381
382 //---------------------------------------------------------------------------
383
384 class wxFontData : public wxObject {
385 public:
386 wxFontData();
387 ~wxFontData();
388
389 void EnableEffects(bool enable);
390 bool GetAllowSymbols();
391 wxColour GetColour();
392 wxFont GetChosenFont();
393 bool GetEnableEffects();
394 wxFont GetInitialFont();
395 bool GetShowHelp();
396 void SetAllowSymbols(bool allowSymbols);
397 void SetChosenFont(const wxFont& font);
398 void SetColour(const wxColour& colour);
399 void SetInitialFont(const wxFont& font);
400 void SetRange(int min, int max);
401 void SetShowHelp(bool showHelp);
402 };
403
404
405 class wxFontDialog : public wxDialog {
406 public:
407 %pythonAppend wxFontDialog "self._setOORInfo(self)"
408
409 wxFontDialog(wxWindow* parent, const wxFontData& data);
410
411 wxFontData& GetFontData();
412 int ShowModal();
413 };
414
415
416 //---------------------------------------------------------------------------
417
418 class wxMessageDialog : public wxDialog {
419 public:
420 %pythonAppend wxMessageDialog "self._setOORInfo(self)"
421
422 wxMessageDialog(wxWindow* parent,
423 const wxString& message,
424 const wxString& caption = wxPyMessageBoxCaptionStr,
425 long style = wxOK | wxCANCEL | wxCENTRE,
426 const wxPoint& pos = wxDefaultPosition);
427
428 int ShowModal();
429 };
430
431 //---------------------------------------------------------------------------
432
433 class wxProgressDialog : public wxFrame {
434 public:
435 %pythonAppend wxProgressDialog "self._setOORInfo(self)"
436
437 wxProgressDialog(const wxString& title,
438 const wxString& message,
439 int maximum = 100,
440 wxWindow* parent = NULL,
441 int style = wxPD_AUTO_HIDE | wxPD_APP_MODAL );
442
443 bool Update(int value, const wxString& newmsg = wxPyEmptyString);
444 void Resume();
445 };
446
447 //---------------------------------------------------------------------------
448
449 enum wxFindReplaceFlags
450 {
451 // downward search/replace selected (otherwise - upwards)
452 wxFR_DOWN = 1,
453
454 // whole word search/replace selected
455 wxFR_WHOLEWORD = 2,
456
457 // case sensitive search/replace selected (otherwise - case insensitive)
458 wxFR_MATCHCASE = 4
459 };
460
461
462 enum wxFindReplaceDialogStyles
463 {
464 // replace dialog (otherwise find dialog)
465 wxFR_REPLACEDIALOG = 1,
466
467 // don't allow changing the search direction
468 wxFR_NOUPDOWN = 2,
469
470 // don't allow case sensitive searching
471 wxFR_NOMATCHCASE = 4,
472
473 // don't allow whole word searching
474 wxFR_NOWHOLEWORD = 8
475 };
476
477
478
479 %constant wxEventType wxEVT_COMMAND_FIND;
480 %constant wxEventType wxEVT_COMMAND_FIND_NEXT;
481 %constant wxEventType wxEVT_COMMAND_FIND_REPLACE;
482 %constant wxEventType wxEVT_COMMAND_FIND_REPLACE_ALL;
483 %constant wxEventType wxEVT_COMMAND_FIND_CLOSE;
484
485
486 %pythoncode {
487 EVT_FIND = wx.PyEventBinder( wxEVT_COMMAND_FIND, 1 )
488 EVT_FIND_NEXT = wx.PyEventBinder( wxEVT_COMMAND_FIND_NEXT, 1 )
489 EVT_FIND_REPLACE = wx.PyEventBinder( wxEVT_COMMAND_FIND_REPLACE, 1 )
490 EVT_FIND_REPLACE_ALL = wx.PyEventBinder( wxEVT_COMMAND_FIND_REPLACE_ALL, 1 )
491 EVT_FIND_CLOSE = wx.PyEventBinder( wxEVT_COMMAND_FIND_CLOSE, 1 )
492
493 %# For backwards compatibility. Should they be removed?
494 EVT_COMMAND_FIND = EVT_FIND
495 EVT_COMMAND_FIND_NEXT = EVT_FIND_NEXT
496 EVT_COMMAND_FIND_REPLACE = EVT_FIND_REPLACE
497 EVT_COMMAND_FIND_REPLACE_ALL = EVT_FIND_REPLACE_ALL
498 EVT_COMMAND_FIND_CLOSE = EVT_FIND_CLOSE
499 }
500
501
502 class wxFindDialogEvent : public wxCommandEvent
503 {
504 public:
505 wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
506 int GetFlags();
507 const wxString& GetFindString();
508 const wxString& GetReplaceString();
509 wxFindReplaceDialog *GetDialog();
510 void SetFlags(int flags);
511 void SetFindString(const wxString& str);
512 void SetReplaceString(const wxString& str);
513 };
514
515
516
517 class wxFindReplaceData : public wxObject
518 {
519 public:
520 wxFindReplaceData(int flags=0);
521 ~wxFindReplaceData();
522
523 const wxString& GetFindString();
524 const wxString& GetReplaceString();
525 int GetFlags();
526 void SetFlags(int flags);
527 void SetFindString(const wxString& str);
528 void SetReplaceString(const wxString& str);
529 };
530
531
532 class wxFindReplaceDialog : public wxDialog {
533 public:
534 %pythonAppend wxFindReplaceDialog "self._setOORInfo(self)"
535 %pythonAppend wxFindReplaceDialog() ""
536
537 wxFindReplaceDialog(wxWindow *parent,
538 wxFindReplaceData *data,
539 const wxString &title,
540 int style = 0);
541 %name(PreFindReplaceDialog)wxFindReplaceDialog();
542
543 bool Create(wxWindow *parent,
544 wxFindReplaceData *data,
545 const wxString &title,
546 int style = 0);
547
548 const wxFindReplaceData *GetData();
549 void SetData(wxFindReplaceData *data);
550 };
551
552 //---------------------------------------------------------------------------
553 //---------------------------------------------------------------------------