Subversion Repositories Kolibri OS

Rev

Rev 9602 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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