Subversion Repositories Kolibri OS

Rev

Rev 6808 | Rev 6978 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3067 leency 1
//HTML Viewer in C--
3987 leency 2
//Copyright 2007-2013 by Veliant & Leency
3107 leency 3
//Asper, lev, Lrz, Barsuk, Nable...
3067 leency 4
 
4085 leency 5
#ifndef AUTOBUILD
6
	#include "lang.h--"
7
#endif
8
 
3107 leency 9
//libraries
6738 leency 10
#define MEMSIZE 4096 * 200
5499 leency 11
#include "..\lib\gui.h"
4508 leency 12
#include "..\lib\draw_buf.h"
13
#include "..\lib\list_box.h"
14
#include "..\lib\cursor.h"
5978 leency 15
#include "..\lib\collection.h"
6045 leency 16
#include "..\lib\menu.h"
6795 leency 17
#include "..\lib\random.h"
5981 leency 18
 
3107 leency 19
//*.obj libraries
5499 leency 20
#include "..\lib\obj\box_lib.h"
21
#include "..\lib\obj\libio_lib.h"
22
#include "..\lib\obj\libimg_lib.h"
23
#include "..\lib\obj\http.h"
5690 leency 24
#include "..\lib\obj\iconv.h"
5408 leency 25
//useful patterns
26
#include "..\lib\patterns\libimg_load_skin.h"
5978 leency 27
#include "..\lib\patterns\history.h"
6058 leency 28
#include "..\lib\patterns\http_downloader.h"
5408 leency 29
 
6698 leency 30
char homepage[] = FROM "html\\homepage.htm""\0";
4677 leency 31
 
4026 leency 32
#ifdef LANG_RUS
6931 leency 33
char version[]="Текстовый браузер 1.6";
6045 leency 34
?define IMAGES_CACHE_CLEARED "Кэш картинок очищен"
35
?define T_LAST_SLIDE "Это последний слайд"
36
char loading[] = "Загрузка страницы...
";
6698 leency 37
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
6045 leency 38
char accept_language[]= "Accept-Language: ru\n";
39
char rmb_menu[] =
40
"Посмотреть исходник
41
Редактировать исходник
42
История
43
Очистить кэш картинок
44
Менеджер загрузок";
4026 leency 45
#else
6931 leency 46
char version[]="Text-based Browser 1.6";
6045 leency 47
?define IMAGES_CACHE_CLEARED "Images cache cleared"
48
?define T_LAST_SLIDE "This slide is the last"
49
char loading[] = "Loading...
";
6698 leency 50
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
6045 leency 51
char accept_language[]= "Accept-Language: en\n";
52
char rmb_menu[] =
53
"View source
54
Edit source
55
History
56
Free image cache
57
Download Manager";
4026 leency 58
#endif
59
 
6795 leency 60
char link_menu[] =
61
"Copy link
62
Download link";
63
 
5773 leency 64
#define URL_SERVICE_HISTORY "WebView://history"
65
#define URL_SERVICE_HOME "WebView://home"
66
#define URL_SERVICE_SOURCE "WebView://source:"
5631 pavelyakov 67
 
3067 leency 68
proc_info Form;
69
 
5772 leency 70
//char search_path[]="http://nigma.ru/index.php?s=";
4558 hidnplayr 71
int redirected = 0;
3067 leency 72
 
4074 leency 73
char stak[4096];
5640 pavelyakov 74
 
4026 leency 75
int action_buf;
76
 
4565 leency 77
dword http_transfer = 0;
4537 leency 78
dword http_buffer;
4534 leency 79
 
6731 leency 80
dword TOOLBAR_H = 40;
5519 leency 81
dword STATUSBAR_H = 15;
4718 leency 82
dword col_bg;
83
dword panel_color;
84
dword border_color;
4677 leency 85
 
5718 leency 86
progress_bar wv_progress_bar;
6931 leency 87
bool souce_mode = false;
88
bool open_in_a_new_window = false;
4677 leency 89
 
