Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
7592 leency 1
 
2
3
 
4
#include "..\lib\gui.h"
5
#include "..\lib\draw_buf.h"
6
#include "..\lib\list_box.h"
7
#include "..\lib\cursor.h"
8
#include "..\lib\collection.h"
9
#include "..\lib\random.h"
10
#include "..\lib\clipboard.h"
11
12
 
13
#include "..\lib\obj\box_lib.h"
14
#include "..\lib\obj\libio.h"
15
#include "..\lib\obj\libimg.h"
16
#include "..\lib\obj\iconv.h"
17
#include "..\lib\obj\proc_lib.h"
7757 leency 18
7592 leency 19
 
7757 leency 20
#include "..\lib\patterns\simple_open_dialog.h"
21
#include "..\lib\patterns\toolbar_button.h"
7759 leency 22
7592 leency 23
 
24
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
25
26
 
27
char accept_language[]= "Accept-Language: en\n";
28
29
 
7757 leency 30
7592 leency 31
 
7759 leency 32
 
33
 
7592 leency 34
35
 
36
 
37
dword STATUSBAR_H = 0;
38
39
 
7752 leency 40
 
7592 leency 41
42
 
43
44
 
45
	REFRESH_BUTTON,
46
	EDIT_SOURCE,
47
	OPEN_PAGE,
7759 leency 48
};
7592 leency 49
50
 
7752 leency 51
#include "..\TWB\TWB.c"
7592 leency 52
TWebBrowser WB1;
7759 leency 53
#include "highlight_c.h"
7757 leency 54
7592 leency 55
 
7757 leency 56
od_filter filter2 = { 16, "C\0H\0C--\0H--\0CPP\0\0" };
57
58
 
59
char edit_path[URL_SIZE+1];
60
int	mouse_twb;
7592 leency 61
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#edit_path,#mouse_twb,2,19,19};
7757 leency 62
7592 leency 63
 
64
65
 
