Subversion Repositories Kolibri OS

Rev

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

Rev 5772 Rev 5773
Line 11... Line 11...
11
#define MEMSIZE 0x100000
11
#define MEMSIZE 0x100000
12
#include "..\lib\gui.h"
12
#include "..\lib\gui.h"
13
#include "..\lib\draw_buf.h"
13
#include "..\lib\draw_buf.h"
14
#include "..\lib\list_box.h"
14
#include "..\lib\list_box.h"
15
#include "..\lib\cursor.h"
15
#include "..\lib\cursor.h"
16
 
-
 
17
//*.obj libraries
16
//*.obj libraries
18
#include "..\lib\obj\box_lib.h"
17
#include "..\lib\obj\box_lib.h"
19
#include "..\lib\obj\libio_lib.h"
18
#include "..\lib\obj\libio_lib.h"
20
#include "..\lib\obj\libimg_lib.h"
19
#include "..\lib\obj\libimg_lib.h"
21
#include "..\lib\obj\http.h"
20
#include "..\lib\obj\http.h"
22
#include "..\lib\obj\iconv.h"
21
#include "..\lib\obj\iconv.h"
23
 
-
 
24
//useful patterns
22
//useful patterns
25
#include "..\lib\patterns\libimg_load_skin.h"
23
#include "..\lib\patterns\libimg_load_skin.h"
Line 26... Line 24...
26
 
24
 
Line 27... Line 25...
27
char homepage[] = FROM "html\\homepage.htm";
25
char homepage[] = FROM "html\\homepage.htm";
28
 
26
 
29
#ifdef LANG_RUS
27
#ifdef LANG_RUS
30
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.35";
28
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.38";
31
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
29
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
32
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
30
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
33
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
31
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
34
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
32
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
35
	char accept_language[]= "Accept-Language: ru\n";
33
	char accept_language[]= "Accept-Language: ru\n";
36
#else
34
#else
37
	char version[]=" Text-based Browser 1.35";
35
	char version[]=" Text-based Browser 1.38";
38
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
36
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
39
	?define T_LAST_SLIDE "This slide is the last"
37
	?define T_LAST_SLIDE "This slide is the last"
40
	char loading[] = "Loading...
";
38
	char loading[] = "Loading...
";
41
	char page_not_found[] = FROM "html\page_not_found_en.htm";
39
	char page_not_found[] = FROM "html\page_not_found_en.htm";
Line -... Line 40...
-
 
40
	char accept_language[]= "Accept-Language: en\n";	
-
 
41
#endif
-
 
42
 
Line 42... Line 43...
42
	char accept_language[]= "Accept-Language: en\n";	
43
#define URL_SERVICE_HISTORY "WebView://history"
43
#endif
-
 
44
 
-
 
Line 45... Line 44...
45
 
44
#define URL_SERVICE_HOME "WebView://home"
46
 
-
 
47
proc_info Form;
45
#define URL_SERVICE_SOURCE "WebView://source:"
Line 48... Line 46...
48
#define WIN_W 799
46
 
Line 49... Line 47...
49
#define WIN_H 559
47
 
Line 93... Line 91...
93
 
91
 
94
char editURL[sizeof(URL)];
92
char editURL[sizeof(URL)];
95
int	mouse_twb;
93
int	mouse_twb;
Line 96... Line -...
96
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
-
 
97
 
-
 
98
#define URL_SERVICE_HISTORY "WebView://history"
-
 
99
#define URL_SERVICE_HOME "WebView://home"
-
 
100
#define URL_SERVICE_SOURCE "WebView://source:"
-
 
101
 
-
 
Line 102... Line 94...
102
libimg_image skin;
94
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
103
 
95
 
104
 
96
 
105
void main()
97
void main()
Line 132... Line 124...
132
				if (WB1.list.MouseOver(mouse.x, mouse.y))
124
				if (WB1.list.MouseOver(mouse.x, mouse.y))
