Subversion Repositories Kolibri OS

Rev

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

Rev 7770 Rev 7771
Line 4... Line 4...
4
#ifndef AUTOBUILD
4
#ifndef AUTOBUILD
5
	#include "lang.h--"
5
	#include "lang.h--"
6
#endif
6
#endif
Line 7... Line 7...
7
 
7
 
8
//libraries
8
//libraries
9
#define MEMSIZE 1024 * 850
9
#define MEMSIZE 1024 * 1000
10
#include "..\lib\gui.h"
10
#include "..\lib\gui.h"
11
#include "..\lib\draw_buf.h"
11
#include "..\lib\draw_buf.h"
12
#include "..\lib\list_box.h"
12
#include "..\lib\list_box.h"
13
#include "..\lib\cursor.h"
13
#include "..\lib\cursor.h"
Line 27... Line 27...
27
#include "..\lib\patterns\history.h"
27
#include "..\lib\patterns\history.h"
28
#include "..\lib\patterns\http_downloader.h"
28
#include "..\lib\patterns\http_downloader.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
30
#include "..\lib\patterns\toolbar_button.h"
30
#include "..\lib\patterns\toolbar_button.h"
Line -... Line 31...
-
 
31
 
-
 
32
#include "texts.h"
31
 
33
#include "cache.h"
32
#include "show_src.h"
34
#include "show_src.h"
33
#include "download_manager.h"
-
 
34
_history history;
-
 
-
 
35
#include "download_manager.h"
35
#include "history.h"
36
 
-
 
37
bool debug_mode = false;
36
bool debug_mode = false;
38
 
37
#include "..\TWB\TWB.c" //HTML Parser, a core component
-
 
38
#include "texts.h"
-
 
Line 39... Line 39...
39
#include "cache.h"
39
#include "..\TWB\TWB.c" //HTML Parser, a core component
-
 
40
 
Line 40... Line 41...
40
 
41
TWebBrowser WB1;
Line 41... Line 42...
41
TWebBrowser WB1;
42
_history history;
42
 
43
 
43
#define URL_SIZE 4000
44
#include "history.h"
-
 
45
 
-
 
46
#define PADDING 9
44
 
47
#define SKIN_Y 24
-
 
48
#define TSZE 25
45
#define PADDING 9
49
#define STATUSBAR_H 15
Line 46... Line 50...
46
#define SKIN_Y 24
50
#define TAB_H 20
Line 47... Line 51...
47
#define TSZE 25
51
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
Line 57... Line 61...
57
progress_bar wv_progress_bar;
61
progress_bar wv_progress_bar;
58
char stak[4096];
62
char stak[4096];
59
proc_info Form;
63
proc_info Form;
Line 60... Line 64...
60
 
64
 
-
 
65
enum { 
61
enum { 
66
	NEW_TAB=600,
62
	ENCODINGS=900,
67
	ENCODINGS=700,
63
	BACK_BUTTON=1000, 
68
	BACK_BUTTON=800, 
64
	FORWARD_BUTTON, 
69
	FORWARD_BUTTON, 
65
	REFRESH_BUTTON, 
70
	REFRESH_BUTTON, 
66
	GOTOURL_BUTTON, 
71
	GOTOURL_BUTTON, 
67
	CHANGE_ENCODING,
72
	CHANGE_ENCODING,
Line 74... Line 79...
74
	DOWNLOAD_MANAGER,
79
	DOWNLOAD_MANAGER,
75
	CLEAR_CACHE,
80
	CLEAR_CACHE,
76
	UPDATE_BROWSER,
81
	UPDATE_BROWSER,
77
	COPY_LINK_URL,
82
	COPY_LINK_URL,
78
	DOWNLOAD_LINK_CONTENTS,
83
	DOWNLOAD_LINK_CONTENTS,
-
 
84
	TAB_ID,
-
 
85
	TAB_CLOSE_ID = 900
79
};
86
};
Line -... Line 87...
-
 
87
 
-
 
88
#include "tabs.h"
80
 
89
 
81
char default_dir[] = "/rd/1";
90
char default_dir[] = "/rd/1";
Line 82... Line 91...
82
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
91
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
83
 
92
 
Line 163... Line 172...
163
			if (1==btn) ExitProcess(); else ProcessEvent(btn);
172
			if (1==btn) ExitProcess(); else ProcessEvent(btn);
164
			break;
173
			break;
Line 165... Line 174...
165
 
174
 
166
		case evKey:
175
		case evKey:
-
 
176
			GetKeys();
-
 
177
			//if (key_scancode == SCAN_CODE_F1) {DebugTabs();break;}
-
 
