Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. #ifdef LANG_RUS
  3.         ?define TITLE_SETT " áâனª¨"
  4.         ?define SHOW_DEVICE_CLASS "‚뢮¤¨âì ­ §¢ ­¨ï ª« áá  ãáâனáâ¢"
  5.         ?define SHOW_STATUS_BAR "®ª §ë¢ âì áâ âãá ¡ à"
  6.         ?define NOTIFY_COPY_END "“¢¥¤®¬«ïâì ® § ¢¥à襭¨¨ ª®¯¨à®¢ ­¨ï"
  7.         ?define SHOW_BREADCRUMBS "ˆá¯®«ì§®¢ âì 'å«¥¡­ë¥ ªà®èª¨'"
  8.         ?define BIG_ICONS "ˆá¯®«ì§®¢ âì ¡®«ì訥 ¨ª®­ª¨"
  9.         ?define USE_TWO_PANELS "„¢¥ ¯ ­¥«¨"
  10.         ?define COLORED_LINES "®¤á¢¥ç¨¢ âì ç¥â­ë¥ «¨­¨¨ ¢ ᯨ᪥"
  11.         ?define FONT_SIZE_LABEL " §¬¥à èà¨äâ "
  12.         ?define LIST_LINE_HEIGHT "‚ëá®â  áâப¨ ¢ ᯨ᪥"
  13.         ?define SAVE_PATH_AS_DEFAULT "’¥ªã騩 ¯ãâì"
  14.         ?define SAVE_START_PATH_AS_DEFAULT "‚¢¥¤¥­­ë© ¯ãâì"
  15.         ?define EDIT_FILE_ASSOCIATIONS "¥¤ ªâ¨à®¢ âì  áá®æ¨ æ¨¨ ä ©«®¢"
  16.         ?define START_PATH " ‘â àâ®¢ë© ¯ãâì: "
  17. #else
  18.         ?define TITLE_SETT "Settings"
  19.         ?define SHOW_DEVICE_CLASS "Show device class name"
  20.         ?define SHOW_STATUS_BAR "Show status bar"
  21.         ?define NOTIFY_COPY_END "Notify when copying finished"
  22.         ?define SHOW_BREADCRUMBS "Show breadcrumbs"
  23.         ?define BIG_ICONS "Big icons in list"
  24.         ?define USE_TWO_PANELS "Two panels"
  25.         ?define COLORED_LINES "Highlight even lines in list"
  26.         ?define FONT_SIZE_LABEL "Font size"
  27.         ?define LIST_LINE_HEIGHT "List line height"
  28.         ?define SAVE_PATH_AS_DEFAULT "Current path"
  29.         ?define SAVE_START_PATH_AS_DEFAULT "Typed path"
  30.         ?define EDIT_FILE_ASSOCIATIONS "Edit file associations"
  31.         ?define START_PATH " Start path: "
  32. #endif
  33.  
  34. char path_start[4096];
  35. edit_box path_start_ed = {290,50,57,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,4098,
  36.                               #path_start,0, 100000000000010b,0,0};
  37.  
  38. more_less_box font_size   = { NULL, 9, 22, FONT_SIZE_LABEL };
  39. more_less_box line_height = { NULL, 16, 64, LIST_LINE_HEIGHT };
  40. checkbox show_dev_name    = { SHOW_DEVICE_CLASS };
  41. checkbox show_status_bar  = { SHOW_STATUS_BAR };
  42. checkbox info_after_copy  = { NOTIFY_COPY_END };
  43. checkbox show_breadcrumb  = { SHOW_BREADCRUMBS };
  44. checkbox big_icons        = { BIG_ICONS };
  45. checkbox two_panels       = { USE_TWO_PANELS };
  46. checkbox colored_lines    = { COLORED_LINES };
  47.  
  48.  
  49. void settings_dialog()
  50. {  
  51.         proc_info Settings;
  52.         int id;
  53.         active_settings=1;
  54.         font_size.value = kfont.size.pt;
  55.         line_height.value = files.item_h;
  56.         SetEventMask(0x27);
  57.         loop(){
  58.                 switch(WaitEvent())
  59.                 {
  60.                         case evMouse:
  61.                                 edit_box_mouse stdcall (#path_start_ed);
  62.                                 break;
  63.                                
  64.                         case evButton:
  65.                                 id=GetButtonID();
  66.                                 if (1==id) { ExitSettings(); break; }
  67.                                 else if (id==5)
  68.                                 {
  69.                                         RunProgram("/sys/tinypad", "/sys/settings/assoc.ini");
  70.                                         break;
  71.                                 }
  72.                                 else if (id==6)
  73.                                 {
  74.                                         strcpy(#path_start,#path);
  75.                                         path_start_ed.size = path_start_ed.pos = strlen(#path_start);
  76.                                         ini.SetString("DefaultPath", #path, strlen(#path));
  77.                                         edit_box_draw stdcall (#path_start_ed);
  78.                                         break;
  79.                                 }
  80.                                 else if (id==7)
  81.                                 {
  82.                                         SetDefaultPath(#path_start);
  83.                                         break;
  84.                                 }
  85.                                 show_dev_name.click(id);
  86.                                 info_after_copy.click(id);
  87.                                 two_panels.click(id);
  88.                                 show_breadcrumb.click(id);
  89.                                 show_status_bar.click(id);
  90.                                 colored_lines.click(id);
  91.                                 if (font_size.click(id)) {
  92.                                         kfont.size.pt = font_size.value;
  93.                                         kfont.changeSIZE();
  94.                                         BigFontsChange();
  95.                                 }
  96.                                 if (line_height.click(id)) files.item_h = files_inactive.item_h = line_height.value;
  97.                                 if (big_icons.click(id)) BigIconsSwitch();
  98.                                 EventRedrawWindow(Form.left,Form.top);
  99.                                 //RefreshWindow(Form.slot, Settings.slot);
  100.                                 break;
  101.                                        
  102.                         case evKey:
  103.                                 GetKeys();
  104.                                 if (key_scancode==SCAN_CODE_ESC) ExitSettings();
  105.                                 EAX= key_ascii << 8;
  106.                                 edit_box_key stdcall (#path_start_ed); 
  107.                                 break;
  108.                                
  109.                         case evReDraw:
  110.                                 DefineAndDrawWindow(Form.cwidth-300/2+Form.left, Form.cheight-292/2+Form.top, 400,
  111.                                         435+skin_height,0x34,sc.work,TITLE_SETT,0);
  112.                                 GetProcessInfo(#Settings, SelfInfo);
  113.                                 DrawSettingsCheckBoxes();
  114.                 }
  115.         }
  116. }
  117.  
  118. void ExitSettings()
  119. {
  120.         active_settings = 0;
  121.         settings_window = 0;
  122.         cmd_free = 4;
  123.         ExitProcess();
  124. }
  125.  
  126. void DrawSettingsCheckBoxes()
  127. {
  128.         incn y;
  129.         int x=11, frx=26, but_x;
  130.         y.n = 0;
  131.         show_dev_name.draw(x, y.inc(14));
  132.         show_status_bar.draw(x, y.inc(25));
  133.         info_after_copy.draw(x, y.inc(25));
  134.         show_breadcrumb.draw(x, y.inc(25));
  135.         big_icons.draw(x, y.inc(25));
  136.         two_panels.draw(x, y.inc(25));
  137.         colored_lines.draw(x, y.inc(25));
  138.         font_size.draw(x, y.inc(31));
  139.         line_height.draw(x, y.inc(31));
  140.        
  141.         DrawFrame(x, y.inc(37), 340, 95, START_PATH);
  142.         // START_PATH {
  143.         DrawEditBoxPos(frx, y.inc(21), #path_start_ed);
  144.         but_x = DrawStandartCaptButton(frx, y.inc(34), 6, SAVE_PATH_AS_DEFAULT);
  145.         DrawStandartCaptButton(frx+but_x, y.inc(0), 7, SAVE_START_PATH_AS_DEFAULT);
  146.         // } START_PATH
  147.  
  148.         DrawStandartCaptButton(x, y.inc(52), 5, EDIT_FILE_ASSOCIATIONS);
  149. }
  150.  
  151.  
  152. void LoadIniSettings()
  153. {
  154.         ini.path = GetIni(#eolite_ini_path, "app.ini");
  155.         ini.section = "Eolite";
  156.  
  157.         files.SetFont(6, 9, 10000000b);
  158.         show_dev_name.checked   = ini.GetInt("ShowDeviceName", true);
  159.         show_status_bar.checked = ini.GetInt("ShowStatusBar", true);
  160.         info_after_copy.checked = ini.GetInt("InfoAfterCopy", false);
  161.         big_icons.checked       = ini.GetInt("BigIcons", false); BigIconsSwitch();
  162.         two_panels.checked      = ini.GetInt("TwoPanels", false);
  163.         colored_lines.checked   = ini.GetInt("ColoredLines", false);
  164.         kfont.size.pt   = ini.GetInt("FontSize", 13);
  165.         files.item_h    = ini.GetInt("LineHeight", 19);
  166.         Form.left   = ini.GetInt("WinX", 200);
  167.         Form.top    = ini.GetInt("WinY", 50);
  168.         Form.width  = ini.GetInt("WinW", 550);
  169.         Form.height = ini.GetInt("WinH", 506);
  170.         ini.GetString("DefaultPath", #path, 4096, "/rd/1");
  171.         ini.GetString("DefaultPath", #path_start, 4096, "/rd/1");
  172.         path_start_ed.size = path_start_ed.pos = strlen(#path_start);
  173.  
  174.         ini_get_str stdcall ("/sys/SETTINGS/SYSTEM.INI", "system", "font file",#temp,4096,DEFAULT_FONT);
  175.         kfont.init(#temp);
  176.         ini_get_str stdcall ("/sys/SETTINGS/SYSTEM.INI", "system", "font smoothing",#temp,4096,"on");
  177.         if(!strcmp(#temp,"off")) kfont.smooth = false; else kfont.smooth = true;
  178. }
  179.  
  180.  
  181. void SaveIniSettings()
  182. {
  183.         ini.SetInt("ShowDeviceName", show_dev_name.checked);
  184.         ini.SetInt("ShowStatusBar", show_status_bar.checked);
  185.         ini.SetInt("InfoAfterCopy", info_after_copy.checked);
  186.         ini.SetInt("BigIcons", big_icons.checked);
  187.         ini.SetInt("TwoPanels", two_panels.checked);
  188.         ini.SetInt("ColoredLines", colored_lines.checked);
  189.         ini.SetInt("FontSize", kfont.size.pt);
  190.         ini.SetInt("LineHeight", files.item_h);
  191.         ini.SetInt("WinX", Form.left);
  192.         ini.SetInt("WinY", Form.top);
  193.         ini.SetInt("WinW", Form.width);
  194.         ini.SetInt("WinH", Form.height);
  195. }
  196.  
  197.  
  198.  
  199. void Write_Error(int error_number)
  200. {
  201.         char error_message[500];
  202.         sprintf(#error_message,"\"%s\n%s\" -%s","Eolite",get_error(error_number),"tE");
  203.         notify(#error_message);
  204. }
  205.  
  206.  
  207. void LoadIcons()
  208. {
  209.         //ICONS16.PNG
  210.         icons16_default.load("/sys/icons16.png");
  211.         icons16_selected.load("/sys/icons16.png");
  212.         icons16_selected.replace_color(0xffFFFfff, col.selec);
  213.         icons16_selected.replace_color(0xffCACBD6, MixColors(col.selec, 0, 200));
  214.         if (col.list_bg!=0xFFFfff) {
  215.                 icons16_default.replace_color(0xffFFFfff, col.list_bg);
  216.                 icons16_default.replace_color(0xffCACBD6, MixColors(col.list_bg, 0, 200));             
  217.         }
  218.         //ICONS32.PNG
  219.         if (big_icons.checked) {
  220.                 icons32_default.load("/sys/icons32.png");
  221.                 icons32_selected.load("/sys/icons32.png");
  222.                 icons32_default.replace_color(0x00000000, col.list_bg);
  223.                 icons32_selected.replace_color(0x00000000, col.selec);         
  224.         }
  225. }
  226.  
  227. void SetAppColors()
  228. {
  229.         int i;
  230.         static dword bg_col;
  231.         dword old_list_bg_color = col.list_bg;
  232.         sc.get();
  233.         sc.work_dark = MixColors(0, sc.work, 35);
  234.         if (sc.work == 0) sc.work = 1;
  235.         if (bg_col == sc.work) return;
  236.         bg_col = sc.work;
  237.         if (skin_is_dark())
  238.         {
  239.                 //use dark colors
  240.                 col.def = false;
  241.                 col.list_bg = sc.work;
  242.                 col.list_gb_text = sc.work_text;
  243.                 col.list_text_hidden = 0xA6A6B7;
  244.                 col.list_vert_line = sc.work_graph;
  245.                 col.lpanel  = MixColors(sc.work_graph, sc.work, 65);
  246.                 col.selec = col.selec_active = sc.button;
  247.                 col.selec_text = sc.button_text;
  248.                 if (col.list_bg==col.selec) col.selec = sc.work_graph; //for fucking skins
  249.                 col.slider_bg_big = MixColors(0xCED0D0, sc.work, 35);
  250.                 col.odd_line = MixColors(0xFFFfff, sc.work, 15);
  251.                 for (i=0; blue_hl_pal[i]!=0; i++) waves_pal[i] = MixColors(col.lpanel, blue_hl_pal[i], 180);
  252.         }
  253.         else
  254.         {
  255.                 //use light colors
  256.                 col.def = true;
  257.                 col.list_bg = 0xFFFfff;
  258.                 col.list_gb_text = 0x000000;
  259.                 col.list_text_hidden = 0xA6A6B7;
  260.                 col.list_vert_line = 0xDDD7CF;
  261.                 col.lpanel  = 0x00699C;
  262.                 col.selec = col.selec_active = 0x94AECE;
  263.                 col.selec_text = 0x000000;
  264.                 col.slider_bg_big = 0xCDCFCF;
  265.                 col.odd_line = 0xF1F1F1;
  266.                 for (i=0; blue_hl_pal[i]!=0; i++) waves_pal[i] = blue_hl_pal[i];
  267.         }
  268.         col.selec_inactive = MixColors(0xBBBbbb, col.list_bg, 65);
  269.         col.slider_bg_left = MixColors(sc.work_graph, col.slider_bg_big, 10);
  270.         for (i=0; i<20; i++) col.work_gradient[i] = MixColors(sc.work_light, sc.work, i*5);
  271.         if (old_list_bg_color!=col.list_bg) LoadIcons();
  272. }
  273.  
  274.  
  275. void BigFontsChange()
  276. {
  277.         files.item_h = kfont.size.pt + 4;
  278.         if (files.item_h<icon_size+3) {
  279.                 files.item_h = icon_size+3;
  280.                 line_height.value = files.item_h;
  281.                 line_height.redraw();
  282.         }
  283.         files_active.item_h = files_inactive.item_h = files.item_h;
  284. }
  285.  
  286. void BigIconsSwitch()
  287. {
  288.         if (big_icons.checked) {
  289.                 icon_size=32;
  290.                 LoadIcons();
  291.         } else {
  292.                 icon_size=16;
  293.         }
  294.         BigFontsChange();
  295. }
  296.  
  297. void SetDefaultPath(dword p)
  298. {
  299.         ini.SetString("DefaultPath", p, strlen(p));
  300.         notify("'Default path has been set' -O");
  301. }