1 |
pcg |
1.3 |
#ifndef MENUBAR_H_ |
2 |
|
|
#define MENUBAR_H_ |
3 |
pcg |
1.1 |
|
4 |
|
|
typedef struct { |
5 |
|
|
short type; /* must not be changed; first element */ |
6 |
|
|
short len; /* strlen (str) */ |
7 |
|
|
unsigned char *str; /* action to take */ |
8 |
|
|
} action_t; |
9 |
|
|
|
10 |
|
|
typedef struct { |
11 |
|
|
short type; /* must not be changed; first element */ |
12 |
|
|
struct menu_t *menu; /* sub-menu */ |
13 |
|
|
} submenu_t; |
14 |
|
|
|
15 |
|
|
typedef struct menuitem_t { |
16 |
|
|
struct menuitem_t *prev; /* prev menu-item */ |
17 |
|
|
struct menuitem_t *next; /* next menu-item */ |
18 |
|
|
char *name; /* character string displayed */ |
19 |
|
|
char *name2; /* character string displayed (right) */ |
20 |
|
|
short len; /* strlen (name) */ |
21 |
|
|
short len2; /* strlen (name) */ |
22 |
|
|
union { |
23 |
|
|
short type; /* must not be changed; first element */ |
24 |
|
|
action_t action; |
25 |
|
|
submenu_t submenu; |
26 |
|
|
} entry; |
27 |
|
|
} menuitem_t; |
28 |
|
|
|
29 |
|
|
enum menuitem_t_action { |
30 |
|
|
MenuLabel, |
31 |
|
|
MenuAction, |
32 |
|
|
MenuTerminalAction, |
33 |
|
|
MenuSubMenu |
34 |
|
|
}; |
35 |
|
|
|
36 |
|
|
typedef struct menu_t { |
37 |
|
|
struct menu_t *parent; /* parent menu */ |
38 |
|
|
struct menu_t *prev; /* prev menu */ |
39 |
|
|
struct menu_t *next; /* next menu */ |
40 |
|
|
menuitem_t *head; /* double-linked list */ |
41 |
|
|
menuitem_t *tail; /* double-linked list */ |
42 |
|
|
menuitem_t *item; /* current item */ |
43 |
|
|
char *name; /* menu name */ |
44 |
|
|
short len; /* strlen (name) */ |
45 |
|
|
short width; /* maximum menu width [chars] */ |
46 |
|
|
Window win; /* window of the menu */ |
47 |
|
|
short x; /* x location [pixels] (chars if parent == NULL) */ |
48 |
|
|
short y; /* y location [pixels] */ |
49 |
|
|
short w, h; /* window width, height [pixels] */ |
50 |
|
|
} menu_t; |
51 |
|
|
|
52 |
|
|
typedef struct bar_t { |
53 |
|
|
menu_t *head, *tail; /* double-linked list of menus */ |
54 |
|
|
char *title; /* title to put in the empty menuBar */ |
55 |
|
|
#if (MENUBAR_MAX > 1) |
56 |
|
|
# define MAXNAME 16 |
57 |
|
|
char name[MAXNAME]; /* name to use to refer to menubar */ |
58 |
|
|
struct bar_t *next, *prev; /* circular linked-list */ |
59 |
|
|
#endif /* (MENUBAR_MAX > 1) */ |
60 |
|
|
#define NARROWS 4 |
61 |
|
|
action_t arrows[NARROWS]; |
62 |
|
|
} bar_t; |
63 |
|
|
|
64 |
|
|
/* #define DEBUG_MENU */ |
65 |
|
|
/* #define DEBUG_MENU_LAYOUT */ |
66 |
|
|
/* #define DEBUG_MENUBAR_STACKING */ |
67 |
|
|
|
68 |
|
|
#define HSPACE 1 /* one space */ |
69 |
|
|
#define isSeparator(name) ((name)[0] == '\0') |
70 |
|
|
#define HEIGHT_SEPARATOR (SHADOW + 1) |
71 |
|
|
#define HEIGHT_TEXT (Height2Pixel(1) + 2) |
72 |
|
|
|
73 |
|
|
#define MENU_DELAY_USEC 250000 /* 1/4 sec */ |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
#define SEPARATOR_NAME "-" |
77 |
|
|
#define MENUITEM_BEG '{' |
78 |
|
|
#define MENUITEM_END '}' |
79 |
|
|
#define COMMENT_CHAR '#' |
80 |
|
|
|
81 |
|
|
#define DOT "." |
82 |
|
|
#define DOTS ".." |
83 |
|
|
|
84 |
|
|
#endif /* _MENUBAR_H_ */ |