Subversion Repositories Kolibri OS

Rev

Rev 6253 | Rev 6271 | 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!
6212 leency 2
//ver 2.0
4078 leency 3
 
4085 leency 4
#ifndef AUTOBUILD
5
	?include "lang.h--"
6
#endif
7
 
4078 leency 8
#define MEMSIZE 0xFE800
9
#include "..\lib\mem.h"
4085 leency 10
#include "..\lib\strings.h"
5654 leency 11
#include "..\lib\io.h"
4078 leency 12
#include "..\lib\list_box.h"
6212 leency 13
#include "..\lib\menu.h"
5499 leency 14
#include "..\lib\gui.h"
15
#include "..\lib\obj\box_lib.h"
4078 leency 16
 
6212 leency 17
 
18
//===================================================//
19
//                                                   //
20
//                       DATA                        //
21
//                                                   //
22
//===================================================//
23
 
4085 leency 24
#ifdef LANG_RUS
6212 leency 25
	?define WINDOW_HEADER "Настройки оформления"
6264 leency 26
	?define T_SKINS       "Стиль окон"
27
	?define T_WALLPAPERS  "Обои"
4085 leency 28
#else
29
	?define WINDOW_HEADER "Appearance"
6264 leency 30
	?define T_SKINS       "Skins"
31
	?define T_WALLPAPERS  "Wallpappers"
4085 leency 32
#endif
4078 leency 33
 
6212 leency 34
#define PANEL_H 40
35
#define LIST_PADDING 20
5765 leency 36
#define SKINS_STANDART_PATH "/kolibrios/res/skins"
4885 leency 37
#define WALP_STANDART_PATH "/kolibrios/res/wallpapers"
4078 leency 38
 
6212 leency 39
llist list;
6264 leency 40
signed int active_skin=-1, active_wallpaper=-1;
6212 leency 41
enum { SKINS=2, WALLPAPERS };
4078 leency 42
 
43
char folder_path[4096];
44
char cur_file_path[4096];
45
char temp_filename[4096];
6096 leency 46
int files_mas[400];
4078 leency 47
 
48
int cur;
49
 
50
proc_info Form;
51
 
4085 leency 52
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};
53
 
4078 leency 54
 
6212 leency 55
//===================================================//
56
//                                                   //
57
//                       CODE                        //
58
//                                                   //
59
//===================================================//
5548 leency 60
 
