Subversion Repositories Kolibri OS

Rev

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

Rev 7450 Rev 7506
1
#define MEMSIZE 4096*100
1
#define MEMSIZE 4096*100
2
 
2
 
3
#include "../lib/gui.h"
3
#include "../lib/gui.h"
4
#include "../lib/kfont.h"
4
#include "../lib/kfont.h"
5
#include "../lib/io.h"
5
#include "../lib/io.h"
6
#include "../lib/cursor.h"
6
#include "../lib/cursor.h"
7
 
7
 
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/libimg.h"
11
#include "../lib/obj/libimg.h"
12
#include "../lib/obj/proc_lib.h"
12
#include "../lib/obj/proc_lib.h"
13
#include "../lib/obj/http.h"
13
#include "../lib/obj/http.h"
14
 
14
 
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
llist list;
20
llist list;
21
 
21
 
22
#include "link.h"
22
#include "link.h"
23
#include "canvas.h"
23
#include "canvas.h"
24
#include "favicon.h"
24
#include "favicon.h"
25
 
25
 
26
char default_dir[] = "/rd/1";
26
char default_dir[] = "/rd/1";
27
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
27
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
28
 
28
 
29
char accept_language[]= "Accept-Language: ru\n";
29
char accept_language[]= "Accept-Language: ru\n";
30
 
30
 
31
#define TOOLBAR_H 36
31
#define TOOLBAR_H 36
32
#define TOOLBAR_ICON_WIDTH  26
32
#define TOOLBAR_ICON_WIDTH  26
33
#define TOOLBAR_ICON_HEIGHT 24
33
#define TOOLBAR_ICON_HEIGHT 24
34
#define STATUSBAR_H 15
34
#define STATUSBAR_H 15
35
 
35
 
36
#define DEFAULT_EDITOR "/sys/tinypad"
36
#define DEFAULT_EDITOR "/sys/tinypad"
37
#define DEFAULT_PREVIEW_PATH "/tmp0/1/aelia_preview.txt"
37
#define DEFAULT_PREVIEW_PATH "/tmp0/1/aelia_preview.txt"
38
 
38
 
39
//ATTENTION: each page must have '\0' character at the end of the file
39
//ATTENTION: each page must have '\0' character at the end of the file
40
char buidin_page_home[] = FROM "buidin_pages\\home.htm";
40
char buidin_page_home[] = FROM "buidin_pages\\home.htm";
41
char buidin_page_about[] = FROM "buidin_pages\\about.htm";
41
char buidin_page_about[] = FROM "buidin_pages\\about.htm";
42
char buidin_page_not_found[] = FROM "buidin_pages\\not_found.htm";
42
char buidin_page_not_found[] = FROM "buidin_pages\\not_found.htm";
43
 
43
 
44
#define UML 4096*2
44
#define UML 4096*2
45
 
45
 
46
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};
46
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};
47
 
47
 
48
proc_info Form;
48
proc_info Form;
49
char title[4196];
49
char title[4196];
50
 
50
 
51
enum {
51
enum {
52
	OPEN_FILE,
52
	OPEN_FILE,
53
	MAGNIFY_MINUS,
53
	MAGNIFY_MINUS,
54
	MAGNIFY_PLUS,
54
	MAGNIFY_PLUS,
55
	CHANGE_ENCODING,
55
	CHANGE_ENCODING,
56
	RUN_EDIT,
56
	RUN_EDIT,
57
	GO_BACK,
57
	GO_BACK,
58
	GO_FORWARD,
58
	GO_FORWARD,
59
	SANDWICH
59
	SANDWICH
60
};
60
};
61
 
61
 
62
char address[UML];
62
char address[UML];
63
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,NULL,2,19,19};
63
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,NULL,2,19,19};
64
 
64
 
65
bool debug_mode=false;
65
bool debug_mode=false;
66
 
66
 
