Subversion Repositories Kolibri OS

Rev

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

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