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 #ifndef MENU_H
30 #define MENU_H
31
32 #include "../ui/menu.h"
33 #include <ucx/list.h>
34
35 #include <QMainWindow>
36 #include <QMenu>
37 #include <QMenuBar>
38 #include <QContextMenuEvent>
39
40 class UiMenuItemI {
41 public:
42 virtual
void addTo(UiObject *obj, QMenuBar *menubar, QMenu *menu) =
0;
43 };
44
45 class UiMenu : public UiMenuItemI {
46 public:
47
48 UcxList *items;
49 char *label;
50
51 UiMenu(
char *label);
52
53 void addMenuItem(UiMenuItemI *item);
54
55 virtual
void addTo(UiObject *obj, QMenuBar *menubar, QMenu *menu);
56 };
57
58 class UiMenuItem : public UiMenuItemI {
59 char *label;
60 ui_callback callback;
61 void *userdata;
62 UcxList *groups;
63 bool checkable = false;
64
65 public:
66 UiMenuItem(
char *label, ui_callback f,
void *userdata);
67 void addGroup(
int group);
68 void setCheckable(bool c);
69
70 virtual
void addTo(UiObject *obj, QMenuBar *menubar, QMenu *menu);
71 };
72
73 class UiStMenuItem : public UiMenuItemI {
74 char *stockid;
75 ui_callback callback;
76 void *userdata;
77 UcxList *groups;
78
79 public:
80 UiStMenuItem(
char *stockid, ui_callback f,
void *userdata);
81 void addGroup(
int group);
82
83 virtual
void addTo(UiObject *obj, QMenuBar *menubar, QMenu *menu);
84 };
85
86 class UiMenuSeparator : public UiMenuItemI {
87 public:
88 virtual
void addTo(UiObject *obj, QMenuBar *menubar, QMenu *menu);
89 };
90
91 class UiCheckItemNV : public UiMenuItemI {
92 char *label;
93 char *varname;
94
95 public:
96 UiCheckItemNV(
char *label,
char *varname);
97 virtual
void addTo(UiObject *obj, QMenuBar *menubar, QMenu *menu);
98 };
99
100
101 class UiAction : public QAction {
102 Q_OBJECT
103
104 UiObject *obj;
105 ui_callback callback;
106 void *userdata;
107
108 public:
109 UiAction(UiObject *obj, QString &label, ui_callback f,
void *userdata);
110
111 private slots:
112 void trigger();
113 };
114
115 void ui_add_menus(UiObject *obj, QMainWindow *window);
116
117 extern "C" int ui_checkitem_get(UiInteger *i);
118 extern "C" void ui_checkitem_set(UiInteger *i,
int value);
119
120 class UiContextMenuHandler : public QObject {
121 Q_OBJECT
122
123 QWidget *widget;
124 QMenu *menu;
125
126 public:
127 UiContextMenuHandler(QWidget *widget, QMenu *menu);
128
129 public slots:
130 void contextMenuEvent(
const QPoint & pos);
131 };
132
133 #endif
134
135