Subversion Repositories Kolibri OS

Rev

Rev 8981 | Rev 9439 | Go to most recent revision | 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.                                 EAX= key_ascii << 8;
  71.                                 edit_box_key stdcall (#path_start_ed); 
  72.                                 break;
  73.                                
  74.                         case evReDraw:
  75.                                 DefineAndDrawWindow(Form.cwidth-300/2+Form.left, Form.cheight-292/2+Form.top, 400,
  76.                                         -efm*42+345+skin_height,0x34,sc.work,TITLE_SETT,0);
  77.                                 GetProcessInfo(#Settings, SelfInfo);
  78.                                 DrawSettingsCheckBoxes();
  79.                 }
  80.         }
  81. }
  82.  
  83. void ExitSettings()
  84. {
  85.         active_settings = false;
  86.         settings_window = 0;
  87.         cmd_free = 4;
  88.         ExitProcess();
  89. }
  90.  
  91. void DrawSettingsCheckBoxes()
  92. {
  93.         incn y;
  94.         int but_x;
  95.         #define FRX 26
  96.         #define XXX 11
  97.         y.n = 0;
  98.         if (!efm) {
  99.                 show_dev_name.draw(XXX, y.inc(14));
  100.                 show_status_bar.draw(XXX, y.inc(25));
  101.         }
  102.         big_icons.draw(XXX, y.inc(25));
  103.         colored_lines.draw(XXX, y.inc(25));
  104.         font_size.draw(XXX, y.inc(31));
  105.         line_height.draw(XXX, y.inc(31));
  106.        
  107.         DrawFrame(XXX, y.inc(37), 340, 95, START_PATH);
  108.         // START_PATH {
  109.         DrawEditBoxPos(FRX, y.inc(21), #path_start_ed);
  110.         but_x = DrawStandartCaptButton(FRX, y.inc(34), 6, SAVE_PATH_AS_DEFAULT);
  111.         DrawStandartCaptButton(FRX+but_x, y.inc(0), 7, SAVE_START_PATH_AS_DEFAULT);
  112.         // } START_PATH
  113.  
  114.         DrawStandartCaptButton(XXX, y.inc(52), 5, EDIT_FILE_ASSOCIATIONS);
  115. }
  116.  
  117.  
  118. void LoadIniSettings()
  119. {
  120.         ini.path = GetIni(#eolite_ini_path, "app.ini");
  121.         if (efm) ini.section = "EFM"; else ini.section = "Eolite";
  122.  
  123.         files.SetFont(6, 9, 10000000b);
  124.         show_dev_name.checked   = ini.GetInt("ShowDeviceName", true);
  125.         show_status_bar.checked = ini.GetInt("ShowStatusBar", true);
  126.         big_icons.checked       = ini.GetInt("BigIcons", false); BigIconsSwitch();
  127.         colored_lines.checked   = ini.GetInt("ColoredLines", true);
  128.         kfont.size.pt   = ini.GetInt("FontSize", 13);
  129.         files.item_h    = ini.GetInt("LineHeight", 19);
  130.         Form.left   = ini.GetInt("WinX", 100);
  131.         Form.top    = ini.GetInt("WinY", 30);
  132.         Form.width  = ini.GetInt("WinW", efm*170+550);
  133.         Form.height = ini.GetInt("WinH", efm*100+517);
  134.         ini.GetString("DefaultPath", #path_start, 4096, "/sys");
  135.         path_start_ed.size = path_start_ed.pos = strlen(#path_start);
  136.         kfont.init(DEFAULT_FONT);
  137.         ini_get_str stdcall ("/sys/SETTINGS/SYSTEM.INI", "system", "font smoothing",#temp,4096,"on");
  138.         if(streq(#temp,"off")) kfont.smooth = false; else kfont.smooth = true;
  139. }
  140.  
  141.  
  142. void SaveIniSettings()
  143. {
  144.         ini.SetInt("ShowDeviceName", show_dev_name.checked);
  145.         ini.SetInt("ShowStatusBar", show_status_bar.checked);
  146.         ini.SetInt("BigIcons", big_icons.checked);
  147.         ini.SetInt("ColoredLines", colored_lines.checked);
  148.         ini.SetInt("FontSize", kfont.size.pt);
  149.         ini.SetInt("LineHeight", files.item_h);
  150.         if (Form.status_window<=2) {
  151.                 ini.SetInt("WinX", Form.left);
  152.                 ini.SetInt("WinY", Form.top);
  153.                 ini.SetInt("WinW", Form.width);
  154.                 ini.SetInt("WinH", Form.height);               
  155.         }
  156. }
  157.  
  158.  
  159.  
  160. void Write_Error(int error_number)
  161. {
  162.         char error_message[500];
  163.         sprintf(#error_message,"\"%s\n%s\" -%s","Eolite",get_error(error_number),"tE");
  164.         notify(#error_message);
  165. }
  166.  
  167.  
  168. void LoadIcons()
  169. {
  170.         dword selected_shadow = MixColors(col.selec, 0, 200);
  171.         dword non_white_shadow = MixColors(col.list_bg, 0, 200);
  172.         if (big_icons.checked)
  173.         {
  174.                 icons32_default.load("/sys/icons32.png");
  175.                 icons32_selected.load("/sys/icons32.png");
  176.                 //FUUUUUU... the next ugly code may replace the previous line
  177.                 //we are copying raw data without loading and unpycking PNG
  178.                 //memmov(icons32_selected.imgsrc, icons32_default.imgsrc, icons32_default.h*32*4);
  179.                 //EDI = icons32_selected.image;
  180.                 //ESDWORD[EDI+04] = 32;
  181.                 //ESDWORD[EDI+08] = icons32_default.h;
  182.                 //ESDWORD[EDI+20] = IMAGE_BPP32;
  183.                 //ESDWORD[EDI+24] = icons32_selected.imgsrc;
  184.                 icons32_default.replace_color(0x00000000, col.list_bg);
  185.                 icons32_selected.replace_color(0x00000000, col.selec);
  186.         } else {
  187.                 icons16_default.load("/sys/icons16.png");
  188.                 icons16_selected.load("/sys/icons16.png");
  189.                 icons16_selected.replace_2colors(0xffFFFfff, col.selec, 0xffCACBD6, selected_shadow);
  190.                 if (col.list_bg!=0xFFFfff) {
  191.                         icons16_default.replace_2colors(0xffFFFfff, col.list_bg, 0xffCACBD6, non_white_shadow);
  192.                 }
  193.         }
  194.  
  195. }
  196.  
  197. void SetAppColors()
  198. {
  199.         int i;
  200.         static dword bg_col;
  201.         dword old_list_bg_color = col.list_bg;
  202.         sc.get();
  203.         sc.work_dark = MixColors(0, sc.work, 35);
  204.         if (sc.work == 0) sc.work = 1;
  205.         if (bg_col == sc.work) return;
  206.         bg_col = sc.work;
  207.         if (skin_is_dark())
  208.         {
  209.                 //use dark colors
  210.                 col.skin_is_dark = true;
  211.                 col.list_bg = sc.work;
  212.                 col.list_gb_text = sc.work_text;
  213.                 col.list_text_hidden = 0xA6A6B7;
  214.                 col.list_vert_line = sc.work_graph;
  215.                 col.lpanel  = MixColors(sc.work_graph, sc.work, 65);
  216.                 col.selec = col.selec_active = sc.button;
  217.                 col.selec_text = sc.button_text;
  218.                 if (col.list_bg==col.selec) col.selec = sc.work_graph; //for fucking skins
  219.                 col.slider_bg_big = MixColors(0xCED0D0, sc.work, 35);
  220.                 col.odd_line = MixColors(0xFFFfff, sc.work, 15);
  221.                 for (i=0; blue_hl_pal[i]!=0; i++) waves_pal[i] = MixColors(col.lpanel, blue_hl_pal[i], 180);
  222.         }
  223.         else
  224.         {
  225.                 //use light colors
  226.                 col.skin_is_dark = false;
  227.                 col.list_bg = 0xFFFfff;
  228.                 col.list_gb_text = 0x000000;
  229.                 col.list_text_hidden = 0xA6A6B7;
  230.                 col.list_vert_line = 0xDDD7CF;
  231.                 col.lpanel  = 0x00699C;
  232.                 col.selec = col.selec_active = 0x92B1D9;
  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.work_graph, col.slider_bg_big, 10);
  240.         for (i=0; i<20; i++) col.work_gradient[i] = MixColors(sc.work_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. }