2011-06-25 03:52:11 +02:00
|
|
|
|
//HTML Viewer in C--
|
2012-03-07 23:51:05 +01:00
|
|
|
|
//Copyright 2007-2012 by Veliant & Leency
|
2012-06-05 10:25:06 +02:00
|
|
|
|
//Asper, lev, Lrz, Barsuk, Nable.
|
2012-05-27 21:17:33 +02:00
|
|
|
|
//home icon - rachel fu, GPL licence
|
|
|
|
|
|
2012-06-20 21:58:55 +02:00
|
|
|
|
#include "..\lib\kolibri.h"
|
2012-06-25 16:14:43 +02:00
|
|
|
|
#include "..\lib\strings.h"
|
2012-06-20 21:58:55 +02:00
|
|
|
|
#include "..\lib\encoding.h"
|
|
|
|
|
#include "..\lib\file_system.h"
|
|
|
|
|
#include "..\lib\mem.h"
|
2012-06-22 13:38:38 +02:00
|
|
|
|
#include "..\lib\dll.h"
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2012-06-20 21:58:55 +02:00
|
|
|
|
#include "..\lib\libio_lib.h"
|
|
|
|
|
#include "..\lib\libimg_lib.h"
|
|
|
|
|
#include "..\lib\edit_box_lib.h"
|
2012-07-02 21:02:06 +02:00
|
|
|
|
#include "..\lib\scroll_lib.h"
|
2012-11-05 17:10:14 +01:00
|
|
|
|
#include "..\lib\truetype.h"
|
2012-06-22 13:38:38 +02:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
#include "img\toolbar_icons.c"
|
|
|
|
|
#include "img\URLgoto.txt";
|
|
|
|
|
|
2011-06-25 03:52:11 +02:00
|
|
|
|
|
2012-07-03 19:24:00 +02:00
|
|
|
|
#define URL param
|
2012-11-05 17:10:14 +01:00
|
|
|
|
int use_truetype = 0;
|
2012-07-03 19:24:00 +02:00
|
|
|
|
|
2012-07-16 13:52:03 +02:00
|
|
|
|
char editURL[sizeof(URL)],
|
2011-06-25 03:52:11 +02:00
|
|
|
|
page_links[12000],
|
2012-07-02 21:02:06 +02:00
|
|
|
|
header[300];
|
2011-06-25 03:52:11 +02:00
|
|
|
|
|
2012-06-20 21:58:55 +02:00
|
|
|
|
struct lines{
|
|
|
|
|
int visible, all, first, column_max;
|
|
|
|
|
};
|
2011-06-25 03:52:11 +02:00
|
|
|
|
|
2012-06-20 21:58:55 +02:00
|
|
|
|
int mouse_dd;
|
2012-07-16 13:52:03 +02:00
|
|
|
|
edit_box edit1= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(editURL),#editURL,#mouse_dd,2,19,19};
|
2012-06-05 10:25:06 +02:00
|
|
|
|
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--
|
2011-06-25 03:52:11 +02:00
|
|
|
|
|
2012-07-03 19:24:00 +02:00
|
|
|
|
|
2012-02-27 14:48:04 +01:00
|
|
|
|
proc_info Form;
|
2012-07-03 19:24:00 +02:00
|
|
|
|
#define WIN_W 640
|
|
|
|
|
#define WIN_H 480
|
|
|
|
|
|
|
|
|
|
|
2012-06-13 16:11:10 +02:00
|
|
|
|
dword stak[100]; //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD>
|
|
|
|
|
mouse m;
|
2011-06-25 03:52:11 +02:00
|
|
|
|
|
2012-02-27 14:48:04 +01:00
|
|
|
|
#include "TWB.h"
|
2012-06-13 16:11:10 +02:00
|
|
|
|
#include "include\menu_rmb.h"
|
2011-06-25 03:52:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
2011-09-04 18:37:00 +02:00
|
|
|
|
int btn;
|
|
|
|
|
byte key;
|
2012-06-20 19:22:56 +02:00
|
|
|
|
int half_scroll_size;
|
2012-07-31 16:44:11 +02:00
|
|
|
|
int scroll_used=0;
|
2011-09-04 18:37:00 +02:00
|
|
|
|
|
2012-06-05 10:25:06 +02:00
|
|
|
|
mem_Init();
|
2012-11-05 19:07:09 +01:00
|
|
|
|
if (load_dll2(libio, #libio_init,1)!=0) debug("<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> libio"w);
|
|
|
|
|
if (load_dll2(libimg, #libimg_init,1)!=0) debug("<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> libimg"w);
|
|
|
|
|
if (load_dll2(boxlib, #edit_box_draw,0)!=0) debug("<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> boxlib"w);
|
2012-06-05 10:25:06 +02:00
|
|
|
|
load_dll2(#abox_lib, #boxlib_init,0);
|
2012-11-05 19:07:09 +01:00
|
|
|
|
if (load_dll2(libtruetype, #truetype,0)!=0) {debug("<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TrueType"w); use_truetype = 2;}
|
2011-09-30 11:19:41 +02:00
|
|
|
|
|
2012-07-31 16:44:11 +02:00
|
|
|
|
if (!URL) strcpy(#URL, "/sys/home.htm");
|
2012-06-20 19:22:56 +02:00
|
|
|
|
strcpy(#editURL, #URL);
|
2011-09-30 11:19:41 +02:00
|
|
|
|
|
2012-07-03 19:24:00 +02:00
|
|
|
|
Form.width=WIN_W;
|
|
|
|
|
Form.height=WIN_H;
|
|
|
|
|
|
|
|
|
|
SetElementSizes();
|
|
|
|
|
|
2012-06-20 21:58:55 +02:00
|
|
|
|
WB1.OpenPage();
|
2012-02-29 13:29:47 +01:00
|
|
|
|
|
2011-06-25 03:52:11 +02:00
|
|
|
|
SetEventMask(0x27);
|
|
|
|
|
loop()
|
|
|
|
|
{
|
2012-06-13 16:11:10 +02:00
|
|
|
|
WaitEventTimeout(2);
|
2012-06-05 10:25:06 +02:00
|
|
|
|
switch(EAX & 0xFF)
|
2011-06-25 03:52:11 +02:00
|
|
|
|
{
|
2012-06-05 10:25:06 +02:00
|
|
|
|
CASE evMouse:
|
|
|
|
|
/*scrollbar_v_mouse (#scroll1); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>"
|
2012-06-20 21:58:55 +02:00
|
|
|
|
if (lines.first <> scroll1.position)
|
2012-06-05 10:25:06 +02:00
|
|
|
|
{
|
2012-06-20 21:58:55 +02:00
|
|
|
|
lines.first = scroll1.position;
|
2012-06-05 10:25:06 +02:00
|
|
|
|
WB1.ParseHTML(buf, filesize);
|
|
|
|
|
//break;
|
|
|
|
|
};*/
|
2012-06-17 14:03:52 +02:00
|
|
|
|
|
2012-06-25 16:14:43 +02:00
|
|
|
|
btn=GetProcessSlot(Form.ID);
|
|
|
|
|
IF (btn<>GetActiveProcess()) break; //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2012-06-13 16:11:10 +02:00
|
|
|
|
|
2012-06-17 14:03:52 +02:00
|
|
|
|
edit_box_mouse stdcall (#edit1);
|
|
|
|
|
|
2011-06-25 03:52:11 +02:00
|
|
|
|
m.get();
|
2012-06-13 16:11:10 +02:00
|
|
|
|
|
|
|
|
|
if (m.pkm) && (m.y>WB1.top) && (m.y<Form.height) && (filesize)
|
|
|
|
|
{
|
2012-07-02 21:02:06 +02:00
|
|
|
|
SwitchToAnotherThread();
|
2012-06-13 16:11:10 +02:00
|
|
|
|
CreateThread(#menu_rmb,#stak);
|
|
|
|
|
}
|
2012-06-05 10:25:06 +02:00
|
|
|
|
|
2011-06-25 03:52:11 +02:00
|
|
|
|
IF (m.vert==65535) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
2012-06-20 21:58:55 +02:00
|
|
|
|
IF (lines.first==0) break;
|
|
|
|
|
IF (lines.first>3) lines.first-=2; ELSE lines.first=1;
|
2011-06-25 03:52:11 +02:00
|
|
|
|
WB1.Scan(ID1);
|
2012-06-05 10:25:06 +02:00
|
|
|
|
break;
|
2011-06-25 03:52:11 +02:00
|
|
|
|
}
|
|
|
|
|
IF (m.vert==1)
|
|
|
|
|
{
|
2012-06-20 21:58:55 +02:00
|
|
|
|
IF(lines.visible+lines.first+3>=lines.all) WB1.Scan(181);
|
2011-06-25 03:52:11 +02:00
|
|
|
|
ELSE {
|
2012-06-20 21:58:55 +02:00
|
|
|
|
lines.first+=2;
|
2011-06-25 03:52:11 +02:00
|
|
|
|
WB1.Scan(ID2);
|
|
|
|
|
}
|
2012-06-05 10:25:06 +02:00
|
|
|
|
break;
|
2011-06-25 03:52:11 +02:00
|
|
|
|
}
|
2012-06-05 10:25:06 +02:00
|
|
|
|
|
2012-07-31 16:44:11 +02:00
|
|
|
|
if (!m.lkm) scroll_used=0;
|
|
|
|
|
if (m.x>=WB1.width-14) && (m.x<=WB1.width+6) && (m.y>WB1.top+16)
|
|
|
|
|
&& (m.y<WB1.top+WB1.height-16) && (lines.all>lines.visible) && (m.lkm)
|
|
|
|
|
scroll_used=1;
|
|
|
|
|
|
|
|
|
|
if (scroll_used)
|
2011-06-25 03:52:11 +02:00
|
|
|
|
{
|
2012-07-31 16:44:11 +02:00
|
|
|
|
half_scroll_size = WB1.height - 16 * lines.visible / lines.all - 3 /2;
|
2012-06-22 13:38:38 +02:00
|
|
|
|
IF (half_scroll_size+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.top; //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
2012-06-20 21:58:55 +02:00
|
|
|
|
btn=lines.first; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
lines.first = m.y -half_scroll_size -WB1.top * lines.all / WB1.height;
|
2012-07-31 16:44:11 +02:00
|
|
|
|
if (lines.visible+lines.first>lines.all) lines.first=lines.all-lines.visible;
|
|
|
|
|
if (btn<>lines.first) WB1.ParseHTML(buf); //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2012-06-05 10:25:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-27 14:48:04 +01:00
|
|
|
|
break;
|
2011-06-25 03:52:11 +02:00
|
|
|
|
case evButton:
|
|
|
|
|
btn=GetButtonID();
|
2012-02-27 14:48:04 +01:00
|
|
|
|
IF (btn==1)
|
|
|
|
|
{
|
|
|
|
|
KillProcess(downloader_id);
|
|
|
|
|
ExitProcess();
|
|
|
|
|
}
|
2011-06-25 03:52:11 +02:00
|
|
|
|
ELSE
|
|
|
|
|
{
|
|
|
|
|
WB1.Scan(btn);
|
|
|
|
|
}
|
2012-06-13 16:11:10 +02:00
|
|
|
|
break;
|
2011-06-25 03:52:11 +02:00
|
|
|
|
case evKey:
|
|
|
|
|
key = GetKey();
|
2012-06-17 14:03:52 +02:00
|
|
|
|
|
|
|
|
|
if (edit1.flags == 66) || (edit1.flags == 98) SWITCH(key) //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
|
|
|
|
|
|
2011-06-25 03:52:11 +02:00
|
|
|
|
WB1.Scan(key);
|
2012-06-17 14:03:52 +02:00
|
|
|
|
|
|
|
|
|
_EDIT_MARK:
|
2011-06-25 14:58:55 +02:00
|
|
|
|
IF (key<>0x0d) && (key<>183) && (key<>184) && (key<>173) {EAX=key<<8; edit_box_key stdcall(#edit1);} //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2012-06-13 16:11:10 +02:00
|
|
|
|
break;
|
2011-06-25 03:52:11 +02:00
|
|
|
|
case evReDraw:
|
|
|
|
|
Draw_Window();
|
|
|
|
|
break;
|
2012-06-05 10:25:06 +02:00
|
|
|
|
default:
|
|
|
|
|
if (downloader_id<>0)
|
|
|
|
|
{
|
|
|
|
|
if (GetProcessSlot(downloader_id)<>0) break;
|
|
|
|
|
downloader_id=0;
|
2012-06-20 21:58:55 +02:00
|
|
|
|
lines.first = lines.all = 0;
|
|
|
|
|
WB1.ReadHtml(_WIN);
|
2012-06-05 10:25:06 +02:00
|
|
|
|
Draw_Window();
|
|
|
|
|
}
|
2011-06-25 03:52:11 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-03 19:24:00 +02:00
|
|
|
|
void SetElementSizes()
|
|
|
|
|
{
|
|
|
|
|
edit1.width=Form.width-266;
|
|
|
|
|
WB1.top=44;
|
|
|
|
|
WB1.width=Form.width-13;
|
|
|
|
|
WB1.height=onTop(43,5);
|
|
|
|
|
lines.column_max = WB1.width - 30 / 6;
|
|
|
|
|
lines.visible = WB1.height - 3 / 10 - 2;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-25 03:52:11 +02:00
|
|
|
|
|
|
|
|
|
void Draw_Window()
|
|
|
|
|
{
|
2012-06-20 19:22:56 +02:00
|
|
|
|
int j;
|
2012-07-16 13:52:03 +02:00
|
|
|
|
DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0x00E4DFE1,0);
|
2012-06-13 16:11:10 +02:00
|
|
|
|
|
2011-09-30 14:05:09 +02:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2012-06-20 19:22:56 +02:00
|
|
|
|
if (Form.status_window>2) //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2011-06-25 03:52:11 +02:00
|
|
|
|
{
|
|
|
|
|
DrawTitle(#header);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-06-20 19:22:56 +02:00
|
|
|
|
if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
|
|
|
|
|
if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
|
2011-09-05 11:18:16 +02:00
|
|
|
|
|
|
|
|
|
PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
|
2012-02-27 14:48:04 +01:00
|
|
|
|
if (GetProcessSlot(downloader_id)<>0) PutImage(#stop_btn,24,24,88,10);
|
|
|
|
|
|
2011-09-05 11:18:16 +02:00
|
|
|
|
DrawBar(200,0,onLeft(200,9),43,0xE4DFE1); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2011-06-25 03:52:11 +02:00
|
|
|
|
DrawBar(0,42,onLeft(5,4),1,0xE2DBDC); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
DrawBar(0,43,onLeft(5,4),1,0xD2CED0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2012-06-22 13:38:38 +02:00
|
|
|
|
for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0xE4DFE1);
|
2011-06-25 03:52:11 +02:00
|
|
|
|
PutImage(#URLgoto,40,19,onLeft(57,0),14);
|
2011-09-04 18:13:26 +02:00
|
|
|
|
DefineButton(onLeft(37,0),15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1);
|
|
|
|
|
DefineButton(onLeft(56,0),15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1);
|
2012-06-05 10:25:06 +02:00
|
|
|
|
DrawRegion(205,14,onLeft(58,205),18,0x94AECE); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
DrawRegion(206,15,onLeft(59,205),16,0xE4ECF3);
|
2012-06-13 16:11:10 +02:00
|
|
|
|
|
2012-07-03 19:24:00 +02:00
|
|
|
|
SetElementSizes();
|
2012-06-20 21:58:55 +02:00
|
|
|
|
WB1.ShowPage();
|
2012-06-22 13:38:38 +02:00
|
|
|
|
|
|
|
|
|
DefineButton(scroll1.start_x+1, scroll1.start_y+1, 16, 16, ID1+BT_HIDE, 0xE4DFE1);
|
|
|
|
|
DefineButton(scroll1.start_x+1, scroll1.start_y+scroll1.size_y-18, 16, 16, ID2+BT_HIDE, 0xE4DFE1);
|
2011-06-25 03:52:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 13:41:07 +02:00
|
|
|
|
int onLeft(dword right,left) {return Form.width-right-left;}
|
2012-07-16 13:52:03 +02:00
|
|
|
|
int onTop(dword down,up) {return Form.height-GetSkinHeight()-down-up;}
|
2011-06-25 03:52:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop:
|