2012-11-26 16:26:15 +01:00
|
|
|
|
//HTML Viewer in C--
|
2013-10-08 19:27:18 +02:00
|
|
|
|
//Copyright 2007-2013 by Veliant & Leency
|
2012-12-15 01:16:06 +01:00
|
|
|
|
//Asper, lev, Lrz, Barsuk, Nable...
|
2012-11-26 16:26:15 +01:00
|
|
|
|
//home icon - rachel fu, GPL licence
|
|
|
|
|
|
2013-10-24 23:45:17 +02:00
|
|
|
|
#ifndef AUTOBUILD
|
|
|
|
|
#include "lang.h--"
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-12-15 01:16:06 +01:00
|
|
|
|
//libraries
|
2013-03-11 19:16:24 +01:00
|
|
|
|
#define MEMSIZE 0x100000
|
2012-11-26 16:26:15 +01:00
|
|
|
|
#include "..\lib\kolibri.h"
|
|
|
|
|
#include "..\lib\strings.h"
|
|
|
|
|
#include "..\lib\figures.h"
|
|
|
|
|
#include "..\lib\encoding.h"
|
|
|
|
|
#include "..\lib\file_system.h"
|
|
|
|
|
#include "..\lib\mem.h"
|
|
|
|
|
#include "..\lib\dll.h"
|
2012-12-15 01:16:06 +01:00
|
|
|
|
//*.obj libraries
|
|
|
|
|
#include "..\lib\lib.obj\box_lib.h"
|
|
|
|
|
#include "..\lib\lib.obj\libio_lib.h"
|
|
|
|
|
#include "..\lib\lib.obj\libimg_lib.h"
|
2013-10-15 00:41:27 +02:00
|
|
|
|
#include "..\lib\list_box.h"
|
2012-12-15 01:16:06 +01:00
|
|
|
|
//images
|
2012-11-26 16:26:15 +01:00
|
|
|
|
#include "img\toolbar_icons.c"
|
|
|
|
|
#include "img\URLgoto.txt";
|
|
|
|
|
|
2013-10-15 00:41:27 +02:00
|
|
|
|
#ifdef LANG_RUS
|
2013-12-27 00:36:17 +01:00
|
|
|
|
char version[]=" <20><><EFBFBD><EFBFBD>⮢<EFBFBD><E2AEA2> <20><><EFBFBD>㧥<EFBFBD> 0.99.11";
|
2013-10-15 00:41:27 +02:00
|
|
|
|
?define IMAGES_CACHE_CLEARED "<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>⨭<EFBFBD><E2A8AD> <20><><EFBFBD>饭"
|
|
|
|
|
#else
|
2013-12-27 00:36:17 +01:00
|
|
|
|
char version[]=" Text-based Browser 0.99.11";
|
2013-10-15 00:41:27 +02:00
|
|
|
|
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
#define URL param
|
2013-04-05 14:58:55 +02:00
|
|
|
|
char fontlol[64];
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
char editURL[sizeof(URL)],
|
|
|
|
|
page_links[12000],
|
2013-04-10 14:40:09 +02:00
|
|
|
|
header[2048];
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
struct lines{
|
|
|
|
|
int visible, all, first, column_max;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int mouse_dd;
|
2013-04-12 02:11:49 +02:00
|
|
|
|
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(editURL),#editURL,#mouse_dd,2,19,19};
|
2013-04-10 14:40:09 +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};
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc_info Form;
|
|
|
|
|
#define WIN_W 640
|
|
|
|
|
#define WIN_H 480
|
|
|
|
|
|
|
|
|
|
|
2013-10-22 23:56:28 +02:00
|
|
|
|
char stak[4096];
|
2012-11-26 16:26:15 +01:00
|
|
|
|
mouse m;
|
|
|
|
|
|
2013-10-15 00:41:27 +02:00
|
|
|
|
int action_buf;
|
|
|
|
|
|
2013-12-27 00:36:17 +01:00
|
|
|
|
#include "..\TWB\TWB.c"
|
|
|
|
|
#include "menu_rmb.h"
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
2013-10-24 20:26:04 +02:00
|
|
|
|
int key, btn;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
int half_scroll_size;
|
2013-10-15 00:41:27 +02:00
|
|
|
|
int scroll_used=0, show_menu;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
mem_Init();
|
2012-12-15 01:16:06 +01:00
|
|
|
|
if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
|
|
|
|
|
if (load_dll2(libio, #libio_init,1)!=0) debug("Error: library doesn't exists - libio"w);
|
|
|
|
|
if (load_dll2(libimg, #libimg_init,1)!=0) debug("Error: library doesn't exists - libimg"w);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2013-10-08 19:27:18 +02:00
|
|
|
|
if (!URL) strcpy(#URL, "/sys/index.htm");
|
2012-11-26 16:26:15 +01:00
|
|
|
|
strcpy(#editURL, #URL);
|
|
|
|
|
|
|
|
|
|
Form.width=WIN_W;
|
|
|
|
|
Form.height=WIN_H;
|
|
|
|
|
SetElementSizes();
|
|
|
|
|
WB1.OpenPage();
|
|
|
|
|
|
|
|
|
|
SetEventMask(0x27);
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
WaitEventTimeout(2);
|
|
|
|
|
switch(EAX & 0xFF)
|
|
|
|
|
{
|
|
|
|
|
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>"
|
|
|
|
|
if (lines.first <> scroll1.position)
|
|
|
|
|
{
|
|
|
|
|
lines.first = scroll1.position;
|
|
|
|
|
WB1.ParseHTML(buf, filesize);
|
|
|
|
|
//break;
|
|
|
|
|
};*/
|
|
|
|
|
|
2013-10-24 20:26:04 +02:00
|
|
|
|
if (!CheckActiveProcess(Form.ID)) break;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2013-04-12 02:11:49 +02:00
|
|
|
|
edit_box_mouse stdcall (#address_box);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
m.get();
|
|
|
|
|
|
2013-10-15 00:41:27 +02:00
|
|
|
|
if (m.y>WB1.top) && (m.y<Form.height) && (filesize)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
2013-10-15 00:41:27 +02:00
|
|
|
|
if (m.pkm)
|
|
|
|
|
{
|
|
|
|
|
show_menu = 1;
|
|
|
|
|
}
|
|
|
|
|
if (!m.pkm) && (show_menu)
|
|
|
|
|
{
|
|
|
|
|
show_menu = 0;
|
|
|
|
|
SwitchToAnotherThread();
|
2013-10-22 23:56:28 +02:00
|
|
|
|
CreateThread(#menu_rmb,#stak+4092);
|
2013-10-15 00:41:27 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-15 00:41:27 +02:00
|
|
|
|
if (m.vert==65535)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
2013-04-20 23:31:47 +02:00
|
|
|
|
if (lines.first==0) break;
|
|
|
|
|
if (lines.first>3) lines.first-=2; ELSE lines.first=1;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
WB1.Scan(ID1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-04-20 23:31:47 +02:00
|
|
|
|
if (m.vert==1)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
2013-04-20 23:31:47 +02:00
|
|
|
|
if(lines.visible+lines.first+3>=lines.all) WB1.Scan(181);
|
2013-10-15 00:41:27 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-26 16:26:15 +01:00
|
|
|
|
lines.first+=2;
|
|
|
|
|
WB1.Scan(ID2);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m.lkm) scroll_used=0;
|
2013-04-20 23:31:47 +02:00
|
|
|
|
if (m.x>=scroll1.start_x) && (m.x<=scroll1.start_x+scroll1.size_x)
|
2013-10-15 00:41:27 +02:00
|
|
|
|
&& (m.y>=scroll1.start_y+scroll1.btn_height) && (-scroll1.btn_height+scroll1.start_y+scroll1.size_y>m.y)
|
|
|
|
|
&& (lines.all>lines.visible) && (m.lkm)
|
|
|
|
|
{
|
|
|
|
|
scroll_used=1;
|
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
if (scroll_used)
|
|
|
|
|
{
|
|
|
|
|
half_scroll_size = WB1.height - 16 * lines.visible / lines.all - 3 /2;
|
2013-04-20 23:31:47 +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-11-26 16:26:15 +01: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;
|
|
|
|
|
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>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case evButton:
|
|
|
|
|
btn=GetButtonID();
|
2013-04-10 14:40:09 +02:00
|
|
|
|
if (btn==1)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
|
|
|
|
KillProcess(downloader_id);
|
|
|
|
|
ExitProcess();
|
|
|
|
|
}
|
|
|
|
|
ELSE
|
|
|
|
|
{
|
|
|
|
|
WB1.Scan(btn);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case evKey:
|
|
|
|
|
key = GetKey();
|
|
|
|
|
|
2013-04-12 02:11:49 +02:00
|
|
|
|
if (address_box.flags & 0b10) 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>
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
|
|
|
|
|
|
|
|
|
|
WB1.Scan(key);
|
|
|
|
|
|
|
|
|
|
_EDIT_MARK:
|
2013-10-09 18:34:31 +02:00
|
|
|
|
if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2012-11-26 16:26:15 +01:00
|
|
|
|
break;
|
|
|
|
|
case evReDraw:
|
2013-10-15 00:41:27 +02:00
|
|
|
|
if (action_buf) { WB1.Scan(action_buf); action_buf=0;}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
Draw_Window();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (downloader_id<>0)
|
|
|
|
|
{
|
|
|
|
|
if (GetProcessSlot(downloader_id)<>0) break;
|
|
|
|
|
downloader_id=0;
|
|
|
|
|
lines.first = lines.all = 0;
|
|
|
|
|
WB1.ReadHtml(_WIN);
|
|
|
|
|
Draw_Window();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetElementSizes()
|
|
|
|
|
{
|
2013-04-12 02:11:49 +02:00
|
|
|
|
address_box.width = Form.width-266;
|
2013-04-10 14:40:09 +02:00
|
|
|
|
WB1.top = 44;
|
2013-04-12 02:11:49 +02:00
|
|
|
|
WB1.width = Form.width - 10 - scroll1.size_x;
|
|
|
|
|
WB1.height = Form.height - WB1.top - GetSkinHeight() - 4;
|
2013-04-10 14:40:09 +02:00
|
|
|
|
WB1.line_h = 10;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
lines.column_max = WB1.width - 30 / 6;
|
2013-04-10 14:40:09 +02:00
|
|
|
|
lines.visible = WB1.height - 3 / WB1.line_h - 2;
|
2013-04-12 18:34:24 +02:00
|
|
|
|
DrawBufInit();
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Draw_Window()
|
|
|
|
|
{
|
|
|
|
|
int j;
|
2013-04-12 02:11:49 +02:00
|
|
|
|
DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0xE4DFE1,0,0);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2013-04-10 14:40:09 +02:00
|
|
|
|
if (Form.status_window>2)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
|
|
|
|
DrawTitle(#header);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
|
|
|
|
|
if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
|
|
|
|
|
|
|
|
|
|
PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
|
2013-03-11 19:16:24 +01:00
|
|
|
|
if (GetProcessSlot(downloader_id)<>0) _PutImage(88,10, 24,24, #stop_btn);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2013-04-10 14:40:09 +02:00
|
|
|
|
DrawBar(200,0,Form.cwidth-200,43,0xE4DFE1);
|
|
|
|
|
DrawBar(0,42,Form.cwidth,1,0xE2DBDC);
|
|
|
|
|
DrawBar(0,43,Form.cwidth,1,0xD2CED0);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0xE4DFE1);
|
2013-04-10 14:40:09 +02:00
|
|
|
|
_PutImage(Form.cwidth-48,14, 40,19, #URLgoto);
|
|
|
|
|
DefineButton(Form.cwidth-28,15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1);
|
|
|
|
|
DefineButton(Form.cwidth-47,15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1);
|
|
|
|
|
DrawRectangle(205,14,Form.cwidth-205-49,18,0x94AECE); //around adress bar
|
|
|
|
|
DrawRectangle(206,15,Form.cwidth-205-50,16,0xE4ECF3);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
SetElementSizes();
|
|
|
|
|
WB1.ShowPage();
|
2013-04-10 14:40:09 +02:00
|
|
|
|
|
2012-11-26 16:26:15 +01: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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop:
|