Subversion Repositories Kolibri OS

Rev

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

Rev 5705 Rev 5706
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 "/sys/skins"
28
#define SKINS_STANDART_PATH "/sys/skins"
29
							//"/kolibrios/res/skins"
29
							//"/kolibrios/res/skins"
30
							
30
							
31
#define WALP_STANDART_PATH "/kolibrios/res/wallpapers"
31
#define WALP_STANDART_PATH "/kolibrios/res/wallpapers"
32
 
32
 
33
llist list[2];
33
llist list[2];
34
int active;
34
int active;
35
enum { WALLPAPERS, SKINS };
35
enum { WALLPAPERS, SKINS };
36
 
36
 
37
char folder_path[4096];
37
char folder_path[4096];
38
char cur_file_path[4096];
38
char cur_file_path[4096];
39
char temp_filename[4096];
39
char temp_filename[4096];
40
int files_mas[100];
40
int files_mas[100];
41
 
41
 
42
int cur;
42
int cur;
43
 
43
 
44
proc_info Form;
44
proc_info Form;
45
 
45
 
46
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};
46
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
 
47
 
48
void Open_Dir()
48
void Open_Dir()
49
{
49
{
50
	int j;
50
	int j;
51
	list[active].count = 0;
51
	list[active].count = 0;
52
	if(io.dir.buffer)free(io.dir.buffer);
52
	if(io.dir.buffer)free(io.dir.buffer);
53
	io.dir.load(#folder_path,DIR_ONLYREAL);
53
	io.dir.load(#folder_path,DIR_ONLYREAL);
54
	for (j=0; j
54
	for (j=0; j
55
	{
55
	{
56
		strcpy(#temp_filename, io.dir.position(j));
56
		strcpy(#temp_filename, io.dir.position(j));
57
		strlwr(#temp_filename);
57
		strlwr(#temp_filename);
58
		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;
59
		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;
60
		cur = list[active].count;
60
		cur = list[active].count;
61
		files_mas[cur]=j;
61
		files_mas[cur]=j;
62
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
62
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
63
		list[active].count++;
63
		list[active].count++;
64
	}
64
	}
65
}
65
}
66
 
66
 
67
void Draw_List()
67
void Draw_List()
68
{
68
{
69
	int i;
69
	int i;
70
	int yyy;
70
	int yyy;
71
	int list_last;
71
	int list_last;
72
	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);
73
	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);
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].line_h+list[active].y;
81
		yyy = i*list[active].line_h+list[active].y;
82
		
82
		
83
		if (list[active].current-list[active].first==i)
83
		if (list[active].current-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].line_h, system.color.work_button);
87
				DrawBar(0, yyy, list[active].w, list[active].line_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].line_h, system.color.grab_button);
92
				DrawBar(0, yyy, list[active].w, list[active].line_h, system.color.grab_button);
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].line_h, 0xFFFfff);
98
			DrawBar(0,yyy,list[active].w, list[active].line_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].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);
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].current;
126
		cur = list[SKINS].current;
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].current;
132
		cur = list[WALLPAPERS].current;
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
	word key_ascii, key_scancode;
-
 
150
	dword status_key;
-
 
151
 
149
 
152
	SetEventMask(0x27);
150
	SetEventMask(0x27);
