Subversion Repositories Kolibri OS

Rev

Rev 1362 | Rev 2381 | Go to most recent revision | 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: 2288 $
  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:
  131.         cmp     dword[ebx], 0
  132.         je      .end_bitmaps
  133.         movzx   eax, [ebx+SKIN_BITMAPS.kind]
  134.         movzx   ecx, [ebx+SKIN_BITMAPS.type]
  135.         dec     eax
  136.         jnz     .not_left
  137.         xor     eax, eax
  138.         mov     edx, skin_active.left.data
  139.         or      ecx, ecx
  140.         jnz     @f
  141.         mov     edx, skin_inactive.left.data
  142.     @@:
  143.         jmp     .next_bitmap
  144.   .not_left:
  145.         dec     eax
  146.         jnz     .not_oper
  147.         mov     esi, [ebx+SKIN_BITMAPS.data]
  148.         add     esi, skin_data
  149.         mov     eax, [esi+0]
  150.         neg     eax
  151.         mov     edx, skin_active.oper.data
  152.         or      ecx, ecx
  153.         jnz     @f
  154.         mov     edx, skin_inactive.oper.data
  155.     @@:
  156.         jmp     .next_bitmap
  157.   .not_oper:
  158.         dec     eax
  159.         jnz     .not_base
  160.         mov     eax, [skin_active.left.width]
  161.         mov     edx, skin_active.base.data
  162.         or      ecx, ecx
  163.         jnz     @f
  164.         mov     eax, [skin_inactive.left.width]
  165.         mov     edx, skin_inactive.base.data
  166.     @@:
  167.         jmp     .next_bitmap
  168.   .not_base:
  169.         add     ebx, 8
  170.         jmp     .lp1
  171.   .next_bitmap:
  172.         mov     ecx, [ebx+SKIN_BITMAPS.data]
  173.         add     ecx, skin_data
  174.         mov     [edx+4], eax
  175.         mov     eax, [ecx+0]
  176.         mov     [edx+8], eax
  177.         add     ecx, 8
  178.         mov     [edx+0], ecx
  179.         add     ebx, 8
  180.         jmp     .lp1
  181.   .end_bitmaps:
  182.  
  183.         mov     ebx, [ebp+SKIN_HEADER.buttons]
  184.         add     ebx, skin_data
  185.   .lp2:
  186.         cmp     dword[ebx], 0
  187.         je      .end_buttons
  188.         mov     eax, [ebx+SKIN_BUTTONS.type]
  189.         dec     eax
  190.         jnz     .not_close
  191.         mov     edx, skin_btn_close
  192.         jmp     .next_button
  193.   .not_close:
  194.         dec     eax
  195.         jnz     .not_minimize
  196.         mov     edx, skin_btn_minimize
  197.         jmp     .next_button
  198.   .not_minimize:
  199.         add     ebx, 12
  200.         jmp     .lp2
  201.   .next_button:
  202.         movsx   eax, [ebx+SKIN_BUTTONS.left]
  203.         mov     [edx+SKIN_BUTTON.left], eax
  204.         movsx   eax, [ebx+SKIN_BUTTONS.top]
  205.         mov     [edx+SKIN_BUTTON.top], eax
  206.         movsx   eax, [ebx+SKIN_BUTTONS.width]
  207.         mov     [edx+SKIN_BUTTON.width], eax
  208.         movsx   eax, [ebx+SKIN_BUTTONS.height]
  209.         mov     [edx+SKIN_BUTTON.height], eax
  210.         add     ebx, 12
  211.         jmp     .lp2
  212.   .end_buttons:
  213.  
  214.   .exit:
  215.         ret
  216.  
  217. sys_putimage_with_check:
  218.         or      ebx, ebx
  219.         jz      @f
  220.         call    sys_putimage.forced
  221.     @@:
  222.         ret
  223.  
  224. drawwindow_IV_caption:
  225.  
  226.         mov     ebp, skin_active
  227.         or      al, al
  228.         jnz     @f
  229.         mov     ebp, skin_inactive
  230.     @@:
  231.  
  232.         mov     esi, [esp+4]
  233.         mov     eax, [esi+WDATA.box.width]   ; window width
  234.         mov     edx, [ebp+SKIN_DATA.left.left]
  235.         shl     edx, 16
  236.         mov     ecx, [ebp+SKIN_DATA.left.width]
  237.         shl     ecx, 16
  238.         add     ecx, [_skinh]
  239.  
  240.         mov     ebx, [ebp+SKIN_DATA.left.data]
  241.         call    sys_putimage_with_check
  242.  
  243.         mov     esi, [esp+4]
  244.         mov     eax, [esi+WDATA.box.width]
  245.         sub     eax, [ebp+SKIN_DATA.left.width]
  246.         sub     eax, [ebp+SKIN_DATA.oper.width]
  247.         cmp     eax, [ebp+SKIN_DATA.base.left]
  248.         jng     .non_base
  249.         xor     edx, edx
  250.         mov     ecx, [ebp+SKIN_DATA.base.width]
  251.         jecxz   .non_base
  252.         div     ecx
  253.  
  254.         inc     eax
  255.  
  256.         mov     ebx, [ebp+SKIN_DATA.base.data]
  257.         mov     ecx, [ebp+SKIN_DATA.base.width]
  258.         shl     ecx, 16
  259.         add     ecx, [_skinh]
  260.         mov     edx, [ebp+SKIN_DATA.base.left]
  261.         sub     edx, [ebp+SKIN_DATA.base.width]
  262.         shl     edx, 16
  263.   .baseskinloop:
  264.         shr     edx, 16
  265.         add     edx, [ebp+SKIN_DATA.base.width]
  266.         shl     edx, 16
  267.  
  268.         push    eax ebx ecx edx
  269.         call    sys_putimage_with_check
  270.         pop     edx ecx ebx eax
  271.  
  272.         dec     eax
  273.         jnz     .baseskinloop
  274.   .non_base:
  275.  
  276.         mov     esi, [esp+4]
  277.         mov     edx, [esi+WDATA.box.width]
  278.         sub     edx, [ebp+SKIN_DATA.oper.width]
  279.         inc     edx
  280.         shl     edx, 16
  281.         mov     ebx, [ebp+SKIN_DATA.oper.data]
  282.  
  283.         mov     ecx, [ebp+SKIN_DATA.oper.width]
  284.         shl     ecx, 16
  285.         add     ecx, [_skinh]
  286.         call    sys_putimage_with_check
  287.  
  288.         ret
  289.  
  290. ;//mike.dld, 2006-08-02 ]
  291.  
  292.  
  293. drawwindow_IV:
  294. ;param1 - aw_yes
  295.  
  296.         pusha
  297.  
  298.         push    edx
  299.  
  300.         mov     edi, edx
  301.  
  302.         mov     ebp, skin_active
  303.         cmp     byte [esp+32+4+4], 0
  304.         jne     @f
  305.         mov     ebp, skin_inactive
  306.      @@:
  307.  
  308.         mov     eax, [edi+WDATA.box.left]
  309.         shl     eax, 16
  310.         mov     ax, word [edi+WDATA.box.left]
  311.         add     ax, word [edi+WDATA.box.width]
  312.         mov     ebx, [edi+WDATA.box.top]
  313.         shl     ebx, 16
  314.         mov     bx, word [edi+WDATA.box.top]
  315.         add     bx, word [edi+WDATA.box.height]
  316. ;        mov   esi,[edi+24]
  317. ;        shr   esi,1
  318. ;        and   esi,0x007f7f7f
  319.         mov     esi, [ebp+SKIN_DATA.colors.outer]
  320.         call    draw_rectangle
  321.         mov     ecx, 3
  322.       _dw3l:
  323.         add     eax, 1*65536-1
  324.         add     ebx, 1*65536-1
  325.         test    ax, ax
  326.         js      no_skin_add_button
  327.         test    bx, bx
  328.         js      no_skin_add_button
  329.         mov     esi, [ebp+SKIN_DATA.colors.frame];[edi+24]
  330.         call    draw_rectangle
  331.         dec     ecx
  332.         jnz     _dw3l
  333.         mov     esi, [ebp+SKIN_DATA.colors.inner]
  334.         add     eax, 1*65536-1
  335.         add     ebx, 1*65536-1
  336.         test    ax, ax
  337.         js      no_skin_add_button
  338.         test    bx, bx
  339.         js      no_skin_add_button
  340.         call    draw_rectangle
  341.  
  342.         cmp     dword[skin_data], 'SKIN'
  343.         je      @f
  344.         xor     eax, eax
  345.         xor     ebx, ebx
  346.         mov     esi, [esp]
  347.         mov     ecx, [esi+WDATA.box.width]
  348.         inc     ecx
  349.         mov     edx, [_skinh]
  350.         mov     edi, [common_colours+4]; standard grab color
  351.         call    [drawbar]
  352.         jmp     draw_clientbar
  353.     @@:
  354.  
  355.         mov     al, [esp+32+4+4]
  356.         call    drawwindow_IV_caption
  357.  
  358.     draw_clientbar:
  359.  
  360.         mov     esi, [esp]
  361.  
  362.         mov     edx, [esi+WDATA.box.top]                    ; WORK AREA
  363.         add     edx, 21+5
  364.         mov     ebx, [esi+WDATA.box.top]
  365.         add     ebx, [esi+WDATA.box.height]
  366.         cmp     edx, ebx
  367.         jg      _noinside2
  368.         mov     eax, 5
  369.         mov     ebx, [_skinh]
  370.         mov     ecx, [esi+WDATA.box.width]
  371.         mov     edx, [esi+WDATA.box.height]
  372.         sub     ecx, 4
  373.         sub     edx, 4
  374.         mov     edi, [esi+WDATA.cl_workarea]
  375.         test    edi, 0x40000000
  376.         jnz     _noinside2
  377.         call    [drawbar]
  378.       _noinside2:
  379.  
  380.         cmp     dword[skin_data], 'SKIN'
  381.         jne     no_skin_add_button
  382.  
  383. ;* close button
  384.         mov     edi, [BTN_ADDR]
  385.         movzx   eax, word [edi]
  386.         cmp     eax, 1000
  387.         jge     no_skin_add_button
  388.         inc     eax
  389.         mov     [edi], ax
  390.  
  391.         shl     eax, 4
  392.         add     eax, edi
  393.  
  394.         mov     bx, [CURRENT_TASK]
  395.         mov     [eax], bx
  396.  
  397.         add     eax, 2      ; save button id number
  398.         mov     bx, 1
  399.         mov     [eax], bx
  400.         add     eax, 2      ; x start
  401.         xor     ebx, ebx
  402.         cmp     [skin_btn_close.left], 0
  403.         jge     _bCx_at_right
  404.         mov     ebx, [esp]
  405.         mov     ebx, [ebx+WDATA.box.width]
  406.         inc     ebx
  407.       _bCx_at_right:
  408.         add     ebx, [skin_btn_close.left]
  409.         mov     [eax], bx
  410.         add     eax, 2      ; x size
  411.         mov     ebx, [skin_btn_close.width]
  412.         dec     ebx
  413.         mov     [eax], bx
  414.         add     eax, 2      ; y start
  415.         mov     ebx, [skin_btn_close.top]
  416.         mov     [eax], bx
  417.         add     eax, 2      ; y size
  418.         mov     ebx, [skin_btn_close.height]
  419.         dec     ebx
  420.         mov     [eax], bx
  421.  
  422. ;* minimize button
  423.         mov     edi, [BTN_ADDR]
  424.         movzx   eax, word [edi]
  425.         cmp     eax, 1000
  426.         jge     no_skin_add_button
  427.         inc     eax
  428.         mov     [edi], ax
  429.  
  430.         shl     eax, 4
  431.         add     eax, edi
  432.  
  433.         mov     bx, [CURRENT_TASK]
  434.         mov     [eax], bx
  435.  
  436.         add     eax, 2      ; save button id number
  437.         mov     bx, 65535;999
  438.         mov     [eax], bx
  439.         add     eax, 2      ; x start
  440.         xor     ebx, ebx
  441.         cmp     [skin_btn_minimize.left], 0
  442.         jge     _bMx_at_right
  443.         mov     ebx, [esp]
  444.         mov     ebx, [ebx+WDATA.box.width]
  445.         inc     ebx
  446.       _bMx_at_right:
  447.         add     ebx, [skin_btn_minimize.left]
  448.         mov     [eax], bx
  449.         add     eax, 2      ; x size
  450.         mov     ebx, [skin_btn_minimize.width]
  451.         dec     ebx
  452.         mov     [eax], bx
  453.         add     eax, 2      ; y start
  454.         mov     ebx, [skin_btn_minimize.top]
  455.         mov     [eax], bx
  456.         add     eax, 2      ; y size
  457.         mov     ebx, [skin_btn_minimize.height]
  458.         dec     ebx
  459.         mov     [eax], bx
  460.  
  461.       no_skin_add_button:
  462.         pop     edi
  463.         popa
  464.  
  465.         ret     4
  466.  
  467.