1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wxWidgets: Common Dialogs</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
<tbody>
<tr>
<td id="projectlogo">
<a href="http://www.wxwidgets.org/" target="_new">
<img alt="wxWidgets" src="logo.png"/>
</a>
</td>
<td style="padding-left: 0.5em; text-align: right;">
<span id="projectnumber">Version: 3.0.2</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Categories</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="index.html">Documentation</a></li><li class="navelem"><a class="el" href="page_topics.html">Programming Guides</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Common Dialogs </div> </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#overview_cmndlg_colour">wxColourDialog Overview</a><ul><li class="level2"><a href="#overview_cmndlg_colour_msw">The MS Windows Colour Selector</a></li>
<li class="level2"><a href="#overview_cmndlg_colour_generic">The Generic Colour Selector</a></li>
<li class="level2"><a href="#overview_cmndlg_colour_example">Example</a></li>
</ul>
</li>
<li class="level1"><a href="#overview_cmndlg_font">wxFontDialog Overview</a><ul><li class="level2"><a href="#overview_cmndlg_font_msw">The MS Windows Font Selector</a></li>
<li class="level2"><a href="#overview_cmndlg_font_generic">The Generic Font Selector</a></li>
<li class="level2"><a href="#overview_cmndlg_font_example">Example</a></li>
</ul>
</li>
<li class="level1"><a href="#overview_cmndlg_print">wxPrintDialog Overview</a></li>
<li class="level1"><a href="#overview_cmndlg_file">wxFileDialog Overview</a></li>
<li class="level1"><a href="#overview_cmndlg_dir">wxDirDialog Overview</a></li>
<li class="level1"><a href="#overview_cmndlg_textentry">wxTextEntryDialog Overview</a></li>
<li class="level1"><a href="#overview_cmndlg_password">wxPasswordEntryDialog Overview</a></li>
<li class="level1"><a href="#overview_cmndlg_msg">wxMessageDialog Overview</a></li>
<li class="level1"><a href="#overview_cmndlg_singlechoice">wxSingleChoiceDialog Overview</a></li>
<li class="level1"><a href="#overview_cmndlg_multichoice">wxMultiChoiceDialog Overview</a></li>
</ul>
</div>
<div class="textblock"><p>Common dialog classes and functions encapsulate commonly-needed dialog box requirements.</p>
<p>They are all 'modal', grabbing the flow of control until the user dismisses the dialog, to make them easy to use within an application.</p>
<p>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, <a class="el" href="classwx_colour_dialog.html" title="This class represents the colour chooser dialog.">wxColourDialog</a> uses the standard colour selector. There is also an equivalent called wxGenericColourDialog for other platforms, and a macro defines <a class="el" href="classwx_colour_dialog.html" title="This class represents the colour chooser dialog.">wxColourDialog</a> 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.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="group__group__class__cmndlg.html">Common Dialogs</a></dd></dl>
<h1><a class="anchor" id="overview_cmndlg_colour"></a>
wxColourDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_colour_dialog.html" title="This class represents the colour chooser dialog.">wxColourDialog</a>, <a class="el" href="classwx_colour_data.html" title="This class holds a variety of information related to colour dialogs.">wxColourData</a></p>
<p>The <a class="el" href="classwx_colour_dialog.html" title="This class represents the colour chooser dialog.">wxColourDialog</a> presents a colour selector to the user, and returns with colour information.</p>
<h2><a class="anchor" id="overview_cmndlg_colour_msw"></a>
The MS Windows Colour Selector</h2>
<p>Under Windows, the native colour selector common dialog is used. This presents a dialog box with three main regions: at the top left, a palette of 48 commonly-used colours is shown. Under this, there is a palette of 16 'custom colours' which can be set by the application if desired. Additionally, the user may open up the dialog box to show a right-hand panel containing controls to select a precise colour, and add it to the custom colour palette.</p>
<h2><a class="anchor" id="overview_cmndlg_colour_generic"></a>
The Generic Colour Selector</h2>
<p>Under non-MS Windows platforms, the colour selector is a simulation of most of the features of the MS Windows selector. Two palettes of 48 standard and 16 custom colours are presented, with the right-hand area containing three sliders for the user to select a colour from red, green and blue components. This colour may be added to the custom colour palette, and will replace either the currently selected custom colour, or the first one in the palette if none is selected. The RGB colour sliders are not optional in the generic colour selector. The generic colour selector is also available under MS Windows; use the name wxGenericColourDialog.</p>
<h2><a class="anchor" id="overview_cmndlg_colour_example"></a>
Example</h2>
<p>In the samples/dialogs directory, there is an example of using the <a class="el" href="classwx_colour_dialog.html" title="This class represents the colour chooser dialog.">wxColourDialog</a> class. Here is an excerpt, which sets various parameters of a <a class="el" href="classwx_colour_data.html" title="This class holds a variety of information related to colour dialogs.">wxColourData</a> object, including a grey scale for the custom colours. If the user did not cancel the dialog, the application retrieves the selected colour and uses it to set the background of a window.</p>
<div class="fragment"><div class="line"><a class="code" href="classwx_colour_data.html" title="This class holds a variety of information related to colour dialogs.">wxColourData</a> data;</div>
<div class="line">data.<a class="code" href="classwx_colour_data.html#a2e5e80d982cbcb17cac113a72efef2bf" title="Under Windows, tells the Windows colour dialog to display the full dialog with custom colour selectio...">SetChooseFull</a>(<span class="keyword">true</span>);</div>
<div class="line"><span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < 16; i++)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="classwx_colour.html" title="A colour is an object representing a combination of Red, Green, and Blue (RGB) intensity values...">wxColour</a> colour(i*16, i*16, i*16);</div>
<div class="line"> data.<a class="code" href="classwx_colour_data.html#afff3c5561456c17bcf6329a81dcfc716" title="Sets custom colours for the colour dialog.">SetCustomColour</a>(i, colour);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><a class="code" href="classwx_colour_dialog.html" title="This class represents the colour chooser dialog.">wxColourDialog</a> dialog(<span class="keyword">this</span>, &data);</div>
<div class="line"><span class="keywordflow">if</span> (dialog.ShowModal() == <a class="code" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbbaeeb1bdf97306d7f0fdffb62c8af3d02f" title="Standard button and menu IDs.">wxID_OK</a>)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="classwx_colour_data.html" title="This class holds a variety of information related to colour dialogs.">wxColourData</a> retData = dialog.GetColourData();</div>
<div class="line"> <a class="code" href="classwx_colour.html" title="A colour is an object representing a combination of Red, Green, and Blue (RGB) intensity values...">wxColour</a> col = retData.<a class="code" href="classwx_colour_data.html#ac9eb69a80b6c0638284f6f55966f2ce4" title="Gets the current colour associated with the colour dialog.">GetColour</a>();</div>
<div class="line"> <a class="code" href="classwx_brush.html" title="A brush is a drawing tool for filling in areas.">wxBrush</a> brush(col, wxSOLID);</div>
<div class="line"> myWindow->SetBackground(brush);</div>
<div class="line"> myWindow->Clear();</div>
<div class="line"> myWindow->Refresh();</div>
<div class="line">}</div>
</div><!-- fragment --><h1><a class="anchor" id="overview_cmndlg_font"></a>
wxFontDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_font_dialog.html" title="This class represents the font chooser dialog.">wxFontDialog</a>, <a class="el" href="classwx_font_data.html" title="This class holds a variety of information related to font dialogs.">wxFontData</a></p>
<p>The <a class="el" href="classwx_font_dialog.html" title="This class represents the font chooser dialog.">wxFontDialog</a> presents a font selector to the user, and returns with font and colour information.</p>
<h2><a class="anchor" id="overview_cmndlg_font_msw"></a>
The MS Windows Font Selector</h2>
<p>Under Windows, the native font selector common dialog is used. This presents a dialog box with controls for font name, point size, style, weight, underlining, strikeout and text foreground colour. A sample of the font is shown on a white area of the dialog box. Note that in the translation from full MS Windows fonts to wxWidgets font conventions, strikeout is ignored and a font family (such as Swiss or Modern) is deduced from the actual font name (such as Arial or Courier).</p>
<h2><a class="anchor" id="overview_cmndlg_font_generic"></a>
The Generic Font Selector</h2>
<p>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, and a sample is shown upon a white background. The generic font selector is also available under MS Windows; use the name wxGenericFontDialog.</p>
<h2><a class="anchor" id="overview_cmndlg_font_example"></a>
Example</h2>
<p>In the samples/dialogs directory, there is an example of using the <a class="el" href="classwx_font_dialog.html" title="This class represents the font chooser dialog.">wxFontDialog</a> class. The application uses the returned font and colour for drawing text on a canvas. Here is an excerpt:</p>
<div class="fragment"><div class="line"><a class="code" href="classwx_font_data.html" title="This class holds a variety of information related to font dialogs.">wxFontData</a> data;</div>
<div class="line">data.<a class="code" href="classwx_font_data.html#a24fd79c0a3eb6764cc7d525acba9aaeb" title="Sets the font that will be initially used by the font dialog.">SetInitialFont</a>(canvasFont);</div>
<div class="line">data.<a class="code" href="classwx_font_data.html#a52e4308bf17d933b5b2948f6eb469608" title="Sets the colour that will be used for the font foreground colour.">SetColour</a>(canvasTextColour);</div>
<div class="line"></div>
<div class="line"><a class="code" href="classwx_font_dialog.html" title="This class represents the font chooser dialog.">wxFontDialog</a> dialog(<span class="keyword">this</span>, &data);</div>
<div class="line"><span class="keywordflow">if</span> (dialog.ShowModal() == <a class="code" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbbaeeb1bdf97306d7f0fdffb62c8af3d02f" title="Standard button and menu IDs.">wxID_OK</a>)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="classwx_font_data.html" title="This class holds a variety of information related to font dialogs.">wxFontData</a> retData = dialog.GetFontData();</div>
<div class="line"> canvasFont = retData.<a class="code" href="classwx_font_data.html#a5ecc1a48c1a783fef87c26f7ea825c0d" title="Gets the font chosen by the user if the user pressed OK (wxFontDialog::ShowModal() returned wxID_OK)...">GetChosenFont</a>();</div>
<div class="line"> canvasTextColour = retData.<a class="code" href="classwx_font_data.html#abb0099f48190807679d721639e9ab6e9" title="Gets the colour associated with the font dialog.">GetColour</a>();</div>
<div class="line"> myWindow->Refresh();</div>
<div class="line">}</div>
</div><!-- fragment --><h1><a class="anchor" id="overview_cmndlg_print"></a>
wxPrintDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_print_dialog.html" title="This class represents the print and print setup common dialogs.">wxPrintDialog</a>, <a class="el" href="classwx_print_data.html" title="This class holds a variety of information related to printers and printer device contexts.">wxPrintData</a></p>
<p>This class represents the print and print setup common dialogs. You may obtain a <a class="el" href="classwx_printer_d_c.html" title="A printer device context is specific to MSW and Mac, and allows access to any printer with a Windows ...">wxPrinterDC</a> device context from a successfully dismissed print dialog.</p>
<p>The samples/printing example shows how to use it: see <a class="el" href="overview_printing.html">Printing Framework Overview</a> for an excerpt from this example.</p>
<h1><a class="anchor" id="overview_cmndlg_file"></a>
wxFileDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_file_dialog.html" title="This class represents the file chooser dialog.">wxFileDialog</a></p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>The wildcard may be a specification for multiple types of file with a description for each, such as:</p>
<pre class="fragment">"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
</pre><h1><a class="anchor" id="overview_cmndlg_dir"></a>
wxDirDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_dir_dialog.html" title="This class represents the directory chooser dialog.">wxDirDialog</a></p>
<p>This dialog shows a directory selector dialog, allowing the user to select a single directory.</p>
<h1><a class="anchor" id="overview_cmndlg_textentry"></a>
wxTextEntryDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_text_entry_dialog.html" title="This class represents a dialog that requests a one-line text string from the user.">wxTextEntryDialog</a></p>
<p>This is a dialog with a text entry field. The value that the user entered is obtained using <a class="el" href="classwx_text_entry_dialog.html#a0cc97d0ced585c7f6d271f6c348fbc32" title="Returns the text that the user has entered if the user has pressed OK, or the original value if the u...">wxTextEntryDialog::GetValue()</a>.</p>
<h1><a class="anchor" id="overview_cmndlg_password"></a>
wxPasswordEntryDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_password_entry_dialog.html" title="This class represents a dialog that requests a one-line password string from the user.">wxPasswordEntryDialog</a></p>
<p>This is a dialog with a password entry field. The value that the user entered is obtained using <a class="el" href="classwx_text_entry_dialog.html#a0cc97d0ced585c7f6d271f6c348fbc32" title="Returns the text that the user has entered if the user has pressed OK, or the original value if the u...">wxTextEntryDialog::GetValue()</a>.</p>
<h1><a class="anchor" id="overview_cmndlg_msg"></a>
wxMessageDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_message_dialog.html" title="This class represents a dialog that shows a single or multi-line message, with a choice of OK...">wxMessageDialog</a></p>
<p>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.</p>
<p>The return value of <a class="el" href="classwx_message_dialog.html#a28e6cea6fb3857df6cc9b103e06dbadf" title="Shows the dialog, returning one of wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO or wxID_HELP.">wxMessageDialog::ShowModal()</a> indicates which button the user pressed.</p>
<h1><a class="anchor" id="overview_cmndlg_singlechoice"></a>
wxSingleChoiceDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_single_choice_dialog.html" title="This class represents a dialog that shows a list of strings, and allows the user to select one...">wxSingleChoiceDialog</a></p>
<p>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.</p>
<h1><a class="anchor" id="overview_cmndlg_multichoice"></a>
wxMultiChoiceDialog Overview</h1>
<p>Classes: <a class="el" href="classwx_multi_choice_dialog.html" title="This class represents a dialog that shows a list of strings, and allows the user to select one or mor...">wxMultiChoiceDialog</a></p>
<p>This dialog shows a list of choices, plus OK and (optionally) Cancel. The user can select one or more of them. </p>
</div></div><!-- contents -->
<address class="footer">
<small>
Generated on Thu Nov 27 2014 13:46:42 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>
|