Subversion Repositories Kolibri OS

Rev

Rev 7551 | Rev 7611 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4078 leency 1
//11.03.12 - start!
7594 leency 2
//ver 2.3
4078 leency 3
 
4085 leency 4
#ifndef AUTOBUILD
5
	?include "lang.h--"
6
#endif
7
 
4078 leency 8
#define MEMSIZE 0xFE800
9
#include "..\lib\mem.h"
4085 leency 10
#include "..\lib\strings.h"
5654 leency 11
#include "..\lib\io.h"
4078 leency 12
#include "..\lib\list_box.h"
5499 leency 13
#include "..\lib\gui.h"
7353 leency 14
 
5499 leency 15
#include "..\lib\obj\box_lib.h"
7353 leency 16
#include "..\lib\obj\proc_lib.h"
7594 leency 17
#include "..\lib\obj\libini.h"
7353 leency 18
 
6651 leency 19
#include "..\lib\patterns\select_list.h"
7353 leency 20
#include "..\lib\patterns\simple_open_dialog.h"
4078 leency 21
 
6212 leency 22
//===================================================//
23
//                                                   //
24
//                       DATA                        //
25
//                                                   //
26
//===================================================//
27
 
4085 leency 28
#ifdef LANG_RUS
6212 leency 29
	?define WINDOW_HEADER "Настройки оформления"
6264 leency 30
	?define T_SKINS       "Стиль окон"
31
	?define T_WALLPAPERS  "Обои"
7353 leency 32
	?define T_SELECT_FOLDER "Выбрать папку"
7447 leency 33
	?define MENU_LIST "Открыть файл   Enter\nУдалить файл     Del"
4085 leency 34
#else
35
	?define WINDOW_HEADER "Appearance"
6264 leency 36
	?define T_SKINS       "Skins"
7353 leency 37
	?define T_WALLPAPERS  "Wallpapers"
38
	?define T_SELECT_FOLDER "Select wallpapers"
7447 leency 39
	?define MENU_LIST "Open file      Enter\nDelete file      Del"
4085 leency 40
#endif
4078 leency 41
 
6212 leency 42
#define PANEL_H 40
7225 leency 43
#define LP 10 //LIST_PADDING
7594 leency 44
char skins_folder_path[4096];
45
char wallp_folder_path[4096];
4078 leency 46
 
6264 leency 47
signed int active_skin=-1, active_wallpaper=-1;
7353 leency 48
enum {
49
	SKINS=2,
50
	WALLPAPERS,
51
	BTN_SELECT_WALLP_FOLDER };
4078 leency 52
 
53
char folder_path[4096];
54
char cur_file_path[4096];
7551 leency 55
char cur_skin_path[4096];
4078 leency 56
char temp_filename[4096];
6096 leency 57
int files_mas[400];
4078 leency 58
 
59
int cur;
60
 
61
proc_info Form;
7244 leency 62
block skp;
4078 leency 63
 
7225 leency 64
_tabs tabs = { LP, LP, NULL, NULL, SKINS };
65
 
7244 leency 66
checkbox checkbox1 = { "Checkbox", true };
7252 leency 67
more_less_box spinbox1 = { 23, 0, 999, "SpinBox" };
7254 leency 68
edit_box edit_cmm = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
7506 leency 69
	0x10000000,sizeof(param)-2,#param,0, 0b};
7244 leency 70
 
7254 leency 71
char st_str[16];
72
edit_box edit_st = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
7506 leency 73
	0x10000000,sizeof(st_str)-2,#st_str,0, 0b};
7254 leency 74
 
7353 leency 75
char default_dir[] = "/rd/1";
76
od_filter filter2 = { 8, "TXT\0\0" };
77
 
6212 leency 78
//===================================================//
79
//                                                   //
80
//                       CODE                        //
81
//                                                   //
82
//===================================================//
5548 leency 83
 
