-
Notifications
You must be signed in to change notification settings - Fork 47
/
ShortcutChooser.h
52 lines (40 loc) · 1.27 KB
/
ShortcutChooser.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
#pragma once
#include <string>
#include "wxutil/dialog/DialogBase.h"
#include <wx/event.h>
class wxStaticText;
class wxTextCtrl;
/**
* greebo: The Shortcutchooser takes care of displaying the dialog and
* re-assigning the events after the shortcut has been entered by the user.
*/
namespace ui
{
class ShortcutChooser :
public wxutil::DialogBase
{
private:
// The label to hold the status text of the shortcut chooser
wxStaticText* _statusText;
wxStaticText* _existingEventText;
wxTextCtrl* _entry;
// Working variable to store the new key/modifier from the user input
wxKeyEvent _savedKeyEvent;
// The event name the shortcut will be assigned to
std::string _commandName;
public:
// Constructor, instantiate this class by specifying the parent window
ShortcutChooser(const std::string& title,
wxWindow* parent,
const std::string& command);
virtual int ShowModal();
private:
// Assigns or unassigns shortcut, based on the user's input (called after OK)
// returns true if the shortcut actually got changed.
bool assignShortcut();
// The callback for catching the keypress events in the shortcut entry field
void onShortcutKeyPress(wxKeyEvent& ev);
void onOK(wxCommandEvent& ev);
void onCancel(wxCommandEvent& ev);
}; // class ShortcutChooser
} // namespace ui