Subversion Repositories Kolibri OS

Rev

Rev 6271 | Rev 6653 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6271 Rev 6651
Line 11... Line 11...
11
#include "..\lib\io.h"
11
#include "..\lib\io.h"
12
#include "..\lib\list_box.h"
12
#include "..\lib\list_box.h"
13
#include "..\lib\menu.h"
13
#include "..\lib\menu.h"
14
#include "..\lib\gui.h"
14
#include "..\lib\gui.h"
15
#include "..\lib\obj\box_lib.h"
15
#include "..\lib\obj\box_lib.h"
-
 
16
#include "..\lib\patterns\select_list.h"
Line 16... Line 17...
16
 
17
 
17
 
18
 
18
//===================================================//
19
//===================================================//
Line 34... Line 35...
34
#define PANEL_H 40
35
#define PANEL_H 40
35
#define LIST_PADDING 20
36
#define LIST_PADDING 20
36
#define SKINS_STANDART_PATH "/kolibrios/res/skins"							
37
#define SKINS_STANDART_PATH "/kolibrios/res/skins"							
37
#define WALP_STANDART_PATH "/kolibrios/res/wallpapers"
38
#define WALP_STANDART_PATH "/kolibrios/res/wallpapers"
Line 38... Line -...
38
 
-
 
39
llist list;
39
 
40
signed int active_skin=-1, active_wallpaper=-1;
40
signed int active_skin=-1, active_wallpaper=-1;
Line 41... Line 41...
41
enum { SKINS=2, WALLPAPERS };
41
enum { SKINS=2, WALLPAPERS };
42
 
42
 
Line 47... Line 47...
47
 
47
 
Line 48... Line 48...
48
int cur;
48
int cur;
Line 49... Line -...
49
 
-
 
50
proc_info Form;
-
 
51
 
-
 
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};
49
 
53
 
50
proc_info Form;
54
 
51
 
