Subversion Repositories Kolibri OS

Rev

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

  1. ;**************************************************************
  2. ; 2016, 0CodErr
  3. ;       Added border styles(raised, sunken, etched, ridged).
  4. ;       Added possibility to fill frame background.
  5. ;**************************************************************
  6. ; Frame Macro for Kolibri OS
  7. ; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario
  8. ; All rights reserved.
  9. ;
  10. ; Redistribution and use in source and binary forms, with or without
  11. ; modification, are permitted provided that the following conditions are met:
  12. ;     * Redistributions of source code must retain the above copyright
  13. ;       notice, this list of conditions and the following disclaimer.
  14. ;     * Redistributions in binary form must reproduce the above copyright
  15. ;       notice, this list of conditions and the following disclaimer in the
  16. ;       documentation and/or other materials provided with the distribution.
  17. ;     * Neither the name of the <organization> nor the
  18. ;       names of its contributors may be used to endorse or promote products
  19. ;       derived from this software without specific prior written permission.
  20. ;
  21. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  22. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  24. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  25. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  28. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ;*****************************************************************************
  32. macro frame_start
  33. {
  34.         pusha
  35. }
  36. ;*****************************************************************************
  37. macro frame_exit
  38. {
  39. popa        
  40. ret 4
  41. }
  42. ;*****************************************************************************
  43. fr equ [esp + 36]
  44. frame:
  45. fr_type              equ [eax + FR_STYLE]         ; dword
  46. fr_size_x            equ [eax + FR_WIDTH]         ;  word
  47. fr_start_x           equ [eax + FR_LEFT]          ;  word
  48. fr_size_y            equ [eax + FR_HEIGHT]        ;  word
  49. fr_start_y           equ [eax + FR_TOP]           ;  word
  50. fr_ext_fr_col        equ [eax + FR_OUTER_COLOR]   ; dword
  51. fr_int_fr_col        equ [eax + FR_INNER_COLOR]   ; dword
  52. fr_flags             equ [eax + FR_FLAGS]         ; dword
  53. fr_text_pointer      equ [eax + FR_TEXT]          ; dword
  54. fr_text_position     equ [eax + FR_TEXT_POSITION] ; dword
  55. fr_font_number       equ [eax + FR_FONT]          ; dword
  56. fr_font_size_y       equ [eax + FR_FONT_HEIGHT]   ; dword
  57. fr_font_color        equ [eax + FR_FORE_COLOR]    ; dword
  58. fr_font_backgr_color equ [eax + FR_BACK_COLOR]    ; dword
  59. ;*****************************************************************************
  60. ;*****************************************************************************
  61. ; draw event
  62. ;*****************************************************************************
  63. ;*****************************************************************************
  64. align 16
  65. .draw:
  66. frame_start
  67.         mov    eax, fr
  68.         mov    edx, fr_ext_fr_col
  69.         mov    edi, fr_int_fr_col
  70.         mov    esi, edx
  71.         mov    ebp, edi
  72.         mov    eax, fr_flags
  73.         and    eax, 1110b
  74. .raised:        
  75.         cmp    eax, FR_RAISED    
  76.         je     .border_style_selected
  77. .sunken:        
  78.         cmp    eax, FR_SUNKEN
  79.         jne    .etched
  80.         xchg   edx, edi
  81.         xchg   esi, ebp
  82.         jmp    .border_style_selected
  83. .etched:        
  84.         cmp    eax, FR_ETCHED
  85.         jne    .ridged
  86.         xchg   edx, edi
  87.         jmp    .border_style_selected
  88. .ridged:        
  89.         cmp    eax, FR_RIDGED
  90.         jne    .double
  91.         xchg   esi, ebp
  92.         jmp    .border_style_selected
  93. .double:    
  94.         cmp    eax, FR_DOUBLE
  95.         jne    .border_style_selected
  96.         mov    edi, edx
  97.         mov    esi, ebp
  98. .border_style_selected:                
  99. ; Outer Top Line
  100.         mov    eax, fr
  101.         mov    bx, fr_start_x
  102.         mov    cx, fr_start_y
  103.         shl    ebx, 16
  104.         shl    ecx, 16
  105.         mov    bx, fr_size_x
  106.         add    bx, fr_start_x
  107.         sub    ebx, 1
  108.         mov    cx, fr_start_y
  109.         mov    eax, 38
  110.         int    64
  111. ; Outer Left Line
  112.         mov    eax, fr
  113.         mov    bx, fr_start_x
  114.         add    cx, fr_size_y        
  115.         sub    ecx, 1
  116.         mov    eax, 38
  117.         int    64                
  118. ; Inner Top Line
  119.         mov    eax, fr
  120.         mov    bx, fr_start_x
  121.         mov    cx, fr_start_y
  122.         add    ebx, 1
  123.         add    ecx, 1
  124.         shl    ebx, 16
  125.         shl    ecx, 16
  126.         mov    bx, fr_size_x
  127.         mov    cx, fr_start_y
  128.         add    bx, fr_start_x        
  129.         sub    ebx, 2
  130.         add    ecx, 1
  131.         mov    edx, esi
  132.         mov    eax, 38
  133.         int    64
  134. ; Inner Left Line
  135.         mov    eax, fr
  136.         mov    bx, fr_start_x
  137.         add    cx, fr_size_y        
  138.         add    ebx, 1
  139.         sub    ecx, 3
  140.         mov    edx, esi
  141.         mov    eax, 38
  142.         int    64    
  143. ; Outer Bottom Line    
  144.         mov    eax, fr    
  145.         mov    bx, fr_size_x
  146.         mov    cx, fr_size_y        
  147.         add    bx, fr_start_x
  148.         add    cx, fr_start_y  
  149.         sub    ebx, 1
  150.         sub    ecx, 1
  151.         shl    ebx, 16
  152.         shl    ecx, 16
  153.         mov    bx, fr_start_x
  154.         mov    cx, fr_size_y
  155.         add    cx, fr_start_y
  156.         sub    ecx, 1
  157.         mov    edx, edi
  158.         mov    eax, 38
  159.         int    64
  160. ; Outer Right Line
  161.         mov    eax, fr
  162.         add    bx, fr_size_x        
  163.         sub    ebx, 1
  164.         mov    cx, fr_start_y
  165.         mov    edx, edi
  166.         mov    eax, 38
  167.         int    64          
  168. ; Inner Bottom Line
  169.         mov    eax, fr
  170.         mov    bx, fr_size_x
  171.         mov    cx, fr_size_y        
  172.         add    bx, fr_start_x
  173.         add    cx, fr_start_y  
  174.         sub    ebx, 2
  175.         sub    ecx, 2
  176.         shl    ebx, 16
  177.         shl    ecx, 16
  178.         mov    bx, fr_start_x
  179.         mov    cx, fr_size_y
  180.         add    cx, fr_start_y
  181.         add    ebx, 1
  182.         sub    ecx, 2
  183.         mov    edx, ebp
  184.         mov    eax, 38
  185.         int    64
  186. ; Inner Right Line
  187.         mov    eax, fr
  188.         mov    cx, fr_start_y        
  189.         add    bx, fr_size_x
  190.         sub    ebx, 3
  191.         add    ecx, 1
  192.         mov    edx, ebp
  193.         mov    eax, 38
  194.         int    64        
  195. ;----------------------------------------------------------------------
  196.         mov    eax, fr        
  197.         test   dword fr_flags, FR_FILLED
  198.         je     .fill_exit
  199.        
  200.         mov    bx, fr_start_x
  201.         mov    cx, fr_start_y
  202.         add    ebx, 2
  203.         add    ecx, 2
  204.         shl    ebx, 16
  205.         shl    ecx, 16
  206.         mov    bx, fr_size_x
  207.         mov    cx, fr_size_y
  208.         sub    ebx, 4
  209.         sub    ecx, 4
  210.         mov    edx, fr_font_backgr_color
  211.         mov    eax, 13
  212.         int    64              
  213. .fill_exit:  
  214. ;----------------------------------------------------------------------
  215.         mov    eax, fr
  216.         test    dword fr_flags, FR_CAPTION
  217.         je      .exit
  218.  
  219.         mov     ecx,0xC0000000
  220.         mov     eax,fr_font_number
  221.         and     eax,11b
  222.         shl     eax,28
  223.         add     ecx,eax
  224.         mov    eax, fr
  225.         mov     eax,fr_font_color
  226.         and     eax,0xffffff
  227.         add     ecx,eax
  228.  
  229.         mov    eax, fr
  230.  
  231.         mov     eax,fr_font_backgr_color
  232.         and     eax,0xffffff
  233.  
  234.         xor     esi,esi
  235.  
  236.         mov    eax, fr
  237.         mov     bx,fr_start_x
  238.         add     bx,10
  239.         shl     ebx,16
  240.         mov     bx,fr_font_size_y
  241.         shr     bx,1
  242.  
  243.         not     bx
  244.         add     bx,fr_start_y
  245.  
  246.         test    fr_font_size_y,word 1b
  247.         jz      @f
  248.        
  249.         inc     bx
  250. ;--------------------------------------
  251. align 4
  252. @@:
  253.         cmp     fr_text_position,dword 0
  254.         je      .draw_1
  255.        
  256.         add     bx,fr_size_y
  257. ;--------------------------------------
  258. align 4
  259. .draw_1:
  260.         mov     edx,fr_text_pointer
  261.         mov     edi,fr_font_backgr_color
  262.         mcall   SF_DRAW_TEXT
  263. ;----------------------------------------------------------------------
  264. align 4
  265. .exit:
  266. frame_exit
  267. ;*****************************************************************************
  268.