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