Rev 3329 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2693 | Serge | 1 | |
3334 | Serge | 2 | #include |
2693 | Serge | 3 | #include |
4 | #include |
||
5 | #include "winlib.h" |
||
6 | |||
7 | |||
8 | |||
9 | |||
10 | extern int res_caption_right[]; |
||
11 | extern int res_caption_body[]; |
||
12 | |||
13 | |||
14 | extern int res_close_btn_hl[]; |
||
15 | extern int res_close_btn_pressed[]; |
||
16 | |||
17 | |||
18 | extern int res_minimize_btn_hl[]; |
||
19 | extern int res_minimize_btn_pressed[]; |
||
20 | |||
21 | |||
3329 | Serge | 22 | extern int res_full_btn_hl[]; |
23 | extern int res_full_btn_pressed[]; |
||
24 | |||
25 | |||
3068 | serge | 26 | |
27 | |||
2693 | Serge | 28 | |
29 | |||
30 | |||
31 | |||
32 | |||
33 | { |
||
34 | button_t *btn; |
||
35 | |||
36 | |||
37 | ctx_t *ctx = &cpt->ctx; |
||
38 | |||
39 | |||
40 | list_initialize(&cpt->ctrl.child); |
||
41 | |||
42 | |||
43 | cpt->ctrl.parent = (ctrl_t*)win; |
||
44 | |||
45 | |||
3068 | serge | 46 | |
47 | |||
3248 | Serge | 48 | cpt->bitmap.height = CAPTION_HEIGHT; |
49 | cpt->bitmap.flags = 0; |
||
50 | |||
51 | |||
52 | { |
||
2693 | Serge | 53 | printf("not enough memory for caption bitmap\n"); |
54 | return 0; |
||
55 | } |
||
3248 | Serge | 56 | |
2693 | Serge | 57 | |
3248 | Serge | 58 | |
2693 | Serge | 59 | ctx->pixmap = &cpt->bitmap; |
3248 | Serge | 60 | ctx->offset_x = 0; |
2693 | Serge | 61 | ctx->offset_y = 0; |
62 | |||
63 | |||
64 | |||
65 | |||
3329 | Serge | 66 | cpt->close_btn = btn; |
2693 | Serge | 67 | |
68 | |||
69 | btn->img_hilite = res_close_btn_hl; |
||
70 | btn->img_pressed = res_close_btn_pressed; |
||
71 | |||
72 | |||
3329 | Serge | 73 | cpt->minimize_btn = btn; |
2693 | Serge | 74 | |
75 | |||
76 | btn->img_hilite = res_minimize_btn_hl; |
||
77 | btn->img_pressed = res_minimize_btn_pressed; |
||
78 | |||
79 | |||
3334 | Serge | 80 | cpt->full_btn = btn; |
3329 | Serge | 81 | |
82 | |||
83 | btn->img_hilite = res_full_btn_hl; |
||
84 | btn->img_pressed = res_full_btn_pressed; |
||
85 | |||
86 | |||
2693 | Serge | 87 | |
88 | |||
89 | }; |
||
90 | |||
91 | |||
92 | |||
93 | { |
||
94 | caption_t *cpt = &win->caption; |
||
95 | bitmap_t *bitmap = cpt->ctx.pixmap; |
||
3248 | Serge | 96 | |
2693 | Serge | 97 | |
98 | int new_size; |
||
99 | int pitch; |
||
3248 | Serge | 100 | |
2693 | Serge | 101 | |
3248 | Serge | 102 | old_size = (old_size+4095) & ~4095; |
2693 | Serge | 103 | |
104 | |||
3248 | Serge | 105 | |
2693 | Serge | 106 | |
3248 | Serge | 107 | new_size = (new_size+4095) & ~4095; |
2693 | Serge | 108 | |
109 | |||
110 | user_unmap(bitmap->data, new_size, old_size-new_size); |
||
3248 | Serge | 111 | |
2693 | Serge | 112 | |
3248 | Serge | 113 | bitmap->pitch = pitch; |
114 | |||
2693 | Serge | 115 | |
116 | cpt->ctrl.rc.t = 0; |
||
117 | cpt->ctrl.rc.r = win->w; |
||
118 | cpt->ctrl.rc.b = CAPTION_HEIGHT; |
||
119 | cpt->ctrl.w = win->w; |
||
120 | cpt->ctrl.h = CAPTION_HEIGHT; |
||
121 | win->client.t = CAPTION_HEIGHT; |
||
122 | |||
123 | |||
3329 | Serge | 124 | cpt->close_btn->ctrl.rc.r = cpt->close_btn->ctrl.rc.l + |
3068 | serge | 125 | cpt->close_btn->ctrl.w; |
126 | |||
2693 | Serge | 127 | |
3329 | Serge | 128 | cpt->minimize_btn->ctrl.rc.r = cpt->minimize_btn->ctrl.rc.l + |
3068 | serge | 129 | cpt->minimize_btn->ctrl.w; |
130 | |||
2693 | Serge | 131 | |
3329 | Serge | 132 | cpt->full_btn->ctrl.rc.r = cpt->full_btn->ctrl.rc.l + |
133 | cpt->full_btn->ctrl.w; |
||
134 | |||
135 | |||
2693 | Serge | 136 | |
137 | |||
138 | |||
3068 | serge | 139 | |
140 | |||
2693 | Serge | 141 | { |
142 | int *pixmap, *src; |
||
143 | rect_t rc; |
||
3248 | Serge | 144 | int i, j, w; |
2693 | Serge | 145 | |
146 | |||
3248 | Serge | 147 | CAPTION_CORNER_W, CAPTION_HEIGHT, CAPTION_CORNER_W*4); |
148 | |||
2693 | Serge | 149 | |
150 | if( w > 0) |
||
151 | { |
||
152 | pixmap = (int*)cpt->ctx.pixmap->data; |
||
3248 | Serge | 153 | pixmap+= CAPTION_CORNER_W; |
2693 | Serge | 154 | src = res_caption_body; |
155 | |||
156 | |||
157 | { |
||
158 | for(j = 0; j < w; j++) |
||
159 | pixmap[j] = src[i]; |
||
160 | pixmap+= cpt->ctx.pixmap->pitch/4; |
||
3248 | Serge | 161 | } |
2693 | Serge | 162 | |
163 | |||
3248 | Serge | 164 | // w, CAPTION_HEIGHT, 0); |
165 | |||
2693 | Serge | 166 | |
167 | |||
168 | |||
3068 | serge | 169 | |
3248 | Serge | 170 | CAPTION_CORNER_W, CAPTION_HEIGHT,CAPTION_CORNER_W*4); |
171 | |||
3068 | serge | 172 | |
3248 | Serge | 173 | rc.t = 0; |
174 | rc.r = cpt->ctrl.w - 27 - 18 - 18 - 5 - 5 - 8; |
||
3329 | Serge | 175 | rc.b = 18; |
3248 | Serge | 176 | |
177 | |||
178 | |||
3068 | serge | 179 | |
2693 | Serge | 180 | child = (ctrl_t*)cpt->ctrl.child.next; |
181 | |||
182 | |||
183 | { |
||
184 | send_message(child, 1, 0, 0); |
||
185 | child = (ctrl_t*)child->link.next; |
||
186 | }; |
||
187 | }; |
||
188 | |||
189 | |||
190 | |||
191 | { |
||
192 | caption_t *cpt = (caption_t*)ctrl; |
||
193 | window_t *win = (window_t*)ctrl->parent; |
||
194 | |||
195 | |||
196 | int x, y; |
||
197 | |||
198 | |||
199 | y = ((pos_t)arg2).y; |
||
200 | |||
201 | |||
202 | { |
||
203 | case 1: |
||
204 | break; |
||
205 | |||
206 | |||
207 | |||
208 | child = get_child(ctrl, x, y); |
||
209 | if( win->child_over ) |
||
210 | { |
||
211 | if(child == win->child_over) |
||
212 | send_message(child, msg, 0, arg2); |
||
213 | else |
||
214 | send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2); |
||
215 | }; |
||
3068 | serge | 216 | |
2693 | Serge | 217 | |
218 | if( child ) |
||
219 | { |
||
3068 | serge | 220 | send_message(child, MSG_MOUSEENTER, 0, arg2); |
221 | send_message(child,msg,0,arg2); |
||
2693 | Serge | 222 | } |
3068 | serge | 223 | else if(main_cursor != 0) |
224 | { |
||
225 | set_cursor(0); |
||
226 | main_cursor = 0; |
||
227 | } |
||
228 | break; |
||
2693 | Serge | 229 | |
230 | |||
231 | |||
232 | switch((short)arg1) |
||
233 | { |
||
234 | case ID_CLOSE: |
||
235 | win->win_command = WIN_CLOSED; |
||
236 | break; |
||
237 | |||
238 | |||
239 | __asm__ __volatile__( |
||
240 | "int $0x40" |
||
241 | ::"a"(18),"b"(10)); |
||
242 | win->win_state = MINIMIZED; |
||
3292 | Serge | 243 | send_message((ctrl_t*)win, MSG_SIZE, 0, 0); |
244 | break; |
||
2693 | Serge | 245 | case ID_FULLSCREEN: |
3334 | Serge | 246 | { |
247 | int screensize; |
||
248 | |||
249 | |||
250 | __asm__ __volatile__( |
||
251 | "int $0x40" |
||
252 | ::"a"(67), "b"(0), "c"(0), |
||
253 | "d"((screensize >> 16)-1),"S"((screensize & 0xFFFF)-1) ); |
||
254 | win->win_state = FULLSCREEN; |
||
255 | window_update_layout(win); |
||
256 | }; |
||
257 | break; |
||
258 | |||
259 | |||
2693 | Serge | 260 | break; |
261 | }; |
||
262 | |||
263 | |||
264 | child = get_child(ctrl, x, y); |
||
265 | if(child) |
||
266 | return send_message(child, msg, 0, arg2); |
||
267 | } |
||
268 | return 1; |
||
269 | }; |
||
270 | |||
271 | |||
272 | |||
273 | |||
274 | { |
||
275 | // printf("%s w:%d h:%d stride: %d\n",__FUNCTION__, |
||
276 | // cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride); |
||
277 | |||
278 | |||
3248 | Serge | 279 | cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.pixmap->pitch); |
280 | };>>> |
||
2693 | Serge | 281 |