-
Notifications
You must be signed in to change notification settings - Fork 99
/
objmenu.h
50 lines (40 loc) · 1.29 KB
/
objmenu.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
#ifndef __OBJMENU_H
#define __OBJMENU_H
#include "ymenu.h"
#include "ymenuitem.h"
#include "yaction.h"
#include "obj.h"
class DObject;
class ObjectMenu:
public YMenu,
public ObjectContainer,
public YActionListener
{
public:
ObjectMenu(YActionListener *wmActionListener, YWindow *parent = nullptr);
virtual ~ObjectMenu();
virtual void actionPerformed(YAction action, unsigned modifiers) override;
virtual void addObject(DObject* object) override;
virtual void addSeparator() override;
virtual void addContainer(mstring name, ref<YIcon> icon, ObjectMenu *container) override;
YMenuItem* addObject(DObject* object, const char* icon,
ObjectMenu* sub = nullptr, bool check = false);
YMenuItem* getObjectItem(DObject* object);
void setActionListener(YActionListener* al) override {
wmActionListener = al;
}
YActionListener* getActionListener() const override {
return const_cast<ObjectMenu*>(this);
}
private:
struct ObjectAction {
DObject* object;
YAction action;
ObjectAction(DObject* obj, YAction act) : object(obj), action(act) { }
};
typedef YArray<ObjectAction> ArrayType;
ArrayType fArray;
YActionListener* wmActionListener;
};
#endif
// vim: set sw=4 ts=4 et: