Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1971 lev 1
//HTML Viewer in C--
2433 leency 2
//Copyright 2007-2012 by Veliant & Leency
2739 leency 3
//Asper, lev, Lrz, Barsuk, Nable.
2696 leency 4
//home icon - rachel fu, GPL licence
5
 
2413 leency 6
#include "..\lib\kolibri.h--"
2660 leency 7
#include "..\lib\encoding.h--"
2413 leency 8
#include "..\lib\file_system.h--"
9
#include "img\toolbar_icons.c"
10
#include "img\URLgoto.txt";
11
#include "..\lib\mem.h--"
12
#include "..\lib\libio_lib.h--"
13
#include "..\lib\libimg_lib.h--"
14
#include "..\lib\edit_box_lib.h--"
15
#include "..\lib\dll.h--"
2739 leency 16
#include "..\lib\scroll_bar\scroll_lib.h--"
1971 lev 17
 
18
//переменные
2558 leency 19
char URL[4096],
1971 lev 20
	editURL[4096],
21
	page_links[12000],
22
	header[512];
23
 
2739 leency 24
int max_kolvo_strok, //lines_visible
25
	max_kolvo_stolbcov,
26
	count, //lines_all
2764 leency 27
	za_kadrom, //lines_first
1971 lev 28
	mouse_dd;
29
 
30
edit_box edit1= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,248,#editURL,#mouse_dd,2,19,19};
2739 leency 31
scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; //details in scroll_lib.h--
1971 lev 32
 
2413 leency 33
proc_info Form;
2764 leency 34
dword stak[100]; //меню ПКМ
35
mouse m;
1971 lev 36
 
2413 leency 37
#include "TWB.h"
2764 leency 38
#include "include\menu_rmb.h"
1971 lev 39
 
40
 
