Subversion Repositories Kolibri OS

Rev

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

Rev 6808 Rev 7227
1
#define MEMSIZE 4096*60
1
#define MEMSIZE 4096*60
2
 
2
 
3
#include "../lib/kfont.h"
3
#include "../lib/kfont.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
	kfont.init(DEFAULT_FONT);
91
	kfont.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
	}
206
	}
207
	if (list.ProcessKey(key_scancode)) {
207
	if (list.ProcessKey(key_scancode)) {
208
		DrawPage();
208
		DrawPage();
209
		return;
209
		return;
210
	}
210
	}
211
	if (key_ascii != 0x0d)
211
	if (key_ascii != 0x0d)
212
	&& (key_ascii != ASCII_KEY_PGDN) 
212
	&& (key_ascii != ASCII_KEY_PGDN) 
213
	&& (key_ascii != ASCII_KEY_PGUP) {
213
	&& (key_ascii != ASCII_KEY_PGUP) {
214
		EAX = key_editbox;
214
		EAX = key_editbox;
215
		edit_box_key stdcall(#address_box);
215
		edit_box_key stdcall(#address_box);
216
	}
216
	}
217
}
217
}
218
 
218
 
219
 
219
 
220
void HandleMouseEvent()
220
void HandleMouseEvent()
221
{
221
{
222
	edit_box_mouse stdcall (#address_box);
222
	edit_box_mouse stdcall (#address_box);
223
	mouse.get();
223
	mouse.get();
224
	list.wheel_size = 7;
224
	list.wheel_size = 7;
225
	link.hover();
225
	link.hover();
226
	if (list.MouseScroll(mouse.vert)) {
226
	if (list.MouseScroll(mouse.vert)) {
227
		DrawPage(); 
227
		DrawPage(); 
228
		return; 
228
		return; 
229
	}
229
	}
230
	scrollbar_v_mouse (#scroll);
230
	scrollbar_v_mouse (#scroll);
231
	if (list.first != scroll.position) {
231
	if (list.first != scroll.position) {
232
		list.first = scroll.position;
232
		list.first = scroll.position;
233
		DrawPage(); 
233
		DrawPage(); 
234
	}
234
	}
235
}
235
}
236
 
236
 
237
 
237
 
238
/* ----------------------------------------------------- */
238
/* ----------------------------------------------------- */
239
 
239
 
240
void EventOpenDialog()
240
void EventOpenDialog()
241
{
241
{
242
	OpenDialog_start stdcall (#o_dialog);
242
	OpenDialog_start stdcall (#o_dialog);
243
	if (o_dialog.status) EventOpenAddress(#openfile_path);
243
	if (o_dialog.status) EventOpenAddress(#openfile_path);
244
}
244
}
245
 
245
 
246
void EventOpenAddress(dword _new_address)
246
void EventOpenAddress(dword _new_address)
247
{
247
{
248
char temp[UML];
248
char temp[UML];
249
char favicon_address[UML];
249
char favicon_address[UML];
250
	if (!ESBYTE[_new_address]) return;
250
	if (!ESBYTE[_new_address]) return;
251
	debugln("====================================");
251
	debugln("====================================");
252
	debug("address: ");
252
	debug("address: ");
253
	debugln(_new_address);
253
	debugln(_new_address);
254
	strlcpy(#address, _new_address, UML);
254
	strlcpy(#address, _new_address, UML);
255
	strlwr(#address);
255
	strlwr(#address);
256
	DrawAddressBox();
256
	DrawAddressBox();
257
 
257
 
258
	/*
258
	/*
259
	There could be several possible types of addresses:
259
	There could be several possible types of addresses:
260
	- build in page
260
	- build in page
261
	- local file
261
	- local file
262
	- url
262
	- url
263
	So we need to detect what incoming address is
263
	So we need to detect what incoming address is
264
	and then halndle it in the propper way.
264
	and then halndle it in the propper way.
265
	*/
265
	*/
266
 
266
 
267
	io.buffer_data = 0;
267
	io.buffer_data = 0;
268
	favicon.get(NULL);
268
	favicon.get(NULL);
269
 
269
 
270
	// - build in page
270
	// - build in page
271
	if (!strncmp(#address,"aelia:",6)) {
271
	if (!strncmp(#address,"aelia:",6)) {
272
		debugln("this is buildin page");
272
		debugln("this is buildin page");
273
		if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home;
273
		if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home;
274
		if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about;
274
		if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about;
275
		if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory();
275
		if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory();
276
	}
276
	}
277
	// - local file
277
	// - local file
278
	else if (check_is_the_adress_local(#address)==true) {
278
	else if (check_is_the_adress_local(#address)==true) {
279
		debugln("this is local address");
279
		debugln("this is local address");
280
		io.read(#address);
280
		io.read(#address);
281
	}
281
	}
282
	// - url
282
	// - url
283
	else {
283
	else {
284
		debugln("this is url");
284
		debugln("this is url");
285
		if (strncmp(#address,"http://",7)!=0) {
285
		if (strncmp(#address,"http://",7)!=0) {
286
			strcpy(#temp, "http://");
286
			strcpy(#temp, "http://");
287
			strlcpy(#temp, #address, UML);
287
			strlcpy(#temp, #address, UML);
288
			strlcpy(#address, #temp, UML);
288
			strlcpy(#address, #temp, UML);
289
			DrawAddressBox();
289
			DrawAddressBox();
290
		}
290
		}
291
		if (!downloader.Start(#address)) {
291
		if (!downloader.Start(#address)) {
292
			downloader.Stop();
292
			downloader.Stop();
293
		} else {
293
		} else {
294
			while (downloader.state!=STATE_COMPLETED)
294
			while (downloader.state!=STATE_COMPLETED)
295
			{ 
295
			{ 
296
				downloader.MonitorProgress(); 
296
				downloader.MonitorProgress(); 
297
				if (downloader.data_full_size>0)
297
				if (downloader.data_full_size>0)
298
					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); 
299
				else
299
				else
300
					DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2);
300
					DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2);
301
			}
301
			}
302
			strcpy(#address,downloader.url);
302
			strcpy(#address,downloader.url);
303
			DrawAddressBox();
303
			DrawAddressBox();
304
			io.buffer_data = downloader.bufpointer;
304
			io.buffer_data = downloader.bufpointer;
305
			get_absolute_url(#favicon_address, #address, "/favicon.ico");
305
			get_absolute_url(#favicon_address, #address, "/favicon.ico");
306
			favicon.get(#favicon_address);
306
			favicon.get(#favicon_address);
307
		}
307
		}
308
	}
308
	}
309
 
309
 
310
	if (!io.buffer_data) {
310
	if (!io.buffer_data) {
311
		debugln("page not found");
311
		debugln("page not found");
312
		io.buffer_data = #buidin_page_not_found;
312
		io.buffer_data = #buidin_page_not_found;
313
	}
313
	}
314
 
314
 
315
	history.add(#address);
315
	history.add(#address);
316
	favicon.draw(address_box.left-18, address_box.top-1);
316
	favicon.draw(address_box.left-18, address_box.top-1);
317
 
317
 
318
	/* 
318
	/* 
319
	Great! So we have the page in our buffer.
319
	Great! So we have the page in our buffer.
320
	We don't know is it a plain text or html.
320
	We don't know is it a plain text or html.
321
	So we need to parse it and draw.
321
	So we need to parse it and draw.
322
	*/
322
	*/
323
 
323
 
324
	list.KeyHome();
324
	list.KeyHome();
325
	list.ClearList();
325
	list.ClearList();
326
	PreparePage();
326
	PreparePage();
327
}
327
}
328
 
328
 
329
void EventMagnifyPlus()
329
void EventMagnifyPlus()
330
{
330
{
331
	kfont.size.pt++;
331
	kfont.size.pt++;
332
	if(!kfont.changeSIZE())
332
	if(!kfont.changeSIZE())
333
		kfont.size.pt--;
333
		kfont.size.pt--;
334
	else
334
	else
335
		PreparePage();
335
		PreparePage();
336
}
336
}
337
 
337
 
338
void EventMagnifyMinus()
338
void EventMagnifyMinus()
339
{
339
{
340
	kfont.size.pt--;
340
	kfont.size.pt--;
341
	if(!kfont.changeSIZE())
341
	if(!kfont.changeSIZE())
342
		kfont.size.pt++;
342
		kfont.size.pt++;
343
	else
343
	else
344
		PreparePage();
344
		PreparePage();
345
}
345
}
346
 
346
 
347
void EventRunEdit()
347
void EventRunEdit()
348
{
348
{
349
	if (check_is_the_adress_local(history.current())==true) {
349
	if (check_is_the_adress_local(history.current())==true) {
350
		io.run(DEFAULT_EDITOR, history.current());
350
		io.run(DEFAULT_EDITOR, history.current());
351
	}
351
	}
352
	else {
352
	else {
353
		//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
354
		WriteFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH);
354
		CreateFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH);
355
		io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH);
355
		io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH);
356
	}
356
	}
357
}
357
}
358
 
358
 
359
void EventChangeEncoding()
359
void EventChangeEncoding()
360
{
360
{
361
	menu.selected = encoding + 1;
361
	menu.selected = encoding + 1;
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);
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);
363
}
363
}
364
 
364
 
365
void EventShowInfo() {
365
void EventShowInfo() {
366
	EventOpenAddress("aelia:about");
366
	EventOpenAddress("aelia:about");
367
}
367
}
368
 
368
 
369
void EventShowHistory()
369
void EventShowHistory()
370
{
370
{
371
	EventOpenAddress("aelia:history");
371
	EventOpenAddress("aelia:history");
372
}
372
}
373
 
373
 
374
void EventGoBack()
374
void EventGoBack()
375
{
375
{
376
	if (history.back()) EventOpenAddress(history.current());
376
	if (history.back()) EventOpenAddress(history.current());
377
}
377
}
378
 
378
 
379
void EventGoForward()
379
void EventGoForward()
380
{
380
{
381
	if (history.forward()) EventOpenAddress(history.current());
381
	if (history.forward()) EventOpenAddress(history.current());
382
}
382
}
383
 
383
 
384
void EventShowSandwichMenu()
384
void EventShowSandwichMenu()
385
{
385
{
386
	menu.selected = 0;
386
	menu.selected = 0;
387
	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);
388
}
388
}
389
 
389
 
390
void EventPageRefresh()
390
void EventPageRefresh()
391
{
391
{
392
	EventOpenAddress(history.current());
392
	EventOpenAddress(history.current());
393
}
393
}
394
 
394
 
395
void EventShowDownloader()
395
void EventShowDownloader()
396
{
396
{
397
	if (!downloader_opened) {
397
	if (!downloader_opened) {
398
		downloader_edit = NULL;
398
		downloader_edit = NULL;
399
		CreateThread(#Downloader,#downloader_stak+4092);
399
		CreateThread(#Downloader,#downloader_stak+4092);
400
	}
400
	}
401
}
401
}
402
 
402
 
403
/* ------------------------------------------- */
403
/* ------------------------------------------- */
404
 
404
 
405
 
405
 
406
void draw_window()
406
void draw_window()
407
{
407
{
408
	DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0);
408
	DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0);
409
	GetProcessInfo(#Form, SelfInfo);
409
	GetProcessInfo(#Form, SelfInfo);
410
	if (Form.status_window>2) return;
410
	if (Form.status_window>2) return;
411
 
411
 
412
	if (Form.width  < 200) { MoveSize(OLD,OLD,200,OLD); return; }
412
	if (Form.width  < 200) { MoveSize(OLD,OLD,200,OLD); return; }
413
	if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
413
	if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
414
	
414
	
415
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1);
415
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1);
416
	DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece);
416
	DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece);
417
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F);
417
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F);
418
	
418
	
419
	DrawToolbarButton(GO_BACK,         8);
419
	DrawToolbarButton(GO_BACK,         8);
420
	DrawToolbarButton(GO_FORWARD,      33);
420
	DrawToolbarButton(GO_FORWARD,      33);
421
	DrawToolbarButton(OPEN_FILE,       68);
421
	DrawToolbarButton(OPEN_FILE,       68);
422
	DrawToolbarButton(MAGNIFY_PLUS,    Form.cwidth - 125);
422
	DrawToolbarButton(MAGNIFY_PLUS,    Form.cwidth - 125);
423
	DrawToolbarButton(MAGNIFY_MINUS,   Form.cwidth - 100);
423
	DrawToolbarButton(MAGNIFY_MINUS,   Form.cwidth - 100);
424
	DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64);
424
	DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64);
425
	DrawToolbarButton(SANDWICH,        Form.cwidth - 31);
425
	DrawToolbarButton(SANDWICH,        Form.cwidth - 31);
426
 
426
 
427
	DrawAddressBox();
427
	DrawAddressBox();
428
 
428
 
429
	if ((Form.cwidth-scroll.size_x-1 == list.w) && 
429
	if ((Form.cwidth-scroll.size_x-1 == list.w) && 
430
		(Form.cheight-TOOLBAR_H == list.h) && 
430
		(Form.cheight-TOOLBAR_H == list.h) && 
431
		(list.count) 
431
		(list.count) 
432
	) 
432
	) 
433
	{
433
	{
434
		DrawPage();
434
		DrawPage();
435
	}
435
	}
436
	else
436
	else
437
	{
437
	{
438
		if (!kfont.raw) {                           //this code need to be run
438
		if (!kfont.raw) {                           //this code need to be run
439
			if (param) EventOpenAddress(#param);    //only once at browser sturtup
439
			if (param) EventOpenAddress(#param);    //only once at browser sturtup
440
			else EventOpenAddress("aelia:home");
440
			else EventOpenAddress("aelia:home");
441
		}
441
		}
442
		else PreparePage();
442
		else PreparePage();
443
	}
443
	}
444
 
444
 
445
	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);
446
}
446
}
447
 
447
 
448
void DrawPage()
448
void DrawPage()
449
{
449
{
450
	list.CheckDoesValuesOkey();
450
	list.CheckDoesValuesOkey();
451
	if (list.count) {
451
	if (list.count) {
452
		kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w);
452
		kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w);
453
	}
453
	}
454
	DrawScroller();
454
	DrawScroller();
455
}
455
}
456
 
456
 
457
void DrawAddressBox()
457
void DrawAddressBox()
458
{
458
{
459
	address_box.left = 97+19;
459
	address_box.left = 97+19;
460
	address_box.top = 11;
460
	address_box.top = 11;
461
	address_box.width = Form.cwidth - address_box.left - 138;
461
	address_box.width = Form.cwidth - address_box.left - 138;
462
	DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C);
462
	DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C);
463
	DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color);
463
	DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color);
464
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address);
464
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address);
465
	address_box.offset = 0;
465
	address_box.offset = 0;
466
	edit_box_draw stdcall(#address_box);
466
	edit_box_draw stdcall(#address_box);
467
	favicon.draw(address_box.left-18, address_box.top-1);
467
	favicon.draw(address_box.left-18, address_box.top-1);
468
	DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff);
468
	DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff);
469
}
469
}