Subversion Repositories Kolibri OS

Rev

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