2018-05-22 14:04:44 +02:00
|
|
|
#define MEMSIZE 4096*100
|
2016-01-07 17:00:59 +01:00
|
|
|
|
2018-10-11 16:32:24 +02:00
|
|
|
#include "../lib/gui.h"
|
2016-12-21 16:40:39 +01:00
|
|
|
#include "../lib/kfont.h"
|
2016-01-07 17:00:59 +01:00
|
|
|
#include "../lib/io.h"
|
2018-10-11 16:32:24 +02:00
|
|
|
#include "../lib/cursor.h"
|
2018-04-16 11:35:30 +02:00
|
|
|
|
2016-01-07 17:00:59 +01:00
|
|
|
#include "../lib/obj/box_lib.h"
|
|
|
|
#include "../lib/obj/libini.h"
|
|
|
|
#include "../lib/obj/iconv.h"
|
2018-04-16 11:35:30 +02:00
|
|
|
#include "../lib/obj/libimg.h"
|
2016-01-07 17:00:59 +01:00
|
|
|
#include "../lib/obj/proc_lib.h"
|
|
|
|
#include "../lib/obj/http.h"
|
2018-04-16 11:35:30 +02:00
|
|
|
|
2016-01-07 17:00:59 +01:00
|
|
|
#include "../lib/patterns/simple_open_dialog.h"
|
|
|
|
#include "../lib/patterns/history.h"
|
2016-01-15 00:05:51 +01:00
|
|
|
#include "../lib/patterns/http_downloader.h"
|
2016-03-23 12:13:28 +01:00
|
|
|
#include "../browser/download_manager.h"
|
2016-01-07 17:00:59 +01:00
|
|
|
|
2018-05-24 20:47:42 +02:00
|
|
|
llist list;
|
|
|
|
|
|
|
|
#include "link.h"
|
|
|
|
#include "canvas.h"
|
|
|
|
#include "favicon.h"
|
|
|
|
|
2020-03-29 12:57:14 +02:00
|
|
|
_history history;
|
|
|
|
|
2016-01-07 17:00:59 +01:00
|
|
|
char default_dir[] = "/rd/1";
|
2018-05-21 18:29:58 +02:00
|
|
|
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
|
2016-01-07 17:00:59 +01:00
|
|
|
|
|
|
|
char accept_language[]= "Accept-Language: ru\n";
|
|
|
|
|
|
|
|
#define TOOLBAR_H 36
|
|
|
|
#define TOOLBAR_ICON_WIDTH 26
|
|
|
|
#define TOOLBAR_ICON_HEIGHT 24
|
2018-05-24 20:47:42 +02:00
|
|
|
#define STATUSBAR_H 15
|
2016-01-07 17:00:59 +01:00
|
|
|
|
|
|
|
#define DEFAULT_EDITOR "/sys/tinypad"
|
|
|
|
#define DEFAULT_PREVIEW_PATH "/tmp0/1/aelia_preview.txt"
|
|
|
|
|
|
|
|
//ATTENTION: each page must have '\0' character at the end of the file
|
|
|
|
char buidin_page_home[] = FROM "buidin_pages\\home.htm";
|
|
|
|
char buidin_page_about[] = FROM "buidin_pages\\about.htm";
|
|
|
|
char buidin_page_not_found[] = FROM "buidin_pages\\not_found.htm";
|
|
|
|
|
|
|
|
#define UML 4096*2
|
|
|
|
|
|
|
|
scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
|
|
|
|
|
|
|
|
proc_info Form;
|
|
|
|
char title[4196];
|
|
|
|
|
|
|
|
enum {
|
|
|
|
OPEN_FILE,
|
|
|
|
MAGNIFY_MINUS,
|
|
|
|
MAGNIFY_PLUS,
|
|
|
|
CHANGE_ENCODING,
|
|
|
|
RUN_EDIT,
|
|
|
|
GO_BACK,
|
|
|
|
GO_FORWARD,
|
2016-01-15 00:05:51 +01:00
|
|
|
SANDWICH
|
2016-01-07 17:00:59 +01:00
|
|
|
};
|
|
|
|
|
2018-05-24 20:47:42 +02:00
|
|
|
char address[UML];
|
2018-05-22 23:02:03 +02:00
|
|
|
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,NULL,2,19,19};
|
2016-01-15 00:51:52 +01:00
|
|
|
|
2018-05-24 20:47:42 +02:00
|
|
|
bool debug_mode=false;
|
|
|
|
|
2016-01-07 17:00:59 +01:00
|
|
|
#include "ini.h"
|
|
|
|
#include "gui.h"
|
|
|
|
#include "prepare_page.h"
|
2018-05-21 18:29:58 +02:00
|
|
|
//#include "special.h"
|
2016-01-15 00:05:51 +01:00
|
|
|
|
2016-03-23 12:13:28 +01:00
|
|
|
#define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nDownloader\nAbout"
|
2016-01-07 17:00:59 +01:00
|
|
|
|
|
|
|
void InitDlls()
|
|
|
|
{
|
|
|
|
load_dll(boxlib, #box_lib_init, 0);
|
|
|
|
load_dll(libHTTP, #http_lib_init, 1);
|
|
|
|
load_dll(libio, #libio_init, 1);
|
|
|
|
load_dll(libimg, #libimg_init, 1);
|
|
|
|
//load_dll(libini, #lib_init, 1);
|
|
|
|
load_dll(iconv_lib, #iconv_open, 0);
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
2016-01-15 00:05:51 +01:00
|
|
|
{
|
2016-01-07 17:00:59 +01:00
|
|
|
InitDlls();
|
|
|
|
OpenDialog_init stdcall (#o_dialog);
|
2018-05-22 14:04:44 +02:00
|
|
|
LoadIniSettings();
|
2016-12-21 20:50:13 +01:00
|
|
|
kfont.init(DEFAULT_FONT);
|
2016-01-07 17:00:59 +01:00
|
|
|
Libimg_LoadImage(#skin, abspath("toolbar.png"));
|
|
|
|
list.no_selection = true;
|
2018-05-24 20:47:42 +02:00
|
|
|
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
2016-01-07 17:00:59 +01:00
|
|
|
loop()
|
|
|
|
{
|
|
|
|
switch(WaitEvent())
|
|
|
|
{
|
|
|
|
case evMouse:
|
|
|
|
HandleMouseEvent();
|
|
|
|
break;
|
|
|
|
case evKey:
|
|
|
|
HandleKeyEvent();
|
|
|
|
break;
|
|
|
|
case evButton:
|
|
|
|
HandleButtonEvent();
|
|
|
|
break;
|
2018-05-24 20:47:42 +02:00
|
|
|
case evNetwork:
|
|
|
|
HandleNetworkEvent();
|
|
|
|
break;
|
2016-01-07 17:00:59 +01:00
|
|
|
case evReDraw:
|
2016-01-10 23:33:10 +01:00
|
|
|
draw_window();
|
2018-10-11 16:32:24 +02:00
|
|
|
if (menu.cur_y>=10) && (menu.cur_y<20) {
|
|
|
|
encoding = menu.cur_y - 10;
|
2016-01-15 00:05:51 +01:00
|
|
|
EventPageRefresh();
|
2018-10-11 16:32:24 +02:00
|
|
|
menu.cur_y = 0;
|
2016-01-07 17:00:59 +01:00
|
|
|
}
|
2018-10-11 16:32:24 +02:00
|
|
|
if (menu.cur_y>=20) {
|
|
|
|
menu.cur_y-=20;
|
|
|
|
if (menu.cur_y==0) EventPageRefresh();
|
|
|
|
if (menu.cur_y==1) EventRunEdit();
|
|
|
|
if (menu.cur_y==2) EventShowHistory();
|
|
|
|
if (menu.cur_y==3) EventShowDownloader();
|
|
|
|
if (menu.cur_y==4) EventShowInfo();
|
|
|
|
menu.cur_y = 0;
|
2016-01-15 00:05:51 +01:00
|
|
|
}
|
2016-01-07 17:00:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HandleButtonEvent()
|
|
|
|
{
|
|
|
|
byte btn = GetButtonID();
|
|
|
|
if (btn==1) {
|
|
|
|
SaveIniSettings();
|
|
|
|
ExitProcess();
|
|
|
|
}
|
|
|
|
switch(btn-10)
|
|
|
|
{
|
|
|
|
case GO_BACK:
|
|
|
|
EventGoBack();
|
|
|
|
break;
|
|
|
|
case GO_FORWARD:
|
|
|
|
EventGoForward();
|
|
|
|
break;
|
|
|
|
case OPEN_FILE:
|
|
|
|
EventOpenDialog();
|
|
|
|
break;
|
|
|
|
case MAGNIFY_PLUS:
|
|
|
|
EventMagnifyPlus();
|
|
|
|
break;
|
|
|
|
case MAGNIFY_MINUS:
|
|
|
|
EventMagnifyMinus();
|
|
|
|
break;
|
|
|
|
case CHANGE_ENCODING:
|
|
|
|
EventChangeEncoding();
|
|
|
|
break;
|
|
|
|
case RUN_EDIT:
|
|
|
|
EventRunEdit();
|
|
|
|
break;
|
2016-01-15 00:05:51 +01:00
|
|
|
case SANDWICH:
|
|
|
|
EventShowSandwichMenu();
|
2016-01-07 17:00:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HandleKeyEvent()
|
|
|
|
{
|
|
|
|
GetKeys();
|
|
|
|
if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
|
|
|
|
switch (key_scancode)
|
|
|
|
{
|
|
|
|
case SCAN_CODE_UP:
|
|
|
|
EventMagnifyPlus();
|
2018-05-24 20:47:42 +02:00
|
|
|
return;
|
2016-01-07 17:00:59 +01:00
|
|
|
case SCAN_CODE_DOWN:
|
|
|
|
EventMagnifyMinus();
|
2018-05-24 20:47:42 +02:00
|
|
|
return;
|
|
|
|
case SCAN_CODE_KEY_O:
|
|
|
|
EventOpenDialog();
|
|
|
|
return;
|
|
|
|
case SCAN_CODE_KEY_E:
|
2016-01-07 17:00:59 +01:00
|
|
|
EventRunEdit();
|
2018-05-24 20:47:42 +02:00
|
|
|
return;
|
|
|
|
case SCAN_CODE_KEY_H:
|
2016-01-07 17:00:59 +01:00
|
|
|
EventShowHistory();
|
2018-05-24 20:47:42 +02:00
|
|
|
return;
|
2016-01-07 17:00:59 +01:00
|
|
|
case SCAN_CODE_TAB:
|
|
|
|
EventChangeEncoding();
|
2018-05-24 20:47:42 +02:00
|
|
|
return;
|
2016-01-07 17:00:59 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-24 20:47:42 +02:00
|
|
|
switch (key_scancode)
|
|
|
|
{
|
|
|
|
case SCAN_CODE_F1:
|
|
|
|
EventShowInfo();
|
|
|
|
return;
|
|
|
|
case SCAN_CODE_F12:
|
|
|
|
EventChangeDebugMode();
|
|
|
|
return;
|
|
|
|
case SCAN_CODE_ENTER:
|
|
|
|
EventOpenAddress(#address);
|
|
|
|
return;
|
|
|
|
case SCAN_CODE_BS:
|
2018-10-29 12:39:31 +01:00
|
|
|
if (! address_box.flags & ed_focus) {
|
2018-05-24 20:47:42 +02:00
|
|
|
EventGoBack();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-10-29 12:39:31 +01:00
|
|
|
if (list.ProcessKey(key_scancode)) && (! address_box.flags & ed_focus) {
|
2016-01-07 17:00:59 +01:00
|
|
|
DrawPage();
|
|
|
|
return;
|
|
|
|
}
|
2018-05-24 20:47:42 +02:00
|
|
|
if (key_ascii != ASCII_KEY_ENTER)
|
2016-01-07 17:00:59 +01:00
|
|
|
&& (key_ascii != ASCII_KEY_PGDN)
|
|
|
|
&& (key_ascii != ASCII_KEY_PGUP) {
|
2016-10-31 13:37:22 +01:00
|
|
|
EAX = key_editbox;
|
2016-01-07 17:00:59 +01:00
|
|
|
edit_box_key stdcall(#address_box);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HandleMouseEvent()
|
|
|
|
{
|
|
|
|
edit_box_mouse stdcall (#address_box);
|
|
|
|
mouse.get();
|
|
|
|
list.wheel_size = 7;
|
2018-05-24 20:47:42 +02:00
|
|
|
|
|
|
|
if (link.hover(mouse.x, mouse.y)) {
|
|
|
|
if (-1 == link.active) {
|
|
|
|
DrawStatusBar( " " ); //just clean status bar
|
2018-05-22 23:02:03 +02:00
|
|
|
}
|
|
|
|
else {
|
2018-05-24 20:47:42 +02:00
|
|
|
DrawStatusBar( link.get_active_url() );
|
2018-05-22 23:02:03 +02:00
|
|
|
}
|
|
|
|
}
|
2018-05-24 20:47:42 +02:00
|
|
|
|
|
|
|
if (mouse.key&MOUSE_LEFT) && (mouse.up) {
|
|
|
|
if (-1 != link.active) EventOpenAddress( link.get_active_url() );
|
|
|
|
}
|
|
|
|
|
2016-01-07 17:00:59 +01:00
|
|
|
if (list.MouseScroll(mouse.vert)) {
|
|
|
|
DrawPage();
|
|
|
|
return;
|
|
|
|
}
|
2018-05-24 20:47:42 +02:00
|
|
|
|
2016-01-07 17:00:59 +01:00
|
|
|
scrollbar_v_mouse (#scroll);
|
|
|
|
if (list.first != scroll.position) {
|
|
|
|
list.first = scroll.position;
|
|
|
|
DrawPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-24 20:47:42 +02:00
|
|
|
void HandleNetworkEvent()
|
|
|
|
{
|
|
|
|
char favicon_address[UML];
|
|
|
|
|
|
|
|
if (downloader.state == STATE_IN_PROGRESS) {
|
|
|
|
downloader.MonitorProgress();
|
|
|
|
|
|
|
|
if (downloader.httpd.content_length>0)
|
|
|
|
DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE*
|
|
|
|
downloader.httpd.content_received/downloader.httpd.content_length);
|
|
|
|
else
|
|
|
|
DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (downloader.state == STATE_COMPLETED)
|
|
|
|
{
|
|
|
|
if (!strncmp(downloader.url,"http://gate.aspero.pro/",22)) {
|
|
|
|
strcpy(#address,downloader.url + 29);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
strcpy(#address,downloader.url);
|
|
|
|
}
|
|
|
|
downloader.Stop();
|
|
|
|
DrawAddressBox();
|
|
|
|
io.buffer_data = downloader.bufpointer;
|
|
|
|
/*
|
|
|
|
get_absolute_url(#favicon_address, #address, "/favicon.ico");
|
|
|
|
favicon.get(#favicon_address);
|
|
|
|
*/
|
|
|
|
PostOpenPageActions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-07 17:00:59 +01:00
|
|
|
|
|
|
|
/* ----------------------------------------------------- */
|
|
|
|
|
|
|
|
void EventOpenDialog()
|
|
|
|
{
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
|
|
|
if (o_dialog.status) EventOpenAddress(#openfile_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventOpenAddress(dword _new_address)
|
|
|
|
{
|
|
|
|
char temp[UML];
|
2018-05-24 20:47:42 +02:00
|
|
|
char getUrl[UML];
|
2016-01-07 17:00:59 +01:00
|
|
|
if (!ESBYTE[_new_address]) return;
|
|
|
|
debugln("====================================");
|
2018-05-24 20:47:42 +02:00
|
|
|
debug("address: ");
|
2016-01-07 17:00:59 +01:00
|
|
|
debugln(_new_address);
|
|
|
|
strlcpy(#address, _new_address, UML);
|
|
|
|
strlwr(#address);
|
|
|
|
DrawAddressBox();
|
|
|
|
|
|
|
|
/*
|
|
|
|
There could be several possible types of addresses:
|
|
|
|
- build in page
|
|
|
|
- local file
|
|
|
|
- url
|
|
|
|
So we need to detect what incoming address is
|
|
|
|
and then halndle it in the propper way.
|
|
|
|
*/
|
|
|
|
|
|
|
|
io.buffer_data = 0;
|
2016-02-06 23:48:51 +01:00
|
|
|
favicon.get(NULL);
|
2016-01-07 17:00:59 +01:00
|
|
|
|
|
|
|
// - build in page
|
|
|
|
if (!strncmp(#address,"aelia:",6)) {
|
|
|
|
debugln("this is buildin page");
|
|
|
|
if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home;
|
|
|
|
if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about;
|
|
|
|
if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory();
|
2018-05-24 20:47:42 +02:00
|
|
|
PostOpenPageActions();
|
2016-01-07 17:00:59 +01:00
|
|
|
}
|
|
|
|
// - local file
|
|
|
|
else if (check_is_the_adress_local(#address)==true) {
|
|
|
|
debugln("this is local address");
|
|
|
|
io.read(#address);
|
2018-05-24 20:47:42 +02:00
|
|
|
PostOpenPageActions();
|
2016-01-07 17:00:59 +01:00
|
|
|
}
|
|
|
|
// - url
|
|
|
|
else {
|
|
|
|
debugln("this is url");
|
2018-05-24 20:47:42 +02:00
|
|
|
if (!strncmp(#address,"https://",8)) {
|
|
|
|
sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #address);
|
|
|
|
}
|
|
|
|
else if (!strncmp(#address,"http://",7)) {
|
|
|
|
strlcpy(#getUrl, #address, UML);
|
|
|
|
}
|
|
|
|
else {
|
2016-01-07 17:00:59 +01:00
|
|
|
strcpy(#temp, "http://");
|
|
|
|
strlcpy(#temp, #address, UML);
|
|
|
|
strlcpy(#address, #temp, UML);
|
|
|
|
DrawAddressBox();
|
2018-05-24 20:47:42 +02:00
|
|
|
strlcpy(#getUrl, #address, UML);
|
2016-01-07 17:00:59 +01:00
|
|
|
}
|
2018-05-24 20:47:42 +02:00
|
|
|
downloader.Start(#getUrl);
|
2016-01-07 17:00:59 +01:00
|
|
|
}
|
2018-05-24 20:47:42 +02:00
|
|
|
}
|
2016-01-07 17:00:59 +01:00
|
|
|
|
2018-05-24 20:47:42 +02:00
|
|
|
void PostOpenPageActions()
|
|
|
|
{
|
2016-01-07 17:00:59 +01:00
|
|
|
if (!io.buffer_data) {
|
|
|
|
debugln("page not found");
|
|
|
|
io.buffer_data = #buidin_page_not_found;
|
|
|
|
}
|
|
|
|
|
|
|
|
history.add(#address);
|
2016-02-06 23:48:51 +01:00
|
|
|
favicon.draw(address_box.left-18, address_box.top-1);
|
2016-01-07 17:00:59 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
Great! So we have the page in our buffer.
|
|
|
|
We don't know is it a plain text or html.
|
|
|
|
So we need to parse it and draw.
|
|
|
|
*/
|
|
|
|
|
|
|
|
list.KeyHome();
|
|
|
|
PreparePage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventMagnifyPlus()
|
|
|
|
{
|
2016-12-21 20:50:13 +01:00
|
|
|
kfont.size.pt++;
|
|
|
|
if(!kfont.changeSIZE())
|
|
|
|
kfont.size.pt--;
|
2016-01-07 17:00:59 +01:00
|
|
|
else
|
|
|
|
PreparePage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventMagnifyMinus()
|
|
|
|
{
|
2016-12-21 20:50:13 +01:00
|
|
|
kfont.size.pt--;
|
|
|
|
if(!kfont.changeSIZE())
|
|
|
|
kfont.size.pt++;
|
2016-01-07 17:00:59 +01:00
|
|
|
else
|
|
|
|
PreparePage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventRunEdit()
|
|
|
|
{
|
|
|
|
if (check_is_the_adress_local(history.current())==true) {
|
|
|
|
io.run(DEFAULT_EDITOR, history.current());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//io.write(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); // <--- doesn't work, smth odd, need to check
|
2018-04-16 00:44:36 +02:00
|
|
|
CreateFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH);
|
2016-01-07 17:00:59 +01:00
|
|
|
io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventChangeEncoding()
|
|
|
|
{
|
|
|
|
menu.selected = encoding + 1;
|
|
|
|
menu.show(Form.left+Form.cwidth-97,Form.top+TOOLBAR_H+skin_height-6, 130, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventShowInfo() {
|
|
|
|
EventOpenAddress("aelia:about");
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventShowHistory()
|
|
|
|
{
|
|
|
|
EventOpenAddress("aelia:history");
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventGoBack()
|
|
|
|
{
|
|
|
|
if (history.back()) EventOpenAddress(history.current());
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventGoForward()
|
|
|
|
{
|
|
|
|
if (history.forward()) EventOpenAddress(history.current());
|
|
|
|
}
|
|
|
|
|
2016-01-15 00:05:51 +01:00
|
|
|
void EventShowSandwichMenu()
|
|
|
|
{
|
|
|
|
menu.selected = 0;
|
|
|
|
menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventPageRefresh()
|
|
|
|
{
|
|
|
|
EventOpenAddress(history.current());
|
|
|
|
}
|
|
|
|
|
2016-03-23 12:13:28 +01:00
|
|
|
void EventShowDownloader()
|
|
|
|
{
|
|
|
|
if (!downloader_opened) {
|
|
|
|
downloader_edit = NULL;
|
|
|
|
CreateThread(#Downloader,#downloader_stak+4092);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-24 20:47:42 +02:00
|
|
|
void EventChangeDebugMode()
|
|
|
|
{
|
|
|
|
debug_mode ^= 1;
|
|
|
|
if (debug_mode) notify("'Debug mode ON'-I");
|
|
|
|
else notify("'Debug mode OFF'-I");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-07 17:00:59 +01:00
|
|
|
/* ------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
void draw_window()
|
|
|
|
{
|
2016-11-23 12:37:13 +01:00
|
|
|
DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0);
|
2016-01-07 17:00:59 +01:00
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
|
|
|
if (Form.status_window>2) return;
|
|
|
|
|
|
|
|
if (Form.width < 200) { MoveSize(OLD,OLD,200,OLD); return; }
|
|
|
|
if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
|
2018-05-24 20:47:42 +02:00
|
|
|
|
|
|
|
system.color.get();
|
|
|
|
|
|
|
|
list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1,
|
|
|
|
Form.cheight-TOOLBAR_H-STATUSBAR_H, kfont.size.pt+4);
|
2016-01-07 17:00:59 +01:00
|
|
|
|
|
|
|
DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1);
|
|
|
|
DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece);
|
|
|
|
DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F);
|
|
|
|
|
|
|
|
DrawToolbarButton(GO_BACK, 8);
|
|
|
|
DrawToolbarButton(GO_FORWARD, 33);
|
|
|
|
DrawToolbarButton(OPEN_FILE, 68);
|
2016-01-15 00:05:51 +01:00
|
|
|
DrawToolbarButton(MAGNIFY_PLUS, Form.cwidth - 125);
|
|
|
|
DrawToolbarButton(MAGNIFY_MINUS, Form.cwidth - 100);
|
|
|
|
DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64);
|
|
|
|
DrawToolbarButton(SANDWICH, Form.cwidth - 31);
|
2016-01-07 17:00:59 +01:00
|
|
|
|
|
|
|
DrawAddressBox();
|
|
|
|
|
|
|
|
if ((Form.cwidth-scroll.size_x-1 == list.w) &&
|
|
|
|
(Form.cheight-TOOLBAR_H == list.h) &&
|
|
|
|
(list.count)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
DrawPage();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-21 20:50:13 +01:00
|
|
|
if (!kfont.raw) { //this code need to be run
|
2016-01-07 17:00:59 +01:00
|
|
|
if (param) EventOpenAddress(#param); //only once at browser sturtup
|
|
|
|
else EventOpenAddress("aelia:home");
|
|
|
|
}
|
|
|
|
else PreparePage();
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col);
|
2018-05-24 20:47:42 +02:00
|
|
|
DrawStatusBar(NULL);
|
2016-01-07 17:00:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawPage()
|
|
|
|
{
|
|
|
|
list.CheckDoesValuesOkey();
|
2016-12-23 01:27:00 +01:00
|
|
|
if (list.count) {
|
|
|
|
kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w);
|
|
|
|
}
|
2016-01-07 17:00:59 +01:00
|
|
|
DrawScroller();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawAddressBox()
|
|
|
|
{
|
2016-02-06 23:48:51 +01:00
|
|
|
address_box.left = 97+19;
|
2016-01-07 17:00:59 +01:00
|
|
|
address_box.top = 11;
|
2016-01-15 00:05:51 +01:00
|
|
|
address_box.width = Form.cwidth - address_box.left - 138;
|
2016-02-06 23:48:51 +01:00
|
|
|
DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C);
|
|
|
|
DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color);
|
2016-01-07 17:00:59 +01:00
|
|
|
address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address);
|
|
|
|
address_box.offset = 0;
|
|
|
|
edit_box_draw stdcall(#address_box);
|
2016-02-06 23:48:51 +01:00
|
|
|
favicon.draw(address_box.left-18, address_box.top-1);
|
|
|
|
DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff);
|
2018-05-21 18:29:58 +02:00
|
|
|
}
|
|
|
|
|
2018-05-24 20:47:42 +02:00
|
|
|
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0};
|
|
|
|
void DrawStatusBar(dword _status_text)
|
|
|
|
{
|
|
|
|
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, system.color.work);
|
|
|
|
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, 0x8C8C8C);
|
|
|
|
|
|
|
|
if (_status_text) {
|
|
|
|
status_text.start_x = 7;
|
|
|
|
status_text.start_y = Form.cheight - STATUSBAR_H + 3;
|
|
|
|
status_text.area_size_x = Form.cwidth - status_text.start_x -3;
|
|
|
|
status_text.font_color = system.color.work_text;
|
|
|
|
status_text.text_pointer = _status_text;
|
|
|
|
PathShow_prepare stdcall(#status_text);
|
|
|
|
PathShow_draw stdcall(#status_text);
|
|
|
|
}
|
|
|
|
}
|