Subversion Repositories Kolibri OS

Rev

Rev 5548 | Rev 5626 | 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
	mouse mm;
167
 
168
	mem_Init();
4410 leency 169
	SetEventMask(0x27);
5621 leency 170
	if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(BOX_LIB_LOAD_ERR);
4081 leency 171
	list[SKINS].current = list[WALLPAPERS].current = -1;
4078 leency 172
	list[SKINS].first = list[WALLPAPERS].first = 0;
4410 leency 173
	TabClick(WALLPAPERS);
174
	list[WALLPAPERS].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
175
	list[SKINS].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
4078 leency 176
	loop()
177
	{
178
	  switch(WaitEvent())
179
	  {
180
	  	case evMouse:
4085 leency 181
			if (!CheckActiveProcess(Form.ID)) break;
182
			scrollbar_v_mouse (#scroll1);
183
			if (list[active].first <> scroll1.position)
184
			{
185
				list[active].first = scroll1.position;
186
				Draw_List();
187
				break;
188
			}
189
 
4078 leency 190
	  		mm.get();
4410 leency 191
 
192
	  		if (mm.vert)
193
	  		{
194
	  			if (list[SKINS].active) && (list[SKINS].MouseScroll(mm.vert)) Draw_List();
195
	  			if (list[WALLPAPERS].active) && (list[WALLPAPERS].MouseScroll(mm.vert)) Draw_List();
196
	  		}
197
 
4078 leency 198
	  		if (mouse_clicked)
199
	  		{
4410 leency 200
	  			if (!mm.lkm) && (list[SKINS].active) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
201
	  			if (!mm.lkm) && (list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
4078 leency 202
	  			mouse_clicked=0;
203
	  		}
4081 leency 204
	  		if (mm.lkm) && (list[SKINS].MouseOver(mm.x, mm.y)) mouse_clicked=1;
4078 leency 205
	  		break;
206
 
4410 leency 207
 
4078 leency 208
		case evButton:
209
			id=GetButtonID();
210
			if (id==1) ExitProcess();
4410 leency 211
			if (id==2) TabClick(WALLPAPERS);
212
			if (id==3) TabClick(SKINS);
4078 leency 213
			break;
214
 
215
		case evKey:
216
			key = GetKey();
4410 leency 217
			if (list[SKINS].active) && (list[SKINS].ProcessKey(key)) Apply();
218
			if (list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessKey(key)) Apply();
4078 leency 219
			IF (key==013) OpenFile();
4410 leency 220
			if (key==9) if (list[SKINS].active) TabClick(WALLPAPERS); else TabClick(SKINS);
4078 leency 221
			IF (key==182) //Del
222
			{
223
				DeleteFile(#cur_file_path);
224
				Open_Dir();
225
				Apply();
226
			}
227
			break;
228
 
229
		 case evReDraw:
230
			sc.get();
4410 leency 231
			DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER,0);
4078 leency 232
			GetProcessInfo(#Form, SelfInfo);
233
			IF (Form.status_window>=2) break;
234
			DrawTabs();
235
			Draw_List();
236
	  }
237
   }
238
}
239
 
4410 leency 240
#define BT_PADDING 16
4078 leency 241
 
4410 leency 242
void DrawTab(dword x,y, but_id, is_active, text)
243
{
244
	dword col_bg, col_text;
245
	dword w=strlen(text)*6+BT_PADDING, h=21;
246
 
247
	if (is_active)
248
	{
249
		col_bg=sc.work_button;
250
		col_text=sc.work_button_text;
251
	}
252
	else
253
	{
254
		col_bg=sc.work;
255
		col_text=sc.work_text;
256
	}
257
	DrawRectangle(x,y, w,h, sc.work_graph);
258
	DrawCaptButton(x+1,y+1, w-2,h-1, but_id, col_bg, col_text, text);
4411 leency 259
	_PutImage(x+6,y+4,  16,15,   but_id-2*16*15*3+#icons);
4410 leency 260
}
261
 
262
 
4078 leency 263
void DrawTabs()
264
{
265
	DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work);
266
 
4410 leency 267
	DrawTab(10,7, 2, list[WALLPAPERS].active, T_WALLPAPERS);
268
	DrawTab(strlen(T_WALLPAPERS)*6+BT_PADDING+21,7, 3, list[SKINS].active, T_SKINS);
4078 leency 269
 
270
	DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph);
271
	DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
272
}
273
 
274
void TabClick(int N)
275
{
4410 leency 276
	if (N==SKINS)
277
	{
278
		list[SKINS].active = 1;
279
		list[WALLPAPERS].active = 0;
280
	}
281
	if (N==WALLPAPERS)
282
	{
283
		list[SKINS].active = 0;
284
		list[WALLPAPERS].active = 1;
285
	}
286
	active = N;
287
	GetFiles();
4078 leency 288
	DrawTabs();
289
	Draw_List();
290
}
291
 
292
 
4085 leency 293
void DrawScroller()
294
{
295
	scroll1.bckg_col = 0xBBBbbb;
296
	scroll1.frnt_col = sc.work;
297
	scroll1.line_col = sc.work_graph;
4078 leency 298
 
4085 leency 299
	scroll1.max_area = list[active].count;
300
	scroll1.cur_area = list[active].visible;
301
	scroll1.position = list[active].first;
4078 leency 302
 
4085 leency 303
	scroll1.all_redraw=1;
304
	scroll1.start_x = list[active].x + list[active].w;
305
	scroll1.start_y = list[active].y-2;
306
	scroll1.size_y = list[active].h+2;
307
 
308
	scrollbar_v_draw(#scroll1);
309
}
310
 
311
 
4078 leency 312
stop: