Subversion Repositories Kolibri OS

Rev

Rev 114 | Rev 186 | 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     [edx+SKIN_HEADER.ident],'????'
  60.         call    load_skin_file
  61.         cmp     eax,ERROR_SUCCESS
  62.         je      @f
  63.         cmp     eax,ERROR_END_OF_FILE
  64.         jne     .exit
  65.     @@: call    parse_skin_data
  66.   .exit:
  67.         popad
  68.         ret
  69.  
  70. parse_skin_data:
  71.         mov     ebp,skin_data
  72.         cmp     [ebp+SKIN_HEADER.ident],'SKIN'
  73.         jne     .exit
  74.  
  75.         mov     edi,skin_udata
  76.         mov     ecx,(skin_udata.end-skin_udata)/4
  77.         xor     eax,eax
  78.         cld
  79.         rep     stosd
  80.  
  81.         mov     ebx,[ebp+SKIN_HEADER.params]
  82.         add     ebx,skin_data
  83.         mov     eax,[ebx+SKIN_PARAMS.skin_height]
  84.         mov     [_skinh],eax
  85.         mov     eax,[ebx+SKIN_PARAMS.colors.inner]
  86.         mov     [skin_active.colors.inner],eax
  87.         mov     eax,[ebx+SKIN_PARAMS.colors.outer]
  88.         mov     [skin_active.colors.outer],eax
  89.         mov     eax,[ebx+SKIN_PARAMS.colors.frame]
  90.         mov     [skin_active.colors.frame],eax
  91.         mov     eax,[ebx+SKIN_PARAMS.colors_1.inner]
  92.         mov     [skin_inactive.colors.inner],eax
  93.         mov     eax,[ebx+SKIN_PARAMS.colors_1.outer]
  94.         mov     [skin_inactive.colors.outer],eax
  95.         mov     eax,[ebx+SKIN_PARAMS.colors_1.frame]
  96.         mov     [skin_inactive.colors.frame],eax
  97.         lea     esi,[ebx+SKIN_PARAMS.dtp.data]
  98.         mov     edi,common_colours
  99.         mov     ecx,[ebx+SKIN_PARAMS.dtp.size]
  100.         and     ecx,127
  101.         rep     movsb
  102.         mov     eax,dword[ebx+SKIN_PARAMS.margin.right]
  103.         mov     dword[_skinmargins+0],eax
  104.         mov     eax,dword[ebx+SKIN_PARAMS.margin.bottom]
  105.         mov     dword[_skinmargins+4],eax
  106.  
  107.         mov     ebx,[ebp+SKIN_HEADER.bitmaps]
  108.         add     ebx,skin_data
  109.   .lp1: cmp     dword[ebx],0
  110.         je      .end_bitmaps
  111.         movzx   eax,[ebx+SKIN_BITMAPS.kind]
  112.         movzx   ecx,[ebx+SKIN_BITMAPS.type]
  113.         dec     eax
  114.         jnz     .not_left
  115.         xor     eax,eax
  116.         mov     edx,skin_active.left.data
  117.         or      ecx,ecx
  118.         jnz     @f
  119.         mov     edx,skin_inactive.left.data
  120.     @@: jmp     .next_bitmap
  121.   .not_left:
  122.         dec     eax
  123.         jnz     .not_oper
  124.         mov     esi,[ebx+SKIN_BITMAPS.data]
  125.         add     esi,skin_data
  126.         mov     eax,[esi+0]
  127.         neg     eax
  128.         mov     edx,skin_active.oper.data
  129.         or      ecx,ecx
  130.         jnz     @f
  131.         mov     edx,skin_inactive.oper.data
  132.     @@: jmp     .next_bitmap
  133.   .not_oper:
  134.         dec     eax
  135.         jnz     .not_base
  136.         mov     eax,[skin_active.left.width]
  137.         mov     edx,skin_active.base.data
  138.         or      ecx,ecx
  139.         jnz     @f
  140.         mov     eax,[skin_inactive.left.width]
  141.         mov     edx,skin_inactive.base.data
  142.     @@: jmp     .next_bitmap
  143.   .not_base:
  144.         add     ebx,8
  145.         jmp     .lp1
  146.   .next_bitmap:
  147.         mov     ecx,[ebx+SKIN_BITMAPS.data]
  148.         add     ecx,skin_data
  149.         mov     [edx+4],eax
  150.         mov     eax,[ecx+0]
  151.         mov     [edx+8],eax
  152.         add     ecx,8
  153.         mov     [edx+0],ecx
  154.         add     ebx,8
  155.         jmp     .lp1
  156.   .end_bitmaps:
  157.  
  158.         mov     ebx,[ebp+SKIN_HEADER.buttons]
  159.         add     ebx,skin_data
  160.   .lp2: cmp     dword[ebx],0
  161.         je      .end_buttons
  162.         mov     eax,[ebx+SKIN_BUTTONS.type]
  163.         dec     eax
  164.         jnz     .not_close
  165.         mov     edx,skin_btn_close
  166.         jmp     .next_button
  167.   .not_close:
  168.         dec     eax
  169.         jnz     .not_minimize
  170.         mov     edx,skin_btn_minimize
  171.         jmp     .next_button
  172.   .not_minimize:
  173.         add     ebx,12
  174.         jmp     .lp2
  175.   .next_button:
  176.         movsx   eax,[ebx+SKIN_BUTTONS.left]
  177.         mov     [edx+SKIN_BUTTON.left],eax
  178.         movsx   eax,[ebx+SKIN_BUTTONS.top]
  179.         mov     [edx+SKIN_BUTTON.top],eax
  180.         movsx   eax,[ebx+SKIN_BUTTONS.width]
  181.         mov     [edx+SKIN_BUTTON.width],eax
  182.         movsx   eax,[ebx+SKIN_BUTTONS.height]
  183.         mov     [edx+SKIN_BUTTON.height],eax
  184.         add     ebx,12
  185.         jmp     .lp2
  186.   .end_buttons:
  187.  
  188.   .exit:
  189.         ret
  190.  
  191. sys_putimage_with_check:
  192.         or      ebx,ebx
  193.         jz      @f
  194.         call    sys_putimage.forced
  195.     @@: ret
  196.  
  197. drawwindow_IV_caption:
  198.  
  199.         mov     ebp,skin_active
  200.         or      al,al
  201.         jnz     @f
  202.         mov     ebp,skin_inactive
  203.     @@:
  204.  
  205.         mov     esi,[esp+4]
  206.         mov     eax,[esi+WDATA.box.width]    ; window width
  207.         mov     edx,[ebp+SKIN_DATA.left.left]
  208.         shl     edx,16
  209.         mov     ecx,[ebp+SKIN_DATA.left.width]
  210.         shl     ecx,16
  211.         add     ecx,[_skinh]
  212.  
  213.         mov     ebx, [ebp+SKIN_DATA.left.data]
  214.         call    sys_putimage_with_check
  215.  
  216.         mov     esi,[esp+4]
  217.         mov     eax,[esi+WDATA.box.width]
  218.         sub     eax,[ebp+SKIN_DATA.left.width]
  219.         sub     eax,[ebp+SKIN_DATA.oper.width]
  220.         cmp     eax,[ebp+SKIN_DATA.base.left]
  221.         jng     .non_base
  222.         xor     edx,edx
  223.         mov     ecx,[ebp+SKIN_DATA.base.width]
  224.         jecxz   .non_base
  225.         div     ecx
  226.  
  227.         inc     eax
  228.  
  229.         mov     ebx,[ebp+SKIN_DATA.base.data]
  230.         mov     ecx,[ebp+SKIN_DATA.base.width]
  231.         shl     ecx,16
  232.         add     ecx,[_skinh]
  233.         mov     edx,[ebp+SKIN_DATA.base.left]
  234.         sub     edx,[ebp+SKIN_DATA.base.width]
  235.         shl     edx,16
  236.   .baseskinloop:
  237.         shr     edx,16
  238.         add     edx,[ebp+SKIN_DATA.base.width]
  239.         shl     edx,16
  240.  
  241.         push    eax ebx ecx edx
  242.         call    sys_putimage_with_check
  243.         pop     edx ecx ebx eax
  244.  
  245.         dec     eax
  246.         jnz     .baseskinloop
  247.   .non_base:
  248.  
  249.         mov     esi,[esp+4]
  250.         mov     edx,[esi+WDATA.box.width]
  251.         sub     edx,[ebp+SKIN_DATA.oper.width]
  252.         inc     edx
  253.         shl     edx,16
  254.         mov     ebx,[ebp+SKIN_DATA.oper.data]
  255.  
  256.         mov     ecx,[ebp+SKIN_DATA.oper.width]
  257.         shl     ecx,16
  258.         add     ecx,[_skinh]
  259.         call    sys_putimage_with_check
  260.  
  261.         ret
  262.  
  263. ;//mike.dld, 2006-08-02 ]
  264.  
  265.  
  266. drawwindow_IV:
  267. ;param1 - aw_yes
  268.  
  269.         pusha
  270.  
  271.         push  edx
  272.  
  273.         mov   edi,[esp]                              ; RECTANGLE
  274.  
  275.         mov     ebp,skin_active
  276.         cmp     byte [esp+32+4+4],0
  277.         jne     @f
  278.         mov     ebp,skin_inactive
  279.      @@:
  280.  
  281.         mov   eax,[edi+WDATA.box.left]
  282.         shl   eax,16
  283.                 mov   ax,word [edi+WDATA.box.left]
  284.                 add   ax,word [edi+WDATA.box.width]
  285.         mov   ebx,[edi+WDATA.box.top]
  286.         shl   ebx,16
  287.                 mov   bx,word [edi+WDATA.box.top]
  288.                 add   bx,word [edi+WDATA.box.height]
  289. ;        mov   esi,[edi+24]
  290. ;        shr   esi,1
  291. ;        and   esi,0x007f7f7f
  292.         mov   esi,[ebp+SKIN_DATA.colors.outer]
  293.         call  draw_rectangle
  294.         mov   ecx,3
  295.       _dw3l:
  296.         add   eax,1*65536-1
  297.         add   ebx,1*65536-1
  298.         test  ax,ax
  299.         js    no_skin_add_button
  300.         test  bx,bx
  301.         js    no_skin_add_button
  302.         mov   esi,[ebp+SKIN_DATA.colors.frame] ;[edi+24]
  303.         call  draw_rectangle
  304.         dec   ecx
  305.         jnz   _dw3l
  306.         mov   esi,[ebp+SKIN_DATA.colors.inner]
  307.         add   eax,1*65536-1
  308.         add   ebx,1*65536-1
  309.         test  ax,ax
  310.         js    no_skin_add_button
  311.         test  bx,bx
  312.         js    no_skin_add_button
  313.         call  draw_rectangle
  314.  
  315.         cmp   dword[skin_data],'SKIN'
  316.         je    @f
  317.         xor   eax,eax
  318.         xor   ebx,ebx
  319.         mov   esi,[esp]
  320.         mov   ecx,[esi+WDATA.box.width]
  321.         inc   ecx
  322.         mov   edx,[_skinh]
  323.         mov   edi,[common_colours+4] ; standard grab color
  324.         call  [drawbar]
  325.         jmp   draw_clientbar
  326.     @@:
  327.  
  328.         mov     al,[esp+32+4+4]
  329.         call    drawwindow_IV_caption
  330.  
  331.     draw_clientbar:
  332.  
  333.         mov   esi,[esp]
  334.  
  335.         mov   edx,[esi+WDATA.box.top]                       ; WORK AREA
  336.         add   edx,21+5
  337.         mov   ebx,[esi+WDATA.box.top]
  338.         add   ebx,[esi+WDATA.box.height]
  339.         cmp   edx,ebx
  340.         jg    _noinside2
  341.         mov   eax,5
  342.         mov   ebx,[_skinh]
  343.         mov   ecx,[esi+WDATA.box.width]
  344.         mov   edx,[esi+WDATA.box.height]
  345.         sub   ecx,4
  346.         sub   edx,4
  347.         mov   edi,[esi+WDATA.cl_workarea]
  348.         call  [drawbar]
  349.       _noinside2:
  350.  
  351.         cmp   dword[skin_data],'SKIN'
  352.         jne   no_skin_add_button
  353.  
  354. ;* close button
  355.         mov   edi,[0xfe88]
  356.         movzx eax,word [edi]
  357.         cmp   eax,1000
  358.         jge   no_skin_add_button
  359.         inc   eax
  360.         mov   [edi],ax
  361.  
  362.         shl   eax,4
  363.         add   eax,edi
  364.  
  365.         mov   bx,[0x3000]
  366.         mov   [eax],bx
  367.  
  368.         add   eax,2         ; save button id number
  369.         mov   bx,1
  370.         mov   [eax],bx
  371.         add   eax,2         ; x start
  372.         xor   ebx,ebx
  373.         cmp   [skin_btn_close.left],0
  374.         jge   _bCx_at_right
  375.         mov   ebx,[esp]
  376.         mov   ebx,[ebx+WDATA.box.width]
  377.         inc   ebx
  378.       _bCx_at_right:
  379.         add   ebx,[skin_btn_close.left]
  380.         mov   [eax],bx
  381.         add   eax,2         ; x size
  382.         mov   ebx,[skin_btn_close.width]
  383.         dec   ebx
  384.         mov   [eax],bx
  385.         add   eax,2         ; y start
  386.         mov   ebx,[skin_btn_close.top]
  387.         mov   [eax],bx
  388.         add   eax,2         ; y size
  389.         mov   ebx,[skin_btn_close.height]
  390.         dec   ebx
  391.         mov   [eax],bx
  392.  
  393. ;* minimize button
  394.         mov   edi,[0xfe88]
  395.         movzx eax,word [edi]
  396.         cmp   eax,1000
  397.         jge   no_skin_add_button
  398.         inc   eax
  399.         mov   [edi],ax
  400.  
  401.         shl   eax,4
  402.         add   eax,edi
  403.  
  404.         mov   bx,[0x3000]
  405.         mov   [eax],bx
  406.  
  407.         add   eax,2         ; save button id number
  408.         mov   bx,65535 ;999
  409.         mov   [eax],bx
  410.         add   eax,2         ; x start
  411.         xor   ebx,ebx
  412.         cmp   [skin_btn_minimize.left],0
  413.         jge   _bMx_at_right
  414.         mov   ebx,[esp]
  415.         mov   ebx,[ebx+WDATA.box.width]
  416.         inc   ebx
  417.       _bMx_at_right:
  418.         add   ebx,[skin_btn_minimize.left]
  419.         mov   [eax],bx
  420.         add   eax,2         ; x size
  421.         mov   ebx,[skin_btn_minimize.width]
  422.         dec   ebx
  423.         mov   [eax],bx
  424.         add   eax,2         ; y start
  425.         mov   ebx,[skin_btn_minimize.top]
  426.         mov   [eax],bx
  427.         add   eax,2         ; y size
  428.         mov   ebx,[skin_btn_minimize.height]
  429.         dec   ebx
  430.         mov   [eax],bx
  431.  
  432.       no_skin_add_button:
  433.  
  434.         add   esp,4
  435.         popa
  436.  
  437.         ret  4
  438.  
  439.