55
//===================================================//
52
//===================================================//
56
//                                                   //
53
//                                                   //
Line 69... Line 66...
69
	{
66
	{
70
	  	case evMouse:
67
	  	case evMouse:
71
			if (!CheckActiveProcess(Form.ID)) break;
68
			if (!CheckActiveProcess(Form.ID)) break;
72
			mouse.get();
69
			mouse.get();
73
			scrollbar_v_mouse (#scroll1);
70
			scrollbar_v_mouse (#scroll1);
74
			if (list.first != scroll1.position)
71
			if (select_list.first != scroll1.position)
75
			{
72
			{
76
				list.first = scroll1.position;
73
				select_list.first = scroll1.position;
77
				Draw_List();
74
				DrawSelectList(select_list.count);
78
				break;
75
				break;
79
			}
76
			}
Line 80... Line 77...
80
 
77
 
Line 81... Line 78...
81
	  		if (mouse.vert) && (list.MouseScroll(mouse.vert)) Draw_List();
78
	  		if (mouse.vert) && (select_list.MouseScroll(mouse.vert)) DrawSelectList(select_list.count);
82
 
79
 
83
	  		if (mouse.up)&&(mouse_clicked)
80
	  		if (mouse.up)&&(mouse_clicked)
84
	  		{
81
	  		{
85
	  			if (mouse.lkm) && (list.ProcessMouse(mouse.x, mouse.y)) EventApply();
82
	  			if (mouse.lkm) && (select_list.ProcessMouse(mouse.x, mouse.y)) EventApply();
86
	  			mouse_clicked=false;
83
	  			mouse_clicked=false;
Line 87... Line 84...
87
	  		}
84
	  		}
88
	  		else if (mouse.down)&&(mouse.lkm) && (list.MouseOver(mouse.x, mouse.y)) mouse_clicked=true;
85
	  		else if (mouse.down)&&(mouse.lkm) && (select_list.MouseOver(mouse.x, mouse.y)) mouse_clicked=true;
89
 
86
 
90
	  		if (mouse.down)&&(mouse.pkm) {
87
	  		if (mouse.down)&&(mouse.pkm) {
91
	  			list.ProcessMouse(mouse.x, mouse.y);
88
	  			select_list.ProcessMouse(mouse.x, mouse.y);
Line 92... Line 89...
92
				Draw_List();
89
				DrawSelectList(select_list.count);
Line 103... Line 100...
103
			if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
100
			if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
104
			break;
101
			break;
Line 105... Line 102...
105
	  
102
	  
106
		case evKey:
103
		case evKey:
107
			GetKeys(); 
104
			GetKeys(); 
108
			if (list.ProcessKey(key_scancode)) EventApply();
105
			if (select_list.ProcessKey(key_scancode)) EventApply();
109
			if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
106
			if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
110
			if (key_scancode==SCAN_CODE_TAB) if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS);
107
			if (key_scancode==SCAN_CODE_TAB) if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS); else EventTabClick(SKINS);
111
			if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
108
			if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
112
			for (id=list.cur_y+1; id
109
			for (id=select_list.cur_y+1; id
113
			{
110
			{
114
				strcpy(#temp_filename, io.dir.position(files_mas[id]));
111
				strcpy(#temp_filename, io.dir.position(files_mas[id]));
115
				if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32)
112
				if (temp_filename[0]==key_ascii) || (temp_filename[0]==key_ascii-32)
116
				{
113
				{
117
					list.cur_y = id - 1;
114
					select_list.cur_y = id - 1;
118
					list.KeyDown();
115
					select_list.KeyDown();
119
					EventApply();
116
					EventApply();
120
					break;
117
					break;
121
				}
118
				}
122
			}
119
			}
Line 137... Line 134...
137
}
134
}
Line 138... Line 135...
138
 
135
 
139
void DrawWindowContent()
136
void DrawWindowContent()
140
{
137
{
141
	int id;
-
 
142
	list.SetFont(8, 14, 0x90);
138
	int id;
143
	id = list.cur_y;
139
	id = select_list.cur_y;
144
	list.SetSizes(LIST_PADDING, PANEL_H, Form.cwidth-scroll1.size_x-LIST_PADDING-LIST_PADDING, Form.cheight-PANEL_H-LIST_PADDING, 20);
140
	InitSelectList(LIST_PADDING, PANEL_H, Form.cwidth-scroll1.size_x-LIST_PADDING-LIST_PADDING, Form.cheight-PANEL_H-LIST_PADDING, false);
Line 145... Line 141...
145
	list.cur_y = id;
141
	select_list.cur_y = id;
146
 
142
 
147
	DrawBar(0,0, Form.cwidth, PANEL_H-LIST_PADDING, system.color.work);
143
	DrawBar(0,0, Form.cwidth, PANEL_H-LIST_PADDING, system.color.work);
148
	DrawRectangle3D(list.x-2, list.y-2, list.w+3+scroll1.size_x, list.h+3, system.color.work_dark, system.color.work_light);
144
	DrawRectangle3D(select_list.x-2, select_list.y-2, select_list.w+3+scroll1.size_x, select_list.h+3, system.color.work_dark, system.color.work_light);
149
	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);
145
	DrawWideRectangle(select_list.x-LIST_PADDING, select_list.y-LIST_PADDING, LIST_PADDING*2+select_list.w+scroll1.size_x, LIST_PADDING*2+select_list.h, LIST_PADDING-2, system.color.work);
150
	tabs.draw(list.x+10, list.y, SKINS, T_SKINS);
146
	tabs.draw(select_list.x+10, select_list.y, SKINS, T_SKINS);
Line 151... Line 147...
151
	if (dir_exists(WALP_STANDART_PATH)) tabs.draw(strlen(T_SKINS)*8+TAB_PADDING+list.x+21, list.y, WALLPAPERS, T_WALLPAPERS);
147
	if (dir_exists(WALP_STANDART_PATH)) tabs.draw(strlen(T_SKINS)*8+TAB_PADDING+select_list.x+21, select_list.y, WALLPAPERS, T_WALLPAPERS);
152
	DrawRectangle(list.x-1, list.y-1, list.w+1+scroll1.size_x, list.h+1, system.color.work_graph);
148
	DrawRectangle(select_list.x-1, select_list.y-1, select_list.w+1+scroll1.size_x, select_list.h+1, system.color.work_graph);
Line 153... Line -...
153
 
-
 
154
	Draw_List();
-
 
155
}
-
 
156
 
-
 
157
void DrawScroller()
-
 
Line 158... Line -...
158
{
-
 
159
	scroll1.bckg_col = MixColors(system.color.work, 0xBBBbbb, 80);
-
 
160
	scroll1.frnt_col = MixColors(system.color.work,0xFFFfff,120);
-
 
161
	scroll1.line_col = system.color.work_graph;
-
 
162
 
-
 
163
	scroll1.max_area = list.count;
-
 
164
	scroll1.cur_area = list.visible;
-
 
165
	scroll1.position = list.first;
-
 
166
 
-
 
167
	scroll1.all_redraw=1;
-
 
168
	scroll1.start_x = list.x + list.w;
-
 
Line 169... Line 149...
169
	scroll1.start_y = list.y-1;
149
 
170
	scroll1.size_y = list.h+2;
150
	DrawSelectList(select_list.count);
171
 
151
}
172
	scrollbar_v_draw(#scroll1);
152
 
173
}
153
 
174
 
154
 
175
void Open_Dir()
155
void Open_Dir()
176
{
156
{
177
	int j;
157
	int j;
178
	list.count = 0;
158
	select_list.count = 0;
179
	if(io.dir.buffer)free(io.dir.buffer);
159
	if(io.dir.buffer)free(io.dir.buffer);
180
	io.dir.load(#folder_path,DIR_ONLYREAL);
160
	io.dir.load(#folder_path,DIR_ONLYREAL);
181
	for (j=0; j
161
	for (j=0; j
182
	{
162
	{
183
		strcpy(#temp_filename, io.dir.position(j));
163
		strcpy(#temp_filename, io.dir.position(j));
184
		strlwr(#temp_filename);
164
		strlwr(#temp_filename);
185
		if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
165
		if (tabs.active_tab==SKINS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
186
		if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
166
		if (tabs.active_tab==WALLPAPERS) if (strcmpi(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
Line 187... Line 167...
187
		cur = list.count;
167
		cur = select_list.count;
188
		files_mas[cur]=j;
168
		files_mas[cur]=j;
189
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
169
		if (!strcmpi("default.skn",#temp_filename)) files_mas[0]>
190
		list.count++;
-
 
191
	}
-
 
Line 192... Line -...
192
}
-
 
193
 
-
 
194
void Draw_List()
170
		select_list.count++;
195
{
171
	}
196
	int i, yyy, list_last;
172
}
197
 
173
 
Line 198... Line 174...
198
	if (list.count > list.visible) list_last = list.visible; else list_last = list.count;
174
void DrawSelectList_Line(dword i)
199
 
175
{
200
	for (i=0; (i
176
	int yyy, list_last;
201
	{
177
 
202
		cur = list.first + i;
178
	cur = select_list.first + i;
203
		strcpy(#temp_filename, io.dir.position(files_mas[cur]));
179
	strcpy(#temp_filename, io.dir.position(files_mas[cur]));
204
		temp_filename[strlen(#temp_filename)-4] = 0;
180
	temp_filename[strlen(#temp_filename)-4] = 0;
205
		yyy = i*list.item_h+list.y;
181
	yyy = i*select_list.item_h+select_list.y;
206
		
182
	
207
		if (list.cur_y-list.first==i)
-
 
208
		{
183
	if (select_list.cur_y-select_list.first==i)
209
			DrawBar(list.x, yyy, list.w, list.item_h, system.color.work_button);
-
 
210
			WriteText(list.x+12,yyy+list.text_y,list.font_type,system.color.work_button_text, #temp_filename);
-
 
211
		}
184
	{
Line 212... Line 185...
212
		else
185
		DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
213
		{
186
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, #temp_filename);
214
			DrawBar(list.x,yyy,list.w, list.item_h, 0xFFFfff);
187
	}
Line 228... Line 201...
228
void EventTabClick(int N)
201
void EventTabClick(int N)
229
{
202
{
230
	tabs.click(N);
203
	tabs.click(N);
231
	if (tabs.active_tab == SKINS) 
204
	if (tabs.active_tab == SKINS) 
232
	{
205
	{
233
		active_wallpaper = list.cur_y;
206
		active_wallpaper = select_list.cur_y;
234
		strcpy(#folder_path, SKINS_STANDART_PATH);
207
		strcpy(#folder_path, SKINS_STANDART_PATH);
235
		list.ClearList();
208
		select_list.ClearList();
236
		Open_Dir();
209
		Open_Dir();
237
		if (!list.count) notify("'No skins were found' -E");
210
		if (!select_list.count) notify("'No skins were found' -E");
238
		list.cur_y = active_skin;
211
		select_list.cur_y = active_skin;
239
	}
212
	}
240
	if (tabs.active_tab == WALLPAPERS)
213
	if (tabs.active_tab == WALLPAPERS)
241
	{
214
	{
242
		active_skin = list.cur_y;
215
		active_skin = select_list.cur_y;
243
		strcpy(#folder_path, WALP_STANDART_PATH);
216
		strcpy(#folder_path, WALP_STANDART_PATH);
244
		list.ClearList();
217
		select_list.ClearList();
245
		Open_Dir();
218
		Open_Dir();
246
		if (!list.count) notify("'No wallpapers were found' -E");
219
		if (!select_list.count) notify("'No wallpapers were found' -E");
247
		list.cur_y = active_wallpaper;
220
		select_list.cur_y = active_wallpaper;
248
	}
221
	}
249
	if (list.cur_y>list.visible) list.first=list.cur_y; list.CheckDoesValuesOkey();
222
	if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey();
250
	if (list.w) DrawWindowContent();
223
	if (select_list.w) DrawWindowContent();
251
}
224
}
Line 252... Line 225...
252
 
225
 
253
void EventDeleteFile()
226
void EventDeleteFile()
254
{
227
{
Line 259... Line 232...
259
 
232
 
260
void EventApply()
233
void EventApply()
261
{
234
{
262
	if (tabs.active_tab==SKINS)
235
	if (tabs.active_tab==SKINS)
263
	{
236
	{
264
		cur = list.cur_y;
237
		cur = select_list.cur_y;
265
		sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur]));
238
		sprintf(#cur_file_path,"%s/%s",#folder_path,io.dir.position(files_mas[cur]));
266
		SetSystemSkin(#cur_file_path);
239
		SetSystemSkin(#cur_file_path);
267
	} 
240
	} 
268
	if (tabs.active_tab==WALLPAPERS)
241
	if (tabs.active_tab==WALLPAPERS)
269
	{
242
	{
270
		cur = list.cur_y;
243
		cur = select_list.cur_y;
271
		sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur]));
244
		sprintf(#cur_file_path,"\\S__%s/%s",#folder_path,io.dir.position(files_mas[cur]));
272
		RunProgram("/sys/media/kiv", #cur_file_path);
245
		RunProgram("/sys/media/kiv", #cur_file_path);
273
		Draw_List();
246
		DrawSelectList(select_list.count);
274
	}
247
	}
Line 275... Line 248...
275
}
248
}
276
 
249