178
 
-
 
179
			if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
-
 
180
				if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();break;}
-
 
181
			}
167
			GetKeys();
182
 
168
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
183
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
169
				if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;}
184
				if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog();
170
				if (key_scancode == SCAN_CODE_KEY_H) {ProcessEvent(VIEW_HISTORY);break;}
185
				else if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY);
171
				if (key_scancode == SCAN_CODE_KEY_U) {EventViewSource();break;}
186
				else if (key_scancode == SCAN_CODE_KEY_U) EventViewSource();
172
				if (key_scancode == SCAN_CODE_KEY_T) 
187
				else if (key_scancode == SCAN_CODE_KEY_T) EventOpenNewTab(URL_SERVICE_HOMEPAGE); 
173
				|| (key_scancode == SCAN_CODE_KEY_N) {RunProgram(#program_path, NULL);break;}
188
				else if (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
174
				if (key_scancode == SCAN_CODE_KEY_J) {ProcessEvent(DOWNLOAD_MANAGER);break;}
189
				else if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER);
175
				if (key_scancode == SCAN_CODE_KEY_R) {ProcessEvent(REFRESH_BUTTON);break;}
190
				else if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON);
176
				if (key_scancode == SCAN_CODE_ENTER) {EventSeachWeb();break;}
191
				else if (key_scancode == SCAN_CODE_ENTER) EventSeachWeb();
177
				if (key_scancode == SCAN_CODE_LEFT)  {ProcessEvent(BACK_BUTTON);break;}
192
				else if (key_scancode == SCAN_CODE_LEFT)  ProcessEvent(BACK_BUTTON);
178
				if (key_scancode == SCAN_CODE_RIGHT) {ProcessEvent(FORWARD_BUTTON);break;}
193
				else if (key_scancode == SCAN_CODE_RIGHT) ProcessEvent(FORWARD_BUTTON);
-
 
194
				else if (key_scancode == SCAN_CODE_KEY_W) EventCloseActiveTab();
-
 
195
				else if (key_scancode == SCAN_CODE_TAB)   EventActivateNextTab();
179
				if (key_scancode == SCAN_CODE_KEY_W) {ExitProcess();break;}
196
				break;
Line 180... Line 197...
180
			}
197
			}
Line 181... Line 198...
181
			
198
			
182
			if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
199
			if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
183
			
200
			
184
			if (address_box.flags & ed_focus)  
201
			if (address_box.flags & ed_focus)  
185
			{
-
 
186
				if (key_scancode == SCAN_CODE_ENTER) {
202
			{
187
					ProcessEvent(key_scancode); 
203
				if (key_scancode == SCAN_CODE_ENTER) {
188
				}
204
					ProcessEvent(key_scancode); 
189
				else {
205
				} else {
190
					EAX = key_editbox; 
-
 
191
					edit_box_key stdcall(#address_box);
206
					EAX = key_editbox; 
192
				}
-
 
193
			}
207
					edit_box_key stdcall(#address_box);
194
			else 
208
				}
195
			{
209
			} else {
196
				#define KEY_SCROLL_N 11
210
				#define KEY_SCROLL_N 11
197
				if (SCAN_CODE_UP   == key_scancode) for (i=0;i
211
				if (SCAN_CODE_UP   == key_scancode) for (i=0;i
198
				if (SCAN_CODE_DOWN == key_scancode) for (i=0;i
212
				if (SCAN_CODE_DOWN == key_scancode) for (i=0;i
199
				if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();}
213
				if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();}
200
				if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
214
				if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
Line 201... Line 215...
201
				else ProcessEvent(key_scancode);
215
				else ProcessEvent(key_scancode);
202
			}
216
			}
203
			break;
217
			break;
204
 
218
 
205
		case evReDraw:
219
		case evReDraw:
206
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),
220
			DefineAndDrawWindow(40, //GetScreenWidth()-800/2-random(80),
207
				GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
221
				GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
Line 243... Line 257...
243
}
257
}
Line 244... Line 258...
244
 
258
 
245
void SetElementSizes()
259
void SetElementSizes()
246
{
260
{
247
	address_box.width = Form.cwidth - address_box.left - 52 - 16;
261
	address_box.width = Form.cwidth - address_box.left - 52 - 16;
248
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, 
262
	WB1.list.SetSizes(0, TOOLBAR_H+TAB_H, Form.width - 10 - scroll_wv.size_x, 
249
		Form.cheight - TOOLBAR_H - STATUSBAR_H, BASIC_LINE_H);
263
		Form.cheight - TOOLBAR_H - STATUSBAR_H - TAB_H, BASIC_LINE_H);
250
	WB1.list.wheel_size = 7 * BASIC_LINE_H;
264
	WB1.list.wheel_size = 7 * BASIC_LINE_H;
251
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
265
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
252
	WB1.list.visible = WB1.list.h;
266
	WB1.list.visible = WB1.list.h;
Line 263... Line 277...
263
	}
277
	}
264
	SetElementSizes();
278
	SetElementSizes();
Line 265... Line 279...
265
 
279
 
266
	DrawBar(0,0, Form.cwidth,PADDING, system.color.work);
280
	DrawBar(0,0, Form.cwidth,PADDING, system.color.work);
267
	DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, system.color.work);
