-
Notifications
You must be signed in to change notification settings - Fork 47
/
Statement.h
63 lines (46 loc) · 1.58 KB
/
Statement.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include "ieventmanager.h"
#include <wx/event.h>
#include <sigc++/connection.h>
#include "Event.h"
namespace ui
{
/* greebo: A Statement is an object that executes a command string when invoked.
*
* Trigger the Statement via the execute() method (usually done by the associated accelerator).
*
* Connect the statement to a wxToolBarToolBase / wxButton / wxMenuItem via the connectWidget method.
*/
class Statement :
public Event,
public wxEvtHandler
{
private:
// The statement to execute
std::string _statement;
// Whether this Statement reacts on keyup or keydown
bool _reactOnKeyUp;
typedef std::set<wxMenuItem*> MenuItems;
MenuItems _menuItems;
typedef std::set<const wxToolBarToolBase*> ToolItems;
ToolItems _toolItems;
public:
Statement(const std::string& statement, bool reactOnKeyUp = false);
virtual ~Statement();
// Invoke the registered callback
virtual void execute();
// Override the derived keyDown/keyUp method
virtual void keyUp();
virtual void keyDown();
// Connect the given menuitem/toolbutton to this Statement
virtual void connectMenuItem(wxMenuItem* item);
virtual void disconnectMenuItem(wxMenuItem* item);
virtual void connectToolItem(const wxToolBarToolBase* item);
virtual void disconnectToolItem(const wxToolBarToolBase* item);
virtual bool empty() const;
private:
// The allback methods that can be connected to a ToolButton or a MenuItem
void onMenuItemClicked(wxCommandEvent& ev);
void onToolItemClicked(wxCommandEvent& ev);
}; // class Statement
}