Debian Codegraph @

code/apis/FREDManager.cpp

raw
1 /*
2 Copyright (C) 2009-2013 wxLauncher Team
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include "apis/FREDManager.h"
20 #include "apis/ProfileManager.h"
21 #include "global/ProfileKeys.h"
22
23 LAUNCHER_DEFINE_EVENT_TYPE(EVT_FRED_ENABLED_CHANGED);
24
25 EventHandlers FREDManager::FREDEnabledChangedHandlers;
26
27 void FREDManager::RegisterFREDEnabledChanged(wxEvtHandler *handler) {
28 wxASSERT_MSG(FREDEnabledChangedHandlers.IndexOf(handler) == wxNOT_FOUND,
29 wxString::Format(
30 _T("RegisterFREDEnabledChanged(): Handler at %p already registered."),
31 handler));
32 FREDEnabledChangedHandlers.Append(handler);
33 }
34 void FREDManager::UnRegisterFREDEnabledChanged(wxEvtHandler *handler) {
35 wxASSERT_MSG(FREDEnabledChangedHandlers.IndexOf(handler) != wxNOT_FOUND,
36 wxString::Format(
37 _T("UnRegisterFREDEnabledChanged(): Handler at %p not registered."),
38 handler));
39 FREDEnabledChangedHandlers.DeleteObject(handler);
40 }
41 void FREDManager::GenerateFREDEnabledChanged() {
42 wxCommandEvent event(EVT_FRED_ENABLED_CHANGED, wxID_NONE);
43 wxLogDebug(_T("Generating EVT_FRED_ENABLED_CHANGED event"));
44 EventHandlers::iterator iter = FREDEnabledChangedHandlers.begin();
45 while (iter != FREDEnabledChangedHandlers.end()) {
46 wxEvtHandler* current = *iter;
47 current->AddPendingEvent(event);
48 wxLogDebug(_T(" Sent EVT_FRED_ENABLED_CHANGED event to %p"), current);
49 iter++;
50 }
51 }