Subversion Repositories Kolibri OS

Rev

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