281
	DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, system.color.work);
268
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, system.color.work_dark);
282
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(system.color.work_dark, system.color.work, 180));
269
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, system.color.work_graph);
283
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, system.color.work_graph);
270
	DrawBar(0, PADDING, address_box.left-2, TSZE+1, system.color.work);
284
	DrawBar(0, PADDING, address_box.left-2, TSZE+1, system.color.work);
Line 271... Line 285...
271
	DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, system.color.work);
285
	DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, system.color.work);
Line 278... Line 292...
278
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, system.color.work_graph);
292
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, system.color.work_graph);
Line 279... Line 293...
279
 
293
 
280
	DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, 
294
	DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, 
Line -... Line 295...
-
 
295
		WB1.list.h-1, scroll_wv.bckg_col);
-
 
296
 
-
 
297
	if (!BrowserWidthChanged()) { 
-
 
298
		WB1.DrawPage(); 
-
 
299
		DrawOmnibox(); 
-
 
300
	}
-
 
301
	DrawProgress();
-
 
302
	DrawStatusBar(NULL);
-
 
303
	DrawTabsBar();
-
 
304
}
-
 
305
 
-
 
306
bool BrowserWidthChanged()
281
		WB1.list.h-1, scroll_wv.bckg_col);
307
{
282
 
308
	dword source_mode_holder;
283
	if (WB1.list.w!=WB1.DrawBuf.bufw) {
309
	if (WB1.list.w!=DrawBuf.bufw) {
284
		WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
310
		DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
285
		if (!strncmp(history.current(),"http",4)) {
311
		if (!strncmp(history.current(),"http",4)) {
286
			//nihuya ne izyashnoe reshenie, no pust' poka butet tak
312
			//nihuya ne izyashnoe reshenie, no pust' poka butet tak
287
			i=source_mode;
313
			source_mode_holder = source_mode;
288
			LoadInternalPage(#loading_text, sizeof(loading_text));
314
			LoadInternalPage(#loading_text, sizeof(loading_text));
289
			source_mode=i;
315
			source_mode = source_mode_holder;
290
		}
-
 
291
		OpenPage(history.current());
-
 
292
	} else { 
316
		}
293
		WB1.DrawPage(); 
317
		OpenPage(history.current());
294
		DrawOmnibox(); 
318
		return true;
295
	}
-
 
296
	DrawProgress();
319
	}
Line -... Line 320...
-
 
320
	return false;
297
	DrawStatusBar(NULL);
321
}
298
}
322
 
299
 
323
 
300
void EventChangeEncodingAndLoadPage(int _new_encoding)
324
void EventChangeEncodingAndLoadPage(int _new_encoding)
301
{
325
{
Line 333... Line 357...
333
		case GOTOURL_BUTTON:
357
		case GOTOURL_BUTTON:
334
		case SCAN_CODE_ENTER:
358
		case SCAN_CODE_ENTER:
335
			EventSubmitOmnibox();
359
			EventSubmitOmnibox();
336
			return;
360
			return;
337
		case REFRESH_BUTTON:
361
		case REFRESH_BUTTON:
338
			if (http.transfer > 0) {
362
			if (http.transfer) {
339
				StopLoading();
363
				StopLoading();
340
				draw_window();
364
				draw_window();
341
			} else {
365
			} else {
342
				OpenPage(history.current());
366
				OpenPage(history.current());
343
			}
367
			}
Line 391... Line 415...
391
		case SCAN_CODE_F12:
415
		case SCAN_CODE_F12:
392
			debug_mode ^= 1;
416
			debug_mode ^= 1;
393
			if (debug_mode) notify("'Debug mode ON'-I");
417
			if (debug_mode) notify("'Debug mode ON'-I");
394
			else notify("'Debug mode OFF'-I");
418
			else notify("'Debug mode OFF'-I");
395
			return;
419
			return;
-
 
420
		case NEW_TAB:
-
 
421
			if (http.transfer) break;
-
 
422
			EventOpenNewTab(URL_SERVICE_HOMEPAGE);
-
 
423
			return;
-
 
424
		case TAB_ID...TAB_ID+TABS_MAX:
-
 
425
			if (http.transfer) break;
-
 
426
			if (mouse.mkm) {
-
 
427
				EventTabClose(id__ - TAB_ID);
-
 
428
			} else {
-
 
429
				EventTabClick(id__ - TAB_ID);
-
 
430
			}
-
 
431
			return;
-
 
432
		case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX:
-
 
433
			EventTabClose(id__ - TAB_CLOSE_ID);
-
 
434
			return;
396
	}
435
	}
397
}
436
}
Line 398... Line 437...
398
 
