Subversion Repositories Kolibri OS

Rev

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