7594 leency 84
void GetRealFolderPathes()
85
{
86
	char real_skin_path[4096];
87
	SetCurDir("/kolibrios");
88
	GetCurDir(#real_skin_path, sizeof(real_skin_path));
89
	sprintf(#skins_folder_path, "%s/res/skins", #real_skin_path);
90
	sprintf(#wallp_folder_path, "%s/res/wallpapers", #real_skin_path);
91
}
92
 
4078 leency 93
void main()
94
{
5705 punk_joker 95
	int id, mouse_clicked;
4078 leency 96
 
7594 leency 97
	GetRealFolderPathes();
98
 
5626 leency 99
	load_dll(boxlib, #box_lib_init,0);
7533 leency 100
	load_dll(libini, #lib_init,1);
7353 leency 101
	load_dll(Proc_lib, #OpenDialog_init,0);
102
	o_dialog.type = 2; //select folder
103
	OpenDialog_init stdcall (#o_dialog);
104
 
6212 leency 105
	EventTabClick(SKINS);
7353 leency 106
 
7551 leency 107
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
6096 leency 108
	loop() switch(WaitEvent())
4078 leency 109
	{
110
	  	case evMouse:
4085 leency 111
			if (!CheckActiveProcess(Form.ID)) break;
6653 leency 112
			SelectList_ProcessMouse();
4410 leency 113
 
7353 leency 114
			if (tabs.active_tab == SKINS) {
115
				edit_box_mouse stdcall (#edit_cmm);
116
				edit_box_mouse stdcall (#edit_st);
117
			}
118
 
7244 leency 119
	  		if (mouse.pkm)&&(select_list.MouseOver(mouse.x, mouse.y)) {
6651 leency 120
	  			select_list.ProcessMouse(mouse.x, mouse.y);
6653 leency 121
				SelectList_Draw();
7353 leency 122
				EventSetNewCurrent();
7447 leency 123
	  			menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 146, MENU_LIST, 10);
6212 leency 124
	  		}
4078 leency 125
	  		break;
126
 
127
		case evButton:
128
			id=GetButtonID();
7551 leency 129
			if (id==1) EventExit();
6212 leency 130
			if (id==SKINS) EventTabClick(SKINS);
131
			if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
7353 leency 132
			if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder();
7244 leency 133
			checkbox1.click(id);
7252 leency 134
			spinbox1.click(id);
4078 leency 135
			break;
136
 
137
		case evKey:
5706 leency 138
			GetKeys();
6651 leency 139
			if (select_list.ProcessKey(key_scancode)) EventApply();
6212 leency 140
			if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
7353 leency 141
			if (key_scancode==SCAN_CODE_TAB) {
7225 leency 142
				if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS);
7353 leency 143
				else EventTabClick(SKINS);
144
			}
6212 leency 145
			if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
7349 leency 146
 
7506 leency 147
			if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus)
6651 leency 148
			for (id=select_list.cur_y+1; id
4078 leency 149
			{
6212 leency 150
				strcpy(#temp_filename, io.dir.position(files_mas[id]));
151
				if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32)
152
				{
6651 leency 153
					select_list.cur_y = id - 1;
154
					select_list.KeyDown();
6212 leency 155
					EventApply();
156
					break;
157
				}
4078 leency 158
			}
7349 leency 159
 
7353 leency 160
			if (tabs.active_tab == SKINS) {
161
				EAX = key_ascii << 8;
162
				edit_box_key stdcall (#edit_cmm);
163
				edit_box_key stdcall (#edit_st);
164
			}
4078 leency 165
			break;
166
 
7353 leency 167
		 case evReDraw:
168
			draw_window();
7450 leency 169
	 		if (menu.cur_y) {
170
				if (menu.cur_y == 10) EventOpenFile();
171
				if (menu.cur_y == 11) EventDeleteFile();
172
				menu.cur_y = 0;
6212 leency 173
			};
4078 leency 174
   }
175
}
176
 
7353 leency 177
void draw_window()
178
{
179
	system.color.get();
180
	DefineAndDrawWindow(screen.width-600/2,80,630,404+skin_height,0x74,0xE4DFE1,WINDOW_HEADER,0);
181
	GetProcessInfo(#Form, SelfInfo);
182
	IF (Form.status_window>=2) return;
183
	DrawWindowContent();
184
}
7244 leency 185
 
6212 leency 186
void DrawWindowContent()
187
{
188
	int id;
7252 leency 189
	incn y;
7353 leency 190
	int list_w;
7225 leency 191
 
7353 leency 192
	if (tabs.active_tab == SKINS) list_w=250; else list_w=370;
193
 
7225 leency 194
	DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work);
195
 
196
	tabs.w = Form.cwidth-LP-LP;
197
	tabs.h = Form.cheight-LP-LP;
198
	tabs.draw_wrapper();
199
 
7226 leency 200
	tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS);
201
	tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS);
7225 leency 202
 
6651 leency 203
	id = select_list.cur_y;
6653 leency 204
	SelectList_Init(
7225 leency 205
		tabs.x+TAB_PADDING,
206
		tabs.y+TAB_HEIGHT+TAB_PADDING,
7353 leency 207
		list_w,
7225 leency 208
		tabs.h - TAB_PADDING - TAB_PADDING - TAB_HEIGHT,
6653 leency 209
		false
210
		);
6651 leency 211
	select_list.cur_y = id;
7244 leency 212
 
213
	skp.set_size(
7252 leency 214
		select_list.x + select_list.w + TAB_PADDING + scroll1.size_x + 20,
215
		select_list.y + 30,
7353 leency 216
		list_w,
7252 leency 217
		select_list.h - 50
7244 leency 218
	);
219
 
6653 leency 220
	SelectList_Draw();
6662 leency 221
	SelectList_DrawBorder();
7244 leency 222
 
223
	if (tabs.active_tab == SKINS)
224
	{
7252 leency 225
		DrawBar(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work);
226
		DrawRectangle(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work_graph);
227
		y.n = skp.y;
7244 leency 228
		DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview ");
7252 leency 229
		checkbox1.draw(skp.x+20, y.inc(30));
230
		spinbox1.draw(skp.x+20, y.inc(30));
7254 leency 231
		WriteText(skp.x+20, y.inc(30), 0x90, system.color.work_text, "C-- Edit");
232
		DrawEditBoxPos(skp.x+20, y.inc(20), #edit_cmm);
233
		WriteText(skp.x+20, y.inc(35), 0x90, system.color.work_text, "Strandard Edit");
234
		DrawStEditBoxPos(skp.x+20, y.inc(20), #edit_st);
7252 leency 235
		DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Button1");
236
		DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Button2");
7244 leency 237
	}
7353 leency 238
	if (tabs.active_tab == WALLPAPERS)
239
	{
7533 leency 240
		DrawStandartCaptButton(select_list.x + select_list.w + scroll1.size_x + 17,
241
			select_list.y, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
7353 leency 242
	}
6212 leency 243
}
244
 
7254 leency 245
:void DrawStEditBoxPos(dword x,y, edit_box_pointer)
246
{
247
	dword c_inactive = MixColors(system.color.work_graph, system.color.work, 128);
248
	dword c_active = MixColors(system.color.work_graph, 0, 128);
249
	ESI = edit_box_pointer;
250
	ESI.edit_box.left = x;
251
	ESI.edit_box.top = y;
252
	ESI.edit_box.blur_border_color = c_inactive;
253
	ESI.edit_box.focus_border_color = c_active;
254
	edit_box_draw  stdcall (edit_box_pointer);
255
}
4410 leency 256
 
6212 leency 257
 
7254 leency 258
 
6212 leency 259
void Open_Dir()
4078 leency 260
{
6212 leency 261
	int j;
6651 leency 262
	select_list.count = 0;
6212 leency 263
	if(io.dir.buffer)free(io.dir.buffer);
264
	io.dir.load(#folder_path,DIR_ONLYREAL);
265
	for (j=0; j
4410 leency 266
	{
6212 leency 267
		strcpy(#temp_filename, io.dir.position(j));
268
		strlwr(#temp_filename);
7353 leency 269
		if (tabs.active_tab==SKINS) {
270
			if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
271
		}
272
		if (tabs.active_tab==WALLPAPERS) {
273
			if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".png")!=0)
274
			&& (strcmpi(#temp_filename+strlen(#temp_filename)-4,".jpg")!=0)
275
			&& (strcmpi(#temp_filename+strlen(#temp_filename)-5,".jpeg")!=0)
276
			&& (strcmpi(#temp_filename+strlen(#temp_filename)-4,".gif")!=0) continue;
277
		}
6651 leency 278
		cur = select_list.count;
6212 leency 279
		files_mas[cur]=j;
6651 leency 280
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
281
		select_list.count++;
4410 leency 282
	}
6212 leency 283
}
284
 
6653 leency 285
void SelectList_DrawLine(dword i)
6212 leency 286
{
6651 leency 287
	int yyy, list_last;
6212 leency 288
 
6651 leency 289
	cur = select_list.first + i;
290
	strcpy(#temp_filename, io.dir.position(files_mas[cur]));
291
	temp_filename[strlen(#temp_filename)-4] = 0;
292
	yyy = i*select_list.item_h+select_list.y;
293
 
294
	if (select_list.cur_y-select_list.first==i)
4410 leency 295
	{
6651 leency 296
		DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
297
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, #temp_filename);
4410 leency 298
	}
6651 leency 299
	else
300
	{
301
		DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
302
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, #temp_filename);
303
	}
4078 leency 304
}
305
 
6653 leency 306
void SelectList_LineChanged()
307
{
308
	EventApply();
309
}
310
 
6212 leency 311
//===================================================//
312
//                                                   //
313
//                     EVENTS                        //
314
//                                                   //
315
//===================================================//
4078 leency 316
 
6212 leency 317
void EventTabClick(int N)
4085 leency 318
{
6264 leency 319
	tabs.click(N);
320
	if (tabs.active_tab == SKINS)
6212 leency 321
	{
6651 leency 322
		active_wallpaper = select_list.cur_y;
7353 leency 323
		strcpy(#folder_path, #skins_folder_path);
6651 leency 324
		select_list.ClearList();
6212 leency 325
		Open_Dir();
6651 leency 326
		if (!select_list.count) notify("'No skins were found' -E");
327
		select_list.cur_y = active_skin;
6212 leency 328
	}
6264 leency 329
	if (tabs.active_tab == WALLPAPERS)
6212 leency 330
	{
6651 leency 331
		active_skin = select_list.cur_y;
7353 leency 332
		strcpy(#folder_path, #wallp_folder_path);
6651 leency 333
		select_list.ClearList();
6212 leency 334
		Open_Dir();
6651 leency 335
		if (!select_list.count) notify("'No wallpapers were found' -E");
336
		select_list.cur_y = active_wallpaper;
6212 leency 337
	}
6651 leency 338
	if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey();
339
	if (select_list.w) DrawWindowContent();
6212 leency 340
}
4078 leency 341
 
6212 leency 342
void EventDeleteFile()
343
{
344
	io.del(#cur_file_path);
345
	Open_Dir();
346
	EventApply();
347
}
4078 leency 348
 
7353 leency 349
void EventSetNewCurrent()
350
{
351
	cur = select_list.cur_y;
352
	sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur]));
353
}
354
 
355
void EventSelectWallpFolder()
356
{
357
	OpenDialog_start stdcall (#o_dialog);
358
	if (o_dialog.status) {
359
		strcpy(#wallp_folder_path, #opendir_path);
360
		EventTabClick(WALLPAPERS);
361
	}
362
}
363
 
6212 leency 364
void EventApply()
365
{
7353 leency 366
	char kivpath[4096+10];
367
	EventSetNewCurrent();
6264 leency 368
	if (tabs.active_tab==SKINS)
6212 leency 369
	{
7551 leency 370
		draw_window();
6651 leency 371
		cur = select_list.cur_y;
6212 leency 372
		SetSystemSkin(#cur_file_path);
7551 leency 373
		strcpy(#cur_skin_path, #cur_file_path);
6212 leency 374
	}
6264 leency 375
	if (tabs.active_tab==WALLPAPERS)
6212 leency 376
	{
7551 leency 377
		SelectList_Draw();
7353 leency 378
		strcpy(#kivpath, "\\S__");
379
		strcat(#kivpath, #cur_file_path);
380
		RunProgram("/sys/media/kiv", #kivpath);
6212 leency 381
	}
382
}
4085 leency 383
 
6212 leency 384
void EventOpenFile()
385
{
6264 leency 386
	if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path);
387
	if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
4085 leency 388
}
389
 
7594 leency 390
_ini ini = { "/sys/settings/eskin.ini", "main" };
7551 leency 391
void EventExit()
392
{
7594 leency 393
	ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path));
7551 leency 394
	ExitProcess();
395
}
396
 
4078 leency 397
stop: