Subversion Repositories Kolibri OS

Rev

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

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