Subversion Repositories Kolibri OS

Rev

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

Rev 4674 Rev 4677
Line 23... Line 23...
23
//*.obj libraries
23
//*.obj libraries
24
#include "..\lib\lib.obj\box_lib.h"
24
#include "..\lib\lib.obj\box_lib.h"
25
#include "..\lib\lib.obj\libio_lib.h"
25
#include "..\lib\lib.obj\libio_lib.h"
26
#include "..\lib\lib.obj\libimg_lib.h"
26
#include "..\lib\lib.obj\libimg_lib.h"
27
#include "..\lib\lib.obj\http.h"
27
#include "..\lib\lib.obj\http.h"
28
//images
28
 
29
#include "img\toolbar_icons.c"
-
 
30
#include "img\URLgoto.txt";
29
char homepage[] = FROM "html\homepage.htm";
Line 31... Line 30...
31
 
30
 
32
#ifdef LANG_RUS
31
#ifdef LANG_RUS
33
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.76";
32
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.0 Beta 1";
34
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
33
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
35
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
34
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
36
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
35
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
37
	unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm";
36
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
38
	char accept_language[]= "Accept-Language: ru\n";
37
	char accept_language[]= "Accept-Language: ru\n";
39
#else
38
#else
40
	char version[]=" Text-based Browser 0.99.76";
39
	char version[]=" Text-based Browser 1.0 Beta 1";
41
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
40
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
42
	?define T_LAST_SLIDE "This slide is the last"
41
	?define T_LAST_SLIDE "This slide is the last"
43
	char loading[] = "Loading...
";
42
	char loading[] = "Loading...
";
44
	unsigned char page_not_found[] = FROM "html\page_not_found_en.htm";
43
	char page_not_found[] = FROM "html\page_not_found_en.htm";
45
	char accept_language[]= "Accept-Language: en\n";	
44
	char accept_language[]= "Accept-Language: en\n";	
Line 46... Line 45...
46
#endif
45
#endif
47
 
46
 
Line 58... Line 57...
58
int action_buf;
57
int action_buf;
Line 59... Line 58...
59
 
58
 
60
dword http_transfer = 0;
59
dword http_transfer = 0;
Line -... Line 60...
-
 
60
dword http_buffer;
-
 
61
 
-
 
62
dword TAB_H = 19;
-
 
63
dword TAB_W = 150;
-
 
64
dword TOOLBAR_H = 50;
-
 
65
dword STATUSBAR_H =18;
-
 
66
dword col_bg = 0xE4DFE1;
-
 
67
dword panel_color = 0xF1F1F1;
-
 
68
dword border_color = 0x9F9F9F;
-
 
69
 
