Subversion Repositories Kolibri OS

Rev

Rev 4081 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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