Subversion Repositories Kolibri OS

Rev

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

Rev 4078 Rev 4081
1
//11.03.12 - start!
1
//11.03.12 - start!
2
 
2
 
3
#define MEMSIZE 0xFE800
3
#define MEMSIZE 0xFE800
4
#include "..\lib\kolibri.h" 
4
#include "..\lib\kolibri.h" 
5
#include "..\lib\mem.h"
5
#include "..\lib\mem.h"
6
#include "..\lib\file_system.h"
6
#include "..\lib\file_system.h"
7
#include "..\lib\strings.h"
7
#include "..\lib\strings.h"
8
#include "..\lib\list_box.h"
8
#include "..\lib\list_box.h"
9
#include "..\lib\figures.h"
9
#include "..\lib\figures.h"
10
 
10
 
11
#define WINDOW_HEADER "Appearance"
11
#define WINDOW_HEADER "Appearance"
12
 
12
 
13
#define PANEL_H 30
13
#define PANEL_H 30
14
#define SKINS_STANDART_PATH "/sys/skins/"
14
#define SKINS_STANDART_PATH "/sys/skins/"
15
#define WALP_STANDART_PATH "/sys/wallpapers/"
15
#define WALP_STANDART_PATH "/sys/wallpapers/"
16
 
16
 
17
llist list[2];
17
llist list[2];
18
int active;
18
int active;
19
enum { SKINS, WALLPAPERS };
19
enum { SKINS, WALLPAPERS };
20
 
20
 
21
char folder_path[4096];
21
char folder_path[4096];
22
char cur_file_path[4096];
22
char cur_file_path[4096];
23
char temp_filename[4096];
23
char temp_filename[4096];
24
int files_mas[100];
24
int files_mas[100];
25
dword buf;
25
dword buf;
26
 
26
 
27
int cur;
27
int cur;
28
 
28
 
29
system_colors sc;
29
system_colors sc;
30
proc_info Form;
30
proc_info Form;
31
 
31
 
32
#include "other.h"
32
#include "other.h"
33
 
33
 
34
//ADD PaNEL
34
//ADD PaNEL
35
 
35
 
36
 
36
 
37
//skins direktory,    configurate, delete from list, delete from disk, make default
37
//skins direktory,    configurate, delete from list, delete from disk, make default
38
 
38
 
