Subversion Repositories Kolibri OS

Rev

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

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