Subversion Repositories Kolibri OS

Rev

Rev 996 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
  4. ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
  5. ;; Distributed under terms of the GNU General Public License    ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 2971 $
  9.  
  10.  
  11. max_buttons=4095
  12. dececx:
  13.     push edx
  14.     push ecx
  15.  
  16.     mov  edx,2
  17.   .loop:
  18.  
  19.     cmp   byte [esp+edx],0x20
  20.     jae   @f
  21.     mov   [esp+edx],byte 0x20
  22.    @@:
  23.     sub   [esp+edx],byte 0x20
  24.  
  25.     dec  edx
  26.     jns  .loop
  27.  
  28.     pop  ecx
  29.     pop  edx
  30.     ret
  31.  
  32. incecx:
  33.     push edx
  34.     push ecx
  35.  
  36.     mov  edx,2
  37.   .loop:
  38.  
  39.     cmp  byte [esp+edx],0xdf
  40.     jbe  @f
  41.     mov  [esp+edx],byte 0xdf
  42.    @@:
  43.     add  [esp+edx],byte 0x20
  44.  
  45.     dec  edx
  46.     jns  .loop
  47.     pop  ecx
  48.     pop  edx
  49.     ret
  50.  
  51. incecx2:
  52.     push edx
  53.     push ecx
  54.  
  55.     mov  edx,2
  56.   .loop:
  57.  
  58.     cmp  byte [esp+edx],0xeb
  59.     jbe  @f
  60.     mov  [esp+edx],byte 0xeb
  61.    @@:
  62.     add  [esp+edx],byte 0x14
  63.  
  64.     dec  edx
  65.     jns  .loop
  66.     pop  ecx
  67.     pop  edx
  68.     ret
  69.  
  70. drawbuttonframes:
  71.  
  72.         push  esi
  73.         push  edi
  74.         push  eax
  75.         push  ebx
  76.         push  ecx
  77.         push  edx
  78.  
  79.         shr   ebx,16
  80.         shr   ecx,16
  81.         mov   eax,[TASK_BASE]
  82.  
  83.         add   ebx,[eax-twdw + WDATA.box.left]
  84.         add   ecx,[eax-twdw + WDATA.box.top]
  85.         mov     eax, ebx
  86.         shl     eax, 16
  87.         mov     ax, bx
  88.         add     ax, word [esp+8]
  89.         mov     ebx, ecx
  90.         shl     ebx, 16
  91.         mov     bx, cx
  92.         push    ebx
  93.         xor     edi, edi
  94.         mov     ecx, esi
  95.         call    incecx
  96.         call    [draw_line]
  97.  
  98.         movzx edx,word [esp+4+4]
  99.         add   ebx,edx
  100.         shl   edx,16
  101.         add   ebx,edx
  102.         mov   ecx,esi
  103.         call  dececx
  104.         call  [draw_line]
  105.  
  106.         pop     ebx
  107.         push  edx
  108.         mov   edx,eax
  109.         shr   edx,16
  110.         mov   ax,dx
  111.         mov   edx,ebx
  112.         shr   edx,16
  113.         mov   bx,dx
  114.         mov   dx,[esp+4+4]
  115.         add   bx,dx
  116.         pop   edx
  117.         mov   ecx,esi
  118.         call  incecx
  119.         call  [draw_line]
  120.  
  121.         mov   dx,[esp+8]
  122.         add   ax,dx
  123.         shl   edx,16
  124.         add   eax,edx
  125.         add   ebx,1*65536
  126.         mov   ecx,esi
  127.         call  dececx
  128.         call  [draw_line]
  129.  
  130.         pop   edx
  131.         pop   ecx
  132.         pop   ebx
  133.         pop   eax
  134.         pop   edi
  135.         pop   esi
  136.  
  137.         ret
  138.  
  139. button_dececx:
  140.  
  141.         cmp   [buttontype],dword 1
  142.         jne   .finish
  143. ;        je    bdece
  144. ;        ret
  145. ;      bdece:
  146.         push  eax
  147.         mov   eax,0x01
  148.         cmp   edi,20
  149.         jg    @f
  150.         mov   eax,0x02
  151.       @@:
  152.         test  ecx,0xff
  153.         jz    @f
  154.         sub   ecx,eax
  155.       @@:
  156.         shl   eax,8
  157.         test  ecx,0xff00
  158.         jz    @f
  159.         sub   ecx,eax
  160.       @@:
  161.         shl   eax,8
  162.         test  ecx,0xff0000
  163.         jz    @f
  164.         sub   ecx,eax
  165.       @@:
  166.         pop    eax
  167.       .finish:
  168.         ret
  169.  
  170.  
  171. sys_button:
  172.  
  173.         mov     eax, [current_slot]
  174.         rol     ebx, 16
  175.         add     bx, word [eax+APPDATA.wnd_clientbox.left]
  176.         rol     ebx, 16
  177.         rol     ecx, 16
  178.         add     cx, word [eax+APPDATA.wnd_clientbox.top]
  179.         rol     ecx, 16
  180. .forced:
  181.  
  182.         test    edx, 0x80000000
  183.         jnz     remove_button
  184.  
  185.         or      bx, bx
  186.         jle     noaddbutt
  187.         or      cx, cx
  188.         jle     noaddbutt
  189.  
  190.         test    edx, 0x40000000
  191.         jnz     button_no_draw
  192.  
  193.         pushad                       ; button body
  194.         movzx   edi, cx
  195.         shr     ebx, 16
  196.         shr     ecx, 16
  197.         mov     eax, [TASK_BASE]
  198.         add     ebx, [eax-twdw + WDATA.box.left]
  199.         add     ecx, [eax-twdw + WDATA.box.top]
  200.         mov     eax, ebx
  201.         shl     eax, 16
  202.         mov     ax, bx
  203.         add     ax, word [esp+16]
  204.         mov     ebx, ecx
  205.         shl     ebx, 16
  206.         mov     bx, cx
  207.         mov     ecx, esi
  208.         cmp     [buttontype], 0
  209.         je      @f
  210.         call    incecx2
  211. @@:
  212.         mov     edx, edi
  213.  
  214. .newline:
  215.         call    button_dececx
  216.         push    edi
  217.         xor     edi, edi
  218.         call    [draw_line]
  219.         pop     edi
  220.         add     ebx, 1*65536+1 ; [ y start | y end ]
  221.         dec     edx
  222.         jnz     .newline
  223.         popad
  224.  
  225.         call    drawbuttonframes
  226.  
  227. button_no_draw:
  228.  
  229.         push    edi
  230.         mov     edi, [btn_addr]
  231.         movzx   eax, word [edi]
  232.         cmp     eax, max_buttons
  233.         jge     noaddbutt
  234.         inc     eax
  235.         mov     [edi], ax
  236.  
  237.         shl     eax, 4
  238.         add     edi, eax
  239.  
  240.         mov     ax, [CURRENT_TASK]
  241.         stosw
  242.         mov     ax, dx
  243.         stosw               ; button id number: bits 0-15
  244.         mov     eax, ebx
  245.         rol     eax, 16
  246.         stosd               ; x start | x size
  247.         mov     eax, ecx
  248.         rol     eax, 16
  249.         stosd               ; y start | y size
  250.         mov     eax, edx
  251.         shr     eax, 16
  252.         stosw               ; button id number: bits 16-31
  253.  
  254.         pop     edi
  255.  
  256. noaddbutt:
  257.  
  258.         ret
  259.  
  260.  
  261. remove_button:
  262.  
  263.         and     edx, 0x7fffffff
  264.  
  265. rnewba2:
  266.  
  267.         mov     edi, [btn_addr]
  268.         mov     eax, edi
  269.         movzx   ebx, word [edi]
  270.         inc     ebx
  271.  
  272. rnewba:
  273.  
  274.         dec     ebx
  275.         jz      rnmba
  276.  
  277.         add     eax, 0x10
  278.  
  279.         mov     cx, [CURRENT_TASK]
  280.         cmp     cx, [eax]
  281.         jnz     rnewba
  282.         cmp     dx, [eax+2]
  283.         jnz     rnewba
  284.  
  285.         lea     ecx, [ebx+1]
  286.         shl     ecx, 4
  287.         mov     ebx, eax
  288.         add     eax, 0x10
  289.         call    memmove
  290.         dec     dword [edi]
  291.         jmp     rnewba2
  292.  
  293. rnmba:
  294.  
  295.         ret
  296.  
  297. find_pressed_button_frames:
  298.  
  299.         pushad
  300.  
  301.         movzx ebx,word [eax+0]
  302.         shl   ebx,5
  303.         add   ebx,window_data
  304.         mov   ecx, [ebx+ WDATA.box.left]     ; window x start
  305.         movzx edx,word [eax+4]     ; button x start
  306.         add   ecx,edx
  307.         push  ecx
  308.  
  309.         mov   dx,[eax+6]                 ; button x size
  310.         add   cx,dx
  311.         mov   esi,ecx
  312.         inc   esi
  313.         mov   ecx, [ebx+WDATA.box.top]   ; window y start
  314.         mov   dx,[eax+8]                 ; button y start
  315.         add   ecx,edx
  316.         mov   ebx,ecx
  317.                 mov   dx,[eax+10]                ; button y size
  318.         add   dx,cx
  319.         inc   dx
  320.  
  321.         pop   eax
  322.  
  323.         ; eax x beginning
  324.         ; ebx y beginning
  325.         ; esi x end
  326.         ; edx y end
  327.         ; ecx color
  328.  
  329.         mov   [pressed_button_eax],eax
  330.         mov   [pressed_button_ebx],ebx
  331.         mov   [pressed_button_ecx],ecx
  332.         mov   [pressed_button_edx],edx
  333.         mov   [pressed_button_esi],esi
  334.  
  335.         popad
  336.         ret
  337.  
  338. uglobal
  339.   pressed_button_eax  dd  0
  340.   pressed_button_ebx  dd  0
  341.   pressed_button_ecx  dd  0
  342.   pressed_button_edx  dd  0
  343.   pressed_button_esi  dd  0
  344. endg
  345.  
  346. ; negative button image
  347.  
  348. negativebutton:
  349.         ; If requested, do not display button
  350.         ; boarder on press.
  351.         test  ebx,0x20000000
  352.         jz    draw_negative_button
  353.         ret
  354.       draw_negative_button:
  355.  
  356.         pushad
  357.  
  358.         mov   eax,[pressed_button_eax]
  359.         mov   ebx,[pressed_button_ebx]
  360.         mov   ecx,[pressed_button_ecx]
  361.         mov   edx,[pressed_button_edx]
  362.         mov   esi,[pressed_button_esi]
  363.         mov   ecx,0x01000000
  364.  
  365.         dec   edx
  366.         push  edx
  367.         inc   edx
  368.         dec   esi
  369.         push  esi
  370.         inc   esi
  371.  
  372.         push  eax
  373.         push  ebx
  374.         push  ecx
  375.         push  edx
  376.         push  edi
  377.  
  378.         call  [disable_mouse]
  379.  
  380.       bdbnewline:
  381.         mov   edi,1    ; force
  382.         cmp   eax,[esp+16]
  383.         jz    bneg
  384.         cmp   eax,[esp+20]
  385.         jz    bneg
  386.         cmp   ebx,[esp+12]
  387.         jz    bneg
  388.         cmp   ebx,[esp+24]
  389.         jnz   nbneg
  390. ;        jz    bneg
  391. ;        jmp   nbneg
  392.  
  393.       bneg:
  394.  
  395.         ;;;call  [disable_mouse]
  396.         call  [putpixel]
  397.  
  398.       nbneg:
  399.  
  400.         inc   eax
  401.         cmp   eax,esi
  402.         jnz   bdbnewline
  403.         mov   eax,[esp+16]
  404.         inc   ebx
  405.         cmp   ebx,edx
  406.         jnz   bdbnewline
  407.  
  408.         add   esp,28
  409.  
  410.         popad
  411.  
  412.         ret
  413.  
  414. ; check buttons
  415.  
  416.  
  417. ; 0000 word process number
  418. ; 0002 word button id number : bits 0-15
  419. ; 0004 word x start
  420. ; 0006 word x size
  421. ; 0008 word y start
  422. ; 000A word y size
  423. ; 000C word button id number : bits 16-31
  424. ;
  425. ; button table in 0x10 increments
  426. ;
  427. ; first at 0x10
  428.  
  429.  
  430. checkbuttons:
  431.  
  432.     cmp   byte [btn_down], 0           ; mouse buttons pressed
  433.     jnz   @f
  434. ;..................................... start 1/5 : modified by vhanla .............................
  435.     mov [bPressedMouseXY_B],0
  436. ;..................................... end 1/5 : modified by vhanla .............................
  437.     ret
  438.   @@:
  439.     pushad
  440.  
  441.     xor    esi, esi
  442.     mov    edi, [btn_addr]
  443.     movzx  edx, word [edi]
  444.     test   edx, edx
  445.     jne    @f
  446.     popad
  447.     ret
  448.  
  449.   @@:
  450. ;..................................... start 2/5 : modified by vhanla .............................
  451.   ;here i catch the coordinates when the mouse's button is clicked
  452.    push eax
  453.    cmp [bPressedMouseXY_B],0;FALSE
  454.    jnz @f
  455.    mov [bPressedMouseXY_B],1;TRUE - it was already clicked
  456.    mov ax,[MOUSE_X]
  457.    mov [mx],ax
  458.    mov ax,[MOUSE_Y]
  459.    mov [my],ax
  460.    @@:
  461.    pop  eax
  462.    ;and it is only refreshed after the mouse's button release
  463. ;..................................... end 2/5 : modified by vhanla .............................
  464.  
  465.     push  esi
  466.     inc   edx
  467.     push  edx
  468.  
  469.   buttonnewcheck:
  470.  
  471.     pop   edx
  472.     pop   esi
  473.     inc   esi
  474.     cmp   edx,esi
  475.     jge   bch
  476.  
  477.     popad                 ; no button pressed
  478.     ret
  479.  
  480.   bch:
  481.  
  482.     push  esi
  483.     push  edx
  484.     mov   eax,esi
  485.     shl   eax,4
  486.     add   eax,edi
  487.  
  488.     ; check that button is at top of windowing stack
  489.  
  490.     movzx ebx,word [eax]
  491.     movzx ecx,word [WIN_STACK + ebx * 2]
  492.     cmp   ecx,[TASK_COUNT]
  493.     jne   buttonnewcheck
  494.  
  495.     ; check that button start is inside window x/y end
  496.  
  497.     movzx ebx,word [eax+0]
  498.     shl   ebx,5
  499.  
  500.         test    [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
  501.         jnz     buttonnewcheck
  502.  
  503. ;    add   ebx,window_data
  504. ;    mov   ecx,[window_data+ebx+8]          ; window end X
  505.     movzx edx,word [eax+4]     ; button start X
  506.     cmp   edx, [window_data+ebx+WDATA.box.width] ;ecx
  507.     jge   buttonnewcheck
  508.  
  509. ;    mov   ecx,[window_data+ebx+12]         ; window end Y
  510.     movzx edx, word [eax+8]    ; button start Y
  511.     cmp   edx, [window_data+ebx+WDATA.box.height] ;ecx
  512.     jge   buttonnewcheck
  513.  
  514.     ; check coordinates
  515.                                ; mouse x >= button x ?
  516.     movzx ebx,word [eax+0]
  517.     shl   ebx,5
  518.     add   ebx,window_data
  519.         mov   ecx, [ebx+WDATA.box.left]     ; window x start
  520.     movzx edx,word [eax+4]     ; button x start
  521.     add   edx,ecx
  522. ;..................................... start 3/5 : modified by vhanla .............................
  523.     mov   cx,[mx]   ;mov cx,[mouse_x]
  524. ;..................................... end 3/5 : modified by vhanla .............................
  525.     cmp   edx,ecx
  526.     jg    buttonnewcheck
  527.  
  528.     movzx ebx,word [eax+6]     ; button x size
  529.     add   edx,ebx
  530.     cmp   ecx,edx
  531.     jg    buttonnewcheck
  532.  
  533.                                ; mouse y >= button y ?
  534.     movzx ebx,word [eax+0]
  535.     shl   ebx,5
  536.     add   ebx,window_data
  537.         mov   ecx, [ebx+WDATA.box.top]     ; window y start
  538.     movzx edx,word [eax+8]     ; button y start
  539.     add   edx,ecx
  540. ;..................................... start 4/5 : modified by vhanla .............................
  541.     mov   cx,[my]  ;mov cx,[MOUSE_Y]
  542. ;..................................... start 4/5 : modified by vhanla .............................
  543.     cmp   edx,ecx
  544.     jg    buttonnewcheck
  545.  
  546.     movzx ebx,word [eax+10]    ; button y size
  547.     add   edx,ebx
  548.     cmp   ecx,edx
  549.     jg    buttonnewcheck
  550.  
  551.     ; mouse on button
  552.  
  553.     pop   edx
  554.     pop   esi
  555.  
  556.     mov   bx,[eax+0xc]     ; button id : bits 16-31
  557.     shl   ebx,16
  558.     mov   bx,[eax+2]                    ; button id : bits 00-16
  559.     push  ebx
  560.  
  561.     call find_pressed_button_frames
  562.     call negativebutton
  563.  
  564.     pushad
  565. ; // Alver 22.06.2008 // {
  566.     push  eax
  567.     mov  al, byte [btn_down]
  568.     mov  byte [btn_down_determ], al
  569.     pop  eax
  570. ; } \\ Alver \\
  571.  
  572.   cbwaitmouseup:
  573.  
  574.     call  checkidle
  575.  
  576.     call  [draw_pointer]
  577.  
  578.     pushad
  579.     call  stack_handler
  580.     popad
  581.  
  582.     cmp  byte [btn_down], 0      ; mouse buttons pressed ?
  583.     jnz   cbwaitmouseup
  584.     popad
  585.  
  586.     call  negativebutton
  587. ;..................................... start 5/5 : modified by vhanla .............................
  588.     ; check coordinates
  589. iglobal
  590.     mx dw 0x0 ; keeps the x mouse's position when it was clicked
  591.     my dw 0x0 ; keeps the y mouse's position when it was clicked
  592.     bPressedMouseXY_B   db 0x0
  593.     btn_down_determ     db 0x0        ; << // Alver 22.06.2008// <<
  594. endg
  595.  
  596.    pusha
  597.   ; mouse x >= button x ?
  598.    movzx ebx,word [eax+0]
  599.    shl   ebx,5
  600.    add   ebx,window_data
  601.    mov   ecx, [ebx+WDATA.box.left]    ; window x start
  602.    movzx edx,word [eax+4]    ; button x start
  603.    add   edx,ecx
  604.    mov   cx,[MOUSE_X]
  605.    cmp   edx,ecx
  606.    jg   no_on_button ;if we release the pointer out of the button area
  607.  
  608.    movzx ebx,word [eax+6]    ; button x size
  609.    add   edx,ebx
  610.    cmp   ecx,edx
  611.    jg   no_on_button
  612.  
  613.         ; mouse y >= button y ?
  614.    movzx ebx,word [eax+0]
  615.    shl   ebx,5
  616.    add   ebx,window_data
  617.    mov   ecx, [ebx+WDATA.box.top]    ; window y start
  618.    movzx edx,word [eax+8]    ; button y start
  619.    add   edx,ecx
  620.    mov   cx,[MOUSE_Y]
  621.    cmp   edx,ecx
  622.    jg   no_on_button
  623.  
  624.    movzx ebx,word [eax+10]   ; button y size
  625.    add   edx,ebx
  626.    cmp   ecx,edx
  627.    jg   no_on_button
  628.    popa
  629.    mov   [BTN_COUNT], 1 ; no of buttons in buffer
  630.    pop   ebx
  631.    mov   [BTN_BUFF],ebx   ; lets put the button id in buffer
  632.    push  ebx
  633.    pusha
  634.    jmp yes_on_button
  635. no_on_button:
  636.    mov   [BTN_COUNT], 0     ; no of buttons in buffer
  637. yes_on_button:
  638.    popa
  639.    pop ebx
  640.    popa
  641.    ret
  642.  
  643. ;..................................... end 5/5 : modified by vhanla ................................
  644.