Subversion Repositories Kolibri OS

Rev

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