Subversion Repositories Kolibri OS

Rev

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

Rev 4085 Rev 4410
Line 14... Line 14...
14
#include "..\lib\figures.h"
14
#include "..\lib\figures.h"
15
#include "..\lib\lib.obj\box_lib.h"
15
#include "..\lib\lib.obj\box_lib.h"
Line 16... Line 16...
16
 
16
 
17
#ifdef LANG_RUS
17
#ifdef LANG_RUS
18
	?define WINDOW_HEADER "“á¯à ¢«¥­¨¥ ⥬®©"
18
	?define WINDOW_HEADER "“á¯à ¢«¥­¨¥ ⥬®©"
19
	?define T_SKINS       "Žª­ "
19
	?define T_SKINS       "’¥¬  ®ª®­"
20
	?define T_WALLPAPERS  "Ž¡®¨ à ¡®ç¥£® á⮫ "
20
	?define T_WALLPAPERS  "Ž¡®¨ à ¡®ç¥£® á⮫ "
21
#else
21
#else
22
	?define WINDOW_HEADER "Appearance"
22
	?define WINDOW_HEADER "Appearance"
23
	?define T_SKINS       "Skins"
23
	?define T_SKINS       "Skins"
24
	?define T_WALLPAPERS  "Wallpappers"
24
	?define T_WALLPAPERS  "Wallpappers"
Line -... Line 25...
-
 
25
#endif
-
 
26
 
Line 25... Line 27...
25
#endif
27
unsigned char icons[sizeof(file "icons.raw")]= FROM "icons.raw";
26
 
28
 
27
 
29
 
Line 28... Line 30...
28
#define PANEL_H 30
30
#define PANEL_H 30
29
#define SKINS_STANDART_PATH "/sys/skins/"
31
#define SKINS_STANDART_PATH "/sys/res/skins/"
30
#define WALP_STANDART_PATH "/sys/wallpapers/"
32
#define WALP_STANDART_PATH "/sys/res/wallpapers/"
Line 31... Line 33...
31
 
33
 
32
llist list[2];
34
llist list[2];
33
int active;
35
int active;
34
enum { SKINS, WALLPAPERS };
36
enum { WALLPAPERS, SKINS };
Line 59... Line 61...
59
	free(buf);
61
	free(buf);
60
	if (GetDir(#buf, #filesnum, #folder_path, DIRS_ONLYREAL)!=0) return;
62
	if (GetDir(#buf, #filesnum, #folder_path, DIRS_ONLYREAL)!=0) return;
Line 61... Line 63...
61
 
63
 
62
	for (j=0; j
64
	for (j=0; j
63
	{
-
 
64
		strlwr(j*304 + buf+72);
65
	{
-
 
66
		strcpy(#temp_filename, j*304 + buf+72);
65
		strcpy(#temp_filename, j*304 + buf+72);
67
		strlwr(#temp_filename);
66
		if (active==SKINS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
68
		if (active==SKINS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
67
		if (active==WALLPAPERS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
69
		if (active==WALLPAPERS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
68
		cur = list[active].count;
70
		cur = list[active].count;
69
		files_mas[cur]=j;
71
		files_mas[cur]=j;
Line 74... Line 76...
74
}
76
}
Line 75... Line 77...
75
 
77
 
76
void Draw_List()
78
void Draw_List()
77
{
79
{
-
 
80
	int i;
78
	int i;
81
	int yyy;
79
	list[SKINS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
82
	list[SKINS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
Line 80... Line 83...
80
	list[WALLPAPERS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
83
	list[WALLPAPERS].SetSizes(0, PANEL_H, Form.cwidth-scroll1.size_x-1, Form.cheight-PANEL_H, 40, 20);
81
	
84
	
82
	for (i=0; i
85
	for (i=0; i
83
	{
86
	{
-
 
87
		cur = list[active].first;
-
 
88
		strcpy(#temp_filename, files_mas[i+cur]*304 + buf+72);
Line 84... Line 89...
84
		cur = list[active].first;
89
		temp_filename[strlen(#temp_filename)-4] = 0;
85
		strcpy(#temp_filename, files_mas[i+cur]*304 + buf+72);
90
		yyy = i*list[active].line_h+list[active].y;
86
		
91
		
87
		if (list[active].current-list[active].first==i)
92
		if (list[active].current-list[active].first==i)
88
		{
93
		{
89
			if (sc.work_button<>sc.work)
94
			if (sc.work_button<>sc.work)
90
			{
95
			{
91
				DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.work_button);
96
				DrawBar(0, yyy, list[active].w, list[active].line_h, sc.work_button);
92
				WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.work_button_text, #temp_filename);
97
				WriteText(11+23,yyy+list[active].text_y,0x80,sc.work_button_text, #temp_filename);
93
			}
98
			}
94
			else
99
			else
95
			{
100
			{
96
				DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.grab_button);
101
				DrawBar(0, yyy, list[active].w, list[active].line_h, sc.grab_button);
97
				WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.grab_button_text, #temp_filename);
102
				WriteText(11+23,yyy+list[active].text_y,0x80,sc.grab_button_text, #temp_filename);
98
			}	
103
			}
99
		}
104
		}
100
		else
105
		else
101
		{
106
		{
-
 
107
			DrawBar(0,yyy,list[active].w, list[active].line_h, 0xFFFfff);
102
			DrawBar(0,i*list[active].line_h+list[active].y,list[active].w, list[active].line_h, 0xFFFfff);
108
			WriteText(11+23,yyy+list[active].text_y,0x80,0, #temp_filename);
103
			WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,0, #temp_filename);
109
		}
104
		}
110
		_PutImage(11,yyy+2,  16,15,   list[WALLPAPERS].active*16*15*3+#icons);
105
	}
111
	}
Line 106... Line 112...
106
	DrawBar(0,list[active].visible*list[active].line_h+list[active].y, list[active].w, -list[active].visible*list[active].line_h+ list[active].h, 0xFFFfff);
112
	DrawBar(0,list[active].visible*list[active].line_h+list[active].y, list[active].w, -list[active].visible*list[active].line_h+ list[active].h, 0xFFFfff);
107
	DrawScroller();
113
	DrawScroller();
108
}
-
 
109
 
114
}
110
void GetFiles(int set_active)
115
 
111
{
116
void GetFiles()
112
	active = set_active;
117
{
113
	if (active==SKINS)
118
	if (list[SKINS].active)
114
	{
119
	{
115
		strcpy(#folder_path, SKINS_STANDART_PATH);
120
		strcpy(#folder_path, SKINS_STANDART_PATH);
116
		Open_Dir();
121
		Open_Dir();
117
		if (!list[active].count) notify("No skins were found");
122
		if (!list[active].count) notify("No skins were found");
118
	}
123
	}
119
	if (active==WALLPAPERS)
124
	if (list[WALLPAPERS].active)
120
	{
125
	{
121
		strcpy(#folder_path, WALP_STANDART_PATH);
126
		strcpy(#folder_path, WALP_STANDART_PATH);
Line 122... Line 127...
122
		Open_Dir();
127
		Open_Dir();
123
		if (!list[active].count) notify("No wallpapers were found");
128
		if (!list[active].count) notify("No wallpapers were found");
124
	}
129
	}
125
}
130
}
126
 
131
 
127
void Apply()
132
void Apply()
128
{
133
{
129
	if (active==SKINS)
134
	if (list[SKINS].active)
-
 
135
	{
130
	{
136
		strcpy(#cur_file_path, #folder_path);
131
		strcpy(#cur_file_path, #folder_path);
137
		cur = list[SKINS].current;
132
		cur = list[active].current;
138
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
133
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
139
		SetSystemSkin(#cur_file_path);
134
		SetSystemSkin(#cur_file_path);
140
		//Draw_List();
135
	} 
141
	} 
136
	if (active==WALLPAPERS)
142
	if (list[WALLPAPERS].active)
137
	{
143
	{
138
		strcpy(#cur_file_path, "\\S__");
144
		strcpy(#cur_file_path, "\\S__");
139
		strcat(#cur_file_path, #folder_path);
145
		strcat(#cur_file_path, #folder_path);
140
		cur = list[active].current;
146
		cur = list[WALLPAPERS].current;
Line 141... Line 147...
141
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
147
		strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
142
		RunProgram("/sys/media/kiv", #cur_file_path);
148
		RunProgram("/sys/media/kiv", #cur_file_path);
143
		Draw_List();
149
		Draw_List();
144
	}
150
	}
145
}
151
}
Line 146... Line 152...
146
 
152
 
147
OpenFile()
153
OpenFile()
148
{
154
{
149
	if (active==SKINS) RunProgram("/sys/desktop", #cur_file_path);
155
	if (list[SKINS].active) RunProgram("/sys/desktop", #cur_file_path);
Line 150... Line 156...
150
	if (active==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
156
	if (list[WALLPAPERS].active) RunProgram("/sys/media/kiv", #cur_file_path);
-
 
157
}
151
}
158
 
152
 
159
 
153
 
160
void main()
154
void main()
161
{   
155
{   
162
	int id, key, mouse_clicked;
156
	int id, key, mouse_clicked;
163
	mouse mm;
157
	mouse mm;
164
 
158
 
165
	mem_Init();
159
	mem_Init();
166
	SetEventMask(0x27);
160
	if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("Fatal Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
167
	if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("Fatal Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
161
	list[SKINS].current = list[WALLPAPERS].current = -1;
168
	list[SKINS].current = list[WALLPAPERS].current = -1;
Line 176... Line 183...
176
				Draw_List();
183
				Draw_List();
177
				break;
184
				break;
178
			}
185
			}
Line 179... Line 186...
179
		
186
		
-
 
187
	  		mm.get();
-
 
188
 
-
 
189
	  		if (mm.vert)
180
	  		mm.get();
190
	  		{
-
 
191
	  			if (list[SKINS].active) && (list[SKINS].MouseScroll(mm.vert)) Draw_List();
-
 
192
	  			if (list[WALLPAPERS].active) && (list[WALLPAPERS].MouseScroll(mm.vert)) Draw_List();
-
 
193
	  		} 
181
	  		if (mm.vert) && (list[active].MouseScroll(mm.vert)) Draw_List();
194
 
182
	  		if (mouse_clicked)
195
	  		if (mouse_clicked)
183
	  		{
196
	  		{
184
	  			if (!mm.lkm) && (active==SKINS) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
197
	  			if (!mm.lkm) && (list[SKINS].active) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
185
	  			if (!mm.lkm) && (active==WALLPAPERS) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
198
	  			if (!mm.lkm) && (list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
186
	  			mouse_clicked=0;
199
	  			mouse_clicked=0;
187
	  		}
200
	  		}
188
	  		if (mm.lkm) && (list[SKINS].MouseOver(mm.x, mm.y)) mouse_clicked=1;
201
	  		if (mm.lkm) && (list[SKINS].MouseOver(mm.x, mm.y)) mouse_clicked=1;
Line -... Line 202...
-
 
202
	  		break;
189
	  		break;
203
 
190
 
204
 
191
		case evButton:
205
		case evButton:
192
			id=GetButtonID();
206
			id=GetButtonID();
193
			if (id==1) ExitProcess();
207
			if (id==1) ExitProcess();
194
			if (id==2) TabClick(SKINS);
208
			if (id==2) TabClick(WALLPAPERS);
Line 195... Line 209...
195
			if (id==3) TabClick(WALLPAPERS);
209
			if (id==3) TabClick(SKINS);
196
			break;
210
			break;
197
	  
211
	  
198
		case evKey:
212
		case evKey:
199
			key = GetKey();
213
			key = GetKey();
200
			if (active==SKINS) && (list[SKINS].ProcessKey(key)) Apply();
-
 
201
			if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessKey(key)) Apply();
-
 
202
			IF (key==013) OpenFile();
-
 
203
			if (key==9) //Tab
214
			if (list[SKINS].active) && (list[SKINS].ProcessKey(key)) Apply();
204
			{
-
 
205
				if (active==SKINS)
-
 
206
					TabClick(WALLPAPERS);
-
 
207
				else
215
			if (list[WALLPAPERS].active) && (list[WALLPAPERS].ProcessKey(key)) Apply();
208
					TabClick(SKINS);
216
			IF (key==013) OpenFile();
209
			}
217
			if (key==9) if (list[SKINS].active) TabClick(WALLPAPERS); else TabClick(SKINS);
210
			IF (key==182) //Del
218
			IF (key==182) //Del
211
			{
219
			{
212
				DeleteFile(#cur_file_path);
220
				DeleteFile(#cur_file_path);
213
				Open_Dir();
221
				Open_Dir();
Line 214... Line 222...
214
				Apply();
222
				Apply();
215
			}
223
			}
216
			break;
224
			break;
217
		 
225
		 
218
		 case evReDraw:
226
		 case evReDraw:
219
			sc.get();			
227
			sc.get();			
220
			DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER);
228
			DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER,0);
221
			GetProcessInfo(#Form, SelfInfo);
229
			GetProcessInfo(#Form, SelfInfo);
222
			IF (Form.status_window>=2) break;
230
			IF (Form.status_window>=2) break;
223
			DrawTabs();
231
			DrawTabs();
Line -... Line 232...
-
 
232
			Draw_List();
Line 224... Line 233...
224
			Draw_List();
233
	  }
225
	  }
234
   }
226
   }
235
}
-
 
236
 
-
 
237
#define BT_PADDING 16
-
 
238
 
-
 
239
void DrawTab(dword x,y, but_id, is_active, text)
-
 
240
{
-
 
241
	dword col_bg, col_text;
-
 
242
	dword w=strlen(text)*6+BT_PADDING, h=21;
-
 
243
 
-
 
244
	if (is_active)
-
 
245
	{
-
 
246
		col_bg=sc.work_button;
-
 
247
		col_text=sc.work_button_text;
-
 
248
	}
-
 
249
	else
-
 
250
	{
-
 
251
		col_bg=sc.work;
-
 
252
		col_text=sc.work_text;
-
 
253
	} 
-
 
254
	DrawRectangle(x,y, w,h, sc.work_graph);
227
}
255
	DrawCaptButton(x+1,y+1, w-2,h-1, but_id, col_bg, col_text, text);
Line 228... Line -...
228
 
-
 
229
 
-
 
230
void DrawTabs()
-
 
231
{
-
 
232
	dword col_bg, col_text;
256
}
233
	DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work);
257
 
Line 234... Line 258...
234
 
258
 
235
	if (active==SKINS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} 
259
void DrawTabs()
236
	DrawRectangle(10-1,7-1, 65+2, 21+2, sc.work_graph);
260
{
Line 237... Line 261...
237
	DrawCaptButton(10,7, 65, 21, 2, col_bg, col_text, T_SKINS); //¢®ªà㣠à¨á®¢ âì ¯¬ïâ®ã£
261
	DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work);
238
	if (active==WALLPAPERS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} 
262
 
-
 
263
	DrawTab(10,7, 2, list[WALLPAPERS].active, T_WALLPAPERS);
-
 
264
	DrawTab(strlen(T_WALLPAPERS)*6+BT_PADDING+21,7, 3, list[SKINS].active, T_SKINS);
-
 
265
 
-
 
266
	DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph);
-
 
267
	DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
-
 
268
}
-
 
269
 
-
 
270
void TabClick(int N)
-
 
271
{
-
 
272
	if (N==SKINS) 
-
 
273
	{
239
	DrawRectangle(90-1,7-1, strlen(T_WALLPAPERS)*6+16+2, 21+2, sc.work_graph);
274
		list[SKINS].active = 1;	
240
	DrawCaptButton(90,7, strlen(T_WALLPAPERS)*6+16, 21, 3, col_bg, col_text, T_WALLPAPERS);
275
		list[WALLPAPERS].active = 0;	
241
 
276
	}
242
	DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph);
277
	if (N==WALLPAPERS)