Rev 5622 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5504 | punk_joker | 1 | #ifndef AUTOBUILD |
2 | #include "lang.h--" |
||
3 | #endif |
||
5472 | leency | 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" |
||
5499 | leency | 11 | #include "..\lib\gui.h" |
5472 | leency | 12 | |
5499 | leency | 13 | #include "..\lib\obj\libio_lib.h" |
14 | #include "..\lib\obj\libini.h" |
||
15 | #include "..\lib\obj\box_lib.h" |
||
5472 | leency | 16 | |
5548 | leency | 17 | #include "..\lib\patterns\restart_process.h" |
5472 | leency | 18 | |
5504 | punk_joker | 19 | #ifdef LANG_RUS |
5506 | punk_joker | 20 | ?define WINDOW_TITLE "Настройки панели задач и Дока" |
21 | ?define TASK_FRAME_T " Панель задач " |
||
22 | ?define DOCK_FRAME_T " Док " |
||
5504 | punk_joker | 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 |
||
5506 | punk_joker | 38 | ?define WINDOW_TITLE "Taskbar and Docky configuration" |
39 | ?define TASK_FRAME_T " Taskbar " |
||
40 | ?define DOCK_FRAME_T " Docky " |
||
5504 | punk_joker | 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" |
||
5507 | punk_joker | 47 | ?define CHANGE_LANG "Change Language" |
5504 | punk_joker | 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 | |||
5506 | punk_joker | 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 }; |
||
5472 | leency | 60 | |
61 | char taskbar_ini_path[] = "/sys/settings/taskbar.ini"; |
||
5477 | leency | 62 | char taskbar_c_flags[] = "Flags"; |
63 | char taskbar_c_variables[] = "Variables"; |
||
5472 | leency | 64 | char docky_ini_path[] = "/sys/settings/docky.ini"; |
65 | |||
5477 | leency | 66 | unsigned char panels_img_data[] = FROM "panels_image.raw"; |
67 | raw_image panels_img = { 37, 27, #panels_img_data }; |
||
5472 | leency | 68 | |
69 | system_colors sc; |
||
70 | proc_info Form; |
||
71 | |||
72 | struct docky_cfg { |
||
73 | word fsize; |
||
74 | byte location, ashow; |
||
75 | } docky_cfg; |
||
76 | |||
77 | struct taskbar_cfg { |
||
78 | byte Attachment; |
||
5477 | leency | 79 | byte PanelHeight, SoftenHeight, ButtonOffset; |
5472 | leency | 80 | byte SoftenUp, SoftenDown, MinLeftButton, MinRightButton, MenuButton, |
81 | RunApplButton, ClnDeskButton, Clock, CpuUsage, ChangeLang; |
||
82 | } taskbar_cfg; |
||
83 | |||
5477 | leency | 84 | enum { |
85 | TASKBAR, |
||
5619 | leency | 86 | DOCKY, |
87 | ALL |
||
5477 | leency | 88 | }; |
5472 | leency | 89 | |
90 | |||
91 | void main() |
||
92 | { |
||
93 | dword id, key; |
||
94 | |||
95 | mem_Init(); |
||
5626 | leency | 96 | load_dll(boxlib, #box_lib_init,0); |
97 | load_dll(boxlib, #box_lib_init,0); |
||
5472 | leency | 98 | |
99 | LoadCfg(); |
||
100 | |||
101 | loop() switch(WaitEvent()) |
||
102 | { |
||
103 | case evButton: |
||
104 | id=GetButtonID(); |
||
105 | if (id==1) ExitProcess(); |
||
106 | //taskbar buttons |
||
107 | if (id>=100) && (id<200) |
||
108 | { |
||
109 | if (id==100) taskbar_cfg.Attachment ^= 1; |
||
110 | if (id==105) taskbar_cfg.SoftenUp ^= 1; |
||
111 | if (id==106) taskbar_cfg.SoftenDown ^= 1; |
||
112 | if (id==107) taskbar_cfg.MinLeftButton ^= 1; |
||
113 | if (id==108) taskbar_cfg.MinRightButton ^= 1; |
||
114 | if (id==109) taskbar_cfg.RunApplButton ^= 1; |
||
115 | if (id==110) taskbar_cfg.ClnDeskButton ^= 1; |
||
116 | if (id==111) taskbar_cfg.Clock ^= 1; |
||
117 | if (id==112) taskbar_cfg.CpuUsage ^= 1; |
||
118 | if (id==113) taskbar_cfg.ChangeLang ^= 1; |
||
119 | if (id==114) taskbar_cfg.MenuButton ^= 1; |
||
5477 | leency | 120 | if (id==120) taskbar_cfg.PanelHeight++; |
121 | if (id==121) && (taskbar_cfg.PanelHeight>6) taskbar_cfg.PanelHeight--; |
||
122 | if (id==122) taskbar_cfg.SoftenHeight++; |
||
123 | if (id==123) && (taskbar_cfg.SoftenHeight>0) taskbar_cfg.SoftenHeight--; |
||
124 | if (id==124) taskbar_cfg.ButtonOffset++; |
||
125 | if (id==125) && (taskbar_cfg.ButtonOffset>0) taskbar_cfg.ButtonOffset--; |
||
126 | DrawWindowContent(TASKBAR); |
||
127 | SaveCfg(TASKBAR); |
||
128 | RestartProcess(TASKBAR); |
||
5472 | leency | 129 | } |
130 | //docky buttons |
||
131 | if (id>=200) |
||
132 | { |
||
133 | if (id==200) |
||
134 | { |
||
135 | if (docky_cfg.location==1) docky_cfg.location = 2; |
||
136 | else if (docky_cfg.location==2) docky_cfg.location = 3; |
||
137 | else if (docky_cfg.location==3) docky_cfg.location = 1; |
||
138 | } |
||
139 | if (id==201) docky_cfg.fsize ^= 1; |
||
140 | if (id==202) docky_cfg.ashow ^= 1; |
||
5477 | leency | 141 | DrawWindowContent(DOCKY); |
142 | SaveCfg(DOCKY); |
||
143 | RestartProcess(DOCKY); |
||
5472 | leency | 144 | } |
145 | break; |
||
146 | |||
147 | case evKey: |
||
148 | key = GetKey(); |
||
149 | if (key==27) ExitProcess(); |
||
150 | break; |
||
151 | |||
152 | case evReDraw: |
||
153 | sc.get(); |
||
5504 | punk_joker | 154 | DefineAndDrawWindow(130, 150, 400, 300+GetSkinHeight(),0x34,sc.work,WINDOW_TITLE); |
5472 | leency | 155 | GetProcessInfo(#Form, SelfInfo); |
156 | if (Form.status_window>2) break; |
||
157 | taskbar_frame.size_x = docky_frame.size_x = - taskbar_frame.start_x * 2 + Form.cwidth; |
||
158 | taskbar_frame.font_color = docky_frame.font_color = sc.work_text; |
||
159 | taskbar_frame.font_backgr_color = docky_frame.font_backgr_color = sc.work; |
||
5477 | leency | 160 | taskbar_frame.ext_col = docky_frame.ext_col = sc.work_graph; |
5619 | leency | 161 | DrawWindowContent(ALL); |
5472 | leency | 162 | } |
163 | } |
||
164 | |||
165 | |||
5619 | leency | 166 | void DrawWindowContent(byte panel_type) |
5472 | leency | 167 | { |
168 | word win_center_x; |
||
169 | |||
5619 | leency | 170 | if (panel_type==ALL) |
171 | { |
||
172 | frame_draw stdcall (#taskbar_frame); |
||
173 | frame_draw stdcall (#docky_frame); |
||
174 | } |
||
175 | if (panel_type==ALL) || (panel_type==TASKBAR) |
||
176 | { |
||
177 | DefineButton(22, taskbar_frame.start_y + 12, panels_img.w-1, 27-1, 100 + BT_HIDE, 0); |
||
178 | _PutImage(22, taskbar_frame.start_y + 12, 37, 27, taskbar_cfg.Attachment * 37 * 27 * 3 + panels_img.data); |
||
179 | WriteText(68, taskbar_frame.start_y + 20, 0x80, sc.work_text, CHANGE_POS); |
||
180 | PanelCfg_CheckBox(22, taskbar_frame.start_y + 48, 105, SOFTEN_UP, taskbar_cfg.SoftenUp); |
||
181 | PanelCfg_CheckBox(22, taskbar_frame.start_y + 68, 106, SOFTEN_DOWN, taskbar_cfg.SoftenDown); |
||
182 | PanelCfg_CheckBox(22, taskbar_frame.start_y + 88, 107, MIN_LEFT_BUTTON, taskbar_cfg.MinLeftButton); |
||
183 | PanelCfg_CheckBox(22, taskbar_frame.start_y + 108, 108, MIN_RIGHT_BUTTON, taskbar_cfg.MinRightButton); |
||
184 | win_center_x = Form.cwidth / 2; |
||
185 | PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y + 48, 111, CLOCK, taskbar_cfg.Clock); |
||
186 | PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y + 68, 112, CPU_USAGE, taskbar_cfg.CpuUsage); |
||
187 | PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y + 88, 113, CHANGE_LANG, taskbar_cfg.ChangeLang); |
||
188 | PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y + 108, 114, MENU_BUTTON, taskbar_cfg.MenuButton); |
||
189 | PanelCfg_MoreLessBox(22, taskbar_frame.start_y + 131, 120, 121, taskbar_cfg.PanelHeight, PANEL_HEIGHT); |
||
190 | PanelCfg_MoreLessBox(win_center_x, taskbar_frame.start_y + 131, 122, 123, taskbar_cfg.SoftenHeight, SOFTEN_HEIGHT); |
||
191 | PanelCfg_MoreLessBox(22, taskbar_frame.start_y + 159, 124, 125, taskbar_cfg.ButtonOffset, BUTTON_OFFSET); |
||
192 | } |
||
193 | if (panel_type==ALL) || (panel_type==DOCKY) |
||
194 | { |
||
195 | DefineButton(22, docky_frame.start_y + 12, panels_img.w-1, 27-1, 200 + BT_HIDE, 0); |
||
196 | _PutImage(22, docky_frame.start_y + 12, 37, 27, docky_cfg.location + 1 * 37 * 27 * 3 + panels_img.data); |
||
197 | WriteText(68, docky_frame.start_y + 20, 0x80, sc.work_text, CHANGE_POS); |
||
198 | PanelCfg_CheckBox(22, docky_frame.start_y + 48, 201, FSIZE, docky_cfg.fsize); |
||
199 | PanelCfg_CheckBox(win_center_x, docky_frame.start_y + 48, 202, ASHOW, docky_cfg.ashow); |
||
200 | } |
||
5472 | leency | 201 | } |
202 | |||
203 | void LoadCfg() |
||
204 | { |
||
5477 | leency | 205 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Attachment", 1); taskbar_cfg.Attachment = EAX; |
206 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenUp", 1); taskbar_cfg.SoftenUp = EAX; |
||
207 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenDown", 1); taskbar_cfg.SoftenDown = EAX; |
||
208 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinLeftButton", 1); taskbar_cfg.MinLeftButton = EAX; |
||
209 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinRightButton", 1); taskbar_cfg.MinRightButton = EAX; |
||
210 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Clock", 1); taskbar_cfg.Clock = EAX; |
||
211 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "CpuUsage", 1); taskbar_cfg.CpuUsage = EAX; |
||
212 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "ChangeLang", 1); taskbar_cfg.ChangeLang = EAX; |
||
213 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MenuButton", 1); taskbar_cfg.MenuButton = EAX; |
||
214 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "PanelHeight", 18); taskbar_cfg.PanelHeight = EAX; |
||
215 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "SoftenHeight", 4); taskbar_cfg.SoftenHeight = EAX; |
||
216 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonTopOffset", 3); taskbar_cfg.ButtonOffset = EAX; |
||
217 | ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonBotOffset", 3); taskbar_cfg.ButtonOffset = EAX; |
||
5472 | leency | 218 | |
219 | ini_get_int stdcall (#docky_ini_path, "@", "location", 0); docky_cfg.location = EAX; |
||
220 | ini_get_int stdcall (#docky_ini_path, "@", "fsize", 0); docky_cfg.fsize = EAX; |
||
221 | ini_get_int stdcall (#docky_ini_path, "@", "ashow", 0); docky_cfg.ashow = EAX; |
||
222 | } |
||
223 | |||
5477 | leency | 224 | void SaveCfg(byte panel_type) |
5472 | leency | 225 | { |
5477 | leency | 226 | if (panel_type==TASKBAR) { |
227 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Attachment", taskbar_cfg.Attachment); |
||
228 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenUp", taskbar_cfg.SoftenUp); |
||
229 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenDown", taskbar_cfg.SoftenDown); |
||
230 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinLeftButton", taskbar_cfg.MinLeftButton); |
||
231 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinRightButton", taskbar_cfg.MinRightButton); |
||
232 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "RunApplButton", taskbar_cfg.RunApplButton); |
||
233 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "ClnDeskButton", taskbar_cfg.ClnDeskButton); |
||
234 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Clock", taskbar_cfg.Clock); |
||
235 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "CpuUsage", taskbar_cfg.CpuUsage); |
||
236 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "ChangeLang", taskbar_cfg.ChangeLang); |
||
237 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MenuButton", taskbar_cfg.MenuButton); |
||
238 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "PanelHeight", taskbar_cfg.PanelHeight); |
||
239 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "SoftenHeight", taskbar_cfg.SoftenHeight); |
||
240 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonTopOffset", taskbar_cfg.ButtonOffset); |
||
241 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonBottOffset", taskbar_cfg.ButtonOffset); |
||
242 | } |
||
243 | if (panel_type==DOCKY) { |
||
244 | ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Attachment", taskbar_cfg.Attachment); |
||
245 | ini_set_int stdcall (#docky_ini_path, "@", "location", docky_cfg.location); |
||
246 | ini_set_int stdcall (#docky_ini_path, "@", "fsize", docky_cfg.fsize); |
||
247 | ini_set_int stdcall (#docky_ini_path, "@", "ashow", docky_cfg.ashow); |
||
248 | } |
||
5472 | leency | 249 | } |
250 | |||
5477 | leency | 251 | void RestartProcess(byte panel_type) |
5472 | leency | 252 | { |
5548 | leency | 253 | dword proc_name1; |
254 | if (panel_type == TASKBAR) |
||
5472 | leency | 255 | { |
5548 | leency | 256 | RestartProcessByName("@taskbar", SINGLE); |
257 | pause(50); |
||
5472 | leency | 258 | } |
5548 | leency | 259 | else |
260 | { |
||
261 | RestartProcessByName("@docky", SINGLE); |
||
262 | pause(120); |
||
263 | } |
||
5472 | leency | 264 | GetProcessInfo(#Form, SelfInfo); |
5477 | leency | 265 | ActivateWindow(GetProcessSlot(Form.ID)); |
5472 | leency | 266 | } |
267 | |||
5477 | leency | 268 | |
269 | |||
270 | void PanelCfg_CheckBox(dword x, y, id, text, byte value) { |
||
5472 | leency | 271 | CheckBox(x, y, 14, 14, id, text, sc.work_graph, sc.work_text, value); |
272 | } |
||
273 | |||
5477 | leency | 274 | void PanelCfg_MoreLessBox(dword x, y, id_more, id_less; byte value; dword text) { |
5542 | leency | 275 | MoreLessBox(x, y, 18, id_more, id_less, #sc, value, text); |
5477 | leency | 276 | } |
277 | |||
278 | |||
5472 | leency | 279 | stop:200) |