Subversion Repositories Kolibri OS

Rev

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