Subversion Repositories Kolibri OS

Rev

Rev 9641 | 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. M01header.params:
  27.         dd app_param    ; parameters
  28.         dd cur_dir_path ; path to file
  29.  
  30. include 'lang.inc'
  31. include '../../../proc32.inc'
  32. include '../../../config.inc'           ;for nightbuild
  33. include '../../../macros.inc'
  34. include '../../../string.inc'
  35. include '../../../dll.inc'
  36. include 'kglobals.inc'
  37. include 'unpacker.inc'
  38. include '../../../KOSfuncs.inc'
  39. include '../../../load_lib.mac'
  40.         @use_library
  41. ;******************************************************************************
  42. ;--------------------------------------
  43. struct SKIN_HEADER
  44.   ident   dd ?
  45.   version dd ?
  46.   params  dd ?
  47.   buttons dd ?
  48.   bitmaps dd ?
  49. ends
  50. ;--------------------------------------
  51. struct SKIN_PARAMS
  52.   skin_height    dd ?
  53.   margin.right   dw ?
  54.   margin.left    dw ?
  55.   margin.bottom  dw ?
  56.   margin.top     dw ?
  57.   colors.inner   dd ?
  58.   colors.outer   dd ?
  59.   colors.frame   dd ?
  60.   colors_1.inner dd ?
  61.   colors_1.outer dd ?
  62.   colors_1.frame dd ?
  63.   dtp.size       dd ?
  64.   dtp.data       db 40 dup (?)
  65. ends
  66. ;--------------------------------------
  67. struct SKIN_BUTTONS
  68.   type     dd ?
  69.   pos:
  70.     left   dw ?
  71.     top    dw ?
  72.   size:
  73.     w  dw ?
  74.     height dw ?
  75. ends
  76. ;--------------------------------------
  77. struct SKIN_BITMAPS
  78.   kind  dw ?
  79.   type  dw ?
  80.   _data  dd ?
  81. ends
  82. ;--------------------------------------
  83. frame_1:
  84.   .x      = 5
  85.   .y      = area.y + area.height + 20
  86.   .w  = area.w + 217
  87.   .height = 65
  88. ;--------------------------------------  
  89. frame_2:
  90.   .x      = frame_1.x
  91.   .y      = frame_1.y + frame_1.height + 20
  92.   .w  = frame_1.w
  93.   .height = frame_1.height
  94. ;---------------------------------------------------------------------
  95. win:
  96.   .w = frame_2.w + frame_2.x + frame_2.x + 9
  97.   .h = frame_2.y + frame_2.height + 10
  98. ;---------------------------------------------------------------------
  99. START:          ; start of execution
  100. ;---------------------------------------------------------------------
  101.         mcall   SF_SYS_MISC,SSF_HEAP_INIT
  102.        
  103.         test    eax,eax
  104.         jz      close  
  105.  
  106. stdcall dll.Load,LibIniImportTable
  107. load_libraries l_libs_start,end_l_libs
  108.  
  109. ;if return code =-1 then exit, else nornary work
  110.         inc     eax
  111.         test    eax,eax
  112.         jz      close
  113. ;---------------------------------------------------------------------
  114. ; set default pathes
  115.         stdcall string.copy, default_skin, skin_info
  116.         stdcall string.copy, default_dtp, dtp_name
  117. ;---------------------------------------------------------------------
  118. ; check app param
  119.         stdcall string.length, [M01header.params]
  120.         add eax, [M01header.params]
  121.         mov ecx, [eax-4]
  122.         or ecx, 0x20202000 ;letters to lowercase
  123.         cmp ecx, '.skn'
  124.         je  load_skin_from_param
  125.         cmp ecx, '.dtp'
  126.         je load_dtp_from_param
  127.         jmp no_param
  128.        
  129. load_dtp_from_param:
  130.         stdcall string.copy, [M01header.params], dtp_name
  131.         call   load_dtp_file.1
  132.         jmp    skin_path_ready
  133.  
  134. load_skin_from_param:
  135.         stdcall string.copy, [M01header.params], skin_info
  136.         call    load_skin_file.2
  137.         jmp     skin_path_ready
  138.  
  139. no_param:
  140.         mcall   SF_STYLE_SETTINGS,SSF_GET_COLORS,color_table,4*10       ; get current colors
  141.         call    load_skin_file.2
  142.        
  143. skin_path_ready:       
  144. ;---------------------------------------------------------------------
  145. ;OpenDialog     initialisation
  146.         push    dword OpenDialog_data
  147.         call    [OpenDialog_Init]
  148.  
  149.         push    dword OpenDialog_data2
  150.         call    [OpenDialog_Init]
  151. ;--------------------------------------------------------------------
  152. ;init_ColorDialog       ColorDialog_data
  153.         push    dword ColorDialog_data
  154.         call    [ColorDialog_Init]
  155. ;--------------------------------------------------------------------
  156. ; prepare for PathShow
  157.         push    dword PathShow_data_1
  158.         call    [PathShow_prepare]
  159.        
  160.         push    dword PathShow_data_2
  161.         call    [PathShow_prepare]
  162. ;--------------------------------------------------------------------- 
  163. red:
  164.         call    draw_window             ; at first, draw the window
  165. ;--------------------------------------------------------------------- 
  166. still:
  167.         mcall   SF_WAIT_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   SF_GET_KEY
  182.         jmp     still
  183. ;---------------------------------------------------------------------
  184. button:         ; button
  185.         mcall   SF_GET_BUTTON
  186.  
  187.         cmp     ah,12   ; load file
  188.         jne     no_load
  189.  
  190.         call    load_dtp_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   SF_STYLE_SETTINGS,SSF_SET_BUTTON_STYLE,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   SF_STYLE_SETTINGS,SSF_SET_BUTTON_STYLE, 0
  215. ;--------------------------------------
  216. doapply:
  217.         mcall   SF_STYLE_SETTINGS,SSF_APPLY, 0
  218.         jmp     still
  219. ;--------------------------------------
  220. no_flat:
  221.         cmp     ah,16   ; apply
  222.         jne     no_apply
  223. ;--------------------------------------
  224. apply_direct:
  225.         mcall   SF_STYLE_SETTINGS,SSF_SET_COLORS,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   SF_STYLE_SETTINGS,SSF_SET_SKIN,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_dtp_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. .2:
  311.         xor     eax, eax
  312.         mov     ebx, read_info
  313.         mov     dword [ebx], eax        ; subfunction: read
  314.         mov     dword [ebx+4], eax      ; offset (low dword)
  315.         mov     dword [ebx+8], eax      ; offset (high dword)
  316.         mov     dword [ebx+12], 40     ; read colors file: 4*10 bytes
  317.         mov     dword [ebx+16], color_table ; address
  318.         mcall   SF_FILE
  319.         ret
  320. ;---------------------------------------------------------------------
  321. load_skin_file:
  322. ;---------------------------------------------------------------------
  323. ; invoke OpenDialog
  324.         push    dword OpenDialog_data2
  325.         call    [OpenDialog_Start]
  326.         cmp     [OpenDialog_data2.status],1
  327.         je      .1
  328.         ret
  329. .1:
  330. ; prepare for PathShow
  331.         push    dword PathShow_data_2
  332.         call    [PathShow_prepare]
  333.  
  334.         call    draw_PathShow
  335. ;---------------------------------------------------------------------
  336. .2:
  337.         xor     eax,eax
  338.         mov     ebx,read_info2
  339.         mov     dword [ebx], eax        ; subfunction: read
  340.         mov     dword [ebx+4], eax      ; offset (low dword)
  341.         mov     dword [ebx+8], eax      ; offset (high dword)
  342.         mov     dword [ebx+12], 32*1024 ; read: max 32 KBytes
  343.         mov     dword [ebx+16], file_load_area ; address
  344.         mcall   SF_FILE
  345.  
  346.         mov     esi, file_load_area
  347.  
  348.         cmp     dword [esi], 'KPCK'
  349.         jnz     notpacked
  350.  
  351.         cmp     dword [esi+4], 32*1024 ; max 32 KBytes
  352.         ja      doret
  353.  
  354.         push    unpack_area
  355.         push    esi
  356.         call    unpack
  357.         mov     esi,unpack_area
  358. ;--------------------------------------
  359. notpacked:
  360.         cmp     [esi+SKIN_HEADER.ident],dword 'SKIN'
  361.         jne     doret
  362.  
  363.         mov     edi,not_packed_area
  364.         mov     ecx,0x8000/4
  365.         rep     movsd
  366.  
  367.         mov     ebp,not_packed_area
  368.         mov     esi,[ebp+SKIN_HEADER.params]
  369.         add     esi,ebp
  370.         lea     esi,[esi+SKIN_PARAMS.dtp.data]
  371.         mov     edi,color_table
  372.         mov     ecx,10
  373.         rep     movsd
  374. ;--------------------------------------
  375. doret:
  376.         ret
  377. ;---------------------------------------------------------------------
  378. save_file:
  379. ;---------------------------------------------------------------------
  380. ; invoke OpenDialog
  381.         mov     [OpenDialog_data.type],dword 1
  382.         push    dword OpenDialog_data
  383.         call    [OpenDialog_Start]
  384.         cmp     [OpenDialog_data.status],1
  385.         je      .1
  386.         ret
  387. .1:
  388. ; prepare for PathShow
  389.         push    dword PathShow_data_1
  390.         call    [PathShow_prepare]
  391.  
  392.         call    draw_PathShow
  393. ;---------------------------------------------------------------------
  394.         xor     eax,eax
  395.         mov     ebx,write_info
  396.         mov     [ebx],dword 2                   ; subfunction: write
  397.         and     [ebx+4],eax                     ; (reserved)
  398.         and     [ebx+8],eax                     ; (reserved)
  399.         mov     [ebx+12],dword 10*4             ; bytes to write
  400.         mov     [ebx+16],dword color_table      ; address
  401.         mcall   SF_FILE
  402.         ret
  403. ;---------------------------------------------------------------------
  404. draw_button_row:
  405.         mov     edx,0x40000000 + 31             ; BUTTON ROW
  406.         mov     ebx,(area.w+18)*65536+29
  407.         mov     ecx,9*65536+15
  408.         mov     eax,8
  409. ;-----------------------------------
  410. .newb:
  411.         mcall
  412.         add     ecx,22*65536
  413.         inc     edx
  414.         cmp     edx,0x40000000 + 40
  415.         jbe     .newb
  416.         ret
  417. ;---------------------------------------------------------------------
  418. draw_button_row_of_texts:
  419.         mov     ebx,(area.w+49)*65536+9 ; ROW OF TEXTS
  420.         mov     ecx,[w_work_text]
  421.         add ecx,0x10000000
  422.         mov     edx,text
  423.         mov     esi,32
  424.         mov     eax,4
  425. ;-----------------------------------
  426. .newline:
  427.         mcall
  428.         add     ebx,22
  429.         add     edx,32
  430.         cmp     [edx],byte 'x'
  431.         jne     .newline
  432.         ret
  433. ;---------------------------------------------------------------------
  434. draw_colours:
  435.         pusha
  436.         mov     esi,color_table
  437.         mov     ebx,(area.w+19)*65536+28
  438.         mov     ecx,10*65536+14
  439.         mov     eax,13
  440.         mov     [frame_data.draw_text_flag],dword 0
  441. ;--------------------------------------
  442. newcol:
  443.         mov     edx,[esi]
  444.         mcall
  445.  
  446.         push    ebx ecx
  447.  
  448.         sub     ebx,2 shl 16
  449.         add     bx,4
  450.         sub     ecx,2 shl 16
  451.         add     cx,4
  452.        
  453.         mov     [frame_data.x],ebx
  454.         mov     [frame_data.y],ecx     
  455.  
  456.         push    dword frame_data
  457.         call    [Frame_draw]
  458.  
  459.         pop     ecx ebx
  460.  
  461.         add     ecx,22*65536
  462.         add     esi,4
  463.         cmp     esi,color_table+4*9
  464.         jbe     newcol
  465.  
  466.         popa
  467.         ret
  468. ;----------------------------------------------------------------------
  469. draw_PathShow:
  470.         pusha
  471.         mcall   SF_DRAW_RECT,<frame_1.x+10,frame_1.w-25>,<frame_1.y+16,15>,0xffffff
  472.         mcall   SF_DRAW_RECT,<frame_2.x+10,frame_2.w-25>,<frame_2.y+16,15>,0xffffff
  473. ; draw for PathShow
  474.         push    dword PathShow_data_1
  475.         call    [PathShow_draw]
  476.        
  477.         push    dword PathShow_data_2
  478.         call    [PathShow_draw]
  479.         popa
  480.         ret
  481. ;---------------------------------------------------------------------
  482. ;   *********************************************
  483. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  484. ;   *********************************************
  485. draw_window:
  486.         mcall   SF_REDRAW,SSF_BEGIN_DRAW
  487.         mcall   SF_STYLE_SETTINGS,SSF_GET_COLORS,app_colours,10*4
  488.         mcall   SF_GET_SCREEN_SIZE
  489.         mcall   SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
  490.         mov     [current_skin_high],eax
  491. ; DRAW WINDOW
  492.         xor     eax,eax         ; function 0 : define and draw window
  493.         xor     esi,esi
  494.         mov     edx,[w_work]    ; color of work area RRGGBB,8->color
  495.         or      edx,0x34000000
  496.         mov     ecx,50 shl 16 + win.h
  497.         add     ecx,[current_skin_high]
  498.         mcall   ,<110, win.w>,,,,title
  499.  
  500.         mcall   SF_THREAD_INFO,procinfo,-1
  501.        
  502.         mov     eax,[procinfo+70] ;status of window
  503.         test    eax,100b
  504.         jne     .end
  505.  
  506. ;if lang eq ru
  507.   load_w  = (5*2+6*9)
  508.   save_w  = (5*2+6*9)
  509.   flat_w  = (5*2+6*7)
  510.   apply_w = (5*2+6*9)
  511. ;else
  512. ;  load_w  = (5*2+6*6)
  513. ;  save_w  = (5*2+6*8)
  514. ;  flat_w  = (5*2+6*4)
  515. ;  apply_w = (5*2+6*7)
  516. ;end if
  517. ;-----------------------------------
  518. ; select color DTP frame
  519. ; LOAD BUTTON   ; button 12
  520.         mcall   SF_DEFINE_BUTTON,<frame_1.x+10,load_w>,<frame_1.y+38,18>,12,[w_work_button]
  521. ; SAVE BUTTON
  522.         add     ebx,(load_w+2)*65536-load_w+save_w
  523.         inc     edx
  524.         mcall           ; button 13
  525. ; APPLY BUTTON
  526.         mov     ebx,(frame_1.x + frame_1.w - apply_w - 15)*65536+apply_w
  527.         mcall   SF_DEFINE_BUTTON,,,16   ; button 17
  528. ; select color DTP button text
  529.         mcall   SF_DRAW_TEXT,<frame_1.x+16,frame_1.y+44>,[w_work_button_text],t1,t1.size
  530. ;-----------------------------------   
  531. ; select skin frame    
  532. ; LOAD SKIN BUTTON      ; button 17
  533.         mcall   SF_DEFINE_BUTTON,<frame_2.x+10,load_w>,<frame_2.y+38,18>,17,[w_work_button]
  534. ; 3D
  535.         mov     ebx,(frame_2.x+155)*65536+34
  536.         mcall   ,,,14   ; button 14
  537. ; FLAT
  538.         add     ebx,36*65536-34+flat_w
  539.         inc     edx
  540.         mcall           ; button 15
  541. ; APPLY SKIN BUTTON
  542.         mov     ebx,(frame_2.x + frame_2.w - apply_w -15)*65536+apply_w
  543.         mcall   ,,,18           ; button 18
  544. ; select skin button text
  545.         mcall   SF_DRAW_TEXT,<frame_2.x+16,frame_2.y+44>,[w_work_button_text],t2,t2.size
  546. ;-----------------------------------           
  547.         call    draw_button_row
  548.         call    draw_button_row_of_texts
  549.         call    draw_colours
  550. ;-----------------------------------
  551.         mov     [frame_data.x],dword frame_1.x shl 16+frame_1.w
  552.         mov     [frame_data.y],dword frame_1.y shl 16+frame_1.height
  553.         mov     [frame_data.text_pointer],dword select_dtp_text
  554.         mov     eax,[w_work]
  555.         mov     [frame_data.font_backgr_color],eax
  556.         mov     eax,[w_work_text]
  557.         mov     [frame_data.font_color],eax
  558.         mov     [frame_data.draw_text_flag],dword 1
  559.        
  560.         push    dword frame_data
  561.         call    [Frame_draw]
  562. ;-----------------------------------
  563.         mov     [frame_data.x],dword frame_2.x shl 16+frame_2.w
  564.         mov     [frame_data.y],dword frame_2.y shl 16+frame_2.height
  565.         mov     [frame_data.text_pointer],dword select_skin_text
  566.  
  567.         push    dword frame_data
  568.         call    [Frame_draw]
  569. ;-----------------------------------
  570.         call    draw_PathShow
  571. ;-----------------------------------
  572.         cmp     dword[not_packed_area+SKIN_HEADER.ident],'SKIN'
  573.         jne     @f
  574.         call    draw_skin
  575. @@:
  576. .end:
  577.         mcall   SF_REDRAW,SSF_END_DRAW
  578.         ret
  579. ;-----------------------------------------------------------------------------
  580. include 'drawskin.inc'
  581. ;-----------------------------------------------------------------------------
  582. ; DATA AREA
  583. ;-----------------------------------------------------------------------------
  584. include 'idata.inc'
  585. ;-----------------------------------------------------------------------------
  586. IM_END:
  587. ;-----------------------------------------------------------------------------
  588. include 'udata.inc'
  589. ;-----------------------------------------------------------------------------
  590. I_END:
  591. ;-----------------------------------------------------------------------------