Subversion Repositories Kolibri OS

Rev

Rev 7634 | Rev 7647 | 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,system.color.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.         Libimg_LoadImage(#icons16_default, "/sys/icons16.png");
  211.         Libimg_LoadImage(#icons16_selected, "/sys/icons16.png");
  212.         Libimg_ReplaceColor(icons16_selected.image, icons16_selected.w, icons16_selected.h, 0xffFFFfff, col.selec);
  213.         Libimg_ReplaceColor(icons16_selected.image, icons16_selected.w, icons16_selected.h, 0xffCACBD6, MixColors(col.selec, 0, 200));
  214.         if (col.list_bg!=0xFFFfff) {
  215.                 Libimg_ReplaceColor(icons16_default.image, icons16_selected.w, icons16_selected.h, 0xffFFFfff, col.list_bg);
  216.                 Libimg_ReplaceColor(icons16_default.image, icons16_selected.w, icons16_selected.h, 0xffCACBD6, MixColors(col.list_bg, 0, 200));        
  217.         }
  218.         //ICONS32.PNG
  219.         Libimg_LoadImage(#icons32_default, "/sys/icons32.png");
  220.         Libimg_LoadImage(#icons32_selected, "/sys/icons32.png");
  221.         Libimg_ReplaceColor(icons32_default.image, icons32_selected.w, icons32_selected.h, 0x00000000, col.list_bg);
  222.         Libimg_ReplaceColor(icons32_selected.image, icons32_selected.w, icons32_selected.h, 0x00000000, col.selec);    
  223. }
  224.  
  225. void SetAppColors()
  226. {
  227.         int i;
  228.         dword bg_col, old_list_bg_color;
  229.         system.color.get();
  230.         if (col.work == system.color.work) return;
  231.         old_list_bg_color = col.list_bg;
  232.         bg_col = system.color.work;
  233.         if (GrayScaleImage(#bg_col,1,1)>=65)
  234.         {
  235.                 //use light colors
  236.                 col.list_bg = 0xFFFfff;
  237.                 col.list_gb_text = 0x000000;
  238.                 col.list_text_hidden = 0xA6A6B7;
  239.                 col.list_vert_line = 0xDDD7CF;
  240.                 col.work = system.color.work;
  241.                 col.graph = system.color.work_graph;
  242.                 col.lpanel  = 0x00699C;
  243.                 col.selec = col.selec_active = 0x94AECE;
  244.                 col.selec_text = 0x000000;
  245.                 system.color.work_dark = MixColors(0, system.color.work, 35);
  246.                 col.slider_bg_big = 0xCDCFCF;
  247.                 col.odd_line = 0xF1F1F1;
  248.         }
  249.         else
  250.         {
  251.                 //use dark colors
  252.                 col.list_bg = system.color.work;
  253.                 col.list_gb_text = system.color.work_text;
  254.                 col.list_text_hidden = 0xA6A6B7;
  255.                 col.list_vert_line = system.color.work_graph;
  256.                 col.work = system.color.work;
  257.                 col.graph = system.color.work_graph;
  258.                 col.lpanel  = MixColors(system.color.work_graph, system.color.work, 65);
  259.                 col.selec = col.selec_active = system.color.work_button;
  260.                 col.selec_text = system.color.work_button_text;
  261.                 system.color.work_dark = MixColors(0, system.color.work, 35);
  262.                 if (col.list_bg==col.selec) col.selec = system.color.work_graph; //for fucking skins
  263.                 col.slider_bg_big = MixColors(0xCED0D0, system.color.work, 35);
  264.                 col.odd_line = MixColors(0xFFFfff, system.color.work, 15);
  265.         }
  266.         col.selec_inactive = MixColors(0xBBBbbb, col.list_bg, 65);
  267.         col.slider_bg_left = MixColors(col.graph, col.slider_bg_big, 10);
  268.         for (i=0; i<=20; i++) col.work_gradient[20-i] = MixColors(0, system.color.work, i);
  269.         if (old_list_bg_color!=col.list_bg) LoadIcons();
  270. }
  271.  
  272.  
  273. void BigFontsChange()
  274. {
  275.         files.item_h = kfont.size.pt + 4;
  276.         if (files.item_h<icon_size+3) {
  277.                 files.item_h = icon_size+3;
  278.                 line_height.value = files.item_h;
  279.                 line_height.redraw();
  280.         }
  281.         files_active.item_h = files_inactive.item_h = files.item_h;
  282. }
  283.  
  284. void BigIconsSwitch()
  285. {
  286.         if (big_icons.checked) icon_size=32; else icon_size=16;
  287.         BigFontsChange();
  288. }
  289.  
  290. void SetDefaultPath(dword p)
  291. {
  292.         ini.SetString("DefaultPath", p, strlen(p));
  293.         notify("'Default path has been set' -O");
  294. }