7757 leency 66
{
7592 leency 67
	load_dll(boxlib, #box_lib_init,0);
68
	load_dll(libio, #libio_init,1);
69
	load_dll(libimg, #libimg_init,1);
70
	load_dll(iconv_lib, #iconv_open,0);
71
	load_dll(Proc_lib,  #OpenDialog_init,0);
7757 leency 72
	OpenDialog_init stdcall (#o_dialog);
73
}
74
75
 
76
{
77
	int i, id;
7759 leency 78
	LoadLibraries();
7757 leency 79
	if (param) strcpy(#current_path, #param); else strcpy(#current_path, URL_SERVICE_HOME);
80
	WB1.list.SetFont(8, 14, 10011000b);
7592 leency 81
	WB1.list.no_selection = true;
82
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
83
	loop() switch(WaitEvent())
84
	{
85
		case evMouse:
86
			edit_box_mouse stdcall (#address_box);
87
			mouse.get();
88
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
89
			scrollbar_v_mouse (#scroll_wv);
90
			if (WB1.list.first != scroll_wv.position)
91
			{
92
				WB1.list.first = scroll_wv.position;
93
				WB1.DrawPage();
94
				break;
95
			}
96
			break;
97
98
 
99
			id = GetButtonID();
7759 leency 100
			if (1==id) ExitProcess();
101
			if (OPEN_PAGE==id) EventOpenDialog();
102
			break;
7592 leency 103
104
 
105
			GetKeys();
106
107
 
108
				OpenPage(#current_path);
7757 leency 109
			}
7592 leency 110
			if (SCAN_CODE_F3 == key_scancode) {
111
				RunProgram("/rd/1/tinypad", #current_path);
7757 leency 112
			}
7592 leency 113
114
 
7757 leency 115
				if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;}
116
			}
117
118
 
7592 leency 119
			{
120
				if (key_ascii == ASCII_KEY_ENTER) {
7757 leency 121
					OpenPage(#edit_path);
122
				}
123
				else {
7592 leency 124
					EAX = key_editbox;
125
					edit_box_key stdcall(#address_box);
126
				}
127
			}
128
			else
129
			{
130
				#define KEY_SCROLL_N 11
131
				if (SCAN_CODE_UP   == key_scancode) for (i=0;i
132
				if (SCAN_CODE_DOWN == key_scancode) for (i=0;i
133
				if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
134
			}
135
			break;
136
137
 
138
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,sc.work,0,0);
7806 leency 139
			GetProcessInfo(#Form, SelfInfo);
7592 leency 140
			sc.get();
7806 leency 141
			if (Form.status_window>2) break;
7759 leency 142
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
7592 leency 143
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
144
			SetElementSizes();
7757 leency 145
			draw_window();
146
			break;
7592 leency 147
	}
148
}
149
150
 
151
{
152
	address_box.top = TOOLBAR_H/2-10;
153
	address_box.left = address_box.top+43;
7759 leency 154
	address_box.width = Form.cwidth - address_box.left - address_box.left -14;
7592 leency 155
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x,
156
		Form.cheight - TOOLBAR_H - STATUSBAR_H, BASIC_LINE_H);
7759 leency 157
	WB1.list.wheel_size = 7 * BASIC_LINE_H;
158
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
7592 leency 159
	WB1.list.visible = WB1.list.h;
160
	if (WB1.list.w!=DrawBuf.bufw) {
7771 leency 161
		DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700);
162
		OpenPage(#current_path);
7757 leency 163
	}
7592 leency 164
}
165
166
 
7757 leency 167
{
7592 leency 168
	DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, sc.work);
7806 leency 169
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
7592 leency 170
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph);
7806 leency 171
	DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,sc.work_graph);
172
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, sc.work);
173
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph);
174
	DrawEditBoxWebView();
7592 leency 175
	if (!WB1.header) {
7759 leency 176
		OpenPage(#current_path);
7757 leency 177
	} else {
178
		WB1.DrawPage();
7592 leency 179
		DrawEditBoxWebView();
180
	}
181
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
182
	DrawTopPanelButton(OPEN_PAGE, 10, address_box.top-3, 0);
7759 leency 183
}
7592 leency 184
185
 
186
 
7757 leency 187
{
7592 leency 188
	dword buf, size;
7757 leency 189
	strcpy(#current_path, _path);
190
	if (streq(_path, URL_SERVICE_HOME)) {
191
		LoadInternalPage(#homepage, sizeof(homepage));
192
		return;
7592 leency 193
	}
194
	file_size stdcall (_path);
7757 leency 195
	if (EBX)
196
	{
7592 leency 197
		size = EBX;
7757 leency 198
		buf = malloc(size);
199
		ReadFile(0, size, buf, _path);
200
		ShowCodeSource();
201
		free(buf);
202
		return;
203
	}
7592 leency 204
	LoadInternalPage(NULL,NULL);
7757 leency 205
}
7592 leency 206
207
 
208
{
209
	int skin_x_offset;
210
	DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
211
	DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
212
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#edit_path);
7757 leency 213
	address_box.offset = 0;
7592 leency 214
	edit_box_draw stdcall(#address_box);
215
	skin_x_offset = 51;
216
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
217
}
218
219
 
7757 leency 220
{
221
	if (!_bufpos) || (!_bufsize) {
222
		LoadInternalPage(#page_not_found, sizeof(page_not_found));
223
		return;
224
	}
225
	strcpy(#edit_path, #current_path);
226
	DrawEditBoxWebView();
7592 leency 227
7757 leency 228
 
229
	WB1.ParseHtml(_bufpos, _bufsize);
7759 leency 230
	WB1.DrawPage();
7755 leency 231
}
7592 leency 232
233
 
7757 leency 234
{
235
	OpenDialog_start stdcall (#o_dialog);
236
	if (o_dialog.status) {
237
		OpenPage(#openfile_path);
238
	}
239
}
240
241
 
242
 
7592 leency 243
void EventClickLink() {return;};
7742 leency 244
void EventShowLinkMenu() {return;};
7592 leency 245
246
 
247
248
 
249