61
dword http_buffer;
70
pb progress_bar = {0, 10, 83, 150, 13, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
62
 
71
 
63
#include "..\TWB\TWB.c"
72
#include "..\TWB\TWB.c"
Line 64... Line 73...
64
#include "menu_rmb.h"
73
#include "menu_rmb.h"
65
#include "history.h"
74
#include "history.h"
66
 
75
 
Line 67... Line 76...
67
char editURL[sizeof(URL)];
76
char editURL[sizeof(URL)];
-
 
77
int	mouse_twb;
Line 68... Line 78...
68
int	mouse_twb;
78
edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
Line -... Line 79...
-
 
79
 
-
 
80
#define URL_SERVICE_HISTORY "WebView://history"
-
 
81
#define URL_SERVICE_HOME "WebView://home"
-
 
82
 
-
 
83
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
-
 
84
 
-
 
85
struct skin {
-
 
86
	dword image, w, h;
-
 
87
} skin;
-
 
88
 
Line 69... Line 89...
69
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
89
int LoadSkin()
70
 
90
{
71
#define URL_HISTORY "WebView://history"
91
	skin.image = load_image(abspath("wv_skin.png"));
72
 
92
	skin.w = DSWORD[skin.image+4];
Line 83... Line 103...
83
	CursorPointer.Load(#CursorFile);
103
	CursorPointer.Load(#CursorFile);
84
	if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
104
	if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
85
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
105
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
86
	if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
106
	if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
87
	if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");
107
	if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");
-
 
108
	LoadSkin();
Line 88... Line -...
88
	
-
 
89
	if (!URL) strcpy(#URL, "/sys/index.htm");
109
	
90
	Form.width=WIN_W;
110
	Form.width=WIN_W;
91
	Form.height=WIN_H;
111
	Form.height=WIN_H;
-
 
112
	SetElementSizes();
92
	SetElementSizes();
113
	if (!URL) strcpy(#URL, URL_SERVICE_HOME);
Line 93... Line 114...
93
	OpenPage();
114
	OpenPage();
94
 
115
 
95
	SetEventMask(0xa7);
116
	SetEventMask(0xa7);
Line 124... Line 145...
124
				if (m.vert)
145
				if (m.vert)
125
				{
146
				{
126
					if (WB1.list.MouseScroll(m.vert)) WB1.Parse();
147
					if (WB1.list.MouseScroll(m.vert)) WB1.Parse();
127
				}
148
				}
128
				//Drag scroller
149
				//Drag scroller
-
 
150
				scroll_wv.all_redraw = 0;
129
				if (!m.lkm) scroll_used=0;
151
				if (!m.lkm) scroll_used=0;
130
				if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x) 
152
				if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x) 
131
				&& (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y)
153
				&& (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y)
132
				&& (WB1.list.count>WB1.list.visible) && (m.lkm)
154
				&& (WB1.list.count>WB1.list.visible) && (m.lkm)
133
				{
155
				{
Line 165... Line 187...
165
				break;
187
				break;
Line 166... Line 188...
166
				
188
				
167
			case evNetwork:
189
			case evNetwork:
168
				if (http_transfer > 0) {
190
				if (http_transfer > 0) {
-
 
191
					http_process stdcall (http_transfer);
-
 
192
					$push EAX
-
 
193
					ESI = http_transfer;
-
 
194
					progress_bar.max = ESI.http_msg.content_length;
-
 
195
					progress_bar.value = ESI.http_msg.content_received;
-
 
196
					progressbar_draw stdcall(#progress_bar);
169
					http_process stdcall (http_transfer);
197
					$pop EAX
170
					if (EAX == 0) {	
198
					if (EAX == 0) {
171
						ESI = http_transfer;
199
						ESI = http_transfer;
172
						// Handle redirects
200
						// Handle redirects
173
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
201
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
Line 221... Line 249...
221
	}
249
	}
222
}
250
}
Line 223... Line 251...
223
 
251
 
224
void SetElementSizes()
252
void SetElementSizes()
-
 
253
{
225
{
254
	address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H;
226
	address_box.width = Form.width - 266;
255
	address_box.width = Form.cwidth - address_box.left - 25 - 22;
227
	WB1.list.SetSizes(0, 44, Form.width - 10 - scroll_wv.size_x, Form.cheight - 44, 0, 10);
256
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 10);
228
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
257
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
229
	WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
258
	WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
230
	WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
259
	WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
Line 231... Line -...
231
}
-
 
232
 
260
}
233
 
261
 
234
void Draw_Window()
262
void Draw_Window()
235
{
263
{
236
	int j;
-
 
237
	DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0xE4DFE1,0,0);
264
	int img_off;
238
 
265
	DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0);
239
	GetProcessInfo(#Form, SelfInfo);
-
 
240
	if (Form.status_window>2)
-
 
241
	{
-
 
242
		DrawTitle(#header);
-
 
243
		return;
266
	GetProcessInfo(#Form, SelfInfo);
244
	}
267
	if (Form.status_window>2) { DrawTitle(#header); return; }
245
	if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
-
 
246
	if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
-
 
247
	
-
 
248
	PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
268
	if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
249
	if (http_transfer > 0) _PutImage(88,10, 24,24, #stop_btn);
269
	if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
250
	
270
	// tab {
251
	DrawBar(200,0,Form.cwidth-200,43,0xE4DFE1);
271
	DrawBar(0, 0, TAB_W, TAB_H+1, panel_color);
252
	DrawBar(0,42,Form.cwidth,1,0xE2DBDC);
-
 
-
 
272
	WriteText(5, 7, 0x80, 0xfdfdFd, "Index.htm");
253
	DrawBar(0,43,Form.cwidth,1,0xD2CED0);
273
	WriteText(4, 6, 0x80, 0, "Index.htm");
254
	for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0xE4DFE1);
274
	// }
255
	_PutImage(Form.cwidth-48,14, 40,19, #URLgoto);
275
	DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg);
256
	DefineButton(Form.cwidth-28,15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1);
276
	DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color);
257
	DefineButton(Form.cwidth-47,15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1);
277
	DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-2, panel_color);
Line 258... Line 278...
258
	DrawRectangle(205,14,Form.cwidth-205-49,18,0x94AECE); //around adress bar
278
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
-
 
279
	img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0);
-
 
280
 
-
 
281
	SetElementSizes();
-
 
282
	DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color);
-
 
283
	DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color);
-
 
284
	// < / >
259
	DrawRectangle(206,15,Form.cwidth-205-50,16,0xE4ECF3);
285
	DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, 300+BT_HIDE, 0);
-
 
286
	DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, 301+BT_HIDE, 0);
-
 
287
	img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0);
-
 
288
	// refrash
-
 
289
	DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0);
-
 
290
	if (http_transfer > 0) img_off = 131; else img_off = 52;
-
 
291
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, img_off, 0);
Line -... Line 292...
-
 
292
	// config
260
 
293
	DefineButton(Form.cwidth-23, address_box.top-2, 17, skin.h-1, 312+BT_HIDE, 0);
-
 
294
	img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-2, 16, skin.h, 85, 0);	
