Subversion Repositories Kolibri OS

Rev

Rev 415 | Rev 431 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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