Subversion Repositories Kolibri OS

Rev

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