Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1176 | andrew_pro | 1 | /* |
2 | control ScrolledWindow |
||
3 | */ |
||
4 | |||
5 | |||
6 | //////////////////////////////////////////////////////////////////////// |
||
7 | // pack controls in ScrolledWindow |
||
8 | //////////////////////////////////////////////////////////////////////// |
||
9 | void ScrolledWindowPackControls(void *parent,void *Control) |
||
10 | { |
||
11 | struct HEADER *control; |
||
12 | struct ControlScrolledWindow *ScrolledWindow; |
||
13 | struct ControlScrollBar *HorizontalScrollBar; |
||
14 | struct ControlScrollBar *VerticalScrollBar; |
||
15 | struct FINITION *fin; |
||
16 | int x,y; |
||
17 | |||
18 | ScrolledWindow=(struct ControlScrolledWindow*)parent; |
||
19 | control=(struct HEADER *)Control; |
||
20 | |||
21 | if (control->ctrl_x+control->ctrl_sizex>ScrolledWindow->virtual_sizex) |
||
22 | { |
||
23 | ScrolledWindow->virtual_sizex=control->ctrl_x+control->ctrl_sizex; |
||
24 | } |
||
25 | if (control->ctrl_y+control->ctrl_sizey>ScrolledWindow->virtual_sizey) |
||
26 | { |
||
27 | ScrolledWindow->virtual_sizey=control->ctrl_y+control->ctrl_sizey; |
||
28 | } |
||
29 | |||
30 | PackControls(ScrolledWindow,control); |
||
31 | |||
32 | //calculate new control coordinates |
||
33 | x=control->ctrl_x+1;//add border width |
||
34 | y=control->ctrl_y+1;//add border heght |
||
35 | SetControlNewPosition(control,x,y); |
||
36 | |||
37 | //save coordinates of control in arrea |
||
38 | ScrolledWindow->virtual_controls_x[ScrolledWindow->number_virtual_controls]=x; |
||
39 | ScrolledWindow->virtual_controls_y[ScrolledWindow->number_virtual_controls]=y; |
||
40 | ScrolledWindow->number_virtual_controls++; |
||
41 | |||
42 | x=ScrolledWindow->ctrl_x+1; |
||
43 | y=ScrolledWindow->ctrl_y+1; |
||
44 | |||
45 | //check cross control with scroll arrea |
||
46 | if (CheckCrossRectangles(x,y,ScrolledWindow->scroll_arrea_sizex,ScrolledWindow->scroll_arrea_sizey, |
||
47 | control->ctrl_x,control->ctrl_y,control->ctrl_sizex,control->ctrl_sizey)==TRUE) |
||
48 | { |
||
49 | control->flags=control->flags | FLAG_SHOW_CONTROL; |
||
50 | control->flags=control->flags & FLAG_MOUSE_BLOCKED_OFF; |
||
51 | } |
||
52 | else |
||
53 | { |
||
54 | control->flags=control->flags & FLAG_HIDE_CONTROL; |
||
55 | control->flags=control->flags | FLAG_MOUSE_BLOCKED_ON; |
||
56 | } |
||
57 | |||
58 | if (ScrolledWindow->virtual_sizex>ScrolledWindow->scroll_arrea_sizex) |
||
59 | { |
||
60 | HorizontalScrollBar=(struct ControlScrollBar*)ScrolledWindow->horizontal_scroll; |
||
61 | |||
62 | if ((ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_HORIZONTAL_SCROLL_ON)==FALSE) |
||
63 | { |
||
64 | ScrolledWindow->scroll_arrea_sizey=ScrolledWindow->ctrl_sizey-16-2; |
||
65 | ScrolledWindow->scw_flags=ScrolledWindow->scw_flags | FLAG_SCROLL_WIN_HORIZONTAL_SCROLL_ON; |
||
66 | HorizontalScrollBar->flags=HorizontalScrollBar->flags | FLAG_SHOW_CONTROL; |
||
67 | HorizontalScrollBar->flags=HorizontalScrollBar->flags & FLAG_MOUSE_BLOCKED_OFF; |
||
68 | } |
||
69 | } |
||
70 | |||
71 | if (ScrolledWindow->virtual_sizey>ScrolledWindow->scroll_arrea_sizey) |
||
72 | { |
||
73 | VerticalScrollBar=(struct ControlScrollBar*)ScrolledWindow->vertical_scroll; |
||
74 | |||
75 | if ((ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_VERTICAL_SCROLL_ON)==FALSE) |
||
76 | { |
||
77 | ScrolledWindow->scroll_arrea_sizex=ScrolledWindow->ctrl_sizex-16-2; |
||
78 | ScrolledWindow->scw_flags=ScrolledWindow->scw_flags | FLAG_SCROLL_WIN_VERTICAL_SCROLL_ON; |
||
79 | VerticalScrollBar->flags=VerticalScrollBar->flags | FLAG_SHOW_CONTROL; |
||
80 | VerticalScrollBar->flags=VerticalScrollBar->flags & FLAG_MOUSE_BLOCKED_OFF; |
||
81 | } |
||
82 | } |
||
83 | |||
84 | if (ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_HORIZONTAL_SCROLL_ON) |
||
85 | { |
||
86 | HorizontalScrollBar->ruller_size=(float)ScrolledWindow->scroll_arrea_sizex; |
||
87 | HorizontalScrollBar->ruller_size=HorizontalScrollBar->ruller_size/((float)ScrolledWindow->virtual_sizex); |
||
88 | } |
||
89 | |||
90 | if (ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_VERTICAL_SCROLL_ON) |
||
91 | { |
||
92 | VerticalScrollBar->ruller_size=(float)ScrolledWindow->scroll_arrea_sizey; |
||
93 | VerticalScrollBar->ruller_size=VerticalScrollBar->ruller_size/((float)ScrolledWindow->virtual_sizey); |
||
94 | } |
||
95 | |||
96 | //finit draw arrea for control |
||
97 | fin=(struct FINITION*)control->finition; |
||
98 | fin->x=ScrolledWindow->ctrl_x+1; |
||
99 | fin->y=ScrolledWindow->ctrl_y+1; |
||
100 | fin->sizex=ScrolledWindow->scroll_arrea_sizex; |
||
101 | fin->sizey=ScrolledWindow->scroll_arrea_sizey; |
||
102 | fin->flags=fin->flags | FINITION_ON; |
||
103 | |||
104 | } |
||
105 | //////////////////////////////////////////////////////////////////////////////// |
||
106 | // Draw full Scrolled Window |
||
107 | //////////////////////////////////////////////////////////////////////////////// |
||
108 | void ScrollWin_FuncCallback_HVScroll(struct HEADER* control,void *data) |
||
109 | { |
||
110 | struct ControlScrollBar *Hscrollbar,*Vscrollbar; |
||
111 | struct ControlScrolledWindow *ScrolledWindow; |
||
112 | struct HEADER *seek_control,*exchange_control; |
||
113 | struct MESSAGE local_message; |
||
114 | struct FINITION *fin; |
||
115 | int i,new_x,new_y,x,y,sizex,sizey; |
||
116 | char c; |
||
117 | char *save_buf,*buf; |
||
118 | int save_size_x,save_size_y; |
||
119 | DWORD draw_output; |
||
120 | |||
121 | ScrolledWindow=(gui_scrolled_window_t*)data; |
||
122 | Hscrollbar=(gui_scroll_bar_t*)ScrolledWindow->horizontal_scroll; |
||
123 | Vscrollbar=(gui_scroll_bar_t*)ScrolledWindow->vertical_scroll; |
||
124 | ScrolledWindow->virtual_x=(ScrolledWindow->virtual_sizex-ScrolledWindow->scroll_arrea_sizex)*Hscrollbar->ruller_pos; |
||
125 | ScrolledWindow->virtual_y=(ScrolledWindow->virtual_sizey-ScrolledWindow->scroll_arrea_sizey)*Vscrollbar->ruller_pos; |
||
126 | |||
127 | x=ScrolledWindow->ctrl_x+1; |
||
128 | y=ScrolledWindow->ctrl_y+1; |
||
129 | sizex=ScrolledWindow->scroll_arrea_sizex; |
||
130 | sizey=ScrolledWindow->scroll_arrea_sizey; |
||
131 | |||
132 | //alocate a buffer for draw text |
||
133 | c=screen.bits_per_pixel >> 3; |
||
134 | i=sizex*sizey*c; |
||
135 | buf=malloc(i); |
||
136 | |||
137 | //save current screen parameters |
||
138 | save_buf=screen.buffer; |
||
139 | save_size_x=screen.size_x; |
||
140 | save_size_y=screen.size_y; |
||
141 | draw_output=screen.draw_output; |
||
142 | |||
143 | //load parameters of local buffer |
||
144 | screen.buffer=buf; |
||
145 | screen.size_x=sizex; |
||
146 | screen.size_y=sizey; |
||
147 | screen.draw_output=DRAW_OUTPUT_BUFFER; |
||
148 | |||
149 | //fill buffer by background color |
||
150 | FillArrea(buf,i,screen.bits_per_pixel,COLOR_LIGHT); |
||
151 | |||
152 | local_message.type=MESSAGE_FULL_REDRAW_ALL_WITH_FINITION; |
||
153 | local_message.arg1=0; |
||
154 | local_message.arg2=0; |
||
155 | local_message.arg3=sizex; |
||
156 | local_message.arg4=sizey; |
||
157 | |||
158 | seek_control=(struct HEADER*)Vscrollbar->ctrl_fd; |
||
159 | //move controls in new position |
||
160 | for(i=0;i |
||
161 | { |
||
162 | new_x=ScrolledWindow->virtual_controls_x[i]-ScrolledWindow->virtual_x; |
||
163 | new_y=ScrolledWindow->virtual_controls_y[i]-ScrolledWindow->virtual_y; |
||
164 | |||
165 | SetControlNewPosition(seek_control,new_x,new_y); |
||
166 | |||
167 | if (CheckCrossRectangles(x,y,sizex,sizey,new_x,new_y, |
||
168 | seek_control->ctrl_sizex, |
||
169 | seek_control->ctrl_sizey)==TRUE) |
||
170 | { |
||
171 | seek_control->flags=seek_control->flags | FLAG_SHOW_CONTROL; |
||
172 | seek_control->flags=seek_control->flags & FLAG_MOUSE_BLOCKED_OFF; |
||
173 | |||
174 | //move control |
||
175 | SetControlNewPosition(seek_control,new_x-x,new_y-y); |
||
176 | //call draw control in buffer |
||
177 | ControlProc=(void (*)(void *Control,struct MESSAGE *message))seek_control->ctrl_proc; |
||
178 | ControlProc(seek_control,&local_message); |
||
179 | //restore last position of control |
||
180 | SetControlNewPosition(seek_control,new_x,new_y); |
||
181 | //restore coordinates of last finition of control |
||
182 | fin=(finition_t*)seek_control->finition; |
||
183 | fin->x=x; |
||
184 | fin->y=y; |
||
185 | } |
||
186 | else |
||
187 | { |
||
188 | seek_control->flags=seek_control->flags & FLAG_HIDE_CONTROL; |
||
189 | seek_control->flags=seek_control->flags | FLAG_MOUSE_BLOCKED_ON; |
||
190 | } |
||
191 | |||
192 | exchange_control=(struct HEADER*)seek_control->ctrl_fd; |
||
193 | seek_control=exchange_control; |
||
194 | } |
||
195 | //restore screen parameters |
||
196 | screen.buffer=save_buf; |
||
197 | screen.size_x=save_size_x; |
||
198 | screen.size_y=save_size_y; |
||
199 | screen.draw_output=draw_output; |
||
200 | |||
201 | //move rendered objects from local buffer to screen |
||
202 | fin=(finition_t*)ScrolledWindow->finition; |
||
203 | if (fin->flags & FINITION_ON) |
||
204 | DrawImageFinit(fin,x,y,sizex,sizey,screen.bits_per_pixel,buf); |
||
205 | else |
||
206 | DrawImage(x,y,sizex,sizey,screen.bits_per_pixel,buf); |
||
207 | |||
208 | //free local buffer |
||
209 | free(buf); |
||
210 | } |
||
211 | |||
212 | void DrawScrolledWindow(struct ControlScrolledWindow *ScrolledWindow) |
||
213 | { |
||
214 | int x,y,sizex,sizey; |
||
215 | struct FINITION *fin; |
||
216 | |||
217 | x=ScrolledWindow->ctrl_x; |
||
218 | y=ScrolledWindow->ctrl_y; |
||
219 | sizex=ScrolledWindow->ctrl_sizex; |
||
220 | sizey=ScrolledWindow->ctrl_sizey; |
||
221 | fin=(struct FINITION*)ScrolledWindow->finition; |
||
222 | |||
223 | if ((ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_HORIZONTAL_SCROLL_ON) || |
||
224 | (ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_VERTICAL_SCROLL_ON)) |
||
225 | { |
||
226 | Draw(fin,TOOL_RECTANGLE,x,y,ScrolledWindow->scroll_arrea_sizex+2, |
||
227 | ScrolledWindow->scroll_arrea_sizey+2,COLOR_ABSOLUTE_DARK); |
||
228 | } |
||
229 | else |
||
230 | Draw(fin,TOOL_RECTANGLE,x,y,sizex,sizey,COLOR_ABSOLUTE_DARK); |
||
231 | |||
232 | ScrollWin_FuncCallback_HVScroll(NULL,ScrolledWindow); |
||
233 | } |
||
234 | |||
235 | void ScrlWinCheckActivatedForKeysControl(struct ControlScrolledWindow *ScrolledWindow) |
||
236 | { |
||
237 | struct HEADER *control,*seek_control,*exchange_control; |
||
238 | struct MESSAGE local_message; |
||
239 | struct FINITION *fin; |
||
240 | struct ControlScrollBar *Vscrollbar,*Hscrollbar; |
||
241 | int i,x,y,sizex,sizey; |
||
242 | int sx,sy; |
||
243 | |||
244 | control=(struct HEADER*)ScrolledWindow->active_control_for_keys; |
||
245 | |||
246 | x=ScrolledWindow->ctrl_x+1; |
||
247 | y=ScrolledWindow->ctrl_y+1; |
||
248 | sizex=ScrolledWindow->scroll_arrea_sizex; |
||
249 | sizey=ScrolledWindow->scroll_arrea_sizey; |
||
250 | |||
251 | if (CheckFullCrossRectangles(x,y,sizex,sizey, |
||
252 | control->ctrl_x,control->ctrl_y,control->ctrl_sizex,control->ctrl_sizey)==TRUE) return; |
||
253 | |||
254 | //calculate new x and y coordinates |
||
255 | if (ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_HORIZONTAL_SCROLL_ON) |
||
256 | { |
||
257 | sx=(control->ctrl_x-x); |
||
258 | |||
259 | if (sx<0) sx=x; |
||
260 | else |
||
261 | { |
||
262 | if (control->ctrl_sizex |
||
263 | else sx=x; |
||
264 | } |
||
265 | } |
||
266 | |||
267 | if (ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_VERTICAL_SCROLL_ON) |
||
268 | { |
||
269 | sy=(control->ctrl_y-y); |
||
270 | |||
271 | if (sy<0) sy=y; |
||
272 | else |
||
273 | { |
||
274 | if (control->ctrl_sizey |
||
275 | else sy=y; |
||
276 | } |
||
277 | } |
||
278 | |||
279 | Vscrollbar=(struct ControlScrollBar*)ScrolledWindow->vertical_scroll; |
||
280 | Hscrollbar=(struct ControlScrollBar*)ScrolledWindow->horizontal_scroll; |
||
281 | //find active control and virtual control coordinates |
||
282 | seek_control=(struct HEADER*)Vscrollbar->ctrl_fd; |
||
283 | |||
284 | for(i=0;i |
||
285 | { |
||
286 | if (seek_control==control) |
||
287 | { |
||
288 | if (ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_HORIZONTAL_SCROLL_ON) |
||
289 | ScrolledWindow->virtual_x=ScrolledWindow->virtual_controls_x[i]-sx; |
||
290 | if (ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_VERTICAL_SCROLL_ON) |
||
291 | ScrolledWindow->virtual_y=ScrolledWindow->virtual_controls_y[i]-sy; |
||
292 | break; |
||
293 | } |
||
294 | |||
295 | exchange_control=(struct HEADER*)seek_control->ctrl_fd; |
||
296 | seek_control=exchange_control; |
||
297 | } |
||
298 | |||
299 | if (ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_HORIZONTAL_SCROLL_ON) |
||
300 | { |
||
301 | Hscrollbar->ruller_pos=(float)ScrolledWindow->virtual_x; |
||
302 | Hscrollbar->ruller_pos=Hscrollbar->ruller_pos/((float)(ScrolledWindow->virtual_sizex-ScrolledWindow->scroll_arrea_sizex)); |
||
303 | SpecialRedrawControl(Hscrollbar); |
||
304 | } |
||
305 | if (ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_VERTICAL_SCROLL_ON) |
||
306 | { |
||
307 | Vscrollbar->ruller_pos=(float)ScrolledWindow->virtual_y; |
||
308 | Vscrollbar->ruller_pos=Vscrollbar->ruller_pos/((float)(ScrolledWindow->virtual_sizey-ScrolledWindow->scroll_arrea_sizey)); |
||
309 | SpecialRedrawControl(Vscrollbar); |
||
310 | } |
||
311 | ScrollWin_FuncCallback_HVScroll(NULL,ScrolledWindow); |
||
312 | } |
||
313 | |||
314 | //--------------------------------------------------------------------------------- |
||
315 | // control ScrolledWindowScrolledWindow->virtual_sizex |
||
316 | //--------------------------------------------------------------------------------- |
||
317 | void ScrolledWindowProc(struct ControlScrolledWindow *ScrolledWindow,struct MESSAGE *message) |
||
318 | { |
||
319 | int i,x,y,sizex,sizey; |
||
320 | struct HEADER *seek_control,*exchange_control; |
||
321 | struct ControlScrollBar *Hscrollbar,*Vscrollbar; |
||
322 | struct MESSAGE local_message; |
||
323 | struct FINITION *fin; |
||
324 | struct TIMER *timer; |
||
325 | |||
326 | x=ScrolledWindow->ctrl_x; |
||
327 | y=ScrolledWindow->ctrl_y; |
||
328 | sizex=ScrolledWindow->ctrl_sizex; |
||
329 | sizey=ScrolledWindow->ctrl_sizey; |
||
330 | |||
331 | switch(message->type) |
||
332 | { |
||
333 | case MESSAGE_FULL_REDRAW_ALL: |
||
334 | { |
||
335 | //draw ScrolledWindow |
||
336 | if (ScrolledWindow->flags & FLAG_SHOW_CONTROL) |
||
337 | { |
||
338 | DrawScrolledWindow(ScrolledWindow); |
||
339 | Hscrollbar=(gui_scroll_bar_t*)ScrolledWindow->horizontal_scroll; |
||
340 | Vscrollbar=(gui_scroll_bar_t*)ScrolledWindow->vertical_scroll; |
||
341 | //draw scroll bars |
||
342 | ControlProc=(void (*)(void *Control,gui_message_t *message))Hscrollbar->ctrl_proc; |
||
343 | ControlProc(Hscrollbar,message); |
||
344 | ControlProc=(void (*)(void *Control,gui_message_t *message))Vscrollbar->ctrl_proc; |
||
345 | ControlProc(Vscrollbar,message); |
||
346 | } |
||
347 | break; |
||
348 | } |
||
349 | case MESSAGE_FULL_REDRAW_ALL_WITH_FINITION: |
||
350 | { |
||
351 | fin=(struct FINITION*)ScrolledWindow->finition; |
||
352 | fin->flags=fin->flags | FINITION_ON; |
||
353 | fin->x=message->arg1; |
||
354 | fin->y=message->arg2; |
||
355 | fin->sizex=message->arg3; |
||
356 | fin->sizey=message->arg4; |
||
357 | DrawScrolledWindow(ScrolledWindow); |
||
358 | SendMessage((struct HEADER*)ScrolledWindow,message);//<<<<<<---------------------------------- |
||
359 | break; |
||
360 | } |
||
361 | case MESSAGE_SPECIALIZED: |
||
362 | { |
||
363 | if (ScrolledWindow->flags & FLAG_SHOW_CONTROL) SendMessage((struct HEADER*)ScrolledWindow,message); |
||
364 | ScrolledWindow->flags=ScrolledWindow->flags & FLAG_GET_SPECIALIZED_MESSAGE_OFF; |
||
365 | break; |
||
366 | } |
||
367 | |||
368 | case MESSAGE_KEYS_EVENT: |
||
369 | { |
||
370 | if (ScrolledWindow->active_control_for_keys!=NULL) ScrlWinCheckActivatedForKeysControl(ScrolledWindow); |
||
371 | SendMessage((struct HEADER*)ScrolledWindow,message); |
||
372 | break; |
||
373 | } |
||
374 | case MESSAGE_MOUSE_EVENT: |
||
375 | { |
||
376 | SendMessage((struct HEADER*)ScrolledWindow,message); |
||
377 | break; |
||
378 | } |
||
379 | case MESSAGE_CHANGE_POSITION_EVENT: |
||
380 | { |
||
381 | ScrolledWindow->ctrl_x=ScrolledWindow->ctrl_x+message->arg1; |
||
382 | ScrolledWindow->ctrl_y=ScrolledWindow->ctrl_y+message->arg2; |
||
383 | |||
384 | //change virtual coordinates of controls |
||
385 | Vscrollbar=(struct ControlScrollBar*)ScrolledWindow->vertical_scroll; |
||
386 | seek_control=(struct HEADER *)Vscrollbar->ctrl_fd; |
||
387 | for(i=0;i |
||
388 | { |
||
389 | ScrolledWindow->virtual_controls_x[i]+=message->arg1; |
||
390 | ScrolledWindow->virtual_controls_y[i]+=message->arg2; |
||
391 | |||
392 | fin=(struct FINITION*)seek_control->finition; |
||
393 | fin->x=ScrolledWindow->ctrl_x+1; |
||
394 | fin->y=ScrolledWindow->ctrl_y+1; |
||
395 | fin->sizex=ScrolledWindow->scroll_arrea_sizex; |
||
396 | fin->sizey=ScrolledWindow->scroll_arrea_sizey; |
||
397 | |||
398 | exchange_control=(struct HEADER*)seek_control->ctrl_fd; |
||
399 | seek_control=exchange_control; |
||
400 | } |
||
401 | |||
402 | SendMessage((struct HEADER*)ScrolledWindow,message); |
||
403 | break; |
||
404 | } |
||
405 | case MESSAGE_CALL_TIMER_EVENT: |
||
406 | { |
||
407 | if (ScrolledWindow->timer!=(DWORD*)NULL) |
||
408 | { |
||
409 | timer=(struct TIMER*)ScrolledWindow->timer; |
||
410 | if (timer->flags & FLAG_TIMER_ON) Timer(timer); |
||
411 | } |
||
412 | SendMessage((struct HEADER*)ScrolledWindow,message); |
||
413 | break; |
||
414 | } |
||
415 | case MESSAGE_SET_FOCUSE: |
||
416 | { |
||
417 | //SendMessage((struct HEADER*)ScrolledWindow,message); |
||
418 | break; |
||
419 | } |
||
420 | case MESSAGE_CHANGE_FOCUSE: |
||
421 | { |
||
422 | //SendMessage((struct HEADER*)ScrolledWindow,message); |
||
423 | break; |
||
424 | } |
||
425 | case MESSAGE_DESTROY_CONTROL: |
||
426 | { |
||
427 | if (ScrolledWindow->timer!=(DWORD*)NULL) free(ScrolledWindow->timer); |
||
428 | free(ScrolledWindow->finition); |
||
429 | SendMessage((struct HEADER*)ScrolledWindow,message); |
||
430 | break; |
||
431 | } |
||
432 | case MESSAGE_SET_MAIN_PARENT: |
||
433 | { |
||
434 | SendMessage((struct HEADER*)ScrolledWindow,message); |
||
435 | ScrolledWindow->main_parent=(DWORD*)message->arg1; |
||
436 | break; |
||
437 | } |
||
438 | |||
439 | default: break; |
||
440 | } |
||
441 | } |
||
442 | |||
443 | //--------------------------------------------------------------------------------- |
||
444 | // create control ScrolledWindow |
||
445 | //--------------------------------------------------------------------------------- |
||
446 | void* CreateScrolledWindow(struct ScrolledWindowData *info_for_control) |
||
447 | { |
||
448 | struct ControlScrolledWindow *ScrolledWindow; |
||
449 | struct FINITION *fin; |
||
450 | struct ControlScrollBar *HorizontalScrollBar; |
||
451 | struct ControlScrollBar *VerticalScrollBar; |
||
452 | struct ScrollBarData HorizontalScrollData; |
||
453 | struct ScrollBarData VerticalScrollData; |
||
454 | |||
455 | |||
456 | ScrolledWindow=malloc(sizeof(struct ControlScrolledWindow)); |
||
457 | ScrolledWindow->finition=malloc(sizeof(struct FINITION)); |
||
458 | fin=(struct FINITION*)ScrolledWindow->finition; |
||
459 | fin->flags=0; |
||
460 | ScrolledWindow->scw_flags=0; |
||
461 | |||
462 | ID++; |
||
463 | #ifdef DEBUG |
||
464 | printf("\ncreated scrollet window with ID=%d",(int)ID); |
||
465 | #endif |
||
466 | ScrolledWindow->child_bk=(DWORD*)NULL; |
||
467 | ScrolledWindow->child_fd=(DWORD*)NULL; |
||
468 | ScrolledWindow->active_control_for_keys=(DWORD*)NULL; |
||
469 | ScrolledWindow->active_control_for_mouse=(DWORD*)NULL; |
||
470 | ScrolledWindow->callback=(DWORD*)NULL; |
||
471 | ScrolledWindow->timer=(DWORD*)NULL; |
||
472 | |||
473 | ScrolledWindow->ctrl_proc=(DWORD*)&ScrolledWindowProc; |
||
474 | ScrolledWindow->ctrl_x=(DWORD)info_for_control->x; |
||
475 | ScrolledWindow->ctrl_y=(DWORD)info_for_control->y; |
||
476 | ScrolledWindow->ctrl_sizex=(DWORD)info_for_control->width; |
||
477 | ScrolledWindow->ctrl_sizey=(DWORD)info_for_control->height; |
||
478 | ScrolledWindow->ctrl_ID=ID; |
||
479 | ScrolledWindow->virtual_x=0; |
||
480 | ScrolledWindow->virtual_y=0; |
||
481 | ScrolledWindow->virtual_controls_x=malloc(1024*sizeof(DWORD)); |
||
482 | ScrolledWindow->virtual_controls_y=malloc(1024*sizeof(DWORD)); |
||
483 | ScrolledWindow->virtual_sizex=0; |
||
484 | ScrolledWindow->virtual_sizey=0; |
||
485 | ScrolledWindow->number_virtual_controls=0; |
||
486 | ScrolledWindow->flags=0; |
||
487 | ScrolledWindow->flags=ScrolledWindow->flags | FLAG_SHOW_CONTROL; |
||
488 | ScrolledWindow->flags=ScrolledWindow->flags | FLAG_FOCUSE_INPUT_SUPPOROTE; |
||
489 | |||
490 | //calculate default scroll arrea size |
||
491 | ScrolledWindow->scroll_arrea_sizex=ScrolledWindow->ctrl_sizex-2; |
||
492 | ScrolledWindow->scroll_arrea_sizey=ScrolledWindow->ctrl_sizey-2; |
||
493 | |||
494 | //create child scroll bars |
||
495 | HorizontalScrollData.x=0; |
||
496 | HorizontalScrollData.y=ScrolledWindow->ctrl_sizey-16; |
||
497 | HorizontalScrollData.width=ScrolledWindow->ctrl_sizex-16; |
||
498 | HorizontalScrollData.height=16; |
||
499 | HorizontalScrollData.ruller_size=1.0; |
||
500 | HorizontalScrollData.ruller_pos=0.0; |
||
501 | HorizontalScrollData.ruller_step=0.05; |
||
502 | |||
503 | VerticalScrollData.x=ScrolledWindow->ctrl_sizex-16; |
||
504 | VerticalScrollData.y=0; |
||
505 | VerticalScrollData.width=16; |
||
506 | VerticalScrollData.height=ScrolledWindow->ctrl_sizey-16; |
||
507 | VerticalScrollData.ruller_size=1.0; |
||
508 | VerticalScrollData.ruller_pos=0.0; |
||
509 | VerticalScrollData.ruller_step=0.05; |
||
510 | |||
511 | HorizontalScrollBar=CreateHorizontalScrollBar(&HorizontalScrollData); |
||
512 | VerticalScrollBar=CreateVerticalScrollBar(&VerticalScrollData); |
||
513 | |||
514 | SetCallbackFunction(HorizontalScrollBar,SCROLLBAR_CHANGED_EVENT,&ScrollWin_FuncCallback_HVScroll,ScrolledWindow); |
||
515 | SetCallbackFunction(VerticalScrollBar,SCROLLBAR_CHANGED_EVENT,&ScrollWin_FuncCallback_HVScroll,ScrolledWindow); |
||
516 | |||
517 | PackControls(ScrolledWindow,HorizontalScrollBar); |
||
518 | PackControls(ScrolledWindow,VerticalScrollBar); |
||
519 | |||
520 | ScrolledWindow->horizontal_scroll=(DWORD*)HorizontalScrollBar; |
||
521 | ScrolledWindow->vertical_scroll=(DWORD*)VerticalScrollBar; |
||
522 | //disable show scrollers and block mouse for them |
||
523 | HorizontalScrollBar->flags=HorizontalScrollBar->flags & FLAG_HIDE_CONTROL; |
||
524 | HorizontalScrollBar->flags=HorizontalScrollBar->flags | FLAG_MOUSE_BLOCKED_ON; |
||
525 | VerticalScrollBar->flags=VerticalScrollBar->flags & FLAG_HIDE_CONTROL; |
||
526 | VerticalScrollBar->flags=VerticalScrollBar->flags | FLAG_MOUSE_BLOCKED_ON; |
||
527 | |||
528 | return(ScrolledWindow); |
||
529 | }---------------------------------- |
||
530 |