Subversion Repositories Kolibri OS

Rev

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

Rev 4085 Rev 4410
1
//11.03.12 - start!
1
//11.03.12 - start!
2
 
2
 
3
#ifndef AUTOBUILD
3
#ifndef AUTOBUILD
4
	?include "lang.h--"
4
	?include "lang.h--"
5
#endif
5
#endif
6
 
6
 
7
#define MEMSIZE 0xFE800
7
#define MEMSIZE 0xFE800
8
#include "..\lib\kolibri.h"
8
#include "..\lib\kolibri.h"
9
#include "..\lib\mem.h"
9
#include "..\lib\mem.h"
10
#include "..\lib\strings.h"
10
#include "..\lib\strings.h"
11
#include "..\lib\dll.h"
11
#include "..\lib\dll.h"
12
#include "..\lib\file_system.h"
12
#include "..\lib\file_system.h"
13
#include "..\lib\list_box.h"
13
#include "..\lib\list_box.h"
14
#include "..\lib\figures.h"
14
#include "..\lib\figures.h"
15
#include "..\lib\lib.obj\box_lib.h"
15
#include "..\lib\lib.obj\box_lib.h"
16
 
16
 
17
#ifdef LANG_RUS
17
#ifdef LANG_RUS
18
	?define WINDOW_HEADER "“á¯à ¢«¥­¨¥ ⥬®©"
18
	?define WINDOW_HEADER "“á¯à ¢«¥­¨¥ ⥬®©"
19
	?define T_SKINS       "Žª­ "
19
	?define T_SKINS       "’¥¬  ®ª®­"
20
	?define T_WALLPAPERS  "Ž¡®¨ à ¡®ç¥£® á⮫ "
20
	?define T_WALLPAPERS  "Ž¡®¨ à ¡®ç¥£® á⮫ "
21
#else
21
#else
22
	?define WINDOW_HEADER "Appearance"
22
	?define WINDOW_HEADER "Appearance"
23
	?define T_SKINS       "Skins"
23
	?define T_SKINS       "Skins"
24
	?define T_WALLPAPERS  "Wallpappers"
24
	?define T_WALLPAPERS  "Wallpappers"
25
#endif
25
#endif
-
 
26
 
-
 
27
unsigned char icons[sizeof(file "icons.raw")]= FROM "icons.raw";
26
 
28
 
27
 
29
 
28
#define PANEL_H 30
30
#define PANEL_H 30
29
#define SKINS_STANDART_PATH "/sys/skins/"
31
#define SKINS_STANDART_PATH "/sys/res/skins/"
30
#define WALP_STANDART_PATH "/sys/wallpapers/"
32
#define WALP_STANDART_PATH "/sys/res/wallpapers/"
31
 
33
 
32
llist list[2];
34
llist list[2];
33
int active;
35
int active;
34
enum { SKINS, WALLPAPERS };
36
enum { WALLPAPERS, SKINS };
35
 
37
 
36
char folder_path[4096];
38
char folder_path[4096];
37
char cur_file_path[4096];
39
char cur_file_path[4096];
38
char temp_filename[4096];
40
char temp_filename[4096];
39
int files_mas[100];
41
int files_mas[100];
40
dword buf;
42
dword buf;
41
 
43
 
42
int cur;
44
int cur;
43
 
45
 
44
system_colors sc;
46
system_colors sc;
45
proc_info Form;
47
proc_info Form;
46
 
48
 
47
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};
49
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};
48
 
50
 
49
#include "other.h"
51
#include "other.h"
50
 
52
 
51
//icons configurate, delete from list, delete from disk, make default
53
//icons configurate, delete from list, delete from disk, make default
52
//remember current
54
//remember current
53
 
55
 
