adding a bunch of code (vesa, keyb, mouse, etc) to the menu
[cdmenu] / menu / src / rtk_impl.h
1 #ifndef RTK_IMPL_H_
2 #define RTK_IMPL_H_
3
4 #include <assert.h>
5 #include "sizeint.h"
6 #include "rtk.h"
7
8 enum {
9         VISIBLE         = 0x0001,
10         ENABLED         = 0x0002,
11         HOVER           = 0x0010,
12         PRESS           = 0x0020,
13         FOCUS           = 0x0040,
14         GEOMCHG         = 0x0100,
15         DIRTY           = 0x0200,
16         CANFOCUS        = 0x0400,
17         AUTOWIDTH       = 0x1000,
18         AUTOHEIGHT      = 0x2000,
19
20         /* window flags */
21         FRAME           = RTK_WIN_FRAME << 16,
22         MOVABLE         = RTK_WIN_MOVABLE << 16,
23         RESIZABLE       = RTK_WIN_RESIZABLE << 16,
24
25         DBGRECT         = 0x40000000
26 };
27
28 #define WIDGET_COMMON \
29         int type; \
30         int x, y, width, height; \
31         int absx, absy; \
32         int pad; \
33         char *text; \
34         int value; \
35         unsigned int flags; \
36         struct rtk_window *par; \
37         rtk_widget *next; \
38         rtk_callback cbfunc, drawcb; \
39         void *cbcls, *drawcls; \
40         void *udata; \
41         rtk_key_callback on_key; \
42         rtk_mbutton_callback on_mbutton; \
43         rtk_click_callback on_click; \
44         rtk_drag_callback on_drag; \
45         rtk_drop_callback on_drop; \
46         rtk_screen *scr
47
48 typedef struct rtk_widget {
49         WIDGET_COMMON;
50 } rtk_widget;
51
52 typedef struct rtk_window {
53         WIDGET_COMMON;
54         rtk_widget *clist, *ctail;
55         int layout;
56 } rtk_window;
57
58 typedef struct rtk_button {
59         WIDGET_COMMON;
60         int mode;
61         rtk_icon *icon;
62 } rtk_button;
63
64 typedef struct rtk_textbox {
65         WIDGET_COMMON;
66         int cursor, scroll;
67         int len, bufsz;
68 } rtk_textbox;
69
70 typedef struct rtk_slider {
71         WIDGET_COMMON;
72         int vmin, vmax;
73 } rtk_slider;
74
75 typedef struct rtk_iconsheet {
76         int width, height;
77         uint32_t *pixels;
78
79         struct rtk_icon *icons;
80 } rtk_iconsheet;
81
82 #define MAX_WINDOWS     64
83
84 typedef struct rtk_screen {
85         rtk_widget *winlist[MAX_WINDOWS];
86         int num_win;
87         rtk_widget *hover, *focus;
88         rtk_window *focuswin;
89         int prev_mx, prev_my;
90
91         rtk_widget *press;                                      /* currently pressed widget */
92         int press_x, press_y;                           /* position of last mouse press */
93
94         rtk_widget *modal;              /* which window is currently modal (null if none) */
95 } rtk_screen;
96
97 #define RTK_ASSERT_TYPE(w, t)   assert(w->type == t)
98
99 extern rtk_draw_ops rtk_gfx;
100
101 void rtk_init_drawing(void);
102 void rtk_calc_widget_rect(rtk_widget *w, rtk_rect *rect);
103 void rtk_abs_pos(rtk_widget *w, int *xpos, int *ypos);
104 int rtk_hittest(rtk_widget *w, int x, int y);
105 void rtk_invalfb(rtk_widget *w);
106 void rtk_clearfb(rtk_widget *w);
107
108
109 #endif  /* RTK_IMPL_H_ */