Subversion Repositories Kolibri OS

Rev

Rev 1168 | Rev 1334 | Go to most recent revision | 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: 1300 $
  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.         mov     edi, [BTN_ADDR]
  230.         movzx   eax, word [edi]
  231.         cmp     eax, max_buttons
  232.         jge     noaddbutt
  233.         inc     eax
  234.         mov     [edi], ax
  235.  
  236.         shl     eax, 4
  237.         add     edi, eax
  238.  
  239.         mov     ax, [CURRENT_TASK]
  240.         stosw
  241.         mov     ax, dx
  242.         stosw               ; button id number: bits 0-15
  243.         mov     eax, ebx
  244.         rol     eax, 16
  245.         stosd               ; x start | x size
  246.         mov     eax, ecx
  247.         rol     eax, 16
  248.         stosd               ; y start | y size
  249.         mov     eax, edx
  250.         shr     eax, 16
  251.         stosw               ; button id number: bits 16-31
  252.  
  253. noaddbutt:
  254.  
  255.         ret
  256.  
  257.  
  258. remove_button:
  259.  
  260.         and     edx, 0x7fffffff
  261.  
  262. rnewba2:
  263.  
  264.         mov     edi, [BTN_ADDR]
  265.         mov     eax, edi
  266.         movzx   ebx, word [edi]
  267.         inc     ebx
  268.  
  269. rnewba:
  270.  
  271.         dec     ebx
  272.         jz      rnmba
  273.  
  274.         add     eax, 0x10
  275.  
  276.         mov     cx, [CURRENT_TASK]
  277.         cmp     cx, [eax]
  278.         jnz     rnewba
  279.         cmp     dx, [eax+2]
  280.         jnz     rnewba
  281.  
  282.         lea     ecx, [ebx+1]
  283.         shl     ecx, 4
  284.         mov     ebx, eax
  285.         add     eax, 0x10
  286.         call    memmove
  287.         dec     dword [edi]
  288.         jmp     rnewba2
  289.  
  290. rnmba:
  291.  
  292.         ret
  293.  
  294. find_pressed_button_frames:
  295.  
  296.         pushad
  297.  
  298.         movzx ebx,word [eax+0]
  299.         shl   ebx,5
  300.         add   ebx,window_data
  301.         mov   ecx, [ebx+ WDATA.box.left]     ; window x start
  302.         movzx edx,word [eax+4]     ; button x start
  303.         add   ecx,edx
  304.         push  ecx
  305.  
  306.         mov   dx,[eax+6]                 ; button x size
  307.         add   cx,dx
  308.         mov   esi,ecx
  309.         inc   esi
  310.         mov   ecx, [ebx+WDATA.box.top]   ; window y start
  311.         mov   dx,[eax+8]                 ; button y start
  312.         add   ecx,edx
  313.         mov   ebx,ecx
  314.                 mov   dx,[eax+10]                ; button y size
  315.         add   dx,cx
  316.         inc   dx
  317.  
  318.         pop   eax
  319.  
  320.         ; eax x beginning
  321.         ; ebx y beginning
  322.         ; esi x end
  323.         ; edx y end
  324.         ; ecx color
  325.  
  326.         mov   [pressed_button_eax],eax
  327.         mov   [pressed_button_ebx],ebx
  328.         mov   [pressed_button_ecx],ecx
  329.         mov   [pressed_button_edx],edx
  330.         mov   [pressed_button_esi],esi
  331.  
  332.         popad
  333.         ret
  334.  
  335. uglobal
  336.   pressed_button_eax  dd  0
  337.   pressed_button_ebx  dd  0
  338.   pressed_button_ecx  dd  0
  339.   pressed_button_edx  dd  0
  340.   pressed_button_esi  dd  0
  341. endg
  342.  
  343. ; negative button image
  344.  
  345. negativebutton:
  346.         ; If requested, do not display button
  347.         ; boarder on press.
  348.         test  ebx,0x20000000
  349.         jz    draw_negative_button
  350.         ret
  351.       draw_negative_button:
  352.  
  353.         pushad
  354.  
  355.         mov   eax,[pressed_button_eax]
  356.         mov   ebx,[pressed_button_ebx]
  357.         mov   ecx,[pressed_button_ecx]
  358.         mov   edx,[pressed_button_edx]
  359.         mov   esi,[pressed_button_esi]
  360.         mov   ecx,0x01000000
  361.  
  362.         dec   edx
  363.         push  edx
  364.         inc   edx
  365.         dec   esi
  366.         push  esi
  367.         inc   esi
  368.  
  369.         push  eax
  370.         push  ebx
  371.         push  ecx
  372.         push  edx
  373.         push  edi
  374.  
  375.         call  [_display.disable_mouse]
  376.  
  377.       bdbnewline:
  378.         mov   edi,1    ; force
  379.         cmp   eax,[esp+16]
  380.         jz    bneg
  381.         cmp   eax,[esp+20]
  382.         jz    bneg
  383.         cmp   ebx,[esp+12]
  384.         jz    bneg
  385.         cmp   ebx,[esp+24]
  386.         jnz   nbneg
  387. ;        jz    bneg
  388. ;        jmp   nbneg
  389.  
  390.       bneg:
  391.  
  392.         call  [putpixel]
  393.  
  394.       nbneg:
  395.  
  396.         inc   eax
  397.         cmp   eax,esi
  398.         jnz   bdbnewline
  399.         mov   eax,[esp+16]
  400.         inc   ebx
  401.         cmp   ebx,edx
  402.         jnz   bdbnewline
  403.  
  404.         add   esp,28
  405.  
  406.         popad
  407.  
  408.         ret
  409.  
  410. ; check buttons
  411.  
  412.  
  413. ; 0000 word process number
  414. ; 0002 word button id number : bits 0-15
  415. ; 0004 word x start
  416. ; 0006 word x size
  417. ; 0008 word y start
  418. ; 000A word y size
  419. ; 000C word button id number : bits 16-31
  420. ;
  421. ; button table in 0x10 increments
  422. ;
  423. ; first at 0x10
  424.  
  425. align 4
  426. checkbuttons:
  427.  
  428.     cmp   [BTN_DOWN],byte 0    ; mouse buttons pressed
  429.     jnz   @f
  430. ;..................................... start 1/5 : modified by vhanla .............................
  431.     mov [bPressedMouseXY_B],0
  432. ;..................................... end 1/5 : modified by vhanla .............................
  433.     ret
  434.   @@:
  435.     pushad
  436.  
  437.     xor    esi, esi
  438.     mov    edi, [BTN_ADDR]
  439.     movzx  edx, word [edi]
  440.     test   edx, edx
  441.     jne    @f
  442.     popad
  443.     ret
  444.  
  445.   @@:
  446. ;..................................... start 2/5 : modified by vhanla .............................
  447.   ;here i catch the coordinates when the mouse's button is clicked
  448.    push ax
  449.    cmp [bPressedMouseXY_B],0;FALSE
  450.    jnz @f
  451.    mov [bPressedMouseXY_B],1;TRUE - it was already clicked
  452.    mov ax,[MOUSE_X]
  453.    mov [mx],ax
  454.    mov ax,[MOUSE_Y]
  455.    mov [my],ax
  456.    @@:
  457.    pop  ax
  458.    ;and it is only refreshed after the mouse's button release
  459. ;..................................... end 2/5 : modified by vhanla .............................
  460.  
  461.     push  esi
  462.     inc   edx
  463.     push  edx
  464.  
  465.   buttonnewcheck:
  466.  
  467.     pop   edx
  468.     pop   esi
  469.     inc   esi
  470.     cmp   edx,esi
  471.     jge   bch
  472.  
  473.     popad                 ; no button pressed
  474.     ret
  475.  
  476.   bch:
  477.  
  478.     push  esi
  479.     push  edx
  480.     mov   eax,esi
  481.     shl   eax,4
  482.     add   eax,edi
  483.  
  484.     ; check that button is at top of windowing stack
  485.  
  486.     movzx ebx,word [eax]
  487.     movzx ecx,word [WIN_STACK + ebx * 2]
  488.     cmp   ecx,[TASK_COUNT]
  489.     jne   buttonnewcheck
  490.  
  491.     ; check that button start is inside window x/y end
  492.  
  493.     movzx ebx,word [eax+0]
  494.     shl   ebx,5
  495.  
  496.         test    [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
  497.         jnz     buttonnewcheck
  498.  
  499. ;    add   ebx,window_data
  500. ;    mov   ecx,[window_data+ebx+8]          ; window end X
  501.     movzx edx,word [eax+4]     ; button start X
  502.     cmp   edx, [window_data+ebx+WDATA.box.width] ;ecx
  503.     jge   buttonnewcheck
  504.  
  505. ;    mov   ecx,[window_data+ebx+12]         ; window end Y
  506.     movzx edx, word [eax+8]    ; button start Y
  507.     cmp   edx, [window_data+ebx+WDATA.box.height] ;ecx
  508.     jge   buttonnewcheck
  509.  
  510.     ; check coordinates
  511.                                ; mouse x >= button x ?
  512.     movzx ebx,word [eax+0]
  513.     shl   ebx,5
  514.     add   ebx,window_data
  515.         mov   ecx, [ebx+WDATA.box.left]     ; window x start
  516.     movzx edx,word [eax+4]     ; button x start
  517.     add   edx,ecx
  518. ;..................................... start 3/5 : modified by vhanla .............................
  519.     mov   cx,[mx]   ;mov cx,[MOUSE_X]
  520. ;..................................... end 3/5 : modified by vhanla .............................
  521.     cmp   edx,ecx
  522.     jg    buttonnewcheck
  523.  
  524.     movzx ebx,word [eax+6]     ; button x size
  525.     add   edx,ebx
  526.     cmp   ecx,edx
  527.     jg    buttonnewcheck
  528.  
  529.                                ; mouse y >= button y ?
  530.     movzx ebx,word [eax+0]
  531.     shl   ebx,5
  532.     add   ebx,window_data
  533.         mov   ecx, [ebx+WDATA.box.top]     ; window y start
  534.     movzx edx,word [eax+8]     ; button y start
  535.     add   edx,ecx
  536. ;..................................... start 4/5 : modified by vhanla .............................
  537.     mov   cx,[my]  ;mov cx,[MOUSE_Y]
  538. ;..................................... start 4/5 : modified by vhanla .............................
  539.     cmp   edx,ecx
  540.     jg    buttonnewcheck
  541.  
  542.     movzx ebx,word [eax+10]    ; button y size
  543.     add   edx,ebx
  544.     cmp   ecx,edx
  545.     jg    buttonnewcheck
  546.  
  547.     ; mouse on button
  548.  
  549.     pop   edx
  550.     pop   esi
  551.  
  552.     mov   bx,[eax+0xc]     ; button id : bits 16-31
  553.     shl   ebx,16
  554.     mov   bx,[eax+2]       ; button id : bits 00-16
  555.     push  ebx
  556.  
  557.     mov   [MOUSE_DOWN],byte 1  ; no mouse down checks
  558.     call find_pressed_button_frames
  559.     call negativebutton
  560.  
  561.     pushad
  562. ; // Alver 22.06.2008 // {
  563.     push  eax
  564.     mov  al, byte [BTN_DOWN]
  565.     mov  byte [btn_down_determ], al
  566.     pop  eax
  567. ; } \\ Alver \\
  568.  
  569.   cbwaitmouseup:
  570.  
  571.     call  checkidle
  572.  
  573.     call  [draw_pointer]
  574.  
  575.     pushad
  576.     call  stack_handler
  577.     popad
  578.  
  579.     cmp   [BTN_DOWN],byte 0  ; mouse buttons pressed ?
  580.     jnz   cbwaitmouseup
  581.     popad
  582.  
  583.     call  negativebutton
  584.     mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
  585.     mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
  586. ;..................................... start 5/5 : modified by vhanla .............................
  587.     ; check coordinates
  588. iglobal
  589.     mx dw 0x0 ; keeps the x mouse's position when it was clicked
  590.     my dw 0x0 ; keeps the y mouse's position when it was clicked
  591.     bPressedMouseXY_B db 0x0
  592.     btn_down_determ     db 0x0        ; << // Alver 22.06.2008// <<
  593. endg
  594.  
  595.    pusha
  596.   ; mouse x >= button x ?
  597.    movzx ebx,word [eax+0]
  598.    shl   ebx,5
  599.    add   ebx,window_data
  600.    mov   ecx, [ebx+WDATA.box.left]    ; window x start
  601.    movzx edx,word [eax+4]    ; button x start
  602.    add   edx,ecx
  603.    mov   cx,[MOUSE_X]
  604.    cmp   edx,ecx
  605.    jg   no_on_button ;if we release the pointer out of the button area
  606.  
  607.    movzx ebx,word [eax+6]    ; button x size
  608.    add   edx,ebx
  609.    cmp   ecx,edx
  610.    jg   no_on_button
  611.  
  612.         ; mouse y >= button y ?
  613.    movzx ebx,word [eax+0]
  614.    shl   ebx,5
  615.    add   ebx,window_data
  616.    mov   ecx, [ebx+WDATA.box.top]    ; window y start
  617.    movzx edx,word [eax+8]    ; button y start
  618.    add   edx,ecx
  619.    mov   cx,[MOUSE_Y]
  620.    cmp   edx,ecx
  621.    jg   no_on_button
  622.  
  623.    movzx ebx,word [eax+10]   ; button y size
  624.    add   edx,ebx
  625.    cmp   ecx,edx
  626.    jg   no_on_button
  627.    popa
  628.    mov   [BTN_COUNT],byte 1 ; no of buttons in buffer
  629.    pop   ebx
  630.    mov   [BTN_BUFF],ebx   ; lets put the button id in buffer
  631.    push  ebx
  632.    pusha
  633.    jmp yes_on_button
  634. no_on_button:
  635.    mov   [BTN_COUNT],byte 0 ; no of buttons in buffer
  636. yes_on_button:
  637.    mov   [MOUSE_DOWN],byte 0 ; mouse down -> do not draw
  638.    popa
  639.    pop ebx
  640.    popa
  641.    ret
  642.  
  643. ;..................................... end 5/5 : modified by vhanla ................................
  644.