]>
git.saurik.com Git - wxWidgets.git/blob - src/common/modalhook.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/modalhook.cpp
3 // Purpose: wxModalDialogHook implementation
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // for compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
25 #include "wx/modalhook.h"
30 wxModalDialogHook::Hooks
wxModalDialogHook::ms_hooks
;
32 // ============================================================================
33 // wxModalDialogHook implementation
34 // ============================================================================
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 void wxModalDialogHook::Register()
43 for ( Hooks::const_iterator it
= ms_hooks
.begin();
49 wxFAIL_MSG( wxS("Registering already registered hook?") );
53 #endif // wxDEBUG_LEVEL
55 ms_hooks
.insert(ms_hooks
.begin(), this);
58 void wxModalDialogHook::Unregister()
60 if ( !DoUnregister() )
62 wxFAIL_MSG( wxS("Unregistering not registered hook?") );
66 bool wxModalDialogHook::DoUnregister()
68 for ( Hooks::iterator it
= ms_hooks
.begin();
82 // ----------------------------------------------------------------------------
83 // Invoking hooks methods
84 // ----------------------------------------------------------------------------
87 int wxModalDialogHook::CallEnter(wxDialog
* dialog
)
89 // Make a copy of the hooks list to avoid problems if it's modified while
90 // we're iterating over it: this is unlikely to happen in our case, but
91 // quite possible in CallExit() as the hooks may remove themselves after
92 // the call to their Exit(), so do it here for symmetry as well.
93 const Hooks hooks
= ms_hooks
;
95 for ( Hooks::const_iterator it
= hooks
.begin(); it
!= hooks
.end(); ++it
)
97 const int rc
= (*it
)->Enter(dialog
);
98 if ( rc
!= wxID_NONE
)
100 // Skip calling all the rest of the hooks if one of them preempts
101 // showing the dialog completely.
110 void wxModalDialogHook::CallExit(wxDialog
* dialog
)
112 // See comment in CallEnter() for the reasons for making a copy here.
113 const Hooks hooks
= ms_hooks
;
115 for ( Hooks::const_iterator it
= hooks
.begin(); it
!= hooks
.end(); ++it
)