Subversion Repositories Kolibri OS

Rev

Rev 648 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
648 andrew_pro 1
;****************************************************************
2
;***************Elements of menegment for Controls***************
3
;****************************************************************
4
 
5
;**********************************************************
6
;********************craete control*************************
7
;**********************************************************
8
 
9
;IN
10
;eax - ctructure's size
11
;ebx - Parend(pointer to structure for parend)
12
;OUT
13
;eax - pointer to new control
14
 
15
craete_control:
16
 
17
      test eax,eax
18
      jnz no_null_size
19
 
20
        mov eax,1
21
      no_null_size:
22
 
23
      call malloc
24
      mov [ReturnControl],eax
25
 
26
      push ebx  ;parend
27
      push eax  ;control
28
      call  AddObject
29
 
30
      mov eax,[ReturnControl]
31
 
32
      ;information about craete control output to debug board
33
      call new_line
34
      mov [s_p],s_craete
35
      call print_string
36
      debug_print_dec [ReturnControl]
37
      mov [s_p],s_parend
38
      call print_string
39
      debug_print_dec dword[eax+20]
40
      mov [s_p],s_last
41
      call print_string
42
      debug_print_dec dword[eax+4]
43
      ;--------------------------------
44
 
45
      ret
46
 
47
AddObject:
48
 
49
      mov ecx,[esp+4] ;control
50
      mov edx,[esp+8] ;parend
51
 
52
      mov eax,[edx+12]  ;eax=parend->child_fd
53
      test eax,eax
54
      jnz else_parend_add_object
55
 
56
        add [ControlID],1
57
        mov esi,[ControlID]
58
 
59
        mov [edx+12],ecx   ;Parend->child_fd=control
60
        mov [edx+16],ecx   ;Parend->child_bk=control
61
 
62
        mov [ecx+20],edx   ;control->parend=Parend
63
        mov [ecx+4],edx    ;control->ctrl_fd=Parend
64
        mov [ecx+40],esi   ;control->ctrl_ID=ID
65
 
66
      jmp exit_if_parend_add_object
67
      else_parend_add_object:
68
 
69
        add [ControlID],1
70
        mov esi,[ControlID]
71
 
72
        mov edi,[edx+16]   ;last_control=Parend->child_bk
73
        mov [edx+16],ecx   ;Parend->child_bk=control
74
 
75
        mov [edi+8],ecx    ;last_control->ctrl_bk=control
76
        mov [ecx+4],edi    ;control->ctrl_fd=last_control;
77
        mov [ecx+20],edx   ;control->parend=Parend;
78
        mov [ecx+40],esi   ;control->ctrl_ID=ID
79
 
80
      exit_if_parend_add_object:
81
 
82
      ret 8
83
 
84
 
85
;************************************************************
86
;***********************Destroy control**********************
87
;************************************************************
88
 
89
;Delete Control.
90
;IN
91
;pointer to control for delete
92
;OUT
93
;not returned value
94
align 4
95
 
96
destroy_control:
97
 
710 andrew_pro 98
      push eax
99
      push ebx
100
      push ecx
101
      push edx
102
      push esi
103
      push edi
104
      push ebp
648 andrew_pro 105
 
710 andrew_pro 106
      mov eax,[esp+28+4]
107
 
648 andrew_pro 108
      mov ebx,[eax+20] ;get parend for control
109
 
110
      ;checking pointer of control to 0
111
      test eax,eax
112
      jz exit_destroy_control
113
 
114
      ;checking parend to main parend(parend of window)
115
      ;if parend equ main parend than exit
116
      test ebx,ebx
117
      jz exit_destroy_control
118
 
119
      mov ecx,[ebx+12] ;Parend->child_fd
120
      test ecx,ecx
121
      jz exit_destroy_control
122
 
123
         mov ecx,[ebx+12]    ;Parend->child_fd
124
         mov edx,[ebx+16]    ;Parend->child_bk
125
 
126
         cmp ecx,edx
127
         jne no_if_parend_child_fd_child_bk
128
 
129
            cmp ecx,eax
130
            jne no_if_parend_child_fd_control
131
 
132
              mov [ebx+12],dword 0  ;Parend->child_fd=0
133
              mov [ebx+16],dword 0  ;Parend->child_bk=0
134
 
135
              ;send message to control for deleting
136
              push eax
137
 
138
              mov [Message],dword -1
139
              mov ebx,[eax] ;load .... for control
140
              push Message
141
              push eax
142
              call ebx
143
 
144
              pop eax
145
 
146
               push eax
147
               call free
148
               pop eax
149
 
150
               call new_line
151
               mov [s_p],s_destroy
152
               call print_string
153
               debug_print_dec eax
154
               mov [s_p],s_1
155
               call print_string
156
 
157
              jmp exit_destroy_control
158
            no_if_parend_child_fd_control:
159
 
160
         no_if_parend_child_fd_child_bk:
161
      ;----------------------------------------------
162
        mov esi,ecx    ;seek_control=Parend->child_fd
163
 
164
        while_seek_control:
165
        cmp esi,0
