Subversion Repositories Kolibri OS

Rev

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

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