Rev 7049 | Rev 7219 | 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 | |
7049 | leency | 13 | #include "..\lib\obj\libio.h" |
5499 | leency | 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 | |||
6197 | leency | 58 | frame taskbar_frame = { 0, NULL, 10, NULL, 16, NULL, 0xFFFfff, 1, TASK_FRAME_T, 0, 1, 12, 0x000111, 0xCCCccc }; |
59 | frame docky_frame = { 0, NULL, 10, NULL, NULL, NULL, 0xFFFfff, 1, DOCK_FRAME_T, 0, 1, 12, 0x000111, 0xCCCccc }; |
||
5472 | leency | 60 | |
61 | char taskbar_ini_path[] = "/sys/settings/taskbar.ini"; |
||
7051 | leency | 62 | _ini taskbar_flags_ini = { #taskbar_ini_path, "Flags" }; |
63 | _ini taskbar_vars_ini = { #taskbar_ini_path, "Variables" }; |
||
5472 | leency | 64 | |
7051 | leency | 65 | _ini docky_ini = { "/sys/settings/docky.ini", "@" }; |
66 | |||
5477 | leency | 67 | unsigned char panels_img_data[] = FROM "panels_image.raw"; |
68 | raw_image panels_img = { 37, 27, #panels_img_data }; |
||
5472 | leency | 69 | |
70 | proc_info Form; |
||
71 | |||
6197 | leency | 72 | word dkFsize; |
73 | byte dkLocation, dkAshow; |
||
5472 | leency | 74 | |
6197 | leency | 75 | byte tbAttachment, tbPanelHeight, tbSoftenHeight, tbButtonOffset, |
76 | tbSoftenUp, tbSoftenDown, tbMinLeftButton, tbMinRightButton, tbMenuButton, |
||
77 | tbRunApplButton, tbClnDeskButton, tbClock, tbCpuUsage, tbChangeLang; |
||
5472 | leency | 78 | |
5477 | leency | 79 | enum { |
80 | TASKBAR, |
||
5619 | leency | 81 | DOCKY, |
82 | ALL |
||
5477 | leency | 83 | }; |
5472 | leency | 84 | |
85 | |||
86 | void main() |
||
87 | { |
||
88 | dword id, key; |
||
89 | |||
5630 | leency | 90 | load_dll(libini, #lib_init,1); |
5626 | leency | 91 | load_dll(boxlib, #box_lib_init,0); |
5472 | leency | 92 | |
93 | LoadCfg(); |
||
94 | |||
95 | loop() switch(WaitEvent()) |
||
96 | { |
||
97 | case evButton: |
||
98 | id=GetButtonID(); |
||
99 | if (id==1) ExitProcess(); |
||
100 | //taskbar buttons |
||
101 | if (id>=100) && (id<200) |
||
102 | { |
||
6197 | leency | 103 | if (id==100) tbAttachment ^= 1; |
104 | if (id==105) tbSoftenUp ^= 1; |
||
105 | if (id==106) tbSoftenDown ^= 1; |
||
106 | if (id==107) tbMinLeftButton ^= 1; |
||
107 | if (id==108) tbMinRightButton ^= 1; |
||
108 | if (id==109) tbRunApplButton ^= 1; |
||
109 | if (id==110) tbClnDeskButton ^= 1; |
||
110 | if (id==111) tbClock ^= 1; |
||
111 | if (id==112) tbCpuUsage ^= 1; |
||
112 | if (id==113) tbChangeLang ^= 1; |
||
113 | if (id==114) tbMenuButton ^= 1; |
||
114 | if (id==120) tbPanelHeight++; |
||
115 | if (id==121) && (tbPanelHeight>6) tbPanelHeight--; |
||
116 | if (id==122) tbSoftenHeight++; |
||
117 | if (id==123) && (tbSoftenHeight>0) tbSoftenHeight--; |
||
118 | if (id==124) tbButtonOffset++; |
||
119 | if (id==125) && (tbButtonOffset>0) tbButtonOffset--; |
||
5477 | leency | 120 | DrawWindowContent(TASKBAR); |
121 | SaveCfg(TASKBAR); |
||
122 | RestartProcess(TASKBAR); |
||
5472 | leency | 123 | } |
124 | //docky buttons |
||
125 | if (id>=200) |
||
126 | { |
||
127 | if (id==200) |
||
128 | { |
||
6197 | leency | 129 | dkLocation++; |
130 | if (dkLocation>3) dkLocation=1; |
||
5472 | leency | 131 | } |
6197 | leency | 132 | if (id==201) dkFsize ^= 1; |
133 | if (id==202) dkAshow ^= 1; |
||
5477 | leency | 134 | DrawWindowContent(DOCKY); |
135 | SaveCfg(DOCKY); |
||
136 | RestartProcess(DOCKY); |
||
5472 | leency | 137 | } |
138 | break; |
||
139 | |||
140 | case evKey: |
||
141 | key = GetKey(); |
||
142 | if (key==27) ExitProcess(); |
||
143 | break; |
||
144 | |||
145 | case evReDraw: |
||
5674 | pavelyakov | 146 | system.color.get(); |
7051 | leency | 147 | DefineAndDrawWindow(130, 150, 465, 398 + skin_height, 0x34, system.color.work, WINDOW_TITLE, 0); |
5472 | leency | 148 | GetProcessInfo(#Form, SelfInfo); |
149 | if (Form.status_window>2) break; |
||
150 | taskbar_frame.size_x = docky_frame.size_x = - taskbar_frame.start_x * 2 + Form.cwidth; |
||
5674 | pavelyakov | 151 | taskbar_frame.font_color = docky_frame.font_color = system.color.work_text; |
152 | taskbar_frame.font_backgr_color = docky_frame.font_backgr_color = system.color.work; |
||
153 | taskbar_frame.ext_col = docky_frame.ext_col = system.color.work_graph; |
||
5619 | leency | 154 | DrawWindowContent(ALL); |
5472 | leency | 155 | } |
156 | } |
||
157 | |||
158 | |||
5619 | leency | 159 | void DrawWindowContent(byte panel_type) |
5472 | leency | 160 | { |
6197 | leency | 161 | word win_center_x = Form.cwidth / 2 + 20; |
162 | incn y; |
||
5472 | leency | 163 | |
5619 | leency | 164 | if (panel_type==ALL) || (panel_type==TASKBAR) |
165 | { |
||
6197 | leency | 166 | y.n = taskbar_frame.start_y; |
167 | DefineButton(22, y.inc(18), panels_img.w-1, 27-1, 100 + BT_HIDE, 0); |
||
168 | _PutImage(22, y.n, 37, 27, tbAttachment * 37 * 27 * 3 + panels_img.data); |
||
169 | WriteText(68, y.inc(7), 0x90, system.color.work_text, CHANGE_POS); |
||
170 | CheckBox(22, y.inc(35), 105, SOFTEN_UP, tbSoftenUp); |
||
171 | CheckBox(win_center_x, y.n, 111, CLOCK, tbClock); |
||
172 | CheckBox(22, y.inc(24), 106, SOFTEN_DOWN, tbSoftenDown); |
||
173 | CheckBox(win_center_x, y.n, 112, CPU_USAGE, tbCpuUsage); |
||
174 | CheckBox(22, y.inc(24), 107, MIN_LEFT_BUTTON, tbMinLeftButton); |
||
175 | CheckBox(win_center_x, y.n, 113, CHANGE_LANG, tbChangeLang); |
||
176 | CheckBox(22, y.inc(24), 108, MIN_RIGHT_BUTTON, tbMinRightButton); |
||
177 | CheckBox(win_center_x, y.n, 114, MENU_BUTTON, tbMenuButton); |
||
178 | MoreLessBox(22, y.inc(28), 120, 121, tbPanelHeight, PANEL_HEIGHT); |
||
179 | MoreLessBox(22, y.inc(32), 122, 123, tbSoftenHeight, SOFTEN_HEIGHT); |
||
180 | MoreLessBox(22, y.inc(32), 124, 125, tbButtonOffset, BUTTON_OFFSET); |
||
181 | taskbar_frame.size_y = y.inc(32) - taskbar_frame.start_y; |
||
5619 | leency | 182 | } |
183 | if (panel_type==ALL) || (panel_type==DOCKY) |
||
184 | { |
||
6197 | leency | 185 | docky_frame.start_y = y.inc(20); |
186 | DefineButton(22, y.inc(18), panels_img.w-1, 27-1, 200 + BT_HIDE, 0); |
||
187 | _PutImage(22, y.n, 37, 27, dkLocation + 1 * 37 * 27 * 3 + panels_img.data); |
||
188 | WriteText(68, y.inc(7), 0x90, system.color.work_text, CHANGE_POS); |
||
189 | CheckBox(22, y.inc(35), 201, FSIZE, dkFsize); |
||
190 | CheckBox(win_center_x, y.n, 202, ASHOW, dkAshow); |
||
191 | docky_frame.size_y = y.inc(30) - docky_frame.start_y; |
||
5619 | leency | 192 | } |
6197 | leency | 193 | if (panel_type==ALL) |
194 | { |
||
195 | frame_draw stdcall (#taskbar_frame); |
||
196 | frame_draw stdcall (#docky_frame); |
||
197 | } |
||
5472 | leency | 198 | } |
199 | |||
200 | void LoadCfg() |
||
201 | { |
||
7051 | leency | 202 | tbAttachment = taskbar_flags_ini.GetInt("Attachment", 1); |
203 | tbSoftenUp = taskbar_flags_ini.GetInt("SoftenUp", 1); |
||
204 | tbSoftenDown = taskbar_flags_ini.GetInt("SoftenDown", 1); |
||
205 | tbMinLeftButton = taskbar_flags_ini.GetInt("MinLeftButton", 1); |
||
206 | tbMinRightButton = taskbar_flags_ini.GetInt("MinRightButton", 1); |
||
207 | tbClock = taskbar_flags_ini.GetInt("Clock", 1); |
||
208 | tbCpuUsage = taskbar_flags_ini.GetInt("CpuUsage", 1); |
||
209 | tbChangeLang = taskbar_flags_ini.GetInt("ChangeLang", 1); |
||
210 | tbMenuButton = taskbar_flags_ini.GetInt("MenuButton", 1); |
||
211 | tbPanelHeight = taskbar_vars_ini.GetInt("PanelHeight", 18); |
||
212 | tbSoftenHeight = taskbar_vars_ini.GetInt("SoftenHeight", 4); |
||
213 | tbButtonOffset = taskbar_vars_ini.GetInt("ButtonTopOffset", 3); |
||
214 | tbButtonOffset = taskbar_vars_ini.GetInt("ButtonBotOffset", 3); |
||
5472 | leency | 215 | |
7051 | leency | 216 | dkLocation = docky_ini.GetInt("location", 0); |
217 | dkFsize = docky_ini.GetInt("fsize", 0); |
||
218 | dkAshow = docky_ini.GetInt("ashow", 0); |
||
5472 | leency | 219 | } |
220 | |||
5477 | leency | 221 | void SaveCfg(byte panel_type) |
5472 | leency | 222 | { |
5477 | leency | 223 | if (panel_type==TASKBAR) { |
7051 | leency | 224 | taskbar_flags_ini.SetInt("Attachment", tbAttachment); |
225 | taskbar_flags_ini.SetInt("SoftenUp", tbSoftenUp); |
||
226 | taskbar_flags_ini.SetInt("SoftenDown", tbSoftenDown); |
||
227 | taskbar_flags_ini.SetInt("MinLeftButton", tbMinLeftButton); |
||
228 | taskbar_flags_ini.SetInt("MinRightButton", tbMinRightButton); |
||
229 | taskbar_flags_ini.SetInt("RunApplButton", tbRunApplButton); |
||
230 | taskbar_flags_ini.SetInt("ClnDeskButton", tbClnDeskButton); |
||
231 | taskbar_flags_ini.SetInt("Clock", tbClock); |
||
232 | taskbar_flags_ini.SetInt("CpuUsage", tbCpuUsage); |
||
233 | taskbar_flags_ini.SetInt("ChangeLang", tbChangeLang); |
||
234 | taskbar_flags_ini.SetInt("MenuButton", tbMenuButton); |
||
235 | taskbar_vars_ini.SetInt("PanelHeight", tbPanelHeight); |
||
236 | taskbar_vars_ini.SetInt("SoftenHeight", tbSoftenHeight); |
||
237 | taskbar_vars_ini.SetInt("ButtonTopOffset", tbButtonOffset); |
||
238 | taskbar_vars_ini.SetInt("ButtonBottOffset", tbButtonOffset); |
||
5477 | leency | 239 | } |
240 | if (panel_type==DOCKY) { |
||
7051 | leency | 241 | docky_ini.SetInt("location", dkLocation); |
242 | docky_ini.SetInt("fsize", dkFsize); |
||
243 | docky_ini.SetInt("ashow", dkAshow); |
||
5477 | leency | 244 | } |
5472 | leency | 245 | } |
246 | |||
5477 | leency | 247 | void RestartProcess(byte panel_type) |
5472 | leency | 248 | { |
5548 | leency | 249 | dword proc_name1; |
250 | if (panel_type == TASKBAR) |
||
5472 | leency | 251 | { |
5548 | leency | 252 | RestartProcessByName("@taskbar", SINGLE); |
253 | pause(50); |
||
5472 | leency | 254 | } |
5548 | leency | 255 | else |
256 | { |
||
257 | RestartProcessByName("@docky", SINGLE); |
||
258 | pause(120); |
||
259 | } |
||
5472 | leency | 260 | GetProcessInfo(#Form, SelfInfo); |
5477 | leency | 261 | ActivateWindow(GetProcessSlot(Form.ID)); |
5472 | leency | 262 | } |
263 | |||
5477 | leency | 264 | |
265 | |||
5472 | leency | 266 | stop:200) |