]>
git.saurik.com Git - wxWidgets.git/blob - src/common/modalhook.cpp
0bba44934e384a6605a4ad61a3add331768d92c3
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/modalhook.cpp
3 // Purpose: wxModalDialogHook implementation
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #include "wx/modalhook.h"
31 wxModalDialogHook::Hooks
wxModalDialogHook::ms_hooks
;
33 // ============================================================================
34 // wxModalDialogHook implementation
35 // ============================================================================
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 void wxModalDialogHook::Register()
44 for ( Hooks::const_iterator it
= ms_hooks
.begin();
50 wxFAIL_MSG( wxS("Registering already registered hook?") );
54 #endif // wxDEBUG_LEVEL
56 ms_hooks
.insert(ms_hooks
.begin(), this);
59 void wxModalDialogHook::Unregister()
61 if ( !DoUnregister() )
63 wxFAIL_MSG( wxS("Unregistering not registered hook?") );
67 bool wxModalDialogHook::DoUnregister()
69 for ( Hooks::iterator it
= ms_hooks
.begin();
83 // ----------------------------------------------------------------------------
84 // Invoking hooks methods
85 // ----------------------------------------------------------------------------
88 int wxModalDialogHook::CallEnter(wxDialog
* dialog
)
90 // Make a copy of the hooks list to avoid problems if it's modified while
91 // we're iterating over it: this is unlikely to happen in our case, but
92 // quite possible in CallExit() as the hooks may remove themselves after
93 // the call to their Exit(), so do it here for symmetry as well.
94 const Hooks hooks
= ms_hooks
;
96 for ( Hooks::const_iterator it
= hooks
.begin(); it
!= hooks
.end(); ++it
)
98 const int rc
= (*it
)->Enter(dialog
);
99 if ( rc
!= wxID_NONE
)
101 // Skip calling all the rest of the hooks if one of them preempts
102 // showing the dialog completely.
111 void wxModalDialogHook::CallExit(wxDialog
* dialog
)
113 // See comment in CallEnter() for the reasons for making a copy here.
114 const Hooks hooks
= ms_hooks
;
116 for ( Hooks::const_iterator it
= hooks
.begin(); it
!= hooks
.end(); ++it
)