39
void Open_Dir()
39
void Open_Dir()
40
{
40
{
41
	int j, filesnum;
41
	int j, filesnum;
42
 
42
 
43
	list[active].count = 0;
43
	list[active].count = 0;
44
	free(buf);
44
	free(buf);
45
	if (GetDir(#buf, #filesnum, #folder_path, DIRS_ONLYREAL)!=0) return;
45
	if (GetDir(#buf, #filesnum, #folder_path, DIRS_ONLYREAL)!=0) return;
46
 
46
 
47
	for (j=0; j
47
	for (j=0; j
48
	{
48
	{
49
		strlwr(j*304 + buf+72);
49
		strlwr(j*304 + buf+72);
50
		strcpy(#temp_filename, j*304 + buf+72);
50
		strcpy(#temp_filename, j*304 + buf+72);
51
		if (active==SKINS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
51
		if (active==SKINS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
52
		if (active==WALLPAPERS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
52
		if (active==WALLPAPERS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
53
		cur = list[active].count;
53
		cur = list[active].count;
54
		files_mas[cur]=j;
54
		files_mas[cur]=j;
55
		if (!strcmp("default.skn",#temp_filename)) files_mas[0]>
55
		if (!strcmp("default.skn",#temp_filename)) files_mas[0]>
56
		list[active].count++;
56
		list[active].count++;
57
	}
57
	}
58
	Sort_by_Name(0, list[active].count-1); 
58
	Sort_by_Name(0, list[active].count-1); 
59
}
59
}
60
 
60
 
61
void Draw_List()
61
void Draw_List()
62
{
62
{
63
	int i;
63
	int i;
64
	list[SKINS].SetSizes(0, PANEL_H, Form.cwidth, Form.cheight-PANEL_H, 40, 20);
64
	list[SKINS].SetSizes(0, PANEL_H, Form.cwidth, Form.cheight-PANEL_H, 40, 20);
65
	list[WALLPAPERS].SetSizes(0, PANEL_H, Form.cwidth, Form.cheight-PANEL_H, 40, 20);
65
	list[WALLPAPERS].SetSizes(0, PANEL_H, Form.cwidth, Form.cheight-PANEL_H, 40, 20);
66
	
66
	
67
	for (i=0; i
67
	for (i=0; i
68
	{
68
	{
69
		cur = list[active].first;
69
		cur = list[active].first;
70
		strcpy(#temp_filename, files_mas[i+cur]*304 + buf+72);
70
		strcpy(#temp_filename, files_mas[i+cur]*304 + buf+72);
71
		
71
		
72
		if (list[active].current-list[active].first==i)
72
		if (list[active].current-list[active].first==i)
73
		{
73
		{
74
			if (sc.work_button<>sc.work)
74
			if (sc.work_button<>sc.work)
75
			{
75
			{
76
				DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.work_button);
76
				DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.work_button);
77
				WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.work_button_text, #temp_filename);
77
				WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.work_button_text, #temp_filename);
78
			}
78
			}
79
			else
79
			else
80
			{
80
			{
81
				DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.grab_button);
81
				DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.grab_button);
82
				WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.grab_button_text, #temp_filename);
82
				WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.grab_button_text, #temp_filename);
83
			}	
83
			}	
84
		}
84
		}
85
		else
85
		else
86
		{
86
		{
87
			DrawBar(0,i*list[active].line_h+list[active].y,list[active].w, list[active].line_h, 0xFFFfff);
87
			DrawBar(0,i*list[active].line_h+list[active].y,list[active].w, list[active].line_h, 0xFFFfff);
88
			WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,0, #temp_filename);
88
			WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,0, #temp_filename);
89
		}
89
		}
90
	}
90
	}
91
	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);
91
	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);
92
}
92
}
93
 
93
 
94
void GetFiles(int set_active)
94
void GetFiles(int set_active)
95
{
95
{
96
	active = set_active;
96
	active = set_active;
97
	if (active==SKINS)
97
	if (active==SKINS)
98
	{
98
	{
99
		strcpy(#folder_path, SKINS_STANDART_PATH);
99
		strcpy(#folder_path, SKINS_STANDART_PATH);
100
		Open_Dir();
100
		Open_Dir();
101
		if (!list[active].count) notify("No skins were found");
101
		if (!list[active].count) notify("No skins were found");
102
	}
102
	}
103
	if (active==WALLPAPERS)
103
	if (active==WALLPAPERS)
104
	{
104
	{
105
		strcpy(#folder_path, WALP_STANDART_PATH);
105
		strcpy(#folder_path, WALP_STANDART_PATH);
106
		Open_Dir();
106
		Open_Dir();
107
		if (!list[active].count) notify("No wallpapers were found");
107
		if (!list[active].count) notify("No wallpapers were found");
108
	}
108
	}
109
}
109
}
110
 
110
 
111
void Apply()
111
void Apply()
112
{
112
{
113
	if (active==SKINS)
113
	if (active==SKINS)
114
	{
114
	{
115
		strcpy(#cur_file_path, #folder_path);
115
		strcpy(#cur_file_path, #folder_path);
116
		cur = list[active].current;
116
		cur = list[active].current;
117
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
117
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
118
		SetSystemSkin(#cur_file_path);
118
		SetSystemSkin(#cur_file_path);
119
	} 
119
	} 
120
	if (active==WALLPAPERS)
120
	if (active==WALLPAPERS)
121
	{
121
	{
122
		strcpy(#cur_file_path, "\\S__");
122
		strcpy(#cur_file_path, "\\S__");
123
		strcat(#cur_file_path, #folder_path);
123
		strcat(#cur_file_path, #folder_path);
124
		cur = list[active].current;
124
		cur = list[active].current;
125
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
125
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
126
		RunProgram("/sys/media/kiv", #cur_file_path);
126
		RunProgram("/sys/media/kiv", #cur_file_path);
127
		Draw_List();
127
		Draw_List();
128
	}
128
	}
129
}
129
}
130
 
130
 
131
OpenFile()
131
OpenFile()
132
{
132
{
133
	if (active==SKINS) RunProgram("/sys/desktop", #cur_file_path);
133
	if (active==SKINS) RunProgram("/sys/desktop", #cur_file_path);
134
	if (active==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
134
	if (active==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
135
}
135
}
136
 
136
 
137
 
137
 
138
void main()
138
void main()
139
{   
139
{   
140
	int id, key, mouse_clicked;
140
	int id, key, mouse_clicked;
141
	mouse mm;
141
	mouse mm;
142
 
142
 
143
	mem_Init();
143
	mem_Init();
144
	if (param) strcpy(#folder_path, #param);
144
	if (param) strcpy(#folder_path, #param);
145
	list[SKINS].current = list[WALLPAPERS].current = 0;
145
	list[SKINS].current = list[WALLPAPERS].current = -1;
146
	list[SKINS].first = list[WALLPAPERS].first = 0;
146
	list[SKINS].first = list[WALLPAPERS].first = 0;
147
	GetFiles(WALLPAPERS);
147
	GetFiles(WALLPAPERS);
148
	list[active].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
148
	list[active].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
149
	SetEventMask(0x27);
149
	SetEventMask(0x27);
150
	loop()
150
	loop()
151
	{
151
	{
152
	  switch(WaitEvent()) 
152
	  switch(WaitEvent()) 
153
	  {
153
	  {
154
	  	case evMouse:
154
	  	case evMouse:
155
	  		mm.get();
155
	  		mm.get();
156
	  		if (mm.vert) && (list[active].MouseScroll(mm.vert)) Draw_List();
156
	  		if (mm.vert) && (list[active].MouseScroll(mm.vert)) Draw_List();
157
	  		/*
-
 
158
	  		if (mouse_clicked)
157
	  		if (mouse_clicked)
159
	  		{
158
	  		{
160
	  			if (!mm.lkm) && (list[active].ProcessMouse(mm.x, mm.y)) Apply();
159
	  			if (!mm.lkm) && (active==SKINS) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
-
 
160
	  			if (!mm.lkm) && (active==WALLPAPERS) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
161
	  			mouse_clicked=0;
161
	  			mouse_clicked=0;
162
	  		}
162
	  		}
163
	  		if (mm.lkm) && (list[active].MouseOver(mm.x, mm.y)) mouse_clicked=1;
163
	  		if (mm.lkm) && (list[SKINS].MouseOver(mm.x, mm.y)) mouse_clicked=1;
164
	  		*/
-
 
165
	  		EAX = active;
-
 
166
	  		if (mm.lkm) 
-
 
167
	  		{
-
 
168
	  			if (active==SKINS) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
-
 
169
	  			if if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
-
 
170
	  		}
-
 
171
	  		break;
164
	  		break;
172
 
165
 
173
		case evButton:
166
		case evButton:
174
			id=GetButtonID();
167
			id=GetButtonID();
175
			if (id==1) ExitProcess();
168
			if (id==1) ExitProcess();
176
			if (id==2) TabClick(SKINS);
169
			if (id==2) TabClick(SKINS);
177
			if (id==3) TabClick(WALLPAPERS);
170
			if (id==3) TabClick(WALLPAPERS);
178
			break;
171
			break;
179
	  
172
	  
180
		case evKey:
173
		case evKey:
181
			key = GetKey();
174
			key = GetKey();
182
			if (active==SKINS) && (list[SKINS].ProcessKey(key)) Apply();
175
			if (active==SKINS) && (list[SKINS].ProcessKey(key)) Apply();
183
			if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessKey(key)) Apply();
176
			if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessKey(key)) Apply();
184
			IF (key==013) OpenFile();
177
			IF (key==013) OpenFile();
185
			if (key==9) //Tab
178
			if (key==9) //Tab
186
			{
179
			{
187
				if (active==SKINS)
180
				if (active==SKINS)
188
					TabClick(WALLPAPERS);
181
					TabClick(WALLPAPERS);
189
				else
182
				else
190
					TabClick(SKINS);
183
					TabClick(SKINS);
191
			}
184
			}
192
			IF (key==182) //Del
185
			IF (key==182) //Del
193
			{
186
			{
194
				DeleteFile(#cur_file_path);
187
				DeleteFile(#cur_file_path);
195
				Open_Dir();
188
				Open_Dir();
196
				Apply();
189
				Apply();
197
			}
190
			}
198
			break;
191
			break;
199
		 
192
		 
200
		 case evReDraw:
193
		 case evReDraw:
201
			sc.get();			
194
			sc.get();			
202
			DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER);
195
			DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER);
203
			GetProcessInfo(#Form, SelfInfo);
196
			GetProcessInfo(#Form, SelfInfo);
204
			IF (Form.status_window>=2) break;
197
			IF (Form.status_window>=2) break;
205
			DrawTabs();
198
			DrawTabs();
206
			Draw_List();
199
			Draw_List();
207
	  }
200
	  }
208
   }
201
   }
209
}
202
}
210
 
203
 
211
 
204
 
212
void DrawTabs()
205
void DrawTabs()
213
{
206
{
214
	dword col_bg, col_text;
207
	dword col_bg, col_text;
215
	DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work);
208
	DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work);
216
 
209
 
217
	if (active==SKINS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} 
210
	if (active==SKINS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} 
218
	DrawRectangle(10-1,7-1, 65+2, 21+2, sc.work_graph);
211
	DrawRectangle(10-1,7-1, 65+2, 21+2, sc.work_graph);
219
	DrawCaptButton(10,7, 65, 21, 2, col_bg, col_text, "Skins"); //вокруг рисовать пмятоуг
212
	DrawCaptButton(10,7, 65, 21, 2, col_bg, col_text, "Skins"); //вокруг рисовать пмятоуг
220
	if (active==WALLPAPERS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} 
213
	if (active==WALLPAPERS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} 
221
	DrawRectangle(90-1,7-1, 95+2, 21+2, sc.work_graph);
214
	DrawRectangle(90-1,7-1, 95+2, 21+2, sc.work_graph);
222
	DrawCaptButton(90,7, 95, 21, 3, col_bg, col_text, "Wallpappers");
215
	DrawCaptButton(90,7, 95, 21, 3, col_bg, col_text, "Wallpappers");
223
 
216
 
224
	DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph);
217
	DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph);
225
	DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
218
	DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
226
}
219
}
227
 
220
 
228
void TabClick(int N)
221
void TabClick(int N)
229
{
222
{
230
	GetFiles(N);
223
	GetFiles(N);
231
	DrawTabs();
224
	DrawTabs();
232
	Draw_List();
225
	Draw_List();
233
}
226
}
234
 
227
 
235
 
228
 
236
 
229
 
237
 
230
 
238
stop:
231
stop:
239
>
232
>