133
				{
125
				{
134
					PageLinks.Hover(mouse.x, WB1.list.first*WB1.list.line_h + mouse.y, link_color_inactive, link_color_active, bg_color);
126
					PageLinks.Hover(mouse.x, WB1.list.first*WB1.list.line_h + mouse.y, link_color_inactive, link_color_active, bg_color);
135
					if (bufsize) && (mouse.pkm) && (mouse.up) { CreateThread(#menu_rmb,#stak+4092); break; }
127
					if (bufsize) && (mouse.pkm) && (mouse.up) { CreateThread(#menu_rmb,#stak+4092); break; }
136
					if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
128
					if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
137
					if (mouse.down) && (PageLinks.active>=0) 
-
 
138
					{
-
 
139
						DrawRectangle(PageLinks.links[PageLinks.active].x, PageLinks.links[PageLinks.active].y,
-
 
140
						PageLinks.links[PageLinks.active].w, PageLinks.links[PageLinks.active].h, 0);
-
 
141
						ClickLink();
-
 
142
					}
-
 
143
				}
129
				}
144
				//Drag scroller
130
				//Drag scroller
145
				scroll_wv.all_redraw = 0;
131
				scroll_wv.all_redraw = 0;
146
				if (!mouse.lkm) scroll_used=0;
132
				if (!mouse.lkm) scroll_used=0;
147
				if (mouse.x>=scroll_wv.start_x) && (mouse.x<=scroll_wv.start_x+scroll_wv.size_x) 
133
				if (mouse.x>=scroll_wv.start_x) && (mouse.x<=scroll_wv.start_x+scroll_wv.size_x) 
Line 178... Line 164...
178
				}
164
				}
179
				break;
165
				break;
Line 180... Line 166...
180
 
166
 
181
			case evReDraw:
167
			case evReDraw:
182
				if (action_buf) Scan(action_buf);
168
				if (action_buf) Scan(action_buf);
183
				DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0);
169
				DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0);
