Subversion Repositories Kolibri OS

Rev

Rev 6271 | Rev 6653 | 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 LIST_PADDING 20
  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. //===================================================//
  53. //                                                   //
  54. //                       CODE                        //
  55. //                                                   //
  56. //===================================================//
  57.  
  58. void main()
  59. {  
  60.         int id, mouse_clicked;
  61.  
  62.         SetEventMask(0x27);
  63.         load_dll(boxlib, #box_lib_init,0);
  64.         EventTabClick(SKINS);
  65.         loop() switch(WaitEvent())
  66.         {
  67.                 case evMouse:
  68.                         if (!CheckActiveProcess(Form.ID)) break;
  69.                         mouse.get();
  70.                         scrollbar_v_mouse (#scroll1);
  71.                         if (select_list.first != scroll1.position)
  72.                         {
  73.                                 select_list.first = scroll1.position;
  74.                                 DrawSelectList(select_list.count);
  75.                                 break;
  76.                         }
  77.  
  78.                         if (mouse.vert) && (select_list.MouseScroll(mouse.vert)) DrawSelectList(select_list.count);
  79.  
  80.                         if (mouse.up)&&(mouse_clicked)
  81.                         {
  82.                                 if (mouse.lkm) && (select_list.ProcessMouse(mouse.x, mouse.y)) EventApply();
  83.                                 mouse_clicked=false;
  84.                         }
  85.                         else if (mouse.down)&&(mouse.lkm) && (select_list.MouseOver(mouse.x, mouse.y)) mouse_clicked=true;
  86.  
  87.                         if (mouse.down)&&(mouse.pkm) {
  88.                                 select_list.ProcessMouse(mouse.x, mouse.y);
  89.                                 DrawSelectList(select_list.count);
  90.                                 menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 136, "Open file     Enter\nDelete          Del", 10);
  91.                         }
  92.  
  93.                         break;
  94.  
  95.  
  96.                 case evButton:
  97.                         id=GetButtonID();
  98.                         if (id==1) ExitProcess();
  99.                         if (id==SKINS) EventTabClick(SKINS);
  100.                         if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
  101.                         break;
  102.          
  103.                 case evKey:
  104.                         GetKeys();
  105.                         if (select_list.ProcessKey(key_scancode)) EventApply();
  106.                         if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
  107.                         if (key_scancode==SCAN_CODE_TAB) if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS);
  108.                         if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
  109.                         for (id=select_list.cur_y+1; id<select_list.count; id++)
  110.                         {
  111.                                 strcpy(#temp_filename, io.dir.position(files_mas[id]));
  112.                                 if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32)
  113.                                 {
  114.                                         select_list.cur_y = id - 1;
  115.                                         select_list.KeyDown();
  116.                                         EventApply();
  117.                                         break;
  118.                                 }
  119.                         }
  120.                         break;
  121.                  
  122.                  case evReDraw:
  123.                         system.color.get();                    
  124.                         DefineAndDrawWindow(screen.width-400/2,80,400,404+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0);
  125.                         GetProcessInfo(#Form, SelfInfo);
  126.                         IF (Form.status_window>=2) break;
  127.                         DrawWindowContent();
  128.                         if (menu.list.cur_y) {
  129.                                 if (menu.list.cur_y == 10) EventOpenFile();
  130.                                 if (menu.list.cur_y == 11) EventDeleteFile();
  131.                                 menu.list.cur_y = 0;
  132.                         };
  133.    }
  134. }
  135.  
  136. void DrawWindowContent()
  137. {
  138.         int id;
  139.         id = select_list.cur_y;
  140.         InitSelectList(LIST_PADDING, PANEL_H, Form.cwidth-scroll1.size_x-LIST_PADDING-LIST_PADDING, Form.cheight-PANEL_H-LIST_PADDING, false);
  141.         select_list.cur_y = id;
  142.  
  143.         DrawBar(0,0, Form.cwidth, PANEL_H-LIST_PADDING, system.color.work);
  144.         DrawRectangle3D(select_list.x-2, select_list.y-2, select_list.w+3+scroll1.size_x, select_list.h+3, system.color.work_dark, system.color.work_light);
  145.         DrawWideRectangle(select_list.x-LIST_PADDING, select_list.y-LIST_PADDING, LIST_PADDING*2+select_list.w+scroll1.size_x, LIST_PADDING*2+select_list.h, LIST_PADDING-2, system.color.work);
  146.         tabs.draw(select_list.x+10, select_list.y, SKINS, T_SKINS);
  147.         if (dir_exists(WALP_STANDART_PATH)) tabs.draw(strlen(T_SKINS)*8+TAB_PADDING+select_list.x+21, select_list.y, WALLPAPERS, T_WALLPAPERS);
  148.         DrawRectangle(select_list.x-1, select_list.y-1, select_list.w+1+scroll1.size_x, select_list.h+1, system.color.work_graph);
  149.  
  150.         DrawSelectList(select_list.count);
  151. }
  152.  
  153.  
  154.  
  155. void Open_Dir()
  156. {
  157.         int j;
  158.         select_list.count = 0;
  159.         if(io.dir.buffer)free(io.dir.buffer);
  160.         io.dir.load(#folder_path,DIR_ONLYREAL);
  161.         for (j=0; j<io.dir.count; j++)
  162.         {
  163.                 strcpy(#temp_filename, io.dir.position(j));
  164.                 strlwr(#temp_filename);
  165.                 if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
  166.                 if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
  167.                 cur = select_list.count;
  168.                 files_mas[cur]=j;
  169.                 if (!strcmpi("default.skn",#temp_filename)) files_mas[0]><files_mas[select_list.count];
  170.                 select_list.count++;
  171.         }
  172. }
  173.  
  174. void DrawSelectList_Line(dword i)
  175. {
  176.         int yyy, list_last;
  177.  
  178.         cur = select_list.first + i;
  179.         strcpy(#temp_filename, io.dir.position(files_mas[cur]));
  180.         temp_filename[strlen(#temp_filename)-4] = 0;
  181.         yyy = i*select_list.item_h+select_list.y;
  182.        
  183.         if (select_list.cur_y-select_list.first==i)
  184.         {
  185.                 DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
  186.                 WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, #temp_filename);
  187.         }
  188.         else
  189.         {
  190.                 DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
  191.                 WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename);
  192.         }
  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.                 DrawSelectList(select_list.count);
  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.