67
#include "ini.h"
67
#include "ini.h"
68
#include "gui.h"
68
#include "gui.h"
69
#include "prepare_page.h"
69
#include "prepare_page.h"
70
//#include "special.h"
70
//#include "special.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
	LoadIniSettings();
90
	LoadIniSettings();
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
	list.no_selection = true;
93
	list.no_selection = true;
94
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
94
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
95
	loop()
95
	loop()
96
	{
96
	{
97
		switch(WaitEvent())
97
		switch(WaitEvent())
98
		{
98
		{
99
			case evMouse:
99
			case evMouse:
100
				HandleMouseEvent();
100
				HandleMouseEvent();
101
				break;
101
				break;
102
			case evKey:
102
			case evKey:
103
				HandleKeyEvent();
103
				HandleKeyEvent();
104
				break;
104
				break;
105
			case evButton:
105
			case evButton:
106
				HandleButtonEvent();
106
				HandleButtonEvent();
107
				break;
107
				break;
108
			case evNetwork:
108
			case evNetwork:
109
				HandleNetworkEvent();
109
				HandleNetworkEvent();
110
				break;
110
				break;
111
			case evReDraw:
111
			case evReDraw:
112
				draw_window();
112
				draw_window();
113
				if (menu.cur_y>=10) && (menu.cur_y<20) {
113
				if (menu.cur_y>=10) && (menu.cur_y<20) {
114
					encoding = menu.cur_y - 10;
114
					encoding = menu.cur_y - 10;
115
					EventPageRefresh();
115
					EventPageRefresh();
116
					menu.cur_y = 0;
116
					menu.cur_y = 0;
117
				}
117
				}
118
				if (menu.cur_y>=20) {
118
				if (menu.cur_y>=20) {
119
					menu.cur_y-=20;
119
					menu.cur_y-=20;
120
					if (menu.cur_y==0) EventPageRefresh();
120
					if (menu.cur_y==0) EventPageRefresh();
121
					if (menu.cur_y==1) EventRunEdit();
121
					if (menu.cur_y==1) EventRunEdit();
122
					if (menu.cur_y==2) EventShowHistory();
122
					if (menu.cur_y==2) EventShowHistory();
123
					if (menu.cur_y==3) EventShowDownloader();
123
					if (menu.cur_y==3) EventShowDownloader();
124
					if (menu.cur_y==4) EventShowInfo();
124
					if (menu.cur_y==4) EventShowInfo();
125
					menu.cur_y = 0;
125
					menu.cur_y = 0;
126
				} 
126
				} 
127
		}
127
		}
128
	}
128
	}
129
}
129
}
130
 
130
 
131
 
131
 
132
void HandleButtonEvent()
132
void HandleButtonEvent()
133
{
133
{
134
	byte btn = GetButtonID();
134
	byte btn = GetButtonID();
135
	if (btn==1) {
135
	if (btn==1) {
136
		SaveIniSettings();
136
		SaveIniSettings();
137
		ExitProcess();
137
		ExitProcess();
138
	}
138
	}
139
	switch(btn-10)
139
	switch(btn-10)
140
	{
140
	{
141
		case GO_BACK:
141
		case GO_BACK:
142
			EventGoBack();
142
			EventGoBack();
143
			break;
143
			break;
144
		case GO_FORWARD:
144
		case GO_FORWARD:
145
			EventGoForward();
145
			EventGoForward();
146
			break;
146
			break;
147
		case OPEN_FILE:
147
		case OPEN_FILE:
148
			EventOpenDialog();
148
			EventOpenDialog();
149
			break;
149
			break;
150
		case MAGNIFY_PLUS:
150
		case MAGNIFY_PLUS:
151
			EventMagnifyPlus();
151
			EventMagnifyPlus();
152
			break;
152
			break;
153
		case MAGNIFY_MINUS:
153
		case MAGNIFY_MINUS:
154
			EventMagnifyMinus();
154
			EventMagnifyMinus();
155
			break;
155
			break;
156
		case CHANGE_ENCODING:
156
		case CHANGE_ENCODING:
157
			EventChangeEncoding();
157
			EventChangeEncoding();
158
			break;
158
			break;
159
		case RUN_EDIT:
159
		case RUN_EDIT:
160
			EventRunEdit();
160
			EventRunEdit();
161
			break;
161
			break;
162
		case SANDWICH:
162
		case SANDWICH:
163
			EventShowSandwichMenu();
163
			EventShowSandwichMenu();
164
			break;
164
			break;
165
	}
165
	}
166
}
166
}
167
 
