Subversion Repositories Kolibri OS

Rev

Rev 7226 | Rev 7252 | 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.  
  57. #define MENU_LIST "Open file     Enter\nDelete          Del"
  58.  
  59. //===================================================//
  60. //                                                   //
  61. //                       CODE                        //
  62. //                                                   //
  63. //===================================================//
  64.  
  65. void main()
  66. {  
  67.         int id, mouse_clicked;
  68.  
  69.         SetEventMask(0x27);
  70.         load_dll(boxlib, #box_lib_init,0);
  71.         EventTabClick(SKINS);
  72.         loop() switch(WaitEvent())
  73.         {
  74.                 case evMouse:
  75.                         if (!CheckActiveProcess(Form.ID)) break;
  76.                         SelectList_ProcessMouse();
  77.  
  78.                         if (mouse.pkm)&&(select_list.MouseOver(mouse.x, mouse.y)) {
  79.                                 select_list.ProcessMouse(mouse.x, mouse.y);
  80.                                 SelectList_Draw();
  81.                                 menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 185, MENU_LIST, 10);
  82.                         }
  83.                         break;
  84.  
  85.                 case evButton:
  86.                         id=GetButtonID();
  87.                         if (id==1) ExitProcess();
  88.                         if (id==SKINS) EventTabClick(SKINS);
  89.                         if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
  90.                         checkbox1.click(id);
  91.                         break;
  92.          
  93.                 case evKey:
  94.                         GetKeys();
  95.                         if (select_list.ProcessKey(key_scancode)) EventApply();
  96.                         if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
  97.                         if (key_scancode==SCAN_CODE_TAB)
  98.                                 if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS);
  99.                                 else EventTabClick(SKINS);
  100.                         if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
  101.                         for (id=select_list.cur_y+1; id<select_list.count; id++)
  102.                         {
  103.                                 strcpy(#temp_filename, io.dir.position(files_mas[id]));
  104.                                 if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32)
  105.                                 {
  106.                                         select_list.cur_y = id - 1;
  107.                                         select_list.KeyDown();
  108.                                         EventApply();
  109.                                         break;
  110.                                 }
  111.                         }
  112.                         break;
  113.                  
  114.                  case evReDraw:
  115.                         system.color.get();                    
  116.                         DefineAndDrawWindow(screen.width-600/2,80,600,404+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0);
  117.                         GetProcessInfo(#Form, SelfInfo);
  118.                         IF (Form.status_window>=2) break;
  119.                         DrawWindowContent();
  120.                         if (menu.list.cur_y) {
  121.                                 if (menu.list.cur_y == 10) EventOpenFile();
  122.                                 if (menu.list.cur_y == 11) EventDeleteFile();
  123.                                 menu.list.cur_y = 0;
  124.                         };
  125.    }
  126. }
  127.  
  128.  
  129. void DrawWindowContent()
  130. {
  131.         int id;
  132.  
  133.         DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work);
  134.  
  135.         tabs.w = Form.cwidth-LP-LP;
  136.         tabs.h = Form.cheight-LP-LP;
  137.         tabs.draw_wrapper();
  138.        
  139.         tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS);  
  140.         tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS);
  141.  
  142.         id = select_list.cur_y;
  143.         SelectList_Init(
  144.                 tabs.x+TAB_PADDING,
  145.                 tabs.y+TAB_HEIGHT+TAB_PADDING,
  146.                 250,
  147.                 tabs.h - TAB_PADDING - TAB_PADDING - TAB_HEIGHT,
  148.                 false
  149.                 );
  150.         select_list.cur_y = id;
  151.  
  152.         skp.set_size(
  153.                 select_list.x + select_list.w + TAB_PADDING + scroll1.size_x,
  154.                 select_list.y,
  155.                 250,
  156.                 250
  157.         );
  158.  
  159.         SelectList_Draw();
  160.         SelectList_DrawBorder();
  161.  
  162.         if (tabs.active_tab == SKINS)
  163.         {
  164.                 DrawBar(skp.x, skp.y, skp.w, skp.h, system.color.work);
  165.                 DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview ");
  166.                 WriteText(skp.x+20, skp.y+30, 0x90, system.color.work_text, "Lorem ipsum");
  167.                 checkbox1.draw(skp.x+20, skp.y+70);
  168.                 DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Apply");
  169.                 DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Close");
  170.         }
  171. }
  172.  
  173.  
  174.  
  175. void Open_Dir()
  176. {
  177.         int j;
  178.         select_list.count = 0;
  179.         if(io.dir.buffer)free(io.dir.buffer);
  180.         io.dir.load(#folder_path,DIR_ONLYREAL);
  181.         for (j=0; j<io.dir.count; j++)
  182.         {
  183.                 strcpy(#temp_filename, io.dir.position(j));
  184.                 strlwr(#temp_filename);
  185.                 if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
  186.                 if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
  187.                 cur = select_list.count;
  188.                 files_mas[cur]=j;
  189.                 if (!strcmpi("default.skn",#temp_filename)) files_mas[0]><files_mas[select_list.count];
  190.                 select_list.count++;
  191.         }
  192. }
  193.  
  194. void SelectList_DrawLine(dword i)
  195. {
  196.         int yyy, list_last;
  197.  
  198.         cur = select_list.first + i;
  199.         strcpy(#temp_filename, io.dir.position(files_mas[cur]));
  200.         temp_filename[strlen(#temp_filename)-4] = 0;
  201.         yyy = i*select_list.item_h+select_list.y;
  202.        
  203.         if (select_list.cur_y-select_list.first==i)
  204.         {
  205.                 DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
  206.                 WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, #temp_filename);
  207.         }
  208.         else
  209.         {
  210.                 DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
  211.                 WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename);
  212.         }
  213. }
  214.  
  215. void SelectList_LineChanged()
  216. {
  217.         EventApply();
  218. }
  219.  
  220. //===================================================//
  221. //                                                   //
  222. //                     EVENTS                        //
  223. //                                                   //
  224. //===================================================//
  225.  
  226. void EventTabClick(int N)
  227. {
  228.         tabs.click(N);
  229.         if (tabs.active_tab == SKINS)
  230.         {
  231.                 active_wallpaper = select_list.cur_y;
  232.                 strcpy(#folder_path, SKINS_STANDART_PATH);
  233.                 select_list.ClearList();
  234.                 Open_Dir();
  235.                 if (!select_list.count) notify("'No skins were found' -E");
  236.                 select_list.cur_y = active_skin;
  237.         }
  238.         if (tabs.active_tab == WALLPAPERS)
  239.         {
  240.                 active_skin = select_list.cur_y;
  241.                 strcpy(#folder_path, WALP_STANDART_PATH);
  242.                 select_list.ClearList();
  243.                 Open_Dir();
  244.                 if (!select_list.count) notify("'No wallpapers were found' -E");
  245.                 select_list.cur_y = active_wallpaper;
  246.         }
  247.         if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey();
  248.         if (select_list.w) DrawWindowContent();
  249. }
  250.  
  251. void EventDeleteFile()
  252. {
  253.         io.del(#cur_file_path);
  254.         Open_Dir();
  255.         EventApply();
  256. }
  257.  
  258. void EventApply()
  259. {
  260.         if (tabs.active_tab==SKINS)
  261.         {
  262.                 cur = select_list.cur_y;
  263.                 sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur]));
  264.                 SetSystemSkin(#cur_file_path);
  265.         }
  266.         if (tabs.active_tab==WALLPAPERS)
  267.         {
  268.                 cur = select_list.cur_y;
  269.                 sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur]));
  270.                 RunProgram("/sys/media/kiv", #cur_file_path);
  271.                 SelectList_Draw();
  272.         }
  273. }
  274.  
  275. void EventOpenFile()
  276. {
  277.         if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path);
  278.         if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
  279. }
  280.  
  281. stop:
  282.