Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;============================================================================
  2. ; This file should be used to generate skins of new standard
  3. ;============================================================================
  4. ; skin file structure:
  5. ;----------------------------------------------------------------------------
  6. ;  header:
  7. ;   dd 'SKIN'
  8. ;   dd = version (1 for now)
  9. ;   dd @ params
  10. ;   dd @ buttons
  11. ;   dd @ bitmaps
  12. ; ...
  13. ;----------------------------------------------------------------------------
  14. ; NOTE: order of sections listed below is insignificant
  15. ;       since they're identified by pointer in above header
  16. ;----------------------------------------------------------------------------
  17. ; ...
  18. ;  params:
  19. ;   dd = skin height
  20. ;   dw = right margin
  21. ;   dw = left margin
  22. ;   dw = bottom margin
  23. ;   dw = top margin
  24. ;   dd = inner line color
  25. ;   dd = outer line color
  26. ;   dd = frame color
  27. ;   dd = dtp file size
  28. ;   ?? = dtp file itself
  29. ; ...
  30. ;----------------------------------------------------------------------------
  31. ; ...
  32. ;  buttons:
  33. ;   dd = button type (1 = close, 2 = minimize)
  34. ;   dw = left button coord (could be negative)
  35. ;   dw = top button coord (could be negative)
  36. ;   dw = button width
  37. ;   dw = button height
  38. ;   ... etc for all buttons
  39. ;   dd = 0 (end of buttons list)
  40. ; ...
  41. ;----------------------------------------------------------------------------
  42. ; ...
  43. ;  bitmaps:
  44. ;   dw = bitmap kind (1 = left, 2 = oper, 3 = base)
  45. ;   dw = bitmap type (1 = active, 0 = inactive)
  46. ;   dd @ bitmap
  47. ;   ... etc for all bitmaps
  48. ;   dd 0 (end of bitmaps list)
  49. ; ...
  50. ;----------------------------------------------------------------------------
  51. ; ...
  52. ;  bitmap:
  53. ;   dd = bitmap width
  54. ;   dd = bitmap height
  55. ;   ?? = raw bitmap data
  56. ;   ... etc for all bitmaps
  57. ; ...
  58. ;============================================================================
  59.  
  60. dd 'SKIN',1,__params__,__buttons__,__bitmaps__
  61.  
  62. struc BITMAPFILEHEADER {
  63.   .bfType      dw ? ; WORD
  64.   .bfSize      dd ? ; DWORD
  65.   .bfReserved1 dw ? ; WORD
  66.   .bfReserved2 dw ? ; WORD
  67.   .bfOffBits   dd ? ; DWORD
  68. }
  69.  
  70. struc BITMAPINFOHEADER {
  71.   .biSize          dd ? ; DWORD
  72.   .biWidth         dd ? ; LONG
  73.   .biHeight        dd ? ; LONG
  74.   .biPlanes        dw ? ; WORD
  75.   .biBitCount      dw ? ; WORD
  76.   .biCompression   dd ? ; DWORD
  77.   .biSizeImage     dd ? ; DWORD
  78.   .biXPelsPerMeter dd ? ; LONG
  79.   .biYPelsPerMeter dd ? ; LONG
  80.   .biClrUsed       dd ? ; DWORD
  81.   .biClrImportant  dd ? ; DWORD
  82. }
  83.  
  84. struc _bmp {
  85.   .h BITMAPFILEHEADER
  86.   .i BITMAPINFOHEADER
  87. }
  88. virtual at 0
  89.   _bmp _bmp
  90. end virtual
  91.  
  92. macro BITMAP _name*,_fname*
  93. {
  94.   local w,h,a,r,g,b
  95.   virtual at 0
  96.     file _fname
  97.     load w dword from _bmp.i.biWidth
  98.     load h dword from _bmp.i.biHeight
  99.   end virtual
  100.   align 4
  101.   label _name
  102.     .width  = w
  103.     .height = h
  104.   dd w,h
  105.   a=54+(w*3+(w mod 4))*(h-1)
  106.   size = $
  107.   repeat h
  108.     repeat w
  109.       virtual at 0
  110.         file _fname
  111.         load r from a+0
  112.         load g from a+1
  113.         load b from a+2
  114.       end virtual
  115.       db r,g,b
  116.       a=a+3
  117.     end repeat
  118.     a=a-w*3*2-(w mod 4)
  119.   end repeat
  120. }
  121.  
  122. macro define_colors name,[col,val]
  123. {
  124.   common
  125.     local a,b,c
  126.   forward
  127.     match =binner,col \{ a = val \}
  128.     match =bouter,col \{ b = val \}
  129.     match =bframe,col \{ c = val \}
  130.   common
  131.     name equ a,b,c
  132. }
  133.  
  134. macro SKIN_PARAMS [a]
  135. {
  136.   common
  137.     local _height,_margins,_colors,_colors_1,_dtp,_dtp_sz
  138.     __params__:
  139.   forward
  140.     match qq == ww,a
  141.     \{
  142.       match =height,qq \\{ _height = ww \\}
  143.       match =margins,qq \\{
  144.         match [q1:q2:q3:q4],ww
  145.         \\\{
  146.           _margins equ q3,q1,q4,q2
  147.         \\\}
  148.       \\}
  149.       match =colors =active,qq
  150.       \\{
  151.         match [q10==q11:q20==q21:q30==q31],ww
  152.         \\\{
  153.           define_colors _colors,q10,q11,q20,q21,q30,q31
  154.         \\\}
  155.       \\}
  156.       match =colors =inactive,qq
  157.       \\{
  158.         match [q10==q11:q20==q21:q30==q31],ww
  159.         \\\{
  160.           define_colors _colors_1,q10,q11,q20,q21,q30,q31
  161.         \\\}
  162.       \\}
  163.       match =dtp,qq \\{ _dtp equ ww \\}
  164.     \}
  165.   common
  166.     dd _height
  167.     dw _margins
  168.     dd _colors,_colors_1
  169.     virtual at 0
  170.       file _dtp
  171.       _dtp_sz = $
  172.     end virtual
  173.     dd _dtp_sz
  174.     file _dtp
  175. }
  176.  
  177. macro SKIN_BUTTONS [a]
  178. {
  179.   common
  180.     local btn
  181.     __buttons__:
  182.   forward
  183.     match qq == ww,a
  184.     \{
  185.       btn = 0
  186.       match =close,qq    \\{ btn = 1 \\}
  187.       match =minimize,qq \\{ btn = 2 \\}
  188.       match [q1:q2][q3:q4],ww
  189.       \\{
  190.         if btn <> 0
  191.           dd btn
  192.           dw q1,q2,q3,q4
  193.         end if
  194.       \\}
  195.     \}
  196.   common
  197.     dd 0
  198. }
  199.  
  200. macro SKIN_BITMAPS [a]
  201. {
  202.   common
  203.     local bmp
  204.     __bitmaps__:
  205.   forward
  206.     match qq == ww,a
  207.     \{
  208.       bmp=-1
  209.       match qqq =active,qq   \\{ bmp = 1 \\}
  210.       match qqq =inactive,qq \\{ bmp = 0 \\}
  211.       match =left qqq,qq
  212.       \\{
  213.         if bmp >= 0
  214.           dw 1,bmp
  215.           dd ww
  216.         end if
  217.       \\}
  218.       match =oper qqq,qq
  219.       \\{
  220.         if bmp >= 0
  221.           dw 2,bmp
  222.           dd ww
  223.         end if
  224.       \\}
  225.       match =base qqq,qq
  226.       \\{
  227.         if bmp >= 0
  228.           dw 3,bmp
  229.           dd ww
  230.         end if
  231.       \\}
  232.     \}
  233.   common
  234.     dd 0
  235. }