Subversion Repositories Kolibri OS

Rev

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

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