add alignment
[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
15/* color enum */
16enum {ColorFG, ColorBG, ColorLast};
17
18/* EWMH atoms */
19enum {NetWMName, NetWMWindowType, NetWMWindowTypePopupMenu, NetLast};
20
21/* configuration structure */
22struct Config {
23 /* the values below are set by config.h */
24 const char *font;
25 const char *background_color;
26 const char *foreground_color;
27 const char *selbackground_color;
28 const char *selforeground_color;
29 const char *separator_color;
30 const char *border_color;
31 int width_pixels;
32 int height_pixels;
33 int border_pixels;
34 int separator_pixels;
35 int gap_pixels;
36 int triangle_width;
37 int triangle_height;
38 int iconpadding;
39 int horzpadding;
40 int alignment;
41
42 /* the values below are set by options */
43 int monitor;
44 int posx, posy; /* rootmenu position */
45
46 /* the value below is computed by xmenu */
47 int iconsize;
48};
49
50/* draw context structure */
51struct DC {
52 XftColor normal[ColorLast];
53 XftColor selected[ColorLast];
54 XftColor border;
55 XftColor separator;
56
57 GC gc;
58
59 FcPattern *pattern;
60 XftFont **fonts;
61 size_t nfonts;
62};
63
64/* menu item structure */
65struct Item {
66 char *label; /* string to be drawed on menu */
67 char *output; /* string to be outputed when item is clicked */
68 char *file; /* filename of the icon */
69 int y; /* item y position relative to menu */
70 int h; /* item height */
71 int textw; /* text width */
72 struct Item *prev; /* previous item */
73 struct Item *next; /* next item */
74 struct Menu *submenu; /* submenu spawned by clicking on item */
75 Drawable sel, unsel; /* pixmap for selected and unselected item */
76 Imlib_Image icon;
77};
78
79/* monitor geometry structure */
80struct Monitor {
81 int x, y, w, h; /* monitor geometry */
82};
83
84/* menu structure */
85struct Menu {
86 struct Menu *parent; /* parent menu */
87 struct Item *caller; /* item that spawned the menu */
88 struct Item *list; /* list of items contained by the menu */
89 struct Item *selected; /* item currently selected in the menu */
90 int x, y, w, h; /* menu geometry */
91 int hasicon; /* whether the menu has item with icons */
92 int drawn; /* whether the menu was already drawn */
93 int maxtextw; /* maximum text width */
94 unsigned level; /* menu level relative to root */
95 Window win; /* menu window to map on the screen */
96};