/
GroupDialog.h
145 lines (111 loc) · 3.51 KB
/
GroupDialog.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#pragma once
#include <memory>
#include <map>
#include "ui/igroupdialog.h"
#include "ui/iusercontrol.h"
#include "wxutil/window/TransientWindow.h"
#include "wxutil/menu/PopupMenu.h"
#include <wx/windowptr.h>
class wxAuiNotebook;
class wxBookCtrlEvent;
class wxAuiNotebookEvent;
class wxImageList;
namespace ui
{
class GroupDialog;
typedef std::shared_ptr<GroupDialog> GroupDialogPtr;
/**
* greebo: The GroupDialog class creates the Window and the Notebook widget
* as soon as construct() is called.
*
* Use the Instance() method to access the static instance of this dialog and
* the addPage method to add new notebook tabs.
*
* ui::GroupDialog::Instance().addPage()
*
* The name passed to the addPage() method can be used to directly toggle
* the notebook widgets via setPage(<name>).
*/
class GroupDialog :
public wxutil::TransientWindow,
public IGroupDialog
{
// Pages, sorted by position
typedef std::map<int, Page> Pages;
// The actual list instance
Pages _pages;
// The page number of the currently active page widget
int _currentPage;
wxWindowPtr<wxAuiNotebook> _notebook;
std::unique_ptr<wxImageList> _imageList;
std::map<std::string, IUserControl::Ptr> _controls;
wxutil::PopupMenuPtr _popupMenu;
private:
// Private constructor creates GTK widgets etc.
GroupDialog();
// TransientWindow events. These deal with window position tracking.
void _postShow();
public:
/**
* Static method to construct the GroupDialog instance.
*/
static void construct();
void addControl(const std::string& controlName) override;
// Documentation: see igroupdialog.h
wxWindow* addPage(const PagePtr& page);
// Removes a given page
void removePage(const std::string& name);
/** greebo: Sets the active tab to the given widget.
*
* @page: The widget that should be displayed, must have been added
* using addPage() beforehand.
*/
void setPage(wxWindow* page);
/** greebo: Activated the named page. The <name> parameter
* refers to the name string passed to the addPage() method.
*/
void setPage(const std::string& name);
// Toggles page/dialog visibility
virtual void togglePage(const std::string& name);
/** greebo: Returns the widget of the currently visible page.
*/
wxWindow* getPage();
/**
* greebo: Returns the name of the current groupdialog page or "" if none is set.
*/
std::string getPageName();
// Returns the window widget containing the GroupDialog.
wxFrame* getDialogWindow();
void showDialogWindow();
void hideDialogWindow();
// Detaches the notebook and relocates it to another parent container
void reparentNotebook(wxWindow* newParent);
void reparentNotebookToSelf();
/**
* Retrieve the static GroupDialog instance.
*/
static GroupDialog& Instance();
/** greebo: The command target to toggle the visibility
*/
static void toggle();
private:
/** greebo: Safely disconnects this window from
* the eventmanager and saves the window position.
*/
void onMainFrameShuttingDown();
// Shows the most recently active page
void onMainFrameConstructed();
// This is where the static shared_ptr of the singleton instance is held.
static GroupDialogPtr& InstancePtr();
/** greebo: Adds the basic widgets to the groupdialog.
*/
void populateWindow();
/** greebo: Updates the pagetitle and the internal page number
*/
void updatePageTitle(int pageNumber);
// Gets called when the user selects a new tab (updates the title)
void onPageSwitch(wxBookCtrlEvent& ev);
void onTabRightClick(wxAuiNotebookEvent& ev);
void undockTab();
};
} // namespace ui