166
        je exit_destroy_control
167
        ;*******************************************************************
168
            cmp esi,eax
169
            jne no_if_seek_control_control
170
            ;***************************************************************
171
                mov edi,[esi+8]
172
                test edi,edi
173
                jz no_if_seek_control_ctrl_bk
174
                ;***********************************************************
175
                    mov ecx,[esi+4]
176
                    mov edx,[esi+8]
177
                    mov [edx+4],ecx
178
 
179
                    cmp ecx,ebx
180
                    je no_if_last_control_parend
181
                    ;*******************************************************
182
                       mov [ecx+8],edx
183
                       jmp else_seek_control_ctrl_bk
184
                    ;*******************************************************
185
                    no_if_last_control_parend:
186
 
187
                       mov [ebx+12],edx
188
 
189
                  jmp else_seek_control_ctrl_bk
190
                  ;*********************************************************
191
                no_if_seek_control_ctrl_bk:
192
                ;**********************************************************
193
 
194
                    mov ecx,[esi+4]      ;last_control=seek_control->ctrl_fd
195
                    mov [ecx+8],dword 0   ;last_control->ctrl_bk=0
196
                    mov [ebx+16],ecx     ;Parend->child_bk=last_control
197
 
198
                else_seek_control_ctrl_bk:
199
                ;**********************************************************
200
 
201
                 ;send message to control for deleting
202
                 push eax
203
 
204
                 mov [Message],dword -1
205
                 mov ebx,[eax] ;load .... for control
206
                 push Message
207
                 push eax
208
                 call ebx
209
 
210
                 pop eax
211
 
212
                 push eax
213
                 call free
214
                 pop eax
215
 
216
                 call new_line
217
                 mov [s_p],s_destroy
218
                 call print_string
219
                 debug_print_dec eax
220
                 mov [s_p],s_2
221
                 call print_string
222
 
223
                 jmp exit_destroy_control
224
 
225
            no_if_seek_control_control:
226
            ;****************************************************************
227
 
228
            mov edi,[esi+8]   ;exchange_control=seek_control->ctrl_bk
229
            mov esi,edi       ;seek_control=exchange_control
230
 
231
        jmp  while_seek_control
232
        ;*******************************************************************
233
      exit_destroy_control:
234
 
710 andrew_pro 235
      pop ebp
236
      pop edi
237
      pop esi
238
      pop edx
239
      pop ecx
240
      pop ebx
241
      pop eax
242
 
648 andrew_pro 243
      ret 4
244
 
245
;***********************************************************
246
;*****************Send message to Control*******************
247
;***********************************************************
248
 
249
;IN
250
;pointer to message
251
;pointer to parend(structure)
252
;OUT
253
;not returned value
254
align 4
255
 
256
send_message:
257
 
710 andrew_pro 258
      push eax
259
      push ebx
260
      push ecx
261
      push edx
262
      push esi
263
      push edi
264
      push ebp
265
 
648 andrew_pro 266
      ;get pointer to parend
710 andrew_pro 267
      mov eax,[esp+28+4]
648 andrew_pro 268
      mov [Parend],eax
269
 
270
      ;get message
710 andrew_pro 271
      mov esi,[esp+28+8]
648 andrew_pro 272
      mov edi,dword Message
273
      mov ecx,4
274
      rep movsd
275
 
276
      ;load event type
277
      mov eax,[Message]
278
 
279
 
280
      ;check for event type and get parameters for Control
281
      dec eax
282
      jnz no_window_redraw
283
 
284
        mov ebx,[Parend]
285
        mov esi,[ebx+12]  ;get pointer to first child control of parend
286
        mov ebx,esi
287
 
288
        send_message_for_redraw_to_next_control:
289
 
290
          ;if esi=0 than exit
291
          test esi,esi
292
          jz exit_check_event_type
293
 
294
            push ebx
295
            push esi
296
 
297
            mov eax,ebx
298
            mov ebx,[eax] ;load .... for control
299
            push Message
300
            push eax
301
            call ebx
302
 
303
            pop esi
304
            pop ebx
305
 
306
            mov esi,[ebx+8]
307
            mov ebx,esi
308
 
309
          jmp send_message_for_redraw_to_next_control
310
 
311
      no_window_redraw:
312
 
313
      dec eax
314
      jnz no_keys
315
 
316
 
317
        ;if have active control than send message
318
        ;checking for active control
319
      mov ebx,[ActiveControlForKeys]
320
      test ebx,ebx
321
      jz exit_check_event_type
322
 
323
        mov eax,[ActiveControlForKeys]
324
        mov ebx,[eax] ;load proc for control
325
        push Message
326
        push eax
327
        call ebx
328
 
329
      jmp exit_check_event_type
330
      no_keys:
331
 
332
      dec eax
333
      jnz no_special_system_message
334
 
335
        mov ebx,[Parend];
336
        mov esi,[ebx+12]
337
        mov ebx,esi
338
 
339
        send_special_message_to_next_control:
340
 
341
          ;if esi=0 than exit
342
          test esi,esi
343
          jz exit_check_event_type
344
 