41
void main()
42
{
2153 leency 43
	int btn;
44
	byte key;
2739 leency 45
	int scroll_size;
2153 leency 46
 
2739 leency 47
	mem_Init();
48
	load_dll2(libio, #libio_init,1);
49
	load_dll2(libimg, #libimg_init,1);
50
	load_dll2(boxlib, #edit_box_draw,0);
51
	load_dll2(#abox_lib, #boxlib_init,0);
2248 leency 52
 
2739 leency 53
	if (param) copystr(#param,#URL);
54
		else copystr("/sys/index.htm",#URL);
2248 leency 55
	copystr(#URL,#editURL);
56
 
2764 leency 57
	OpenPage();
2420 leency 58
 
1971 lev 59
	SetEventMask(0x27);
60
	loop()
61
	{
2764 leency 62
		WaitEventTimeout(2);
2739 leency 63
		switch(EAX & 0xFF)
1971 lev 64
		{
2739 leency 65
			CASE evMouse:
66
				/*scrollbar_v_mouse (#scroll1);      //конченый скролл притормажимает, идём "своим путём"
67
				if (za_kadrom <> scroll1.position)
68
				{
69
					za_kadrom = scroll1.position;
70
					WB1.ParseHTML(buf, filesize);
71
					//break;
72
				};*/
2803 leency 73
 
2764 leency 74
				btn=GetSlot(Form.ID);
75
				IF (btn<>ActiveProcess()) break; //если окно не активно на события мыши не реагируем
76
 
2803 leency 77
				edit_box_mouse stdcall (#edit1);
78
 
1971 lev 79
				m.get();
2764 leency 80
 
81
				if (m.pkm) && (m.y>WB1.top) && (m.y
82
				{
83
					CreateThread(#menu_rmb,#stak);
84
				}
2739 leency 85
 
1971 lev 86
				IF (m.vert==65535) //прокрутка колёсиком
87
				{
88
					IF (za_kadrom==0) break;
89
					IF (za_kadrom>3) za_kadrom-=2; ELSE za_kadrom=1;
90
					WB1.Scan(ID1);
2739 leency 91
					break;
1971 lev 92
				}
93
				IF (m.vert==1)
94
				{
2238 leency 95
					IF(max_kolvo_strok+za_kadrom+3>=count) WB1.Scan(181);
1971 lev 96
					ELSE	{
97
						za_kadrom+=2;
98
						WB1.Scan(ID2);
99
					}
2739 leency 100
					break;
1971 lev 101
				}
2739 leency 102
 
103
				IF (count
104
				scroll_size = WB1.height - 16 * max_kolvo_strok / count - 3;
2085 leency 105
				if (m.x>=WB1.width-14) && (m.x<=WB1.width+6)
106
				&& (m.y>WB1.top+16) && (m.y
2238 leency 107
				&& (count>max_kolvo_strok) while (m.lkm)
1971 lev 108
				{
2238 leency 109
					IF (scroll_size/2+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+WB1.top; //если курсор над окном
1971 lev 110
					btn=za_kadrom; //сохраняем старое количество
2238 leency 111
					j= scroll_size/2;
112
					za_kadrom = m.y -j -WB1.top * count / WB1.height;
113
					IF (max_kolvo_strok+za_kadrom>count) za_kadrom=count-max_kolvo_strok;
1971 lev 114
					IF (btn<>za_kadrom) WB1.ParseHTML(buf, filesize); //чтоб лишний раз не перерисовывать
115
					m.get();
2739 leency 116
				}
117
 
2413 leency 118
				break;
1971 lev 119
			case evButton:
120
				btn=GetButtonID();
2413 leency 121
				IF (btn==1)
122
				{
123
					KillProcess(downloader_id);
124
					ExitProcess();
125
				}
1971 lev 126
				ELSE
127
				{
128
					WB1.Scan(btn);
129
				}
2764 leency 130
				break;
1971 lev 131
			case evKey:
132
				key = GetKey();
2803 leency 133
 
134
				if (edit1.flags == 66) || (edit1.flags == 98) SWITCH(key) //если активна строка адреса игнорируем некоторые кнопки
135
					{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
136
 
1971 lev 137
				WB1.Scan(key);
2803 leency 138
 
139
				_EDIT_MARK:
1974 yogev_ezra 140
				IF (key<>0x0d) && (key<>183) && (key<>184) && (key<>173) {EAX=key<<8; edit_box_key stdcall(#edit1);} //адресная строка
2764 leency 141
				break;
1971 lev 142
			case evReDraw:
143
				Draw_Window();
144
				break;
2739 leency 145
			default:
146
				if (downloader_id<>0)
147
				{
148
					if (GetProcessSlot(downloader_id)<>0) break;
149
					downloader_id=0;
2764 leency 150
					ReadHtml();
151
					if (filesize) wintodos(buf);
2739 leency 152
					Draw_Window();
2764 leency 153
					//WB1.ShowPage(#URL);
2739 leency 154
				}
1971 lev 155
		}
156
	}
157
}
158
 
159
 
160
void Draw_Window()
161
{
162
	DefineAndDrawWindow(215,100,640,480,0x73,0x00E4DFE1,0,0,0);
2764 leency 163
 
2250 leency 164
	GetProcessInfo(#Form, SelfInfo);
2763 leency 165
	IF (Form.status_window>2) //если свернуто в заголовок, ничего не рисуем
1971 lev 166
	{
167
		DrawTitle(#header);
168
		return;
169
	}
170
	IF (Form.height<120) MoveSize(OLD,OLD,OLD,120);
171
	IF (Form.width<280) MoveSize(OLD,OLD,280,OLD);
2155 leency 172
 
173
	PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
2413 leency 174
	if (GetProcessSlot(downloader_id)<>0) PutImage(#stop_btn,24,24,88,10);
175
 
2155 leency 176
	DrawBar(200,0,onLeft(200,9),43,0xE4DFE1); //закрашиваем фон под тулбаром
1971 lev 177
	DrawBar(0,42,onLeft(5,4),1,0xE2DBDC); //выпуклость
178
	DrawBar(0,43,onLeft(5,4),1,0xD2CED0); //выпуклость
179
	FOR (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0x00E4DFE1);
180
	PutImage(#URLgoto,40,19,onLeft(57,0),14);
2152 leency 181
	DefineButton(onLeft(37,0),15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1);
182
	DefineButton(onLeft(56,0),15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1);
2739 leency 183
	DrawRegion(205,14,onLeft(58,205),18,0x94AECE); //ободок полосы адреса
184
	DrawRegion(206,15,onLeft(59,205),16,0xE4ECF3);
2764 leency 185
 
1971 lev 186
	edit1.width=Form.width-266;
187
	WB1.top=44;
2739 leency 188
	WB1.width=Form.width-13;
1971 lev 189
	WB1.height=onTop(43,5);
2764 leency 190
	max_kolvo_stolbcov = WB1.width - 30 / 6;
191
	max_kolvo_strok = WB1.height - 3 / 10 - 2;
192
 
2399 leency 193
	WB1.ShowPage(#URL);
1971 lev 194
}
195
 
2238 leency 196
int onLeft(dword right,left) {return Form.width-right-left;}
197
int onTop(dword down,up) {return Form.height-GetSkinWidth()-down-up;}
1971 lev 198
 
199
 
200
stop: