Subversion Repositories Kolibri OS

Rev

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