/
GuiSelector.h
82 lines (62 loc) · 2.15 KB
/
GuiSelector.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
#pragma once
#include "wxutil/dialog/DialogBase.h"
#include "wxutil/dataview/VFSTreePopulator.h"
#include "wxutil/dataview/TreeView.h"
class wxNotebook;
class wxBookCtrlEvent;
namespace ui
{
// Forward decl.
class ReadableEditorDialog;
///////////////////////////// XDataSelector:
// Selector-Dialog for TwoSided and OneSided readable guis. Switching the pages of the notebook
// also toggles the according editing mode on the ReadableEditorDialog (TwoSided or OneSided).
// Selecting a gui definition updates the guiView for previewing.
class GuiSelector :
public wxutil::DialogBase,
public wxutil::VFSTreePopulator::Visitor
{
public:
// Treestore enum
struct GuiTreeModelColumns :
public wxutil::TreeModel::ColumnRecord
{
GuiTreeModelColumns() :
name(add(wxutil::TreeModel::Column::IconText)),
fullName(add(wxutil::TreeModel::Column::String)),
isFolder(add(wxutil::TreeModel::Column::Boolean))
{}
wxutil::TreeModel::Column name;
wxutil::TreeModel::Column fullName;
wxutil::TreeModel::Column isFolder;
};
private:
// Reference to the calling ReadableEditorDialog
ReadableEditorDialog* _editorDialog;
// The name that was picked.
std::string _name;
// The notebook holding the tabs for one-sided and two-sided readables.
wxNotebook* _notebook;
GuiTreeModelColumns _columns;
wxutil::TreeModel::Ptr _oneSidedStore;
wxutil::TreeModel::Ptr _twoSidedStore;
wxutil::TreeView* _oneSidedView;
wxutil::TreeView* _twoSidedView;
wxIcon _guiIcon;
wxIcon _folderIcon;
public:
// Starts the GuiSelector and returns the name of the selected GUI or an empty string if the user canceled.
// The dialog shows the twoSided treeview if twoSided is true.
static std::string Run(bool twoSided, ReadableEditorDialog* editorDialog);
void visit(wxutil::TreeModel& store, wxutil::TreeModel::Row& row,
const std::string& path, bool isExplicit);
// Disconnect all events when the dialog is destroyed
virtual bool Destroy() override;
private:
GuiSelector(bool twoSided, ReadableEditorDialog* editorDialog);
void fillTrees();
void populateWindow();
void onSelectionChanged(wxDataViewEvent& ev);
void onPageSwitch(wxBookCtrlEvent& ev);
};
} // namespace