Subversion Repositories Kolibri OS

Rev

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

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