Subversion Repositories Kolibri OS

Rev

Rev 7349 | Rev 7447 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7349 Rev 7353
Line 1... Line 1...
1
//11.03.12 - start!
1
//11.03.12 - start!
2
//ver 2.0
2
//ver 2.1
Line 3... Line 3...
3
 
3
 
4
#ifndef AUTOBUILD
4
#ifndef AUTOBUILD
5
	?include "lang.h--"
5
	?include "lang.h--"
Line 10... Line 10...
10
#include "..\lib\strings.h"
10
#include "..\lib\strings.h"
11
#include "..\lib\io.h"
11
#include "..\lib\io.h"
12
#include "..\lib\list_box.h"
12
#include "..\lib\list_box.h"
13
#include "..\lib\menu.h"
13
#include "..\lib\menu.h"
14
#include "..\lib\gui.h"
14
#include "..\lib\gui.h"
-
 
15
 
15
#include "..\lib\obj\box_lib.h"
16
#include "..\lib\obj\box_lib.h"
16
#include "..\lib\patterns\select_list.h"
17
#include "..\lib\obj\proc_lib.h"
Line -... Line 18...
-
 
18
 
-
 
19
#include "..\lib\patterns\select_list.h"
Line 17... Line 20...
17
 
20
#include "..\lib\patterns\simple_open_dialog.h"
18
 
21
 
19
//===================================================//
22
//===================================================//
20
//                                                   //
23
//                                                   //
Line 24... Line 27...
24
 
27
 
25
#ifdef LANG_RUS
28
#ifdef LANG_RUS
26
	?define WINDOW_HEADER " áâனª¨ ®ä®à¬«¥­¨ï"
29
	?define WINDOW_HEADER " áâனª¨ ®ä®à¬«¥­¨ï"
27
	?define T_SKINS       "‘â¨«ì ®ª®­"
30
	?define T_SKINS       "‘â¨«ì ®ª®­"
-
 
31
	?define T_WALLPAPERS  "Ž¡®¨"
28
	?define T_WALLPAPERS  "Ž¡®¨"
32
	?define T_SELECT_FOLDER "‚ë¡à âì ¯ ¯ªã"
29
#else
33
#else
30
	?define WINDOW_HEADER "Appearance"
34
	?define WINDOW_HEADER "Appearance"
31
	?define T_SKINS       "Skins"
35
	?define T_SKINS       "Skins"
-
 
36
	?define T_WALLPAPERS  "Wallpapers"
32
	?define T_WALLPAPERS  "Wallpappers"
37
	?define T_SELECT_FOLDER "Select wallpapers"
Line 33... Line 38...
33
#endif
38
#endif
34
 
39
 
35
#define PANEL_H 40
40
#define PANEL_H 40
36
#define LP 10 //LIST_PADDING
41
#define LP 10 //LIST_PADDING
Line 37... Line 42...
37
#define SKINS_STANDART_PATH "/kolibrios/res/skins"							
42
char skins_folder_path[4096] = "/kolibrios/res/skins";
-
 
43
char wallp_folder_path[4096] = "/kolibrios/res/wallpapers";
-
 
44
 
-
 
45
signed int active_skin=-1, active_wallpaper=-1;
38
#define WALP_STANDART_PATH "/kolibrios/res/wallpapers"
46
enum { 
Line 39... Line 47...
39
 
47
	SKINS=2, 
40
signed int active_skin=-1, active_wallpaper=-1;
48
	WALLPAPERS,
41
enum { SKINS=2, WALLPAPERS };
49
	BTN_SELECT_WALLP_FOLDER };
42
 
50
 
Line 59... Line 67...
59
 
67
 
60
char st_str[16];
68
char st_str[16];
61
edit_box edit_st = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
69
edit_box edit_st = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
Line 62... Line -...
62
	0x10000000,sizeof(st_str),#st_str,0, 0b};
-
 
63
 
70
	0x10000000,sizeof(st_str),#st_str,0, 0b};
Line -... Line 71...
-
 
71
 
-
 
72
#define MENU_LIST "Open file     Enter\nDelete          Del"
-
 
73
 
64
 
74
char default_dir[] = "/rd/1";
65
#define MENU_LIST "Open file     Enter\nDelete          Del"
75
od_filter filter2 = { 8, "TXT\0\0" };
66
 
76
 
67
//===================================================//
77
//===================================================//
68
//                                                   //
78
//                                                   //
Line 69... Line 79...
69
//                       CODE                        //
79
//                       CODE                        //
70
//                                                   //
80
//                                                   //
71
//===================================================//
81
//===================================================//
Line 72... Line -...
72
 
-
 
73
void main()
82
 
-
 
83
void main()
-
 
84
{   
-
 
85
	int id, mouse_clicked;
-
 
86
 
74
{   
87
	load_dll(boxlib, #box_lib_init,0);
-
 
88
	load_dll(Proc_lib, #OpenDialog_init,0);
-
 
89
	o_dialog.type = 2; //select folder
75
	int id, mouse_clicked;
90
	OpenDialog_init stdcall (#o_dialog);
76
 
91
 
77
	SetEventMask(0x27);
92
	EventTabClick(SKINS);
78
	load_dll(boxlib, #box_lib_init,0);
93
 
79
	EventTabClick(SKINS);
94
	SetEventMask(0x27);
-
 
95
	loop() switch(WaitEvent()) 
-
 
96
	{
80
	loop() switch(WaitEvent()) 
97
	  	case evMouse:
81
	{
98
			if (!CheckActiveProcess(Form.ID)) break;
-
 
99
			SelectList_ProcessMouse();
Line 82... Line 100...
82
	  	case evMouse:
100
 
83
			if (!CheckActiveProcess(Form.ID)) break;
101
			if (tabs.active_tab == SKINS) {
84
			SelectList_ProcessMouse();
102
				edit_box_mouse stdcall (#edit_cmm);
-
 
103
				edit_box_mouse stdcall (#edit_st);
85
			edit_box_mouse stdcall (#edit_cmm);
104
			}
86
			edit_box_mouse stdcall (#edit_st);
105
 
87
 
106
	  		if (mouse.pkm)&&(select_list.MouseOver(mouse.x, mouse.y)) {
Line 88... Line 107...
88
	  		if (mouse.pkm)&&(select_list.MouseOver(mouse.x, mouse.y)) {
107
	  			select_list.ProcessMouse(mouse.x, mouse.y);
89
	  			select_list.ProcessMouse(mouse.x, mouse.y);
108
				SelectList_Draw();
90
				SelectList_Draw();
109
				EventSetNewCurrent();
91
	  			menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 185, MENU_LIST, 10); 
110
	  			menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 185, MENU_LIST, 10); 
92
	  		}
111
	  		}
-
 
112
	  		break;
93
	  		break;
113
 
94
 
114
		case evButton:
95
		case evButton:
115
			id=GetButtonID();
Line 96... Line 116...
96
			id=GetButtonID();
116
			if (id==1) ExitProcess();
97
			if (id==1) ExitProcess();
117
			if (id==SKINS) EventTabClick(SKINS);
98
			if (id==SKINS) EventTabClick(SKINS);
118
			if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
99
			if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
119
			if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder();
100
			checkbox1.click(id);
120
			checkbox1.click(id);
101
			spinbox1.click(id);
121
			spinbox1.click(id);
102
			break;
122
			break;
-
 
123
	  
103
	  
124
		case evKey:
Line 104... Line 125...
104
		case evKey:
125
			GetKeys(); 
105
			GetKeys(); 
126
			if (select_list.ProcessKey(key_scancode)) EventApply();
106
			if (select_list.ProcessKey(key_scancode)) EventApply();
127
			if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
Line 121... Line 142...
121
					EventApply();
142
					EventApply();
122
					break;
143
					break;
123
				}
144
				}
124
			}
145
			}
Line -... Line 146...
-
 
146
 
125
 
147
			if (tabs.active_tab == SKINS) {
126
			EAX = key_ascii << 8;
148
				EAX = key_ascii << 8;
127
			edit_box_key stdcall (#edit_cmm);
149
				edit_box_key stdcall (#edit_cmm);
-
 
150
				edit_box_key stdcall (#edit_st);				
128
			edit_box_key stdcall (#edit_st);
151
			}
Line 129... Line 152...
129
			break;
152
			break;
130
		 
-
 
131
		 case evReDraw:
-
 
132
			system.color.get();			
-
 
133
			DefineAndDrawWindow(screen.width-600/2,80,630,404+skin_height,0x74,0xE4DFE1,WINDOW_HEADER,0);
-
 
134
			GetProcessInfo(#Form, SelfInfo);
153
		 
135
			IF (Form.status_window>=2) break;
154
		 case evReDraw:		
136
		 	DrawWindowContent();
155
			draw_window();
137
	 		if (menu.list.cur_y) {
156
	 		if (menu.list.cur_y) {
138
				if (menu.list.cur_y == 10) EventOpenFile();
157
				if (menu.list.cur_y == 10) EventOpenFile();
139
				if (menu.list.cur_y == 11) EventDeleteFile();
158
				if (menu.list.cur_y == 11) EventDeleteFile();
140
				menu.list.cur_y = 0;
159
				menu.list.cur_y = 0;
141
			};
160
			};
Line -... Line 161...
-
 
161
   }
-
 
162
}
-
 
163
 
-
 
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);
Line 142... Line 169...
142
   }
169
	IF (Form.status_window>=2) return;
143
}
170
	DrawWindowContent();
144
 
171
}
145
 
172
 
-
 
173
void DrawWindowContent()
-
 
174
{
-
 
175
	int id;
Line 146... Line 176...
146
void DrawWindowContent()
176
	incn y;
Line 147... Line 177...
147
{
177
	int list_w;
148
	int id;
178
 
Line 159... Line 189...
159
 
189
 
160
	id = select_list.cur_y;
190
	id = select_list.cur_y;
161
	SelectList_Init(
191
	SelectList_Init(
162
		tabs.x+TAB_PADDING,
192
		tabs.x+TAB_PADDING,
163
		tabs.y+TAB_HEIGHT+TAB_PADDING, 
193
		tabs.y+TAB_HEIGHT+TAB_PADDING, 
164
		250, 
194
		list_w, 
165
		tabs.h - TAB_PADDING - TAB_PADDING - TAB_HEIGHT, 
195
		tabs.h - TAB_PADDING - TAB_PADDING - TAB_HEIGHT, 
166
		false
196
		false
167
		);
197
		);
Line 168... Line 198...
168
	select_list.cur_y = id;
198
	select_list.cur_y = id;
169
 
199
 
170
	skp.set_size(
200
	skp.set_size(
171
		select_list.x + select_list.w + TAB_PADDING + scroll1.size_x + 20,
201
		select_list.x + select_list.w + TAB_PADDING + scroll1.size_x + 20,
172
		select_list.y + 30,
202
		select_list.y + 30,
173
		250,
203
		list_w,
Line 174... Line 204...
174
		select_list.h - 50
204
		select_list.h - 50
175
	);
205
	);
Line 190... Line 220...
190
		WriteText(skp.x+20, y.inc(35), 0x90, system.color.work_text, "Strandard Edit");
220
		WriteText(skp.x+20, y.inc(35), 0x90, system.color.work_text, "Strandard Edit");
191
		DrawStEditBoxPos(skp.x+20, y.inc(20), #edit_st);
221
		DrawStEditBoxPos(skp.x+20, y.inc(20), #edit_st);
192
		DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Button1");
222
		DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Button1");
193
		DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Button2");
223
		DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Button2");
194
	}
224
	}
-
 
225
	if (tabs.active_tab == WALLPAPERS)
-
 
226
	{
-
 
227
		DrawStandartCaptButton(skp.x, select_list.y, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
-
 
228
	}
195
}
229
}
Line 196... Line 230...
196
 
230
 
197
:void DrawStEditBoxPos(dword x,y, edit_box_pointer)
231
:void DrawStEditBoxPos(dword x,y, edit_box_pointer)
198
{
232
{
Line 216... Line 250...
216
	io.dir.load(#folder_path,DIR_ONLYREAL);
250
	io.dir.load(#folder_path,DIR_ONLYREAL);
217
	for (j=0; j
251
	for (j=0; j
218
	{
252
	{
219
		strcpy(#temp_filename, io.dir.position(j));
253
		strcpy(#temp_filename, io.dir.position(j));
220
		strlwr(#temp_filename);
254
		strlwr(#temp_filename);
-
 
255
		if (tabs.active_tab==SKINS) {
221
		if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
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)
222
		if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
262
			&& (strcmpi(#temp_filename+strlen(#temp_filename)-4,".gif")!=0) continue;
-
 
263
		}
223
		cur = select_list.count;
264
		cur = select_list.count;
224
		files_mas[cur]=j;
265
		files_mas[cur]=j;
225
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
266
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
226
		select_list.count++;
267
		select_list.count++;
227
	}
268
	}
Line 263... Line 304...
263
{
304
{
264
	tabs.click(N);
305
	tabs.click(N);
265
	if (tabs.active_tab == SKINS) 
306
	if (tabs.active_tab == SKINS) 
266
	{
307
	{
267
		active_wallpaper = select_list.cur_y;
308
		active_wallpaper = select_list.cur_y;
268
		strcpy(#folder_path, SKINS_STANDART_PATH);
309
		strcpy(#folder_path, #skins_folder_path);
269
		select_list.ClearList();
310
		select_list.ClearList();
270
		Open_Dir();
311
		Open_Dir();
271
		if (!select_list.count) notify("'No skins were found' -E");
312
		if (!select_list.count) notify("'No skins were found' -E");
272
		select_list.cur_y = active_skin;
313
		select_list.cur_y = active_skin;
273
	}
314
	}
274
	if (tabs.active_tab == WALLPAPERS)
315
	if (tabs.active_tab == WALLPAPERS)
275
	{
316
	{
276
		active_skin = select_list.cur_y;
317
		active_skin = select_list.cur_y;
277
		strcpy(#folder_path, WALP_STANDART_PATH);
318
		strcpy(#folder_path, #wallp_folder_path);
278
		select_list.ClearList();
319
		select_list.ClearList();
279
		Open_Dir();
320
		Open_Dir();
280
		if (!select_list.count) notify("'No wallpapers were found' -E");
321
		if (!select_list.count) notify("'No wallpapers were found' -E");
281
		select_list.cur_y = active_wallpaper;
322
		select_list.cur_y = active_wallpaper;
282
	}
323
	}
Line 289... Line 330...
289
	io.del(#cur_file_path);
330
	io.del(#cur_file_path);
290
	Open_Dir();
331
	Open_Dir();
291
	EventApply();
332
	EventApply();
292
}
333
}
Line -... Line 334...
-
 
334
 
-
 
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
}
293
 
349
 
294
void EventApply()
350
void EventApply()
-
 
351
{
-
 
352
	char kivpath[4096+10];
295
{
353
	EventSetNewCurrent();
296
	if (tabs.active_tab==SKINS)
354
	if (tabs.active_tab==SKINS)
297
	{
355
	{
298
		cur = select_list.cur_y;
-
 
299
		sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur]));
356
		cur = select_list.cur_y;
300
		SetSystemSkin(#cur_file_path);
357
		SetSystemSkin(#cur_file_path);
301
	} 
358
	} 
302
	if (tabs.active_tab==WALLPAPERS)
359
	if (tabs.active_tab==WALLPAPERS)
303
	{
360
	{
304
		cur = select_list.cur_y;
361
		strcpy(#kivpath, "\\S__");
305
		sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur]));
362
		strcat(#kivpath, #cur_file_path);
306
		RunProgram("/sys/media/kiv", #cur_file_path);
363
		RunProgram("/sys/media/kiv", #kivpath);
307
		SelectList_Draw();
364
		SelectList_Draw();
308
	}
365
	}
Line 309... Line 366...
309
}
366
}