Subversion Repositories Kolibri OS

Rev

Rev 52 | Rev 54 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. include "skindata.inc"
  2.  
  3. skin_data = 0x00778000
  4.  
  5. load_skin_file:
  6. ; eax = filename
  7. ; edx = destination
  8.     mov   ebx,1
  9.     or    ecx,-1
  10.     mov   esi,12
  11.     call  fileread
  12.     ret
  13.  
  14. struct SKIN_HEADER
  15.   .ident   dd ?
  16.   .version dd ?
  17.   .params  dd ?
  18.   .buttons dd ?
  19.   .bitmaps dd ?
  20. ends
  21.  
  22. struct SKIN_PARAMS
  23.   .skin_height    dd ?
  24.   .margin.right   dw ?
  25.   .margin.left    dw ?
  26.   .margin.bottom  dw ?
  27.   .margin.top     dw ?
  28.   .colors.inner   dd ?
  29.   .colors.outer   dd ?
  30.   .colors.frame   dd ?
  31.   .colors_1.inner dd ?
  32.   .colors_1.outer dd ?
  33.   .colors_1.frame dd ?
  34.   .dtp.size       dd ?
  35.   .dtp.data       db 40 dup (?)
  36. ends
  37.  
  38. struct SKIN_BUTTONS
  39.   .type     dd ?
  40.   .pos:
  41.     .left   dw ?
  42.     .top    dw ?
  43.   .size:
  44.     .width  dw ?
  45.     .height dw ?
  46. ends
  47.  
  48. struct SKIN_BITMAPS
  49.   .kind  dw ?
  50.   .type  dw ?
  51.   .data  dd ?
  52. ends
  53.  
  54. load_skin:
  55.         pushad
  56.         mov     [_skinh],22
  57.         mov     eax,_skin_file
  58.         mov     edx,skin_data
  59.         mov     [ebp+SKIN_HEADER.ident],'????'
  60.         call    load_skin_file
  61.         call    parse_skin_data
  62.         popad
  63.         ret
  64.  
  65. parse_skin_data:
  66.         mov     ebp,skin_data
  67.         cmp     [ebp+SKIN_HEADER.ident],'SKIN'
  68.         jne     .exit
  69.  
  70.         mov     ebx,[ebp+SKIN_HEADER.params]
  71.         add     ebx,skin_data
  72.         mov     eax,[ebx+SKIN_PARAMS.skin_height]
  73.         mov     [_skinh],eax
  74.         mov     eax,[ebx+SKIN_PARAMS.colors.inner]
  75.         mov     [skin_active.colors.inner],eax
  76.         mov     eax,[ebx+SKIN_PARAMS.colors.outer]
  77.         mov     [skin_active.colors.outer],eax
  78.         mov     eax,[ebx+SKIN_PARAMS.colors.frame]
  79.         mov     [skin_active.colors.frame],eax
  80.         mov     eax,[ebx+SKIN_PARAMS.colors_1.inner]
  81.         mov     [skin_inactive.colors.inner],eax
  82.         mov     eax,[ebx+SKIN_PARAMS.colors_1.outer]
  83.         mov     [skin_inactive.colors.outer],eax
  84.         mov     eax,[ebx+SKIN_PARAMS.colors_1.frame]
  85.         mov     [skin_inactive.colors.frame],eax
  86.         lea     esi,[ebx+SKIN_PARAMS.dtp.data]
  87.         mov     edi,common_colours
  88.         mov     ecx,[ebx+SKIN_PARAMS.dtp.size]
  89.         and     ecx,127
  90.         cld
  91.         rep     movsb
  92.         mov     eax,dword[ebx+SKIN_PARAMS.margin.right]
  93.         mov     dword[_skinmargins+0],eax
  94.         mov     eax,dword[ebx+SKIN_PARAMS.margin.bottom]
  95.         mov     dword[_skinmargins+4],eax
  96.  
  97.         mov     ebx,[ebp+SKIN_HEADER.bitmaps]
  98.         add     ebx,skin_data
  99.   .lp1: cmp     dword[ebx],0
  100.         je      .end_bitmaps
  101.         movzx   eax,[ebx+SKIN_BITMAPS.kind]
  102.         movzx   ecx,[ebx+SKIN_BITMAPS.type]
  103.         dec     eax
  104.         jnz     .not_left
  105.         xor     eax,eax
  106.         mov     edx,skin_active.left.data
  107.         or      ecx,ecx
  108.         jnz     @f
  109.         mov     edx,skin_inactive.left.data
  110.     @@: jmp     .next_bitmap
  111.   .not_left:
  112.         dec     eax
  113.         jnz     .not_oper
  114.         mov     esi,[ebx+SKIN_BITMAPS.data]
  115.         add     esi,skin_data
  116.         mov     eax,[esi+0]
  117.         neg     eax
  118.         mov     edx,skin_active.oper.data
  119.         or      ecx,ecx
  120.         jnz     @f
  121.         mov     edx,skin_inactive.oper.data
  122.     @@: jmp     .next_bitmap
  123.   .not_oper:
  124.         dec     eax
  125.         jnz     .not_base
  126.         mov     eax,[skin_active.left.width]
  127.         mov     edx,skin_active.base.data
  128.         or      ecx,ecx
  129.         jnz     @f
  130.         mov     eax,[skin_inactive.left.width]
  131.         mov     edx,skin_inactive.base.data
  132.     @@: jmp     .next_bitmap
  133.   .not_base:
  134.         add     ebx,8
  135.         jmp     .lp1
  136.   .next_bitmap:
  137.         mov     ecx,[ebx+SKIN_BITMAPS.data]
  138.         add     ecx,skin_data
  139.         mov     [edx+4],eax
  140.         mov     eax,[ecx+0]
  141.         mov     [edx+8],eax
  142.         add     ecx,8
  143.         mov     [edx+0],ecx
  144.         add     ebx,8
  145.         jmp     .lp1
  146.   .end_bitmaps:
  147.  
  148.         mov     ebx,[ebp+SKIN_HEADER.buttons]
  149.         add     ebx,skin_data
  150.   .lp2: cmp     dword[ebx],0
  151.         je      .end_buttons
  152.         mov     eax,[ebx+SKIN_BUTTONS.type]
  153.         dec     eax
  154.         jnz     .not_close
  155.         mov     edx,skin_btn_close
  156.         jmp     .next_button
  157.   .not_close:
  158.         dec     eax
  159.         jnz     .not_minimize
  160.         mov     edx,skin_btn_minimize
  161.         jmp     .next_button
  162.   .not_minimize:
  163.         add     ebx,12
  164.         jmp     .lp2
  165.   .next_button:
  166.         movsx   eax,[ebx+SKIN_BUTTONS.left]
  167.         mov     [edx+SKIN_BUTTON.left],eax
  168.         movsx   eax,[ebx+SKIN_BUTTONS.top]
  169.         mov     [edx+SKIN_BUTTON.top],eax
  170.         movsx   eax,[ebx+SKIN_BUTTONS.width]
  171.         mov     [edx+SKIN_BUTTON.width],eax
  172.         movsx   eax,[ebx+SKIN_BUTTONS.height]
  173.         mov     [edx+SKIN_BUTTON.height],eax
  174.         add     ebx,12
  175.         jmp     .lp2
  176.   .end_buttons:
  177.  
  178.   .exit:
  179.         ret
  180.  
  181. sys_putimage_with_check:
  182.         or      ebx,ebx
  183.         jz      @f
  184.         call    sys_putimage
  185.     @@: ret
  186.  
  187. drawwindow_IV:
  188. ;param1 - aw_yes
  189.  
  190.         pusha
  191.  
  192.         push  edx
  193.  
  194.         mov   edi,[esp]                              ; RECTANGLE
  195.  
  196.         mov     ebp,skin_active
  197.         cmp     byte [esp+32+4+4],0
  198.         jne     @f
  199.         mov     ebp,skin_inactive
  200.      @@:
  201.  
  202.         mov   eax,[edi+0]
  203.         shl   eax,16
  204.         mov   ax,[edi+0]
  205.         add   ax,[edi+8]
  206.         mov   ebx,[edi+4]
  207.         shl   ebx,16
  208.         mov   bx,[edi+4]
  209.         add   bx,[edi+12]
  210. ;        mov   esi,[edi+24]
  211. ;        shr   esi,1
  212. ;        and   esi,0x007f7f7f
  213.         mov   esi,[ebp+SKIN_DATA.colors.outer]
  214.         call  draw_rectangle
  215.         mov   ecx,3
  216.       _dw3l:
  217.         add   eax,1*65536-1
  218.         add   ebx,1*65536-1
  219.         test  ax,ax
  220.         js    no_skin_add_button
  221.         test  bx,bx
  222.         js    no_skin_add_button
  223.         mov   esi,[ebp+SKIN_DATA.colors.frame] ;[edi+24]
  224.         call  draw_rectangle
  225.         dec   ecx
  226.         jnz   _dw3l
  227.         mov   esi,[ebp+SKIN_DATA.colors.inner]
  228.         add   eax,1*65536-1
  229.         add   ebx,1*65536-1
  230.         test  ax,ax
  231.         js    no_skin_add_button
  232.         test  bx,bx
  233.         js    no_skin_add_button
  234.         call  draw_rectangle
  235.  
  236.         mov   esi,[esp]
  237.         mov   eax,[esi+8]    ; window width
  238.         mov   edx,[ebp+SKIN_DATA.left.left]
  239.         shl   edx,16
  240.         mov   ecx,[ebp+SKIN_DATA.left.width]
  241.         shl   ecx,16
  242.         add   ecx,[_skinh]
  243.  
  244.         mov   ebx, [ebp+SKIN_DATA.left.data]
  245.         call  sys_putimage_with_check
  246.  
  247.         mov   esi,[esp]
  248.         mov   eax,[esi+8]
  249.         sub   eax,[ebp+SKIN_DATA.left.width]
  250.         sub   eax,[ebp+SKIN_DATA.oper.width]
  251.         cmp   eax,[ebp+SKIN_DATA.base.left]
  252.         jng   non_base
  253.         xor   edx,edx
  254.         mov   ecx,[ebp+SKIN_DATA.base.width]
  255.         jecxz non_base
  256.         div   ecx
  257.  
  258.         inc   eax
  259.  
  260.         mov   ebx,[ebp+SKIN_DATA.base.data]
  261.         mov   ecx,[ebp+SKIN_DATA.base.width]
  262.         shl   ecx,16
  263.         add   ecx,[_skinh]
  264.         mov   edx,[ebp+SKIN_DATA.base.left]
  265.         sub   edx,[ebp+SKIN_DATA.base.width]
  266.         shl   edx,16
  267.       baseskinloop:
  268.         shr   edx,16
  269.         add   edx,[ebp+SKIN_DATA.base.width]
  270.         shl   edx,16
  271.  
  272.         push  eax ebx ecx edx
  273.         call  sys_putimage_with_check
  274.         pop   edx ecx ebx eax
  275.  
  276.         dec   eax
  277.         jnz   baseskinloop
  278.       non_base:
  279.  
  280.         mov   esi,[esp]
  281.         mov   edx,[esi+8]
  282.         sub   edx,[ebp+SKIN_DATA.oper.width]
  283.         inc   edx
  284.         shl   edx,16
  285.         mov   ebx,[ebp+SKIN_DATA.oper.data]
  286.  
  287.         mov   ecx,[ebp+SKIN_DATA.oper.width]
  288.         shl   ecx,16
  289.         add   ecx,[_skinh]
  290.         call  sys_putimage_with_check
  291.  
  292.         mov   esi,[esp]
  293.  
  294.         mov   edx,[esi+04]                       ; WORK AREA
  295.         add   edx,21+5
  296.         mov   ebx,[esi+04]
  297.         add   ebx,[esi+12]
  298.         cmp   edx,ebx
  299.         jg    _noinside2
  300.         mov   eax,5
  301.         mov   ebx,[_skinh]
  302.         mov   ecx,[esi+8]
  303.         mov   edx,[esi+12]
  304.         sub   ecx,4
  305.         sub   edx,4
  306.         mov   edi,[esi+16]
  307.         call  [drawbar]
  308.       _noinside2:
  309.  
  310. ;* close button
  311.         mov   edi,[0xfe88]
  312.         movzx eax,word [edi]
  313.         cmp   eax,1000
  314.         jge   no_skin_add_button
  315.         inc   eax
  316.         mov   [edi],ax
  317.  
  318.         shl   eax,4
  319.         add   eax,edi
  320.  
  321.         mov   bx,[0x3000]
  322.         mov   [eax],bx
  323.  
  324.         add   eax,2         ; save button id number
  325.         mov   bx,1
  326.         mov   [eax],bx
  327.         add   eax,2         ; x start
  328.         xor   ebx,ebx
  329.         cmp   [skin_btn_close.left],0
  330.         jge   _bCx_at_right
  331.         mov   ebx,[esp]
  332.         mov   ebx,[ebx+8]
  333.         inc   ebx
  334.       _bCx_at_right:
  335.         add   ebx,[skin_btn_close.left]
  336.         mov   [eax],bx
  337.         add   eax,2         ; x size
  338.         mov   ebx,[skin_btn_close.width]
  339.         dec   ebx
  340.         mov   [eax],bx
  341.         add   eax,2         ; y start
  342.         mov   ebx,[skin_btn_close.top]
  343.         mov   [eax],bx
  344.         add   eax,2         ; y size
  345.         mov   ebx,[skin_btn_close.height]
  346.         dec   ebx
  347.         mov   [eax],bx
  348.  
  349. ;* minimize button
  350.         mov   edi,[0xfe88]
  351.         movzx eax,word [edi]
  352.         cmp   eax,1000
  353.         jge   no_skin_add_button
  354.         inc   eax
  355.         mov   [edi],ax
  356.  
  357.         shl   eax,4
  358.         add   eax,edi
  359.  
  360.         mov   bx,[0x3000]
  361.         mov   [eax],bx
  362.  
  363.         add   eax,2         ; save button id number
  364.         mov   bx,65535 ;999
  365.         mov   [eax],bx
  366.         add   eax,2         ; x start
  367.         xor   ebx,ebx
  368.         cmp   [skin_btn_minimize.left],0
  369.         jge   _bMx_at_right
  370.         mov   ebx,[esp]
  371.         mov   ebx,[ebx+8]
  372.         inc   ebx
  373.       _bMx_at_right:
  374.         add   ebx,[skin_btn_minimize.left]
  375.         mov   [eax],bx
  376.         add   eax,2         ; x size
  377.         mov   ebx,[skin_btn_minimize.width]
  378.         dec   ebx
  379.         mov   [eax],bx
  380.         add   eax,2         ; y start
  381.         mov   ebx,[skin_btn_minimize.top]
  382.         mov   [eax],bx
  383.         add   eax,2         ; y size
  384.         mov   ebx,[skin_btn_minimize.height]
  385.         dec   ebx
  386.         mov   [eax],bx
  387.  
  388.       no_skin_add_button:
  389.  
  390.         add   esp,4
  391.         popa
  392.  
  393.         ret  4
  394.  
  395.