261
	SetElementSizes();
295
 
-
 
296
	ShowPage();
-
 
297
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
-
 
298
	//status bar
262
	ShowPage();
299
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
Line 263... Line 300...
263
 
300
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
264
	DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+1, 16, 16, BTN_UP+BT_HIDE, 0xE4DFE1);
301
	progress_bar.top = Form.cheight - STATUSBAR_H + 4;
Line 303... Line 340...
303
			notify(IMAGES_CACHE_CLEARED);
340
			notify(IMAGES_CACHE_CLEARED);
304
			WB1.Parse();
341
			WB1.Parse();
305
			return;
342
			return;
Line 306... Line 343...
306
 
343
 
307
		case 003: //history
344
		case 003: //history
308
			strcpy(#URL, URL_HISTORY);
345
			strcpy(#URL, URL_SERVICE_HISTORY);
309
			OpenPage();
346
			OpenPage();
Line 310... Line 347...
310
			return;
347
			return;
311
 
348
 
Line 397... Line 434...
397
 
434
 
398
		case 181: //end
435
		case 181: //end
399
			if (WB1.list.count < WB1.list.visible) return;
436
			if (WB1.list.count < WB1.list.visible) return;
400
			if (WB1.list.KeyEnd()) WB1.Parse();
437
			if (WB1.list.KeyEnd()) WB1.Parse();
-
 
438
			return;
-
 
439
		case 312:
-
 
440
			SwitchToAnotherThread();
-
 
441
			m.y = TOOLBAR_H-6;
-
 
442
			m.x = Form.cwidth - 167;
401
			return;
443
			CreateThread(#menu_rmb,#stak+4092);
402
	}
444
	}
Line 469... Line 511...
469
		mem_Free(EAX);						// free data
511
		mem_Free(EAX);						// free data
470
		http_transfer=0;
512
		http_transfer=0;
471
		bufsize = 0;
513
		bufsize = 0;
472
		bufpointer = mem_Free(bufpointer);
514
		bufpointer = mem_Free(bufpointer);
473
	}
515
	}
-
 
516
	progress_bar.value = 0;
474
	PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
517
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0);
475
}
518
}
Line 476... Line 519...
476
 
519
 
477
void SetPageDefaults()
520
void SetPageDefaults()
478
{
521
{
Line 489... Line 532...
489
void OpenPage()
532
void OpenPage()
490
{
533
{
491
	StopLoading();
534
	StopLoading();
492
	strcpy(#editURL, #URL);
535
	strcpy(#editURL, #URL);
493
	BrowserHistory.AddUrl();
536
	BrowserHistory.AddUrl();
-
 
537
	if (strncmp(#URL,"WebView:",8)==0) return;
494
	if (strncmp(#URL,"http:",5)==0)
538
	if (strncmp(#URL,"http:",5)==0)
495
	{
539
	{
496
		_PutImage(88,10, 24,24, #stop_btn);
540
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0);
497
		http_get stdcall (#URL, #accept_language);
541
		http_get stdcall (#URL, #accept_language);
498
		http_transfer = EAX;
542
		http_transfer = EAX;
499
		if (http_transfer == 0)
543
		if (http_transfer == 0)
500
		{
544
		{
501
			StopLoading();
545
			StopLoading();
Line 524... Line 568...
524
{
568
{
525
	address_box.size = address_box.pos = strlen(#editURL);
569
	address_box.size = address_box.pos = strlen(#editURL);
526
	address_box.offset=0;
570
	address_box.offset=0;
527
	edit_box_draw stdcall(#address_box);
571
	edit_box_draw stdcall(#address_box);
Line -... Line 572...
-
 
572
 
528
 
573
	if (strcmp(#URL, URL_SERVICE_HOME)==0) WB1.Prepare(#homepage, sizeof(homepage)); else
529
	if (strcmp(#URL, URL_HISTORY)==0) ShowHistory(); else
574
	if (strcmp(#URL, URL_SERVICE_HISTORY)==0) ShowHistory(); else
530
	if (!bufsize)
575
	if (!bufsize)
531
	{
576
	{
532
		PageLinks.Clear();
577
		PageLinks.Clear();
533
		if (http_transfer<>0)
578
		if (http_transfer<>0)