Subversion Repositories Kolibri OS

Rev

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

Rev 4693 Rev 4718
Line 27... Line 27...
27
#include "..\lib\lib.obj\http.h"
27
#include "..\lib\lib.obj\http.h"
Line 28... Line 28...
28
 
28
 
Line 29... Line 29...
29
char homepage[] = FROM "html\homepage.htm";
29
char homepage[] = FROM "html\homepage.htm";
30
 
30
 
31
#ifdef LANG_RUS
31
#ifdef LANG_RUS
32
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.0 Beta 3";
32
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.0 Beta 4";
33
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
33
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
34
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
34
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
35
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
35
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
36
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
36
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
37
	char accept_language[]= "Accept-Language: ru\n";
37
	char accept_language[]= "Accept-Language: ru\n";
38
#else
38
#else
39
	char version[]=" Text-based Browser 1.0 Beta 3";
39
	char version[]=" Text-based Browser 1.0 Beta 4";
40
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
40
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
41
	?define T_LAST_SLIDE "This slide is the last"
41
	?define T_LAST_SLIDE "This slide is the last"
42
	char loading[] = "Loading...
";
42
	char loading[] = "Loading...
";
Line 60... Line 60...
60
dword http_buffer;
60
dword http_buffer;
Line 61... Line 61...
61
 
61
 
62
dword TAB_H = false; //19;
62
dword TAB_H = false; //19;
63
dword TAB_W = 150;
63
dword TAB_W = 150;
64
dword TOOLBAR_H = 31; //50;
64
dword TOOLBAR_H = 31; //50;
65
dword STATUSBAR_H =16;
65
dword STATUSBAR_H =15;
66
dword col_bg = 0xE4DFE1;
66
dword col_bg;
67
dword panel_color = 0xF1F1F1;
67
dword panel_color;
Line 68... Line 68...
68
dword border_color = 0x9F9F9F;
68
dword border_color;
-
 
69
 
Line 69... Line 70...
69
 
70
pb progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
70
pb progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
71
byte souce_mode = false;
71
 
72
 
-
 
73
#include "..\TWB\TWB.c"
Line 72... Line 74...
72
#include "..\TWB\TWB.c"
74
#include "menu_rmb.h"
73
#include "menu_rmb.h"
75
#include "history.h"
74
#include "history.h"
76
#include "show_src.h"
Line 75... Line 77...
75
 
77
 
76
char editURL[sizeof(URL)];
78
char editURL[sizeof(URL)];
-
 
79
int	mouse_twb;
Line 77... Line 80...
77
int	mouse_twb;
80
edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
Line 78... Line 81...
78
edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
81
 
79
 
82
#define URL_SERVICE_HISTORY "WebView://history"
-
 
83
#define URL_SERVICE_HOME "WebView://home"
80
#define URL_SERVICE_HISTORY "WebView://history"
84
#define URL_SERVICE_SOURCE "WebView://source:"
Line 81... Line 85...
81
#define URL_SERVICE_HOME "WebView://home"
85
 
82
 
86
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
-
 
87
 
83
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
88
struct struct_skin {
84
 
89
	dword image, w, h;
85
struct skin {
90
	int Load();
86
	dword image, w, h;
91
} skin;
-
 
92
 
-
 
93
int struct_skin::Load()
-
 
94
{
-
 
95
	dword image_data;
-
 
96
	skin.image = load_image(abspath("wv_skin.png"));
-
 
97
	if (!skin.image) notify("WebView skin file 'wv_skin.png' not found, program will terminate");
-
 
98
	skin.w = DSWORD[skin.image+4];
-
 
99
	skin.h = DSWORD[skin.image+8];
-
 
100
	image_data = DSDWORD[skin.image+24];
-
 
101
 
87
} skin;
102
	col_bg = DSDWORD[DSDWORD[skin.image+24]];
Line 88... Line 103...
88
 
103
	panel_color  = DSDWORD[skin.w*4*4 + image_data];
89
int LoadSkin()
104
	border_color = DSDWORD[skin.w*4*7 + image_data];
90
{
105
	progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
Line 102... Line 117...
102
	if (http_transfer == 0) return;
117
	if (http_transfer == 0) return;
103
	if (progress_bar.max) btn = address_box.width*progress_bar.value/progress_bar.max; else btn = 30;
118
	if (progress_bar.max) btn = address_box.width*progress_bar.value/progress_bar.max; else btn = 30;
104
	DrawBar(address_box.left-1, address_box.top+14, btn, 2, progress_bar.progress_color);
119
	DrawBar(address_box.left-1, address_box.top+14, btn, 2, progress_bar.progress_color);
105
}
120
}
Line -... Line 121...
-
 
121
 
106
 
122
 
