Subversion Repositories Kolibri OS

Rev

Rev 1710 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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