Subversion Repositories Kolibri OS

Rev

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

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