54
void Open_Dir()
56
void Open_Dir()
55
{
57
{
56
	int j, filesnum;
58
	int j, filesnum;
57
 
59
 
58
	list[active].count = 0;
60
	list[active].count = 0;
59
	free(buf);
61
	free(buf);
60
	if (GetDir(#buf, #filesnum, #folder_path, DIRS_ONLYREAL)!=0) return;
62
	if (GetDir(#buf, #filesnum, #folder_path, DIRS_ONLYREAL)!=0) return;
61
 
63
 
62
	for (j=0; j
64
	for (j=0; j
63
	{
65
	{
64
		strlwr(j*304 + buf+72);
-
 
65
		strcpy(#temp_filename, j*304 + buf+72);
66
		strcpy(#temp_filename, j*304 + buf+72);
-
 
67
		strlwr(#temp_filename);
66
		if (active==SKINS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
68
		if (active==SKINS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
67
		if (active==WALLPAPERS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
69
		if (active==WALLPAPERS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
68
		cur = list[active].count;
70
		cur = list[active].count;
69
		files_mas[cur]=j;
71
		files_mas[cur]=j;
70
		if (!strcmp("default.skn",#temp_filename)) files_mas[0]>
72
		if (!strcmp("default.skn",#temp_filename)) files_mas[0]>
71
		list[active].count++;
73
		list[active].count++;
72
	}
74
	}
73
	Sort_by_Name(0, list[active].count-1); 
75
	Sort_by_Name(0, list[active].count-1); 
74
}
76
}
75
 
77
 
76
void Draw_List()
78
void Draw_List()
77
{
79
{
78
	int i;
80
	int i;
-
 
81
	int yyy;
79
	list[SKINS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
82
	list[SKINS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
80
	list[WALLPAPERS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
83
	list[WALLPAPERS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
81
	
84
	
82
	for (i=0; i
85
	for (i=0; i
83
	{
86
	{
84
		cur = list[active].first;
87
		cur = list[active].first;
85
		strcpy(#temp_filename, files_mas[i+cur]*304 + buf+72);
88
		strcpy(#temp_filename, files_mas[i+cur]*304 + buf+72);
-
 
89
		temp_filename[strlen(#temp_filename)-4] = 0;
-
 
90
		yyy = i*list[active].line_h+list[active].y;
86
		
91
		
87
		if (list[active].current-list[active].first==i)
92
		if (list[active].current-list[active].first==i)
88
		{
93
		{
89
			if (sc.work_button<>sc.work)
94
			if (sc.work_button<>sc.work)
90
			{
95
			{
91
				DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.work_button);
96
				DrawBar(0, yyy, list[active].w, list[active].line_h, sc.work_button);
92
				WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.work_button_text, #temp_filename);
97
				WriteText(11+23,yyy+list[active].text_y,0x80,sc.work_button_text, #temp_filename);
93
			}
98
			}
94
			else
99
			else
95
			{
100
			{
96
				DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.grab_button);
101
				DrawBar(0, yyy, list[active].w, list[active].line_h, sc.grab_button);
97
				WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.grab_button_text, #temp_filename);
102
				WriteText(11+23,yyy+list[active].text_y,0x80,sc.grab_button_text, #temp_filename);
98
			}	
103
			}
99
		}
104
		}
100
		else
105
		else
101
		{
106
		{
102
			DrawBar(0,i*list[active].line_h+list[active].y,list[active].w, list[active].line_h, 0xFFFfff);
107
			DrawBar(0,yyy,list[active].w, list[active].line_h, 0xFFFfff);
103
			WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,0, #temp_filename);
108
			WriteText(11+23,yyy+list[active].text_y,0x80,0, #temp_filename);
104
		}
109
		}
-
 
110
		_PutImage(11,yyy+2,  16,15,   list[WALLPAPERS].active*16*15*3+#icons);
105
	}
111
	}
106
	DrawBar(0,list[active].visible*list[active].line_h+list[active].y, list[active].w, -list[active].visible*list[active].line_h+ list[active].h, 0xFFFfff);
112
	DrawBar(0,list[active].visible*list[active].line_h+list[active].y, list[active].w, -list[active].visible*list[active].line_h+ list[active].h, 0xFFFfff);
107
	DrawScroller();
113
	DrawScroller();
108
}
114
}
109
 
115
 
110
void GetFiles(int set_active)
116
void GetFiles()
111
{
-
 
112
	active = set_active;
117
{
113
	if (active==SKINS)
118
	if (list[SKINS].active)
114
	{
119
	{
115
		strcpy(#folder_path, SKINS_STANDART_PATH);
120
		strcpy(#folder_path, SKINS_STANDART_PATH);
116
		Open_Dir();
121
		Open_Dir();
117
		if (!list[active].count) notify("No skins were found");
122
		if (!list[active].count) notify("No skins were found");
118
	}
123
	}
119
	if (active==WALLPAPERS)
124
	if (list[WALLPAPERS].active)
120
	{
125
	{
121
		strcpy(#folder_path, WALP_STANDART_PATH);
126
		strcpy(#folder_path, WALP_STANDART_PATH);
122
		Open_Dir();
127
		Open_Dir();
123
		if (!list[active].count) notify("No wallpapers were found");
128
		if (!list[active].count) notify("No wallpapers were found");
124
	}
129
	}
125
}
130
}
126
 
131
 
127
void Apply()
132
void Apply()
128
{
133
{
129
	if (active==SKINS)
134
	if (list[SKINS].active)
130
	{
135
	{
131
		strcpy(#cur_file_path, #folder_path);
136
		strcpy(#cur_file_path, #folder_path);
132
		cur = list[active].current;
137
		cur = list[SKINS].current;
133
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
138
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
134
		SetSystemSkin(#cur_file_path);
139
		SetSystemSkin(#cur_file_path);
-
 
140
		//Draw_List();
135
	} 
141
	} 
136
	if (active==WALLPAPERS)
142
	if (list[WALLPAPERS].active)
137
	{
143
	{
138
		strcpy(#cur_file_path, "\\S__");
144
		strcpy(#cur_file_path, "\\S__");
139
		strcat(#cur_file_path, #folder_path);
145
		strcat(#cur_file_path, #folder_path);
140
		cur = list[active].current;
146
		cur = list[WALLPAPERS].current;
141
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
147
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
142
		RunProgram("/sys/media/kiv", #cur_file_path);
148
		RunProgram("/sys/media/kiv", #cur_file_path);
143
		Draw_List();
149
		Draw_List();
144
	}
150
	}
145
}
151
}
146
 
152
 
147
OpenFile()
153
OpenFile()
148
{
154
{
149
	if (active==SKINS) RunProgram("/sys/desktop", #cur_file_path);
155
	if (list[SKINS].active) RunProgram("/sys/desktop", #cur_file_path);
150
	if (active==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
156
	if (list[WALLPAPERS].active) RunProgram("/sys/media/kiv", #cur_file_path);
151
}
157
}
152
 
158
 
153
 
159
 
154
void main()
160
void main()
155
{   
161
{   
156
	int id, key, mouse_clicked;
162
	int id, key, mouse_clicked;
157
	mouse mm;
163
	mouse mm;
158
 
164
 
159
	mem_Init();
165
	mem_Init();
-
 
166
	SetEventMask(0x27);
160
	if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("Fatal Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
167
	if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("Fatal Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
161
	list[SKINS].current = list[WALLPAPERS].current = -1;
168
	list[SKINS].current = list[WALLPAPERS].current = -1;
162
	list[SKINS].first = list[WALLPAPERS].first = 0;
169
	list[SKINS].first = list[WALLPAPERS].first = 0;
163
	GetFiles(WALLPAPERS);
170
	TabClick(WALLPAPERS);
164
	list[active].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
171
	list[WALLPAPERS].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
165
	SetEventMask(0x27);
172
	list[SKINS].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
166
	loop()
173
	loop()
167
	{
174
	{
168
	  switch(WaitEvent()) 
175
	  switch(WaitEvent()) 
169
	  {
176
	  {
170
	  	case evMouse:
177
	  	case evMouse:
171
			if (!CheckActiveProcess(Form.ID)) break;
178
			if (!CheckActiveProcess(Form.ID)) break;
172
			scrollbar_v_mouse (#scroll1);
179
			scrollbar_v_mouse (#scroll1);
173
			if (list[active].first <> scroll1.position)
180
			if (list[active].first <> scroll1.position)
174
			{
181
			{
175
				list[active].first = scroll1.position;
182
				list[active].first = scroll1.position;
176
				Draw_List();
183
				Draw_List();
177
				break;
184
				break;
178
			}
185
			}
179
		
186
		
180
	  		mm.get();
187
	  		mm.get();
-
 
188
 
-
 
189
	  		if (mm.vert)
-
 
190
	  		{
181
	  		if (mm.vert) && (list[active].MouseScroll(mm.vert)) Draw_List();
191
	  			if (list[SKINS].active) && (list[SKINS].MouseScroll(mm.vert)) Draw_List();
-
 
192
	  			if (list[WALLPAPERS].active) && (list[WALLPAPERS].MouseScroll(mm.vert)) Draw_List();
-
 
193
	  		} 
-
 
194
 
182
	  		if (mouse_clicked)
195
	  		if (mouse_clicked)
183
	  		{
196
	  		{
184
	  			if (!mm.lkm) && (active==SKINS) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
197
	  			if (!mm.lkm) && (list[SKINS].active) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
185
	  			if (!mm.lkm) && (active==WALLPAPERS) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
198
	  			if (!mm.lkm) && (list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
186
	  			mouse_clicked=0;
199
	  			mouse_clicked=0;
187
	  		}
200
	  		}
188
	  		if (mm.lkm) && (list[SKINS].MouseOver(mm.x, mm.y)) mouse_clicked=1;
201
	  		if (mm.lkm) && (list[SKINS].MouseOver(mm.x, mm.y)) mouse_clicked=1;
189
	  		break;
202
	  		break;
-
 
203
 
190
 
204
 
191
		case evButton:
205
		case evButton:
192
			id=GetButtonID();
206
			id=GetButtonID();
193
			if (id==1) ExitProcess();
207
			if (id==1) ExitProcess();
194
			if (id==2) TabClick(SKINS);
208
			if (id==2) TabClick(WALLPAPERS);
195
			if (id==3) TabClick(WALLPAPERS);
209
			if (id==3) TabClick(SKINS);
196
			break;
210
			break;
197
	  
211
	  
198
		case evKey:
212
		case evKey:
199
			key = GetKey();
213
			key = GetKey();
200
			if (active==SKINS) && (list[SKINS].ProcessKey(key)) Apply();
214
			if (list[SKINS].active) && (list[SKINS].ProcessKey(key)) Apply();
201
			if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessKey(key)) Apply();
215
			if (list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessKey(key)) Apply();
202
			IF (key==013) OpenFile();
216
			IF (key==013) OpenFile();
203
			if (key==9) //Tab
-
 
204
			{
-
 
205
				if (active==SKINS)
-
 
206
					TabClick(WALLPAPERS);
217
			if (key==9) if (list[SKINS].active) TabClick(WALLPAPERS); else TabClick(SKINS);
207
				else
-
 
208
					TabClick(SKINS);
-
 
209
			}
-
 
210
			IF (key==182) //Del
218
			IF (key==182) //Del
211
			{
219
			{
212
				DeleteFile(#cur_file_path);
220
				DeleteFile(#cur_file_path);
213
				Open_Dir();
221
				Open_Dir();
214
				Apply();
222
				Apply();
215
			}
223
			}
216
			break;
224
			break;
217
		 
225
		 
218
		 case evReDraw:
226
		 case evReDraw:
219
			sc.get();			
227
			sc.get();			
220
			DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER);
228
			DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER,0);
221
			GetProcessInfo(#Form, SelfInfo);
229
			GetProcessInfo(#Form, SelfInfo);
222
			IF (Form.status_window>=2) break;
230
			IF (Form.status_window>=2) break;
223
			DrawTabs();
231
			DrawTabs();
224
			Draw_List();
232
			Draw_List();
225
	  }
233
	  }
226
   }
234
   }
227
}
235
}
-
 
236
 
228
 
237
#define BT_PADDING 16
229
 
238
 
230
void DrawTabs()
239
void DrawTab(dword x,y, but_id, is_active, text)
-
 
240
{
-
 
241
	dword col_bg, col_text;
-
 
242
	dword w=strlen(text)*6+BT_PADDING, h=21;
-
 
243
 
-
 
244
	if (is_active)
-
 
245
	{
-
 
246
		col_bg=sc.work_button;
-
 
247
		col_text=sc.work_button_text;
-
 
248
	}
-
 
249
	else
-
 
250
	{
-
 
251
		col_bg=sc.work;
-
 
252
		col_text=sc.work_text;
-
 
253
	} 
-
 
254
	DrawRectangle(x,y, w,h, sc.work_graph);
-
 
255
	DrawCaptButton(x+1,y+1, w-2,h-1, but_id, col_bg, col_text, text);
-
 
256
}
-
 
257
 
-
 
258
 
231
{
259
void DrawTabs()
232
	dword col_bg, col_text;
-
 
233
	DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work);
-
 
234
 
-
 
235
	if (active==SKINS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} 
-
 
236
	DrawRectangle(10-1,7-1, 65+2, 21+2, sc.work_graph);
260
{
237
	DrawCaptButton(10,7, 65, 21, 2, col_bg, col_text, T_SKINS); //¢®ªà㣠à¨á®¢ âì ¯¬ïâ®ã£
261
	DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work);
238
	if (active==WALLPAPERS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} 
262
 
239
	DrawRectangle(90-1,7-1, strlen(T_WALLPAPERS)*6+16+2, 21+2, sc.work_graph);
263
	DrawTab(10,7, 2, list[WALLPAPERS].active, T_WALLPAPERS);
240
	DrawCaptButton(90,7, strlen(T_WALLPAPERS)*6+16, 21, 3, col_bg, col_text, T_WALLPAPERS);
264
	DrawTab(strlen(T_WALLPAPERS)*6+BT_PADDING+21,7, 3, list[SKINS].active, T_SKINS);
241
 
265
 
242
	DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph);
266
	DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph);
243
	DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
267
	DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
244
}
268
}
245
 
269
 
246
void TabClick(int N)
270
void TabClick(int N)
247
{
271
{
-
 
272
	if (N==SKINS) 
-
 
273
	{
-
 
274
		list[SKINS].active = 1;	
-
 
275
		list[WALLPAPERS].active = 0;	
-
 
276
	}
-
 
277
	if (N==WALLPAPERS) 
-
 
278
	{
-
 
279
		list[SKINS].active = 0;	
-
 
280
		list[WALLPAPERS].active = 1;	
-
 
281
	}
-
 
282
	active = N;
248
	GetFiles(N);
283
	GetFiles();
249
	DrawTabs();
284
	DrawTabs();
250
	Draw_List();
285
	Draw_List();
251
}
286
}
252
 
287
 
253
 
288
 
254
void DrawScroller()
289
void DrawScroller()
255
{
290
{
256
	scroll1.bckg_col = 0xBBBbbb;
291
	scroll1.bckg_col = 0xBBBbbb;
257
	scroll1.frnt_col = sc.work;
292
	scroll1.frnt_col = sc.work;
258
	scroll1.line_col = sc.work_graph;
293
	scroll1.line_col = sc.work_graph;
259
 
294
 
260
	scroll1.max_area = list[active].count;
295
	scroll1.max_area = list[active].count;
261
	scroll1.cur_area = list[active].visible;
296
	scroll1.cur_area = list[active].visible;
262
	scroll1.position = list[active].first;
297
	scroll1.position = list[active].first;
263
 
298
 
264
	scroll1.all_redraw=1;
299
	scroll1.all_redraw=1;
265
	scroll1.start_x = list[active].x + list[active].w;
300
	scroll1.start_x = list[active].x + list[active].w;
266
	scroll1.start_y = list[active].y-2;
301
	scroll1.start_y = list[active].y-2;
267
	scroll1.size_y = list[active].h+2;
302
	scroll1.size_y = list[active].h+2;
268
 
303
 
269
	scrollbar_v_draw(#scroll1);
304
	scrollbar_v_draw(#scroll1);
270
}
305
}
271
 
306
 
272
 
307
 
273
stop:
308
stop:
274
>
309
>