5718 leency 90
enum {
91
	BACK_BUTTON=1000,
92
	FORWARD_BUTTON,
93
	REFRESH_BUTTON,
94
	GOTOURL_BUTTON,
6795 leency 95
	SANDWICH_BUTTON,
5768 leency 96
	VIEW_SOURCE=1100,
5718 leency 97
	EDIT_SOURCE,
98
	VIEW_HISTORY,
99
	FREE_IMG_CACHE,
6795 leency 100
	DOWNLOAD_MANAGER,
101
	COPY_LINK=1200,
102
	DOWNLOAD_LINK
5718 leency 103
};
104
 
4411 leency 105
#include "..\TWB\TWB.c"
4636 leency 106
#include "history.h"
4718 leency 107
#include "show_src.h"
6001 leency 108
#include "download_manager.h"
3067 leency 109
 
4534 leency 110
char editURL[sizeof(URL)];
111
int	mouse_twb;
6731 leency 112
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL),#editURL,#mouse_twb,2,19,19};
4534 leency 113
 
114
 
3067 leency 115
void main()
116
{
4536 leency 117
	CursorPointer.Load(#CursorFile);
5626 leency 118
	load_dll(boxlib, #box_lib_init,0);
119
	load_dll(libio, #libio_init,1);
120
	load_dll(libimg, #libimg_init,1);
121
	load_dll(libHTTP, #http_lib_init,1);
5690 leency 122
	load_dll(iconv_lib, #iconv_open,0);
5408 leency 123
	Libimg_LoadImage(#skin, abspath("wv_skin.png"));
124
	SetSkinColors();
5772 leency 125
	CreateDir("/tmp0/1/downloads");
126
	if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
6045 leency 127
	WB1.list.SetFont(8, 14, 10011000b);
5779 leency 128
	WB1.list.no_selection = true;
4536 leency 129
	SetEventMask(0xa7);
5631 pavelyakov 130
	BEGIN_LOOP_APPLICATION:
3067 leency 131
		WaitEventTimeout(2);
132
		switch(EAX & 0xFF)
133
		{
134
			CASE evMouse:
4081 leency 135
				if (!CheckActiveProcess(Form.ID)) break;
3466 leency 136
				edit_box_mouse stdcall (#address_box);
5640 pavelyakov 137
				mouse.get();
5772 leency 138
				if (WB1.list.MouseOver(mouse.x, mouse.y))
3067 leency 139
				{
6795 leency 140
					if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
141
					&& (bufsize) && (mouse.pkm) && (mouse.up) {
142
						EventShowPageMenu(mouse.x, mouse.y);
6045 leency 143
						break;
144
					}
5772 leency 145
					if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
3067 leency 146
				}
5782 leency 147
				scrollbar_v_mouse (#scroll_wv);
148
				if (WB1.list.first != scroll_wv.position)
3067 leency 149
				{
5782 leency 150
					WB1.list.first = scroll_wv.position;
151
					WB1.DrawPage();
152
					break;
3067 leency 153
				}
154
				break;
5711 leency 155
 
3067 leency 156
			case evButton:
6698 leency 157
				ProcessEvent(GetButtonID());
3067 leency 158
				break;
5711 leency 159
 
3067 leency 160
			case evKey:
5711 leency 161
				GetKeys();
5531 leency 162
				if (address_box.flags & 0b10)
5530 leency 163
				{
6698 leency 164
					if (key_ascii == ASCII_KEY_ENTER) ProcessEvent(key_scancode); else {
6641 leency 165
						EAX = key_editbox;
166
						edit_box_key stdcall(#address_box);
167
					}
5530 leency 168
				}
5711 leency 169
				else
170
				{
6698 leency 171
					if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
172
					else ProcessEvent(key_scancode);
5711 leency 173
				}
5530 leency 174
				break;
3067 leency 175
 
176
			case evReDraw:
6045 leency 177
				if (menu.list.cur_y) {
6698 leency 178
					ProcessEvent(menu.list.cur_y);
6045 leency 179
					menu.list.cur_y = 0;
180
				}
6795 leency 181
				DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0);
4725 leency 182
				GetProcessInfo(#Form, SelfInfo);