1 /*
2  Copyright (C) 2010-2014 Kristian Duske
3 
4  This file is part of TrenchBroom.
5 
6  TrenchBroom is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  TrenchBroom is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "ExecutableEvent.h"
21 
22 wxDEFINE_EVENT(EXECUTABLE_EVENT, TrenchBroom::View::ExecutableEvent);
23 
24 namespace TrenchBroom {
25     namespace View {
IMPLEMENT_DYNAMIC_CLASS(ExecutableEvent,wxEvent)26         IMPLEMENT_DYNAMIC_CLASS(ExecutableEvent, wxEvent)
27 
28         ExecutableEvent::Executable::~Executable() {}
29 
operator ()()30         void ExecutableEvent::Executable::operator()() {
31             execute();
32         }
33 
ExecutableEvent()34         ExecutableEvent::ExecutableEvent() {}
35 
ExecutableEvent(Executable * executable)36         ExecutableEvent::ExecutableEvent(Executable* executable) :
37         wxEvent(wxID_ANY, EXECUTABLE_EVENT),
38         m_executable(executable) {}
39 
ExecutableEvent(Executable::Ptr sharedExecutable)40         ExecutableEvent::ExecutableEvent(Executable::Ptr sharedExecutable) :
41         wxEvent(wxID_ANY, EXECUTABLE_EVENT),
42         m_executable(sharedExecutable) {}
43 
Clone() const44         wxEvent* ExecutableEvent::Clone() const {
45             return new ExecutableEvent(*this);
46         }
47 
execute()48         void ExecutableEvent::execute() {
49             if (m_executable.get() != NULL)
50                 (*m_executable)();
51         }
52     }
53 }
54