184
				GetProcessInfo(#Form, SelfInfo);
170
				GetProcessInfo(#Form, SelfInfo);
185
				if (Form.status_window>2) { DrawTitle(#header); break; }
171
				if (Form.status_window>2) { DrawTitle(#header); break; }
186
				if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
172
				if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
187
				if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
173
				if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
Line 206... Line 192...
206
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
192
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
207
						{
193
						{
208
							redirected++;
194
							redirected++;
209
							if (redirected<=5)
195
							if (redirected<=5)
210
							{
196
							{
211
								http_find_header_field stdcall (http_transfer, #str_location);
197
								http_find_header_field stdcall (http_transfer, "location\0");
212
								if (EAX!=0) {
198
								if (EAX!=0) {
213
									ESI = EAX;
199
									ESI = EAX;
214
									EDI = #URL;
200
									EDI = #URL;
215
									do {
201
									do {
216
										$lodsb;
202
										$lodsb;
Line 265... Line 251...
265
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, 
251
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, 
266
		Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom);
252
		Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom);
267
	WB1.list.wheel_size = 7;
253
	WB1.list.wheel_size = 7;
268
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
254
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
269
	WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
255
	WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
270
	if (WB1.list.w!=WB1.DrawBuf.bufw) WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 20);
256
	if (WB1.list.w!=WB1.DrawBuf.bufw) WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 30);
271
}
257
}
Line 272... Line 258...
272
 
258
 
273
void Draw_Window()
259
void Draw_Window()
274
{
260
{
Line 350... Line 336...
350
			CreateThread(#menu_rmb,#stak+4092);
336
			CreateThread(#menu_rmb,#stak+4092);
351
			return;
337
			return;
352
		case VIEW_SOURCE:
338
		case VIEW_SOURCE:
353
			WB1.list.first = 0;
339
			WB1.list.first = 0;
354
			ShowSource();
340
			ShowSource();
355
			WB1.DrawPage();
341
			WB1.LoadInternalPage(bufpointer, bufsize);
356
			break;
342
			break;
357
		case EDIT_SOURCE:
343
		case EDIT_SOURCE:
358
			if (!strncmp(#URL,"http:",5)) 
344
			if (!strncmp(#URL,"http:",5)) 
359
			{
345
			{
360
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
346
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
Line 388... Line 374...
388
			return; */
374
			return; */
389
	}
375
	}
390
}
376
}
Line 391... Line -...
391
 
-
 
392
 
-
 
393
 
-
 
394
void ClickLink()
-
 
395
{
-
 
396
	if (http_transfer > 0) 
-
 
397
	{
-
 
398
		StopLoading();
-
 
399
		BrowserHistory.current--;
-
 
400
	}
-
 
401
 
-
 
402
	strcpy(#URL, PageLinks.GetURL(PageLinks.active));	
-
 
403
	//#1
-
 
404
	if (URL[0] == '#')
-
 
405
	{
-
 
406
		strcpy(#anchor, #URL+strrchr(#URL, '#'));		
-
 
407
		strcpy(#URL, BrowserHistory.CurrentUrl());
-
 
408
		WB1.list.first=WB1.list.count-WB1.list.visible;
-
 
409
		ShowPage();
-
 
410
		return;
-
 
411
	}
-
 
412
	//liner.ru#1
-
 
413
	if (strrchr(#URL, '#')!=-1)
-
 
414
	{
-
 
415
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
-
 
416
		URL[strrchr(#URL, '#')-1] = 0x00;
-
 
417
	}
-
 
418
	
-
 
419
	PageLinks.GetAbsoluteURL(#URL);
-
 
420
	
-
 
421
	if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
-
 
422
	|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) 
-
 
423
	{
-
 
424
		//notify(#URL);
-
 
425
		if (!strncmp(#URL,"http://", 7))
-
 
426
		{
-
 
427
			strcpy(#DL_URL, #URL);
-
 
428
			CreateThread(#Downloader,#downloader_stak+4092);
-
 
429
		}
-
 
430
		else RunProgram("@open", #URL);
-
 
431
		strcpy(#editURL, BrowserHistory.CurrentUrl());
-
 
432
		strcpy(#URL, BrowserHistory.CurrentUrl());
-
 
433
		return;
-
 
434
	}
-
 
435
	if (!strncmp(#URL,"mailto:", 7))
-
 
436
	{
-
 
437
		notify(#URL);
-
 
438
		strcpy(#editURL, BrowserHistory.CurrentUrl());
-
 
439
		strcpy(#URL, BrowserHistory.CurrentUrl());
-
 
440
		return;
-
 
441
	}
-
 
442
	OpenPage();
-
 
443
	return;
-
 
444
}
377
 
445
 
378
 
446
void StopLoading()
379
void StopLoading()
447
{
380
{
448
	if (http_transfer)
381
	if (http_transfer)
Line 529... Line 462...
529
void ShowPage()
462
void ShowPage()
530
{
463
{
531
	DrawEditBox();
464
	DrawEditBox();
532
	if (!bufsize)
465
	if (!bufsize)
533
	{
466
	{
534
		PageLinks.Clear();
-
 
535
		if (http_transfer)
-
 
536
		{
-
 
537
			WB1.LoadInternalPage(#loading, sizeof(loading));
467
		if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
538
		}
-
 
539
		else
-
 
540
			WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
468
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
541
	}
469
	}
542
	else
470
	else
543
	{
471
	{
544
		WB1.Prepare();
472
		WB1.Prepare();
545
	}
473
	}
Line 546... Line 474...
546
 
474
 
547
	if (!header) strcpy(#header, #version);
475
	//if (!header) strcpy(#header, #version);
548
	if (!strcmp(#version, #header)) DrawTitle(#header);
476
	if (!strcmp(#version, #header)) DrawTitle(#header);
Line 549... Line 477...
549
}
477
}
550
 
478