Subversion Repositories Kolibri OS

Rev

Rev 5651 | Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef AUTOBUILD
  2. #include "lang.h--"
  3. #endif
  4.  
  5. #define MEMSIZE 0x23E80
  6. #include "..\lib\kolibri.h"
  7. #include "..\lib\strings.h"
  8. #include "..\lib\mem.h"
  9. #include "..\lib\file_system.h"
  10. #include "..\lib\dll.h"
  11. #include "..\lib\gui.h"
  12.  
  13. #include "..\lib\obj\libio_lib.h"
  14. #include "..\lib\obj\libini.h"
  15. #include "..\lib\obj\box_lib.h"
  16.  
  17. #include "..\lib\patterns\restart_process.h"
  18.  
  19. #ifdef LANG_RUS
  20.         ?define WINDOW_TITLE " áâனª¨ ¯ ­¥«¨ § ¤ ç ¨ „®ª "
  21.     ?define TASK_FRAME_T "  ­¥«ì § ¤ ç "
  22.         ?define DOCK_FRAME_T " „®ª "
  23.         ?define MIN_LEFT_BUTTON "Š­®¯ª  áªàëâ¨ï á«¥¢ "
  24.         ?define MIN_RIGHT_BUTTON "Š­®¯ª  áªàëâ¨ï á¯à ¢ "
  25.         ?define SOFTEN_UP   "‘£« ¦¨¢ ­¨¥ ᢥàåã"
  26.         ?define SOFTEN_DOWN "‘£« ¦¨¢ ­¨¥ á­¨§ã"
  27.         ?define CLOCK    "— áë"
  28.         ?define CPU_USAGE "‡ £à㧪  –"
  29.         ?define CHANGE_LANG "Ÿ§ëª ¢¢®¤ "
  30.         ?define MENU_BUTTON "Š­®¯ª  ¬¥­î"
  31.         ?define PANEL_HEIGHT "‚ëá®â  ¯ ­¥«¨"
  32.         ?define SOFTEN_HEIGHT "‚ëá®â  ᣫ ¦¨¢ ­¨ï"
  33.         ?define BUTTON_OFFSET "®«¥ ¢®ªà㣠ª­®¯®ª"
  34.         ?define FSIZE "¥¦¨¬ ¯ ­¥«¨"
  35.         ?define ASHOW "¥ áªà뢠âì"
  36.         ?define CHANGE_POS " ¦¬¨â¥ ­  ¨§®¡à ¦¥­¨¥ ¤«ï ᬥ­ë ¯®§¨æ¨¨"
  37. #else
  38.         ?define WINDOW_TITLE "Taskbar and Docky configuration"
  39.     ?define TASK_FRAME_T " Taskbar "
  40.         ?define DOCK_FRAME_T " Docky "
  41.         ?define MIN_LEFT_BUTTON "Min Left Button"
  42.         ?define MIN_RIGHT_BUTTON "Min Right Button"
  43.         ?define SOFTEN_UP   "Soften Up"
  44.         ?define SOFTEN_DOWN "Soften Down"
  45.         ?define CLOCK    "Clock"
  46.         ?define CPU_USAGE "Cpu Usage"
  47.         ?define CHANGE_LANG "Change Language"
  48.         ?define MENU_BUTTON "Menu Button"
  49.         ?define PANEL_HEIGHT "Panel Height"
  50.         ?define SOFTEN_HEIGHT "Soften Height"
  51.         ?define BUTTON_OFFSET "Button Offset"
  52.         ?define FSIZE "Full width"
  53.         ?define ASHOW "Always show"
  54.         ?define CHANGE_POS "Click on image to change position"
  55. #endif
  56.  
  57.  
  58. frame taskbar_frame = { 0, 000, 10, 188, 14, 0x000111, 0xFFFfff, 1, TASK_FRAME_T, 0, 0, 6, 0x000111, 0xCCCccc };
  59. frame docky_frame = { 0, 000, 10, 73, 217, 0x000111, 0xFFFfff, 1, DOCK_FRAME_T, 0, 0, 6, 0x000111, 0xCCCccc };
  60.  
  61. char taskbar_ini_path[] = "/sys/settings/taskbar.ini";
  62. char taskbar_c_flags[] = "Flags";
  63. char taskbar_c_variables[] = "Variables";
  64. char docky_ini_path[] = "/sys/settings/docky.ini";
  65.  
  66. unsigned char panels_img_data[] = FROM "panels_image.raw";
  67. raw_image panels_img = { 37, 27, #panels_img_data };
  68.  
  69. proc_info Form;
  70.  
  71. struct docky_cfg {
  72.         word fsize;
  73.         byte location, ashow;
  74. } docky_cfg;
  75.  
  76. struct taskbar_cfg {
  77.         byte Attachment;
  78.         byte PanelHeight, SoftenHeight, ButtonOffset;
  79.         byte SoftenUp, SoftenDown, MinLeftButton, MinRightButton, MenuButton,
  80.              RunApplButton, ClnDeskButton, Clock, CpuUsage, ChangeLang;
  81. } taskbar_cfg;
  82.  
  83. enum {
  84.         TASKBAR,
  85.         DOCKY,
  86.         ALL
  87. };
  88.  
  89.  
  90. void main()
  91. {
  92.         dword id, key;
  93.  
  94.         load_dll(libini, #lib_init,1);
  95.         load_dll(boxlib, #box_lib_init,0);
  96.  
  97.         LoadCfg();
  98.  
  99.         loop() switch(WaitEvent())
  100.         {
  101.                 case evButton:
  102.                                 id=GetButtonID();
  103.                                 if (id==1) ExitProcess();
  104.                                 //taskbar buttons
  105.                                 if (id>=100) && (id<200)
  106.                                 {
  107.                                         if (id==100) taskbar_cfg.Attachment ^= 1;
  108.                                         if (id==105) taskbar_cfg.SoftenUp ^= 1;
  109.                                         if (id==106) taskbar_cfg.SoftenDown ^= 1;
  110.                                         if (id==107) taskbar_cfg.MinLeftButton ^= 1;
  111.                                         if (id==108) taskbar_cfg.MinRightButton ^= 1;
  112.                                         if (id==109) taskbar_cfg.RunApplButton ^= 1;
  113.                                         if (id==110) taskbar_cfg.ClnDeskButton ^= 1;
  114.                                         if (id==111) taskbar_cfg.Clock ^= 1;
  115.                                         if (id==112) taskbar_cfg.CpuUsage ^= 1;
  116.                                         if (id==113) taskbar_cfg.ChangeLang ^= 1;
  117.                                         if (id==114) taskbar_cfg.MenuButton ^= 1;
  118.                                         if (id==120) taskbar_cfg.PanelHeight++;
  119.                                         if (id==121) && (taskbar_cfg.PanelHeight>6) taskbar_cfg.PanelHeight--;
  120.                                         if (id==122) taskbar_cfg.SoftenHeight++;
  121.                                         if (id==123) && (taskbar_cfg.SoftenHeight>0) taskbar_cfg.SoftenHeight--;
  122.                                         if (id==124) taskbar_cfg.ButtonOffset++;
  123.                                         if (id==125) && (taskbar_cfg.ButtonOffset>0) taskbar_cfg.ButtonOffset--;
  124.                                         DrawWindowContent(TASKBAR);
  125.                                         SaveCfg(TASKBAR);
  126.                                         RestartProcess(TASKBAR);
  127.                                 }
  128.                                 //docky buttons                
  129.                                 if (id>=200)
  130.                                 {
  131.                                         if (id==200)
  132.                                         {
  133.                                                      if (docky_cfg.location==1) docky_cfg.location = 2;
  134.                                                 else if (docky_cfg.location==2) docky_cfg.location = 3;
  135.                                                 else if (docky_cfg.location==3) docky_cfg.location = 1;
  136.                                         }
  137.                                         if (id==201) docky_cfg.fsize ^= 1;
  138.                                         if (id==202) docky_cfg.ashow ^= 1;
  139.                                         DrawWindowContent(DOCKY);
  140.                                         SaveCfg(DOCKY);
  141.                                         RestartProcess(DOCKY);
  142.                                 }
  143.                                 break;
  144.                                
  145.                 case evKey:
  146.                                 key = GetKey();
  147.                                 if (key==27) ExitProcess();
  148.                                 break;
  149.                        
  150.                 case evReDraw:
  151.                                 system.color.get();
  152.                                 DefineAndDrawWindow(130, 150, 400, 300+GetSkinHeight(),0x34,system.color.work,WINDOW_TITLE);
  153.                                 GetProcessInfo(#Form, SelfInfo);
  154.                                 if (Form.status_window>2) break;
  155.                                 taskbar_frame.size_x = docky_frame.size_x = - taskbar_frame.start_x * 2 + Form.cwidth;
  156.                                 taskbar_frame.font_color = docky_frame.font_color = system.color.work_text;
  157.                                 taskbar_frame.font_backgr_color = docky_frame.font_backgr_color = system.color.work;
  158.                                 taskbar_frame.ext_col = docky_frame.ext_col = system.color.work_graph;
  159.                                 DrawWindowContent(ALL);
  160.         }
  161. }
  162.  
  163.  
  164. void DrawWindowContent(byte panel_type)
  165. {
  166.         word win_center_x;
  167.  
  168.         if (panel_type==ALL)
  169.         {
  170.                 frame_draw stdcall (#taskbar_frame);
  171.                 frame_draw stdcall (#docky_frame);
  172.         }
  173.         if (panel_type==ALL) || (panel_type==TASKBAR)
  174.         {
  175.                 DefineButton(22, taskbar_frame.start_y + 12, panels_img.w-1, 27-1, 100 + BT_HIDE, 0);
  176.                 _PutImage(22, taskbar_frame.start_y + 12,  37, 27, taskbar_cfg.Attachment * 37 * 27 * 3 + panels_img.data);
  177.                 WriteText(68, taskbar_frame.start_y + 20, 0x80, system.color.work_text, CHANGE_POS);
  178.                 PanelCfg_CheckBox(22, taskbar_frame.start_y +  48, 105, SOFTEN_UP, taskbar_cfg.SoftenUp);
  179.                 PanelCfg_CheckBox(22, taskbar_frame.start_y +  68, 106, SOFTEN_DOWN, taskbar_cfg.SoftenDown);
  180.                 PanelCfg_CheckBox(22, taskbar_frame.start_y +  88, 107, MIN_LEFT_BUTTON, taskbar_cfg.MinLeftButton);
  181.                 PanelCfg_CheckBox(22, taskbar_frame.start_y + 108, 108, MIN_RIGHT_BUTTON, taskbar_cfg.MinRightButton);
  182.                 win_center_x = Form.cwidth / 2;
  183.                 PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y +  48, 111, CLOCK, taskbar_cfg.Clock);
  184.                 PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y +  68, 112, CPU_USAGE, taskbar_cfg.CpuUsage);
  185.                 PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y +  88, 113, CHANGE_LANG, taskbar_cfg.ChangeLang);
  186.                 PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y + 108, 114, MENU_BUTTON, taskbar_cfg.MenuButton);
  187.                 PanelCfg_MoreLessBox(22, taskbar_frame.start_y + 131, 120, 121, taskbar_cfg.PanelHeight, PANEL_HEIGHT);
  188.                 PanelCfg_MoreLessBox(win_center_x, taskbar_frame.start_y + 131, 122, 123, taskbar_cfg.SoftenHeight, SOFTEN_HEIGHT);
  189.                 PanelCfg_MoreLessBox(22, taskbar_frame.start_y + 159, 124, 125, taskbar_cfg.ButtonOffset, BUTTON_OFFSET);
  190.         }
  191.         if (panel_type==ALL) || (panel_type==DOCKY)
  192.         {
  193.                 DefineButton(22, docky_frame.start_y + 12, panels_img.w-1, 27-1, 200 + BT_HIDE, 0);
  194.                 _PutImage(22, docky_frame.start_y + 12,  37, 27, docky_cfg.location + 1 * 37 * 27 * 3 + panels_img.data);
  195.                 WriteText(68, docky_frame.start_y + 20, 0x80, system.color.work_text, CHANGE_POS);
  196.                 PanelCfg_CheckBox(22, docky_frame.start_y + 48, 201, FSIZE,  docky_cfg.fsize);
  197.                 PanelCfg_CheckBox(win_center_x, docky_frame.start_y + 48, 202, ASHOW, docky_cfg.ashow);
  198.         }
  199. }
  200.  
  201. void LoadCfg()
  202. {
  203.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Attachment", 1);     taskbar_cfg.Attachment = EAX;
  204.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenUp", 1);       taskbar_cfg.SoftenUp = EAX;
  205.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenDown", 1);     taskbar_cfg.SoftenDown = EAX;
  206.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinLeftButton", 1);  taskbar_cfg.MinLeftButton = EAX;
  207.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinRightButton", 1); taskbar_cfg.MinRightButton = EAX;
  208.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Clock", 1);          taskbar_cfg.Clock = EAX;
  209.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "CpuUsage", 1);       taskbar_cfg.CpuUsage = EAX;
  210.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "ChangeLang", 1);     taskbar_cfg.ChangeLang = EAX;
  211.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MenuButton", 1);     taskbar_cfg.MenuButton = EAX;
  212.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "PanelHeight", 18);    taskbar_cfg.PanelHeight = EAX;
  213.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "SoftenHeight", 4);    taskbar_cfg.SoftenHeight = EAX;
  214.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonTopOffset", 3); taskbar_cfg.ButtonOffset = EAX;
  215.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonBotOffset", 3); taskbar_cfg.ButtonOffset = EAX;
  216.  
  217.         ini_get_int stdcall (#docky_ini_path, "@", "location", 0);  docky_cfg.location = EAX;
  218.         ini_get_int stdcall (#docky_ini_path, "@", "fsize", 0);     docky_cfg.fsize = EAX;
  219.         ini_get_int stdcall (#docky_ini_path, "@", "ashow", 0);     docky_cfg.ashow = EAX;
  220. }
  221.  
  222. void SaveCfg(byte panel_type)
  223. {
  224.         if (panel_type==TASKBAR) {
  225.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Attachment", taskbar_cfg.Attachment);
  226.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenUp", taskbar_cfg.SoftenUp);
  227.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenDown", taskbar_cfg.SoftenDown);
  228.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinLeftButton", taskbar_cfg.MinLeftButton);
  229.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinRightButton", taskbar_cfg.MinRightButton);
  230.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "RunApplButton", taskbar_cfg.RunApplButton);
  231.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "ClnDeskButton", taskbar_cfg.ClnDeskButton);
  232.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Clock", taskbar_cfg.Clock);
  233.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "CpuUsage", taskbar_cfg.CpuUsage);
  234.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "ChangeLang", taskbar_cfg.ChangeLang);
  235.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MenuButton", taskbar_cfg.MenuButton);
  236.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "PanelHeight", taskbar_cfg.PanelHeight);
  237.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "SoftenHeight", taskbar_cfg.SoftenHeight);
  238.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonTopOffset", taskbar_cfg.ButtonOffset);
  239.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonBottOffset", taskbar_cfg.ButtonOffset);
  240.         }
  241.         if (panel_type==DOCKY) {
  242.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Attachment", taskbar_cfg.Attachment);
  243.                 ini_set_int stdcall (#docky_ini_path, "@", "location", docky_cfg.location);
  244.                 ini_set_int stdcall (#docky_ini_path, "@", "fsize", docky_cfg.fsize);
  245.                 ini_set_int stdcall (#docky_ini_path, "@", "ashow", docky_cfg.ashow);
  246.         }
  247. }
  248.  
  249. void RestartProcess(byte panel_type)
  250. {
  251.         dword proc_name1;
  252.         if (panel_type == TASKBAR)
  253.         {
  254.                 RestartProcessByName("@taskbar", SINGLE);
  255.                 pause(50);
  256.         }
  257.         else
  258.         {
  259.                 RestartProcessByName("@docky", SINGLE);
  260.                 pause(120);
  261.         }
  262.         GetProcessInfo(#Form, SelfInfo);
  263.         ActivateWindow(GetProcessSlot(Form.ID));
  264. }
  265.  
  266.  
  267.  
  268. void PanelCfg_CheckBox(dword x, y, id, text, byte value) {
  269.         CheckBox(x, y, 14, 14, id, text, system.color.work_graph, system.color.work_text, value);
  270. }
  271.  
  272. void PanelCfg_MoreLessBox(dword x, y, id_more, id_less; byte value; dword text) {
  273.         MoreLessBox(x, y, 18, id_more, id_less, #system.color, value, text);
  274. }
  275.  
  276.  
  277. stop: