Subversion Repositories Kolibri OS

Rev

Rev 7252 | Rev 7349 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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