Subversion Repositories Kolibri OS

Rev

Rev 3472 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;    UNIFORM WINDOW COLOURS & SKIN
  3. ;
  4. ;    Compile with FASM for Menuet
  5. ;
  6. ;    < russian edition by Ivan Poddubny >
  7. ;    < skin selection by Mike Semenyako >
  8. ;******************************************************************************
  9. ; last update:  01/04/2013
  10. ; written by:   Marat Zakiyanov aka Mario79, aka Mario
  11. ; changes:      select colors with ColorDialog
  12. ;               some redesign of the look of the program
  13. ;******************************************************************************
  14. ; last update:  10/09/2010
  15. ; written by:   Marat Zakiyanov aka Mario79, aka Mario
  16. ; changes:      select path with OpenDialog
  17. ;******************************************************************************
  18.         use32
  19.         org 0
  20.         db 'MENUET01'   ; identifier
  21.         dd 1            ; header version
  22.         dd START        ; start address
  23.         dd IM_END       ; file size
  24.         dd I_END        ; memory
  25.         dd stacktop     ; stack pointer
  26.         dd skin_info    ; parameters
  27.         dd cur_dir_path ; path to file
  28.  
  29. include 'lang.inc'
  30. include '../../../config.inc'           ;for nightbuild
  31. include '../../../macros.inc'
  32. include 'kglobals.inc'
  33. include 'unpacker.inc'
  34. include '../../../develop/libraries/box_lib/load_lib.mac'
  35.         @use_library
  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. frame_1:
  79.   .x      = 5
  80.   .y      = 220
  81.   .width  = 420
  82.   .height = 50
  83. ;--------------------------------------  
  84. frame_2:
  85.   .x      = 5
  86.   .y      = 280
  87.   .width  = 420
  88.   .height = 50
  89. ;---------------------------------------------------------------------
  90. START:          ; start of execution
  91. ;---------------------------------------------------------------------
  92.         mcall   68,11
  93.        
  94.         test    eax,eax
  95.         jz      close  
  96.  
  97. load_libraries l_libs_start,end_l_libs
  98.  
  99. ;if return code =-1 then exit, else nornary work
  100.         inc     eax
  101.         test    eax,eax
  102.         jz      close
  103. ;---------------------------------------------------------------------
  104.         mov     edi,filename_area
  105.         mov     esi,start_temp_file_name
  106.         xor     eax,eax
  107.         cld
  108. @@:
  109.         lodsb
  110.         stosb
  111.         test    eax,eax
  112.         jnz     @b
  113.  
  114.  
  115.         mov     edi,fname
  116.         mov     esi,default_dtp
  117.         xor     eax,eax
  118.         cld
  119. @@:
  120.         lodsb
  121.         stosb
  122.         test    eax,eax
  123.         jnz     @b
  124.  
  125. ;---------------------------------------------------------------------
  126.         mov     edi,skin_info
  127.         cmp     byte [edi], 0
  128.         jne     skin_path_ready
  129.         mov     esi,default_skin
  130.         xor     eax,eax
  131.         cld
  132. @@:
  133.         lodsb
  134.         stosb
  135.         test    eax,eax
  136.         jnz     @b
  137. skin_path_ready:       
  138. ;---------------------------------------------------------------------
  139. ;OpenDialog     initialisation
  140.         push    dword OpenDialog_data
  141.         call    [OpenDialog_Init]
  142.  
  143.         push    dword OpenDialog_data2
  144.         call    [OpenDialog_Init]
  145. ;--------------------------------------------------------------------
  146. ;init_ColorDialog       ColorDialog_data
  147.         push    dword ColorDialog_data
  148.         call    [ColorDialog_Init]
  149. ;--------------------------------------------------------------------
  150. ; prepare for PathShow
  151.         push    dword PathShow_data_1
  152.         call    [PathShow_prepare]
  153.        
  154.         push    dword PathShow_data_2
  155.         call    [PathShow_prepare]
  156. ;--------------------------------------------------------------------- 
  157.         mcall   48,3,color_table,4*10   ; get current colors
  158.         call    load_skin_file.2
  159. ;--------------------------------------------------------------------- 
  160. red:
  161.         call    draw_window             ; at first, draw the window
  162. ;--------------------------------------------------------------------- 
  163. still:
  164.         mcall   10      ; wait here for event
  165.  
  166.         dec     eax     ; redraw request ?
  167.         jz      red
  168.  
  169.         dec     eax     ; key in buffer ?
  170.         jz      key
  171.  
  172.         dec     eax     ; button in buffer ?
  173.         jz      button
  174.  
  175.         jmp     still
  176. ;---------------------------------------------------------------------
  177. key:            ; key
  178.         mcall   2       ; just read it and ignore
  179.         jmp     still
  180. ;---------------------------------------------------------------------
  181. button:         ; button
  182.         mcall   17      ; get id
  183.  
  184.         cmp     ah,12   ; load file
  185.         jne     no_load
  186.  
  187.         call    load_file
  188.         call    draw_window
  189.         jmp     still
  190. ;--------------------------------------
  191. no_load:
  192.         cmp     ah,13   ; save file
  193.         jne     no_save
  194.  
  195.         call    save_file
  196.         jmp     still
  197. ;--------------------------------------
  198. no_save:
  199.         cmp     ah,14   ; set 3d buttons
  200.         jne     no_3d
  201.  
  202.         mcall   48,1,1
  203.         jmp     doapply
  204. ;--------------------------------------
  205. no_3d:
  206.         cmp     ah,15   ; set flat buttons
  207.         jne     no_flat
  208.  
  209.         mcall   48, 1, 0
  210. ;--------------------------------------
  211. doapply:
  212.         mcall   48, 0, 0
  213.         jmp     still
  214. ;--------------------------------------
  215. no_flat:
  216.         cmp     ah,16   ; apply
  217.         jne     no_apply
  218. ;--------------------------------------
  219. apply_direct:
  220.         mcall   48,2,color_table,10*4
  221.         jmp     doapply
  222. ;--------------------------------------
  223.  no_apply:
  224.         cmp     ah,17   ; load skin file
  225.         jne     no_load_skin
  226.  
  227.         call    load_skin_file
  228.         call    draw_window
  229.         jmp     still
  230. ;--------------------------------------
  231. no_load_skin:
  232.         cmp     ah,18   ; apply skin
  233.         jne     no_apply_skin
  234.  
  235.         cmp     [skin_info],0
  236.         je      no_apply_skin
  237.  
  238.         mcall   48,8,skin_info
  239.         call    draw_window
  240.         jmp     still
  241. ;--------------------------------------
  242. no_apply_skin:
  243.         cmp     ah,31
  244.         jb      no_new_colour
  245.  
  246.         cmp     ah,41
  247.         jg      no_new_colour
  248.        
  249. ;--------------------------------------------------------------------- 
  250. .start_ColorDialog:
  251.         push    dword ColorDialog_data
  252.         call    [ColorDialog_Start]
  253. ; 2 - use another method/not found program
  254.         cmp     [ColorDialog_data.status],2
  255.         je      still
  256. ; 1 - OK, color selected       
  257.         cmp     [ColorDialog_data.status],1
  258.         jne     still
  259. ;--------------------------------------------------------------------- 
  260.        
  261.         shr     eax,8
  262.         sub     eax,31
  263.         shl     eax,2
  264.         mov     ebx,[ColorDialog_data.color]
  265.         and     ebx,0xffffff    ; temporary for ColorDialog!!!!!!!!!!
  266.         mov     [eax+color_table],ebx
  267.         cmp     dword[not_packed_area+SKIN_HEADER.ident],'SKIN'
  268.         jne     @f
  269.  
  270.         mov     edi,[not_packed_area+SKIN_HEADER.params]
  271.         mov     dword[edi+not_packed_area+SKIN_PARAMS.dtp.data+eax],ebx
  272.         call    draw_skin
  273. ;--------------------------------------
  274. @@:
  275.         call    draw_colours
  276.         jmp     still
  277. ;--------------------------------------
  278. no_new_colour:
  279.         cmp     ah,1    ; terminate
  280.         jnz     noid1
  281. ;--------------------------------------
  282. close:
  283.         or      eax,-1
  284.         mcall
  285. ;--------------------------------------
  286. noid1:
  287.         jmp     still
  288. ;---------------------------------------------------------------------
  289. load_file:
  290. ;---------------------------------------------------------------------
  291. ; invoke OpenDialog
  292.         mov     [OpenDialog_data.type],dword 0
  293.         push    dword OpenDialog_data
  294.         call    [OpenDialog_Start]
  295.         cmp     [OpenDialog_data.status],1
  296.         je      .1
  297.         ret
  298. .1:
  299. ; prepare for PathShow
  300.         push    dword PathShow_data_1
  301.         call    [PathShow_prepare]
  302.  
  303.         call    draw_PathShow
  304. ;---------------------------------------------------------------------
  305.         xor     eax, eax
  306.         mov     ebx, read_info
  307.         mov     dword [ebx], eax        ; subfunction: read
  308.         mov     dword [ebx+4], eax      ; offset (low dword)
  309.         mov     dword [ebx+8], eax      ; offset (high dword)
  310.         mov     dword [ebx+12], 40     ; read colors file: 4*10 bytes
  311.         mov     dword [ebx+16], color_table ; address
  312.         mcall   70
  313.         ret
  314. ;---------------------------------------------------------------------
  315. load_skin_file:
  316. ;---------------------------------------------------------------------
  317. ; invoke OpenDialog
  318.         push    dword OpenDialog_data2
  319.         call    [OpenDialog_Start]
  320.         cmp     [OpenDialog_data2.status],1
  321.         je      .1
  322.         ret
  323. .1:
  324. ; prepare for PathShow
  325.         push    dword PathShow_data_2
  326.         call    [PathShow_prepare]
  327.  
  328.         call    draw_PathShow
  329. ;---------------------------------------------------------------------
  330. .2:
  331.         xor     eax,eax
  332.         mov     ebx,read_info2
  333.         mov     dword [ebx], eax        ; subfunction: read
  334.         mov     dword [ebx+4], eax      ; offset (low dword)
  335.         mov     dword [ebx+8], eax      ; offset (high dword)
  336.         mov     dword [ebx+12], 32*1024 ; read: max 32 KBytes
  337.         mov     dword [ebx+16], file_load_area ; address
  338.         mcall   70
  339.  
  340.         mov     esi, file_load_area
  341.  
  342.         cmp     dword [esi], 'KPCK'
  343.         jnz     notpacked
  344.  
  345.         cmp     dword [esi+4], 32*1024 ; max 32 KBytes
  346.         ja      doret
  347.  
  348.         push    unpack_area
  349.         push    esi
  350.         call    unpack
  351.         mov     esi,unpack_area
  352. ;--------------------------------------
  353. notpacked:
  354.         cmp     [esi+SKIN_HEADER.ident],dword 'SKIN'
  355.         jne     doret
  356.  
  357.         mov     edi,not_packed_area
  358.         mov     ecx,0x8000/4
  359.         rep     movsd
  360.  
  361.         mov     ebp,not_packed_area
  362.         mov     esi,[ebp+SKIN_HEADER.params]
  363.         add     esi,ebp
  364.         lea     esi,[esi+SKIN_PARAMS.dtp.data]
  365.         mov     edi,color_table
  366.         mov     ecx,10
  367.         rep     movsd
  368. ;--------------------------------------
  369. doret:
  370.         ret
  371. ;---------------------------------------------------------------------
  372. save_file:
  373. ;---------------------------------------------------------------------
  374. ; invoke OpenDialog
  375.         mov     [OpenDialog_data.type],dword 1
  376.         push    dword OpenDialog_data
  377.         call    [OpenDialog_Start]
  378.         cmp     [OpenDialog_data.status],1
  379.         je      .1
  380.         ret
  381. .1:
  382. ; prepare for PathShow
  383.         push    dword PathShow_data_1
  384.         call    [PathShow_prepare]
  385.  
  386.         call    draw_PathShow
  387. ;---------------------------------------------------------------------
  388.         xor     eax,eax
  389.         mov     ebx,write_info
  390.         mov     [ebx],dword 2                   ; subfunction: write
  391.         and     [ebx+4],eax                     ; (reserved)
  392.         and     [ebx+8],eax                     ; (reserved)
  393.         mov     [ebx+12],dword 10*4             ; bytes to write
  394.         mov     [ebx+16],dword color_table      ; address
  395.         mcall   70
  396.         ret
  397. ;---------------------------------------------------------------------
  398. draw_button_row:
  399.         mov     edx,0x60000000 + 31             ; BUTTON ROW
  400.         mov     ebx,220*65536+14
  401.         mov     ecx,10*65536+14
  402.         mov     eax,8
  403. ;-----------------------------------
  404. .newb:
  405.         mcall
  406.         add     ecx,20*65536
  407.         inc     edx
  408.         cmp     edx,0x60000000 + 40
  409.         jbe     .newb
  410.         ret
  411. ;---------------------------------------------------------------------
  412. draw_button_row_of_texts:
  413.         mov     ebx,240*65536+13        ; ROW OF TEXTS
  414.         mov     ecx,[w_work_text]
  415.         mov     edx,text
  416.         mov     esi,32
  417.         mov     eax,4
  418. ;-----------------------------------
  419. .newline:
  420.         mcall
  421.         add     ebx,20
  422.         add     edx,32
  423.         cmp     [edx],byte 'x'
  424.         jne     .newline
  425.         ret
  426. ;---------------------------------------------------------------------
  427. draw_colours:
  428.         pusha
  429.         mov     esi,color_table
  430.         mov     ebx,220*65536+14
  431.         mov     ecx,10*65536+14
  432.         mov     eax,13
  433.         mov     [frame_data.draw_text_flag],dword 0
  434. ;--------------------------------------
  435. newcol:
  436.         mov     edx,[esi]
  437.         mcall
  438.  
  439.         push    ebx ecx
  440.  
  441.         sub     ebx,2 shl 16
  442.         add     bx,4
  443.         sub     ecx,2 shl 16
  444.         add     cx,4
  445.        
  446.         mov     [frame_data.x],ebx
  447.         mov     [frame_data.y],ecx     
  448.  
  449.         push    dword frame_data
  450.         call    [Frame_draw]
  451.  
  452.         pop     ecx ebx
  453.  
  454.         add     ecx,20*65536
  455.         add     esi,4
  456.         cmp     esi,color_table+4*9
  457.         jbe     newcol
  458.  
  459.         popa
  460.         ret
  461. ;----------------------------------------------------------------------
  462. draw_PathShow:
  463.         pusha
  464.         mcall   13,<frame_1.x+5,frame_1.width-15>,<frame_1.y+7,15>,0xffffff
  465.         mcall   13,<frame_2.x+5,frame_2.width-15>,<frame_2.y+7,15>,0xffffff
  466. ; draw for PathShow
  467.         push    dword PathShow_data_1
  468.         call    [PathShow_draw]
  469.        
  470.         push    dword PathShow_data_2
  471.         call    [PathShow_draw]
  472.         popa
  473.         ret
  474. ;---------------------------------------------------------------------
  475. ;   *********************************************
  476. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  477. ;   *********************************************
  478. draw_window:
  479.         mcall   12,1
  480.         mcall   48,3,app_colours,10*4
  481.         mcall   14
  482.         mcall   48,4
  483.         mov     [current_skin_high],eax
  484. ; DRAW WINDOW
  485.         xor     eax,eax         ; function 0 : define and draw window
  486.         xor     esi,esi
  487.         mov     edx,[w_work]    ; color of work area RRGGBB,8->color
  488.         or      edx,0x34000000
  489.         mov     ecx,50 shl 16 + 346
  490.         add     ecx,[current_skin_high]
  491.         mcall   ,<110,440>,,,,title
  492.  
  493.         mcall   9,procinfo,-1
  494.        
  495.         mov     eax,[procinfo+70] ;status of window
  496.         test    eax,100b
  497.         jne     .end
  498.  
  499. ;if lang eq ru
  500.   load_w  = (5*2+6*9)
  501.   save_w  = (5*2+6*9)
  502.   flat_w  = (5*2+6*7)
  503.   apply_w = (5*2+6*9)
  504. ;else
  505. ;  load_w  = (5*2+6*6)
  506. ;  save_w  = (5*2+6*8)
  507. ;  flat_w  = (5*2+6*4)
  508. ;  apply_w = (5*2+6*7)
  509. ;end if
  510. ;-----------------------------------
  511. ; select color DTP frame
  512. ; LOAD BUTTON   ; button 12
  513.         mcall   8,<frame_1.x+10,load_w>,<frame_1.y+25,18>,12,[w_work_button]
  514. ; SAVE BUTTON
  515.         add     ebx,(load_w+2)*65536-load_w+save_w
  516.         inc     edx
  517.         mcall           ; button 13
  518. ; APPLY BUTTON
  519.         mov     ebx,(frame_1.x + frame_1.width - apply_w - 15)*65536+apply_w
  520.         mcall   8,,,16  ; button 17
  521. ; select color DTP button text
  522.         mcall   4,<frame_1.x+16,frame_1.y+31>,[w_work_button_text],t1,t1.size
  523. ;-----------------------------------   
  524. ; select skin frame    
  525. ; LOAD SKIN BUTTON      ; button 17
  526.         mcall   8,<frame_2.x+10,load_w>,<frame_2.y+25,18>,17,[w_work_button]
  527. ; 3D
  528.         mov     ebx,(frame_2.x+155)*65536+34
  529.         mcall   ,,,14   ; button 14
  530. ; FLAT
  531.         add     ebx,36*65536-34+flat_w
  532.         inc     edx
  533.         mcall           ; button 15
  534. ; APPLY SKIN BUTTON
  535.         mov     ebx,(frame_2.x + frame_2.width - apply_w -15)*65536+apply_w
  536.         mcall   ,,,18           ; button 18
  537. ; select skin button text
  538.         mcall   4,<frame_2.x+16,frame_2.y+31>,[w_work_button_text],t2,t2.size
  539. ;-----------------------------------           
  540.         call    draw_button_row
  541.         call    draw_button_row_of_texts
  542.         call    draw_colours
  543. ;-----------------------------------
  544.         mov     [frame_data.x],dword frame_1.x shl 16+frame_1.width
  545.         mov     [frame_data.y],dword frame_1.y shl 16+frame_1.height
  546.         mov     [frame_data.text_pointer],dword select_dtp_text
  547.         mov     eax,[w_work]
  548.         mov     [frame_data.font_backgr_color],eax
  549.         mov     eax,[w_work_text]
  550.         mov     [frame_data.font_color],eax
  551.         mov     [frame_data.draw_text_flag],dword 1
  552.        
  553.         push    dword frame_data
  554.         call    [Frame_draw]
  555. ;-----------------------------------
  556.         mov     [frame_data.x],dword frame_2.x shl 16+frame_2.width
  557.         mov     [frame_data.y],dword frame_2.y shl 16+frame_2.height
  558.         mov     [frame_data.text_pointer],dword select_skin_text
  559.  
  560.         push    dword frame_data
  561.         call    [Frame_draw]
  562. ;-----------------------------------
  563.         call    draw_PathShow
  564. ;-----------------------------------
  565.         cmp     dword[not_packed_area+SKIN_HEADER.ident],'SKIN'
  566.         jne     @f
  567.         call    draw_skin
  568. @@:
  569. .end:
  570.         mcall   12,2
  571.         ret
  572. ;-----------------------------------------------------------------------------
  573. include 'drawskin.inc'
  574. ;-----------------------------------------------------------------------------
  575. ; DATA AREA
  576. ;-----------------------------------------------------------------------------
  577. include 'idata.inc'
  578. ;-----------------------------------------------------------------------------
  579. IM_END:
  580. ;-----------------------------------------------------------------------------
  581. include 'udata.inc'
  582. ;-----------------------------------------------------------------------------
  583. I_END:
  584. ;-----------------------------------------------------------------------------