Subversion Repositories Kolibri OS

Rev

Rev 7252 | Rev 7349 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //11.03.12 - start!
  2. //ver 2.0
  3.  
  4. #ifndef AUTOBUILD
  5.         ?include "lang.h--"
  6. #endif
  7.  
  8. #define MEMSIZE 0xFE800
  9. #include "..\lib\mem.h"
  10. #include "..\lib\strings.h"
  11. #include "..\lib\io.h"
  12. #include "..\lib\list_box.h"
  13. #include "..\lib\menu.h"
  14. #include "..\lib\gui.h"
  15. #include "..\lib\obj\box_lib.h"
  16. #include "..\lib\patterns\select_list.h"
  17.  
  18.  
  19. //===================================================//
  20. //                                                   //
  21. //                       DATA                        //
  22. //                                                   //
  23. //===================================================//
  24.  
  25. #ifdef LANG_RUS
  26.         ?define WINDOW_HEADER " áâனª¨ ®ä®à¬«¥­¨ï"
  27.         ?define T_SKINS       "‘â¨«ì ®ª®­"
  28.         ?define T_WALLPAPERS  "Ž¡®¨"
  29. #else
  30.         ?define WINDOW_HEADER "Appearance"
  31.         ?define T_SKINS       "Skins"
  32.         ?define T_WALLPAPERS  "Wallpappers"
  33. #endif
  34.  
  35. #define PANEL_H 40
  36. #define LP 10 //LIST_PADDING
  37. #define SKINS_STANDART_PATH "/kolibrios/res/skins"                                                     
  38. #define WALP_STANDART_PATH "/kolibrios/res/wallpapers"
  39.  
  40. signed int active_skin=-1, active_wallpaper=-1;
  41. enum { SKINS=2, WALLPAPERS };
  42.  
  43. char folder_path[4096];
  44. char cur_file_path[4096];
  45. char temp_filename[4096];
  46. int files_mas[400];
  47.  
  48. int cur;
  49.  
  50. proc_info Form;
  51. block skp;
  52.  
  53. _tabs tabs = { LP, LP, NULL, NULL, SKINS };
  54.  
  55. checkbox checkbox1 = { "Checkbox", true };
  56. more_less_box spinbox1 = { 23, 0, 999, "SpinBox" };
  57. edit_box edit_cmm = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
  58.         0x10000000,sizeof(param),#param,0, 0b};
  59.  
  60. char st_str[16];
  61. edit_box edit_st = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
  62.         0x10000000,sizeof(st_str),#st_str,0, 0b};
  63.  
  64.  
  65. #define MENU_LIST "Open file     Enter\nDelete          Del"
  66.  
  67. //===================================================//
  68. //                                                   //
  69. //                       CODE                        //
  70. //                                                   //
  71. //===================================================//
  72.  
  73. void main()
  74. {  
  75.         int id, mouse_clicked;
  76.  
  77.         SetEventMask(0x27);
  78.         load_dll(boxlib, #box_lib_init,0);
  79.         EventTabClick(SKINS);
  80.         loop() switch(WaitEvent())
  81.         {
  82.                 case evMouse:
  83.                         if (!CheckActiveProcess(Form.ID)) break;
  84.                         SelectList_ProcessMouse();
  85.                         edit_box_mouse stdcall (#edit_cmm);
  86.                         edit_box_mouse stdcall (#edit_st);
  87.  
  88.                         if (mouse.pkm)&&(select_list.MouseOver(mouse.x, mouse.y)) {
  89.                                 select_list.ProcessMouse(mouse.x, mouse.y);
  90.                                 SelectList_Draw();
  91.                                 menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 185, MENU_LIST, 10);
  92.                         }
  93.                         break;
  94.  
  95.                 case evButton:
  96.                         id=GetButtonID();
  97.                         if (id==1) ExitProcess();
  98.                         if (id==SKINS) EventTabClick(SKINS);
  99.                         if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
  100.                         checkbox1.click(id);
  101.                         spinbox1.click(id);
  102.                         break;
  103.          
  104.                 case evKey:
  105.                         GetKeys();
  106.                         if (select_list.ProcessKey(key_scancode)) EventApply();
  107.                         if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
  108.                         if (key_scancode==SCAN_CODE_TAB)
  109.                                 if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS);
  110.                                 else EventTabClick(SKINS);
  111.                         if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
  112.                         for (id=select_list.cur_y+1; id<select_list.count; id++)
  113.                         {
  114.                                 strcpy(#temp_filename, io.dir.position(files_mas[id]));
  115.                                 if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32)
  116.                                 {
  117.                                         select_list.cur_y = id - 1;
  118.                                         select_list.KeyDown();
  119.                                         EventApply();
  120.                                         break;
  121.                                 }
  122.                         }
  123.                         EAX= key_ascii << 8;
  124.                         edit_box_key stdcall (#edit_cmm);
  125.                         edit_box_key stdcall (#edit_st);
  126.                         break;
  127.                  
  128.                  case evReDraw:
  129.                         system.color.get();                    
  130.                         DefineAndDrawWindow(screen.width-600/2,80,630,404+skin_height,0x74,0xE4DFE1,WINDOW_HEADER,0);
  131.                         GetProcessInfo(#Form, SelfInfo);
  132.                         IF (Form.status_window>=2) break;
  133.                         DrawWindowContent();
  134.                         if (menu.list.cur_y) {
  135.                                 if (menu.list.cur_y == 10) EventOpenFile();
  136.                                 if (menu.list.cur_y == 11) EventDeleteFile();
  137.                                 menu.list.cur_y = 0;
  138.                         };
  139.    }
  140. }
  141.  
  142.  
  143. void DrawWindowContent()
  144. {
  145.         int id;
  146.         incn y;
  147.  
  148.         DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work);
  149.  
  150.         tabs.w = Form.cwidth-LP-LP;
  151.         tabs.h = Form.cheight-LP-LP;
  152.         tabs.draw_wrapper();
  153.        
  154.         tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS);  
  155.         tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS);
  156.  
  157.         id = select_list.cur_y;
  158.         SelectList_Init(
  159.                 tabs.x+TAB_PADDING,
  160.                 tabs.y+TAB_HEIGHT+TAB_PADDING,
  161.                 250,
  162.                 tabs.h - TAB_PADDING - TAB_PADDING - TAB_HEIGHT,
  163.                 false
  164.                 );
  165.         select_list.cur_y = id;
  166.  
  167.         skp.set_size(
  168.                 select_list.x + select_list.w + TAB_PADDING + scroll1.size_x + 20,
  169.                 select_list.y + 30,
  170.                 250,
  171.                 select_list.h - 50
  172.         );
  173.  
  174.         SelectList_Draw();
  175.         SelectList_DrawBorder();
  176.  
  177.         if (tabs.active_tab == SKINS)
  178.         {
  179.                 DrawBar(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work);
  180.                 DrawRectangle(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work_graph);
  181.                 y.n = skp.y;
  182.                 DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview ");
  183.                 checkbox1.draw(skp.x+20, y.inc(30));
  184.                 spinbox1.draw(skp.x+20, y.inc(30));
  185.                 WriteText(skp.x+20, y.inc(30), 0x90, system.color.work_text, "C-- Edit");
  186.                 DrawEditBoxPos(skp.x+20, y.inc(20), #edit_cmm);
  187.                 WriteText(skp.x+20, y.inc(35), 0x90, system.color.work_text, "Strandard Edit");
  188.                 DrawStEditBoxPos(skp.x+20, y.inc(20), #edit_st);
  189.                 DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Button1");
  190.                 DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Button2");
  191.         }
  192. }
  193.  
  194. :void DrawStEditBoxPos(dword x,y, edit_box_pointer)
  195. {
  196.         dword c_inactive = MixColors(system.color.work_graph, system.color.work, 128);
  197.         dword c_active = MixColors(system.color.work_graph, 0, 128);
  198.         ESI = edit_box_pointer;
  199.         ESI.edit_box.left = x;
  200.         ESI.edit_box.top = y;
  201.         ESI.edit_box.blur_border_color = c_inactive;
  202.         ESI.edit_box.focus_border_color = c_active;
  203.         edit_box_draw  stdcall (edit_box_pointer);
  204. }
  205.  
  206.  
  207.  
  208. void Open_Dir()
  209. {
  210.         int j;
  211.         select_list.count = 0;
  212.         if(io.dir.buffer)free(io.dir.buffer);
  213.         io.dir.load(#folder_path,DIR_ONLYREAL);
  214.         for (j=0; j<io.dir.count; j++)
  215.         {
  216.                 strcpy(#temp_filename, io.dir.position(j));
  217.                 strlwr(#temp_filename);
  218.                 if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
  219.                 if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
  220.                 cur = select_list.count;
  221.                 files_mas[cur]=j;
  222.                 if (!strcmpi("default.skn",#temp_filename)) files_mas[0]><files_mas[select_list.count];
  223.                 select_list.count++;
  224.         }
  225. }
  226.  
  227. void SelectList_DrawLine(dword i)
  228. {
  229.         int yyy, list_last;
  230.  
  231.         cur = select_list.first + i;
  232.         strcpy(#temp_filename, io.dir.position(files_mas[cur]));
  233.         temp_filename[strlen(#temp_filename)-4] = 0;
  234.         yyy = i*select_list.item_h+select_list.y;
  235.        
  236.         if (select_list.cur_y-select_list.first==i)
  237.         {
  238.                 DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
  239.                 WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, #temp_filename);
  240.         }
  241.         else
  242.         {
  243.                 DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
  244.                 WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename);
  245.         }
  246. }
  247.  
  248. void SelectList_LineChanged()
  249. {
  250.         EventApply();
  251. }
  252.  
  253. //===================================================//
  254. //                                                   //
  255. //                     EVENTS                        //
  256. //                                                   //
  257. //===================================================//
  258.  
  259. void EventTabClick(int N)
  260. {
  261.         tabs.click(N);
  262.         if (tabs.active_tab == SKINS)
  263.         {
  264.                 active_wallpaper = select_list.cur_y;
  265.                 strcpy(#folder_path, SKINS_STANDART_PATH);
  266.                 select_list.ClearList();
  267.                 Open_Dir();
  268.                 if (!select_list.count) notify("'No skins were found' -E");
  269.                 select_list.cur_y = active_skin;
  270.         }
  271.         if (tabs.active_tab == WALLPAPERS)
  272.         {
  273.                 active_skin = select_list.cur_y;
  274.                 strcpy(#folder_path, WALP_STANDART_PATH);
  275.                 select_list.ClearList();
  276.                 Open_Dir();
  277.                 if (!select_list.count) notify("'No wallpapers were found' -E");
  278.                 select_list.cur_y = active_wallpaper;
  279.         }
  280.         if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey();
  281.         if (select_list.w) DrawWindowContent();
  282. }
  283.  
  284. void EventDeleteFile()
  285. {
  286.         io.del(#cur_file_path);
  287.         Open_Dir();
  288.         EventApply();
  289. }
  290.  
  291. void EventApply()
  292. {
  293.         if (tabs.active_tab==SKINS)
  294.         {
  295.                 cur = select_list.cur_y;
  296.                 sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur]));
  297.                 SetSystemSkin(#cur_file_path);
  298.         }
  299.         if (tabs.active_tab==WALLPAPERS)
  300.         {
  301.                 cur = select_list.cur_y;
  302.                 sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur]));
  303.                 RunProgram("/sys/media/kiv", #cur_file_path);
  304.                 SelectList_Draw();
  305.         }
  306. }
  307.  
  308. void EventOpenFile()
  309. {
  310.         if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path);
  311.         if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
  312. }
  313.  
  314. stop:
  315.