Some dialogs have both platform-dependent and platform-independent implementations, so that if underlying windowing systems do not provide the required functionality, the generic classes and functions can stand in. For example, under MS Windows, wxColourDialog uses the standard colour selector. There is also an equivalent called wxGenericColourDialog for other platforms, and a macro defines wxColourDialog to be the same as wxGenericColourDialog on non-MS Windows platforms. However, under MS Windows, the generic dialog can also be used, for testing or other purposes.
The wxColourDialog presents a colour selector to the user, and returns with colour information.
wxColourData data; data.SetChooseFull(true); for (int i = 0; i < 16; i++) { wxColour colour(i*16, i*16, i*16); data.SetCustomColour(i, colour); } wxColourDialog dialog(this, &data); if (dialog.ShowModal() == wxID_OK) { wxColourData retData = dialog.GetColourData(); wxColour col = retData.GetColour(); wxBrush brush(col, wxSOLID); myWindow->SetBackground(brush); myWindow->Clear(); myWindow->Refresh(); }
The wxFontDialog presents a font selector to the user, and returns with font and colour information.
wxFontData data; data.SetInitialFont(canvasFont); data.SetColour(canvasTextColour); wxFontDialog dialog(this, &data); if (dialog.ShowModal() == wxID_OK) { wxFontData retData = dialog.GetFontData(); canvasFont = retData.GetChosenFont(); canvasTextColour = retData.GetColour(); myWindow->Refresh(); }
This class represents the print and print setup common dialogs. You may obtain a wxPrinterDC device context from a successfully dismissed print dialog.
The samples/printing example shows how to use it: see Printing Framework Overview for an excerpt from this example.
Pops up a file selector box. On Windows and GTK 2.4+, this is the common file selector dialog. In X, this is a file selector box with somewhat less functionality. The path and filename are distinct elements of a full file pathname.
If path is "", the current directory will be used. If filename is "", 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 wxFD_OPEN, wxFD_SAVE, wxFD_OVERWRITE_PROMPT, wxFD_HIDE_READONLY, wxFD_FILE_MUST_EXIST, wxFD_MULTIPLE, wxFD_CHANGE_DIR or 0.
Both the X 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. In the X version, supplying no default name will result in the wildcard filter being inserted in the filename text item; the filter is ignored if a default name is supplied.
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"
This dialog shows a directory selector dialog, allowing the user to select a single directory.
This is a dialog with a text entry field. The value that the user entered is obtained using wxTextEntryDialog::GetValue().
This is a dialog with a password entry field. The value that the user entered is obtained using wxTextEntryDialog::GetValue().
This dialog shows a message, plus buttons that can be chosen from OK, Cancel, Yes, and No. Under Windows, an optional icon can be shown, such as an exclamation mark or question mark.
The return value of wxMessageDialog::ShowModal() indicates which button the user pressed.
This dialog shows a list of choices, plus OK and (optionally) Cancel. The user can select one of them. The selection can be obtained from the dialog as an index, a string or client data.
This dialog shows a list of choices, plus OK and (optionally) Cancel. The user can select one or more of them.
![]() |
[ top ] |