Subversion Repositories Kolibri OS

Rev

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