Subversion Repositories Kolibri OS

Rev

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