aboutsummaryrefslogtreecommitdiff
path: root/src/menu.h
blob: 5d4ad94ad2c6d2e462e0fc0fe7886d10620e626c (plain)
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
/**
 * @file menu.h
 * @author Joe Wingbermuehle
 * @date 2004-2006
 *
 * @brief Header for the menu functions.
 *
 */

#ifndef MENU_H
#define MENU_H

typedef enum {
	MA_NONE,
	MA_EXECUTE,
	MA_DESKTOP,
	MA_SENDTO,
	MA_LAYER,
	MA_STICK,
	MA_MAXIMIZE,
	MA_MINIMIZE,
	MA_RESTORE,
	MA_SHADE,
	MA_MOVE,
	MA_RESIZE,
	MA_KILL,
	MA_CLOSE,
	MA_EXIT,
	MA_RESTART
} MenuActionType;

typedef struct MenuAction {
	MenuActionType type;
	union {
		int i;
		char *str;
	} data;
} MenuAction;

typedef enum {
	MENU_ITEM_NORMAL,
	MENU_ITEM_SUBMENU,
	MENU_ITEM_SEPARATOR
} MenuItemType;

typedef struct MenuItem {

	MenuItemType type;
	char *name;
	MenuAction action;
	char *iconName;
	struct Menu *submenu;
	struct MenuItem *next;

	/* This field is handled by menu.c */
	struct IconNode *icon;

} MenuItem;

typedef struct Menu {

	/* These fields must be set before calling ShowMenu */
	struct MenuItem *items;
	char *label;
	int itemHeight;

	/* These fields are handled by menu.c */
	Window window;
	int x, y;
	int width, height;
	int currentIndex, lastIndex;
	unsigned int itemCount;
	int parentOffset;
	int textOffset;
	int *offsets;
	struct Menu *parent;

} Menu;

typedef void (*RunMenuCommandType)(const MenuAction *action);

void InitializeMenu(Menu *menu);
void ShowMenu(Menu *menu, RunMenuCommandType runner, int x, int y);
void DestroyMenu(Menu *menu);

extern int menuShown;

#endif