Audacity  2.2.0
AppCommandEvent.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity - A Digital Audio Editor
4  Copyright 1999-2009 Audacity Team
5  File License: wxWidgets
6 
7  Dan Horgan
8 
9 ******************************************************************//*******************************************************************/
15 
16 #ifndef __APPCOMMANDEVENT__
17 #define __APPCOMMANDEVENT__
18 
19 #include <wx/event.h>
20 #include "../Audacity.h"
21 #include "../MemoryX.h"
22 
23 DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, wxEVT_APP_COMMAND_RECEIVED, -1);
24 
25 class Command;
26 using CommandHolder = std::shared_ptr<Command>;
27 
28 class AppCommandEvent final : public wxCommandEvent
29 {
30 private:
32 
33 public:
34  AppCommandEvent(wxEventType commandType = wxEVT_APP_COMMAND_RECEIVED, int id = 0);
35 
36  AppCommandEvent(const AppCommandEvent &event);
38 
39  wxEvent *Clone() const override;
40  void SetCommand(const CommandHolder &cmd);
42 
43 private:
44  DECLARE_DYNAMIC_CLASS(AppCommandEvent)
45 };
46 
47 typedef void (wxEvtHandler::*wxAppCommandEventFunction)(AppCommandEvent&);
48 
49 #define wxAppCommandEventHandler(func) \
50  (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAppCommandEventFunction, &func)
51 
52 #define EVT_APP_COMMAND(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_APP_COMMAND_RECEIVED, winid, wxID_ANY, wxAppCommandEventHandler(fn), (wxObject *) NULL ),
53 
54 #endif /* End of include guard: __APPCOMMANDEVENT__ */
CommandHolder mCommand
Definition: AppCommandEvent.h:31
~AppCommandEvent()
Definition: AppCommandEvent.cpp:41
std::shared_ptr< Command > CommandHolder
Definition: AppCommandEvent.h:26
AppCommandEvent(wxEventType commandType=wxEVT_APP_COMMAND_RECEIVED, int id=0)
Definition: AppCommandEvent.cpp:30
Abstract base class for command interface. It implements Command::SetParameter() and defers all other...
Definition: Command.h:70
wxEvent * Clone() const override
Definition: AppCommandEvent.cpp:46
void(wxEvtHandler::* wxAppCommandEventFunction)(AppCommandEvent &)
Definition: AppCommandEvent.h:47
An event 'envelope' for sending Command objects through the wxwidgets event loop. ...
Definition: AppCommandEvent.h:28
CommandHolder GetCommand()
Definition: AppCommandEvent.cpp:58
void SetCommand(const CommandHolder &cmd)
Store a pointer to a command object.
Definition: AppCommandEvent.cpp:52
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, wxEVT_APP_COMMAND_RECEIVED,-1)