Subversion Repositories Kolibri OS

Rev

Rev 1666 | Blame | Last modification | View Log | Download | RSS feed

  1. ;**************************************************************
  2. ; ScrollBar Macro for Kolibri OS
  3. ; Copyright (c) 2009, Marat Zakiyanov aka Mario79, aka Mario
  4. ; All rights reserved.
  5. ;
  6. ; Redistribution and use in source and binary forms, with or without
  7. ; modification, are permitted provided that the following conditions are met:
  8. ;        * Redistributions of source code must retain the above copyright
  9. ;          notice, this list of conditions and the following disclaimer.
  10. ;        * Redistributions in binary form must reproduce the above copyright
  11. ;          notice, this list of conditions and the following disclaimer in the
  12. ;          documentation and/or other materials provided with the distribution.
  13. ;        * Neither the name of the <organization> nor the
  14. ;          names of its contributors may be used to endorse or promote products
  15. ;          derived from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  18. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  21. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ;*****************************************************************************
  28. macro scroll_bar_exit
  29. {
  30. popa
  31. ret 4
  32. }
  33. ;*****************************************************************************
  34. macro draw_up_arrow_vertical
  35. {
  36.         push  ebx
  37.        
  38.         xor   eax,eax
  39.         mov   ax,sb_size_x
  40.         shr   eax,1
  41.         shl   eax,16
  42.         add   ebx,eax
  43.        
  44.         xor   eax,eax
  45.         mov   ax,sb_btn_high
  46.         shr   eax,1
  47.         shl   eax,16
  48.         add   ecx,eax
  49.        
  50.         mov   edx,sb_line_col
  51.         sub   ebx,4 shl 16
  52.         mov   bx,7
  53.         mov   cx,1
  54.         mov   eax,13
  55.         int   0x40
  56.         sub   ecx,1 shl 16
  57.         add   ebx,1 shl 16
  58.         mov   bx,5
  59.         int   0x40
  60.         sub   ecx,1 shl 16
  61.         add   ebx,1 shl 16
  62.         mov   bx,3
  63.         int   0x40
  64.         sub   ecx,1 shl 16
  65.         add   ebx,1 shl 16
  66.         mov   bx,1
  67.         int   0x40
  68.         pop   ebx
  69. }
  70. ;*****************************************************************************
  71. macro draw_down_arrow_vertical
  72. {
  73.         push  ebx
  74.        
  75.         xor   eax,eax
  76.         mov   ax,sb_size_x
  77.         shr   eax,1
  78.         shl   eax,16
  79.         add   ebx,eax
  80.        
  81.         xor   eax,eax
  82.         mov   ax,sb_btn_high
  83.         shr   eax,1
  84.         shl   eax,16
  85.         add   ecx,eax
  86.        
  87.         mov   edx,sb_line_col
  88.         sub   ebx,4 shl 16
  89.         mov   bx,7
  90.         sub   ecx,2 shl 16
  91.         mov   cx,1
  92.         mov   eax,13
  93.         int   0x40
  94.         add   ecx,1 shl 16
  95.         add   ebx,1 shl 16
  96.         mov   bx,5
  97.         int   0x40
  98.         add   ecx,1 shl 16
  99.         add   ebx,1 shl 16
  100.         mov   bx,3
  101.         int   0x40
  102.         add   ecx,1 shl 16
  103.         add   ebx,1 shl 16
  104.         mov   bx,1
  105.         int   0x40
  106.         pop   ebx
  107. }
  108. ;*****************************************************************************
  109. macro draw_runner_center_vertical
  110. {
  111.         push  ebx
  112.         push  ecx
  113.        
  114.         xor   eax,eax
  115.         mov   ax,sb_size_x
  116.         shr   eax,1
  117.         shl   eax,16
  118.         add   ebx,eax
  119.        
  120.         mov   edx,sb_run_size
  121.         shr   edx,1
  122.         shl   edx,16
  123.         add   ecx,edx
  124.         mov   edx,sb_line_col
  125.         sub   ecx,8 shl 16
  126.         sub   ebx,5 shl 16
  127.         mov   bx,10
  128.         add   ecx,4 shl 16
  129.         mov   cx,1
  130.         mov   eax,13
  131.         int   0x40
  132.         add   ecx,3 shl 16
  133.         sub   ebx,1 shl 16
  134.         mov   bx,12
  135.         int   0x40
  136.         add   ebx,1 shl 16
  137.         mov   bx,10
  138.         add   ecx,3 shl 16
  139.         int   0x40
  140.         pop   ecx
  141.         pop   ebx
  142. }
  143. ;*****************************************************************************
  144. macro draw_up_arrow_horizontal
  145. {
  146.         push  ecx
  147.        
  148.         xor   eax,eax
  149.         mov   ax,sb_btn_high
  150.         shr   eax,1
  151.         shl   eax,16
  152.         add   ebx,eax
  153.        
  154.         xor   eax,eax
  155.         mov   ax,sb_size_y
  156.         shr   eax,1
  157.         shl   eax,16
  158.         add   ecx,eax
  159.        
  160.         mov   edx,sb_line_col
  161.         sub   ecx,4 shl 16
  162.         mov   cx,7
  163.         mov   bx,1
  164.        
  165.         mov   eax,13
  166.         int   0x40
  167.         sub   ebx,1 shl 16
  168.         add   ecx,1 shl 16
  169.         mov   cx,5
  170.         int   0x40
  171.         sub   ebx,1 shl 16
  172.         add   ecx,1 shl 16
  173.         mov   cx,3
  174.         int   0x40
  175.         sub   ebx,1 shl 16
  176.         add   ecx,1 shl 16
  177.         mov   cx,1
  178.         int   0x40
  179.         pop   ecx
  180. }
  181. ;*****************************************************************************
  182. macro draw_down_arrow_horizontal
  183. {
  184.         push  ecx
  185.        
  186.         xor   eax,eax
  187.         mov   ax,sb_btn_high
  188.         shr   eax,1
  189.         shl   eax,16
  190.         add   ebx,eax
  191.        
  192.         xor   eax,eax
  193.         mov   ax,sb_size_y
  194.         shr   eax,1
  195.         shl   eax,16
  196.         add   ecx,eax
  197.        
  198.         mov   edx,sb_line_col
  199.         sub   ecx,4 shl 16
  200.         mov   cx,7
  201.         sub   ebx,2 shl 16
  202.         mov   bx,1
  203.         mov   eax,13
  204.         int   0x40
  205.         add   ebx,1 shl 16
  206.         add   ecx,1 shl 16
  207.         mov   cx,5
  208.         int   0x40
  209.         add   ebx,1 shl 16
  210.         add   ecx,1 shl 16
  211.         mov   cx,3
  212.         int   0x40
  213.         add   ecx,1 shl 16
  214.         add   ebx,1 shl 16
  215.         mov   cx,1
  216.         int   0x40
  217.         pop   ecx
  218. }
  219. ;*****************************************************************************
  220. macro draw_runner_center_horizontal
  221. {
  222.         push  ebx
  223.         push  ecx
  224.        
  225.         xor   eax,eax
  226.         mov   ax,sb_size_y
  227.         shr   eax,1
  228.         shl   eax,16
  229.         add   ecx,eax
  230.        
  231.         mov   edx,sb_run_size
  232.         shr   edx,1
  233.         shl   edx,16
  234.         add   ebx,edx
  235.         mov   edx,sb_line_col
  236.         sub   ebx,8 shl 16
  237.         sub   ecx,5 shl 16
  238.         mov   cx,10
  239.         add   ebx,4 shl 16
  240.         mov   bx,1
  241.         mov   eax,13
  242.         int   0x40
  243.         add   ebx,3 shl 16
  244.         sub   ecx,1 shl 16
  245.         mov   cx,12
  246.         int   0x40
  247.         add   ecx,1 shl 16
  248.         mov   cx,10
  249.         add   ebx,3 shl 16
  250.         int   0x40
  251.         pop   ecx
  252.         pop   ebx
  253. }
  254. ;*****************************************************************************
  255. macro use_scroll_bar
  256. {
  257. scroll_bar:
  258. sb_size_x               equ [edi]
  259. sb_start_x              equ [edi+2]
  260. sb_size_y               equ [edi+4]
  261. sb_start_y              equ [edi+6]
  262. sb_btn_high             equ [edi+8]
  263. sb_type                 equ [edi+12]
  264. sb_max_area             equ [edi+16]
  265. sb_cur_area             equ [edi+20]
  266. sb_position             equ [edi+24]
  267. sb_bckg_col             equ [edi+28]
  268. sb_frnt_col             equ [edi+32]
  269. sb_line_col             equ [edi+36]
  270. sb_redraw               equ [edi+40]
  271. sb_delta                equ [edi+44]
  272. sb_delta2               equ [edi+46]
  273. sb_r_size_x             equ [edi+48]
  274. sb_r_start_x    equ [edi+50]
  275. sb_r_size_y             equ [edi+52]
  276. sb_r_start_y    equ [edi+54]
  277. sb_m_pos                equ [edi+56]
  278. sb_m_pos_2              equ [edi+60]
  279. sb_m_keys               equ [edi+64]
  280. sb_run_size             equ [edi+68]
  281. sb_position2    equ [edi+72]
  282. sb_work_size    equ [edi+76]
  283. sb_all_redraw   equ [edi+80]
  284. sb_ar_offset    equ [edi+84]
  285. }
  286. ;*****************************************************************************
  287. ;*****************************************************************************
  288. ; draw event
  289. ;*****************************************************************************
  290. ;*****************************************************************************
  291. macro use_scroll_bar_vertical
  292. {
  293. scroll_bar_vertical:
  294. .draw:
  295.         pusha
  296.         mov   edi,dword [esp+36]
  297.         mov   sb_delta,word 0
  298.         call  .draw_1
  299.         mov   sb_all_redraw,dword 0
  300. scroll_bar_exit
  301. .draw_1:
  302.         pusha
  303. ;*********************************
  304.         xor   eax,eax
  305.         mov   ax,sb_size_y
  306.         mov   edx,sb_btn_high
  307.         shl   edx,1
  308.         sub   eax,edx
  309.         mov   sb_work_size,eax
  310. ;*********************************
  311.         mov   eax,sb_work_size
  312.         mov   ebx,sb_max_area
  313.         cmp   ebx,sb_cur_area
  314.         ja      @f
  315.  
  316.         jmp   .no_size
  317.  
  318. @@:
  319.         imul  eax,sb_cur_area
  320.         xor   edx,edx
  321.         div   ebx
  322.         cmp   eax,10
  323.         jae   @f
  324.         mov   eax,10
  325. @@:
  326. .no_size:
  327.         mov   sb_run_size,eax
  328. ;*********************************
  329.         cmp   word sb_delta,1
  330.         je      .@@_3
  331.         mov   eax,sb_work_size
  332.         sub   eax,sb_run_size
  333.         mov   ebx,sb_max_area
  334.         cmp   ebx,sb_cur_area
  335.         ja      @f
  336.         xor   eax,eax
  337.         jmp   .@@_1
  338. @@:
  339.         sub   ebx,sb_cur_area
  340.         imul  eax,sb_position
  341.         xor   edx,edx
  342.         div   ebx
  343. .@@_1:
  344.         mov   sb_position2,eax
  345.         xor   edx,edx
  346.         mov   dx,sb_size_y
  347.         sub   edx,sb_btn_high
  348.         sub   edx,sb_btn_high
  349.         sub   edx,sb_run_size
  350.         cmp   sb_position2,edx
  351.         jbe   .@@_3
  352.         mov   sb_position2,edx
  353. .@@_3:
  354. ;*********************************     
  355.         mov   ebx,sb_start_x
  356.         shl   ebx,16
  357.         inc   ebx
  358.         mov   ecx,sb_size_y
  359.         mov   edx,sb_line_col
  360.         mov   eax,13
  361.         cmp  dword sb_all_redraw,0
  362.         je   @f
  363.         int   0x40   ; left extreme line
  364. @@:
  365.         push  ebx
  366.         ror   ebx,16
  367.         add   bx,sb_size_x
  368.         rol   ebx,16
  369.         cmp  dword sb_all_redraw,0
  370.         je   @f
  371.         int   0x40   ; right extreme line
  372. @@:
  373.         pop   ebx
  374.  
  375.         push  ecx
  376.        
  377.         add   ebx,1 shl 16
  378.         mov   bx,sb_size_x
  379.         dec   ebx      
  380.         mov   cx,1
  381.         cmp  dword sb_all_redraw,0
  382.         je   @f
  383.         int   0x40   ; top button - extreme line
  384. @@:
  385.         push  ecx
  386.         add   ecx,1 shl 16
  387.         add   ecx,sb_btn_high
  388.         sub   ecx,2
  389.         mov   edx,sb_frnt_col
  390.         cmp  dword sb_all_redraw,0
  391.         je   @f
  392.         int   0x40   ; top button filling
  393. ;*********************************     
  394. draw_up_arrow_vertical
  395. ;*********************************
  396. @@:
  397.         pop   ecx
  398.        
  399.         ror   ecx,16
  400.         add   ecx,sb_btn_high  ;14 shl 16
  401.         rol   ecx,16
  402.         mov   edx,sb_line_col
  403.         cmp  dword sb_all_redraw,0
  404.         je   @f
  405.         int   0x40   ;  top button - bottom line
  406. @@:
  407.         pop   ecx
  408. ;*********************************
  409.         ror   ecx,16   
  410.         add   ecx,sb_btn_high  ;15 shl 16
  411.         inc   ecx
  412.         rol   ecx,16
  413.         sub   ecx,sb_btn_high  ;30
  414.         sub   ecx,sb_btn_high
  415.         push  ecx
  416.         mov   cx,0
  417.         add   ecx,sb_position2
  418.         dec   cx
  419.         mov   eax,13
  420.         test  cx,0x8000
  421.         jnz   @f
  422.         mov   edx,sb_bckg_col
  423.         int   0x40      ; top interval
  424. @@:
  425. ;*********************************
  426.         shr   ecx,16
  427.         add   ecx,sb_position2
  428.         dec   ecx
  429.         shl   ecx,16
  430.         inc   ecx
  431.         mov   edx,sb_line_col
  432.         int   0x40      ; runner - top extreme line
  433.        
  434.         add   ecx,1 shl 16
  435.         mov   cx,0
  436.         add   ecx,sb_run_size
  437.         mov   sb_r_size_x,ebx
  438.         mov   sb_r_size_y,ecx
  439.         sub   ecx,2
  440.         mov   edx,sb_frnt_col
  441.         int   0x40   ; runner filling
  442. ;*********************************
  443. draw_runner_center_vertical
  444. ;*********************************
  445.         cmp word sb_type,1
  446.         jne @f
  447.                 push eax ebx ecx edx
  448.                 movzx eax,word sb_start_x
  449.                 xor ebx,ebx
  450.                 add bx,sb_r_start_y
  451.                 dec ebx
  452.                 movzx ecx,word sb_size_x
  453.                 mov edx,sb_run_size
  454.                 dec edx
  455.                 ;à¨á®¢ ­¨¥ á⨫쭮© à ¬ª¨ ­  ¯®«§ã­ª¥
  456.                 stdcall draw_edge, eax,ebx,ecx,edx, sb_bckg_col, sb_frnt_col, sb_line_col
  457.                 pop edx ecx ebx eax
  458.         @@:
  459.         shr   ecx,16
  460.         add   ecx,sb_run_size
  461.         sub   ecx,2
  462.         shl   ecx,16  
  463.         inc   ecx
  464.         mov   edx,sb_line_col
  465.         int   0x40   ; runner - bottom extreme line
  466.        
  467.         add   ecx,1 shl 16
  468.         mov   cx,sb_start_y
  469.         add   cx,sb_size_y
  470.         sub   ecx,sb_btn_high
  471.         dec   ecx
  472.         mov   eax,ecx
  473.         shr   eax,16
  474.         sub   cx,ax
  475.         test  cx,0x8000
  476.         jnz       @f
  477.         mov   edx,sb_bckg_col
  478.         mov   eax,13
  479.         int   0x40   ; bottom interval
  480. @@:    
  481.         pop   ecx      
  482. ;*********************************     
  483.         mov   ax,cx
  484.         shr   ecx,16
  485.         add   cx,ax
  486.         sub   ecx,2
  487.         shl   ecx,16
  488.         inc   ecx
  489.         mov   edx,sb_line_col
  490.         mov   eax,13
  491.         cmp  dword sb_all_redraw,0
  492.         je   @f
  493.         int   0x40   ; bottom button - top line
  494. @@:
  495.         push  ecx
  496.         add   ecx,1 shl 16
  497.         add   cx,sb_btn_high
  498.         sub   ecx,2
  499.         mov   edx,sb_frnt_col
  500.         cmp  dword sb_all_redraw,0
  501.         je   @f
  502.         int   0x40   ; bottom button filling
  503. ;*********************************
  504. draw_down_arrow_vertical
  505. ;*********************************
  506. @@:
  507.         pop   ecx
  508.        
  509.         ror   ecx,16
  510.         add   ecx,sb_btn_high
  511.         rol   ecx,16
  512.        
  513.         mov   edx,sb_line_col
  514.         mov   cx,1
  515.         cmp  dword sb_all_redraw,0
  516.         je   @f
  517.         int   0x40   ; bottom button - extreme line
  518.         cmp word sb_type,1
  519.         jne @f
  520.                 movzx eax,word sb_start_x
  521.                 movzx ebx,word sb_start_y
  522.                 movzx ecx,word sb_size_x
  523.                 ;à¨á®¢ ­¨¥ á⨫쭮© à ¬ª¨ ­  ¢¥àå­¥© ª­®¯ª¥
  524.                 stdcall draw_edge, eax,ebx,ecx,sb_btn_high,\
  525.                         sb_bckg_col, sb_frnt_col, sb_line_col
  526.  
  527.                 add bx,sb_size_y
  528.                 sub ebx,sb_btn_high
  529.                 dec ebx
  530.                 ;à¨á®¢ ­¨¥ á⨫쭮© à ¬ª¨ ­  ­¨¦­¥© ª­®¯ª¥
  531.                 stdcall draw_edge, eax,ebx,ecx,sb_btn_high,\
  532.                         sb_bckg_col, sb_frnt_col, sb_line_col
  533. @@:
  534.         popa
  535.         ret
  536. ;*****************************************************************************
  537. ;*****************************************************************************
  538. ; mouse event
  539. ;*****************************************************************************
  540. ;*****************************************************************************
  541. .mouse:
  542.         pusha
  543.         mov      edi,dword [esp+36]
  544.         mcall 37,1
  545.         mov   sb_m_pos,eax
  546.         cmp   dword sb_m_pos_2,0
  547.         jne   @f
  548.        
  549.         mov   sb_m_pos_2,eax   
  550. @@:
  551.         mcall 37,2
  552.         mov   sb_m_keys,eax    
  553.  
  554.         cmp   sb_m_keys,eax
  555.         je        @f
  556.        
  557.         mov   sb_m_keys,eax
  558.  
  559.         mov   sb_delta,dword 0
  560.  
  561.         mov   eax,sb_m_pos
  562.         mov   sb_m_pos_2,eax
  563.         jmp   .continue_2
  564.        
  565. @@:
  566.         cmp   dword sb_m_keys,0
  567.         jne      @f
  568.         mov   eax,sb_m_pos
  569.         mov   sb_m_pos_2,eax
  570.         jmp   .correct_1        ;.exit_sb      
  571. @@:
  572.         mov   sb_delta,word 1
  573.  
  574. .continue_2:
  575.         mov   eax,sb_m_pos
  576.         test  eax,0x80000000
  577.         jnz   .exit_sb
  578.        
  579.         test  eax,0x8000
  580.         jnz   .exit_sb
  581.        
  582.         mov   ebx,eax
  583.         shr   ebx,16   ; x position
  584.         shl   eax,16
  585.         shr   eax,16   ; y position
  586.  
  587.         mov   cx,sb_start_y
  588.         cmp   ax,cx
  589.         jb      .exit_sb
  590.        
  591.         cmp   word sb_delta2,0
  592.         je      @f
  593.         push  ecx
  594.         add   cx,sb_btn_high
  595.         cmp   ax,cx
  596.         pop   ecx
  597.         jb      .exit_sb
  598.        
  599. @@:
  600.         add   cx,sb_size_y
  601.         cmp   ax,cx
  602.         ja      .exit_sb
  603.  
  604.         cmp   word sb_delta2,0
  605.         je      @f
  606.         sub   cx,sb_btn_high
  607.         cmp   ax,cx
  608.         ja      .exit_sb
  609.        
  610. @@:
  611.         cmp   word sb_delta2,1
  612.         je      @f
  613.        
  614.         cmp   dword sb_m_keys,0
  615.         je      .exit_sb
  616.        
  617.         mov   cx,sb_start_x
  618.         cmp   bx,cx
  619.         jb      .exit_sb
  620.        
  621.         add   cx,sb_size_x
  622.         cmp   bx,cx
  623.         ja      .exit_sb
  624.  
  625.         mov   cx,sb_r_start_y
  626.         cmp   ax,cx
  627.         jb      .no_runner
  628.        
  629.         add   cx,sb_r_size_y
  630.         cmp   ax,cx
  631.         ja      .no_runner
  632.  
  633.         mov   sb_delta2,word 1 
  634. @@:
  635.         push  eax
  636.         mov   ax,sb_m_pos
  637.         cmp   ax,sb_m_pos_2
  638.         je      .correct       
  639.        
  640.         shl   eax,16
  641.         shr   eax,16
  642.         mov   ebx,sb_m_pos_2
  643.         shl   ebx,16
  644.         shr   ebx,16
  645.         cmp   eax,ebx
  646.         jb   .sub
  647.        
  648.         sub   eax,ebx
  649.         mov   ebx,eax
  650.         add   sb_position2,ebx
  651.         xor   eax,eax
  652.         mov   ax,sb_size_y
  653.         sub   eax,sb_btn_high
  654.         sub   eax,sb_btn_high
  655.         sub   eax,sb_run_size
  656.         cmp   sb_position2,eax
  657.         jbe   @f
  658.        
  659.         mov   sb_position2,eax
  660. @@:
  661.         mov   eax,sb_m_pos
  662.         mov   sb_m_pos_2,eax
  663.         pop   eax
  664.         call  .draw_1
  665.         jmp   .no_runner_1
  666.        
  667. .correct:
  668.         pop   eax
  669.         jmp   .exit_sb
  670. .correct_1:
  671.         mov   sb_delta,dword 0
  672.         jmp   .exit_sb
  673.  
  674. .sub:
  675.         sub   ebx,eax
  676.         sub   sb_position2,ebx
  677.         test  sb_position2,dword 0x80000000
  678.         jz        @f
  679.        
  680.         mov   sb_position2,dword 0
  681. @@:
  682.         mov   eax,sb_m_pos
  683.         mov   sb_m_pos_2,eax
  684.         pop   eax
  685.         call  .draw_1
  686.         jmp   .no_runner_1
  687.  
  688. ;*****************************************************************************
  689. .no_runner:
  690.         mov   sb_delta,dword 0
  691. .no_runner_1:
  692.         xor   ecx,ecx
  693.         mov   cx,sb_start_y
  694.         add   cx,sb_btn_high   ;15
  695.         cmp   word sb_delta,1
  696.         je      .scroll_sb
  697.        
  698.         cmp   ax,cx
  699.         ja      .scroll_sb
  700.        
  701.         cmp   dword sb_m_keys,0
  702.         je   .exit_sb
  703.        
  704.         mov   eax,sb_ar_offset
  705.         cmp   sb_position,eax  ;dword 0
  706.         jbe   @f
  707.        
  708.         sub   sb_position,eax
  709.         jmp   .all_sb
  710. @@:
  711.         xor   eax,eax
  712.         mov   sb_position,eax ;dword 0
  713.         mov   sb_position2,eax ;dword 0
  714.         jmp   .all_sb
  715. ;*****************************************************************************
  716. .scroll_sb:
  717.         add   cx,sb_size_y
  718.         sub   cx,sb_btn_high
  719.         sub   cx,sb_btn_high
  720.         cmp   word sb_delta,1
  721.         je      @f
  722.        
  723.         cmp   ax,cx
  724.         ja      .down_sb
  725.        
  726. @@:
  727.         mov   ebx,sb_btn_high   ;16  ;15
  728.         add   bx,sb_start_y
  729.         sub   cx,bx
  730.         sub   ax,bx
  731.        
  732. .scroll_sb_1:  
  733.         mov   ebx,sb_run_size
  734. ;***************************************************************************** 
  735.         cmp   word sb_delta,1
  736.         je      .continue
  737.        
  738. @@:
  739.         mov   edx,eax
  740.         push  ebx
  741.         shr   ebx,1
  742.         sub   edx,ebx
  743.         pop   ebx
  744.         mov   sb_position2,edx
  745.         test  sb_position2,dword 0x80000000
  746.         jz       .test_1
  747.        
  748.         mov   sb_position2,dword 0
  749.         jmp   .continue
  750.        
  751. .test_1:
  752.         xor   edx,edx
  753.         mov   dx,sb_size_y
  754.         sub   edx,sb_btn_high
  755.         sub   edx,sb_btn_high
  756.         sub   edx,sb_run_size
  757.         cmp   sb_position2,edx
  758.         jbe   .continue
  759.        
  760.         mov   sb_position2,edx
  761.  
  762. .continue:  
  763.         mov   eax,sb_position2
  764.         sub   ecx,ebx
  765. .continue_1:
  766. ;*****************************************************************************  
  767.         mov   ebx,eax
  768.  
  769.         mov   eax,sb_max_area
  770.         cmp   eax,sb_cur_area
  771.         ja      @f
  772.  
  773.         xor   eax,eax
  774.         inc   eax
  775.         mov   sb_position2,eax
  776.         jmp   .all_sb
  777. @@:
  778.         sub   eax,sb_cur_area
  779.         inc   eax
  780.         shl   eax,10
  781.         xor   edx,edx
  782.         div   ecx
  783.         shl   edx,1
  784.         cmp   edx,ecx
  785.         jb      @f
  786.        
  787.         inc   eax
  788.        
  789. @@:
  790.         imul  eax,ebx
  791.         shr   eax,10
  792.        
  793.         cmp   sb_position,eax
  794.         je      .exit_sb
  795.        
  796.         cmp   eax,0
  797.         ja      @f
  798.        
  799.         xor   eax,eax
  800.        
  801. @@:
  802. .store_position:
  803.         mov   sb_position,eax
  804. .all_sb:
  805.         mov   sb_redraw,dword 1
  806.         call  .draw_1
  807.         mov   eax,sb_m_pos
  808.         mov   sb_m_pos_2,eax
  809.         jmp   .exit_sb
  810. ;*****************************************************************************
  811. .down_sb:
  812.         cmp   dword sb_m_keys,0
  813.         je   .exit_sb
  814.        
  815.         mov   eax,sb_max_area
  816.         mov   ebx,sb_ar_offset
  817.         sub   eax,sb_cur_area
  818.         push  eax
  819.         sub   eax,ebx
  820.         cmp   sb_position,eax
  821.         pop   eax
  822.         jae   @f
  823.        
  824.         add   sb_position,ebx
  825.         jmp   .all_sb
  826. @@:
  827.         mov   sb_position,eax
  828.         xor   eax,eax
  829.         mov   ax,sb_size_y
  830.         sub   eax,sb_btn_high
  831.         sub   eax,sb_btn_high
  832.         sub   eax,sb_run_size
  833.         mov   sb_position2,eax
  834.         jmp   .all_sb  
  835. .exit_sb:      
  836. scroll_bar_exit
  837. }
  838.  
  839. ;*****************************************************************************
  840. ;*****************************************************************************
  841. ;*****************************************************************************
  842. ;*****************************************************************************
  843. ;*****************************************************************************
  844. macro use_scroll_bar_horizontal
  845. {
  846. scroll_bar_horizontal:
  847. .draw:
  848.         pusha
  849.         mov   edi,dword [esp+36]
  850.         mov   sb_delta,word 0
  851.         call  .draw_1
  852.         mov   sb_all_redraw,dword 0
  853. scroll_bar_exit
  854. .draw_1:
  855.         pusha
  856. ;*********************************
  857.         xor   eax,eax
  858.         mov   ax,sb_size_x      ;sb_size_y
  859.         mov   edx,sb_btn_high
  860.         shl   edx,1
  861.         sub   eax,edx
  862.         mov   sb_work_size,eax
  863. ;*********************************
  864.         mov   eax,sb_work_size   ;sb_max_area
  865.         mov   ebx,sb_max_area
  866.         cmp   ebx,sb_cur_area
  867.         ja      @f
  868.  
  869.         jmp   .no_size
  870.  
  871. @@:
  872.         imul  eax,sb_cur_area
  873.         xor   edx,edx
  874.         div   ebx
  875.         cmp   eax,10
  876.         jae   @f
  877.         mov   eax,10
  878. @@:
  879. .no_size:
  880.         mov   sb_run_size,eax
  881. ;*********************************
  882.         cmp   word sb_delta,1
  883.         je      .@@_3
  884.         mov   eax,sb_work_size
  885.         sub   eax,sb_run_size
  886.         mov   ebx,sb_max_area
  887.         cmp   ebx,sb_cur_area
  888.         ja      @f
  889.         xor   eax,eax
  890.         jmp   .@@_1
  891. @@:
  892.         sub   ebx,sb_cur_area
  893.         imul  eax,sb_position
  894.         xor   edx,edx
  895.         div   ebx
  896. .@@_1:
  897.         mov   sb_position2,eax
  898.         xor   edx,edx
  899.         mov   dx,sb_size_x
  900.         sub   edx,sb_btn_high
  901.         sub   edx,sb_btn_high
  902.         sub   edx,sb_run_size
  903.         cmp   sb_position2,edx
  904.         jbe   .@@_3
  905.         mov   sb_position2,edx
  906. .@@_3:
  907. ;*********************************     
  908.         mov   ebx,sb_size_x
  909.         mov   ecx,sb_start_y
  910.         shl   ecx,16
  911.         inc   ecx      
  912.         mov   edx,sb_line_col
  913.         mov   eax,13
  914.         cmp  dword sb_all_redraw,0
  915.         je   @f
  916.         int   0x40   ; top extreme line
  917. @@:
  918.         push  ecx
  919.         ror   ecx,16
  920.         add   cx,sb_size_y
  921.         rol   ecx,16
  922.         cmp  dword sb_all_redraw,0
  923.         je   @f
  924.         int   0x40   ; bottom extreme line
  925. @@:
  926.         pop   ecx
  927.  
  928.         push  ebx
  929.        
  930.         add   ecx,1 shl 16
  931.         mov   cx,sb_size_y
  932.         dec   ecx      
  933.         mov   bx,1
  934.         cmp  dword sb_all_redraw,0
  935.         je   @f
  936.         int   0x40   ; left button - extreme line
  937. @@:
  938.         push  ebx
  939.         add   ebx,1 shl 16
  940.         add   ebx,sb_btn_high
  941.         sub   ebx,2
  942.         mov   edx,sb_frnt_col
  943.         cmp  dword sb_all_redraw,0
  944.         je   @f
  945.         int   0x40   ; left  button filling
  946. ;*********************************     
  947. draw_up_arrow_horizontal
  948. ;*********************************
  949. @@:
  950.         pop   ebx
  951.        
  952.         ror   ebx,16
  953.         add   ebx,sb_btn_high  ;14 shl 16
  954.         rol   ebx,16
  955.         mov   edx,sb_line_col
  956.         cmp  dword sb_all_redraw,0
  957.         je   @f
  958.         int   0x40   ;  left  button - right line
  959. @@:
  960.         pop   ebx
  961. ;*********************************
  962.         ror   ebx,16   
  963.         add   ebx,sb_btn_high  ;15 shl 16
  964.           inc   ebx
  965.         rol   ebx,16
  966.         sub   ebx,sb_btn_high  ;30
  967.         sub   ebx,sb_btn_high
  968.         push  ebx
  969.         mov   bx,0
  970.         add   ebx,sb_position2
  971.           dec   bx
  972.         mov   eax,13
  973.         test  bx,0x8000
  974.         jnz   @f
  975.         mov   edx,sb_bckg_col
  976.         int   0x40      ; left interval
  977. @@:
  978. ;*********************************
  979.         shr   ebx,16
  980.         add   ebx,sb_position2
  981.         dec   ebx
  982.         shl   ebx,16
  983.         inc   ebx
  984.         mov   edx,sb_line_col
  985.         int   0x40      ; runner - left extreme line
  986.        
  987.         add   ebx,1 shl 16
  988.         mov   bx,0
  989.         add   ebx,sb_run_size
  990.         mov   sb_r_size_x,ebx
  991.         mov   sb_r_size_y,ecx
  992.         sub   ebx,2
  993.         mov   edx,sb_frnt_col
  994.         int   0x40   ; runner filling
  995. ;*********************************
  996. draw_runner_center_horizontal
  997. ;*********************************
  998.         cmp word sb_type,1
  999.         jne @f
  1000.                 push eax ebx ecx edx
  1001.                 xor eax,eax
  1002.                 add ax,sb_r_start_x
  1003.                 dec eax
  1004.                 movzx ebx,word sb_start_y
  1005.                 mov ecx,sb_run_size
  1006.                 dec ecx
  1007.                 movzx edx,word sb_size_y
  1008.                 ;à¨á®¢ ­¨¥ á⨫쭮© à ¬ª¨ ­  ¯®«§ã­ª¥
  1009.                 stdcall draw_edge, eax,ebx,ecx,edx,\
  1010.                         sb_bckg_col, sb_frnt_col, sb_line_col
  1011.                 pop edx ecx ebx eax
  1012.         @@:
  1013.  
  1014.         shr   ebx,16
  1015.         add   ebx,sb_run_size
  1016.         sub   ebx,2
  1017.         shl   ebx,16  
  1018.         inc   ebx
  1019.         mov   edx,sb_line_col
  1020.         int   0x40   ; runner - bottom extreme line
  1021.        
  1022.         add   ebx,1 shl 16
  1023.         mov   bx,sb_start_x
  1024.         add   bx,sb_size_x
  1025.         sub   ebx,sb_btn_high
  1026.         dec   ebx
  1027.         mov   eax,ebx
  1028.         shr   eax,16
  1029.         sub   bx,ax
  1030.         test  bx,0x8000
  1031.         jnz   @f
  1032.         mov   edx,sb_bckg_col
  1033.         mov   eax,13
  1034.         int   0x40   ; bottom interval
  1035. @@:
  1036.         pop   ebx      
  1037. ;*********************************     
  1038.         mov   ax,bx
  1039.         shr   ebx,16
  1040.         add   bx,ax
  1041.         sub   ebx,2
  1042.         shl   ebx,16
  1043.         inc   ebx
  1044.         mov   edx,sb_line_col
  1045.         mov   eax,13
  1046.         cmp  dword sb_all_redraw,0
  1047.         je   @f
  1048.         int   0x40      ; bottom button - top line
  1049. @@:
  1050.         push  ebx
  1051.         add   ebx,1 shl 16
  1052.         add   bx,sb_btn_high
  1053.         sub   ebx,2
  1054.         mov   edx,sb_frnt_col
  1055.         cmp  dword sb_all_redraw,0
  1056.         je   @f
  1057.         int   0x40   ; bottom button filling
  1058. ;*********************************
  1059. draw_down_arrow_horizontal
  1060. ;*********************************
  1061. @@:
  1062.         pop   ebx
  1063.        
  1064.         ror   ebx,16
  1065.         add   ebx,sb_btn_high  ;14 shl 16
  1066.         rol   ebx,16
  1067.        
  1068.         mov   edx,sb_line_col
  1069.         mov   bx,1
  1070.         cmp  dword sb_all_redraw,0
  1071.         je   @f
  1072.         int   0x40   ; bottom button - extreme line
  1073.         cmp word sb_type,1
  1074.         jne @f
  1075.                 ;à¨á®¢ ­¨¥ á⨫쭮© à ¬ª¨ ­  «¥¢®© ª­®¯ª¥
  1076.                 movzx eax,word sb_start_x
  1077.                 movzx ebx,word sb_start_y
  1078.                 movzx edx,word sb_size_y
  1079.                 stdcall draw_edge, eax,ebx,sb_btn_high,edx,\
  1080.                         sb_bckg_col, sb_frnt_col, sb_line_col
  1081.  
  1082.                 movzx eax,word sb_start_x
  1083.                 add ax,sb_size_x
  1084.                 sub eax,sb_btn_high
  1085.                 dec eax
  1086.                 ;à¨á®¢ ­¨¥ á⨫쭮© à ¬ª¨ ­  ¯à ¢®© ª­®¯ª¥
  1087.                 stdcall draw_edge, eax,ebx,sb_btn_high,edx,\
  1088.                         sb_bckg_col, sb_frnt_col, sb_line_col
  1089. @@:
  1090.         popa
  1091.         ret
  1092. ;*****************************************************************************
  1093. ; mouse event
  1094. ;*****************************************************************************
  1095. .mouse:
  1096.         pusha
  1097.         mov      edi,dword [esp+36]
  1098.         mcall 37,1
  1099.         mov   sb_m_pos,eax
  1100.         cmp   dword sb_m_pos_2,0
  1101.         jne   @f
  1102.        
  1103.         mov   sb_m_pos_2,eax   
  1104. @@:
  1105.         mcall 37,2
  1106.         mov   sb_m_keys,eax    
  1107.  
  1108.         cmp   sb_m_keys,eax
  1109.         je        @f
  1110.        
  1111.         mov   sb_m_keys,eax
  1112.  
  1113.         mov   sb_delta,dword 0
  1114.        
  1115.         mov   eax,sb_m_pos
  1116.         mov   sb_m_pos_2,eax
  1117.         jmp   .continue_2
  1118.        
  1119. @@:
  1120.         cmp   dword sb_m_keys,0
  1121.         jne      @f
  1122.         mov   eax,sb_m_pos
  1123.         mov   sb_m_pos_2,eax
  1124.         jmp   .correct_1        ;.exit_sb
  1125. @@:
  1126.         mov   sb_delta,word 1
  1127.  
  1128. .continue_2:
  1129.         mov   eax,sb_m_pos
  1130.         test  eax,0x80000000
  1131.         jnz   .exit_sb
  1132.        
  1133.         test  eax,0x8000
  1134.         jnz   .exit_sb
  1135.        
  1136.         mov   ebx,eax
  1137.         shr   eax,16   ; x position
  1138.         shl   ebx,16
  1139.         shr   ebx,16   ; y position
  1140.  
  1141.         mov   cx,sb_start_x   ;y
  1142.         cmp   ax,cx
  1143.         jb      .exit_sb
  1144.        
  1145.         cmp   word sb_delta2,0
  1146.         je      @f
  1147.         push  ecx
  1148.         add   cx,sb_btn_high
  1149.         cmp   ax,cx
  1150.         pop   ecx
  1151.         jb      .exit_sb
  1152.        
  1153. @@:
  1154.         add   cx,sb_size_x      ;y
  1155.         cmp   ax,cx
  1156.         ja      .exit_sb
  1157.  
  1158.         cmp   word sb_delta2,0
  1159.         je      @f
  1160.         sub   cx,sb_btn_high
  1161.         cmp   ax,cx
  1162.         ja      .exit_sb
  1163.        
  1164. @@:
  1165.         cmp   word sb_delta2,1
  1166.         je      @f
  1167.        
  1168.         cmp   dword sb_m_keys,0
  1169.         je      .exit_sb
  1170.        
  1171.         mov   cx,sb_start_y   ;x
  1172.         cmp   bx,cx
  1173.         jb      .exit_sb
  1174.        
  1175.         add   cx,sb_size_y      ;x
  1176.         cmp   bx,cx
  1177.         ja      .exit_sb
  1178.        
  1179.         mov   cx,sb_r_start_x
  1180.         cmp   ax,cx
  1181.         jb      .no_runner
  1182.        
  1183.         add   cx,sb_r_size_x
  1184.         cmp   ax,cx
  1185.         ja      .no_runner
  1186.  
  1187.         mov   sb_delta2,word 1
  1188. @@:
  1189.         push  eax
  1190.         mov   eax,sb_m_pos
  1191.         mov   ebx,sb_m_pos_2
  1192.         shr   eax,16
  1193.         shr   ebx,16
  1194.         cmp   eax,ebx
  1195.         je      .correct       
  1196.        
  1197. ;       shl   eax,16
  1198. ;       shr   eax,16
  1199. ;       mov   ebx,sb_m_pos_2
  1200. ;       shl   ebx,16
  1201. ;       shr   ebx,16
  1202. ;       cmp   eax,ebx
  1203.         jb   .sub
  1204.        
  1205.         sub   eax,ebx
  1206.         mov   ebx,eax
  1207.         add   sb_position2,ebx
  1208.         xor   eax,eax
  1209.         mov   ax,sb_size_x      ;y
  1210.         sub   eax,sb_btn_high
  1211.         sub   eax,sb_btn_high
  1212.         sub   eax,sb_run_size
  1213.         cmp   sb_position2,eax
  1214.         jbe   @f
  1215.        
  1216.         mov   sb_position2,eax
  1217. @@:
  1218.         mov   eax,sb_m_pos
  1219.         mov   sb_m_pos_2,eax
  1220.         pop   eax
  1221.         call  .draw_1
  1222.         jmp   .no_runner_1
  1223.        
  1224. .correct:
  1225.         pop   eax
  1226.         jmp   .exit_sb
  1227. .correct_1:
  1228.         mov   sb_delta,dword 0
  1229.         jmp   .exit_sb
  1230.  
  1231. .sub:
  1232.         sub   ebx,eax
  1233.         sub   sb_position2,ebx
  1234.         test  sb_position2,dword 0x80000000
  1235.         jz        @f
  1236.        
  1237.         mov   sb_position2,dword 0
  1238. @@:
  1239.         mov   eax,sb_m_pos
  1240.         mov   sb_m_pos_2,eax
  1241.         pop   eax
  1242.         call  .draw_1
  1243.         jmp   .no_runner_1
  1244.  
  1245. ;*****************************************************************************
  1246. .no_runner:
  1247.         mov   sb_delta,dword 0
  1248. .no_runner_1:
  1249.         xor   ecx,ecx
  1250.         mov   cx,sb_start_x   ;y
  1251.         add   cx,sb_btn_high   ;15
  1252.         cmp   word sb_delta,1
  1253.         je      .scroll_sb
  1254.        
  1255.         cmp   ax,cx
  1256.         ja      .scroll_sb
  1257.        
  1258.         cmp   dword sb_m_keys,0
  1259.         je   .exit_sb
  1260.        
  1261.         mov   eax,sb_ar_offset
  1262.         cmp   sb_position,eax  ;dword 0
  1263.         jbe   @f
  1264.        
  1265.         sub   sb_position,eax
  1266.         jmp   .all_sb
  1267. @@:
  1268.         xor   eax,eax
  1269.         mov   sb_position,eax ;dword 0
  1270.         mov   sb_position2,eax  ;dword 0
  1271.         jmp   .all_sb
  1272. ;*****************************************************************************
  1273. .scroll_sb:
  1274.         add   cx,sb_size_x      ;y
  1275.         sub   cx,sb_btn_high
  1276.         sub   cx,sb_btn_high
  1277.         cmp   word sb_delta,1
  1278.         je      @f
  1279.        
  1280.         cmp   ax,cx
  1281.         ja      .down_sb
  1282.        
  1283. @@:
  1284.         mov   ebx,sb_btn_high   ;16  ;15
  1285.         add   bx,sb_start_x     ;y
  1286.         sub   cx,bx
  1287.         sub   ax,bx
  1288.        
  1289. .scroll_sb_1:  
  1290.         mov   ebx,sb_run_size
  1291. ;***************************************************************************** 
  1292.         cmp   word sb_delta,1
  1293.         je      .continue
  1294.        
  1295. @@:
  1296.         mov   edx,eax
  1297.  
  1298.         push  ebx
  1299.         shr   ebx,1
  1300.         sub   edx,ebx
  1301.         pop   ebx
  1302.         mov   sb_position2,edx
  1303.         test  sb_position2,dword 0x80000000
  1304.         jz       .test_1
  1305.        
  1306.         mov   sb_position2,dword 0
  1307.         jmp   .continue
  1308.        
  1309. .test_1:
  1310.         xor   edx,edx
  1311.         mov   dx,sb_size_x       ;y
  1312.         sub   edx,sb_btn_high
  1313.         sub   edx,sb_btn_high
  1314.         sub   edx,sb_run_size
  1315.         cmp   sb_position2,edx
  1316.         jbe   .continue
  1317.        
  1318.         mov   sb_position2,edx
  1319.  
  1320. .continue:  
  1321.         mov   eax,sb_position2
  1322.         sub   ecx,ebx
  1323. .continue_1:
  1324. ;*****************************************************************************  
  1325.         mov   ebx,eax
  1326.  
  1327.         mov   eax,sb_max_area
  1328.         cmp   eax,sb_cur_area
  1329.         ja      @f
  1330.  
  1331.         xor   eax,eax
  1332.         inc   eax
  1333.         mov   sb_position2,eax
  1334.         jmp   .all_sb
  1335. @@:
  1336.         sub   eax,sb_cur_area
  1337.         inc   eax
  1338.         shl   eax,10
  1339.         xor   edx,edx
  1340.         div   ecx
  1341.         shl   edx,1
  1342.         cmp   edx,ecx
  1343.         jb      @f
  1344.        
  1345.         inc   eax
  1346.        
  1347. @@:
  1348.         imul  eax,ebx
  1349.         shr   eax,10
  1350.        
  1351.         cmp   sb_position,eax
  1352.         je      .exit_sb
  1353.        
  1354.         cmp   eax,0
  1355.         ja      @f
  1356.        
  1357.         xor   eax,eax
  1358.        
  1359. @@:
  1360. .store_position:
  1361.         mov   sb_position,eax
  1362. .all_sb:
  1363.         mov   sb_redraw,dword 1
  1364.         call  .draw_1
  1365.         mov   eax,sb_m_pos
  1366.         mov   sb_m_pos_2,eax
  1367.         jmp   .exit_sb
  1368. ;*****************************************************************************
  1369. .down_sb:
  1370.         cmp   dword sb_m_keys,0
  1371.         je   .exit_sb
  1372.        
  1373.         mov   eax,sb_max_area
  1374.         mov   ebx,sb_ar_offset
  1375.         sub   eax,sb_cur_area
  1376.         push  eax
  1377.         sub   eax,ebx
  1378.         cmp   sb_position,eax
  1379.         pop   eax
  1380.         jae   @f
  1381.        
  1382.         add   sb_position,ebx
  1383.         jmp   .all_sb
  1384. @@:
  1385.         mov   sb_position,eax
  1386.         xor   eax,eax
  1387.         mov   ax,sb_size_x
  1388.         sub   eax,sb_btn_high
  1389.         sub   eax,sb_btn_high
  1390.         sub   eax,sb_run_size
  1391.         mov   sb_position2,eax
  1392.         jmp   .all_sb
  1393. .exit_sb:
  1394. scroll_bar_exit
  1395. }
  1396.