Subversion Repositories Kolibri OS

Rev

Rev 129 | 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_TASK]
  168.         shl     edi,8
  169.         rol     eax,16
  170.         add     ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
  171.         rol     eax,16
  172.         rol     ebx,16
  173.         add     bx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
  174.         rol     ebx,16
  175.         pop     edi
  176.   .forced:
  177.  
  178.         test  ecx,0x80000000
  179.         jnz   remove_button
  180.  
  181.         push  esi
  182.         push  edi
  183.         push  eax ; <x,xs>
  184.         push  ebx ; <y,ys>
  185.         push  ecx ; <id>
  186.         push  edx
  187.  
  188.         or    ax,ax
  189.         jle   noaddbutt
  190.         or    bx,bx
  191.         jle   noaddbutt
  192.  
  193.         test  ecx,0x40000000
  194.         jnz   button_no_draw
  195.  
  196.         pushad                       ; button body
  197.         push  ebx
  198.         sar   eax,16
  199.         sar   ebx,16
  200.         mov   edx,[TASK_BASE]
  201.         mov   esi,[edx-twdw + WDATA.box.left]
  202.         mov   edi,[edx-twdw + WDATA.box.top]
  203.         add   eax,esi
  204.         add   ebx,edi
  205.         mov   cx,ax
  206.         mov   dx,bx
  207.         shl   eax,16
  208.         shl   ebx,16
  209.         mov   ax,cx
  210.         mov   bx,dx
  211.         add   ax,[4+32+esp+12]
  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.         inc     bx
  229.         rol     ebx,16
  230.         inc     bx
  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.         movsx edx,word [eax+4]                       ; button x start
  334.         add   ecx,edx
  335.         push  ecx
  336.  
  337.         movzx edx,word[eax+6]                        ; button x size
  338.         add   ecx,edx
  339.         mov   esi,ecx
  340.         inc   esi
  341.                 mov   ecx, [ebx+WDATA.box.top]   ; window y start
  342.         movsx edx,word[eax+8]     ; button y start
  343.         add   ecx,edx
  344.         mov   ebx,ecx
  345.         movzx edx,word[eax+10]    ; button y size
  346.         add   edx,ecx
  347.         inc   edx
  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.     ret
  463.   @@:
  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.  
  477.     push  esi
  478.     inc   edx
  479.     push  edx
  480.  
  481.   buttonnewcheck:
  482.  
  483.     pop   edx
  484.     pop   esi
  485.     inc   esi
  486.     cmp   edx,esi
  487.     jge   bch
  488.  
  489.     popad                 ; no button pressed
  490.     ret
  491.  
  492.   bch:
  493.  
  494.     push  esi
  495.     push  edx
  496.     mov   eax,esi
  497.     shl   eax,4
  498.     add   eax,edi
  499.  
  500. ;......................start 1/2 : modified by vhanla .............................
  501.     mov   [buttonid],eax
  502. ;......................end   1/2 : modified by vhanla .............................
  503.  
  504.     ; check that button is at top of windowing stack
  505.  
  506.     movzx ebx,word [eax]
  507.     movzx ecx,word [WIN_STACK + ebx * 2]
  508.     cmp   ecx,[TASK_COUNT]
  509.     jne   buttonnewcheck
  510.  
  511.     ; check that button start is inside window x/y end
  512.  
  513.     movzx ebx,word [eax+0]
  514.     shl   ebx,5
  515.  
  516.         test    [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
  517.         jnz     buttonnewcheck
  518.  
  519. ;    add   ebx,window_data
  520. ;    mov   ecx,[window_data+ebx+8]          ; window end X
  521.     movsx edx,word [eax+4]     ; button start X
  522.     cmp   edx, [window_data+ebx+WDATA.box.width] ;ecx
  523.     jge   buttonnewcheck
  524.  
  525. ;    mov   ecx,[window_data+ebx+12]         ; window end Y
  526.     movsx edx, word [eax+8]    ; button start Y
  527.     cmp   edx, [window_data+ebx+WDATA.box.height] ;ecx
  528.     jge   buttonnewcheck
  529.  
  530.     ; check coordinates
  531.                                ; mouse x >= button x ?
  532.     movzx ebx,word [eax+0]
  533.     shl   ebx,5
  534.     add   ebx,window_data
  535.         mov   ecx, [ebx+WDATA.box.left]     ; window x start
  536.     movsx edx,word [eax+4]     ; button x start
  537.     add   edx,ecx
  538.     movzx ecx,word[0xfb0a]
  539.     cmp   ecx,edx
  540.     jl    buttonnewcheck
  541.  
  542.     movzx ebx,word [eax+6]     ; button x size
  543.     add   edx,ebx
  544.     cmp   ecx,edx
  545.     jg    buttonnewcheck
  546.  
  547.                                ; mouse y >= button y ?
  548.     movzx ebx,word [eax+0]
  549.     shl   ebx,5
  550.     add   ebx,window_data
  551.         mov   ecx, [ebx+WDATA.box.top]     ; window y start
  552.     movsx edx,word [eax+8]     ; button y start
  553.     add   edx,ecx
  554.     movzx ecx,word[0xfb0c]
  555.     cmp   ecx,edx
  556.     jl    buttonnewcheck
  557.  
  558.     movzx ebx,word [eax+10]    ; button y size
  559.     add   edx,ebx
  560.     cmp   ecx,edx
  561.     jg    buttonnewcheck
  562.  
  563.     ; mouse on button
  564.  
  565.     pop   edx
  566.     pop   esi
  567.  
  568.     mov   bx,[eax+0xc]     ; button id : bits 16-31
  569.     shl   ebx,16
  570.     mov   bx,[eax+2]       ; button id : bits 00-16
  571.     push  ebx
  572.  
  573.     mov   [MOUSE_DOWN],byte 1  ; no mouse down checks
  574.     call find_pressed_button_frames
  575.     call negativebutton
  576.  
  577.     pushad
  578.   cbwaitmouseup:
  579.  
  580.     call  checkidle
  581.  
  582.     call  [draw_pointer]
  583.  
  584.     pushad
  585.     call  stack_handler
  586.     popad
  587.  
  588.     cmp   [BTN_DOWN],byte 0  ; mouse buttons pressed ?
  589.     jnz   cbwaitmouseup
  590.     popad
  591.  
  592.     call  negativebutton
  593.     mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
  594.     mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
  595. ;..................................... start 2/2 : modified by vhanla .............................
  596.     ; check coordinates
  597.     jmp afterbuttonid
  598.     buttonid dd 0x0 ;here a will backup the eax value
  599.     afterbuttonid:
  600.  
  601.    pusha
  602.   ; mouse x >= button x ?
  603.    movzx ebx,word [eax+0]
  604.    shl   ebx,5
  605.    add   ebx,window_data
  606.    mov   ecx, [ebx+WDATA.box.left]    ; window x start
  607.    movsx edx,word [eax+4]    ; button x start
  608.    add   edx,ecx
  609.    movzx ecx,word[0xfb0a]
  610.    cmp   edx,ecx
  611.    jg   no_on_button ;if we release the pointer out of the button area
  612.  
  613.    movzx ebx,word [eax+6]    ; button x size
  614.    add   edx,ebx
  615.    cmp   ecx,edx
  616.    jg   no_on_button
  617.  
  618.         ; mouse y >= button y ?
  619.    movzx ebx,word [eax+0]
  620.    shl   ebx,5
  621.    add   ebx,window_data
  622.    mov   ecx, [ebx+WDATA.box.top]    ; window y start
  623.    movsx edx,word [eax+8]    ; button y start
  624.    add   edx,ecx
  625.    movzx ecx,word[0xfb0c]
  626.    cmp   edx,ecx
  627.    jg   no_on_button
  628.  
  629.    movzx ebx,word [eax+10]   ; button y size
  630.    add   edx,ebx
  631.    cmp   ecx,edx
  632.    jg   no_on_button
  633.    popa
  634.    mov   [BTN_COUNT],byte 1 ; no of buttons in buffer
  635.    pop   ebx
  636.    mov   [BTN_BUFF],ebx   ; lets put the button id in buffer
  637.    push  ebx
  638.    pusha
  639.    jmp yes_on_button
  640. no_on_button:
  641.    mov   [BTN_COUNT],byte 0 ; no of buttons in buffer
  642. yes_on_button:
  643.    mov   [MOUSE_DOWN],byte 0 ; mouse down -> do not draw
  644.    popa
  645.    pop ebx
  646.    popa
  647.    ret
  648.  
  649. ;..................................... end 2/2 : modified by vhanla ................................
  650.