dialog functionsbelow are a number of convenience functions for getting input from the user or displaying messages. note that in these functions the last three parameters are optional. however, it is recommended to pass a parent frame parameter, or (in ms windows or motif) the wrong window frame may be brought to the front when the dialog box is popped up.
::wxaboutbox
::wxaboutboxvoid wxaboutbox(const wxaboutdialoginfo& info) this function shows the standard about dialog containing the information specified in info. if the current platform has a native about dialog which is capable of showing all the fields in info, the native dialog is used, otherwise the function falls back to the generic wxwidgets version of the dialog, i.e. does the same thing as wxgenericaboutbox(). here is an example of how this function may be used: void myframe::showsimpleaboutdialog(wxcommandevent& wxunused(event)) { wxaboutdialoginfo info; info.setname(_("my program")); info.setversion(_("1.2.3 beta")); info.setdescription(_("this program does something great.")); info.setcopyright(_t("(c) 2007 me <my@email.addre.ss>")); wxaboutbox(info); }please see the dialogs sample for more examples of using this function and wxaboutdialoginfo for the description of the information which can be shown in the about dialog. include files <wx/aboutdlg.h>
::wxbeginbusycursorvoid wxbeginbusycursor(wxcursor *cursor = wxhourglass_cursor) changes the cursor to the given cursor for all windows in the application. use wxendbusycursor to revert the cursor back to its previous state. these two calls can be nested, and a counter ensures that only the outer calls take effect. see also wxisbusy, wxbusycursor. include files <wx/utils.h>
::wxbellvoid wxbell() ring the system bell. include files <wx/utils.h>
::wxcreatefiletipproviderwxtipprovider * wxcreatefiletipprovider(const wxstring& filename, size_t currenttip) this function creates a wxtipprovider which may be used with wxshowtip. filename
see also include files <wx/tipdlg.h>
::wxdirselector
wxstring wxdirselector(const wxstring& message = wxdirselectorpromptstr, pops up a directory selector dialog. the arguments have the same meaning as those of wxdirdialog::wxdirdialog(). the message is displayed at the top, and the default_path, if specified, is set as the initial selection. the application must check for an empty return value (if the user pressed cancel). for example:
const wxstring& dir = wxdirselector("choose a folder"); if ( !dir.empty() ) { ... }include files <wx/dirdlg.h>
::wxfileselector
wxstring wxfileselector(const wxstring& message, const wxstring& default_path = "", pops up a file selector box. in windows, this is the common file selector dialog. in x, this is a file selector box with the same functionality. the path and filename are distinct elements of a full file pathname. if path is empty, the current directory will be used. if filename is empty, no default filename will be supplied. the wildcard determines what files are displayed in the file selector, and file extension supplies a type extension for the required filename. flags may be a combination of wxopen, wxsave, wxoverwrite_prompt or wxfile_must_exist. note that wxmultiple can only be used with wxfiledialog and not here as this function only returns a single file name. both the unix and windows versions implement a wildcard filter. typing a filename containing wildcards (*, ?) in the filename text item, and clicking on ok, will result in only those files matching the pattern being displayed. the wildcard may be a specification for multiple types of file with a description for each, such as:
"bmp files (*.bmp)|*.bmp|gif files (*.gif)|*.gif"the application must check for an empty return value (the user pressed cancel). for example:
wxstring filename = wxfileselector("choose a file to open"); if ( !filename.empty() ) { // work with the file ... } //else: cancelled by userinclude files <wx/filedlg.h>
::wxendbusycursorvoid wxendbusycursor() changes the cursor back to the original cursor, for all windows in the application. use with wxbeginbusycursor. see also wxisbusy, wxbusycursor. include files <wx/utils.h>
::wxgenericaboutboxvoid wxgenericaboutbox(const wxaboutdialoginfo& info) this function does the same thing as wxaboutbox except that it always uses the generic wxwidgets version of the dialog instead of the native one. this is mainly useful if you need to customize the dialog by e.g. adding custom controls to it (customizing the native dialog is not currently supported). see the dialogs sample for an example of about dialog customization. see also include files
<wx/aboutdlg.h>
::wxgetcolourfromuserwxcolour wxgetcolourfromuser(wxwindow *parent, const wxcolour& colinit, const wxstring& caption = wxemptystring) shows the colour selection dialog and returns the colour selected by user or invalid colour (use wxcolour:isok to test whether a colour is valid) if the dialog was cancelled. parameters parent
colinit
caption
include files <wx/colordlg.h>
::wxgetfontfromuserwxfont wxgetfontfromuser(wxwindow *parent, const wxfont& fontinit, const wxstring& caption = wxemptystring) shows the font selection dialog and returns the font selected by user or invalid font (use wxfont:isok to test whether a font is valid) if the dialog was cancelled. parameters parent
fontinit
caption
include files <wx/fontdlg.h>
::wxgetmultiplechoices
size_t wxgetmultiplechoices(
size_t wxgetmultiplechoices( pops up a dialog box containing a message, ok/cancel buttons and a multiple-selection listbox. the user may choose an arbitrary (including 0) number of items in the listbox whose indices will be returned in selection array. the initial contents of this array will be used to select the items when the dialog is shown. you may pass the list of strings to choose from either using choices which is an array of n strings for the listbox or by using a single achoices parameter of type wxarraystring. if centre is true, the message text (which may include new line characters) is centred; if false, the message is left-justified. include files <wx/choicdlg.h> wxperl note: in wxperl there is just an array reference in place of n and choices, and no selections parameter; the function returns an array containing the user selections.
::wxgetnumberfromuserlong wxgetnumberfromuser( const wxstring& message, const wxstring& prompt, const wxstring& caption, long value, long min = 0, long max = 100, wxwindow *parent = null, const wxpoint& pos = wxdefaultposition) shows a dialog asking the user for numeric input. the dialogs title is set to caption, it contains a (possibly) multiline message above the single line prompt and the zone for entering the number. the number entered must be in the range min..max (both of which should be positive) and value is the initial value of it. if the user enters an invalid value or cancels the dialog, the function will return -1. dialog is centered on its parent unless an explicit position is given in pos. include files <wx/numdlg.h>
::wxgetpasswordfromuser
wxstring wxgetpasswordfromuser(const wxstring& message, const wxstring& caption = "input text", similar to wxgettextfromuser but the text entered in the dialog is not shown on screen but replaced with stars. this is intended to be used for entering passwords as the function name implies. include files <wx/textdlg.h>
::wxgettextfromuser
wxstring wxgettextfromuser(const wxstring& message, const wxstring& caption = "input text", pop up a dialog box with title set to caption, message, and a default_value. the user may type in text and press ok to return this text, or press cancel to return the empty string. if centre is true, the message text (which may include new line characters) is centred; if false, the message is left-justified. include files <wx/textdlg.h>
::wxgetmultiplechoice
int wxgetmultiplechoice(const wxstring& message, const wxstring& caption, int n, const wxstring& choices[], pops up a dialog box containing a message, ok/cancel buttons and a multiple-selection listbox. the user may choose one or more item(s) and press ok or cancel. the number of initially selected choices, and array of the selected indices, are passed in; this array will contain the user selections on exit, with the function returning the number of selections. selection must be as big as the number of choices, in case all are selected. if cancel is pressed, -1 is returned. choices is an array of n strings for the listbox. if centre is true, the message text (which may include new line characters) is centred; if false, the message is left-justified. include files <wx/choicdlg.h>
::wxgetsinglechoice
wxstring wxgetsinglechoice(const wxstring& message,
wxstring wxgetsinglechoice(const wxstring& message, pops up a dialog box containing a message, ok/cancel buttons and a single-selection listbox. the user may choose an item and press ok to return a string or cancel to return the empty string. use wxgetsinglechoiceindex if empty string is a valid choice and if you want to be able to detect pressing cancel reliably. you may pass the list of strings to choose from either using choices which is an array of n strings for the listbox or by using a single achoices parameter of type wxarraystring. if centre is true, the message text (which may include new line characters) is centred; if false, the message is left-justified. include files <wx/choicdlg.h> wxperl note: in wxperl there is just an array reference in place of n and choices.
::wxgetsinglechoiceindex
int wxgetsinglechoiceindex(const wxstring& message,
int wxgetsinglechoiceindex(const wxstring& message, as wxgetsinglechoice but returns the index representing the selected string. if the user pressed cancel, -1 is returned. include files <wx/choicdlg.h> wxperl note: in wxperl there is just an array reference in place of n and choices.
::wxgetsinglechoicedata
wxstring wxgetsinglechoicedata(const wxstring& message,
wxstring wxgetsinglechoicedata(const wxstring& message, as wxgetsinglechoice but takes an array of client data pointers corresponding to the strings, and returns one of these pointers or null if cancel was pressed. the client_data array must have the same number of elements as choices or achoices! include files <wx/choicdlg.h> wxperl note: in wxperl there is just an array reference in place of n and choices, and the client data array must have the same length as the choices array.
::wxisbusybool wxisbusy() returns true if between two wxbeginbusycursor and wxendbusycursor calls. see also wxbusycursor. include files <wx/utils.h>
::wxmessagebox
int wxmessagebox(const wxstring& message, const wxstring& caption = "message", int style = wxok, general purpose message dialog. style may be a bit list of the following identifiers:
the return value is one of: wxyes, wxno, wxcancel, wxok. for example:
... int answer = wxmessagebox("quit program?", "confirm", wxyes_no | wxcancel, main_frame); if (answer == wxyes) main_frame->close(); ...message may contain newline characters, in which case the message will be split into separate lines, to cater for large messages. include files <wx/msgdlg.h>
::wxshowtipbool wxshowtip(wxwindow *parent, wxtipprovider *tipprovider, bool showatstartup = true) this function shows a "startup tip" to the user. the return value is the state of the 'show tips at startup' checkbox. parent
tipprovider
showatstartup
see also include files <wx/tipdlg.h>
|