📄 tcommdlg.tex
字号:
\section{Common dialogs overview}\label{commondialogsoverview}Classes: \helpref{wxColourDialog}{wxcolourdialog}, \helpref{wxFontDialog}{wxfontdialog},\rtfsp\helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxFileDialog}{wxfiledialog},\rtfsp\helpref{wxDirDialog}{wxdirdialog}, \helpref{wxTextEntryDialog}{wxtextentrydialog},\rtfsp\helpref{wxPasswordEntryDialog}{wxpasswordentrydialog},\rtfsp\helpref{wxMessageDialog}{wxmessagedialog}, \helpref{wxSingleChoiceDialog}{wxsinglechoicedialog},\rtfsp\helpref{wxMultiChoiceDialog}{wxmultichoicedialog}Common dialog classes and functions encapsulate commonly-needed dialog box requirements.They are all `modal', grabbing the flow of control until the user dismisses the dialog,to make them easy to use within an application.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, wxColourDialoguses the standard colour selector. There is also an equivalent called wxGenericColourDialogfor other platforms, and a macro defines wxColourDialog to be the same as wxGenericColourDialogon non-MS Windows platforms. However, under MS Windows, the generic dialog can also beused, for testing or other purposes.\subsection{wxColourDialog overview}\label{wxcolourdialogoverview}Classes: \helpref{wxColourDialog}{wxcolourdialog}, \helpref{wxColourData}{wxcolourdata}The wxColourDialog presents a colour selector to the user, and returnswith colour information.{\bf The MS Windows colour selector}Under Windows, the native colour selector common dialog is used. Thispresents a dialog box with three main regions: at the top left, apalette of 48 commonly-used colours is shown. Under this, there is apalette of 16 `custom colours' which can be set by the application ifdesired. Additionally, the user may open up the dialog box to showa right-hand panel containing controls to select a precise colour, and addit to the custom colour palette.{\bf The generic colour selector}Under non-MS Windows platforms, the colour selector is a simulation ofmost of the features of the MS Windows selector. Two palettes of 48standard and 16 custom colours are presented, with the right-hand areacontaining three sliders for the user to select a colour from red,green and blue components. This colour may be added to the custom colourpalette, and will replace either the currently selected custom colour,or the first one in the palette if none is selected. The RGB colour slidersare not optional in the generic colour selector. The generic colourselector is also available under MS Windows; use the namewxGenericColourDialog.{\bf Example}In the samples/dialogs directory, there is an example of usingthe wxColourDialog class. Here is an excerpt, whichsets various parameters of a wxColourData object, includinga grey scale for the custom colours. If the user did not cancelthe dialog, the application retrieves the selected colour anduses it to set the background of a window.\begin{verbatim} 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(); }\end{verbatim}\subsection{wxFontDialog overview}\label{wxfontdialogoverview}Classes: \helpref{wxFontDialog}{wxfontdialog}, \helpref{wxFontData}{wxfontdata}The wxFontDialog presents a font selector to the user, and returnswith font and colour information.{\bf The MS Windows font selector}Under Windows, the native font selector common dialog is used. Thispresents a dialog box with controls for font name, point size, style, weight,underlining, strikeout and text foreground colour. A sample of thefont is shown on a white area of the dialog box. Note thatin the translation from full MS Windows fonts to wxWidgets fontconventions, strikeout is ignored and a font family (such asSwiss or Modern) is deduced from the actual font name (such as Arialor Courier).{\bf The generic font selector}Under non-MS Windows platforms, the font selector is simpler.Controls for font family, point size, style, weight,underlining and text foreground colour are provided, anda sample is shown upon a white background. The generic font selectoris also available under MS Windows; use the name wxGenericFontDialog.{\bf Example}In the samples/dialogs directory, there is an example of usingthe wxFontDialog class. The application uses the returned fontand colour for drawing text on a canvas. Here is an excerpt:\begin{verbatim} 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(); }\end{verbatim}\subsection{wxPrintDialog overview}\label{wxprintdialogoverview}Classes: \helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxPrintData}{wxprintdata}This class represents the print and print setup common dialogs.You may obtain a \helpref{wxPrinterDC}{wxprinterdc} device context froma successfully dismissed print dialog.The samples/printing example shows how to use it: see \helpref{Printing overview}{printingoverview} foran excerpt from this example.\subsection{wxFileDialog overview}\label{wxfiledialogoverview}Classes: \helpref{wxFileDialog}{wxfiledialog}Pops up a file selector box. In Windows and GTK2.4+, this is the commonfile selector dialog. In X, this is a file selector box with somewhat lessfunctionality. 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 filesare displayed in the file selector, and file extension supplies a typeextension for the required filename. Flags may be a combination of wxOPEN,wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, wxFILE\_MUST\_EXIST,wxMULTIPLE, wxCHANGE\_DIR or 0.Both the X and Windows versions implement a wildcard filter. Typing afilename containing wildcards (*, ?) in the filename text item, andclicking on Ok, will result in only those files matching the pattern beingdisplayed. In the X version, supplying no default name will result in thewildcard filter being inserted in the filename text item; the filter isignored if a default name is supplied.The wildcard may be a specification for multipletypes of file with a description for each, such as:\begin{verbatim} "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"\end{verbatim}\subsection{wxDirDialog overview}\label{wxdirdialogoverview}Classes: \helpref{wxDirDialog}{wxdirdialog}This dialog shows a directory selector dialog, allowing the user to select a singledirectory.\subsection{wxTextEntryDialog overview}\label{wxtextentrydialogoverview}Classes: \helpref{wxTextEntryDialog}{wxtextentrydialog}This is a dialog with a text entry field. The value that the userentered is obtained using \helpref{wxTextEntryDialog::GetValue}{wxtextentrydialoggetvalue}.\subsection{wxPasswordEntryDialog overview}\label{wxpasswordentrydialogoverview}Classes: \helpref{wxPasswordEntryDialog}{wxpasswordentrydialog}This is a dialog with a password entry field. The value that the userentered is obtained using \helpref{wxTextEntryDialog::GetValue}{wxtextentrydialoggetvalue}.\subsection{wxMessageDialog overview}\label{wxmessagedialogoverview}Classes: \helpref{wxMessageDialog}{wxmessagedialog}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 \helpref{wxMessageDialog::ShowModal}{wxmessagedialogshowmodal} indicateswhich button the user pressed.\subsection{wxSingleChoiceDialog overview}\label{wxsinglechoicedialogoverview}Classes: \helpref{wxSingleChoiceDialog}{wxsinglechoicedialog}This dialog shows a list of choices, plus OK and (optionally) Cancel. The user canselect one of them. The selection can be obtained from the dialog as an index,a string or client data.\subsection{wxMultiChoiceDialog overview}\label{wxmultichoicedialogoverview}Classes: \helpref{wxMultiChoiceDialog}{wxmultichoicedialog}This dialog shows a list of choices, plus OK and (optionally) Cancel. The user canselect one or more of them.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -