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 the colour
31 chooser dialog, used to transfer settings and results to and from the
32 `wx.ColourDialog`.", "");
34 class wxColourData : public wxObject {
38 "Constructor, sets default values.", "");
44 bool , GetChooseFull(),
45 "Under Windows, determines whether the Windows colour dialog will
46 display the full dialog with custom colour selection controls. Has no
47 meaning under other platforms. The default value is true.", "");
50 wxColour , GetColour(),
51 "Gets the colour (pre)selected by the dialog.", "");
54 wxColour , GetCustomColour(int i),
55 "Gets the i'th custom colour associated with the colour dialog. i
56 should be an integer between 0 and 15. The default custom colours are
60 void , SetChooseFull(int flag),
61 "Under Windows, tells the Windows colour dialog to display the full
62 dialog with custom colour selection controls. Under other platforms,
63 has no effect. The default value is true.", "");
66 void , SetColour(const wxColour& colour),
67 "Sets the default colour for the colour dialog. The default colour is
71 void , SetCustomColour(int i, const wxColour& colour),
72 "Sets the i'th custom colour for the colour dialog. i should be an
73 integer between 0 and 15. The default custom colours are all white.", "");
80 DocStr(wxColourDialog,
81 "This class represents the colour chooser dialog.", "");
83 class wxColourDialog : public wxDialog {
85 %pythonAppend wxColourDialog "self._setOORInfo(self)"
88 wxColourDialog(wxWindow* parent, wxColourData* data = NULL),
89 "Constructor. Pass a parent window, and optionally a `wx.ColourData`,
90 which will be copied to the colour dialog's internal ColourData
94 wxColourData& , GetColourData(),
95 "Returns a reference to the `wx.ColourData` used by the dialog.", "");
99 //--------------------------------------------------------------------------------
103 "wx.DirDialog allows the user to select a directory by browising the
108 ==================== ==========================================
109 wx.DD_NEW_DIR_BUTTON Add 'Create new directory' button and allow
110 directory names to be editable. On Windows
111 the new directory button is only available
112 with recent versions of the common dialogs.
113 ==================== ==========================================
116 class wxDirDialog : public wxDialog {
118 %pythonAppend wxDirDialog "self._setOORInfo(self)"
121 wxDirDialog(wxWindow* parent,
122 const wxString& message = wxPyDirSelectorPromptStr,
123 const wxString& defaultPath = wxPyEmptyString,
125 const wxPoint& pos = wxDefaultPosition,
126 const wxSize& size = wxDefaultSize,
127 const wxString& name = wxPyDirDialogNameStr),
128 "Constructor. Use ShowModal method to show the dialog.", "");
132 wxString , GetPath(),
133 "Returns the default or user-selected path.", "");
136 wxString , GetMessage(),
137 "Returns the message that will be displayed on the dialog.", "");
141 "Returns the dialog style.", "");
144 void , SetMessage(const wxString& message),
145 "Sets the message that will be displayed on the dialog.", "");
148 void , SetPath(const wxString& path),
149 "Sets the default path.", "");
154 //---------------------------------------------------------------------------
157 "wx.FileDialog allows the user to select one or more files from the
160 In Windows, this is the common file selector dialog. On X based
161 platforms a generic alternative is used. The path and filename are
162 distinct elements of a full file pathname. If path is \"\", the
163 current directory will be used. If filename is \"\", no default
164 filename will be supplied. The wildcard determines what files are
165 displayed in the file selector, and file extension supplies a type
166 extension for the required filename.
168 Both the X and Windows versions implement a wildcard filter. Typing a
169 filename containing wildcards (\*, ?) in the filename text item, and
170 clicking on Ok, will result in only those files matching the pattern
171 being displayed. The wildcard may be a specification for multiple
172 types of file with a description for each, such as::
174 \"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif\"
179 =================== ==========================================
180 wx.OPEN This is an open dialog.
182 wx.SAVE This is a save dialog.
184 wx.HIDE_READONLY For open dialog only: hide the checkbox
185 allowing to open the file in read-only mode.
187 wx.OVERWRITE_PROMPT For save dialog only: prompt for a confirmation
188 if a file will be overwritten.
190 wx.MULTIPLE For open dialog only: allows selecting multiple
193 wx.CHANGE_DIR Change the current working directory to the
194 directory where the file(s) chosen by the user
196 =================== ==========================================
201 class wxFileDialog : public wxDialog {
203 %pythonAppend wxFileDialog "self._setOORInfo(self)"
206 wxFileDialog(wxWindow* parent,
207 const wxString& message = wxPyFileSelectorPromptStr,
208 const wxString& defaultDir = wxPyEmptyString,
209 const wxString& defaultFile = wxPyEmptyString,
210 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
212 const wxPoint& pos = wxDefaultPosition),
213 "Constructor. Use ShowModal method to show the dialog.", "");
217 void , SetMessage(const wxString& message),
218 "Sets the message that will be displayed on the dialog.", "");
221 void , SetPath(const wxString& path),
222 "Sets the path (the combined directory and filename that will be
223 returned when the dialog is dismissed).", "");
226 void , SetDirectory(const wxString& dir),
227 "Sets the default directory.", "");
230 void , SetFilename(const wxString& name),
231 "Sets the default filename.", "");
234 void , SetWildcard(const wxString& wildCard),
235 "Sets the wildcard, which can contain multiple file types, for
238 \"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif\"
242 void , SetStyle(long style),
243 "Sets the dialog style.", "");
246 void , SetFilterIndex(int filterIndex),
247 "Sets the default filter index, starting from zero.", "");
251 wxString , GetMessage() const,
252 "Returns the message that will be displayed on the dialog.", "");
255 wxString , GetPath() const,
256 "Returns the full path (directory and filename) of the selected file.", "");
259 wxString , GetDirectory() const,
260 "Returns the default directory.", "");
263 wxString , GetFilename() const,
264 "Returns the default filename.", "");
267 wxString , GetWildcard() const,
268 "Returns the file dialog wildcard.", "");
271 long , GetStyle() const,
272 "Returns the dialog style.", "");
275 int , GetFilterIndex() const,
276 "Returns the index into the list of filters supplied, optionally, in
277 the wildcard parameter. Before the dialog is shown, this is the index
278 which will be used when the dialog is first displayed. After the
279 dialog is shown, this is the index selected by the user.", "");
283 "Returns a list of filenames chosen in the dialog. This function
284 should only be used with the dialogs which have wx.MULTIPLE style, use
285 GetFilename for the others.", "");
288 "Fills the array paths with the full paths of the files chosen. This
289 function should only be used with the dialogs which have wx.MULTIPLE
290 style, use GetPath for the others.", "");
293 PyObject* GetFilenames() {
295 self->GetFilenames(arr);
296 return wxArrayString2PyList_helper(arr);
299 PyObject* GetPaths() {
302 return wxArrayString2PyList_helper(arr);
307 // // Utility functions
309 // // Parses the wildCard, returning the number of filters.
310 // // Returns 0 if none or if there's a problem,
311 // // The arrays will contain an equal number of items found before the error.
312 // // wildCard is in the form:
313 // // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
314 // static int ParseWildcard(const wxString& wildCard,
315 // wxArrayString& descriptions,
316 // wxArrayString& filters);
318 // // Append first extension to filePath from a ';' separated extensionList
319 // // if filePath = "path/foo.bar" just return it as is
320 // // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
321 // // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
322 // static wxString AppendExtension(const wxString &filePath,
323 // const wxString &extensionList);
329 //---------------------------------------------------------------------------
331 enum { wxCHOICEDLG_STYLE };
334 DocStr(wxMultiChoiceDialog,
335 "A simple dialog with a multi selection listbox.", "");
337 class wxMultiChoiceDialog : public wxDialog
340 %pythonAppend wxMultiChoiceDialog "self._setOORInfo(self)"
343 wxMultiChoiceDialog(wxWindow *parent,
344 const wxString& message,
345 const wxString& caption,
346 int choices=0, wxString* choices_array,
347 long style = wxCHOICEDLG_STYLE,
348 const wxPoint& pos = wxDefaultPosition),
349 "__init__(Window parent, String message, String caption,
350 List choices=[], long style=CHOICEDLG_STYLE,
351 Point pos=DefaultPosition) -> MultiChoiceDialog",
352 "Constructor. Use ShowModal method to show the dialog.", "");
356 void, SetSelections(const wxArrayInt& selections),
357 "SetSelections(List selections)",
358 "Specify the items in the list that should be selected, using a list of
361 DocAStr(GetSelections,
362 "GetSelections() -> [selections]",
363 "Returns a list of integers representing the items that are selected.", "");
365 PyObject* GetSelections() {
366 return wxArrayInt2PyList_helper(self->GetSelections());
372 //---------------------------------------------------------------------------
374 DocStr(wxSingleChoiceDialog,
375 "A simple dialog with a single selection listbox.", "");
377 class wxSingleChoiceDialog : public wxDialog {
379 %pythonAppend wxSingleChoiceDialog "self._setOORInfo(self)"
381 DocAStr(wxSingleChoiceDialog,
382 "__init__(Window parent, String message, String caption,
383 List choices=[], long style=CHOICEDLG_STYLE,
384 Point pos=DefaultPosition) -> SingleChoiceDialog",
385 "Constructor. Use ShowModal method to show the dialog.", "");
388 // TODO: ignoring clientData for now... FIX THIS
389 // SWIG is messing up the &/*'s for some reason.
390 wxSingleChoiceDialog(wxWindow* parent,
391 const wxString& message,
392 const wxString& caption,
393 int choices, wxString* choices_array,
394 //char** clientData = NULL,
395 long style = wxCHOICEDLG_STYLE,
396 const wxPoint& pos = wxDefaultPosition) {
397 return new wxSingleChoiceDialog(parent, message, caption,
398 choices, choices_array, NULL, style, pos);
403 int , GetSelection(),
404 "Get the index of teh currently selected item.", "");
407 wxString , GetStringSelection(),
408 "Returns the string value of the currently selected item", "");
411 void , SetSelection(int sel),
412 "Set the current selected item to sel", "");
416 //---------------------------------------------------------------------------
418 DocStr(wxTextEntryDialog,
419 "A dialog with text control, [ok] and [cancel] buttons", "");
421 class wxTextEntryDialog : public wxDialog {
423 %pythonAppend wxTextEntryDialog "self._setOORInfo(self)"
426 wxTextEntryDialog(wxWindow* parent,
427 const wxString& message,
428 const wxString& caption = wxPyGetTextFromUserPromptStr,
429 const wxString& defaultValue = wxPyEmptyString,
430 long style = wxOK | wxCANCEL | wxCENTRE,
431 const wxPoint& pos = wxDefaultPosition),
432 "Constructor. Use ShowModal method to show the dialog.", "");
435 wxString , GetValue(),
436 "Returns the text that the user has entered if the user has pressed OK,
437 or the original value if the user has pressed Cancel.", "");
440 void , SetValue(const wxString& value),
441 "Sets the default text value.", "");
444 //---------------------------------------------------------------------------
448 "This class holds a variety of information related to font dialogs and
449 is used to transfer settings to and results from a `wx.FontDialog`.", "");
452 class wxFontData : public wxObject {
458 void , EnableEffects(bool enable),
459 "Enables or disables 'effects' under MS Windows only. This refers to
460 the controls for manipulating colour, strikeout and underline
461 properties. The default value is true.", "");
464 bool , GetAllowSymbols(),
465 "Under MS Windows, returns a flag determining whether symbol fonts can
466 be selected. Has no effect on other platforms. The default value is
470 wxColour , GetColour(),
471 "Gets the colour associated with the font dialog. The default value is
475 wxFont , GetChosenFont(),
476 "Gets the font chosen by the user.", "");
479 bool , GetEnableEffects(),
480 "Determines whether 'effects' are enabled under Windows.", "");
483 wxFont , GetInitialFont(),
484 "Gets the font that will be initially used by the font dialog. This
485 should have previously been set by the application.", "");
488 bool , GetShowHelp(),
489 "Returns true if the Help button will be shown (Windows only). The
490 default value is false.", "");
493 void , SetAllowSymbols(bool allowSymbols),
494 "Under MS Windows, determines whether symbol fonts can be selected. Has
495 no effect on other platforms. The default value is true.", "");
498 void , SetChosenFont(const wxFont& font),
499 "Sets the font that will be returned to the user (normally for internal
503 void , SetColour(const wxColour& colour),
504 "Sets the colour that will be used for the font foreground colour. The
505 default colour is black.", "");
508 void , SetInitialFont(const wxFont& font),
509 "Sets the font that will be initially used by the font dialog.", "");
512 void , SetRange(int min, int max),
513 "Sets the valid range for the font point size (Windows only). The
514 default is 0, 0 (unrestricted range).", "");
517 void , SetShowHelp(bool showHelp),
518 "Determines whether the Help button will be displayed in the font
519 dialog (Windows only). The default value is false.", "");
526 "wx.FontDialog allows the user to select a system font and its attributes.
531 class wxFontDialog : public wxDialog {
533 %pythonAppend wxFontDialog "self._setOORInfo(self)"
536 "Constructor. Pass a parent window and the `wx.FontData` object to be
537 used to initialize the dialog controls. Call `ShowModal` to display
538 the dialog. If ShowModal returns ``wx.ID_OK`` then you can fetch the
539 results with via the `wx.FontData` returned by `GetFontData`.", "");
540 wxFontDialog(wxWindow* parent, const wxFontData& data);
544 wxFontData& , GetFontData(),
545 "Returns a reference to the internal `wx.FontData` used by the
546 wx.FontDialog.", "");
550 //---------------------------------------------------------------------------
553 DocStr(wxMessageDialog,
554 "This class provides a simple dialog that shows a single or multi-line
555 message, with a choice of OK, Yes, No and/or Cancel buttons.", "
559 =================== =============================================
560 wx.OK Show an OK button.
561 wx.CANCEL Show a Cancel button.
562 wx.YES_NO Show Yes and No buttons.
563 wx.YES_DEFAULT Used with wxYES_NO, makes Yes button the
564 default - which is the default behaviour.
565 wx.NO_DEFAULT Used with wxYES_NO, makes No button the default.
566 wx.ICON_EXCLAMATION Shows an exclamation mark icon.
567 wx.ICON_HAND Shows an error icon.
568 wx.ICON_ERROR Shows an error icon - the same as wxICON_HAND.
569 wx.ICON_QUESTION Shows a question mark icon.
570 wx.ICON_INFORMATION Shows an information (i) icon.
571 wx.STAY_ON_TOP The message box stays on top of all other
572 window, even those of the other applications
574 =================== =============================================
578 class wxMessageDialog : public wxDialog {
580 %pythonAppend wxMessageDialog "self._setOORInfo(self)"
583 wxMessageDialog(wxWindow* parent,
584 const wxString& message,
585 const wxString& caption = wxPyMessageBoxCaptionStr,
586 long style = wxOK | wxCANCEL | wxCENTRE,
587 const wxPoint& pos = wxDefaultPosition),
588 "Constructor, use `ShowModal` to display the dialog.", "");
592 //---------------------------------------------------------------------------
595 DocStr(wxProgressDialog,
596 "A dialog that shows a short message and a progress bar. Optionally, it
597 can display an ABORT button.", "
601 ==================== =============================================
602 wx.PD_APP_MODAL Make the progress dialog modal. If this flag is
603 not given, it is only \"locally\" modal -
604 that is the input to the parent window is
605 disabled, but not to the other ones.
607 wx.PD_AUTO_HIDE Causes the progress dialog to disappear from
608 screen as soon as the maximum value of the
609 progress meter has been reached.
611 wx.PD_CAN_ABORT This flag tells the dialog that it should have
612 a \"Cancel\" button which the user may press. If
613 this happens, the next call to Update() will
616 wx.PD_ELAPSED_TIME This flag tells the dialog that it should show
617 elapsed time (since creating the dialog).
619 wx.PD_ESTIMATED_TIME This flag tells the dialog that it should show
622 wx.PD_REMAINING_TIME This flag tells the dialog that it should show
624 ==================== =============================================
628 class wxProgressDialog : public wxFrame {
630 %pythonAppend wxProgressDialog "self._setOORInfo(self)"
633 wxProgressDialog(const wxString& title,
634 const wxString& message,
636 wxWindow* parent = NULL,
637 int style = wxPD_AUTO_HIDE | wxPD_APP_MODAL ),
638 "Constructor. Creates the dialog, displays it and disables user input
639 for other windows, or, if wx.PD_APP_MODAL flag is not given, for its
640 parent window only.", "");
643 virtual bool , Update(int value, const wxString& newmsg = wxPyEmptyString),
644 "Updates the dialog, setting the progress bar to the new value and, if
645 given changes the message above it. Returns true unless the Cancel
646 button has been pressed.
648 If false is returned, the application can either immediately destroy
649 the dialog or ask the user for the confirmation and if the abort is
650 not confirmed the dialog may be resumed with Resume function.", "");
654 "Can be used to continue with the dialog, after the user had chosen to
659 //---------------------------------------------------------------------------
661 enum wxFindReplaceFlags
663 // downward search/replace selected (otherwise - upwards)
666 // whole word search/replace selected
669 // case sensitive search/replace selected (otherwise - case insensitive)
674 enum wxFindReplaceDialogStyles
676 // replace dialog (otherwise find dialog)
677 wxFR_REPLACEDIALOG = 1,
679 // don't allow changing the search direction
682 // don't allow case sensitive searching
683 wxFR_NOMATCHCASE = 4,
685 // don't allow whole word searching
691 %constant wxEventType wxEVT_COMMAND_FIND;
692 %constant wxEventType wxEVT_COMMAND_FIND_NEXT;
693 %constant wxEventType wxEVT_COMMAND_FIND_REPLACE;
694 %constant wxEventType wxEVT_COMMAND_FIND_REPLACE_ALL;
695 %constant wxEventType wxEVT_COMMAND_FIND_CLOSE;
699 EVT_FIND = wx.PyEventBinder( wxEVT_COMMAND_FIND, 1 )
700 EVT_FIND_NEXT = wx.PyEventBinder( wxEVT_COMMAND_FIND_NEXT, 1 )
701 EVT_FIND_REPLACE = wx.PyEventBinder( wxEVT_COMMAND_FIND_REPLACE, 1 )
702 EVT_FIND_REPLACE_ALL = wx.PyEventBinder( wxEVT_COMMAND_FIND_REPLACE_ALL, 1 )
703 EVT_FIND_CLOSE = wx.PyEventBinder( wxEVT_COMMAND_FIND_CLOSE, 1 )
705 %# For backwards compatibility. Should they be removed?
706 EVT_COMMAND_FIND = EVT_FIND
707 EVT_COMMAND_FIND_NEXT = EVT_FIND_NEXT
708 EVT_COMMAND_FIND_REPLACE = EVT_FIND_REPLACE
709 EVT_COMMAND_FIND_REPLACE_ALL = EVT_FIND_REPLACE_ALL
710 EVT_COMMAND_FIND_CLOSE = EVT_FIND_CLOSE
714 DocStr(wxFindDialogEvent,
715 "Events for the FindReplaceDialog", "");
717 class wxFindDialogEvent : public wxCommandEvent
720 wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
724 "Get the currently selected flags: this is the combination of
725 wx.FR_DOWN, wx.FR_WHOLEWORD and wx.FR_MATCHCASE flags.", "");
728 const wxString& , GetFindString(),
729 "Return the string to find (never empty).", "");
732 const wxString& , GetReplaceString(),
733 "Return the string to replace the search string with (only for replace
734 and replace all events).", "");
737 wxFindReplaceDialog *, GetDialog(),
738 "Return the pointer to the dialog which generated this event.", "");
741 void , SetFlags(int flags),
745 void , SetFindString(const wxString& str),
749 void , SetReplaceString(const wxString& str),
755 DocStr(wxFindReplaceData,
756 "wx.FindReplaceData holds the data for wx.FindReplaceDialog. It is used
757 to initialize the dialog with the default values and will keep the
758 last values from the dialog when it is closed. It is also updated each
759 time a `wx.FindDialogEvent` is generated so instead of using the
760 `wx.FindDialogEvent` methods you can also directly query this object.
762 Note that all SetXXX() methods may only be called before showing the
763 dialog and calling them has no effect later.", "
767 ================ ===============================================
768 wx.FR_DOWN Downward search/replace selected (otherwise,
771 wx.FR_WHOLEWORD Whole word search/replace selected
773 wx.FR_MATCHCASE Case sensitive search/replace selected
774 (otherwise, case insensitive)
775 ================ ===============================================
781 class wxFindReplaceData : public wxObject
785 wxFindReplaceData(int flags=0),
786 "Constuctor initializes the flags to default value (0).", "");
788 ~wxFindReplaceData();
792 const wxString& , GetFindString(),
793 "Get the string to find.", "");
796 const wxString& , GetReplaceString(),
797 "Get the replacement string.", "");
801 "Get the combination of flag values.", "");
804 void , SetFlags(int flags),
805 "Set the flags to use to initialize the controls of the dialog.", "");
808 void , SetFindString(const wxString& str),
809 "Set the string to find (used as initial value by the dialog).", "");
812 void , SetReplaceString(const wxString& str),
813 "Set the replacement string (used as initial value by the dialog).", "");
820 DocStr(wxFindReplaceDialog,
821 "wx.FindReplaceDialog is a standard modeless dialog which is used to
822 allow the user to search for some text (and possibly replace it with
823 something else). The actual searching is supposed to be done in the
824 owner window which is the parent of this dialog. Note that it means
825 that unlike for the other standard dialogs this one must have a parent
826 window. Also note that there is no way to use this dialog in a modal
827 way; it is always, by design and implementation, modeless.", "
833 ===================== =========================================
834 wx.FR_REPLACEDIALOG replace dialog (otherwise find dialog)
836 wx.FR_NOUPDOWN don't allow changing the search direction
838 wx.FR_NOMATCHCASE don't allow case sensitive searching
840 wx.FR_NOWHOLEWORD don't allow whole word searching
841 ===================== =========================================
844 class wxFindReplaceDialog : public wxDialog {
846 %pythonAppend wxFindReplaceDialog "self._setOORInfo(self)"
847 %pythonAppend wxFindReplaceDialog() ""
850 wxFindReplaceDialog(wxWindow *parent,
851 wxFindReplaceData *data,
852 const wxString &title,
854 "Create a FindReplaceDialog. The parent and data parameters must be
855 non-None. Use Show to display the dialog.", "");
858 wxFindReplaceDialog(),
859 "Precreate a FindReplaceDialog for 2-phase creation", "",
860 PreFindReplaceDialog);
864 bool , Create(wxWindow *parent, wxFindReplaceData *data,
865 const wxString &title, int style = 0),
866 "Create the dialog, for 2-phase create.", "");
870 const wxFindReplaceData *, GetData(),
871 "Get the FindReplaceData object used by this dialog.", "");
874 void , SetData(wxFindReplaceData *data),
875 "Set the FindReplaceData object used by this dialog.", "");
879 //---------------------------------------------------------------------------
880 //---------------------------------------------------------------------------