Subversion Repositories Kolibri OS

Rev

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