167
 
168
 
168
 
169
void HandleKeyEvent()
169
void HandleKeyEvent()
170
{
170
{
171
	GetKeys();
171
	GetKeys();
172
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
172
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
173
		switch (key_scancode)
173
		switch (key_scancode)
174
		{
174
		{
175
			case SCAN_CODE_UP:
175
			case SCAN_CODE_UP:
176
				EventMagnifyPlus();
176
				EventMagnifyPlus();
177
				return;
177
				return;
178
			case SCAN_CODE_DOWN:
178
			case SCAN_CODE_DOWN:
179
				EventMagnifyMinus();
179
				EventMagnifyMinus();
180
				return;
180
				return;
181
			case SCAN_CODE_KEY_O:
181
			case SCAN_CODE_KEY_O:
182
				EventOpenDialog();
182
				EventOpenDialog();
183
				return;
183
				return;
184
			case SCAN_CODE_KEY_E:
184
			case SCAN_CODE_KEY_E:
185
				EventRunEdit();
185
				EventRunEdit();
186
				return;
186
				return;
187
			case SCAN_CODE_KEY_H:
187
			case SCAN_CODE_KEY_H:
188
				EventShowHistory();
188
				EventShowHistory();
189
				return;
189
				return;
190
			case SCAN_CODE_TAB:
190
			case SCAN_CODE_TAB:
191
				EventChangeEncoding();
191
				EventChangeEncoding();
192
				return;
192
				return;
193
		}
193
		}
194
	}
194
	}
195
	switch (key_scancode) 
195
	switch (key_scancode) 