107
void main()
123
void main()
108
{
124
{
109
	unsigned long key, btn;
125
	unsigned long key, btn;
110
	int half_scroll_size;
126
	int half_scroll_size;
Line 114... Line 130...
114
	CursorPointer.Load(#CursorFile);
130
	CursorPointer.Load(#CursorFile);
115
	if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj");
131
	if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj");
116
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
132
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
117
	if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
133
	if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
118
	if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");
134
	if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");
119
	LoadSkin();
135
	skin.Load();
Line 120... Line 136...
120
	
136
	
121
	Form.width=WIN_W;
137
	Form.width=WIN_W;
122
	Form.height=WIN_H;
138
	Form.height=WIN_H;
123
	SetElementSizes();
139
	SetElementSizes();
Line 183... Line 199...
183
				break;
199
				break;
184
			case evKey:
200
			case evKey:
185
				key = GetKey();
201
				key = GetKey();
Line 186... Line 202...
186
				
202
				
187
				if (address_box.flags & 0b10) SWITCH(key)
203
				if (address_box.flags & 0b10) SWITCH(key)
Line 188... Line 204...
188
					{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; } 
204
					{ CASE 52: CASE 53: CASE 54: CASE 180: CASE 181: goto _EDIT_MARK; } 
Line 189... Line 205...
189
 
205
 
190
				Scan(key);
206
				Scan(key);
Line 266... Line 282...
266
 
282
 
267
void SetElementSizes()
283
void SetElementSizes()
268
{
284
{
269
	address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H;
285
	address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H;
270
	address_box.width = Form.cwidth - address_box.left - 25 - 22;
286
	address_box.width = Form.cwidth - address_box.left - 25 - 22;
271
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 10);
287
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 11);
272
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
288
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
273
	WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
289
	WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
274
	WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
290
	WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
Line 371... Line 387...
371
		case FORWARD:
387
		case FORWARD:
372
			if (!BrowserHistory.GoForward()) return;
388
			if (!BrowserHistory.GoForward()) return;
373
			OpenPage();
389
			OpenPage();
374
			return;
390
			return;
375
		case 052:  //F3
391
		case 052: //F3
-
 
392
			ShowSource();
-
 
393
			break;
-
 
394
		case 053: //F4
376
			if (strncmp(#URL,"http:",5)==0) 
395
			if (strncmp(#URL,"http:",5)==0) 
377
			{
396
			{
378
				WriteFile(bufsize, bufpointer, "/tmp0/1/webview.tmp");
397
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
379
				if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/webview.tmp");
398
				if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
380
			}
399
			}
381
			else
400
			else
382
			{
401
			{
383
				RunProgram("/rd/1/tinypad", #URL);
402
				RunProgram("/rd/1/tinypad", #URL);
384
			}
403
			}
Line 402... Line 421...
402
			
421
			
403
		case HOME:
422
		case HOME:
404
			strcpy(#editURL, "http://kolibrios.org/");
423
			strcpy(#editURL, "http://kolibrios.org/");
405
		case GOTOURL:
424
		case GOTOURL:
-
 
425
		case 0x0D: //enter
406
		case 0x0D: //enter
426
			if (!editURL[0]) return;
407
			if ((strncmp(#editURL,"http:",5)!=0) && (editURL[0]!='/') && ((strncmp(#editURL,"WebView:",8)!=0))
427
			if ((strncmp(#editURL,"http:",5)!=0) && (editURL[0]!='/') && ((strncmp(#editURL,"WebView:",8)!=0))
408
			{
428
			{
409
				strcpy(#URL,"http://");
429
				strcpy(#URL,"http://");
410
			} 
430
			} 
Line 557... Line 577...
557
}
577
}
Line 558... Line 578...
558
 
578
 
559
void OpenPage()
579
void OpenPage()
560
{
580
{
-
 
581
	StopLoading();
561
	StopLoading();
582
	souce_mode = false;
562
	strcpy(#editURL, #URL);
583
	strcpy(#editURL, #URL);
563
	BrowserHistory.AddUrl();
584
	BrowserHistory.AddUrl();
564
	if (strncmp(#URL,"WebView:",8)==0)
585
	if (strncmp(#URL,"WebView:",8)==0)
565
	{
586
	{
Line 592... Line 613...
592
	{
613
	{
593
		file_size stdcall (#URL);
614
		file_size stdcall (#URL);
594
		bufsize = EBX;
615
		bufsize = EBX;
595
		if (bufsize)
616
		if (bufsize)
596
		{
617
		{
597
			bufpointer = mem_Free(bufpointer);
618
			mem_Free(bufpointer);
598
			bufpointer = mem_Alloc(bufsize);
619
			bufpointer = mem_Alloc(bufsize);
599
			SetPageDefaults();
620
			SetPageDefaults();
600
			ReadFile(0, bufsize, bufpointer, #URL);				
621
			ReadFile(0, bufsize, bufpointer, #URL);
-
 
622
			//ShowSource();
601
		}
623
		}
602
		ShowPage();
624
		ShowPage();
603
	}
625
	}
604
}
626
}
Line 605... Line 627...
605
 
627
 
606
void ShowPage()
628
DrawEditBox()
607
{
629
{
608
	address_box.size = address_box.pos = strlen(#editURL);
630
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
609
	address_box.offset=0;
631
	address_box.offset = 0;
-
 
632
	edit_box_draw stdcall(#address_box);
-
 
633
}
Line -... Line 634...
-
 
634
 
-
 
635
 
-
 
636
void ShowPage()
610
	edit_box_draw stdcall(#address_box);
637
{
611
 
638
	DrawEditBox();
612
	if (!bufsize)
639
	if (!bufsize)
613
	{
640
	{
614
		PageLinks.Clear();
641
		PageLinks.Clear();