Subversion Repositories Kolibri OS

Rev

Rev 1041 | 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   sb_delta,word 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  sb_all_redraw,dword 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  sb_all_redraw,dword 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  sb_all_redraw,dword 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  sb_all_redraw,dword 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  sb_all_redraw,dword 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.         shr   ecx,16
  446.         add   ecx,sb_run_size
  447.         sub   ecx,2
  448.         shl   ecx,16  
  449.         inc   ecx
  450.         mov   edx,sb_line_col
  451.         int   0x40   ; runner - bottom extreme line
  452.        
  453.         add   ecx,1 shl 16
  454.         mov   cx,sb_start_y
  455.         add   cx,sb_size_y
  456.         sub   ecx,sb_btn_high
  457.         dec   ecx
  458.         mov   eax,ecx
  459.         shr   eax,16
  460.         sub   cx,ax
  461.         test  cx,0x8000
  462.         jnz       @f
  463.         mov   edx,sb_bckg_col
  464.         mov   eax,13
  465.         int   0x40   ; bottom interval
  466. @@:    
  467.         pop   ecx      
  468. ;*********************************     
  469.         mov   ax,cx
  470.         shr   ecx,16
  471.         add   cx,ax
  472.         sub   ecx,2
  473.         shl   ecx,16
  474.         inc   ecx
  475.         mov   edx,sb_line_col
  476.         mov   eax,13
  477.         cmp  sb_all_redraw,dword 0
  478.         je   @f
  479.         int   0x40   ; bottom button - top line
  480. @@:
  481.         push  ecx
  482.         add   ecx,1 shl 16
  483.         add   cx,sb_btn_high
  484.         sub   ecx,2
  485.         mov   edx,sb_frnt_col
  486.         cmp  sb_all_redraw,dword 0
  487.         je   @f
  488.         int   0x40   ; bottom button filling
  489. ;*********************************
  490. draw_down_arrow_vertical
  491. ;*********************************
  492. @@:
  493.         pop   ecx
  494.        
  495.         ror   ecx,16
  496.         add   ecx,sb_btn_high
  497.         rol   ecx,16
  498.        
  499.         mov   edx,sb_line_col
  500.         mov   cx,1
  501.         cmp  sb_all_redraw,dword 0
  502.         je   @f
  503.         int   0x40   ; bottom button - extreme line
  504. @@:
  505.         popa
  506.         ret
  507. ;*****************************************************************************
  508. ;*****************************************************************************
  509. ; mouse event
  510. ;*****************************************************************************
  511. ;*****************************************************************************
  512. .mouse:
  513.         pusha
  514.         mov      edi,dword [esp+36]
  515.         mcall 37,1
  516.         mov   sb_m_pos,eax
  517.         cmp   sb_m_pos_2,dword 0
  518.         jne   @f
  519.        
  520.         mov   sb_m_pos_2,eax   
  521. @@:
  522.         mcall 37,2
  523.         mov   sb_m_keys,eax    
  524.  
  525.         cmp   sb_m_keys,eax
  526.         je        @f
  527.        
  528.         mov   sb_m_keys,eax
  529.  
  530.         mov   sb_delta,dword 0
  531.  
  532.         mov   eax,sb_m_pos
  533.         mov   sb_m_pos_2,eax
  534.         jmp   .continue_2
  535.        
  536. @@:
  537.         cmp   sb_m_keys,dword 0
  538.         jne      @f
  539.         mov   eax,sb_m_pos
  540.         mov   sb_m_pos_2,eax
  541.         jmp   .correct_1        ;.exit_sb      
  542. @@:
  543.         mov   sb_delta,word 1
  544.  
  545. .continue_2:
  546.         mov   eax,sb_m_pos
  547.         test  eax,0x80000000
  548.         jnz   .exit_sb
  549.        
  550.         test  eax,0x8000
  551.         jnz   .exit_sb
  552.        
  553.         mov   ebx,eax
  554.         shr   ebx,16   ; x position
  555.         shl   eax,16
  556.         shr   eax,16   ; y position
  557.  
  558.         mov   cx,sb_start_y
  559.         cmp   ax,cx
  560.         jb      .exit_sb
  561.        
  562.         cmp   sb_delta2,word 0
  563.         je      @f
  564.         push  ecx
  565.         add   cx,sb_btn_high
  566.         cmp   ax,cx
  567.         pop   ecx
  568.         jb      .exit_sb
  569.        
  570. @@:
  571.         add   cx,sb_size_y
  572.         cmp   ax,cx
  573.         ja      .exit_sb
  574.  
  575.         cmp   sb_delta2,word 0
  576.         je      @f
  577.         sub   cx,sb_btn_high
  578.         cmp   ax,cx
  579.         ja      .exit_sb
  580.        
  581. @@:
  582.         cmp   sb_delta2,word 1
  583.         je      @f
  584.        
  585.         cmp   sb_m_keys,dword 0
  586.         je      .exit_sb
  587.        
  588.         mov   cx,sb_start_x
  589.         cmp   bx,cx
  590.         jb      .exit_sb
  591.        
  592.         add   cx,sb_size_x
  593.         cmp   bx,cx
  594.         ja      .exit_sb
  595.  
  596.         mov   cx,sb_r_start_y
  597.         cmp   ax,cx
  598.         jb      .no_runner
  599.        
  600.         add   cx,sb_r_size_y
  601.         cmp   ax,cx
  602.         ja      .no_runner
  603.  
  604.         mov   sb_delta2,word 1 
  605. @@:
  606.         push  eax
  607.         mov   ax,sb_m_pos
  608.         cmp   ax,sb_m_pos_2
  609.         je      .correct       
  610.        
  611.         shl   eax,16
  612.         shr   eax,16
  613.         mov   ebx,sb_m_pos_2
  614.         shl   ebx,16
  615.         shr   ebx,16
  616.         cmp   eax,ebx
  617.         jb   .sub
  618.        
  619.         sub   eax,ebx
  620.         mov   ebx,eax
  621.         add   sb_position2,ebx
  622.         xor   eax,eax
  623.         mov   ax,sb_size_y
  624.         sub   eax,sb_btn_high
  625.         sub   eax,sb_btn_high
  626.         sub   eax,sb_run_size
  627.         cmp   sb_position2,eax
  628.         jbe   @f
  629.        
  630.         mov   sb_position2,eax
  631. @@:
  632.         mov   eax,sb_m_pos
  633.         mov   sb_m_pos_2,eax
  634.         pop   eax
  635.         call  .draw_1
  636.         jmp   .no_runner_1
  637.        
  638. .correct:
  639.         pop   eax
  640.         jmp   .exit_sb
  641. .correct_1:
  642.         mov   sb_delta,dword 0
  643.         jmp   .exit_sb
  644.  
  645. .sub:
  646.         sub   ebx,eax
  647.         sub   sb_position2,ebx
  648.         test  sb_position2,dword 0x80000000
  649.         jz        @f
  650.        
  651.         mov   sb_position2,dword 0
  652. @@:
  653.         mov   eax,sb_m_pos
  654.         mov   sb_m_pos_2,eax
  655.         pop   eax
  656.         call  .draw_1
  657.         jmp   .no_runner_1
  658.  
  659. ;*****************************************************************************
  660. .no_runner:
  661.         mov   sb_delta,dword 0
  662. .no_runner_1:
  663.         xor   ecx,ecx
  664.         mov   cx,sb_start_y
  665.         add   cx,sb_btn_high   ;15
  666.         cmp   sb_delta,word 1
  667.         je      .scroll_sb
  668.        
  669.         cmp   ax,cx
  670.         ja      .scroll_sb
  671.        
  672.         cmp   sb_m_keys,dword 0
  673.         je   .exit_sb
  674.        
  675.         mov   eax,sb_ar_offset
  676.         cmp   sb_position,eax  ;dword 0
  677.         jbe   @f
  678.        
  679.         sub   sb_position,eax
  680.         jmp   .all_sb
  681. @@:
  682.         xor   eax,eax
  683.         mov   sb_position,eax ;dword 0
  684.         mov   sb_position2,eax ;dword 0
  685.         jmp   .all_sb
  686. ;*****************************************************************************
  687. .scroll_sb:
  688.         add   cx,sb_size_y
  689.         sub   cx,sb_btn_high
  690.         sub   cx,sb_btn_high
  691.         cmp   sb_delta,word 1
  692.         je      @f
  693.        
  694.         cmp   ax,cx
  695.         ja      .down_sb
  696.        
  697. @@:
  698.         mov   ebx,sb_btn_high   ;16  ;15
  699.         add   bx,sb_start_y
  700.         sub   cx,bx
  701.         sub   ax,bx
  702.        
  703. .scroll_sb_1:  
  704.         mov   ebx,sb_run_size
  705. ;***************************************************************************** 
  706.         cmp   sb_delta,word 1
  707.         je      .continue
  708.        
  709. @@:
  710.         mov   edx,eax
  711.         push  ebx
  712.         shr   ebx,1
  713.         sub   edx,ebx
  714.         pop   ebx
  715.         mov   sb_position2,edx
  716.         test  sb_position2,dword 0x80000000
  717.         jz       .test_1
  718.        
  719.         mov   sb_position2,dword 0
  720.         jmp   .continue
  721.        
  722. .test_1:
  723.         xor   edx,edx
  724.         mov   dx,sb_size_y
  725.         sub   edx,sb_btn_high
  726.         sub   edx,sb_btn_high
  727.         sub   edx,sb_run_size
  728.         cmp   sb_position2,edx
  729.         jbe   .continue
  730.        
  731.         mov   sb_position2,edx
  732.  
  733. .continue:  
  734.         mov   eax,sb_position2
  735.         sub   ecx,ebx
  736. .continue_1:
  737. ;*****************************************************************************  
  738.         mov   ebx,eax
  739.  
  740.         mov   eax,sb_max_area
  741.         cmp   eax,sb_cur_area
  742.         ja      @f
  743.  
  744.         xor   eax,eax
  745.         inc   eax
  746.         mov   sb_position2,eax
  747.         jmp   .all_sb
  748. @@:
  749.         sub   eax,sb_cur_area
  750.         inc   eax
  751.         shl   eax,10
  752.         xor   edx,edx
  753.         div   ecx
  754.         shl   edx,1
  755.         cmp   edx,ecx
  756.         jb      @f
  757.        
  758.         inc   eax
  759.        
  760. @@:
  761.         imul  eax,ebx
  762.         shr   eax,10
  763.        
  764.         cmp   sb_position,eax
  765.         je      .exit_sb
  766.        
  767.         cmp   eax,0
  768.         ja      @f
  769.        
  770.         xor   eax,eax
  771.        
  772. @@:
  773. .store_position:
  774.         mov   sb_position,eax
  775. .all_sb:
  776.         mov   sb_redraw,dword 1
  777.         call  .draw_1
  778.         mov   eax,sb_m_pos
  779.         mov   sb_m_pos_2,eax
  780.         jmp   .exit_sb
  781. ;*****************************************************************************
  782. .down_sb:
  783.         cmp   sb_m_keys,dword 0
  784.         je   .exit_sb
  785.        
  786.         mov   eax,sb_max_area
  787.         mov   ebx,sb_ar_offset
  788.         sub   eax,sb_cur_area
  789.         push  eax
  790.         sub   eax,ebx
  791.         cmp   sb_position,eax
  792.         pop   eax
  793.         jae   @f
  794.        
  795.         add   sb_position,ebx
  796.         jmp   .all_sb
  797. @@:
  798.         mov   sb_position,eax
  799.         xor   eax,eax
  800.         mov   ax,sb_size_y
  801.         sub   eax,sb_btn_high
  802.         sub   eax,sb_btn_high
  803.         sub   eax,sb_run_size
  804.         mov   sb_position2,eax
  805.         jmp   .all_sb  
  806. .exit_sb:      
  807. scroll_bar_exit
  808. }
  809.  
  810. ;*****************************************************************************
  811. ;*****************************************************************************
  812. ;*****************************************************************************
  813. ;*****************************************************************************
  814. ;*****************************************************************************
  815. macro use_scroll_bar_horizontal
  816. {
  817. scroll_bar_horizontal:
  818. .draw:
  819.         pusha
  820.         mov   edi,dword [esp+36]
  821.         mov   sb_delta,word 0
  822.         call  .draw_1
  823.         mov   sb_all_redraw,dword 0
  824. scroll_bar_exit
  825. .draw_1:
  826.         pusha
  827. ;*********************************
  828.         xor   eax,eax
  829.         mov   ax,sb_size_x      ;sb_size_y
  830.         mov   edx,sb_btn_high
  831.         shl   edx,1
  832.         sub   eax,edx
  833.         mov   sb_work_size,eax
  834. ;*********************************
  835.         mov   eax,sb_work_size   ;sb_max_area
  836.         mov   ebx,sb_max_area
  837.         cmp   ebx,sb_cur_area
  838.         ja      @f
  839.  
  840.         jmp   .no_size
  841.  
  842. @@:
  843.         imul  eax,sb_cur_area
  844.         xor   edx,edx
  845.         div   ebx
  846.         cmp   eax,10
  847.         jae   @f
  848.         mov   eax,10
  849. @@:
  850. .no_size:
  851.         mov   sb_run_size,eax
  852. ;*********************************
  853.         cmp   sb_delta,word 1
  854.         je      .@@_3
  855.         mov   eax,sb_work_size
  856.         sub   eax,sb_run_size
  857.         mov   ebx,sb_max_area
  858.         cmp   ebx,sb_cur_area
  859.         ja      @f
  860.         xor   eax,eax
  861.         jmp   .@@_1
  862. @@:
  863.         sub   ebx,sb_cur_area
  864.         imul  eax,sb_position
  865.         xor   edx,edx
  866.         div   ebx
  867. .@@_1:
  868.         mov   sb_position2,eax
  869.         xor   edx,edx
  870.         mov   dx,sb_size_x
  871.         sub   edx,sb_btn_high
  872.         sub   edx,sb_btn_high
  873.         sub   edx,sb_run_size
  874.         cmp   sb_position2,edx
  875.         jbe   .@@_3
  876.         mov   sb_position2,edx
  877. .@@_3:
  878. ;*********************************     
  879.         mov   ebx,sb_size_x
  880.         mov   ecx,sb_start_y
  881.         shl   ecx,16
  882.         inc   ecx      
  883.         mov   edx,sb_line_col
  884.         mov   eax,13
  885.         cmp  sb_all_redraw,dword 0
  886.         je   @f
  887.         int   0x40   ; top extreme line
  888. @@:
  889.         push  ecx
  890.         ror   ecx,16
  891.         add   cx,sb_size_y
  892.         rol   ecx,16
  893.         cmp  sb_all_redraw,dword 0
  894.         je   @f
  895.         int   0x40   ; bottom extreme line
  896. @@:
  897.         pop   ecx
  898.  
  899.         push  ebx
  900.        
  901.         add   ecx,1 shl 16
  902.         mov   cx,sb_size_y
  903.         dec   ecx      
  904.         mov   bx,1
  905.         cmp  sb_all_redraw,dword 0
  906.         je   @f
  907.         int   0x40   ; left button - extreme line
  908. @@:
  909.         push  ebx
  910.         add   ebx,1 shl 16
  911.         add   ebx,sb_btn_high
  912.         sub   ebx,2
  913.         mov   edx,sb_frnt_col
  914.         cmp  sb_all_redraw,dword 0
  915.         je   @f
  916.         int   0x40   ; left  button filling
  917. ;*********************************     
  918. draw_up_arrow_horizontal
  919. ;*********************************
  920. @@:
  921.         pop   ebx
  922.        
  923.         ror   ebx,16
  924.         add   ebx,sb_btn_high  ;14 shl 16
  925.         rol   ebx,16
  926.         mov   edx,sb_line_col
  927.         cmp  sb_all_redraw,dword 0
  928.         je   @f
  929.         int   0x40   ;  left  button - right line
  930. @@:
  931.         pop   ebx
  932. ;*********************************
  933.         ror   ebx,16   
  934.         add   ebx,sb_btn_high  ;15 shl 16
  935.           inc   ebx
  936.         rol   ebx,16
  937.         sub   ebx,sb_btn_high  ;30
  938.         sub   ebx,sb_btn_high
  939.         push  ebx
  940.         mov   bx,0
  941.         add   ebx,sb_position2
  942.           dec   bx
  943.         mov   eax,13
  944.         test  bx,0x8000
  945.         jnz   @f
  946.         mov   edx,sb_bckg_col
  947.         int   0x40      ; left interval
  948. @@:
  949. ;*********************************
  950.         shr   ebx,16
  951.         add   ebx,sb_position2
  952.         dec   ebx
  953.         shl   ebx,16
  954.         inc   ebx
  955.         mov   edx,sb_line_col
  956.         int   0x40      ; runner - left extreme line
  957.        
  958.         add   ebx,1 shl 16
  959.         mov   bx,0
  960.         add   ebx,sb_run_size
  961.         mov   sb_r_size_x,ebx
  962.         mov   sb_r_size_y,ecx
  963.         sub   ebx,2
  964.         mov   edx,sb_frnt_col
  965.         int   0x40   ; runner filling
  966. ;*********************************
  967. draw_runner_center_horizontal
  968. ;*********************************
  969.         shr   ebx,16
  970.         add   ebx,sb_run_size
  971.         sub   ebx,2
  972.         shl   ebx,16  
  973.         inc   ebx
  974.         mov   edx,sb_line_col
  975.         int   0x40   ; runner - bottom extreme line
  976.        
  977.         add   ebx,1 shl 16
  978.         mov   bx,sb_start_x
  979.         add   bx,sb_size_x
  980.         sub   ebx,sb_btn_high
  981.         dec   ebx
  982.         mov   eax,ebx
  983.         shr   eax,16
  984.         sub   bx,ax
  985.         test  bx,0x8000
  986.         jnz   @f
  987.         mov   edx,sb_bckg_col
  988.         mov   eax,13
  989.         int   0x40   ; bottom interval
  990. @@:
  991.         pop   ebx      
  992. ;*********************************     
  993.         mov   ax,bx
  994.         shr   ebx,16
  995.         add   bx,ax
  996.         sub   ebx,2
  997.         shl   ebx,16
  998.         inc   ebx
  999.         mov   edx,sb_line_col
  1000.         mov   eax,13
  1001.         cmp  sb_all_redraw,dword 0
  1002.         je   @f
  1003.         int   0x40      ; bottom button - top line
  1004. @@:
  1005.         push  ebx
  1006.         add   ebx,1 shl 16
  1007.         add   bx,sb_btn_high
  1008.         sub   ebx,2
  1009.         mov   edx,sb_frnt_col
  1010.         cmp  sb_all_redraw,dword 0
  1011.         je   @f
  1012.         int   0x40   ; bottom button filling
  1013. ;*********************************
  1014. draw_down_arrow_horizontal
  1015. ;*********************************
  1016. @@:
  1017.         pop   ebx
  1018.        
  1019.         ror   ebx,16
  1020.         add   ebx,sb_btn_high  ;14 shl 16
  1021.         rol   ebx,16
  1022.        
  1023.         mov   edx,sb_line_col
  1024.         mov   bx,1
  1025.         cmp  sb_all_redraw,dword 0
  1026.         je   @f
  1027.         int   0x40   ; bottom button - extreme line
  1028. @@:
  1029.         popa
  1030.         ret
  1031. ;*****************************************************************************
  1032. ; mouse event
  1033. ;*****************************************************************************
  1034. .mouse:
  1035.         pusha
  1036.         mov      edi,dword [esp+36]
  1037.         mcall 37,1
  1038.         mov   sb_m_pos,eax
  1039.         cmp   sb_m_pos_2,dword 0
  1040.         jne   @f
  1041.        
  1042.         mov   sb_m_pos_2,eax   
  1043. @@:
  1044.         mcall 37,2
  1045.         mov   sb_m_keys,eax    
  1046.  
  1047.         cmp   sb_m_keys,eax
  1048.         je        @f
  1049.        
  1050.         mov   sb_m_keys,eax
  1051.  
  1052.         mov   sb_delta,dword 0
  1053.        
  1054.         mov   eax,sb_m_pos
  1055.         mov   sb_m_pos_2,eax
  1056.         jmp   .continue_2
  1057.        
  1058. @@:
  1059.         cmp   sb_m_keys,dword 0
  1060.         jne      @f
  1061.         mov   eax,sb_m_pos
  1062.         mov   sb_m_pos_2,eax
  1063.         jmp   .correct_1        ;.exit_sb
  1064. @@:
  1065.         mov   sb_delta,word 1
  1066.  
  1067. .continue_2:
  1068.         mov   eax,sb_m_pos
  1069.         test  eax,0x80000000
  1070.         jnz   .exit_sb
  1071.        
  1072.         test  eax,0x8000
  1073.         jnz   .exit_sb
  1074.        
  1075.         mov   ebx,eax
  1076.         shr   eax,16   ; x position
  1077.         shl   ebx,16
  1078.         shr   ebx,16   ; y position
  1079.  
  1080.         mov   cx,sb_start_x   ;y
  1081.         cmp   ax,cx
  1082.         jb      .exit_sb
  1083.        
  1084.         cmp   sb_delta2,word 0
  1085.         je      @f
  1086.         push  ecx
  1087.         add   cx,sb_btn_high
  1088.         cmp   ax,cx
  1089.         pop   ecx
  1090.         jb      .exit_sb
  1091.        
  1092. @@:
  1093.         add   cx,sb_size_x      ;y
  1094.         cmp   ax,cx
  1095.         ja      .exit_sb
  1096.  
  1097.         cmp   sb_delta2,word 0
  1098.         je      @f
  1099.         sub   cx,sb_btn_high
  1100.         cmp   ax,cx
  1101.         ja      .exit_sb
  1102.        
  1103. @@:
  1104.         cmp   sb_delta2,word 1
  1105.         je      @f
  1106.        
  1107.         cmp   sb_m_keys,dword 0
  1108.         je      .exit_sb
  1109.        
  1110.         mov   cx,sb_start_y   ;x
  1111.         cmp   bx,cx
  1112.         jb      .exit_sb
  1113.        
  1114.         add   cx,sb_size_y      ;x
  1115.         cmp   bx,cx
  1116.         ja      .exit_sb
  1117.        
  1118.         mov   cx,sb_r_start_x
  1119.         cmp   ax,cx
  1120.         jb      .no_runner
  1121.        
  1122.         add   cx,sb_r_size_x
  1123.         cmp   ax,cx
  1124.         ja      .no_runner
  1125.  
  1126.         mov   sb_delta2,word 1
  1127. @@:
  1128.         push  eax
  1129.         mov   eax,sb_m_pos
  1130.         mov   ebx,sb_m_pos_2
  1131.         shr   eax,16
  1132.         shr   ebx,16
  1133.         cmp   eax,ebx
  1134.         je      .correct       
  1135.        
  1136. ;       shl   eax,16
  1137. ;       shr   eax,16
  1138. ;       mov   ebx,sb_m_pos_2
  1139. ;       shl   ebx,16
  1140. ;       shr   ebx,16
  1141. ;       cmp   eax,ebx
  1142.         jb   .sub
  1143.        
  1144.         sub   eax,ebx
  1145.         mov   ebx,eax
  1146.         add   sb_position2,ebx
  1147.         xor   eax,eax
  1148.         mov   ax,sb_size_x      ;y
  1149.         sub   eax,sb_btn_high
  1150.         sub   eax,sb_btn_high
  1151.         sub   eax,sb_run_size
  1152.         cmp   sb_position2,eax
  1153.         jbe   @f
  1154.        
  1155.         mov   sb_position2,eax
  1156. @@:
  1157.         mov   eax,sb_m_pos
  1158.         mov   sb_m_pos_2,eax
  1159.         pop   eax
  1160.         call  .draw_1
  1161.         jmp   .no_runner_1
  1162.        
  1163. .correct:
  1164.         pop   eax
  1165.         jmp   .exit_sb
  1166. .correct_1:
  1167.         mov   sb_delta,dword 0
  1168.         jmp   .exit_sb
  1169.  
  1170. .sub:
  1171.         sub   ebx,eax
  1172.         sub   sb_position2,ebx
  1173.         test  sb_position2,dword 0x80000000
  1174.         jz        @f
  1175.        
  1176.         mov   sb_position2,dword 0
  1177. @@:
  1178.         mov   eax,sb_m_pos
  1179.         mov   sb_m_pos_2,eax
  1180.         pop   eax
  1181.         call  .draw_1
  1182.         jmp   .no_runner_1
  1183.  
  1184. ;*****************************************************************************
  1185. .no_runner:
  1186.         mov   sb_delta,dword 0
  1187. .no_runner_1:
  1188.         xor   ecx,ecx
  1189.         mov   cx,sb_start_x   ;y
  1190.         add   cx,sb_btn_high   ;15
  1191.         cmp   sb_delta,word 1
  1192.         je      .scroll_sb
  1193.        
  1194.         cmp   ax,cx
  1195.         ja      .scroll_sb
  1196.        
  1197.         cmp   sb_m_keys,dword 0
  1198.         je   .exit_sb
  1199.        
  1200.         mov   eax,sb_ar_offset
  1201.         cmp   sb_position,eax  ;dword 0
  1202.         jbe   @f
  1203.        
  1204.         sub   sb_position,eax
  1205.         jmp   .all_sb
  1206. @@:
  1207.         xor   eax,eax
  1208.         mov   sb_position,eax ;dword 0
  1209.         mov   sb_position2,eax  ;dword 0
  1210.         jmp   .all_sb
  1211. ;*****************************************************************************
  1212. .scroll_sb:
  1213.         add   cx,sb_size_x      ;y
  1214.         sub   cx,sb_btn_high
  1215.         sub   cx,sb_btn_high
  1216.         cmp   sb_delta,word 1
  1217.         je      @f
  1218.        
  1219.         cmp   ax,cx
  1220.         ja      .down_sb
  1221.        
  1222. @@:
  1223.         mov   ebx,sb_btn_high   ;16  ;15
  1224.         add   bx,sb_start_x     ;y
  1225.         sub   cx,bx
  1226.         sub   ax,bx
  1227.        
  1228. .scroll_sb_1:  
  1229.         mov   ebx,sb_run_size
  1230. ;***************************************************************************** 
  1231.         cmp   sb_delta,word 1
  1232.         je      .continue
  1233.        
  1234. @@:
  1235.         mov   edx,eax
  1236.  
  1237.         push  ebx
  1238.         shr   ebx,1
  1239.         sub   edx,ebx
  1240.         pop   ebx
  1241.         mov   sb_position2,edx
  1242.         test  sb_position2,dword 0x80000000
  1243.         jz       .test_1
  1244.        
  1245.         mov   sb_position2,dword 0
  1246.         jmp   .continue
  1247.        
  1248. .test_1:
  1249.         xor   edx,edx
  1250.         mov   dx,sb_size_x       ;y
  1251.         sub   edx,sb_btn_high
  1252.         sub   edx,sb_btn_high
  1253.         sub   edx,sb_run_size
  1254.         cmp   sb_position2,edx
  1255.         jbe   .continue
  1256.        
  1257.         mov   sb_position2,edx
  1258.  
  1259. .continue:  
  1260.         mov   eax,sb_position2
  1261.         sub   ecx,ebx
  1262. .continue_1:
  1263. ;*****************************************************************************  
  1264.         mov   ebx,eax
  1265.  
  1266.         mov   eax,sb_max_area
  1267.         cmp   eax,sb_cur_area
  1268.         ja      @f
  1269.  
  1270.         xor   eax,eax
  1271.         inc   eax
  1272.         mov   sb_position2,eax
  1273.         jmp   .all_sb
  1274. @@:
  1275.         sub   eax,sb_cur_area
  1276.         inc   eax
  1277.         shl   eax,10
  1278.         xor   edx,edx
  1279.         div   ecx
  1280.         shl   edx,1
  1281.         cmp   edx,ecx
  1282.         jb      @f
  1283.        
  1284.         inc   eax
  1285.        
  1286. @@:
  1287.         imul  eax,ebx
  1288.         shr   eax,10
  1289.        
  1290.         cmp   sb_position,eax
  1291.         je      .exit_sb
  1292.        
  1293.         cmp   eax,0
  1294.         ja      @f
  1295.        
  1296.         xor   eax,eax
  1297.        
  1298. @@:
  1299. .store_position:
  1300.         mov   sb_position,eax
  1301. .all_sb:
  1302.         mov   sb_redraw,dword 1
  1303.         call  .draw_1
  1304.         mov   eax,sb_m_pos
  1305.         mov   sb_m_pos_2,eax
  1306.         jmp   .exit_sb
  1307. ;*****************************************************************************
  1308. .down_sb:
  1309.         cmp   sb_m_keys,dword 0
  1310.         je   .exit_sb
  1311.        
  1312.         mov   eax,sb_max_area
  1313.         mov   ebx,sb_ar_offset
  1314.         sub   eax,sb_cur_area
  1315.         push  eax
  1316.         sub   eax,ebx
  1317.         cmp   sb_position,eax
  1318.         pop   eax
  1319.         jae   @f
  1320.        
  1321.         add   sb_position,ebx
  1322.         jmp   .all_sb
  1323. @@:
  1324.         mov   sb_position,eax
  1325.         xor   eax,eax
  1326.         mov   ax,sb_size_x
  1327.         sub   eax,sb_btn_high
  1328.         sub   eax,sb_btn_high
  1329.         sub   eax,sb_run_size
  1330.         mov   sb_position2,eax
  1331.         jmp   .all_sb
  1332. .exit_sb:
  1333. scroll_bar_exit
  1334. }
  1335.