Subversion Repositories Kolibri OS

Rev

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