Subversion Repositories Kolibri OS

Rev

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

  1. //11.03.12 - start!
  2.  
  3. #ifndef AUTOBUILD
  4.         ?include "lang.h--"
  5. #endif
  6.  
  7. #define MEMSIZE 0xFE800
  8. #include "..\lib\kolibri.h"
  9. #include "..\lib\mem.h"
  10. #include "..\lib\strings.h"
  11. #include "..\lib\dll.h"
  12. #include "..\lib\file_system.h"
  13. #include "..\lib\list_box.h"
  14. #include "..\lib\figures.h"
  15. #include "..\lib\lib.obj\box_lib.h"
  16.  
  17. #ifdef LANG_RUS
  18.         ?define WINDOW_HEADER "“á¯à ¢«¥­¨¥ ⥬®©"
  19.         ?define T_SKINS       "Žª­ "
  20.         ?define T_WALLPAPERS  "Ž¡®¨ à ¡®ç¥£® á⮫ "
  21. #else
  22.         ?define WINDOW_HEADER "Appearance"
  23.         ?define T_SKINS       "Skins"
  24.         ?define T_WALLPAPERS  "Wallpappers"
  25. #endif
  26.  
  27.  
  28. #define PANEL_H 30
  29. #define SKINS_STANDART_PATH "/sys/skins/"
  30. #define WALP_STANDART_PATH "/sys/wallpapers/"
  31.  
  32. llist list[2];
  33. int active;
  34. enum { SKINS, WALLPAPERS };
  35.  
  36. char folder_path[4096];
  37. char cur_file_path[4096];
  38. char temp_filename[4096];
  39. int files_mas[100];
  40. dword buf;
  41.  
  42. int cur;
  43.  
  44. system_colors sc;
  45. proc_info Form;
  46.  
  47. scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
  48.  
  49. #include "other.h"
  50.  
  51. //icons configurate, delete from list, delete from disk, make default
  52. //remember current
  53.  
  54. void Open_Dir()
  55. {
  56.         int j, filesnum;
  57.  
  58.         list[active].count = 0;
  59.         free(buf);
  60.         if (GetDir(#buf, #filesnum, #folder_path, DIRS_ONLYREAL)!=0) return;
  61.  
  62.         for (j=0; j<filesnum; j++)
  63.         {
  64.                 strlwr(j*304 + buf+72);
  65.                 strcpy(#temp_filename, j*304 + buf+72);
  66.                 if (active==SKINS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
  67.                 if (active==WALLPAPERS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
  68.                 cur = list[active].count;
  69.                 files_mas[cur]=j;
  70.                 if (!strcmp("default.skn",#temp_filename)) files_mas[0]><files_mas[list[active].count];
  71.                 list[active].count++;
  72.         }
  73.         Sort_by_Name(0, list[active].count-1);
  74. }
  75.  
  76. void Draw_List()
  77. {
  78.         int i;
  79.         list[SKINS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
  80.         list[WALLPAPERS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
  81.        
  82.         for (i=0; i<list[active].visible; i++;)
  83.         {
  84.                 cur = list[active].first;
  85.                 strcpy(#temp_filename, files_mas[i+cur]*304 + buf+72);
  86.                
  87.                 if (list[active].current-list[active].first==i)
  88.                 {
  89.                         if (sc.work_button<>sc.work)
  90.                         {
  91.                                 DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.work_button);
  92.                                 WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.work_button_text, #temp_filename);
  93.                         }
  94.                         else
  95.                         {
  96.                                 DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.grab_button);
  97.                                 WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.grab_button_text, #temp_filename);
  98.                         }      
  99.                 }
  100.                 else
  101.                 {
  102.                         DrawBar(0,i*list[active].line_h+list[active].y,list[active].w, list[active].line_h, 0xFFFfff);
  103.                         WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,0, #temp_filename);
  104.                 }
  105.         }
  106.         DrawBar(0,list[active].visible*list[active].line_h+list[active].y, list[active].w, -list[active].visible*list[active].line_h+ list[active].h, 0xFFFfff);
  107.         DrawScroller();
  108. }
  109.  
  110. void GetFiles(int set_active)
  111. {
  112.         active = set_active;
  113.         if (active==SKINS)
  114.         {
  115.                 strcpy(#folder_path, SKINS_STANDART_PATH);
  116.                 Open_Dir();
  117.                 if (!list[active].count) notify("No skins were found");
  118.         }
  119.         if (active==WALLPAPERS)
  120.         {
  121.                 strcpy(#folder_path, WALP_STANDART_PATH);
  122.                 Open_Dir();
  123.                 if (!list[active].count) notify("No wallpapers were found");
  124.         }
  125. }
  126.  
  127. void Apply()
  128. {
  129.         if (active==SKINS)
  130.         {
  131.                 strcpy(#cur_file_path, #folder_path);
  132.                 cur = list[active].current;
  133.                 strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
  134.                 SetSystemSkin(#cur_file_path);
  135.         }
  136.         if (active==WALLPAPERS)
  137.         {
  138.                 strcpy(#cur_file_path, "\\S__");
  139.                 strcat(#cur_file_path, #folder_path);
  140.                 cur = list[active].current;
  141.                 strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
  142.                 RunProgram("/sys/media/kiv", #cur_file_path);
  143.                 Draw_List();
  144.         }
  145. }
  146.  
  147. OpenFile()
  148. {
  149.         if (active==SKINS) RunProgram("/sys/desktop", #cur_file_path);
  150.         if (active==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
  151. }
  152.  
  153.  
  154. void main()
  155. {  
  156.         int id, key, mouse_clicked;
  157.         mouse mm;
  158.  
  159.         mem_Init();
  160.         if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("Fatal Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
  161.         list[SKINS].current = list[WALLPAPERS].current = -1;
  162.         list[SKINS].first = list[WALLPAPERS].first = 0;
  163.         GetFiles(WALLPAPERS);
  164.         list[active].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
  165.         SetEventMask(0x27);
  166.         loop()
  167.         {
  168.           switch(WaitEvent())
  169.           {
  170.                 case evMouse:
  171.                         if (!CheckActiveProcess(Form.ID)) break;
  172.                         scrollbar_v_mouse (#scroll1);
  173.                         if (list[active].first <> scroll1.position)
  174.                         {
  175.                                 list[active].first = scroll1.position;
  176.                                 Draw_List();
  177.                                 break;
  178.                         }
  179.                
  180.                         mm.get();
  181.                         if (mm.vert) && (list[active].MouseScroll(mm.vert)) Draw_List();
  182.                         if (mouse_clicked)
  183.                         {
  184.                                 if (!mm.lkm) && (active==SKINS) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
  185.                                 if (!mm.lkm) && (active==WALLPAPERS) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
  186.                                 mouse_clicked=0;
  187.                         }
  188.                         if (mm.lkm) && (list[SKINS].MouseOver(mm.x, mm.y)) mouse_clicked=1;
  189.                         break;
  190.  
  191.                 case evButton:
  192.                         id=GetButtonID();
  193.                         if (id==1) ExitProcess();
  194.                         if (id==2) TabClick(SKINS);
  195.                         if (id==3) TabClick(WALLPAPERS);
  196.                         break;
  197.          
  198.                 case evKey:
  199.                         key = GetKey();
  200.                         if (active==SKINS) && (list[SKINS].ProcessKey(key)) Apply();
  201.                         if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessKey(key)) Apply();
  202.                         IF (key==013) OpenFile();
  203.                         if (key==9) //Tab
  204.                         {
  205.                                 if (active==SKINS)
  206.                                         TabClick(WALLPAPERS);
  207.                                 else
  208.                                         TabClick(SKINS);
  209.                         }
  210.                         IF (key==182) //Del
  211.                         {
  212.                                 DeleteFile(#cur_file_path);
  213.                                 Open_Dir();
  214.                                 Apply();
  215.                         }
  216.                         break;
  217.                  
  218.                  case evReDraw:
  219.                         sc.get();                      
  220.                         DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER);
  221.                         GetProcessInfo(#Form, SelfInfo);
  222.                         IF (Form.status_window>=2) break;
  223.                         DrawTabs();
  224.                         Draw_List();
  225.           }
  226.    }
  227. }
  228.  
  229.  
  230. void DrawTabs()
  231. {
  232.         dword col_bg, col_text;
  233.         DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work);
  234.  
  235.         if (active==SKINS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;}
  236.         DrawRectangle(10-1,7-1, 65+2, 21+2, sc.work_graph);
  237.         DrawCaptButton(10,7, 65, 21, 2, col_bg, col_text, T_SKINS); //¢®ªà㣠à¨á®¢ âì ¯¬ïâ®ã£
  238.         if (active==WALLPAPERS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;}
  239.         DrawRectangle(90-1,7-1, strlen(T_WALLPAPERS)*6+16+2, 21+2, sc.work_graph);
  240.         DrawCaptButton(90,7, strlen(T_WALLPAPERS)*6+16, 21, 3, col_bg, col_text, T_WALLPAPERS);
  241.  
  242.         DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph);
  243.         DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
  244. }
  245.  
  246. void TabClick(int N)
  247. {
  248.         GetFiles(N);
  249.         DrawTabs();
  250.         Draw_List();
  251. }
  252.  
  253.  
  254. void DrawScroller()
  255. {
  256.         scroll1.bckg_col = 0xBBBbbb;
  257.         scroll1.frnt_col = sc.work;
  258.         scroll1.line_col = sc.work_graph;
  259.  
  260.         scroll1.max_area = list[active].count;
  261.         scroll1.cur_area = list[active].visible;
  262.         scroll1.position = list[active].first;
  263.  
  264.         scroll1.all_redraw=1;
  265.         scroll1.start_x = list[active].x + list[active].w;
  266.         scroll1.start_y = list[active].y-2;
  267.         scroll1.size_y = list[active].h+2;
  268.  
  269.         scrollbar_v_draw(#scroll1);
  270. }
  271.  
  272.  
  273. stop:
  274.