Subversion Repositories Kolibri OS

Rev

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

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