Rev 5372 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4438 | Serge | 1 | #ifndef __CONTROL_H__ |
2 | #define __CONTROL_H_ |
||
3 | |||
4 | #include |
||
5 | #include "link.h" |
||
6 | |||
7 | typedef struct |
||
8 | { |
||
9 | int l; |
||
10 | int t; |
||
11 | int r; |
||
12 | int b; |
||
13 | }rect_t; |
||
14 | |||
15 | typedef struct ctx |
||
16 | { |
||
17 | bitmap_t *pixmap; |
||
18 | int offset_x; |
||
19 | int offset_y; |
||
20 | }ctx_t; |
||
21 | |||
22 | ctx_t *get_window_ctx(); |
||
23 | |||
24 | typedef struct tag_control ctrl_t; |
||
25 | |||
26 | typedef int (handler_t)(ctrl_t*, uint32_t, uint32_t, uint32_t); |
||
27 | |||
28 | struct tag_control |
||
29 | { |
||
30 | link_t link; |
||
31 | link_t child; |
||
32 | |||
33 | handler_t *handler; |
||
34 | ctrl_t *parent; |
||
35 | |||
36 | ctx_t *ctx; |
||
37 | uint32_t id; |
||
38 | uint32_t style; |
||
39 | |||
40 | rect_t rc; |
||
41 | int w; |
||
42 | int h; |
||
43 | }; |
||
44 | |||
45 | |||
46 | typedef struct timer |
||
47 | { |
||
48 | link_t link; |
||
49 | ctrl_t *ctrl; |
||
50 | uint32_t exp_time; /* expiration time */ |
||
51 | uint32_t tmr_arg; /* random argument */ |
||
52 | } ostimer_t; |
||
53 | |||
54 | |||
55 | typedef struct |
||
56 | { |
||
57 | ctrl_t ctrl; |
||
58 | |||
59 | uint32_t state; |
||
60 | ostimer_t timer; |
||
61 | |||
62 | char *caption; |
||
63 | int capt_len; |
||
64 | |||
65 | void *img_default; |
||
66 | void *img_hilite; |
||
67 | void *img_pressed; |
||
68 | }button_t; |
||
69 | |||
70 | typedef struct |
||
71 | { |
||
72 | ctrl_t ctrl; |
||
73 | float min; |
||
74 | float max; |
||
75 | float current; |
||
76 | int pos; |
||
77 | }progress_t; |
||
78 | |||
79 | typedef struct |
||
80 | { |
||
81 | ctrl_t ctrl; |
||
82 | int min; |
||
83 | int max; |
||
84 | int current; |
||
85 | int pos; |
||
86 | int vol; |
||
87 | int visible; |
||
88 | void *img_level; |
||
89 | }level_t; |
||
90 | |||
91 | typedef struct |
||
92 | { |
||
93 | ctrl_t ctrl; |
||
94 | int min; |
||
95 | int max; |
||
96 | int current; |
||
97 | int pos; |
||
98 | int mode; |
||
99 | void *img_slider; |
||
100 | void *img_vol_slider; |
||
101 | }slider_t; |
||
102 | |||
103 | typedef struct |
||
104 | { |
||
105 | link_t link; |
||
106 | link_t child; |
||
107 | |||
108 | handler_t *handler; |
||
109 | ctrl_t *parent; |
||
110 | |||
111 | ctx_t *ctx; |
||
112 | uint32_t id; |
||
113 | uint32_t style; |
||
114 | |||
115 | rect_t rc; |
||
116 | int w; |
||
117 | int h; |
||
118 | |||
119 | uint32_t state; |
||
120 | |||
121 | int pix_range; |
||
122 | |||
123 | int min_range; |
||
124 | int max_range; |
||
125 | int page_size; |
||
126 | int thumb_pos; |
||
127 | |||
128 | rect_t tl_rect; |
||
129 | rect_t br_rect; |
||
130 | |||
131 | button_t *btn_up; |
||
132 | button_t *btn_down; |
||
133 | button_t *thumb; |
||
134 | }scroller_t; |
||
135 | |||
136 | #define bPressed 2 |
||
137 | #define bHighlight 1 |
||
138 | |||
139 | #define MSG_PAINT 0x001 |
||
140 | #define MSG_KEY 0x002 |
||
141 | #define MSG_BUTTON 0x003 |
||
142 | #define MSG_DRAW_CLIENT 0x004 |
||
143 | |||
144 | #define MSG_LBTNDOWN 0x010 |
||
145 | #define MSG_LBTNUP 0x011 |
||
146 | #define MSG_RBTNDOWN 0x012 |
||
147 | #define MSG_RBTNUP 0x013 |
||
148 | #define MSG_MBTNDOWN 0x014 |
||
149 | #define MSG_MBTNUP 0x015 |
||
150 | #define MSG_WHEELDOWN 0x016 |
||
151 | #define MSG_WHEELUP 0x017 |
||
152 | |||
153 | #define MSG_LBTNDBLCLK 0x018 |
||
154 | |||
155 | #define MSG_MOUSEMOVE 0x019 |
||
156 | #define MSG_MOUSEENTER 0x01A |
||
157 | #define MSG_MOUSELEAVE 0x01B |
||
158 | |||
159 | #define MSG_SIZE 0x020 |
||
160 | |||
161 | #define MSG_COMMAND 0x030 |
||
162 | #define MSG_TIMER 0x031 |
||
163 | |||
164 | #define LBN_DBLCLK 0x100 |
||
165 | #define LBOX_READDIR 0x100 |
||
166 | #define LBOX_GETFILENAME 0x101 |
||
167 | |||
168 | #define PRG_PROGRESS 0x102 |
||
169 | |||
170 | #define ID_CLOSE 1 |
||
171 | #define ID_MINIMIZE 2 |
||
172 | #define ID_FULLSCREEN 3 |
||
173 | |||
174 | #define ID_SCROLLER_UP 10 |
||
175 | #define ID_SCROLLER_DOWN 11 |
||
176 | #define ID_SCROLLER_THUMB 12 |
||
177 | |||
178 | #define send_message( ctrl, msg, arg1, arg2) \ |
||
179 | (ctrl)->handler( (ctrl_t*)(ctrl), \ |
||
180 | (uint32_t)(msg), (uint32_t)(arg1), (uint32_t)(arg2)) |
||
181 | |||
182 | static inline handler_t *subclass_control(ctrl_t *ctrl, handler_t *handler) |
||
183 | { |
||
184 | handler_t *old = ctrl->handler; |
||
185 | ctrl->handler = handler; |
||
186 | return old; |
||
187 | }; |
||
188 | |||
189 | //int inline send_message(ctrl_t *ctrl, u32_t msg, u32_t arg1, u32_t arg2) |
||
190 | //{ |
||
191 | // return ctrl->handler(ctrl, msg, arg1, arg2); |
||
192 | //}; |
||
193 | |||
194 | static inline int pt_in_rect(rect_t *rc, int x, int y) |
||
195 | { |
||
196 | if( (x >= rc->l) && (x < rc->r) && |
||
197 | (y >= rc->t) && (y < rc->b) ) |
||
198 | return 1; |
||
199 | return 0; |
||
200 | }; |
||
201 | |||
202 | ctrl_t *get_child(ctrl_t *ctrl, int x, int y); |
||
203 | |||
204 | ctrl_t *capture_mouse(ctrl_t *newm); |
||
205 | |||
206 | void blit_raw(ctx_t *ctx, void *raw, int x, int y, int w, int h, int pitch); |
||
207 | |||
208 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
||
209 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
||
210 | |||
211 | |||
212 | #endif>> |