Subversion Repositories Kolibri OS

Rev

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