Subversion Repositories Kolibri OS

Rev

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