/
CommandList.h
85 lines (65 loc) · 2.06 KB
/
CommandList.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include <string>
#include "icommandsystem.h"
#include "wxutil/dialog/DialogBase.h"
#include "wxutil/TreeModel.h"
#include "wxutil/TreeView.h"
class wxButton;
/* greebo: The CommandListDialog class displays a list of all available
* DarkRadiant commands and provides methods to clear and assign the shortcuts.
*
* The actual re-assignment is taken care of by the ShortcutChooser helper class.
*
* Note: Show the dialog by instantiating this class. It blocks the GUI and
* destroys itself upon dialog closure and returns control to the calling function.
*/
namespace ui
{
class CommandList :
public wxutil::DialogBase
{
public:
struct Columns :
public wxutil::TreeModel::ColumnRecord
{
Columns() :
command(add(wxutil::TreeModel::Column::String)),
key(add(wxutil::TreeModel::Column::String))
{}
wxutil::TreeModel::Column command;
wxutil::TreeModel::Column key;
};
private:
Columns _columns;
// The list store containing the list of ColourSchemes
wxutil::TreeModel::Ptr _listStore;
// The treeview containing the above liststore
wxutil::TreeView* _treeView;
wxButton* _assignButton;
wxButton* _clearButton;
public:
// Constructor
CommandList();
/** greebo: Shows the dialog (allocates on heap, dialog self-destructs)
*/
static void ShowDialog(const cmd::ArgumentList& args);
private:
// This is called to initialise the dialog window / create the widgets
void populateWindow();
void updateButtonState();
// Handles the assignment of a new shortcut to the selected row
void assignShortcut();
// Removes all items from the treeview and reloads the list
void reloadList();
// Gets the currently selected event name
std::string getSelectedCommand();
// The callbacks for the buttons
void onClose(wxCommandEvent& ev);
void onClear(wxCommandEvent& ev);
void onAssign(wxCommandEvent& ev);
void onResetToDefault(wxCommandEvent& ev);
// The callback to catch the double click on a treeview row
void onItemDoubleClicked(wxDataViewEvent& ev);
void onSelectionChanged(wxDataViewEvent& ev);
}; // class CommandListDialog
} // namespace ui