437
 
399
void StopLoading()
438
void StopLoading()
Line 454... Line 493...
454
{
493
{
455
	char new_url[URL_SIZE+1];
494
	char new_url[URL_SIZE+1];
Line 456... Line 495...
456
 
495
 
Line -... Line 496...
-
 
496
	StopLoading();
-
 
497
 
457
	StopLoading();
498
	if (open_new_tab) {
458
 
499
		open_new_tab = false;
-
 
500
		EventOpenNewTab(_open_URL);
-
 
501
		return;
459
	strcpy(#editURL, _open_URL);
502
	}
Line 460... Line 503...
460
	address_box.flags=0;
503
 
Line 461... Line 504...
461
	DrawOmnibox();
504
	SetOmniboxText(_open_URL);
462
 
505
 
Line 533... Line 576...
533
	if (!strncmp(_click_URL,"mailto:", 7)) || (!strncmp(_click_URL,"tel:", 4)) {
576
	if (!strncmp(_click_URL,"mailto:", 7)) || (!strncmp(_click_URL,"tel:", 4)) {
534
		notify(_click_URL);
577
		notify(_click_URL);
535
		return;
578
		return;
536
	}
579
	}
Line 537... Line 580...
537
 
580
 
538
	if (http.transfer > 0) {
581
	if (http.transfer) {
539
		StopLoading();
582
		StopLoading();
540
		history.back();
583
		history.back();
Line 541... Line 584...
541
	}
584
	}
Line 605... Line 648...
605
			strcat(#editURL, #anchors.current);
648
			strcat(#editURL, #anchors.current);
606
			DrawOmnibox();
649
			DrawOmnibox();
607
		}
650
		}
608
		WB1.ParseHtml(_bufdata, _in_bufsize);
651
		WB1.ParseHtml(_bufdata, _in_bufsize);
609
		DrawStatusBar(NULL);
652
		DrawStatusBar(NULL);
-
 
653
		DrawActiveTab();
610
		if (source_mode) {
654
		if (source_mode) {
611
			source_mode = false;
655
			source_mode = false;
612
			ShowSource(WB1.bufpointer, _in_bufsize);
656
			ShowSource(WB1.bufpointer, _in_bufsize);
613
		} else {
657
		} else {
614
			WB1.DrawPage();			
658
			WB1.DrawPage();			
Line 687... Line 731...
687
}
731
}
Line 688... Line 732...
688
 
732
 
689
void EventViewSource()
733
void EventViewSource()
690
{
734
{
691
	char source_view_param[URL_SIZE+1];
735
	char source_view_param[URL_SIZE+1];
692
	strcpy(#source_view_param, "-source ");
736
	//strcpy(#source_view_param, "-source ");
693
	strncat(#source_view_param, history.current(), URL_SIZE);
737
	//strncat(#source_view_param, history.current(), URL_SIZE);
-
 
738
	//RunProgram(#program_path, #source_view_param);
-
 
739
	source_mode = true;
694
	RunProgram(#program_path, #source_view_param);
740
	EventOpenNewTab(history.current());
Line 695... Line 741...
695
}
741
}
696
 
742
 
697
dword GetFileSize(dword _path)
743
dword GetFileSize(dword _path)
Line 779... Line 825...
779
	DefineHiddenButton(address_box.left+address_box.width-1, address_box.top-2, 17, skin.h-3, REFRESH_BUTTON);
825
	DefineHiddenButton(address_box.left+address_box.width-1, address_box.top-2, 17, skin.h-3, REFRESH_BUTTON);
Line 780... Line 826...
780
 
826
 
781
	DrawProgress();
827
	DrawProgress();
Line -... Line 828...
-
 
828
}
-
 
829
 
-
 
830
void SetOmniboxText(dword _text)
-
 
831
{
-
 
832
	strcpy(#editURL, _text);
-
 
833
	address_box.flags=0;
-
 
834
	DrawOmnibox();
Line 782... Line 835...
782
}
835
}
783
 
836