Subversion Repositories Kolibri OS

Rev

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

Rev 6253 Rev 6264
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
 
16
 
17
 
17
 
18
//===================================================//
18
//===================================================//
19
//                                                   //
19
//                                                   //
20
//                       DATA                        //
20
//                       DATA                        //
21
//                                                   //
21
//                                                   //
22
//===================================================//
22
//===================================================//
23
 
23
 
24
#ifdef LANG_RUS
24
#ifdef LANG_RUS
25
	?define WINDOW_HEADER " áâனª¨ ®ä®à¬«¥­¨ï"
25
	?define WINDOW_HEADER " áâனª¨ ®ä®à¬«¥­¨ï"
26
	?define T_SKINS       "   ‘â¨«ì ®ª®­"
26
	?define T_SKINS       "‘â¨«ì ®ª®­"
27
	?define T_WALLPAPERS  "   Ž¡®¨"
27
	?define T_WALLPAPERS  "Ž¡®¨"
28
#else
28
#else
29
	?define WINDOW_HEADER "Appearance"
29
	?define WINDOW_HEADER "Appearance"
30
	?define T_SKINS       "   Skins"
30
	?define T_SKINS       "Skins"
31
	?define T_WALLPAPERS  "   Wallpappers"
31
	?define T_WALLPAPERS  "Wallpappers"
32
#endif
32
#endif
33
 
-
 
34
unsigned char icons[]= FROM "icons.raw";
-
 
35
 
33
 
36
#define PANEL_H 40
34
#define PANEL_H 40
37
#define LIST_PADDING 20
-
 
38
#define TAB_PADDING 16
-
 
39
#define TAB_HEIGHT 25
35
#define LIST_PADDING 20
40
#define SKINS_STANDART_PATH "/kolibrios/res/skins"							
36
#define SKINS_STANDART_PATH "/kolibrios/res/skins"							
41
#define WALP_STANDART_PATH "/kolibrios/res/wallpapers"
37
#define WALP_STANDART_PATH "/kolibrios/res/wallpapers"
42
 
38
 
43
llist list;
39
llist list;
44
signed int active_tab, active_skin=-1, active_wallpaper=-1;
40
signed int active_skin=-1, active_wallpaper=-1;
45
enum { SKINS=2, WALLPAPERS };
41
enum { SKINS=2, WALLPAPERS };
46
 
42
 
47
char folder_path[4096];
43
char folder_path[4096];
48
char cur_file_path[4096];
44
char cur_file_path[4096];
49
char temp_filename[4096];
45
char temp_filename[4096];
50
int files_mas[400];
46
int files_mas[400];
51
 
47
 
52
int cur;
48
int cur;
53
 
49
 
54
proc_info Form;
50
proc_info Form;
55
 
51
 
56
scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
52
scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
57
 
53
 
58
 
54
 
59
//===================================================//
55
//===================================================//
60
//                                                   //
56
//                                                   //
61
//                       CODE                        //
57
//                       CODE                        //
62
//                                                   //
58
//                                                   //
63
//===================================================//
59
//===================================================//
64
 
60
 