4078 leency 61
void main()
62
{
5705 punk_joker 63
	int id, mouse_clicked;
4078 leency 64
 
4410 leency 65
	SetEventMask(0x27);
5626 leency 66
	load_dll(boxlib, #box_lib_init,0);
6212 leency 67
	EventTabClick(SKINS);
6096 leency 68
	loop() switch(WaitEvent())
4078 leency 69
	{
70
	  	case evMouse:
4085 leency 71
			if (!CheckActiveProcess(Form.ID)) break;
5656 pavelyakov 72
			mouse.get();
4085 leency 73
			scrollbar_v_mouse (#scroll1);
6212 leency 74
			if (list.first != scroll1.position)
4085 leency 75
			{
6212 leency 76
				list.first = scroll1.position;
4085 leency 77
				Draw_List();
78
				break;
79
			}
4410 leency 80
 
6212 leency 81
	  		if (mouse.vert) && (list.MouseScroll(mouse.vert)) Draw_List();
4410 leency 82
 
5656 pavelyakov 83
	  		if (mouse.up)&&(mouse_clicked)
4078 leency 84
	  		{
6212 leency 85
	  			if (mouse.lkm) && (list.ProcessMouse(mouse.x, mouse.y)) EventApply();
5656 pavelyakov 86
	  			mouse_clicked=false;
4078 leency 87
	  		}
6212 leency 88
	  		else if (mouse.down)&&(mouse.lkm) && (list.MouseOver(mouse.x, mouse.y)) mouse_clicked=true;
89
 
90
	  		if (mouse.down)&&(mouse.pkm) {
91
	  			list.ProcessMouse(mouse.x, mouse.y);
92
				Draw_List();
93
	  			menu.show(Form.left+mouse.x, Form.top+mouse.y+skin_height, 136, "Open file     Enter\nDelete          Del", 10);
94
	  		}
95
 
4078 leency 96
	  		break;
97
 
4410 leency 98
 
4078 leency 99
		case evButton:
100
			id=GetButtonID();
101
			if (id==1) ExitProcess();
6212 leency 102
			if (id==SKINS) EventTabClick(SKINS);
103
			if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
4078 leency 104
			break;
105
 
106
		case evKey:
5706 leency 107
			GetKeys();
6212 leency 108
			if (list.ProcessKey(key_scancode)) EventApply();
109
			if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
6264 leency 110
			if (key_scancode==SCAN_CODE_TAB) if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS);
6212 leency 111
			if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
112
			for (id=list.cur_y+1; id
4078 leency 113
			{
6212 leency 114
				strcpy(#temp_filename, io.dir.position(files_mas[id]));
115
				if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32)
116
				{
117
					list.cur_y = id - 1;
118
					list.KeyDown();
119
					EventApply();
120
					break;
121
				}
4078 leency 122
			}
123
			break;
124
 
125
		 case evReDraw:
5674 pavelyakov 126
			system.color.get();
6212 leency 127
			DefineAndDrawWindow(screen.width-400/2,80,400,404+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0);
4078 leency 128
			GetProcessInfo(#Form, SelfInfo);
129
			IF (Form.status_window>=2) break;
6212 leency 130
		 	DrawWindowContent();
131
		 	debugi(menu.list.cur_y);
132
	 		if (menu.list.cur_y) {
133
				if (menu.list.cur_y == 10) EventOpenFile();
134
				if (menu.list.cur_y == 11) EventDeleteFile();
135
				menu.list.cur_y = 0;
136
			};
4078 leency 137
   }
138
}
139
 
6212 leency 140
void DrawWindowContent()
141
{
142
	int id;
143
	list.SetFont(8, 14, 0x90);
144
	id = list.cur_y;
145
	list.SetSizes(LIST_PADDING, PANEL_H, Form.cwidth-scroll1.size_x-LIST_PADDING-LIST_PADDING, Form.cheight-PANEL_H-LIST_PADDING, 20);
146
	list.cur_y = id;
4078 leency 147
 
6212 leency 148
	DrawBar(0,0, Form.cwidth, PANEL_H-LIST_PADDING, system.color.work);
149
	DrawRectangle3D(list.x-2, list.y-2, list.w+3+scroll1.size_x, list.h+3, system.color.work_dark, system.color.work_light);
150
	DrawWideRectangle(list.x-LIST_PADDING, list.y-LIST_PADDING, LIST_PADDING*2+list.w+scroll1.size_x, LIST_PADDING*2+list.h, LIST_PADDING-2, system.color.work);
6264 leency 151
	tabs.draw(list.x+10, list.y, SKINS, T_SKINS);
152
	if (dir_exists(WALP_STANDART_PATH)) tabs.draw(strlen(T_SKINS)*8+TAB_PADDING+list.x+21, list.y, WALLPAPERS, T_WALLPAPERS);
6212 leency 153
	DrawRectangle(list.x-1, list.y-1, list.w+1+scroll1.size_x, list.h+1, system.color.work_graph);
154
 
155
	Draw_List();
156
}
157
 
158
void DrawScroller()
159
{
6253 leency 160
	scroll1.bckg_col = MixColors(system.color.work, 0xBBBbbb, 80);
161
	scroll1.frnt_col = MixColors(system.color.work,0xFFFfff,120);
6212 leency 162
	scroll1.line_col = system.color.work_graph;
4410 leency 163
 
6212 leency 164
	scroll1.max_area = list.count;
165
	scroll1.cur_area = list.visible;
166
	scroll1.position = list.first;
167
 
168
	scroll1.all_redraw=1;
169
	scroll1.start_x = list.x + list.w;
170
	scroll1.start_y = list.y-1;
171
	scroll1.size_y = list.h+2;
172
 
173
	scrollbar_v_draw(#scroll1);
4078 leency 174
}
175
 
6212 leency 176
void Open_Dir()
4078 leency 177
{
6212 leency 178
	int j;
179
	list.count = 0;
180
	if(io.dir.buffer)free(io.dir.buffer);
181
	io.dir.load(#folder_path,DIR_ONLYREAL);
182
	for (j=0; j
4410 leency 183
	{
6212 leency 184
		strcpy(#temp_filename, io.dir.position(j));
185
		strlwr(#temp_filename);
6264 leency 186
		if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
187
		if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
6212 leency 188
		cur = list.count;
189
		files_mas[cur]=j;
190
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
191
		list.count++;
4410 leency 192
	}
6212 leency 193
}
194
 
195
void Draw_List()
196
{
197
	int i, yyy, list_last;
198
 
199
	if (list.count > list.visible) list_last = list.visible; else list_last = list.count;
200
 
201
	for (i=0; (i
4410 leency 202
	{
6212 leency 203
		cur = list.first + i;
204
		strcpy(#temp_filename, io.dir.position(files_mas[cur]));
205
		temp_filename[strlen(#temp_filename)-4] = 0;
206
		yyy = i*list.item_h+list.y;
207
 
208
		if (list.cur_y-list.first==i)
209
		{
210
			DrawBar(list.x, yyy, list.w, list.item_h, system.color.work_button);
211
			WriteText(list.x+12,yyy+list.text_y,list.font_type,system.color.work_button_text, #temp_filename);
212
		}
213
		else
214
		{
215
			DrawBar(list.x,yyy,list.w, list.item_h, 0xFFFfff);
216
			WriteText(list.x+12,yyy+list.text_y,list.font_type,0, #temp_filename);
217
		}
4410 leency 218
	}
6212 leency 219
	DrawBar(list.x,i*list.item_h+list.y, list.w, -i*list.item_h+ list.h, 0xFFFfff);
220
	DrawScroller();
4078 leency 221
}
222
 
6212 leency 223
//===================================================//
224
//                                                   //
225
//                     EVENTS                        //
226
//                                                   //
227
//===================================================//
4078 leency 228
 
6212 leency 229
void EventTabClick(int N)
4085 leency 230
{
6264 leency 231
	tabs.click(N);
232
	if (tabs.active_tab == SKINS)
6212 leency 233
	{
234
		active_wallpaper = list.cur_y;
235
		strcpy(#folder_path, SKINS_STANDART_PATH);
236
		list.ClearList();
237
		Open_Dir();
238
		if (!list.count) notify("'No skins were found' -E");
239
		list.cur_y = active_skin;
240
	}
6264 leency 241
	if (tabs.active_tab == WALLPAPERS)
6212 leency 242
	{
243
		active_skin = list.cur_y;
244
		strcpy(#folder_path, WALP_STANDART_PATH);
245
		list.ClearList();
246
		Open_Dir();
247
		if (!list.count) notify("'No wallpapers were found' -E");
248
		list.cur_y = active_wallpaper;
249
	}
6264 leency 250
	if (list.cur_y>list.visible) list.first=list.cur_y; list.CheckDoesValuesOkey();
6212 leency 251
	if (list.w) DrawWindowContent();
252
}
4078 leency 253
 
6212 leency 254
void EventDeleteFile()
255
{
256
	io.del(#cur_file_path);
257
	Open_Dir();
258
	EventApply();
259
}
4078 leency 260
 
6212 leency 261
void EventApply()
262
{
6264 leency 263
	if (tabs.active_tab==SKINS)
6212 leency 264
	{
265
		cur = list.cur_y;
266
		sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur]));
267
		SetSystemSkin(#cur_file_path);
268
	}
6264 leency 269
	if (tabs.active_tab==WALLPAPERS)
6212 leency 270
	{
271
		cur = list.cur_y;
272
		sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur]));
273
		RunProgram("/sys/media/kiv", #cur_file_path);
274
		Draw_List();
275
	}
276
}
4085 leency 277
 
6212 leency 278
void EventOpenFile()
279
{
6264 leency 280
	if (tabs.active_tab==SKINS) RunProgram("/sys/skincfg", #cur_file_path);
281
	if (tabs.active_tab==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
4085 leency 282
}
283
 
4078 leency 284
stop: