Subversion Repositories Kolibri OS

Rev

Rev 6366 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6366 Rev 6641
1
#define MEMSIZE 4096*60
1
#define MEMSIZE 4096*60
2
 
2
 
3
#include "../lib/font.h"
3
#include "../lib/font.h"
4
#include "../lib/io.h"
4
#include "../lib/io.h"
5
#include "../lib/gui.h"
5
#include "../lib/gui.h"
6
#include "../lib/list_box.h"
6
#include "../lib/list_box.h"
7
#include "../lib/menu.h"
7
#include "../lib/menu.h"
8
#include "../lib/obj/box_lib.h"
8
#include "../lib/obj/box_lib.h"
9
#include "../lib/obj/libini.h"
9
#include "../lib/obj/libini.h"
10
#include "../lib/obj/iconv.h"
10
#include "../lib/obj/iconv.h"
11
#include "../lib/obj/proc_lib.h"
11
#include "../lib/obj/proc_lib.h"
12
#include "../lib/obj/http.h"
12
#include "../lib/obj/http.h"
13
#include "../lib/cursor.h"
13
#include "../lib/cursor.h"
14
#include "../lib/patterns/libimg_load_skin.h"
14
#include "../lib/patterns/libimg_load_skin.h"
15
#include "../lib/patterns/simple_open_dialog.h"
15
#include "../lib/patterns/simple_open_dialog.h"
16
#include "../lib/patterns/history.h"
16
#include "../lib/patterns/history.h"
17
#include "../lib/patterns/http_downloader.h"
17
#include "../lib/patterns/http_downloader.h"
18
#include "../browser/download_manager.h"
18
#include "../browser/download_manager.h"
19
 
19
 
20
char default_dir[] = "/rd/1";
20
char default_dir[] = "/rd/1";
21
od_filter filter2 = {0,0};
21
od_filter filter2 = {0,0};
22
 
22
 
23
char accept_language[]= "Accept-Language: ru\n";
23
char accept_language[]= "Accept-Language: ru\n";
24
 
24
 
25
#define TOOLBAR_H 36
25
#define TOOLBAR_H 36
26
#define TOOLBAR_ICON_WIDTH  26
26
#define TOOLBAR_ICON_WIDTH  26
27
#define TOOLBAR_ICON_HEIGHT 24
27
#define TOOLBAR_ICON_HEIGHT 24
28
 
28
 
29
#define DEFAULT_EDITOR "/sys/tinypad"
29
#define DEFAULT_EDITOR "/sys/tinypad"
30
#define DEFAULT_PREVIEW_PATH "/tmp0/1/aelia_preview.txt"
30
#define DEFAULT_PREVIEW_PATH "/tmp0/1/aelia_preview.txt"
31
 
31
 
32
//ATTENTION: each page must have '\0' character at the end of the file
32
//ATTENTION: each page must have '\0' character at the end of the file
33
char buidin_page_home[] = FROM "buidin_pages\\home.htm";
33
char buidin_page_home[] = FROM "buidin_pages\\home.htm";
34
char buidin_page_about[] = FROM "buidin_pages\\about.htm";
34
char buidin_page_about[] = FROM "buidin_pages\\about.htm";
35
char buidin_page_not_found[] = FROM "buidin_pages\\not_found.htm";
35
char buidin_page_not_found[] = FROM "buidin_pages\\not_found.htm";
36
 
36
 
37
#define UML 4096*2
37
#define UML 4096*2
38
 
38
 
39
scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
39
scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
40
llist list;
40
llist list;
41
 
41
 
42
proc_info Form;
42
proc_info Form;
43
char title[4196];
43
char title[4196];
44
 
44
 
45
enum {
45
enum {
46
	OPEN_FILE,
46
	OPEN_FILE,
47
	MAGNIFY_MINUS,
47
	MAGNIFY_MINUS,
48
	MAGNIFY_PLUS,
48
	MAGNIFY_PLUS,
49
	CHANGE_ENCODING,
49
	CHANGE_ENCODING,
50
	RUN_EDIT,
50
	RUN_EDIT,
51
	GO_BACK,
51
	GO_BACK,
52
	GO_FORWARD,
52
	GO_FORWARD,
53
	SANDWICH
53
	SANDWICH
54
};
54
};
55
 