65
void main()
61
void main()
66
{   
62
{   
67
	int id, mouse_clicked;
63
	int id, mouse_clicked;
68
 
64
 
69
	SetEventMask(0x27);
65
	SetEventMask(0x27);
70
	load_dll(boxlib, #box_lib_init,0);
66
	load_dll(boxlib, #box_lib_init,0);
71
	EventTabClick(SKINS);
67
	EventTabClick(SKINS);
72
	loop() switch(WaitEvent()) 
68
	loop() switch(WaitEvent()) 
73
	{
69
	{
74
	  	case evMouse:
70
	  	case evMouse:
75
			if (!CheckActiveProcess(Form.ID)) break;
71
			if (!CheckActiveProcess(Form.ID)) break;
76
			mouse.get();
72
			mouse.get();
77
			scrollbar_v_mouse (#scroll1);
73
			scrollbar_v_mouse (#scroll1);
78
			if (list.first != scroll1.position)
74
			if (list.first != scroll1.position)
79
			{
75
			{
80
				list.first = scroll1.position;
76
				list.first = scroll1.position;
81
				Draw_List();
77
				Draw_List();
82
				break;
78
				break;
83
			}
79
			}
84
 
80
 
85
	  		if (mouse.vert) && (list.MouseScroll(mouse.vert)) Draw_List();
81
	  		if (mouse.vert) && (list.MouseScroll(mouse.vert)) Draw_List();
86
 
82
 
87
	  		if (mouse.up)&&(mouse_clicked)
83
	  		if (mouse.up)&&(mouse_clicked)
88
	  		{
84
	  		{
89
	  			if (mouse.lkm) && (list.ProcessMouse(mouse.x, mouse.y)) EventApply();
85
	  			if (mouse.lkm) && (list.ProcessMouse(mouse.x, mouse.y)) EventApply();
90
	  			mouse_clicked=false;
86
	  			mouse_clicked=false;
91
	  		}
87
	  		}
92
	  		else if (mouse.down)&&(mouse.lkm) && (list.MouseOver(mouse.x, mouse.y)) mouse_clicked=true;
88
	  		else if (mouse.down)&&(mouse.lkm) && (list.MouseOver(mouse.x, mouse.y)) mouse_clicked=true;
93
 
89
 
94
	  		if (mouse.down)&&(mouse.pkm) {
90
	  		if (mouse.down)&&(mouse.pkm) {
95
	  			list.ProcessMouse(mouse.x, mouse.y);
91
	  			list.ProcessMouse(mouse.x, mouse.y);
96
				Draw_List();
92
				Draw_List();
97
	  			menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 136, "Open file     Enter\nDelete          Del", 10); 
93
	  			menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 136, "Open file     Enter\nDelete          Del", 10); 
98
	  		}
94
	  		}
99
 
95
 
100
	  		break;
96
	  		break;
101
 
97
 
102
 
98
 
103
		case evButton:
99
		case evButton:
104
			id=GetButtonID();
100
			id=GetButtonID();
105
			if (id==1) ExitProcess();
101
			if (id==1) ExitProcess();
106
			if (id==SKINS) EventTabClick(SKINS);
102
			if (id==SKINS) EventTabClick(SKINS);
107
			if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
103
			if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
108
			break;
104
			break;
109
	  
105
	  
110
		case evKey:
106
		case evKey:
111
			GetKeys(); 
107
			GetKeys(); 
112
			if (list.ProcessKey(key_scancode)) EventApply();
108
			if (list.ProcessKey(key_scancode)) EventApply();
113
			if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
109
			if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
114
			if (key_scancode==SCAN_CODE_TAB) if (active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS);
110
			if (key_scancode==SCAN_CODE_TAB) if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS);
115
			if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
111
			if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
116
			for (id=list.cur_y+1; id
112
			for (id=list.cur_y+1; id
117
			{
113
			{
118
				strcpy(#temp_filename, io.dir.position(files_mas[id]));
114
				strcpy(#temp_filename, io.dir.position(files_mas[id]));
119
				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)
120
				{
116
				{
121
					list.cur_y = id - 1;
117
					list.cur_y = id - 1;
122
					list.KeyDown();
118
					list.KeyDown();
123
					EventApply();
119
					EventApply();
124
					break;
120
					break;
125
				}
121
				}
126
			}
122
			}
127
			break;
123
			break;
128
		 
124
		 
129
		 case evReDraw:
125
		 case evReDraw:
130
			system.color.get();			
126
			system.color.get();			
131
			DefineAndDrawWindow(screen.width-400/2,80,400,404+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0);
127
			DefineAndDrawWindow(screen.width-400/2,80,400,404+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0);
132
			GetProcessInfo(#Form, SelfInfo);
128
			GetProcessInfo(#Form, SelfInfo);
133
			IF (Form.status_window>=2) break;
129
			IF (Form.status_window>=2) break;
134
		 	DrawWindowContent();
130
		 	DrawWindowContent();
135
		 	debugi(menu.list.cur_y);
131
		 	debugi(menu.list.cur_y);
136
	 		if (menu.list.cur_y) {
132
	 		if (menu.list.cur_y) {
137
				if (menu.list.cur_y == 10) EventOpenFile();
133
				if (menu.list.cur_y == 10) EventOpenFile();
138
				if (menu.list.cur_y == 11) EventDeleteFile();
134
				if (menu.list.cur_y == 11) EventDeleteFile();
139
				menu.list.cur_y = 0;
135
				menu.list.cur_y = 0;
140
			};
136
			};
141
   }
137
   }
142
}
138
}
143
 
139
 
144
void DrawWindowContent()
140
void DrawWindowContent()
145
{
141
{
146
	int id;
142
	int id;
147
	list.SetFont(8, 14, 0x90);
143
	list.SetFont(8, 14, 0x90);
148
	id = list.cur_y;
144
	id = list.cur_y;
149
	list.SetSizes(LIST_PADDING, PANEL_H, Form.cwidth-scroll1.size_x-LIST_PADDING-LIST_PADDING, Form.cheight-PANEL_H-LIST_PADDING, 20);
145
	list.SetSizes(LIST_PADDING, PANEL_H, Form.cwidth-scroll1.size_x-LIST_PADDING-LIST_PADDING, Form.cheight-PANEL_H-LIST_PADDING, 20);
150
	list.cur_y = id;
146
	list.cur_y = id;
151
 
147
 
152
	DrawBar(0,0, Form.cwidth, PANEL_H-LIST_PADDING, system.color.work);
148
	DrawBar(0,0, Form.cwidth, PANEL_H-LIST_PADDING, system.color.work);
153
	DrawRectangle3D(list.x-2, list.y-2, list.w+3+scroll1.size_x, list.h+3, system.color.work_dark, system.color.work_light);
149
	DrawRectangle3D(list.x-2, list.y-2, list.w+3+scroll1.size_x, list.h+3, system.color.work_dark, system.color.work_light);
154
	DrawWideRectangle(list.x-LIST_PADDING, list.y-LIST_PADDING, LIST_PADDING*2+list.w+scroll1.size_x, LIST_PADDING*2+list.h, LIST_PADDING-2, system.color.work);
150
	DrawWideRectangle(list.x-LIST_PADDING, list.y-LIST_PADDING, LIST_PADDING*2+list.w+scroll1.size_x, LIST_PADDING*2+list.h, LIST_PADDING-2, system.color.work);
155
	DrawTab(list.x+10, list.y, SKINS, T_SKINS);
151
	tabs.draw(list.x+10, list.y, SKINS, T_SKINS);
156
	if (dir_exists(WALP_STANDART_PATH)) DrawTab(strlen(T_SKINS)*8+TAB_PADDING+list.x+21, list.y, WALLPAPERS, T_WALLPAPERS);
152
	if (dir_exists(WALP_STANDART_PATH)) tabs.draw(strlen(T_SKINS)*8+TAB_PADDING+list.x+21, list.y, WALLPAPERS, T_WALLPAPERS);
157
	DrawRectangle(list.x-1, list.y-1, list.w+1+scroll1.size_x, list.h+1, system.color.work_graph);
153
	DrawRectangle(list.x-1, list.y-1, list.w+1+scroll1.size_x, list.h+1, system.color.work_graph);
158
 
154
 
159
	Draw_List();
155
	Draw_List();
160
}
156
}
161
 
-
 
162
void DrawTab(dword x,y, but_id, text)
-
 
163
{
-
 
164
	dword col_bg, col_text;
-
 
165
	dword w=strlen(text)*8+TAB_PADDING, h=TAB_HEIGHT;
-
 
166
	y -= h;
-
 
167
 
-
 
168
	if (but_id==active_tab)
-
 
169
	{
-
 
170
		col_bg=system.color.work_button;
-
 
171
		col_text=system.color.work_button_text;
-
 
172
	}
-
 
173
	else
-
 
174
	{
-
 
175
		col_bg=system.color.work;
-
 
176
		col_text=system.color.work_text;
-
 
177
	} 
-
 
178
	DrawCaptButton(x,y, w-1,h+1, but_id, col_bg, col_text, text);
-
 
179
	_PutImage(x+10,h-16/2+y+1,  16,15,   but_id-2*16*15*3+#icons);
-
 
180
}
-
 
181
 
157
 
182
void DrawScroller()
158
void DrawScroller()
183
{
159
{
184
	scroll1.bckg_col = MixColors(system.color.work, 0xBBBbbb, 80);
160
	scroll1.bckg_col = MixColors(system.color.work, 0xBBBbbb, 80);
185
	scroll1.frnt_col = MixColors(system.color.work,0xFFFfff,120);
161
	scroll1.frnt_col = MixColors(system.color.work,0xFFFfff,120);
186
	scroll1.line_col = system.color.work_graph;
162
	scroll1.line_col = system.color.work_graph;
187
 
163
 
188
	scroll1.max_area = list.count;
164
	scroll1.max_area = list.count;
189
	scroll1.cur_area = list.visible;
165
	scroll1.cur_area = list.visible;
190
	scroll1.position = list.first;
166
	scroll1.position = list.first;
191
 
167
 
192
	scroll1.all_redraw=1;
168
	scroll1.all_redraw=1;
193
	scroll1.start_x = list.x + list.w;
169
	scroll1.start_x = list.x + list.w;
194
	scroll1.start_y = list.y-1;
170
	scroll1.start_y = list.y-1;
195
	scroll1.size_y = list.h+2;
171
	scroll1.size_y = list.h+2;
196
 
172
 
197
	scrollbar_v_draw(#scroll1);
173
	scrollbar_v_draw(#scroll1);
198
}
174
}
199
 
175
 
200
void Open_Dir()
176
void Open_Dir()
201
{
177
{
202
	int j;
178
	int j;
203
	list.count = 0;
179
	list.count = 0;
204
	if(io.dir.buffer)free(io.dir.buffer);
180
	if(io.dir.buffer)free(io.dir.buffer);
205
	io.dir.load(#folder_path,DIR_ONLYREAL);
181
	io.dir.load(#folder_path,DIR_ONLYREAL);
206
	for (j=0; j
182
	for (j=0; j
207
	{
183
	{
208
		strcpy(#temp_filename, io.dir.position(j));
184
		strcpy(#temp_filename, io.dir.position(j));
209
		strlwr(#temp_filename);
185
		strlwr(#temp_filename);
210
		if (active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
186
		if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
211
		if (active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
187
		if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
212
		cur = list.count;
188
		cur = list.count;
213
		files_mas[cur]=j;
189
		files_mas[cur]=j;
214
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
190
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
215
		list.count++;
191
		list.count++;
216
	}
192
	}
217
}
193
}
218
 
194
 
219
void Draw_List()
195
void Draw_List()
220
{
196
{
221
	int i, yyy, list_last;
197
	int i, yyy, list_last;
222
 
198
 
223
	if (list.count > list.visible) list_last = list.visible; else list_last = list.count;
199
	if (list.count > list.visible) list_last = list.visible; else list_last = list.count;
224
 
200
 
225
	for (i=0; (i
201
	for (i=0; (i
226
	{
202
	{
227
		cur = list.first + i;
203
		cur = list.first + i;
228
		strcpy(#temp_filename, io.dir.position(files_mas[cur]));
204
		strcpy(#temp_filename, io.dir.position(files_mas[cur]));
229
		temp_filename[strlen(#temp_filename)-4] = 0;
205
		temp_filename[strlen(#temp_filename)-4] = 0;
230
		yyy = i*list.item_h+list.y;
206
		yyy = i*list.item_h+list.y;
231
		
207
		
232
		if (list.cur_y-list.first==i)
208
		if (list.cur_y-list.first==i)
233
		{
209
		{
234
			DrawBar(list.x, yyy, list.w, list.item_h, system.color.work_button);
210
			DrawBar(list.x, yyy, list.w, list.item_h, system.color.work_button);
235
			WriteText(list.x+12,yyy+list.text_y,list.font_type,system.color.work_button_text, #temp_filename);
211
			WriteText(list.x+12,yyy+list.text_y,list.font_type,system.color.work_button_text, #temp_filename);
236
		}
212
		}
237
		else
213
		else
238
		{
214
		{
239
			DrawBar(list.x,yyy,list.w, list.item_h, 0xFFFfff);
215
			DrawBar(list.x,yyy,list.w, list.item_h, 0xFFFfff);
240
			WriteText(list.x+12,yyy+list.text_y,list.font_type,0, #temp_filename);
216
			WriteText(list.x+12,yyy+list.text_y,list.font_type,0, #temp_filename);
241
		}
217
		}
242
	}
218
	}
243
	DrawBar(list.x,i*list.item_h+list.y, list.w, -i*list.item_h+ list.h, 0xFFFfff);
219
	DrawBar(list.x,i*list.item_h+list.y, list.w, -i*list.item_h+ list.h, 0xFFFfff);
244
	DrawScroller();
220
	DrawScroller();
245
}
221
}
246
 
222
 
247
//===================================================//
223
//===================================================//
248
//                                                   //
224
//                                                   //
249
//                     EVENTS                        //
225
//                     EVENTS                        //
250
//                                                   //
226
//                                                   //
251
//===================================================//
227
//===================================================//
252
 
228
 
253
void EventTabClick(int N)
229
void EventTabClick(int N)
254
{
230
{
255
	active_tab = N;
231
	tabs.click(N);
256
	if (active_tab == SKINS) 
232
	if (tabs.active_tab == SKINS) 
257
	{
233
	{
258
		active_wallpaper = list.cur_y;
234
		active_wallpaper = list.cur_y;
259
		strcpy(#folder_path, SKINS_STANDART_PATH);
235
		strcpy(#folder_path, SKINS_STANDART_PATH);
260
		list.ClearList();
236
		list.ClearList();
261
		Open_Dir();
237
		Open_Dir();
262
		if (!list.count) notify("'No skins were found' -E");
238
		if (!list.count) notify("'No skins were found' -E");
263
		list.cur_y = active_skin;
239
		list.cur_y = active_skin;
264
	}
240
	}
265
	if (active_tab == WALLPAPERS) 
241
	if (tabs.active_tab == WALLPAPERS)
266
	{
242
	{
267
		active_skin = list.cur_y;
243
		active_skin = list.cur_y;
268
		strcpy(#folder_path, WALP_STANDART_PATH);
244
		strcpy(#folder_path, WALP_STANDART_PATH);
269
		list.ClearList();
245
		list.ClearList();
270
		Open_Dir();
246
		Open_Dir();
271
		if (!list.count) notify("'No wallpapers were found' -E");
247
		if (!list.count) notify("'No wallpapers were found' -E");
272
		list.cur_y = active_wallpaper;
248
		list.cur_y = active_wallpaper;
273
	}
249
	}
-
 
250
	if (list.cur_y>list.visible) list.first=list.cur_y; list.CheckDoesValuesOkey();
274
	if (list.w) DrawWindowContent();
251
	if (list.w) DrawWindowContent();
275
}
252
}
276
 
253
 
277
void EventDeleteFile()
254
void EventDeleteFile()
278
{
255
{
279
	io.del(#cur_file_path);
256
	io.del(#cur_file_path);
280
	Open_Dir();
257
	Open_Dir();
281
	EventApply();
258
	EventApply();
282
}
259
}
283
 
260
 
284
void EventApply()
261
void EventApply()
285
{
262
{
286
	if (active_tab==SKINS)
263
	if (tabs.active_tab==SKINS)
287
	{
264
	{
288
		cur = list.cur_y;
265
		cur = list.cur_y;
289
		sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur]));
266
		sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur]));
290
		SetSystemSkin(#cur_file_path);
267
		SetSystemSkin(#cur_file_path);
291
	} 
268
	} 
292
	if (active_tab==WALLPAPERS)
269
	if (tabs.active_tab==WALLPAPERS)
293
	{
270
	{
294
		cur = list.cur_y;
271
		cur = list.cur_y;
295
		sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur]));
272
		sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur]));
296
		RunProgram("/sys/media/kiv", #cur_file_path);
273
		RunProgram("/sys/media/kiv", #cur_file_path);
297
		Draw_List();
274
		Draw_List();
298
	}
275
	}
299
}
276
}
300
 
277
 
301
void EventOpenFile()
278
void EventOpenFile()
302
{
279
{
303
	if (active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path);
280
	if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path);
304
	if (active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
281
	if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
305
}
282
}
306
 
283
 
307
stop:
284
stop:
308
>
285
>