commondialogs.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: commondialogs.h
  3. // Purpose: topic overview
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @page overview_cmndlg Common Dialogs
  9. @tableofcontents
  10. Common dialog classes and functions encapsulate commonly-needed dialog box
  11. requirements. They are all 'modal', grabbing the flow of control until the user
  12. dismisses the dialog, to make them easy to use within an application.
  13. Some dialogs have both platform-dependent and platform-independent
  14. implementations, so that if underlying windowing systems do not provide the
  15. required functionality, the generic classes and functions can stand in. For
  16. example, under MS Windows, wxColourDialog uses the standard colour selector.
  17. There is also an equivalent called wxGenericColourDialog for other platforms,
  18. and a macro defines wxColourDialog to be the same as wxGenericColourDialog on
  19. non-MS Windows platforms. However, under MS Windows, the generic dialog can
  20. also be used, for testing or other purposes.
  21. @see @ref group_class_cmndlg
  22. @section overview_cmndlg_colour wxColourDialog Overview
  23. Classes: wxColourDialog, wxColourData
  24. The wxColourDialog presents a colour selector to the user, and returns with
  25. colour information.
  26. @subsection overview_cmndlg_colour_msw The MS Windows Colour Selector
  27. Under Windows, the native colour selector common dialog is used. This presents
  28. a dialog box with three main regions: at the top left, a palette of 48
  29. commonly-used colours is shown. Under this, there is a palette of 16
  30. 'custom colours' which can be set by the application if desired. Additionally,
  31. the user may open up the dialog box to show a right-hand panel containing
  32. controls to select a precise colour, and add it to the custom colour palette.
  33. @subsection overview_cmndlg_colour_generic The Generic Colour Selector
  34. Under non-MS Windows platforms, the colour selector is a simulation of most of
  35. the features of the MS Windows selector. Two palettes of 48 standard and 16
  36. custom colours are presented, with the right-hand area containing three sliders
  37. for the user to select a colour from red, green and blue components. This
  38. colour may be added to the custom colour palette, and will replace either the
  39. currently selected custom colour, or the first one in the palette if none is
  40. selected. The RGB colour sliders are not optional in the generic colour
  41. selector. The generic colour selector is also available under MS Windows; use
  42. the name wxGenericColourDialog.
  43. @subsection overview_cmndlg_colour_example Example
  44. In the samples/dialogs directory, there is an example of using the
  45. wxColourDialog class. Here is an excerpt, which sets various parameters of a
  46. wxColourData object, including a grey scale for the custom colours. If the user
  47. did not cancel the dialog, the application retrieves the selected colour and
  48. uses it to set the background of a window.
  49. @code
  50. wxColourData data;
  51. data.SetChooseFull(true);
  52. for (int i = 0; i < 16; i++)
  53. {
  54. wxColour colour(i*16, i*16, i*16);
  55. data.SetCustomColour(i, colour);
  56. }
  57. wxColourDialog dialog(this, &data);
  58. if (dialog.ShowModal() == wxID_OK)
  59. {
  60. wxColourData retData = dialog.GetColourData();
  61. wxColour col = retData.GetColour();
  62. wxBrush brush(col, wxSOLID);
  63. myWindow->SetBackground(brush);
  64. myWindow->Clear();
  65. myWindow->Refresh();
  66. }
  67. @endcode
  68. @section overview_cmndlg_font wxFontDialog Overview
  69. Classes: wxFontDialog, wxFontData
  70. The wxFontDialog presents a font selector to the user, and returns with font
  71. and colour information.
  72. @subsection overview_cmndlg_font_msw The MS Windows Font Selector
  73. Under Windows, the native font selector common dialog is used. This presents a
  74. dialog box with controls for font name, point size, style, weight, underlining,
  75. strikeout and text foreground colour. A sample of the font is shown on a white
  76. area of the dialog box. Note that in the translation from full MS Windows fonts
  77. to wxWidgets font conventions, strikeout is ignored and a font family (such as
  78. Swiss or Modern) is deduced from the actual font name (such as Arial or
  79. Courier).
  80. @subsection overview_cmndlg_font_generic The Generic Font Selector
  81. Under non-MS Windows platforms, the font selector is simpler. Controls for font
  82. family, point size, style, weight, underlining and text foreground colour are
  83. provided, and a sample is shown upon a white background. The generic font
  84. selector is also available under MS Windows; use the name wxGenericFontDialog.
  85. @subsection overview_cmndlg_font_example Example
  86. In the samples/dialogs directory, there is an example of using the wxFontDialog
  87. class. The application uses the returned font and colour for drawing text on a
  88. canvas. Here is an excerpt:
  89. @code
  90. wxFontData data;
  91. data.SetInitialFont(canvasFont);
  92. data.SetColour(canvasTextColour);
  93. wxFontDialog dialog(this, &data);
  94. if (dialog.ShowModal() == wxID_OK)
  95. {
  96. wxFontData retData = dialog.GetFontData();
  97. canvasFont = retData.GetChosenFont();
  98. canvasTextColour = retData.GetColour();
  99. myWindow->Refresh();
  100. }
  101. @endcode
  102. @section overview_cmndlg_print wxPrintDialog Overview
  103. Classes: wxPrintDialog, wxPrintData
  104. This class represents the print and print setup common dialogs. You may obtain
  105. a wxPrinterDC device context from a successfully dismissed print dialog.
  106. The samples/printing example shows how to use it: see @ref overview_printing
  107. for an excerpt from this example.
  108. @section overview_cmndlg_file wxFileDialog Overview
  109. Classes: wxFileDialog
  110. Pops up a file selector box. On Windows and GTK 2.4+, this is the common file
  111. selector dialog. In X, this is a file selector box with somewhat less
  112. functionality. The path and filename are distinct elements of a full file
  113. pathname.
  114. If path is "", the current directory will be used. If filename is "", no
  115. default filename will be supplied. The wildcard determines what files are
  116. displayed in the file selector, and file extension supplies a type extension
  117. for the required filename. Flags may be a combination of wxFD_OPEN, wxFD_SAVE,
  118. wxFD_OVERWRITE_PROMPT, wxFD_HIDE_READONLY, wxFD_FILE_MUST_EXIST, wxFD_MULTIPLE,
  119. wxFD_CHANGE_DIR or 0.
  120. Both the X and Windows versions implement a wildcard filter. Typing a filename
  121. containing wildcards (*, ?) in the filename text item, and clicking on Ok, will
  122. result in only those files matching the pattern being displayed. In the X
  123. version, supplying no default name will result in the wildcard filter being
  124. inserted in the filename text item; the filter is ignored if a default name is
  125. supplied.
  126. The wildcard may be a specification for multiple types of file with a
  127. description for each, such as:
  128. @verbatim
  129. "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
  130. @endverbatim
  131. @section overview_cmndlg_dir wxDirDialog Overview
  132. Classes: wxDirDialog
  133. This dialog shows a directory selector dialog, allowing the user to select a
  134. single directory.
  135. @section overview_cmndlg_textentry wxTextEntryDialog Overview
  136. Classes: wxTextEntryDialog
  137. This is a dialog with a text entry field. The value that the user entered is
  138. obtained using wxTextEntryDialog::GetValue().
  139. @section overview_cmndlg_password wxPasswordEntryDialog Overview
  140. Classes: wxPasswordEntryDialog
  141. This is a dialog with a password entry field. The value that the user entered
  142. is obtained using wxTextEntryDialog::GetValue().
  143. @section overview_cmndlg_msg wxMessageDialog Overview
  144. Classes: wxMessageDialog
  145. This dialog shows a message, plus buttons that can be chosen from OK, Cancel,
  146. Yes, and No. Under Windows, an optional icon can be shown, such as an
  147. exclamation mark or question mark.
  148. The return value of wxMessageDialog::ShowModal() indicates which button the
  149. user pressed.
  150. @section overview_cmndlg_singlechoice wxSingleChoiceDialog Overview
  151. Classes: wxSingleChoiceDialog
  152. This dialog shows a list of choices, plus OK and (optionally) Cancel. The user
  153. can select one of them. The selection can be obtained from the dialog as an
  154. index, a string or client data.
  155. @section overview_cmndlg_multichoice wxMultiChoiceDialog Overview
  156. Classes: wxMultiChoiceDialog
  157. This dialog shows a list of choices, plus OK and (optionally) Cancel. The user
  158. can select one or more of them.
  159. */