Subversion Repositories Kolibri OS

Rev

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

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