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 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
<!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: wxModalDialogHook Class Reference</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><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Categories</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="#pro-methods">Protected Member Functions</a> |
<a href="classwx_modal_dialog_hook-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">wxModalDialogHook Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include <wx/modalhook.h></code></p>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Allows to intercept all modal dialog calls. </p>
<p>This class can be used to hook into normal modal dialog handling for some special needs. One of the most common use cases is for testing: as automatic tests can't continue if a modal dialog is shown while they run, this class can be used to avoid showing the modal dialogs during unattended execution. <a class="el" href="classwx_modal_dialog_hook.html" title="Allows to intercept all modal dialog calls.">wxModalDialogHook</a> can also be used for disabling some background operation while a modal dialog is shown.</p>
<p>To install a modal dialog hook, you need to derive your own class from this one and implement its pure virtual <a class="el" href="classwx_modal_dialog_hook.html#a9f477ea46562af13c12f4fd39594e9e8" title="Called by wxWidgets before showing any modal dialogs.">Enter()</a> method. Then simply create an object of your class and call <a class="el" href="classwx_modal_dialog_hook.html#a02fa64dfe62289002cd7667af46abc4c" title="Register this hook as being active.">Register()</a> on it to start receiving calls to your overridden <a class="el" href="classwx_modal_dialog_hook.html#a9f477ea46562af13c12f4fd39594e9e8" title="Called by wxWidgets before showing any modal dialogs.">Enter()</a> (and possibly <a class="el" href="classwx_modal_dialog_hook.html#a038ee1611b0176902fe9d1295af083c2" title="Called by wxWidgets after dismissing the modal dialog.">Exit()</a>) methods: </p>
<div class="fragment"><div class="line"><span class="keyword">class </span>MyModalDialogHook : <span class="keyword">public</span> <a class="code" href="classwx_modal_dialog_hook.html" title="Allows to intercept all modal dialog calls.">wxModalDialogHook</a></div>
<div class="line">{</div>
<div class="line"><span class="keyword">protected</span>:</div>
<div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classwx_modal_dialog_hook.html#a9f477ea46562af13c12f4fd39594e9e8" title="Called by wxWidgets before showing any modal dialogs.">Enter</a>(<a class="code" href="classwx_dialog.html" title="A dialog box is a window with a title bar and sometimes a system menu, which can be moved around the ...">wxDialog</a>* dialog)</div>
<div class="line"> {</div>
<div class="line"> <span class="comment">// Just for demonstration purposes, intercept all uses of</span></div>
<div class="line"> <span class="comment">// wxFileDialog. Notice that this doesn't provide any real</span></div>
<div class="line"> <span class="comment">// sandboxing, of course, the program can still read and write</span></div>
<div class="line"> <span class="comment">// files by not using wxFileDialog to ask the user for their</span></div>
<div class="line"> <span class="comment">// names.</span></div>
<div class="line"> <span class="keywordflow">if</span> ( <a class="code" href="group__group__funcmacro__rtti.html#ga2606f92f8d5f8e22f4afb44a6df3c38a" title="This macro returns the pointer ptr cast to the type classname * if the pointer is of this type (the c...">wxDynamicCast</a>(dialog, <a class="code" href="classwx_file_dialog.html" title="This class represents the file chooser dialog.">wxFileDialog</a>) )</div>
<div class="line"> {</div>
<div class="line"> <a class="code" href="group__group__funcmacro__log.html#ga0dd3c633f990f794e76065c9a7af4c87" title="The functions to use for error messages, i.e.">wxLogError</a>(<span class="stringliteral">"Access to file system disallowed."</span>);</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Skip showing the file dialog entirely.</span></div>
<div class="line"> <span class="keywordflow">return</span> <a class="code" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbba27aec3f2d4b5cf0e36c028bbab048206">wxID_CANCEL</a>;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> m_lastEnter = <a class="code" href="classwx_date_time.html#a6e6c37a0414bb4831e2cc03b37f498a2" title="Returns the object corresponding to the current time.">wxDateTime::Now</a>();</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Allow the dialog to be shown as usual.</span></div>
<div class="line"> <span class="keywordflow">return</span> <a class="code" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbbaa49202a202b229f4a4cc91f1b60ae31b" title="No id matches this one when compared to it.">wxID_NONE</a>;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classwx_modal_dialog_hook.html#a038ee1611b0176902fe9d1295af083c2" title="Called by wxWidgets after dismissing the modal dialog.">Exit</a>(<a class="code" href="classwx_dialog.html" title="A dialog box is a window with a title bar and sometimes a system menu, which can be moved around the ...">wxDialog</a>* dialog)</div>
<div class="line"> {</div>
<div class="line"> <span class="comment">// Again, just for demonstration purposes, show how long did</span></div>
<div class="line"> <span class="comment">// the user take to dismiss the dialog. Notice that we</span></div>
<div class="line"> <span class="comment">// shouldn't use wxLogMessage() here as this would result in</span></div>
<div class="line"> <span class="comment">// another modal dialog call and hence infinite recursion. In</span></div>
<div class="line"> <span class="comment">// general, the hooks should be as unintrusive as possible.</span></div>
<div class="line"> <a class="code" href="group__group__funcmacro__log.html#ga9c530ae20eb423744f90874d2c97d02b" title="The right functions for debug output.">wxLogDebug</a>(<span class="stringliteral">"%s dialog took %s to be dismissed"</span>,</div>
<div class="line"> dialog-><a class="code" href="classwx_object.html#ab3a0c6f723cbaddb47be4e8dd98cc8e2" title="This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).">GetClassInfo</a>()-><a class="code" href="classwx_class_info.html#a4827f2dcd6ded37542370e6b1875c79e" title="Returns the string form of the class name.">GetClassName</a>(),</div>
<div class="line"> (<a class="code" href="classwx_date_time.html#a6e6c37a0414bb4831e2cc03b37f498a2" title="Returns the object corresponding to the current time.">wxDateTime::Now</a>() - m_lastEnter).Format());</div>
<div class="line"> }</div>
<div class="line">};</div>
<div class="line"></div>
<div class="line"><span class="keyword">class </span>MyApp : <span class="keyword">public</span> <a class="code" href="classwx_app.html" title="The wxApp class represents the application itself when wxUSE_GUI=1.">wxApp</a></div>
<div class="line">{</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnInit()</div>
<div class="line"> {</div>
<div class="line"> ...</div>
<div class="line"> m_myHook.Register();</div>
<div class="line"> ...</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"><span class="keyword">private</span>:</div>
<div class="line"> MyModalDialogHook m_myHook;</div>
<div class="line">};</div>
</div><!-- fragment --><dl class="section since"><dt>Since</dt><dd>2.9.5 </dd></dl>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a2eb90569818889b3f2963a1e9f026444"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_modal_dialog_hook.html#a2eb90569818889b3f2963a1e9f026444">wxModalDialogHook</a> ()</td></tr>
<tr class="memdesc:a2eb90569818889b3f2963a1e9f026444"><td class="mdescLeft"> </td><td class="mdescRight">Default and trivial constructor. <a href="#a2eb90569818889b3f2963a1e9f026444"></a><br/></td></tr>
<tr class="separator:a2eb90569818889b3f2963a1e9f026444"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a89c7988df3b7da3fbf8b1eeffe65295d"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_modal_dialog_hook.html#a89c7988df3b7da3fbf8b1eeffe65295d">~wxModalDialogHook</a> ()</td></tr>
<tr class="memdesc:a89c7988df3b7da3fbf8b1eeffe65295d"><td class="mdescLeft"> </td><td class="mdescRight">Destructor unregisters the hook if it's currently active. <a href="#a89c7988df3b7da3fbf8b1eeffe65295d"></a><br/></td></tr>
<tr class="separator:a89c7988df3b7da3fbf8b1eeffe65295d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a02fa64dfe62289002cd7667af46abc4c"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_modal_dialog_hook.html#a02fa64dfe62289002cd7667af46abc4c">Register</a> ()</td></tr>
<tr class="memdesc:a02fa64dfe62289002cd7667af46abc4c"><td class="mdescLeft"> </td><td class="mdescRight">Register this hook as being active. <a href="#a02fa64dfe62289002cd7667af46abc4c"></a><br/></td></tr>
<tr class="separator:a02fa64dfe62289002cd7667af46abc4c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a127e7215c35b1d6940e3628ef8463f58"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_modal_dialog_hook.html#a127e7215c35b1d6940e3628ef8463f58">Unregister</a> ()</td></tr>
<tr class="memdesc:a127e7215c35b1d6940e3628ef8463f58"><td class="mdescLeft"> </td><td class="mdescRight">Unregister this hook. <a href="#a127e7215c35b1d6940e3628ef8463f58"></a><br/></td></tr>
<tr class="separator:a127e7215c35b1d6940e3628ef8463f58"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a9f477ea46562af13c12f4fd39594e9e8"><td class="memItemLeft" align="right" valign="top">virtual int </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_modal_dialog_hook.html#a9f477ea46562af13c12f4fd39594e9e8">Enter</a> (<a class="el" href="classwx_dialog.html">wxDialog</a> *dialog)=0</td></tr>
<tr class="memdesc:a9f477ea46562af13c12f4fd39594e9e8"><td class="mdescLeft"> </td><td class="mdescRight">Called by wxWidgets before showing any modal dialogs. <a href="#a9f477ea46562af13c12f4fd39594e9e8"></a><br/></td></tr>
<tr class="separator:a9f477ea46562af13c12f4fd39594e9e8"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a038ee1611b0176902fe9d1295af083c2"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_modal_dialog_hook.html#a038ee1611b0176902fe9d1295af083c2">Exit</a> (<a class="el" href="classwx_dialog.html">wxDialog</a> *dialog)</td></tr>
<tr class="memdesc:a038ee1611b0176902fe9d1295af083c2"><td class="mdescLeft"> </td><td class="mdescRight">Called by wxWidgets after dismissing the modal dialog. <a href="#a038ee1611b0176902fe9d1295af083c2"></a><br/></td></tr>
<tr class="separator:a038ee1611b0176902fe9d1295af083c2"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a class="anchor" id="a2eb90569818889b3f2963a1e9f026444"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">wxModalDialogHook::wxModalDialogHook </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Default and trivial constructor. </p>
<p>The constructor doesn't do anything, call <a class="el" href="classwx_modal_dialog_hook.html#a02fa64dfe62289002cd7667af46abc4c" title="Register this hook as being active.">Register()</a> to make this hook active. </p>
</div>
</div>
<a class="anchor" id="a89c7988df3b7da3fbf8b1eeffe65295d"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual wxModalDialogHook::~wxModalDialogHook </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Destructor unregisters the hook if it's currently active. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a9f477ea46562af13c12f4fd39594e9e8"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual int wxModalDialogHook::Enter </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classwx_dialog.html">wxDialog</a> * </td>
<td class="paramname"><em>dialog</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Called by wxWidgets before showing any modal dialogs. </p>
<p>Override this to be notified whenever a modal dialog is about to be shown.</p>
<p>If the return value of this method is <a class="el" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbbaa49202a202b229f4a4cc91f1b60ae31b" title="No id matches this one when compared to it.">wxID_NONE</a>, the dialog is shown as usual and <a class="el" href="classwx_modal_dialog_hook.html#a038ee1611b0176902fe9d1295af083c2" title="Called by wxWidgets after dismissing the modal dialog.">Exit()</a> will be called when it is dismissed. If the return value is anything else, the dialog is not shown at all and its <a class="el" href="classwx_dialog.html#a6e078c3d0653f75ad3c34a37c0b54637" title="Shows an application-modal dialog.">wxDialog::ShowModal()</a> simply returns with the given result. In this case, <a class="el" href="classwx_modal_dialog_hook.html#a038ee1611b0176902fe9d1295af083c2" title="Called by wxWidgets after dismissing the modal dialog.">Exit()</a> won't be called neither.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">dialog</td><td>The dialog about to be shown, never <span class="literal">NULL</span>. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>wxID_NONE to continue with showing the dialog or anything else to skip showing the dialog and just return this value from its ShowModal(). </dd></dl>
</div>
</div>
<a class="anchor" id="a038ee1611b0176902fe9d1295af083c2"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual void wxModalDialogHook::Exit </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classwx_dialog.html">wxDialog</a> * </td>
<td class="paramname"><em>dialog</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Called by wxWidgets after dismissing the modal dialog. </p>
<p>Notice that it won't be called if <a class="el" href="classwx_modal_dialog_hook.html#a9f477ea46562af13c12f4fd39594e9e8" title="Called by wxWidgets before showing any modal dialogs.">Enter()</a> hadn't been called because another modal hook, registered after this one, intercepted the dialog or if our <a class="el" href="classwx_modal_dialog_hook.html#a9f477ea46562af13c12f4fd39594e9e8" title="Called by wxWidgets before showing any modal dialogs.">Enter()</a> was called but returned a value different from <a class="el" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbbaa49202a202b229f4a4cc91f1b60ae31b" title="No id matches this one when compared to it.">wxID_NONE</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">dialog</td><td>The dialog that was shown and dismissed, never <span class="literal">NULL</span>. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a02fa64dfe62289002cd7667af46abc4c"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void wxModalDialogHook::Register </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Register this hook as being active. </p>
<p>After registering the hook, its <a class="el" href="classwx_modal_dialog_hook.html#a9f477ea46562af13c12f4fd39594e9e8" title="Called by wxWidgets before showing any modal dialogs.">Enter()</a> and <a class="el" href="classwx_modal_dialog_hook.html#a038ee1611b0176902fe9d1295af083c2" title="Called by wxWidgets after dismissing the modal dialog.">Exit()</a> methods will be called whenever a modal dialog is shown.</p>
<p>Notice that the order of registration matters: the last hook registered is called first, and if its <a class="el" href="classwx_modal_dialog_hook.html#a9f477ea46562af13c12f4fd39594e9e8" title="Called by wxWidgets before showing any modal dialogs.">Enter()</a> returns a value different from <a class="el" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbbaa49202a202b229f4a4cc91f1b60ae31b" title="No id matches this one when compared to it.">wxID_NONE</a>, the subsequent hooks are skipped.</p>
<p>It is an error to register the same hook twice. </p>
</div>
</div>
<a class="anchor" id="a127e7215c35b1d6940e3628ef8463f58"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void wxModalDialogHook::Unregister </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Unregister this hook. </p>
<p>Notice that is done automatically from the destructor, so usually calling this method explicitly is unnecessary.</p>
<p>The hook must be currently registered. </p>
</div>
</div>
</div><!-- contents -->
<address class="footer">
<small>
Generated on Thu Nov 27 2014 13:46:51 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>
|