Merge pull request #24 from kawaiiamber/readme
[xmenu] / xmenu.h
... / ...
CommitLineData
1#define PROGNAME "xmenu"
2
3/* enum for keyboard menu navigation */
4enum { ITEMPREV, ITEMNEXT, ITEMFIRST, ITEMLAST };
5
6/* enum for text alignment */
7enum {LeftAlignment, CenterAlignment, RightAlignment};
8
9/* macros */
10#define LEN(x) (sizeof (x) / sizeof (x[0]))
11#define MAX(x,y) ((x)>(y)?(x):(y))
12#define MIN(x,y) ((x)<(y)?(x):(y))
13#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
14#define GETNUM(n, s) { \
15 unsigned long __TMP__; \
16 if ((__TMP__ = strtoul((s), NULL, 10)) < INT_MAX) \
17 (n) = __TMP__; \
18 }
19
20/* color enum */
21enum {ColorFG, ColorBG, ColorLast};
22
23/* EWMH atoms */
24enum {NetWMName, NetWMWindowType, NetWMWindowTypePopupMenu, NetLast};
25
26/* configuration structure */
27struct Config {
28 /* the values below are set by config.h */
29 const char *font;
30 const char *background_color;
31 const char *foreground_color;
32 const char *selbackground_color;
33 const char *selforeground_color;
34 const char *separator_color;
35 const char *border_color;
36 int width_pixels;
37 int height_pixels;
38 int border_pixels;
39 int separator_pixels;
40 int gap_pixels;
41 int triangle_width;
42 int triangle_height;
43 int iconpadding;
44 int horzpadding;
45 int alignment;
46
47 /* the values below are set by options */
48 int monitor;
49 int posx, posy; /* rootmenu position */
50
51 /* the value below is computed by xmenu */
52 int iconsize;
53};
54
55/* draw context structure */
56struct DC {
57 XftColor normal[ColorLast];
58 XftColor selected[ColorLast];
59 XftColor border;
60 XftColor separator;
61
62 GC gc;
63
64 FcPattern *pattern;
65 XftFont **fonts;
66 size_t nfonts;
67};
68
69/* menu item structure */
70struct Item {
71 char *label; /* string to be drawed on menu */
72 char *output; /* string to be outputed when item is clicked */
73 char *file; /* filename of the icon */
74 int y; /* item y position relative to menu */
75 int h; /* item height */
76 int textw; /* text width */
77 struct Item *prev; /* previous item */
78 struct Item *next; /* next item */
79 struct Menu *submenu; /* submenu spawned by clicking on item */
80 Drawable sel, unsel; /* pixmap for selected and unselected item */
81 Imlib_Image icon;
82};
83
84/* monitor geometry structure */
85struct Monitor {
86 int x, y, w, h; /* monitor geometry */
87};
88
89/* menu structure */
90struct Menu {
91 struct Menu *parent; /* parent menu */
92 struct Item *caller; /* item that spawned the menu */
93 struct Item *list; /* list of items contained by the menu */
94 struct Item *selected; /* item currently selected in the menu */
95 int x, y, w, h; /* menu geometry */
96 int hasicon; /* whether the menu has item with icons */
97 int drawn; /* whether the menu was already drawn */
98 int maxtextw; /* maximum text width */
99 unsigned level; /* menu level relative to root */
100 Window win; /* menu window to map on the screen */
101};