153
	load_dll(boxlib, #box_lib_init,0);
151
	load_dll(boxlib, #box_lib_init,0);
154
	list[SKINS].current = list[WALLPAPERS].current = -1;
152
	list[SKINS].current = list[WALLPAPERS].current = -1;
155
	list[SKINS].first = list[WALLPAPERS].first = 0;
153
	list[SKINS].first = list[WALLPAPERS].first = 0;
156
	TabClick(WALLPAPERS);
154
	TabClick(WALLPAPERS);
157
	list[WALLPAPERS].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
155
	list[WALLPAPERS].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
158
	list[SKINS].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
156
	list[SKINS].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
159
	loop()
157
	loop()
160
	{
158
	{
161
	  switch(WaitEvent()) 
159
	  switch(WaitEvent()) 
162
	  {
160
	  {
163
	  	case evMouse:
161
	  	case evMouse:
164
			if (!CheckActiveProcess(Form.ID)) break;
162
			if (!CheckActiveProcess(Form.ID)) break;
165
			mouse.get();
163
			mouse.get();
166
			scrollbar_v_mouse (#scroll1);
164
			scrollbar_v_mouse (#scroll1);
167
			if (list[active].first != scroll1.position)
165
			if (list[active].first != scroll1.position)
168
			{
166
			{
169
				list[active].first = scroll1.position;
167
				list[active].first = scroll1.position;
170
				Draw_List();
168
				Draw_List();
171
				break;
169
				break;
172
			}
170
			}
173
 
171
 
174
	  		if (mouse.vert)
172
	  		if (mouse.vert)
175
	  		{
173
	  		{
176
	  			if (list[SKINS].active) && (list[SKINS].MouseScroll(mouse.vert)) Draw_List();
174
	  			if (list[SKINS].active) && (list[SKINS].MouseScroll(mouse.vert)) Draw_List();
177
	  			if (list[WALLPAPERS].active) && (list[WALLPAPERS].MouseScroll(mouse.vert)) Draw_List();
175
	  			if (list[WALLPAPERS].active) && (list[WALLPAPERS].MouseScroll(mouse.vert)) Draw_List();
178
	  		} 
176
	  		} 
179
 
177
 
180
	  		if (mouse.up)&&(mouse_clicked)
178
	  		if (mouse.up)&&(mouse_clicked)
181
	  		{
179
	  		{
182
	  			if (mouse.lkm) &&(list[SKINS].active) && (list[SKINS].ProcessMouse(mouse.x, mouse.y)) Apply();
180
	  			if (mouse.lkm) &&(list[SKINS].active) && (list[SKINS].ProcessMouse(mouse.x, mouse.y)) Apply();
183
	  			if (mouse.lkm) &&(list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessMouse(mouse.x, mouse.y)) Apply();
181
	  			if (mouse.lkm) &&(list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessMouse(mouse.x, mouse.y)) Apply();
184
	  			mouse_clicked=false;
182
	  			mouse_clicked=false;
185
	  		}
183
	  		}
186
	  		else if (mouse.down)&&(mouse.lkm) && (list[SKINS].MouseOver(mouse.x, mouse.y)) mouse_clicked=true;
184
	  		else if (mouse.down)&&(mouse.lkm) && (list[SKINS].MouseOver(mouse.x, mouse.y)) mouse_clicked=true;
187
	  		break;
185
	  		break;
188
 
186
 
189
 
187
 
190
		case evButton:
188
		case evButton:
191
			id=GetButtonID();
189
			id=GetButtonID();
192
			if (id==1) ExitProcess();
190
			if (id==1) ExitProcess();
193
			if (id==2) TabClick(WALLPAPERS);
191
			if (id==2) TabClick(WALLPAPERS);
194
			if (id==3) TabClick(SKINS);
192
			if (id==3) TabClick(SKINS);
195
			break;
193
			break;
196
	  
194
	  
197
		case evKey:
195
		case evKey:
198
			GetFullKey();
196
			GetKeys(); 
199
			key_ascii = AH;
-
 
200
			$shr  eax,16
-
 
201
			key_scancode = AL;
-
 
202
			status_key = GetStatusKey();
-
 
203
			if (list[SKINS].active) && (list[SKINS].ProcessKey(key_scancode)) Apply();
197
			if (list[SKINS].active) && (list[SKINS].ProcessKey(key_scancode)) Apply();
204
			if (list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessKey(key_scancode)) Apply();
198
			if (list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessKey(key_scancode)) Apply();
205
			IF (key_scancode==SCAN_CODE_ENTER) OpenFile();
199
			IF (key_scancode==SCAN_CODE_ENTER) OpenFile();
206
			if (key_scancode==SCAN_CODE_TAB) if (list[SKINS].active) TabClick(WALLPAPERS); else TabClick(SKINS);
200
			if (key_scancode==SCAN_CODE_TAB) if (list[SKINS].active) TabClick(WALLPAPERS); else TabClick(SKINS);
207
			IF (key_scancode==SCAN_CODE_TAB) //Del
201
			IF (key_scancode==SCAN_CODE_TAB) //Del
208
			{
202
			{
209
				DeleteFile(#cur_file_path);
203
				DeleteFile(#cur_file_path);
210
				Open_Dir();
204
				Open_Dir();
211
				Apply();
205
				Apply();
212
			}
206
			}
213
			break;
207
			break;
214
		 
208
		 
215
		 case evReDraw:
209
		 case evReDraw:
216
			system.color.get();			
210
			system.color.get();			
217
			DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER,0);
211
			DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER,0);
218
			GetProcessInfo(#Form, SelfInfo);
212
			GetProcessInfo(#Form, SelfInfo);
219
			IF (Form.status_window>=2) break;
213
			IF (Form.status_window>=2) break;
220
			DrawTabs();
214
			DrawTabs();
221
			Draw_List();
215
			Draw_List();
222
	  }
216
	  }
223
   }
217
   }
224
}
218
}
225
 
219
 
226
#define BT_PADDING 16
220
#define BT_PADDING 16
227
 
221
 
228
void DrawTab(dword x,y, but_id, is_active, text)
222
void DrawTab(dword x,y, but_id, is_active, text)
229
{
223
{
230
	dword col_bg, col_text;
224
	dword col_bg, col_text;
231
	dword w=strlen(text)*6+BT_PADDING, h=21;
225
	dword w=strlen(text)*6+BT_PADDING, h=21;
232
 
226
 
233
	if (is_active)
227
	if (is_active)
234
	{
228
	{
235
		col_bg=system.color.work_button;
229
		col_bg=system.color.work_button;
236
		col_text=system.color.work_button_text;
230
		col_text=system.color.work_button_text;
237
	}
231
	}
238
	else
232
	else
239
	{
233
	{
240
		col_bg=system.color.work;
234
		col_bg=system.color.work;
241
		col_text=system.color.work_text;
235
		col_text=system.color.work_text;
242
	} 
236
	} 
243
	DrawRectangle(x,y, w,h, system.color.work_graph);
237
	DrawRectangle(x,y, w,h, system.color.work_graph);
244
	DrawCaptButton(x+1,y+1, w-2,h-1, but_id, col_bg, col_text, text);
238
	DrawCaptButton(x+1,y+1, w-2,h-1, but_id, col_bg, col_text, text);
245
	_PutImage(x+6,y+4,  16,15,   but_id-2*16*15*3+#icons);
239
	_PutImage(x+6,y+4,  16,15,   but_id-2*16*15*3+#icons);
246
}
240
}
247
 
241
 
248
 
242
 
249
void DrawTabs()
243
void DrawTabs()
250
{
244
{
251
	DrawBar(0,0, Form.cwidth, PANEL_H-1, system.color.work);
245
	DrawBar(0,0, Form.cwidth, PANEL_H-1, system.color.work);
252
	DrawTab(10,7, 2, list[WALLPAPERS].active, T_WALLPAPERS);
246
	DrawTab(10,7, 2, list[WALLPAPERS].active, T_WALLPAPERS);
253
	DrawTab(strlen(T_WALLPAPERS)*6+BT_PADDING+21,7, 3, list[SKINS].active, T_SKINS);
247
	DrawTab(strlen(T_WALLPAPERS)*6+BT_PADDING+21,7, 3, list[SKINS].active, T_SKINS);
254
	DrawBar(0,PANEL_H-2, Form.cwidth, 1, system.color.work_graph);
248
	DrawBar(0,PANEL_H-2, Form.cwidth, 1, system.color.work_graph);
255
	DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
249
	DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
256
}
250
}
257
 
251
 
258
void TabClick(int N)
252
void TabClick(int N)
259
{
253
{
260
	if (N==SKINS) 
254
	if (N==SKINS) 
261
	{
255
	{
262
		list[SKINS].active = 1;	
256
		list[SKINS].active = 1;	
263
		list[WALLPAPERS].active = 0;	
257
		list[WALLPAPERS].active = 0;	
264
	}
258
	}
265
	if (N==WALLPAPERS) 
259
	if (N==WALLPAPERS) 
266
	{
260
	{
267
		list[SKINS].active = 0;	
261
		list[SKINS].active = 0;	
268
		list[WALLPAPERS].active = 1;	
262
		list[WALLPAPERS].active = 1;	
269
	}
263
	}
270
	active = N;
264
	active = N;
271
	GetFiles();
265
	GetFiles();
272
	DrawTabs();
266
	DrawTabs();
273
	Draw_List();
267
	Draw_List();
274
}
268
}
275
 
269
 
276
 
270
 
277
void DrawScroller()
271
void DrawScroller()
278
{
272
{
279
	scroll1.bckg_col = 0xBBBbbb;
273
	scroll1.bckg_col = 0xBBBbbb;
280
	scroll1.frnt_col = system.color.work;
274
	scroll1.frnt_col = system.color.work;
281
	scroll1.line_col = system.color.work_graph;
275
	scroll1.line_col = system.color.work_graph;
282
 
276
 
283
	scroll1.max_area = list[active].count;
277
	scroll1.max_area = list[active].count;
284
	scroll1.cur_area = list[active].visible;
278
	scroll1.cur_area = list[active].visible;
285
	scroll1.position = list[active].first;
279
	scroll1.position = list[active].first;
286
 
280
 
287
	scroll1.all_redraw=1;
281
	scroll1.all_redraw=1;
288
	scroll1.start_x = list[active].x + list[active].w;
282
	scroll1.start_x = list[active].x + list[active].w;
289
	scroll1.start_y = list[active].y-2;
283
	scroll1.start_y = list[active].y-2;
290
	scroll1.size_y = list[active].h+2;
284
	scroll1.size_y = list[active].h+2;
291
 
285
 
292
	scrollbar_v_draw(#scroll1);
286
	scrollbar_v_draw(#scroll1);
293
}
287
}
294
 
288
 
295
 
289
 
296
stop:
290
stop:
297
>
291
>