345
            push ebx
346
            push esi
347
 
348
            mov eax,ebx
349
            mov ebx,[eax] ;load .... for control
350
            push Message
351
            push eax
352
            call ebx
353
 
354
            pop esi
355
            pop ebx
356
 
357
            mov esi,[ebx+8]
358
            mov ebx,esi
359
 
360
          jmp send_special_message_to_next_control
361
 
362
      no_special_system_message:
363
 
364
      ;*************************************************
365
      ;****************Mouse send message***************
366
      ;*************************************************
367
 
368
      cmp eax,3
369
      jne no_mouse
370
 
371
        ;check childrens of parend for crossing
372
        mov ebx,[Parend]
373
        mov esi,[ebx+12]    ;esi =first child control
374
        mov ebx,esi         ;ebx =first child control
375
 
376
          mov eax,[Message+12]
377
          and eax,1b
378
          test eax,eax
379
          jz left_button_of_mouse_not_pressed
380
 
381
                mov eax,[ActiveControl]
382
                test eax,eax
383
                jz havent_active_control
384
 
385
                        mov eax,[ActiveControl]
386
                        mov ebx,[eax] ;load proc for control
387
                        push Message
388
                        push eax
389
                        call ebx
390
 
391
                        jmp exit_check_event_type
392
                havent_active_control:
393
 
394
          jmp exit_if_left_button_of_mouse__pressed
395
          left_button_of_mouse_not_pressed:
396
 
397
                mov eax,[ActiveControl]
398
                test eax,eax
399
                jz havent_active_control_
400
 
401
                        mov [ActiveControl],dword 0
402
 
403
                havent_active_control_:
404
 
405
          exit_if_left_button_of_mouse__pressed:
406
 
407
 
408
        next_conrol_check_for_crossing_with_mouse:
409
 
410
          test esi,esi
411
          jz exit_next_conrol_check_for_crossing_with_mouse
412
 
413
          mov [PointerToControl],ebx
414
 
415
 
416
          push ebx
417
          push esi
418
 
419
          mov eax,[ebx+28]    ;eax = y coordinat of control
420
          mov [y_ctl],eax
421
          mov eax,[ebx+24]    ;eax = x coordinat of control
422
 
423
          mov ecx,[ebx+32]    ;ecx = size x of control
424
          mov edx,[ebx+36]    ;edx = size y of control
425
          mov esi,[Message+4] ;mouse x
426
          mov edi,[Message+8] ;mouse y
427
          mov ebx,[y_ctl]
428
 
429
          call CheckCrossingBox
430
 
431
          cmp eax,0xffffff
432
          jne no_activate_control
433
 
434
            mov eax,[Message+12]
435
            and eax,1b
436
            test eax,eax
437
            jz no_activate_control
438
 
439
               mov eax,[PointerToControl]
440
               mov [ActiveControl],eax
441
               mov [ActiveControlForKeys],eax
442
 
443
          no_activate_control:
444
 
445
            mov eax,[PointerToControl]
446
            mov ebx,[eax] ;load proc for control
447
            push Message
448
            push eax
449
            call ebx
450
 
451
          pop esi
452
          pop ebx
453
 
454
          mov esi,[ebx+8] ;16 but not 8
455
          mov ebx,esi
456
 
457
        jmp next_conrol_check_for_crossing_with_mouse
458
 
459
        exit_next_conrol_check_for_crossing_with_mouse:
460
 
461
      no_mouse:
462
 
463
      exit_check_event_type:
464
 
710 andrew_pro 465
      pop ebp
466
      pop edi
467
      pop esi
468
      pop edx
469
      pop ecx
470
      pop ebx
471
      pop eax
472
 
648 andrew_pro 473
      ret 8
474
 
475
 
476
new_line:
477
 
478
      pushad
479
 
480
      mov eax,63
481
      mov ebx,1
482
      xor ecx,ecx
483
      mov cl,13
484
      int 0x40
485
 
486
      mov eax,63
487
      mov ebx,1
488
      xor ecx,ecx
489
      mov cl,10
490
      int 0x40
491
 
492
      popad
493
 
494
      ret
495
 
496
print_string:
497
 
498
      pushad
499
 
500
      xor esi,esi
501
 
502
      next_symbol_print:
503
 
504
      mov edi,[s_p]
505
      add edi,esi
506
 
507
      xor edx,edx
508
      mov dl,byte[edi]
509
      test dl,dl
510
      jz exit_print_str
511
 
512
      mov eax,63
513
      mov ebx,1
514
      xor ecx,ecx
515
      mov cl,byte[edi]
516
      int 0x40
517
 
518
      inc esi
519
      jmp next_symbol_print
520
 
521
      exit_print_str:
522
 
523
      popad
524
 
525
 
526
      ret
527
 
528
s_p dd 0
529
s_craete  db 'craete ',0
530
s_destroy db 'destroy ',0
531
s_parend  db ' parend ',0
532
s_last    db ' ctrl_fd ',0
533
s_next    db ' ctrl_bk ',0
534
s_1       db ' 1',0
535
s_2       db ' 2',0