Subversion Repositories Kolibri OS

Rev

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