55
 
56
char address[UML]="http://";
56
char address[UML]="http://";
57
int	mouse_address_box;
57
int	mouse_address_box;
58
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,#mouse_address_box,2,19,19};
58
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,#mouse_address_box,2,19,19};
59
 
59
 
60
CustomCursor CursorPointer;
60
CustomCursor CursorPointer;
61
dword CursorFile = FROM "pointer.cur";
61
dword CursorFile = FROM "pointer.cur";
62
 
62
 
63
#include "favicon.h"
63
#include "favicon.h"
64
#include "ini.h"
64
#include "ini.h"
65
#include "gui.h"
65
#include "gui.h"
66
#include "label.h"
66
#include "label.h"
67
#include "link.h"
67
#include "link.h"
68
#include "tag.h"
68
#include "tag.h"
69
#include "prepare_page.h"
69
#include "prepare_page.h"
70
//#include "special_symbols.h"
70
//#include "special_symbols.h"
71
 
71
 
72
#define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nDownloader\nAbout"
72
#define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nDownloader\nAbout"
73
 
73
 
74
void InitDlls()
74
void InitDlls()
75
{
75
{
76
	load_dll(boxlib,    #box_lib_init,   0);
76
	load_dll(boxlib,    #box_lib_init,   0);
77
	load_dll(libHTTP,   #http_lib_init,  1);
77
	load_dll(libHTTP,   #http_lib_init,  1);
78
	load_dll(libio,     #libio_init,     1);
78
	load_dll(libio,     #libio_init,     1);
79
	load_dll(libimg,    #libimg_init,    1);
79
	load_dll(libimg,    #libimg_init,    1);
80
	//load_dll(libini,    #lib_init,       1);
80
	//load_dll(libini,    #lib_init,       1);
81
	load_dll(iconv_lib, #iconv_open,     0);
81
	load_dll(iconv_lib, #iconv_open,     0);
82
	load_dll(Proc_lib,  #OpenDialog_init,0);
82
	load_dll(Proc_lib,  #OpenDialog_init,0);
83
}
83
}
84
 
84
 
85
 
85
 
86
void main()
86
void main()
87
{   
87
{   
88
	InitDlls();	
88
	InitDlls();	
89
	OpenDialog_init stdcall (#o_dialog);
89
	OpenDialog_init stdcall (#o_dialog);
90
	CursorPointer.Load(#CursorFile);
90
	CursorPointer.Load(#CursorFile);
91
	label.init(DEFAULT_FONT);
91
	label.init(DEFAULT_FONT);
92
	Libimg_LoadImage(#skin, abspath("toolbar.png"));
92
	Libimg_LoadImage(#skin, abspath("toolbar.png"));
93
	LoadIniSettings();
93
	LoadIniSettings();
94
	list.no_selection = true;
94
	list.no_selection = true;
95
	SetEventMask(10000000000000000000000001100111b);
95
	SetEventMask(10000000000000000000000001100111b);
96
	loop()
96
	loop()
97
	{
97
	{
98
		switch(WaitEvent())
98
		switch(WaitEvent())
99
		{
99
		{
100
			case evMouse:
100
			case evMouse:
101
				HandleMouseEvent();
101
				HandleMouseEvent();
102
				break;
102
				break;
103
			case evKey:
103
			case evKey:
104
				HandleKeyEvent();
104
				HandleKeyEvent();
105
				break;
105
				break;
106
			case evButton:
106
			case evButton:
107
				HandleButtonEvent();
107
				HandleButtonEvent();
108
				break;
108
				break;
109
			case evReDraw:
109
			case evReDraw:
110
				draw_window();
110
				draw_window();
111
				if (menu.list.cur_y>=10) && (menu.list.cur_y<20) {
111
				if (menu.list.cur_y>=10) && (menu.list.cur_y<20) {
112
					encoding = menu.list.cur_y - 10;
112
					encoding = menu.list.cur_y - 10;
113
					EventPageRefresh();
113
					EventPageRefresh();
114
					menu.list.cur_y = 0;
114
					menu.list.cur_y = 0;
115
				}
115
				}
116
				if (menu.list.cur_y>=20) {
116
				if (menu.list.cur_y>=20) {
117
					menu.list.cur_y-=20;
117
					menu.list.cur_y-=20;
118
					if (menu.list.cur_y==0) EventPageRefresh();
118
					if (menu.list.cur_y==0) EventPageRefresh();
119
					if (menu.list.cur_y==1) EventRunEdit();
119
					if (menu.list.cur_y==1) EventRunEdit();
120
					if (menu.list.cur_y==2) EventShowHistory();
120
					if (menu.list.cur_y==2) EventShowHistory();
121
					if (menu.list.cur_y==3) EventShowDownloader();
121
					if (menu.list.cur_y==3) EventShowDownloader();
122
					if (menu.list.cur_y==4) EventShowInfo();
122
					if (menu.list.cur_y==4) EventShowInfo();
123
					menu.list.cur_y = 0;
123
					menu.list.cur_y = 0;
124
				} 
124
				} 
125
		}
125
		}
126
	}
126
	}
127
}
127
}
128
 
128
 
129
 
129
 
130
void HandleButtonEvent()
130
void HandleButtonEvent()
131
{
131
{
132
	byte btn = GetButtonID();
132
	byte btn = GetButtonID();
133
	if (btn==1) {
133
	if (btn==1) {
134
		SaveIniSettings();
134
		SaveIniSettings();
135
		ExitProcess();
135
		ExitProcess();
136
	}
136
	}
137
	switch(btn-10)
137
	switch(btn-10)
138
	{
138
	{
139
		case GO_BACK:
139
		case GO_BACK:
140
			EventGoBack();
140
			EventGoBack();
141
			break;
141
			break;
142
		case GO_FORWARD:
142
		case GO_FORWARD:
143
			EventGoForward();
143
			EventGoForward();
144
			break;
144
			break;
145
		case OPEN_FILE:
145
		case OPEN_FILE:
146
			EventOpenDialog();
146
			EventOpenDialog();
147
			break;
147
			break;
148
		case MAGNIFY_PLUS:
148
		case MAGNIFY_PLUS:
149
			EventMagnifyPlus();
149
			EventMagnifyPlus();
150
			break;
150
			break;
151
		case MAGNIFY_MINUS:
151
		case MAGNIFY_MINUS:
152
			EventMagnifyMinus();
152
			EventMagnifyMinus();
153
			break;
153
			break;
154
		case CHANGE_ENCODING:
154
		case CHANGE_ENCODING:
155
			EventChangeEncoding();
155
			EventChangeEncoding();
156
			break;
156
			break;
157
		case RUN_EDIT:
157
		case RUN_EDIT:
158
			EventRunEdit();
158
			EventRunEdit();
159
			break;
159
			break;
160
		case SANDWICH:
160
		case SANDWICH:
161
			EventShowSandwichMenu();
161
			EventShowSandwichMenu();
162
			break;
162
			break;
163
	}
163
	}
164
}
164
}
165
 
165
 
166
 
166
 
167
void HandleKeyEvent()
167
void HandleKeyEvent()
168
{
168
{
169
	GetKeys();
169
	GetKeys();
170
	switch (key_scancode) 
170
	switch (key_scancode) 
171
	{
171
	{
172
		case 059:
172
		case 059:
173
			EventShowInfo();
173
			EventShowInfo();
174
			return;
174
			return;
175
		case SCAN_CODE_ENTER:
175
		case SCAN_CODE_ENTER:
176
			EventOpenAddress(#address);
176
			EventOpenAddress(#address);
177
			return;
177
			return;
178
		case SCAN_CODE_BS:
178
		case SCAN_CODE_BS:
179
			if (! address_box.flags & 0b10) {
179
			if (! address_box.flags & 0b10) {
180
				EventGoBack();
180
				EventGoBack();
181
				return;
181
				return;
182
			}
182
			}
183
	}
183
	}
184
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
184
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
185
		switch (key_scancode)
185
		switch (key_scancode)
186
		{
186
		{
187
			case 024: //O
187
			case 024: //O
188
				EventOpenDialog();
188
				EventOpenDialog();
189
				break;
189
				break;
190
			case SCAN_CODE_UP:
190
			case SCAN_CODE_UP:
191
				EventMagnifyPlus();
191
				EventMagnifyPlus();
192
				break;
192
				break;
193
			case SCAN_CODE_DOWN:
193
			case SCAN_CODE_DOWN:
194
				EventMagnifyMinus();
194
				EventMagnifyMinus();
195
				break;
195
				break;
196
			case 018: //E
196
			case 018: //E
197
				EventRunEdit();
197
				EventRunEdit();
198
				break;
198
				break;
199
			case 035: //H
199
			case 035: //H
200
				EventShowHistory();
200
				EventShowHistory();
201
				break;
201
				break;
202
			case SCAN_CODE_TAB:
202
			case SCAN_CODE_TAB:
203
				EventChangeEncoding();
203
				EventChangeEncoding();
204
				break;
204
				break;
205
		}
205
		}
206
		return;
-
 
207
	}
206
	}
208
	if (list.ProcessKey(key_scancode)) {
207
	if (list.ProcessKey(key_scancode)) {
209
		DrawPage();
208
		DrawPage();
210
		return;
209
		return;
211
	}
210
	}
212
	if (key_ascii != 0x0d)
211
	if (key_ascii != 0x0d)
213
	&& (key_ascii != ASCII_KEY_PGDN) 
212
	&& (key_ascii != ASCII_KEY_PGDN) 
214
	&& (key_ascii != ASCII_KEY_PGUP) {
213
	&& (key_ascii != ASCII_KEY_PGUP) {
215
		EAX = key_ascii << 8; 
214
		EAX = key_editbox;
216
		edit_box_key stdcall(#address_box);
215
		edit_box_key stdcall(#address_box);
217
	}
216
	}
218
}
217
}
219
 
218
 
220
 
219
 
221
void HandleMouseEvent()
220
void HandleMouseEvent()
222
{
221
{
223
	edit_box_mouse stdcall (#address_box);
222
	edit_box_mouse stdcall (#address_box);
224
	mouse.get();
223
	mouse.get();
225
	list.wheel_size = 7;
224
	list.wheel_size = 7;
226
	link.hover();
225
	link.hover();
227
	if (list.MouseScroll(mouse.vert)) {
226
	if (list.MouseScroll(mouse.vert)) {
228
		DrawPage(); 
227
		DrawPage(); 
229
		return; 
228
		return; 
230
	}
229
	}
231
	scrollbar_v_mouse (#scroll);
230
	scrollbar_v_mouse (#scroll);
232
	if (list.first != scroll.position) {
231
	if (list.first != scroll.position) {
233
		list.first = scroll.position;
232
		list.first = scroll.position;
234
		DrawPage(); 
233
		DrawPage(); 
235
	}
234
	}
236
}
235
}
237
 
236
 
238
 
237
 
239
/* ----------------------------------------------------- */
238
/* ----------------------------------------------------- */
240
 
239
 
241
void EventOpenDialog()
240
void EventOpenDialog()
242
{
241
{
243
	OpenDialog_start stdcall (#o_dialog);
242
	OpenDialog_start stdcall (#o_dialog);
244
	if (o_dialog.status) EventOpenAddress(#openfile_path);
243
	if (o_dialog.status) EventOpenAddress(#openfile_path);
245
}
244
}
246
 
245
 
247
void EventOpenAddress(dword _new_address)
246
void EventOpenAddress(dword _new_address)
248
{
247
{
249
char temp[UML];
248
char temp[UML];
250
char favicon_address[UML];
249
char favicon_address[UML];
251
	if (!ESBYTE[_new_address]) return;
250
	if (!ESBYTE[_new_address]) return;
252
	debugln("====================================");
251
	debugln("====================================");
253
	debug("address: ");
252
	debug("address: ");
254
	debugln(_new_address);
253
	debugln(_new_address);
255
	strlcpy(#address, _new_address, UML);
254
	strlcpy(#address, _new_address, UML);
256
	strlwr(#address);
255
	strlwr(#address);
257
	DrawAddressBox();
256
	DrawAddressBox();
258
 
257
 
259
	/*
258
	/*
260
	There could be several possible types of addresses:
259
	There could be several possible types of addresses:
261
	- build in page
260
	- build in page
262
	- local file
261
	- local file
263
	- url
262
	- url
264
	So we need to detect what incoming address is
263
	So we need to detect what incoming address is
265
	and then halndle it in the propper way.
264
	and then halndle it in the propper way.
266
	*/
265
	*/
267
 
266
 
268
	io.buffer_data = 0;
267
	io.buffer_data = 0;
269
	favicon.get(NULL);
268
	favicon.get(NULL);
270
 
269
 
271
	// - build in page
270
	// - build in page
272
	if (!strncmp(#address,"aelia:",6)) {
271
	if (!strncmp(#address,"aelia:",6)) {
273
		debugln("this is buildin page");
272
		debugln("this is buildin page");
274
		if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home;
273
		if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home;
275
		if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about;
274
		if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about;
276
		if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory();
275
		if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory();
277
	}
276
	}
278
	// - local file
277
	// - local file
279
	else if (check_is_the_adress_local(#address)==true) {
278
	else if (check_is_the_adress_local(#address)==true) {
280
		debugln("this is local address");
279
		debugln("this is local address");
281
		io.read(#address);
280
		io.read(#address);
282
	}
281
	}
283
	// - url
282
	// - url
284
	else {
283
	else {
285
		debugln("this is url");
284
		debugln("this is url");
286
		if (strncmp(#address,"http://",7)!=0) {
285
		if (strncmp(#address,"http://",7)!=0) {
287
			strcpy(#temp, "http://");
286
			strcpy(#temp, "http://");
288
			strlcpy(#temp, #address, UML);
287
			strlcpy(#temp, #address, UML);
289
			strlcpy(#address, #temp, UML);
288
			strlcpy(#address, #temp, UML);
290
			DrawAddressBox();
289
			DrawAddressBox();
291
		}
290
		}
292
		if (!downloader.Start(#address)) {
291
		if (!downloader.Start(#address)) {
293
			downloader.Stop();
292
			downloader.Stop();
294
		} else {
293
		} else {
295
			while (downloader.state!=STATE_COMPLETED)
294
			while (downloader.state!=STATE_COMPLETED)
296
			{ 
295
			{ 
297
				downloader.MonitorProgress(); 
296
				downloader.MonitorProgress(); 
298
				if (downloader.data_full_size>0)
297
				if (downloader.data_full_size>0)
299
					DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE*downloader.data_downloaded_size/downloader.data_full_size); 
298
					DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE*downloader.data_downloaded_size/downloader.data_full_size); 
300
				else
299
				else
301
					DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2);
300
					DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2);
302
			}
301
			}
303
			strcpy(#address,downloader.url);
302
			strcpy(#address,downloader.url);
304
			DrawAddressBox();
303
			DrawAddressBox();
305
			io.buffer_data = downloader.bufpointer;
304
			io.buffer_data = downloader.bufpointer;
306
			get_absolute_url(#favicon_address, #address, "/favicon.ico");
305
			get_absolute_url(#favicon_address, #address, "/favicon.ico");
307
			favicon.get(#favicon_address);
306
			favicon.get(#favicon_address);
308
		}
307
		}
309
	}
308
	}
310
 
309
 
311
	if (!io.buffer_data) {
310
	if (!io.buffer_data) {
312
		debugln("page not found");
311
		debugln("page not found");
313
		io.buffer_data = #buidin_page_not_found;
312
		io.buffer_data = #buidin_page_not_found;
314
	}
313
	}
315
 
314
 
316
	history.add(#address);
315
	history.add(#address);
317
	favicon.draw(address_box.left-18, address_box.top-1);
316
	favicon.draw(address_box.left-18, address_box.top-1);
318
 
317
 
319
	/* 
318
	/* 
320
	Great! So we have the page in our buffer.
319
	Great! So we have the page in our buffer.
321
	We don't know is it a plain text or html.
320
	We don't know is it a plain text or html.
322
	So we need to parse it and draw.
321
	So we need to parse it and draw.
323
	*/
322
	*/
324
 
323
 
325
	list.KeyHome();
324
	list.KeyHome();
326
	list.ClearList();
325
	list.ClearList();
327
	PreparePage();
326
	PreparePage();
328
}
327
}
329
 
328
 
330
void EventMagnifyPlus()
329
void EventMagnifyPlus()
331
{
330
{
332
	label.size.pt++;
331
	label.size.pt++;
333
	if(!label.changeSIZE())
332
	if(!label.changeSIZE())
334
		label.size.pt--;
333
		label.size.pt--;
335
	else
334
	else
336
		PreparePage();
335
		PreparePage();
337
}
336
}
338
 
337
 
339
void EventMagnifyMinus()
338
void EventMagnifyMinus()
340
{
339
{
341
	label.size.pt--;
340
	label.size.pt--;
342
	if(!label.changeSIZE())
341
	if(!label.changeSIZE())
343
		label.size.pt++;
342
		label.size.pt++;
344
	else
343
	else
345
		PreparePage();
344
		PreparePage();
346
}
345
}
347
 
346
 
348
void EventRunEdit()
347
void EventRunEdit()
349
{
348
{
350
	if (check_is_the_adress_local(history.current())==true) {
349
	if (check_is_the_adress_local(history.current())==true) {
351
		io.run(DEFAULT_EDITOR, history.current());
350
		io.run(DEFAULT_EDITOR, history.current());
352
	}
351
	}
353
	else {
352
	else {
354
		//io.write(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); // <--- doesn't work, smth odd, need to check
353
		//io.write(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); // <--- doesn't work, smth odd, need to check
355
		WriteFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH);
354
		WriteFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH);
356
		io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH);
355
		io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH);
357
	}
356
	}
358
}
357
}
359
 
358
 
360
void EventChangeEncoding()
359
void EventChangeEncoding()
361
{
360
{
362
	menu.selected = encoding + 1;
361
	menu.selected = encoding + 1;
363
	menu.show(Form.left+Form.cwidth-97,Form.top+TOOLBAR_H+skin_height-6, 130, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10);
362
	menu.show(Form.left+Form.cwidth-97,Form.top+TOOLBAR_H+skin_height-6, 130, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10);
364
}
363
}
365
 
364
 
366
void EventShowInfo() {
365
void EventShowInfo() {
367
	EventOpenAddress("aelia:about");
366
	EventOpenAddress("aelia:about");
368
}
367
}
369
 
368
 
370
void EventShowHistory()
369
void EventShowHistory()
371
{
370
{
372
	EventOpenAddress("aelia:history");
371
	EventOpenAddress("aelia:history");
373
}
372
}
374
 
373
 
375
void EventGoBack()
374
void EventGoBack()
376
{
375
{
377
	if (history.back()) EventOpenAddress(history.current());
376
	if (history.back()) EventOpenAddress(history.current());
378
}
377
}
379
 
378
 
380
void EventGoForward()
379
void EventGoForward()
381
{
380
{
382
	if (history.forward()) EventOpenAddress(history.current());
381
	if (history.forward()) EventOpenAddress(history.current());
383
}
382
}
384
 
383
 
385
void EventShowSandwichMenu()
384
void EventShowSandwichMenu()
386
{
385
{
387
	menu.selected = 0;
386
	menu.selected = 0;
388
	menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20);
387
	menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20);
389
}
388
}
390
 
389
 
391
void EventPageRefresh()
390
void EventPageRefresh()
392
{
391
{
393
	EventOpenAddress(history.current());
392
	EventOpenAddress(history.current());
394
}
393
}
395
 
394
 
396
void EventShowDownloader()
395
void EventShowDownloader()
397
{
396
{
398
	if (!downloader_opened) {
397
	if (!downloader_opened) {
399
		downloader_edit = NULL;
398
		downloader_edit = NULL;
400
		CreateThread(#Downloader,#downloader_stak+4092);
399
		CreateThread(#Downloader,#downloader_stak+4092);
401
	}
400
	}
402
}
401
}
403
 
402
 
404
/* ------------------------------------------- */
403
/* ------------------------------------------- */
405
 
404
 
406
 
405
 
407
void draw_window()
406
void draw_window()
408
{
407
{
409
	DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title);
408
	DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title);
410
	GetProcessInfo(#Form, SelfInfo);
409
	GetProcessInfo(#Form, SelfInfo);
411
	if (Form.status_window>2) return;
410
	if (Form.status_window>2) return;
412
 
411
 
413
	if (Form.width  < 200) { MoveSize(OLD,OLD,200,OLD); return; }
412
	if (Form.width  < 200) { MoveSize(OLD,OLD,200,OLD); return; }
414
	if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
413
	if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
415
	
414
	
416
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1);
415
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1);
417
	DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece);
416
	DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece);
418
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F);
417
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F);
419
	
418
	
420
	DrawToolbarButton(GO_BACK,         8);
419
	DrawToolbarButton(GO_BACK,         8);
421
	DrawToolbarButton(GO_FORWARD,      33);
420
	DrawToolbarButton(GO_FORWARD,      33);
422
	DrawToolbarButton(OPEN_FILE,       68);
421
	DrawToolbarButton(OPEN_FILE,       68);
423
	DrawToolbarButton(MAGNIFY_PLUS,    Form.cwidth - 125);
422
	DrawToolbarButton(MAGNIFY_PLUS,    Form.cwidth - 125);
424
	DrawToolbarButton(MAGNIFY_MINUS,   Form.cwidth - 100);
423
	DrawToolbarButton(MAGNIFY_MINUS,   Form.cwidth - 100);
425
	DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64);
424
	DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64);
426
	DrawToolbarButton(SANDWICH,        Form.cwidth - 31);
425
	DrawToolbarButton(SANDWICH,        Form.cwidth - 31);
427
 
426
 
428
	DrawAddressBox();
427
	DrawAddressBox();
429
 
428
 
430
	if ((Form.cwidth-scroll.size_x-1 == list.w) && 
429
	if ((Form.cwidth-scroll.size_x-1 == list.w) && 
431
		(Form.cheight-TOOLBAR_H == list.h) && 
430
		(Form.cheight-TOOLBAR_H == list.h) && 
432
		(list.count) 
431
		(list.count) 
433
	) 
432
	) 
434
	{
433
	{
435
		DrawPage();
434
		DrawPage();
436
	}
435
	}
437
	else
436
	else
438
	{
437
	{
439
		if (!label.raw) {                           //this code need to be run
438
		if (!label.raw) {                           //this code need to be run
440
			if (param) EventOpenAddress(#param);    //only once at browser sturtup
439
			if (param) EventOpenAddress(#param);    //only once at browser sturtup
441
			else EventOpenAddress("aelia:home");
440
			else EventOpenAddress("aelia:home");
442
		}
441
		}
443
		else PreparePage();
442
		else PreparePage();
444
	}
443
	}
445
 
444
 
446
	DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col);
445
	DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col);
447
}
446
}
448
 
447
 
449
void DrawPage()
448
void DrawPage()
450
{
449
{
451
	list.CheckDoesValuesOkey();
450
	list.CheckDoesValuesOkey();
452
	if (list.count) _PutImage(list.x,list.y,list.w,list.h,list.first*list.item_h*list.w*3 + label.raw);
451
	if (list.count) _PutImage(list.x,list.y,list.w,list.h,list.first*list.item_h*list.w*3 + label.raw);
453
	DrawScroller();
452
	DrawScroller();
454
}
453
}
455
 
454
 
456
void DrawAddressBox()
455
void DrawAddressBox()
457
{
456
{
458
	address_box.left = 97+19;
457
	address_box.left = 97+19;
459
	address_box.top = 11;
458
	address_box.top = 11;
460
	address_box.width = Form.cwidth - address_box.left - 138;
459
	address_box.width = Form.cwidth - address_box.left - 138;
461
	DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C);
460
	DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C);
462
	DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color);
461
	DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color);
463
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address);
462
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address);
464
	address_box.offset = 0;
463
	address_box.offset = 0;
465
	edit_box_draw stdcall(#address_box);
464
	edit_box_draw stdcall(#address_box);
466
	favicon.draw(address_box.left-18, address_box.top-1);
465
	favicon.draw(address_box.left-18, address_box.top-1);
467
	DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff);
466
	DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff);
468
}
467
}