Subversion Repositories Kolibri OS

Rev

Rev 4085 | Rev 4411 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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