-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMainMenu.cpp
154 lines (128 loc) · 4.2 KB
/
MainMenu.cpp
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
146
147
148
149
150
151
152
153
154
#include <iostream>
#include <gtkmm.h>
using namespace Glib;
using namespace Gtk;
class Form : public Window {
public:
Form() {
add(vbox);
vbox.pack_start(menuBar, PACK_SHRINK);
vbox.pack_end(scrolledWindow);
scrolledWindow.add(fixed);
menuFile.set_label("File");
menuBar.append(menuFile);
menuEdit.set_label("Edit");
menuBar.append(menuEdit);
menuView.set_label("View");
menuBar.append(menuView);
menuWindow.set_label("Window");
menuBar.append(menuWindow);
menuHelp.set_label("Help");
menuBar.append(menuHelp);
menuFile.set_submenu(subMenuFile);
menuEdit.set_submenu(subMenuEdit);
menuView.set_submenu(subMenuView);
menuWindow.set_submenu(subMenuWindow);
menuHelp.set_submenu(subMenuHelp);
subMenuFile.append(menuFileNew);
subMenuFile.append(menuFileOpen);
subMenuFile.append(separator1);
subMenuFile.append(menuFileClose);
subMenuEdit.append(menuEditUndo);
subMenuEdit.append(menuEditRedo);
subMenuEdit.append(separator2);
subMenuEdit.append(menuEditCut);
subMenuEdit.append(menuEditCopy);
subMenuEdit.append(menuEditPaste);
subMenuEdit.append(menuEditDelete);
subMenuEdit.append(separator3);
subMenuEdit.append(menuEditSelectAll);
menuFileNew.set_label("_New");
menuFileNew.set_use_underline(true);
menuFileNew.Gtk::Widget::add_accelerator("New", get_accel_group(), 'n', Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
menuFileNew.signal_activate().connect([&]() {
std::cout << "MainMenu/File/New" << std::endl;
});
menuFileOpen.set_label("_Open");
menuFileOpen.set_use_underline(true);
menuFileOpen.signal_activate().connect([&]() {
std::cout << "MainMenu/File/Open" << std::endl;
});
menuFileClose.set_label("_Close");
menuFileClose.set_use_underline(true);
menuFileClose.signal_activate().connect([&]() {
std::cout << "MainMenu/File/Close" << std::endl;
});
menuEditUndo.set_label("_Undo");
menuEditUndo.set_use_underline(true);
menuEditUndo.signal_activate().connect([&]() {
std::cout << "MainMenu/Edit/Undo" << std::endl;
});
menuEditRedo.set_label("_Redo");
menuEditRedo.set_use_underline(true);
menuEditRedo.signal_activate().connect([&]() {
std::cout << "MainMenu/Edit/Redo" << std::endl;
});
menuEditCut.set_label("C_ut");
menuEditCut.set_use_underline(true);
menuEditCut.signal_activate().connect([&]() {
std::cout << "MainMenu/Edit/Cut" << std::endl;
});
menuEditCopy.set_label("_Copy");
menuEditCopy.set_use_underline(true);
menuEditCopy.signal_activate().connect([&]() {
std::cout << "MainMenu/Edit/Copy" << std::endl;
});
menuEditPaste.set_label("_Paste");
menuEditPaste.set_use_underline(true);
menuEditPaste.signal_activate().connect([&]() {
std::cout << "MainMenu/Edit/Paste" << std::endl;
});
menuEditDelete.set_label("_Delete");
menuEditDelete.set_use_underline(true);
menuEditDelete.signal_activate().connect([&]() {
std::cout << "MainMenu/Edit/Delete" << std::endl;
});
menuEditSelectAll.set_label("Select _All");
menuEditSelectAll.set_use_underline(true);
menuEditSelectAll.signal_activate().connect([&]() {
std::cout << "MainMenu/Edit/SelectAll" << std::endl;
});
set_title("MainMenu example");
resize(300, 300);
show_all();
}
private:
VBox vbox;
Fixed fixed;
ScrolledWindow scrolledWindow;
MenuBar menuBar;
MenuItem menuFile;
MenuItem menuEdit;
MenuItem menuView;
MenuItem menuWindow;
MenuItem menuHelp;
Menu subMenuFile;
Menu subMenuEdit;
Menu subMenuView;
Menu subMenuWindow;
Menu subMenuHelp;
MenuItem menuFileNew;
SeparatorMenuItem separator1;
MenuItem menuFileOpen;
MenuItem menuFileClose;
MenuItem menuEditUndo;
MenuItem menuEditRedo;
SeparatorMenuItem separator2;
MenuItem menuEditCut;
MenuItem menuEditCopy;
MenuItem menuEditPaste;
MenuItem menuEditDelete;
SeparatorMenuItem separator3;
MenuItem menuEditSelectAll;
};
int main(int argc, char* argv[]) {
RefPtr<Application> application = Application::create(argc, argv);
Form form;
return application->run(form);
}