Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  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.  
  98.       mov eax,[esp+4]
  99.  
  100.       mov ebx,[eax+20] ;get parend for control
  101.  
  102.       ;checking pointer of control to 0
  103.       test eax,eax
  104.       jz exit_destroy_control
  105.  
  106.       ;checking parend to main parend(parend of window)
  107.       ;if parend equ main parend than exit
  108.       test ebx,ebx
  109.       jz exit_destroy_control
  110.  
  111.       mov ecx,[ebx+12] ;Parend->child_fd
  112.       test ecx,ecx
  113.       jz exit_destroy_control
  114.  
  115.          mov ecx,[ebx+12]    ;Parend->child_fd
  116.          mov edx,[ebx+16]    ;Parend->child_bk
  117.  
  118.          cmp ecx,edx
  119.          jne no_if_parend_child_fd_child_bk
  120.  
  121.             cmp ecx,eax
  122.             jne no_if_parend_child_fd_control
  123.  
  124.               mov [ebx+12],dword 0  ;Parend->child_fd=0
  125.               mov [ebx+16],dword 0  ;Parend->child_bk=0
  126.  
  127.               ;send message to control for deleting
  128.               push eax
  129.  
  130.               mov [Message],dword -1
  131.               mov ebx,[eax] ;load .... for control
  132.               push Message
  133.               push eax
  134.               call ebx
  135.  
  136.               pop eax
  137.  
  138.                push eax
  139.                call free
  140.                pop eax
  141.  
  142.                call new_line
  143.                mov [s_p],s_destroy
  144.                call print_string
  145.                debug_print_dec eax
  146.                mov [s_p],s_1
  147.                call print_string
  148.  
  149.               jmp exit_destroy_control
  150.             no_if_parend_child_fd_control:
  151.  
  152.          no_if_parend_child_fd_child_bk:
  153.       ;----------------------------------------------
  154.         mov esi,ecx    ;seek_control=Parend->child_fd
  155.  
  156.         while_seek_control:
  157.         cmp esi,0
  158.         je exit_destroy_control
  159.         ;*******************************************************************
  160.             cmp esi,eax
  161.             jne no_if_seek_control_control
  162.             ;***************************************************************
  163.                 mov edi,[esi+8]
  164.                 test edi,edi
  165.                 jz no_if_seek_control_ctrl_bk
  166.                 ;***********************************************************
  167.                     mov ecx,[esi+4]
  168.                     mov edx,[esi+8]
  169.                     mov [edx+4],ecx
  170.  
  171.                     cmp ecx,ebx
  172.                     je no_if_last_control_parend
  173.                     ;*******************************************************
  174.                        mov [ecx+8],edx
  175.                        jmp else_seek_control_ctrl_bk
  176.                     ;*******************************************************
  177.                     no_if_last_control_parend:
  178.  
  179.                        mov [ebx+12],edx
  180.  
  181.                   jmp else_seek_control_ctrl_bk
  182.                   ;*********************************************************
  183.                 no_if_seek_control_ctrl_bk:
  184.                 ;**********************************************************
  185.  
  186.                     mov ecx,[esi+4]      ;last_control=seek_control->ctrl_fd
  187.                     mov [ecx+8],dword 0   ;last_control->ctrl_bk=0
  188.                     mov [ebx+16],ecx     ;Parend->child_bk=last_control
  189.  
  190.                 else_seek_control_ctrl_bk:
  191.                 ;**********************************************************
  192.  
  193.                  ;send message to control for deleting
  194.                  push eax
  195.  
  196.                  mov [Message],dword -1
  197.                  mov ebx,[eax] ;load .... for control
  198.                  push Message
  199.                  push eax
  200.                  call ebx
  201.  
  202.                  pop eax
  203.  
  204.                  push eax
  205.                  call free
  206.                  pop eax
  207.  
  208.                  call new_line
  209.                  mov [s_p],s_destroy
  210.                  call print_string
  211.                  debug_print_dec eax
  212.                  mov [s_p],s_2
  213.                  call print_string
  214.  
  215.                  jmp exit_destroy_control
  216.  
  217.             no_if_seek_control_control:
  218.             ;****************************************************************
  219.  
  220.             mov edi,[esi+8]   ;exchange_control=seek_control->ctrl_bk
  221.             mov esi,edi       ;seek_control=exchange_control
  222.  
  223.         jmp  while_seek_control
  224.         ;*******************************************************************
  225.       exit_destroy_control:
  226.  
  227.       ret 4
  228.  
  229. ;***********************************************************
  230. ;*****************Send message to Control*******************
  231. ;***********************************************************
  232.  
  233. ;IN
  234. ;pointer to message
  235. ;pointer to parend(structure)
  236. ;OUT
  237. ;not returned value
  238. align 4
  239.  
  240. send_message:
  241.  
  242.       ;get pointer to parend
  243.       mov eax,[esp+4]
  244.       mov [Parend],eax
  245.  
  246.       ;get message
  247.       mov esi,[esp+8]
  248.       mov edi,dword Message
  249.       mov ecx,4
  250.       rep movsd
  251.  
  252.       ;load event type
  253.       mov eax,[Message]
  254.  
  255.  
  256.       ;check for event type and get parameters for Control
  257.       dec eax
  258.       jnz no_window_redraw
  259.  
  260.         mov ebx,[Parend]
  261.         mov esi,[ebx+12]  ;get pointer to first child control of parend
  262.         mov ebx,esi
  263.  
  264.         send_message_for_redraw_to_next_control:
  265.  
  266.           ;if esi=0 than exit
  267.           test esi,esi
  268.           jz exit_check_event_type
  269.  
  270.             push ebx
  271.             push esi
  272.  
  273.             mov eax,ebx
  274.             mov ebx,[eax] ;load .... for control
  275.             push Message
  276.             push eax
  277.             call ebx
  278.  
  279.             pop esi
  280.             pop ebx
  281.  
  282.             mov esi,[ebx+8]
  283.             mov ebx,esi
  284.  
  285.           jmp send_message_for_redraw_to_next_control
  286.  
  287.       no_window_redraw:
  288.  
  289.       dec eax
  290.       jnz no_keys
  291.  
  292.  
  293.         ;if have active control than send message
  294.         ;checking for active control
  295.       mov ebx,[ActiveControlForKeys]
  296.       test ebx,ebx
  297.       jz exit_check_event_type
  298.  
  299.         mov eax,[ActiveControlForKeys]
  300.         mov ebx,[eax] ;load proc for control
  301.         push Message
  302.         push eax
  303.         call ebx
  304.  
  305.       jmp exit_check_event_type
  306.       no_keys:
  307.  
  308.       dec eax
  309.       jnz no_special_system_message
  310.  
  311.         mov ebx,[Parend];
  312.         mov esi,[ebx+12]
  313.         mov ebx,esi
  314.  
  315.         send_special_message_to_next_control:
  316.  
  317.           ;if esi=0 than exit
  318.           test esi,esi
  319.           jz exit_check_event_type
  320.  
  321.             push ebx
  322.             push esi
  323.  
  324.             mov eax,ebx
  325.             mov ebx,[eax] ;load .... for control
  326.             push Message
  327.             push eax
  328.             call ebx
  329.  
  330.             pop esi
  331.             pop ebx
  332.  
  333.             mov esi,[ebx+8]
  334.             mov ebx,esi
  335.  
  336.           jmp send_special_message_to_next_control
  337.  
  338.       no_special_system_message:
  339.  
  340.       ;*************************************************
  341.       ;****************Mouse send message***************
  342.       ;*************************************************
  343.  
  344.       cmp eax,3
  345.       jne no_mouse
  346.  
  347.         ;check childrens of parend for crossing
  348.         mov ebx,[Parend]
  349.         mov esi,[ebx+12]    ;esi =first child control
  350.         mov ebx,esi         ;ebx =first child control
  351.  
  352.           mov eax,[Message+12]
  353.           and eax,1b
  354.           test eax,eax
  355.           jz left_button_of_mouse_not_pressed
  356.  
  357.                 mov eax,[ActiveControl]
  358.                 test eax,eax
  359.                 jz havent_active_control
  360.  
  361.                         mov eax,[ActiveControl]
  362.                         mov ebx,[eax] ;load proc for control
  363.                         push Message
  364.                         push eax
  365.                         call ebx
  366.  
  367.                         jmp exit_check_event_type
  368.                 havent_active_control:
  369.  
  370.           jmp exit_if_left_button_of_mouse__pressed
  371.           left_button_of_mouse_not_pressed:
  372.  
  373.                 mov eax,[ActiveControl]
  374.                 test eax,eax
  375.                 jz havent_active_control_
  376.  
  377.                         mov [ActiveControl],dword 0
  378.  
  379.                 havent_active_control_:
  380.  
  381.           exit_if_left_button_of_mouse__pressed:
  382.  
  383.  
  384.         next_conrol_check_for_crossing_with_mouse:
  385.  
  386.           test esi,esi
  387.           jz exit_next_conrol_check_for_crossing_with_mouse
  388.  
  389.           mov [PointerToControl],ebx
  390.  
  391.  
  392.           push ebx
  393.           push esi
  394.  
  395.           mov eax,[ebx+28]    ;eax = y coordinat of control
  396.           mov [y_ctl],eax
  397.           mov eax,[ebx+24]    ;eax = x coordinat of control
  398.  
  399.           mov ecx,[ebx+32]    ;ecx = size x of control
  400.           mov edx,[ebx+36]    ;edx = size y of control
  401.           mov esi,[Message+4] ;mouse x
  402.           mov edi,[Message+8] ;mouse y
  403.           mov ebx,[y_ctl]
  404.  
  405.           call CheckCrossingBox
  406.  
  407.           cmp eax,0xffffff
  408.           jne no_activate_control
  409.  
  410.             mov eax,[Message+12]
  411.             and eax,1b
  412.             test eax,eax
  413.             jz no_activate_control
  414.  
  415.                mov eax,[PointerToControl]
  416.                mov [ActiveControl],eax
  417.                mov [ActiveControlForKeys],eax
  418.  
  419.           no_activate_control:
  420.  
  421.             mov eax,[PointerToControl]
  422.             mov ebx,[eax] ;load proc for control
  423.             push Message
  424.             push eax
  425.             call ebx
  426.  
  427.           pop esi
  428.           pop ebx
  429.  
  430.           mov esi,[ebx+8] ;16 but not 8
  431.           mov ebx,esi
  432.  
  433.         jmp next_conrol_check_for_crossing_with_mouse
  434.  
  435.         exit_next_conrol_check_for_crossing_with_mouse:
  436.  
  437.       no_mouse:
  438.  
  439.       exit_check_event_type:
  440.  
  441.       ret 8
  442.  
  443.  
  444. new_line:
  445.  
  446.       pushad
  447.  
  448.       mov eax,63
  449.       mov ebx,1
  450.       xor ecx,ecx
  451.       mov cl,13
  452.       int 0x40
  453.  
  454.       mov eax,63
  455.       mov ebx,1
  456.       xor ecx,ecx
  457.       mov cl,10
  458.       int 0x40
  459.  
  460.       popad
  461.  
  462.       ret
  463.  
  464. print_string:
  465.  
  466.       pushad
  467.  
  468.       xor esi,esi
  469.  
  470.       next_symbol_print:
  471.  
  472.       mov edi,[s_p]
  473.       add edi,esi
  474.  
  475.       xor edx,edx
  476.       mov dl,byte[edi]
  477.       test dl,dl
  478.       jz exit_print_str
  479.  
  480.       mov eax,63
  481.       mov ebx,1
  482.       xor ecx,ecx
  483.       mov cl,byte[edi]
  484.       int 0x40
  485.  
  486.       inc esi
  487.       jmp next_symbol_print
  488.  
  489.       exit_print_str:
  490.  
  491.       popad
  492.  
  493.  
  494.       ret
  495.  
  496. s_p dd 0
  497. s_craete  db 'craete ',0
  498. s_destroy db 'destroy ',0
  499. s_parend  db ' parend ',0
  500. s_last    db ' ctrl_fd ',0
  501. s_next    db ' ctrl_bk ',0
  502. s_1       db ' 1',0
  503. s_2       db ' 2',0