196
	{
196
	{
197
		case SCAN_CODE_F1:
197
		case SCAN_CODE_F1:
198
			EventShowInfo();
198
			EventShowInfo();
199
			return;
199
			return;
200
		case SCAN_CODE_F12:
200
		case SCAN_CODE_F12:
201
			EventChangeDebugMode();
201
			EventChangeDebugMode();
202
			return;
202
			return;
203
		case SCAN_CODE_ENTER:
203
		case SCAN_CODE_ENTER:
204
			EventOpenAddress(#address);
204
			EventOpenAddress(#address);
205
			return;
205
			return;
206
		case SCAN_CODE_BS:
206
		case SCAN_CODE_BS:
207
			if (! address_box.flags & 0b10) {
207
			if (! address_box.flags & ed_focus) {
208
				EventGoBack();
208
				EventGoBack();
209
				return;
209
				return;
210
			}
210
			}
211
	}
211
	}
212
	if (list.ProcessKey(key_scancode)) && (! address_box.flags & 0b10) {
212
	if (list.ProcessKey(key_scancode)) && (! address_box.flags & ed_focus) {
213
		DrawPage();
213
		DrawPage();
214
		return;
214
		return;
215
	}
215
	}
216
	if (key_ascii != ASCII_KEY_ENTER)
216
	if (key_ascii != ASCII_KEY_ENTER)
217
	&& (key_ascii != ASCII_KEY_PGDN) 
217
	&& (key_ascii != ASCII_KEY_PGDN) 
218
	&& (key_ascii != ASCII_KEY_PGUP) {
218
	&& (key_ascii != ASCII_KEY_PGUP) {
219
		EAX = key_editbox;
219
		EAX = key_editbox;
220
		edit_box_key stdcall(#address_box);
220
		edit_box_key stdcall(#address_box);
221
	}
221
	}
222
}
222
}
223
 
223
 
224
 
224
 
225
void HandleMouseEvent()
225
void HandleMouseEvent()
226
{
226
{
227
	edit_box_mouse stdcall (#address_box);
227
	edit_box_mouse stdcall (#address_box);
228
	mouse.get();
228
	mouse.get();
229
	list.wheel_size = 7;
229
	list.wheel_size = 7;
230
 
230
 
231
	if (link.hover(mouse.x, mouse.y)) {
231
	if (link.hover(mouse.x, mouse.y)) {
232
		if (-1 == link.active) {
232
		if (-1 == link.active) {
233
			DrawStatusBar( " " ); //just clean status bar	
233
			DrawStatusBar( " " ); //just clean status bar	
234
		}
234
		}
235
		else {
235
		else {
236
			DrawStatusBar( link.get_active_url() );
236
			DrawStatusBar( link.get_active_url() );
237
		}
237
		}
238
	}
238
	}
239
 
239
 
240
	if (mouse.key&MOUSE_LEFT) && (mouse.up) {
240
	if (mouse.key&MOUSE_LEFT) && (mouse.up) {
241
		if (-1 != link.active) EventOpenAddress( link.get_active_url() );
241
		if (-1 != link.active) EventOpenAddress( link.get_active_url() );
242
	}
242
	}
243
 
243
 
244
	if (list.MouseScroll(mouse.vert)) {
244
	if (list.MouseScroll(mouse.vert)) {
245
		DrawPage(); 
245
		DrawPage(); 
246
		return; 
246
		return; 
247
	}
247
	}
248
 
248
 
249
	scrollbar_v_mouse (#scroll);
249
	scrollbar_v_mouse (#scroll);
250
	if (list.first != scroll.position) {
250
	if (list.first != scroll.position) {
251
		list.first = scroll.position;
251
		list.first = scroll.position;
252
		DrawPage(); 
252
		DrawPage(); 
253
	}
253
	}
254
}
254
}
255
 
255
 
256
void HandleNetworkEvent()
256
void HandleNetworkEvent()
257
{
257
{
258
	char favicon_address[UML];
258
	char favicon_address[UML];
259
 
259
 
260
	if (downloader.state == STATE_IN_PROGRESS) {
260
	if (downloader.state == STATE_IN_PROGRESS) {
261
		downloader.MonitorProgress();
261
		downloader.MonitorProgress();
262
 
262
 
263
		if (downloader.httpd.content_length>0)
263
		if (downloader.httpd.content_length>0)
264
			DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE*
264
			DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE*
265
				downloader.httpd.content_received/downloader.httpd.content_length); 
265
				downloader.httpd.content_received/downloader.httpd.content_length); 
266
		else
266
		else
267
			DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2);		
267
			DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2);		
268
	} 
268
	} 
269
	
269
	
270
	if (downloader.state == STATE_COMPLETED) 
270
	if (downloader.state == STATE_COMPLETED) 
271
	{
271
	{
272
		if (!strncmp(downloader.url,"http://gate.aspero.pro/",22)) {
272
		if (!strncmp(downloader.url,"http://gate.aspero.pro/",22)) {
273
			strcpy(#address,downloader.url + 29);
273
			strcpy(#address,downloader.url + 29);
274
		}
274
		}
275
		else {
275
		else {
276
			strcpy(#address,downloader.url);
276
			strcpy(#address,downloader.url);
277
		}
277
		}
278
		downloader.Stop();
278
		downloader.Stop();
279
		DrawAddressBox();
279
		DrawAddressBox();
280
		io.buffer_data = downloader.bufpointer;
280
		io.buffer_data = downloader.bufpointer;
281
		/*
281
		/*
282
		get_absolute_url(#favicon_address, #address, "/favicon.ico");
282
		get_absolute_url(#favicon_address, #address, "/favicon.ico");
283
		favicon.get(#favicon_address);
283
		favicon.get(#favicon_address);
284
		*/
284
		*/
285
		PostOpenPageActions();
285
		PostOpenPageActions();
286
	}
286
	}
287
}
287
}
288
 
288
 
289
 
289
 
290
/* ----------------------------------------------------- */
290
/* ----------------------------------------------------- */
291
 
291
 
292
void EventOpenDialog()
292
void EventOpenDialog()
293
{
293
{
294
	OpenDialog_start stdcall (#o_dialog);
294
	OpenDialog_start stdcall (#o_dialog);
295
	if (o_dialog.status) EventOpenAddress(#openfile_path);
295
	if (o_dialog.status) EventOpenAddress(#openfile_path);
296
}
296
}
297
 
297
 
298
void EventOpenAddress(dword _new_address)
298
void EventOpenAddress(dword _new_address)
299
{
299
{
300
char temp[UML];
300
char temp[UML];
301
char getUrl[UML];
301
char getUrl[UML];
302
	if (!ESBYTE[_new_address]) return;
302
	if (!ESBYTE[_new_address]) return;
303
	debugln("====================================");
303
	debugln("====================================");
304
	debug("address: "); 
304
	debug("address: "); 
305
	debugln(_new_address);
305
	debugln(_new_address);
306
	strlcpy(#address, _new_address, UML);
306
	strlcpy(#address, _new_address, UML);
307
	strlwr(#address);
307
	strlwr(#address);
308
	DrawAddressBox();
308
	DrawAddressBox();
309
 
309
 
310
	/*
310
	/*
311
	There could be several possible types of addresses:
311
	There could be several possible types of addresses:
312
	- build in page
312
	- build in page
313
	- local file
313
	- local file
314
	- url
314
	- url
315
	So we need to detect what incoming address is
315
	So we need to detect what incoming address is
316
	and then halndle it in the propper way.
316
	and then halndle it in the propper way.
317
	*/
317
	*/
318
 
318
 
319
	io.buffer_data = 0;
319
	io.buffer_data = 0;
320
	favicon.get(NULL);
320
	favicon.get(NULL);
321
 
321
 
322
	// - build in page
322
	// - build in page
323
	if (!strncmp(#address,"aelia:",6)) {
323
	if (!strncmp(#address,"aelia:",6)) {
324
		debugln("this is buildin page");
324
		debugln("this is buildin page");
325
		if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home;
325
		if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home;
326
		if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about;
326
		if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about;
327
		if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory();
327
		if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory();
328
		PostOpenPageActions();
328
		PostOpenPageActions();
329
	}
329
	}
330
	// - local file
330
	// - local file
331
	else if (check_is_the_adress_local(#address)==true) {
331
	else if (check_is_the_adress_local(#address)==true) {
332
		debugln("this is local address");
332
		debugln("this is local address");
333
		io.read(#address);
333
		io.read(#address);
334
		PostOpenPageActions();
334
		PostOpenPageActions();
335
	}
335
	}
336
	// - url
336
	// - url
337
	else {
337
	else {
338
		debugln("this is url");
338
		debugln("this is url");
339
		if (!strncmp(#address,"https://",8)) {
339
		if (!strncmp(#address,"https://",8)) {
340
			sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #address);
340
			sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #address);
341
		}
341
		}
342
		else if (!strncmp(#address,"http://",7)) {
342
		else if (!strncmp(#address,"http://",7)) {
343
			strlcpy(#getUrl, #address, UML);
343
			strlcpy(#getUrl, #address, UML);
344
		}
344
		}
345
		else {
345
		else {
346
			strcpy(#temp, "http://");
346
			strcpy(#temp, "http://");
347
			strlcpy(#temp, #address, UML);
347
			strlcpy(#temp, #address, UML);
348
			strlcpy(#address, #temp, UML);
348
			strlcpy(#address, #temp, UML);
349
			DrawAddressBox();
349
			DrawAddressBox();
350
			strlcpy(#getUrl, #address, UML);
350
			strlcpy(#getUrl, #address, UML);
351
		}
351
		}
352
		downloader.Start(#getUrl);
352
		downloader.Start(#getUrl);
353
	}
353
	}
354
}
354
}
355
 
355
 
356
void PostOpenPageActions()
356
void PostOpenPageActions()
357
{
357
{
358
	if (!io.buffer_data) {
358
	if (!io.buffer_data) {
359
		debugln("page not found");
359
		debugln("page not found");
360
		io.buffer_data = #buidin_page_not_found;
360
		io.buffer_data = #buidin_page_not_found;
361
	}
361
	}
362
 
362
 
363
	history.add(#address);
363
	history.add(#address);
364
	favicon.draw(address_box.left-18, address_box.top-1);
364
	favicon.draw(address_box.left-18, address_box.top-1);
365
 
365
 
366
	/* 
366
	/* 
367
	Great! So we have the page in our buffer.
367
	Great! So we have the page in our buffer.
368
	We don't know is it a plain text or html.
368
	We don't know is it a plain text or html.
369
	So we need to parse it and draw.
369
	So we need to parse it and draw.
370
	*/
370
	*/
371
 
371
 
372
	list.KeyHome();
372
	list.KeyHome();
373
	PreparePage();
373
	PreparePage();
374
}
374
}
375
 
375
 
376
void EventMagnifyPlus()
376
void EventMagnifyPlus()
377
{
377
{
378
	kfont.size.pt++;
378
	kfont.size.pt++;
379
	if(!kfont.changeSIZE())
379
	if(!kfont.changeSIZE())
380
		kfont.size.pt--;
380
		kfont.size.pt--;
381
	else
381
	else
382
		PreparePage();
382
		PreparePage();
383
}
383
}
384
 
384
 
385
void EventMagnifyMinus()
385
void EventMagnifyMinus()
386
{
386
{
387
	kfont.size.pt--;
387
	kfont.size.pt--;
388
	if(!kfont.changeSIZE())
388
	if(!kfont.changeSIZE())
389
		kfont.size.pt++;
389
		kfont.size.pt++;
390
	else
390
	else
391
		PreparePage();
391
		PreparePage();
392
}
392
}
393
 
393
 
394
void EventRunEdit()
394
void EventRunEdit()
395
{
395
{
396
	if (check_is_the_adress_local(history.current())==true) {
396
	if (check_is_the_adress_local(history.current())==true) {
397
		io.run(DEFAULT_EDITOR, history.current());
397
		io.run(DEFAULT_EDITOR, history.current());
398
	}
398
	}
399
	else {
399
	else {
400
		//io.write(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); // <--- doesn't work, smth odd, need to check
400
		//io.write(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); // <--- doesn't work, smth odd, need to check
401
		CreateFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH);
401
		CreateFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH);
402
		io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH);
402
		io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH);
403
	}
403
	}
404
}
404
}
405
 
405
 
406
void EventChangeEncoding()
406
void EventChangeEncoding()
407
{
407
{
408
	menu.selected = encoding + 1;
408
	menu.selected = encoding + 1;
409
	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);
409
	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);
410
}
410
}
411
 
411
 
412
void EventShowInfo() {
412
void EventShowInfo() {
413
	EventOpenAddress("aelia:about");
413
	EventOpenAddress("aelia:about");
414
}
414
}
415
 
415
 
416
void EventShowHistory()
416
void EventShowHistory()
417
{
417
{
418
	EventOpenAddress("aelia:history");
418
	EventOpenAddress("aelia:history");
419
}
419
}
420
 
420
 
421
void EventGoBack()
421
void EventGoBack()
422
{
422
{
423
	if (history.back()) EventOpenAddress(history.current());
423
	if (history.back()) EventOpenAddress(history.current());
424
}
424
}
425
 
425
 
426
void EventGoForward()
426
void EventGoForward()
427
{
427
{
428
	if (history.forward()) EventOpenAddress(history.current());
428
	if (history.forward()) EventOpenAddress(history.current());
429
}
429
}
430
 
430
 
431
void EventShowSandwichMenu()
431
void EventShowSandwichMenu()
432
{
432
{
433
	menu.selected = 0;
433
	menu.selected = 0;
434
	menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20);
434
	menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20);
435
}
435
}
436
 
436
 
437
void EventPageRefresh()
437
void EventPageRefresh()
438
{
438
{
439
	EventOpenAddress(history.current());
439
	EventOpenAddress(history.current());
440
}
440
}
441
 
441
 
442
void EventShowDownloader()
442
void EventShowDownloader()
443
{
443
{
444
	if (!downloader_opened) {
444
	if (!downloader_opened) {
445
		downloader_edit = NULL;
445
		downloader_edit = NULL;
446
		CreateThread(#Downloader,#downloader_stak+4092);
446
		CreateThread(#Downloader,#downloader_stak+4092);
447
	}
447
	}
448
}
448
}
449
 
449
 
450
void EventChangeDebugMode()
450
void EventChangeDebugMode()
451
{
451
{
452
	debug_mode ^= 1;
452
	debug_mode ^= 1;
453
	if (debug_mode) notify("'Debug mode ON'-I");
453
	if (debug_mode) notify("'Debug mode ON'-I");
454
	else notify("'Debug mode OFF'-I");
454
	else notify("'Debug mode OFF'-I");
455
	return;
455
	return;
456
}
456
}
457
 
457
 
458
/* ------------------------------------------- */
458
/* ------------------------------------------- */
459
 
459
 
460
 
460
 
461
void draw_window()
461
void draw_window()
462
{
462
{
463
	DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0);
463
	DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0);
464
	GetProcessInfo(#Form, SelfInfo);
464
	GetProcessInfo(#Form, SelfInfo);
465
	if (Form.status_window>2) return;
465
	if (Form.status_window>2) return;
466
 
466
 
467
	if (Form.width  < 200) { MoveSize(OLD,OLD,200,OLD); return; }
467
	if (Form.width  < 200) { MoveSize(OLD,OLD,200,OLD); return; }
468
	if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
468
	if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
469
 
469
 
470
	system.color.get();
470
	system.color.get();
471
 
471
 
472
	list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, 
472
	list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, 
473
		Form.cheight-TOOLBAR_H-STATUSBAR_H, kfont.size.pt+4);
473
		Form.cheight-TOOLBAR_H-STATUSBAR_H, kfont.size.pt+4);
474
	
474
	
475
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1);
475
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1);
476
	DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece);
476
	DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece);
477
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F);
477
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F);
478
	
478
	
479
	DrawToolbarButton(GO_BACK,         8);
479
	DrawToolbarButton(GO_BACK,         8);
480
	DrawToolbarButton(GO_FORWARD,      33);
480
	DrawToolbarButton(GO_FORWARD,      33);
481
	DrawToolbarButton(OPEN_FILE,       68);
481
	DrawToolbarButton(OPEN_FILE,       68);
482
	DrawToolbarButton(MAGNIFY_PLUS,    Form.cwidth - 125);
482
	DrawToolbarButton(MAGNIFY_PLUS,    Form.cwidth - 125);
483
	DrawToolbarButton(MAGNIFY_MINUS,   Form.cwidth - 100);
483
	DrawToolbarButton(MAGNIFY_MINUS,   Form.cwidth - 100);
484
	DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64);
484
	DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64);
485
	DrawToolbarButton(SANDWICH,        Form.cwidth - 31);
485
	DrawToolbarButton(SANDWICH,        Form.cwidth - 31);
486
 
486
 
487
	DrawAddressBox();
487
	DrawAddressBox();
488
 
488
 
489
	if ((Form.cwidth-scroll.size_x-1 == list.w) && 
489
	if ((Form.cwidth-scroll.size_x-1 == list.w) && 
490
		(Form.cheight-TOOLBAR_H == list.h) && 
490
		(Form.cheight-TOOLBAR_H == list.h) && 
491
		(list.count) 
491
		(list.count) 
492
	) 
492
	) 
493
	{
493
	{
494
		DrawPage();
494
		DrawPage();
495
	}
495
	}
496
	else
496
	else
497
	{
497
	{
498
		if (!kfont.raw) {                           //this code need to be run
498
		if (!kfont.raw) {                           //this code need to be run
499
			if (param) EventOpenAddress(#param);    //only once at browser sturtup
499
			if (param) EventOpenAddress(#param);    //only once at browser sturtup
500
			else EventOpenAddress("aelia:home");
500
			else EventOpenAddress("aelia:home");
501
		}
501
		}
502
		else PreparePage();
502
		else PreparePage();
503
	}
503
	}
504
 
504
 
505
	DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col);
505
	DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col);
506
	DrawStatusBar(NULL);
506
	DrawStatusBar(NULL);
507
}
507
}
508
 
508
 
509
void DrawPage()
509
void DrawPage()
510
{
510
{
511
	list.CheckDoesValuesOkey();
511
	list.CheckDoesValuesOkey();
512
	if (list.count) {
512
	if (list.count) {
513
		kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w);
513
		kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w);
514
	}
514
	}
515
	DrawScroller();
515
	DrawScroller();
516
}
516
}
517
 
517
 
518
void DrawAddressBox()
518
void DrawAddressBox()
519
{
519
{
520
	address_box.left = 97+19;
520
	address_box.left = 97+19;
521
	address_box.top = 11;
521
	address_box.top = 11;
522
	address_box.width = Form.cwidth - address_box.left - 138;
522
	address_box.width = Form.cwidth - address_box.left - 138;
523
	DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C);
523
	DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C);
524
	DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color);
524
	DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color);
525
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address);
525
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address);
526
	address_box.offset = 0;
526
	address_box.offset = 0;
527
	edit_box_draw stdcall(#address_box);
527
	edit_box_draw stdcall(#address_box);
528
	favicon.draw(address_box.left-18, address_box.top-1);
528
	favicon.draw(address_box.left-18, address_box.top-1);
529
	DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff);
529
	DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff);
530
}
530
}
531
 
531
 
532
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0};
532
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0};
533
void DrawStatusBar(dword _status_text)
533
void DrawStatusBar(dword _status_text)
534
{
534
{
535
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, system.color.work);
535
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, system.color.work);
536
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, 0x8C8C8C);
536
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, 0x8C8C8C);
537
 
537
 
538
	if (_status_text) {
538
	if (_status_text) {
539
		status_text.start_x = 7;
539
		status_text.start_x = 7;
540
		status_text.start_y = Form.cheight - STATUSBAR_H + 3;
540
		status_text.start_y = Form.cheight - STATUSBAR_H + 3;
541
		status_text.area_size_x = Form.cwidth - status_text.start_x -3;
541
		status_text.area_size_x = Form.cwidth - status_text.start_x -3;
542
		status_text.font_color = system.color.work_text;
542
		status_text.font_color = system.color.work_text;
543
		status_text.text_pointer = _status_text;
543
		status_text.text_pointer = _status_text;
544
		PathShow_prepare stdcall(#status_text);
544
		PathShow_prepare stdcall(#status_text);
545
		PathShow_draw stdcall(#status_text);
545
		PathShow_draw stdcall(#status_text);
546
	}
546
	}
547
}
547
}