1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for the "Common Dialog" classes
7 // Created: 25-July-1998
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
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);
26 //---------------------------------------------------------------------------
30 "This class holds a variety of information related to colour dialogs.");
32 class wxColourData : public wxObject {
36 "Constructor, sets default values.");
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.");
48 wxColour , GetColour(),
49 "Gets the colour (pre)selected by the dialog.");
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.");
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.");
63 void , SetColour(const wxColour& colour),
64 "Sets the default colour for the colour dialog. The default colour is black.");
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.");
74 DocStr(wxColourDialog,
75 "This class represents the colour chooser dialog.");
77 class wxColourDialog : public wxDialog {
79 %pythonAppend wxColourDialog "self._setOORInfo(self)"
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.");
87 wxColourData& , GetColourData(),
88 "Returns a reference to the ColourData used by the dialog.");
92 //--------------------------------------------------------------------------------
96 "This class represents the directory chooser dialog.");
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.");
105 class wxDirDialog : public wxDialog {
107 %pythonAppend wxDirDialog "self._setOORInfo(self)"
110 wxDirDialog(wxWindow* parent,
111 const wxString& message = wxPyDirSelectorPromptStr,
112 const wxString& defaultPath = wxPyEmptyString,
114 const wxPoint& pos = wxDefaultPosition,
115 const wxSize& size = wxDefaultSize,
116 const wxString& name = wxPyDirDialogNameStr),
117 "Constructor. Use ShowModal method to show the dialog.");
121 wxString , GetPath(),
122 "Returns the default or user-selected path.");
125 wxString , GetMessage(),
126 "Returns the message that will be displayed on the dialog.");
130 "Returns the dialog style.");
133 void , SetMessage(const wxString& message),
134 "Sets the message that will be displayed on the dialog.");
137 void , SetPath(const wxString& path),
138 "Sets the default path.");
143 //---------------------------------------------------------------------------
146 "This class represents the file chooser dialog.");
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
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
163 \"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif\"
166 wx.OPEN This is an open dialog.
168 wx.SAVE This is a save dialog.
170 wx.HIDE_READONLY For open dialog only: hide the checkbox allowing to
171 open the file in read-only mode.
173 wx.OVERWRITE_PROMPT For save dialog only: prompt for a confirmation if a
174 file will be overwritten.
176 wx.MULTIPLE For open dialog only: allows selecting multiple files.
178 wx.CHANGE_DIR Change the current working directory to the directory
179 where the file(s) chosen by the user are.
184 class wxFileDialog : public wxDialog {
186 %pythonAppend wxFileDialog "self._setOORInfo(self)"
189 wxFileDialog(wxWindow* parent,
190 const wxString& message = wxPyFileSelectorPromptStr,
191 const wxString& defaultDir = wxPyEmptyString,
192 const wxString& defaultFile = wxPyEmptyString,
193 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
195 const wxPoint& pos = wxDefaultPosition),
196 "Constructor. Use ShowModal method to show the dialog.");
200 void , SetMessage(const wxString& message),
201 "Sets the message that will be displayed on the dialog.");
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).");
209 void , SetDirectory(const wxString& dir),
210 "Sets the default directory.");
213 void , SetFilename(const wxString& name),
214 "Sets the default filename.");
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\"");
222 void , SetStyle(long style),
223 "Sets the dialog style.");
226 void , SetFilterIndex(int filterIndex),
227 "Sets the default filter index, starting from zero.");
231 wxString , GetMessage() const,
232 "Returns the message that will be displayed on the dialog.");
235 wxString , GetPath() const,
236 "Returns the full path (directory and filename) of the selected file.");
239 wxString , GetDirectory() const,
240 "Returns the default directory.");
243 wxString , GetFilename() const,
244 "Returns the default filename.");
247 wxString , GetWildcard() const,
248 "Returns the file dialog wildcard.");
251 long , GetStyle() const,
252 "Returns the dialog style.");
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.");
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.");
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.");
273 PyObject* GetFilenames() {
275 self->GetFilenames(arr);
276 return wxArrayString2PyList_helper(arr);
279 PyObject* GetPaths() {
282 return wxArrayString2PyList_helper(arr);
287 // // Utility functions
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);
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);
309 //---------------------------------------------------------------------------
311 enum { wxCHOICEDLG_STYLE };
314 DocStr(wxMultiChoiceDialog,
315 "A simple dialog with a multi selection listbox.");
317 class wxMultiChoiceDialog : public wxDialog
320 %pythonAppend wxMultiChoiceDialog "self._setOORInfo(self)"
323 wxMultiChoiceDialog(wxWindow *parent,
324 const wxString& message,
325 const wxString& caption,
326 int choices=0, wxString* choices_array,
327 long style = wxCHOICEDLG_STYLE,
328 const wxPoint& pos = wxDefaultPosition),
329 "__init__(Window parent, String message, String caption,\n"
330 " List choices=[], long style=CHOICEDLG_STYLE,\n"
331 " Point pos=DefaultPosition) -> MultiChoiceDialog",
332 "Constructor. Use ShowModal method to show the dialog.");
336 void, SetSelections(const wxArrayInt& selections),
337 "SetSelections(List selections)",
338 "Specify the items in the list that shoudl be selected, using a list of integers.");
340 DocAStr(GetSelections,
341 "GetSelections() -> [selections]",
342 "Returns a list of integers representing the items that are selected.");
344 PyObject* GetSelections() {
345 return wxArrayInt2PyList_helper(self->GetSelections());
351 //---------------------------------------------------------------------------
353 DocStr(wxSingleChoiceDialog,
354 "A simple dialog with a single selection listbox.");
356 class wxSingleChoiceDialog : public wxDialog {
358 %pythonAppend wxSingleChoiceDialog "self._setOORInfo(self)"
360 DocAStr(wxSingleChoiceDialog,
361 "__init__(Window parent, String message, String caption,\n"
362 " List choices=[], long style=CHOICEDLG_STYLE,\n"
363 " Point pos=DefaultPosition) -> SingleChoiceDialog",
364 "Constructor. Use ShowModal method to show the dialog.");
367 // TODO: ignoring clientData for now... FIX THIS
368 // SWIG is messing up the &/*'s for some reason.
369 wxSingleChoiceDialog(wxWindow* parent,
370 const wxString& message,
371 const wxString& caption,
372 int choices, wxString* choices_array,
373 //char** clientData = NULL,
374 long style = wxCHOICEDLG_STYLE,
375 const wxPoint& pos = wxDefaultPosition) {
376 return new wxSingleChoiceDialog(parent, message, caption,
377 choices, choices_array, NULL, style, pos);
382 int , GetSelection(),
383 "Get the index of teh currently selected item.");
386 wxString , GetStringSelection(),
387 "Returns the string value of the currently selected item");
390 void , SetSelection(int sel),
391 "Set the current selected item to sel");
395 //---------------------------------------------------------------------------
397 DocStr(wxTextEntryDialog,
398 "A dialog with text control, [ok] and [cancel] buttons");
400 class wxTextEntryDialog : public wxDialog {
402 %pythonAppend wxTextEntryDialog "self._setOORInfo(self)"
405 wxTextEntryDialog(wxWindow* parent,
406 const wxString& message,
407 const wxString& caption = wxPyGetTextFromUserPromptStr,
408 const wxString& defaultValue = wxPyEmptyString,
409 long style = wxOK | wxCANCEL | wxCENTRE,
410 const wxPoint& pos = wxDefaultPosition),
411 "Constructor. Use ShowModal method to show the dialog.");
414 wxString , GetValue(),
415 "Returns the text that the user has entered if the user has pressed OK,\n"
416 "or the original value if the user has pressed Cancel.");
419 void , SetValue(const wxString& value),
420 "Sets the default text value.");
423 //---------------------------------------------------------------------------
427 "This class holds a variety of information related to font dialogs.");
430 class wxFontData : public wxObject {
436 void , EnableEffects(bool enable),
437 "Enables or disables 'effects' under MS Windows only. This refers\n"
438 "to the controls for manipulating colour, strikeout and underline\n"
439 "properties. The default value is true.");
442 bool , GetAllowSymbols(),
443 "Under MS Windows, returns a flag determining whether symbol fonts can be\n"
444 "selected. Has no effect on other platforms. The default value is true.");
447 wxColour , GetColour(),
448 "Gets the colour associated with the font dialog. The default value is black.");
451 wxFont , GetChosenFont(),
452 "Gets the font chosen by the user.");
455 bool , GetEnableEffects(),
456 "Determines whether 'effects' are enabled under Windows.");
459 wxFont , GetInitialFont(),
460 "Gets the font that will be initially used by the font dialog. This should have\n"
461 "previously been set by the application.");
464 bool , GetShowHelp(),
465 "Returns true if the Help button will be shown (Windows only). The default\n"
469 void , SetAllowSymbols(bool allowSymbols),
470 "Under MS Windows, determines whether symbol fonts can be selected. Has no\n"
471 "effect on other platforms. The default value is true.");
474 void , SetChosenFont(const wxFont& font),
475 "Sets the font that will be returned to the user (for internal use only).");
478 void , SetColour(const wxColour& colour),
479 "Sets the colour that will be used for the font foreground colour. The default\n"
483 void , SetInitialFont(const wxFont& font),
484 "Sets the font that will be initially used by the font dialog.");
487 void , SetRange(int min, int max),
488 "Sets the valid range for the font point size (Windows only). The default is\n"
489 "0, 0 (unrestricted range).");
492 void , SetShowHelp(bool showHelp),
493 "Determines whether the Help button will be displayed in the font dialog\n"
494 "(Windows only). The default value is false.");
501 "This class represents the font chooser dialog.");
503 class wxFontDialog : public wxDialog {
505 %pythonAppend wxFontDialog "self._setOORInfo(self)"
508 "Constructor. Pass a parent window and the FontData object to be\n"
509 "used to initialize the dialog controls.");
510 wxFontDialog(wxWindow* parent, const wxFontData& data);
514 wxFontData& , GetFontData(),
515 "Returns a reference to the internal FontData used by the FontDialog.");
519 //---------------------------------------------------------------------------
522 DocStr(wxMessageDialog,
523 "This class provides a dialog that shows a single or multi-line message, with\n"
524 "a choice of OK, Yes, No and Cancel buttons.");
526 RefDoc(wxMessageDialog, "
528 wx.OK: Show an OK button.
530 wx.CANCEL: Show a Cancel button.
532 wx.YES_NO: Show Yes and No buttons.
534 wx.YES_DEFAULT: Used with wxYES_NO, makes Yes button the default - which is the default behaviour.
536 wx.NO_DEFAULT: Used with wxYES_NO, makes No button the default.
538 wx.ICON_EXCLAMATION: Shows an exclamation mark icon.
540 wx.ICON_HAND: Shows an error icon.
542 wx.ICON_ERROR: Shows an error icon - the same as wxICON_HAND.
544 wx.ICON_QUESTION: Shows a question mark icon.
546 wx.ICON_INFORMATION: Shows an information (i) icon.
548 wx.STAY_ON_TOP: The message box stays on top of all other window, even those of the other applications (Windows only).
552 class wxMessageDialog : public wxDialog {
554 %pythonAppend wxMessageDialog "self._setOORInfo(self)"
556 wxMessageDialog(wxWindow* parent,
557 const wxString& message,
558 const wxString& caption = wxPyMessageBoxCaptionStr,
559 long style = wxOK | wxCANCEL | wxCENTRE,
560 const wxPoint& pos = wxDefaultPosition);
564 //---------------------------------------------------------------------------
567 DocStr(wxProgressDialog,
568 "A dialog that shows a short message and a progress bar. Optionally, it can\n"
569 "display an ABORT button.");
571 RefDoc(wxProgressDialog, "
574 wx.PD_APP_MODAL: Make the progress dialog modal. If this flag is
575 not given, it is only \"locally\" modal - that is
576 the input to the parent window is disabled,
577 but not to the other ones.
579 wx.PD_AUTO_HIDE: Causes the progress dialog to disappear from screen
580 as soon as the maximum value of the progress
581 meter has been reached.
583 wx.PD_CAN_ABORT: This flag tells the dialog that it should have
584 a \"Cancel\" button which the user may press. If
585 this happens, the next call to Update() will
588 wx.PD_ELAPSED_TIME: This flag tells the dialog that it should show
589 elapsed time (since creating the dialog).
591 wx.PD_ESTIMATED_TIME: This flag tells the dialog that it should show
594 wx.PD_REMAINING_TIME: This flag tells the dialog that it should show
599 class wxProgressDialog : public wxFrame {
601 %pythonAppend wxProgressDialog "self._setOORInfo(self)"
604 wxProgressDialog(const wxString& title,
605 const wxString& message,
607 wxWindow* parent = NULL,
608 int style = wxPD_AUTO_HIDE | wxPD_APP_MODAL ),
609 "Constructor. Creates the dialog, displays it and disables user input for other\n"
610 "windows, or, if wxPD_APP_MODAL flag is not given, for its parent window only.");
613 bool , Update(int value, const wxString& newmsg = wxPyEmptyString),
614 "Updates the dialog, setting the progress bar to the new value and, if given\n"
615 "changes the message above it. Returns true unless the Cancel button has been\n"
617 "If false is returned, the application can either immediately destroy the\n"
618 "dialog or ask the user for the confirmation and if the abort is not confirmed\n"
619 "the dialog may be resumed with Resume function.");
623 "Can be used to continue with the dialog, after the user had chosen to abort.");
627 //---------------------------------------------------------------------------
629 enum wxFindReplaceFlags
631 // downward search/replace selected (otherwise - upwards)
634 // whole word search/replace selected
637 // case sensitive search/replace selected (otherwise - case insensitive)
642 enum wxFindReplaceDialogStyles
644 // replace dialog (otherwise find dialog)
645 wxFR_REPLACEDIALOG = 1,
647 // don't allow changing the search direction
650 // don't allow case sensitive searching
651 wxFR_NOMATCHCASE = 4,
653 // don't allow whole word searching
659 %constant wxEventType wxEVT_COMMAND_FIND;
660 %constant wxEventType wxEVT_COMMAND_FIND_NEXT;
661 %constant wxEventType wxEVT_COMMAND_FIND_REPLACE;
662 %constant wxEventType wxEVT_COMMAND_FIND_REPLACE_ALL;
663 %constant wxEventType wxEVT_COMMAND_FIND_CLOSE;
667 EVT_FIND = wx.PyEventBinder( wxEVT_COMMAND_FIND, 1 )
668 EVT_FIND_NEXT = wx.PyEventBinder( wxEVT_COMMAND_FIND_NEXT, 1 )
669 EVT_FIND_REPLACE = wx.PyEventBinder( wxEVT_COMMAND_FIND_REPLACE, 1 )
670 EVT_FIND_REPLACE_ALL = wx.PyEventBinder( wxEVT_COMMAND_FIND_REPLACE_ALL, 1 )
671 EVT_FIND_CLOSE = wx.PyEventBinder( wxEVT_COMMAND_FIND_CLOSE, 1 )
673 %# For backwards compatibility. Should they be removed?
674 EVT_COMMAND_FIND = EVT_FIND
675 EVT_COMMAND_FIND_NEXT = EVT_FIND_NEXT
676 EVT_COMMAND_FIND_REPLACE = EVT_FIND_REPLACE
677 EVT_COMMAND_FIND_REPLACE_ALL = EVT_FIND_REPLACE_ALL
678 EVT_COMMAND_FIND_CLOSE = EVT_FIND_CLOSE
682 DocStr(wxFindDialogEvent,
683 "Events for the FindReplaceDialog");
685 class wxFindDialogEvent : public wxCommandEvent
688 wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
692 "Get the currently selected flags: this is the combination of\n"
693 "wx.FR_DOWN, wx.FR_WHOLEWORD and wx.FR_MATCHCASE flags.");
696 const wxString& , GetFindString(),
697 "Return the string to find (never empty).");
700 const wxString& , GetReplaceString(),
701 "Return the string to replace the search string with (only\n"
702 "for replace and replace all events).");
705 wxFindReplaceDialog *, GetDialog(),
706 "Return the pointer to the dialog which generated this event.");
709 void , SetFlags(int flags),
713 void , SetFindString(const wxString& str),
717 void , SetReplaceString(const wxString& str),
723 DocStr(wxFindReplaceData,
724 "FindReplaceData holds the data for FindReplaceDialog. It is used to initialize
725 the dialog with the default values and will keep the last values from the
726 dialog when it is closed. It is also updated each time a wxFindDialogEvent is
727 generated so instead of using the wxFindDialogEvent methods you can also
728 directly query this object.
730 Note that all SetXXX() methods may only be called before showing the dialog
731 and calling them has no effect later.
734 wxFR_DOWN: downward search/replace selected (otherwise, upwards)
736 wxFR_WHOLEWORD: whole word search/replace selected
738 wxFR_MATCHCASE: case sensitive search/replace selected (otherwise,
745 class wxFindReplaceData : public wxObject
749 wxFindReplaceData(int flags=0),
750 "Constuctor initializes the flags to default value (0).");
752 ~wxFindReplaceData();
756 const wxString& , GetFindString(),
757 "Get the string to find.");
760 const wxString& , GetReplaceString(),
761 "Get the replacement string.");
765 "Get the combination of flag values.");
768 void , SetFlags(int flags),
769 "Set the flags to use to initialize the controls of the dialog.");
772 void , SetFindString(const wxString& str),
773 "Set the string to find (used as initial value by the dialog).");
776 void , SetReplaceString(const wxString& str),
777 "Set the replacement string (used as initial value by the dialog).");
784 DocStr(wxFindReplaceDialog,
785 "FindReplaceDialog is a standard modeless dialog which is used to allow the
786 user to search for some text (and possibly replace it with something
787 else). The actual searching is supposed to be done in the owner window which
788 is the parent of this dialog. Note that it means that unlike for the other
789 standard dialogs this one must have a parent window. Also note that there is
790 no way to use this dialog in a modal way; it is always, by design and
791 implementation, modeless.");
793 RefDoc(wxFindReplaceDialog, "
795 wx.FR_REPLACEDIALOG: replace dialog (otherwise find dialog)
797 wx.FR_NOUPDOWN: don't allow changing the search direction
799 wx.FR_NOMATCHCASE: don't allow case sensitive searching
801 wx.FR_NOWHOLEWORD: don't allow whole word searching
804 class wxFindReplaceDialog : public wxDialog {
806 %pythonAppend wxFindReplaceDialog "self._setOORInfo(self)"
807 %pythonAppend wxFindReplaceDialog() ""
810 wxFindReplaceDialog(wxWindow *parent,
811 wxFindReplaceData *data,
812 const wxString &title,
814 "Create a FindReplaceDialog. The parent and data parameters must be\n"
815 "non-None. Use Show to display the dialog.");
818 wxFindReplaceDialog(),
819 "Precreate a FindReplaceDialog for 2-phase creation",
820 PreFindReplaceDialog);
824 bool , Create(wxWindow *parent,
825 wxFindReplaceData *data,
826 const wxString &title,
828 "Create the dialog, for 2-phase create.");
832 const wxFindReplaceData *, GetData(),
833 "Get the FindReplaceData object used by this dialog.");
836 void , SetData(wxFindReplaceData *data),
837 "Set the FindReplaceData object used by this dialog.");
841 //---------------------------------------------------------------------------
842 //---------------------------------------------------------------------------