WebView 2.1: ordered list support, feature to change encoding manually

git-svn-id: svn://kolibrios.org@7759 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-04-03 23:17:28 +00:00
parent 8a746b8351
commit 1fa2b55388
9 changed files with 278 additions and 220 deletions

View File

@ -3,26 +3,25 @@
#include "..\TWB\parce_tag.h" #include "..\TWB\parce_tag.h"
#include "..\TWB\special.h" #include "..\TWB\special.h"
#include "..\TWB\img_cache.h" #include "..\TWB\img_cache.h"
#include "..\TWB\tag_list.h"
dword page_bg; dword page_bg;
dword link_color_inactive; dword link_color_default;
dword link_color_active; dword link_color_active;
#include "..\TWB\links.h" #include "..\TWB\links.h"
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; #define BODY_MARGIN 6
#define BASIC_LINE_H 18
struct _style { struct _style {
bool bool
b, u, s, h, b, u, s, h,
pre, pre,
blq, blq,
li,
li_tab,
button, button,
image, image;
align;
dword bg_color; dword bg_color;
LIST tag_list;
dword main_title; dword tag_title;
}; };
struct TWebBrowser { struct TWebBrowser {
@ -32,6 +31,11 @@ struct TWebBrowser {
dword draw_y, stolbec; dword draw_y, stolbec;
int zoom; int zoom;
dword o_bufpointer; dword o_bufpointer;
int cur_encoding, custom_encoding;
bool link, t_html, t_body;
dword bufpointer;
dword bufsize;
void SetPageDefaults(); void SetPageDefaults();
void AddCharToTheLine(); void AddCharToTheLine();
void ParseHtml(); void ParseHtml();
@ -41,21 +45,9 @@ struct TWebBrowser {
void DrawScroller(); void DrawScroller();
void NewLine(); void NewLine();
bool CheckForLineBreak(); bool CheckForLineBreak();
void BufEncode(); char line[500];
} WB1; char header[150];
};
char line[500];
bool link, cur_encoding, t_html, t_body;
dword bufpointer=0;
dword bufsize=0;
char header[150];
int body_magrin=6;
int basic_line_h=22;
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
@ -64,11 +56,11 @@ void TWebBrowser::DrawStyle()
{ {
dword start_x, line_length, stolbec_len; dword start_x, line_length, stolbec_len;
if (style.main_title) if (style.tag_title)
{ {
strncpy(#header, #line, sizeof(header)-1); strncpy(#header, #line, sizeof(TWebBrowser.header)-1);
strncat(#header, " - ", sizeof(header)-1); strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
strncat(#header, #version, sizeof(header)-1); strncat(#header, #version, sizeof(TWebBrowser.header)-1);
line = 0; line = 0;
return; return;
} }
@ -79,7 +71,7 @@ void TWebBrowser::DrawStyle()
if (line) if (line)
{ {
start_x = stolbec * list.font_w + body_magrin + list.x; start_x = stolbec * list.font_w + BODY_MARGIN + list.x;
stolbec_len = strlen(#line) * zoom; stolbec_len = strlen(#line) * zoom;
line_length = stolbec_len * list.font_w; line_length = stolbec_len * list.font_w;
@ -105,8 +97,8 @@ void TWebBrowser::DrawStyle()
if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
if (link) { if (link) {
if (line[0]==' ') && (line[1]==NULL) {} else { if (line[0]==' ') && (line[1]==NULL) {} else {
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, link_color_inactive); DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default);
PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, UNDERLINE, zoom);
} }
} }
stolbec += stolbec_len; stolbec += stolbec_len;
@ -118,9 +110,9 @@ void TWebBrowser::DrawStyle()
void TWebBrowser::SetPageDefaults() void TWebBrowser::SetPageDefaults()
{ {
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre = style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
style.li = link = text_color_index = text_colors[0] = style.li_tab = style.main_title = false; link = text_color_index = text_colors[0] = style.tag_title = false;
style.align = ALIGN_LEFT; style.tag_list.reset();
link_color_inactive = 0x0000FF; link_color_default = 0x0000FF;
link_color_active = 0xFF0000; link_color_active = 0xFF0000;
page_bg = 0xFFFFFF; page_bg = 0xFFFFFF;
style.bg_color = page_bg; style.bg_color = page_bg;
@ -128,8 +120,8 @@ void TWebBrowser::SetPageDefaults()
PageLinks.Clear(); PageLinks.Clear();
anchors.clear(); anchors.clear();
header = NULL; header = NULL;
cur_encoding = CH_NULL; cur_encoding = CH_CP866;
draw_y = body_magrin; draw_y = BODY_MARGIN;
stolbec = 0; stolbec = 0;
line = 0; line = 0;
zoom = 1; zoom = 1;
@ -137,6 +129,10 @@ void TWebBrowser::SetPageDefaults()
if (o_bufpointer) o_bufpointer=free(o_bufpointer); if (o_bufpointer) o_bufpointer=free(o_bufpointer);
o_bufpointer = malloc(bufsize); o_bufpointer = malloc(bufsize);
memmov(o_bufpointer, bufpointer, bufsize); memmov(o_bufpointer, bufpointer, bufsize);
if (custom_encoding != -1) {
cur_encoding = custom_encoding;
bufpointer = ChangeCharset(cur_encoding*10+#charsets, "CP866", bufpointer);
}
} }
//============================================================================================ //============================================================================================
void TWebBrowser::AddCharToTheLine(unsigned char _char) void TWebBrowser::AddCharToTheLine(unsigned char _char)
@ -149,11 +145,11 @@ void TWebBrowser::AddCharToTheLine(unsigned char _char)
if (line[line_len-1]==' ') return; //no double spaces if (line[line_len-1]==' ') return; //no double spaces
if (!stolbec) && (!line) return; //no paces at the beginning of the line if (!stolbec) && (!line) return; //no paces at the beginning of the line
} }
if (line_len < sizeof(line)) chrcat(#line, _char); if (line_len < sizeof(TWebBrowser.line)) chrcat(#line, _char);
CheckForLineBreak(); CheckForLineBreak();
} }
//============================================================================================ //============================================================================================
void TWebBrowser::ParseHtml(){ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
word bukva[2]; word bukva[2];
char unicode_symbol[10]; char unicode_symbol[10];
dword unicode_symbol_result; dword unicode_symbol_result;
@ -161,6 +157,9 @@ void TWebBrowser::ParseHtml(){
bool ignor_param=false; bool ignor_param=false;
int tab_len; int tab_len;
dword bufpos; dword bufpos;
bufsize = _bufsize;
bufpointer = malloc(bufsize);
memmov(bufpointer, _bufpointer, bufsize);
SetPageDefaults(); SetPageDefaults();
if (strstri(bufpointer, "<body")==-1) { if (strstri(bufpointer, "<body")==-1) {
t_body = true; t_body = true;
@ -194,7 +193,7 @@ void TWebBrowser::ParseHtml(){
bukva = ESBYTE[bufpos+j]; bukva = ESBYTE[bufpos+j];
chrcat(#unicode_symbol, bukva); chrcat(#unicode_symbol, bukva);
} }
if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) { if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(TWebBrowser.line)-1)) {
bufpos += j; bufpos += j;
CheckForLineBreak(); CheckForLineBreak();
} else { } else {
@ -264,8 +263,9 @@ void TWebBrowser::ParseHtml(){
list.count = draw_y; list.count = draw_y;
list.CheckDoesValuesOkey(); list.CheckDoesValuesOkey();
anchors.current = NULL; anchors.current = NULL;
custom_encoding = -1;
if (!header) { if (!header) {
strncpy(#header, #version, sizeof(header)-1); strncpy(#header, #version, sizeof(TWebBrowser.header)-1);
DrawTitle(#header); DrawTitle(#header);
} }
} }
@ -284,7 +284,7 @@ bool TWebBrowser::CheckForLineBreak()
while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--; while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--;
} }
//Maybe a new line is too big for the whole new line? Then we have to split it //Maybe a new line is too big for the whole new line? Then we have to split it
if (!line_break_pos) && (style.li_tab*5 + strlen(#line) * zoom >= list.column_max) { if (!line_break_pos) && (style.tag_list.level*5 + strlen(#line) * zoom >= list.column_max) {
line_break_pos = list.column_max/zoom - stolbec; line_break_pos = list.column_max/zoom - stolbec;
} }
strcpy(#new_line_text, #line + line_break_pos); strcpy(#new_line_text, #line + line_break_pos);
@ -326,13 +326,13 @@ void TWebBrowser::SetStyle() {
return; return;
} }
if (tag.is("title")) { if (tag.is("title")) {
style.main_title = tag.opened; style.tag_title = tag.opened;
if (!tag.opened) DrawTitle(#header); if (!tag.opened) DrawTitle(#header);
return; return;
} }
if (tag.is("body")) { if (tag.is("body")) {
t_body = tag.opened; t_body = tag.opened;
if (value = tag.get_value_of("link=")) link_color_inactive = GetColor(value); if (value = tag.get_value_of("link=")) link_color_default = GetColor(value);
if (value = tag.get_value_of("alink=")) link_color_active = GetColor(value); if (value = tag.get_value_of("alink=")) link_color_active = GetColor(value);
if (value = tag.get_value_of("text=")) text_colors[0]=GetColor(value); if (value = tag.get_value_of("text=")) text_colors[0]=GetColor(value);
if (value = tag.get_value_of("bgcolor=")) { if (value = tag.get_value_of("bgcolor=")) {
@ -350,7 +350,7 @@ void TWebBrowser::SetStyle() {
text_color_index++; text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1]; text_colors[text_color_index] = text_colors[text_color_index-1];
link = 1; link = 1;
text_colors[text_color_index] = link_color_inactive; text_colors[text_color_index] = link_color_default;
PageLinks.AddLink(value); PageLinks.AddLink(value);
} }
} else { } else {
@ -394,11 +394,15 @@ void TWebBrowser::SetStyle() {
if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; } if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; }
if (tag.is("dd")) { stolbec += 5; return; } if (tag.is("dd")) { stolbec += 5; return; }
if (tag.is("blockquote")) { style.blq = tag.opened; return; } if (tag.is("blockquote")) { style.blq = tag.opened; return; }
if (tag.is("pre")) || (tag.is("code")) { style.pre = tag.opened; return; } if (tag.is("pre")) { style.pre = tag.opened; return; }
if (tag.is("code")) {
if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg;
style.pre = tag.opened; return;
}
if (tag.is("img")) { if (tag.is("img")) {
if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1); if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1);
if (value = tag.get_value_of("title=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value); if (value = tag.get_value_of("title=")) && (strlen(value)<sizeof(TWebBrowser.line)-3) && (value) sprintf(#line, "[%s]", value);
if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value); if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(TWebBrowser.line)-3) && (value) sprintf(#line, "[%s]", value);
if (!img_path) { line=0; return; } if (!img_path) { line=0; return; }
style.image = true; style.image = true;
text_color_index++; text_color_index++;
@ -413,10 +417,11 @@ void TWebBrowser::SetStyle() {
DrawStyle(); DrawStyle();
text_color_index--; text_color_index--;
style.image = false; style.image = false;
//ImgCache.Images( list.x, draw_y, WB1.list.w); //ImgCache.Images( list.x, draw_y, list.w);
return; return;
} }
if (tag.is("h4")) { if (tag.is("h4")) {
NewLine();
NewLine(); NewLine();
style.h = tag.opened; style.h = tag.opened;
style.b = tag.opened; style.b = tag.opened;
@ -424,49 +429,49 @@ void TWebBrowser::SetStyle() {
if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) { if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) {
style.h = tag.opened; style.h = tag.opened;
if (tag.opened) { if (tag.opened) {
NewLine(); if (!style.pre) NewLine();
draw_y += 10; draw_y += 10;
WB1.zoom=2; zoom=2;
WB1.list.font_type |= 10011001b; list.font_type |= 10011001b;
list.item_h = basic_line_h * 2 - 2; list.item_h = BASIC_LINE_H * 2 - 2;
if (tag.is("h1")) style.b = true; if (tag.is("h1")) style.b = true;
} else { } else {
if (tag.is("h1")) style.b = false; if (tag.is("h1")) style.b = false;
NewLine(); NewLine();
WB1.zoom=1; zoom=1;
WB1.list.font_type = 10011000b; list.font_type = 10011000b;
list.item_h = basic_line_h; list.item_h = BASIC_LINE_H;
} }
return; return;
} }
if (tag.is("dt")) { if (tag.is("dt")) {
style.li = tag.opened; style.tag_list.upd_level(tag.opened, DT);
if (tag.opened) NewLine(); if (tag.opened) NewLine();
return; return;
} }
if (tag.is("li")) || (tag.is("dt")) if (tag.is("ul")) {
{ style.tag_list.upd_level(tag.opened, UL);
style.li = tag.opened; if (!tag.opened) && (!style.pre) NewLine();
if (tag.opened)
{
if (style.li_tab==0) style.li_tab++;
NewLine();
stolbec = style.li_tab * 5 - 2;
strcpy(#line, "\31 ");
//stolbec-=2;
}
return; return;
} }
if (tag.is("ul")) || (tag.is("ol")) { if (tag.is("ol")) {
if (!tag.opened) style.tag_list.upd_level(tag.opened, OL);
{ if (!tag.opened) && (!style.pre) NewLine();
style.li = false; return;
if (style.li_tab>0) style.li_tab--; }
NewLine(); if (tag.is("li")) && (tag.opened)
{
if (!style.tag_list.level) style.tag_list.upd_level(1, UL);
if (!style.pre) NewLine();
if (style.tag_list.get_order_type() == UL) {
strcpy(#line, "\31 ");
stolbec = style.tag_list.level * 5 - 2;
} }
else { if (style.tag_list.get_order_type() == OL) {
if (style.li_tab<5) style.li_tab++; sprintf(#line, "%i. ", style.tag_list.inc_counter());
stolbec = style.tag_list.level * 5 - strlen(#line);
} }
return;
} }
if (tag.is("hr")) { if (tag.is("hr")) {
if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999; if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999;
@ -479,8 +484,8 @@ void TWebBrowser::SetStyle() {
draw_y += 10; draw_y += 10;
return; return;
} }
if (tag.is("meta")) || (tag.is("?xml")) { if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) {
meta_encoding = CH_NULL; meta_encoding = CH_CP866;
if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding=")) if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding="))
{ {
value += strrchr(value, '='); //search in content= value += strrchr(value, '='); //search in content=
@ -491,10 +496,11 @@ void TWebBrowser::SetStyle() {
else if (streq(value,"iso-8859-5")) || (streq(value,"iso8859-5")) meta_encoding = CH_ISO8859_5; else if (streq(value,"iso-8859-5")) || (streq(value,"iso8859-5")) meta_encoding = CH_ISO8859_5;
else if (streq(value,"koi8-r")) || (streq(value,"koi8-u")) meta_encoding = CH_KOI8; else if (streq(value,"koi8-r")) || (streq(value,"koi8-u")) meta_encoding = CH_KOI8;
} }
if (meta_encoding!=CH_NULL) { if (meta_encoding != CH_CP866) && (cur_encoding != meta_encoding) {
BufEncode(meta_encoding); cur_encoding = meta_encoding;
bufpointer = ChangeCharset(cur_encoding*10+#charsets, "CP866", bufpointer);
if (header) { if (header) {
ChangeCharset(charsets[cur_encoding], "CP866", #header); ChangeCharset(cur_encoding*10+#charsets, "CP866", #header);
DrawTitle(#header); DrawTitle(#header);
} }
} }
@ -502,14 +508,6 @@ void TWebBrowser::SetStyle() {
} }
} }
//============================================================================================ //============================================================================================
void TWebBrowser::BufEncode(dword set_new_encoding)
{
if (cur_encoding != set_new_encoding) {
cur_encoding = set_new_encoding;
bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer);
}
}
//============================================================================================
void TWebBrowser::DrawScroller() void TWebBrowser::DrawScroller()
{ {
scroll_wv.max_area = list.count; scroll_wv.max_area = list.count;
@ -527,9 +525,9 @@ void TWebBrowser::NewLine()
dword onleft, ontop; dword onleft, ontop;
static int empty_line=0; static int empty_line=0;
if (!stolbec) && (draw_y==body_magrin) return; if (!stolbec) && (draw_y==BODY_MARGIN) return;
if (style.li) && (stolbec == style.li_tab * 5) { if (style.tag_list.level) && (stolbec == style.tag_list.level * 5) {
if (empty_line<1) empty_line++; if (empty_line<1) empty_line++;
else return; else return;
} else if (!stolbec) { } else if (!stolbec) {
@ -539,12 +537,12 @@ void TWebBrowser::NewLine()
empty_line=0; empty_line=0;
} }
onleft = list.x + body_magrin; onleft = list.x + BODY_MARGIN;
ontop = draw_y + list.y; ontop = draw_y + list.y;
if (t_html) && (!t_body) return; if (t_html) && (!t_body) return;
draw_y += list.item_h; draw_y += list.item_h;
if (style.blq) stolbec = 6; else stolbec = 0; if (style.blq) stolbec = 6; else stolbec = 0;
if (style.li) stolbec = style.li_tab * 5; stolbec += style.tag_list.level * 5;
if (debug_mode) debugln(NULL); if (debug_mode) debugln(NULL);
} }
//============================================================================================ //============================================================================================

View File

@ -114,7 +114,7 @@ bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
CursorPointer.Set(); CursorPointer.Set();
if (links[active].underline) { if (links[active].underline) {
DrawUnderline(active, list_first, list_y, link_color_inactive); DrawUnderline(active, list_first, list_y, link_color_default);
} }
if (links[i].underline) { if (links[i].underline) {
@ -130,7 +130,7 @@ bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
{ {
CursorPointer.Restore(); CursorPointer.Restore();
if (links[active].underline) { if (links[active].underline) {
DrawUnderline(active, list_first, list_y, link_color_inactive); DrawUnderline(active, list_first, list_y, link_color_default);
} }
DrawStatusBar(NULL); DrawStatusBar(NULL);
active = -1; active = -1;

View File

@ -0,0 +1,39 @@
enum {DT=1, OL, UL};
struct LIST
{
int level;
int ordered[5];
int counter[5];
void reset();
void upd_level();
int inc_counter();
int get_order_type();
};
void LIST::reset()
{
level = 0;
}
void LIST::upd_level(int direction, type)
{
if (direction == 1) && (level<5) {
level++;
counter[level]=0;
ordered[level]=type;
}
if (direction == 0) && (level>0) {
level--;
}
}
int LIST::inc_counter()
{
counter[level]++;
return counter[level];
}
int LIST::get_order_type()
{
return ordered[level];
}

View File

@ -1,4 +1,3 @@
//HTML Viewer in C--
//Copyright 2007-2020 by Veliant & Leency //Copyright 2007-2020 by Veliant & Leency
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr... //Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
@ -28,15 +27,18 @@
#include "..\lib\patterns\history.h" #include "..\lib\patterns\history.h"
#include "..\lib\patterns\http_downloader.h" #include "..\lib\patterns\http_downloader.h"
#include "..\lib\patterns\simple_open_dialog.h" #include "..\lib\patterns\simple_open_dialog.h"
#include "..\lib\patterns\toolbar_button.h"
#include "show_src.h" #include "show_src.h"
#include "download_manager.h" #include "download_manager.h"
_history history; _history history;
#include "history.h" #include "history.h"
bool debug_mode = false; bool debug_mode = false;
#include "..\TWB\TWB.c" #include "..\TWB\TWB.c" //HTML Parser, a core component
char version[]="WebView 2.0 Gold"; TWebBrowser WB1;
char version[]="WebView 2.1";
#ifdef LANG_RUS #ifdef LANG_RUS
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
@ -88,7 +90,7 @@ dword STATUSBAR_H = 15;
int action_buf; int action_buf;
_http http = {0, 0, 0, 0, 0, 0, 0}; _http http = 0;
bool source_mode = false; bool source_mode = false;
@ -97,10 +99,12 @@ char stak[4096];
proc_info Form; proc_info Form;
enum { enum {
ENCODINGS=900,
BACK_BUTTON=1000, BACK_BUTTON=1000,
FORWARD_BUTTON, FORWARD_BUTTON,
REFRESH_BUTTON, REFRESH_BUTTON,
GOTOURL_BUTTON, GOTOURL_BUTTON,
CHANGE_ENCODING,
SANDWICH_BUTTON, SANDWICH_BUTTON,
VIEW_SOURCE, VIEW_SOURCE,
EDIT_SOURCE, EDIT_SOURCE,
@ -159,6 +163,7 @@ void main()
skin.h = 26; skin.h = 26;
WB1.list.SetFont(8, 14, 10011000b); WB1.list.SetFont(8, 14, 10011000b);
WB1.list.no_selection = true; WB1.list.no_selection = true;
WB1.custom_encoding = -1;
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
@ -237,7 +242,7 @@ void main()
GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
GetProcessInfo(#Form, SelfInfo); GetProcessInfo(#Form, SelfInfo);
system.color.get(); system.color.get();
if (Form.status_window>2) { DrawTitle(#header); break; } if (Form.status_window>2) break;
if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
draw_window(); draw_window();
@ -273,17 +278,15 @@ void main()
void SetElementSizes() void SetElementSizes()
{ {
basic_line_h = calc(WB1.list.font_h * 130) / 100;
address_box.width = Form.cwidth - address_box.left - 52 - 16; address_box.width = Form.cwidth - address_box.left - 52 - 16;
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x,
Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); Form.cheight - TOOLBAR_H - STATUSBAR_H, BASIC_LINE_H);
WB1.list.wheel_size = 7 * basic_line_h; WB1.list.wheel_size = 7 * BASIC_LINE_H;
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
WB1.list.visible = WB1.list.h; WB1.list.visible = WB1.list.h;
} }
void draw_window() void draw_window()
{ {
int i; int i;
@ -296,12 +299,11 @@ void draw_window()
DrawBar(0, PADDING, address_box.left-2, TSZE+1, system.color.work); DrawBar(0, PADDING, address_box.left-2, TSZE+1, system.color.work);
DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, system.color.work); DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, system.color.work);
DrawTopPanelButton(BACK_BUTTON, PADDING-1, 30); DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30);
DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, 31); DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31);
DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, -1); DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, PADDING, -1);
for (i=0; i<=2; i++) DrawBar(Form.cwidth-PADDING-TSZE+3, i*5+PADDING+7, 15, 3, system.color.work_graph); for (i=0; i<=2; i++) DrawBar(Form.cwidth-PADDING-TSZE+3, i*5+PADDING+7, 15, 3, system.color.work_graph);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, system.color.work);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, system.color.work_graph); DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, system.color.work_graph);
DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x,
@ -310,12 +312,10 @@ void draw_window()
if (WB1.list.w!=WB1.DrawBuf.bufw) { if (WB1.list.w!=WB1.DrawBuf.bufw) {
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20); WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
if (!strncmp(history.current(),"http",4)) { if (!strncmp(history.current(),"http",4)) {
//nihuya ne izyachnoe reshenie, no pust' poka butet tak //nihuya ne izyashnoe reshenie, no pust' poka butet tak
i=source_mode; i=source_mode;
debugval("source_mode", source_mode);
LoadInternalPage(#loading_text, sizeof(loading_text)); LoadInternalPage(#loading_text, sizeof(loading_text));
source_mode=i; source_mode=i;
debugval("source_mode", source_mode);
} }
OpenPage(history.current()); OpenPage(history.current());
} else { } else {
@ -323,6 +323,18 @@ void draw_window()
DrawOmnibox(); DrawOmnibox();
} }
DrawProgress(); DrawProgress();
DrawStatusBar(NULL);
}
void EventChangeEncodingAndLoadPage(int _new_encoding)
{
dword newbuf, newsize;
WB1.custom_encoding = _new_encoding;
newsize = strlen(WB1.o_bufpointer);
newbuf = malloc(newsize);
memmov(newbuf, WB1.o_bufpointer, newsize);
LoadInternalPage(newbuf, newsize);
free(newbuf);
} }
@ -330,6 +342,9 @@ void ProcessEvent(dword id__)
{ {
switch (id__) switch (id__)
{ {
case ENCODINGS...ENCODINGS+6:
EventChangeEncodingAndLoadPage(id__-ENCODINGS);
return;
case NEW_WINDOW: case NEW_WINDOW:
RunProgram(#program_path, NULL); RunProgram(#program_path, NULL);
return; return;
@ -356,6 +371,9 @@ void ProcessEvent(dword id__)
OpenPage(history.current()); OpenPage(history.current());
} }
return; return;
case CHANGE_ENCODING:
EventShowEncodingsList(Form.cwidth - 150, status_text.start_y-117);
return;
case SANDWICH_BUTTON: case SANDWICH_BUTTON:
EventShowMainMenu(Form.cwidth - 215, TOOLBAR_H-6); EventShowMainMenu(Form.cwidth - 215, TOOLBAR_H-6);
return; return;
@ -366,7 +384,7 @@ void ProcessEvent(dword id__)
if (check_is_the_adress_local(history.current())) { if (check_is_the_adress_local(history.current())) {
RunProgram("/rd/1/tinypad", history.current()); RunProgram("/rd/1/tinypad", history.current());
} else { } else {
CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm");
if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
} }
return; return;
@ -598,20 +616,17 @@ void LoadInternalPage(dword _bufdata, _in_bufsize){
if (!_bufdata) || (!_in_bufsize) { if (!_bufdata) || (!_in_bufsize) {
LoadInternalPage(#page_not_found, sizeof(page_not_found)); LoadInternalPage(#page_not_found, sizeof(page_not_found));
} else { } else {
bufsize = _in_bufsize;
if (bufpointer!=_bufdata) free(bufpointer);
bufpointer = malloc(bufsize);
memmov(bufpointer, _bufdata, bufsize);
WB1.list.first = 0; //scroll page to the top WB1.list.first = 0; //scroll page to the top
DrawOmnibox(); DrawOmnibox();
if(!strrchr(#editURL, '#')) { if(!strrchr(#editURL, '#')) {
strcat(#editURL, #anchors.current); strcat(#editURL, #anchors.current);
DrawOmnibox(); DrawOmnibox();
} }
WB1.ParseHtml(); WB1.ParseHtml(_bufdata, _in_bufsize);
DrawStatusBar(NULL);
if (source_mode) { if (source_mode) {
source_mode = false; source_mode = false;
ShowSource(bufpointer, bufsize); ShowSource(WB1.bufpointer, _in_bufsize);
} else { } else {
WB1.DrawPage(); WB1.DrawPage();
} }
@ -638,16 +653,26 @@ void DrawProgress()
void EventShowPageMenu(dword _left, _top) void EventShowPageMenu(dword _left, _top)
{ {
menu.selected = 0;
menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE); menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE);
} }
void EventShowEncodingsList(dword _left, _top)
{
menu.selected = WB1.cur_encoding + 1;
menu.show(Form.left+_left-6+77,Form.top+_top+skin_height-3, 100,
"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", ENCODINGS);
}
void EventShowMainMenu(dword _left, _top) void EventShowMainMenu(dword _left, _top)
{ {
menu.selected = 0;
menu.show(Form.left+_left-6+77,Form.top+_top+skin_height-3, 140, #main_menu, OPEN_FILE); menu.show(Form.left+_left-6+77,Form.top+_top+skin_height-3, 140, #main_menu, OPEN_FILE);
} }
void EventShowLinkMenu(dword _left, _top) void EventShowLinkMenu(dword _left, _top)
{ {
menu.selected = 0;
menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL); menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL);
} }
@ -688,72 +713,29 @@ void EventViewSource()
void DrawStatusBar(dword _status_text) void DrawStatusBar(dword _status_text)
{ {
status_text.font_color = system.color.work_text;
status_text.start_x = 10; status_text.start_x = 10;
status_text.start_y = Form.cheight - STATUSBAR_H + 3; status_text.start_y = Form.cheight - STATUSBAR_H + 4;
status_text.area_size_x = Form.cwidth - status_text.start_x -3; status_text.area_size_x = Form.cwidth - status_text.start_x -3 - 70;
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, system.color.work); //DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, system.color.work);
status_text.text_pointer = _status_text; DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, system.color.work);
PathShow_prepare stdcall(#status_text); if (_status_text) {
PathShow_draw stdcall(#status_text); status_text.text_pointer = _status_text;
} PathShow_prepare stdcall(#status_text);
PathShow_draw stdcall(#status_text);
void DrawOvalBorder(dword x,y,w,h, light,dark,right,dots)
{
DrawBar(x+1, y, w, 1, light);
DrawBar(x+1, y+h+1, w, 1, dark);
DrawBar(x, y+1, 1, h-1, light);
DrawBar(x+w+1, y+2, 1, h-2, right);
PutPixel(x, y, dots);
PutPixel(x+w+1, y+h+1, dots);
PutPixel(x, y+h+1, dots);
PutPixel(x+w+1, y, dots);
PutPixel(x, y+h, dark);
PutPixel(x+w+1, y+1, light);
PutPixel(x+w+1, y+h, dark);
}
libimg_image top_icons;
libimg_image left_icons;
void DrawTopPanelButton(dword _button_id, _x, signed int _icon_n)
{
static dword semi_white=0, bg_col, bg_col_light, bg_col_dark, bg_dark;
if (!semi_white) {
bg_col = system.color.work;
if (GrayScaleImage(#bg_col,1,1)<65) bg_dark=true; else bg_dark=false;
Libimg_LoadImage(#top_icons, "/sys/icons16.png");
Libimg_LoadImage(#left_icons, "/sys/icons16.png");
semi_white = MixColors(system.color.work, 0xFFFfff, bg_dark*90 + 96);
bg_col_dark = MixColors(system.color.work, system.color.work_graph, 90);
bg_col_light = MixColors(semi_white, 0xFFFfff, bg_dark*90 + 10);
Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffFFFfff, semi_white);
Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffCACBD6, MixColors(semi_white, 0, 220));
Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffFFFfff, system.color.work);
Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffCACBD6, MixColors(system.color.work, 0, 200));
}
DrawWideRectangle(_x+1, PADDING+1, TSZE, TSZE, 5, semi_white);
DrawOvalBorder(_x, PADDING, TSZE, TSZE, bg_col_light, bg_col_dark, semi_white, system.color.work);
DefineHiddenButton(_x, PADDING, TSZE+1, TSZE+1, _button_id);
if (_icon_n==-1) {
DrawBar(_x+6, PADDING+5, 16, 16, semi_white);
} else {
img_draw stdcall(top_icons.image, _x+6, PADDING+5, 16, 16, 0, _icon_n*16);
} }
DefineHiddenButton(status_text.start_x+status_text.area_size_x+10, status_text.start_y-3,
60, 12, CHANGE_ENCODING);
WriteTextCenter(status_text.start_x+status_text.area_size_x+10,
status_text.start_y, 60, system.color.work_text, WB1.cur_encoding*10+#charsets);
} }
void DrawOmnibox() void DrawOmnibox()
{ {
int skin_x_offset; int skin_x_offset;
DrawOvalBorder(address_box.left-2, address_box.top-3, address_box.width+18, 24, system.color.work_graph, system.color.work_graph, system.color.work_graph, system.color.work_dark); DrawOvalBorder(address_box.left-2, address_box.top-3, address_box.width+18, 24, system.color.work_graph,
system.color.work_graph, system.color.work_graph, system.color.work_dark);
DrawBar(address_box.left-1, address_box.top-2, address_box.width+18, 1, 0xD8DCD8); DrawBar(address_box.left-1, address_box.top-2, address_box.width+18, 1, 0xD8DCD8);
DrawBar(address_box.left-1, address_box.top-1, address_box.width+18, 1, address_box.color); DrawBar(address_box.left-1, address_box.top-1, address_box.width+18, 1, address_box.color);
DrawBar(address_box.left-1, address_box.top, 1, 22, address_box.color); DrawBar(address_box.left-1, address_box.top, 1, 22, address_box.color);

View File

@ -19,6 +19,7 @@
//useful patterns //useful patterns
#include "..\lib\patterns\simple_open_dialog.h" #include "..\lib\patterns\simple_open_dialog.h"
#include "..\lib\patterns\toolbar_button.h"
char homepage[] = FROM "html\\homepage.htm""\0"; char homepage[] = FROM "html\\homepage.htm""\0";
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
@ -28,6 +29,8 @@ char accept_language[]= "Accept-Language: en\n";
#define URL_SERVICE_HOME "CodeView:home" #define URL_SERVICE_HOME "CodeView:home"
proc_info Form; proc_info Form;
@ -35,10 +38,6 @@ dword TOOLBAR_H = 40;
dword STATUSBAR_H = 0; dword STATUSBAR_H = 0;
dword col_bg = 0xE3E2E2;
dword panel_color = 0xE3E2E2;
dword border_color = 0x8C8C8C;
bool debug_mode = false; bool debug_mode = false;
bool open_in_a_new_window = false; bool open_in_a_new_window = false;
@ -46,10 +45,12 @@ bool open_in_a_new_window = false;
enum { enum {
REFRESH_BUTTON, REFRESH_BUTTON,
EDIT_SOURCE, EDIT_SOURCE,
OPEN_PAGE,
}; };
#define URL_SIZE 4000; #define URL_SIZE 4000;
#include "..\TWB\TWB.c" #include "..\TWB\TWB.c"
TWebBrowser WB1;
#include "highlight_c.h" #include "highlight_c.h"
char default_dir[] = "/rd/1"; char default_dir[] = "/rd/1";
@ -74,7 +75,7 @@ void LoadLibraries()
void main() void main()
{ {
int i; int i, id;
LoadLibraries(); LoadLibraries();
if (param) strcpy(#current_path, #param); else strcpy(#current_path, URL_SERVICE_HOME); if (param) strcpy(#current_path, #param); else strcpy(#current_path, URL_SERVICE_HOME);
WB1.list.SetFont(8, 14, 10011000b); WB1.list.SetFont(8, 14, 10011000b);
@ -96,7 +97,9 @@ void main()
break; break;
case evButton: case evButton:
if (GetButtonID()==1) ExitProcess(); id = GetButtonID();
if (1==id) ExitProcess();
if (OPEN_PAGE==id) EventOpenDialog();
break; break;
case evKey: case evKey:
@ -133,9 +136,10 @@ void main()
break; break;
case evReDraw: case evReDraw:
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0); DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,system.color.work,0,0);
GetProcessInfo(#Form, SelfInfo); GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) { DrawTitle(#header); break; } system.color.get();
if (Form.status_window>2) break;
if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
SetElementSizes(); SetElementSizes();
@ -147,12 +151,11 @@ void main()
void SetElementSizes() void SetElementSizes()
{ {
address_box.top = TOOLBAR_H/2-10; address_box.top = TOOLBAR_H/2-10;
basic_line_h = calc(WB1.list.font_h * 130) / 100; address_box.left = address_box.top+43;
address_box.left = address_box.top;
address_box.width = Form.cwidth - address_box.left - address_box.left -14; address_box.width = Form.cwidth - address_box.left - address_box.left -14;
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x,
Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); Form.cheight - TOOLBAR_H - STATUSBAR_H, BASIC_LINE_H);
WB1.list.wheel_size = 7 * basic_line_h; WB1.list.wheel_size = 7 * BASIC_LINE_H;
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
WB1.list.visible = WB1.list.h; WB1.list.visible = WB1.list.h;
if (WB1.list.w!=WB1.DrawBuf.bufw) { if (WB1.list.w!=WB1.DrawBuf.bufw) {
@ -163,20 +166,21 @@ void SetElementSizes()
void draw_window() void draw_window()
{ {
DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, system.color.work);
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, system.color.work_graph);
DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,border_color); DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,system.color.work_graph);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, system.color.work);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, system.color.work_graph);
DrawEditBoxWebView(); DrawEditBoxWebView();
if (!header) { if (!WB1.header) {
OpenPage(#current_path); OpenPage(#current_path);
} else { } else {
WB1.DrawPage(); WB1.DrawPage();
DrawEditBoxWebView(); DrawEditBoxWebView();
} }
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
DrawTopPanelButton(OPEN_PAGE, 10, address_box.top-3, 0);
} }
@ -215,8 +219,6 @@ DrawEditBoxWebView()
void LoadInternalPage(dword _bufpos, _bufsize) void LoadInternalPage(dword _bufpos, _bufsize)
{ {
if (bufpointer) free(bufpointer);
if (!_bufpos) || (!_bufsize) { if (!_bufpos) || (!_bufsize) {
LoadInternalPage(#page_not_found, sizeof(page_not_found)); LoadInternalPage(#page_not_found, sizeof(page_not_found));
return; return;
@ -224,13 +226,8 @@ void LoadInternalPage(dword _bufpos, _bufsize)
strcpy(#edit_path, #current_path); strcpy(#edit_path, #current_path);
DrawEditBoxWebView(); DrawEditBoxWebView();
bufpointer = _bufpos;
bufsize = _bufsize;
bufpointer = malloc(bufsize);
strcpy(bufpointer, _bufpos);
WB1.list.first = 0; WB1.list.first = 0;
WB1.ParseHtml(); WB1.ParseHtml(_bufpos, _bufsize);
WB1.DrawPage(); WB1.DrawPage();
} }

View File

@ -274,6 +274,23 @@
ESBYTE[next_word_pointer] = '\n'; ESBYTE[next_word_pointer] = '\n';
} }
:void DrawOvalBorder(dword x,y,w,h, light,dark,right,dots)
{
DrawBar(x+1, y, w, 1, light);
DrawBar(x+1, y+h+1, w, 1, dark);
DrawBar(x, y+1, 1, h-1, light);
DrawBar(x+w+1, y+2, 1, h-2, right);
PutPixel(x, y, dots);
PutPixel(x+w+1, y+h+1, dots);
PutPixel(x, y+h+1, dots);
PutPixel(x+w+1, y, dots);
PutPixel(x, y+h, dark);
PutPixel(x+w+1, y+1, light);
PutPixel(x+w+1, y+h, dark);
}
//this function increase falue and return it //this function increase falue and return it
//useful for list of controls which goes one after one //useful for list of controls which goes one after one
:struct incn :struct incn

View File

@ -16,17 +16,19 @@ $DD 2 dup 0
char aIconv_open[] = "iconv_open"; char aIconv_open[] = "iconv_open";
char aIconv[] = "iconv"; char aIconv[] = "iconv";
char charsets[] = "UTF-8\0 KOI8-RU\0 CP1251\0 CP1252\0 ISO8859-5\0CP866";
enum { CH_UTF8, CH_KOI8, CH_CP1251, CH_CP1252, CH_ISO8859_5, CH_CP866, CH_NULL };
dword ChangeCharset(dword from_chs, to_chs, conv_buf) dword ChangeCharset(dword from_chs, to_chs, conv_buf)
{ {
dword cd, in_len, out_len, new_buf; dword cd, in_len, out_len, new_buf;
debug("iconv: from_chs = "); debugln(from_chs);
debug("iconv: to_chs = "); debugln(to_chs);
iconv_open stdcall (from_chs, to_chs); //CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5 iconv_open stdcall (from_chs, to_chs); //CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5
if (EAX==-1) if (EAX==-1) {
{ debugln("iconv: unsupported charset");
debugln(from_chs);
debugln(to_chs);
debugln("iconv: wrong charset,\nuse only CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5");
return 0; return 0;
} }
cd = EAX; cd = EAX;
@ -41,16 +43,11 @@ dword ChangeCharset(dword from_chs, to_chs, conv_buf)
debugval("in_len", in_len); debugval("in_len", in_len);
debugval("out_len", out_len); debugval("out_len", out_len);
new_buf = free(new_buf); new_buf = free(new_buf);
return 0; return conv_buf;
} }
strcpy(conv_buf, new_buf); strcpy(conv_buf, new_buf);
free(new_buf); free(new_buf);
return conv_buf; return conv_buf;
} }
:int cur_charset;
:char *charsets[] = { "UTF-8", "KOI8-RU", "CP1251", "CP1252", "ISO8859-5", "CP866", 0 };
enum { CH_UTF8, CH_KOI8, CH_CP1251, CH_CP1252, CH_ISO8859_5, CH_CP866, CH_NULL };
#endif #endif

View File

@ -0,0 +1,29 @@
void DrawTopPanelButton(dword _button_id, _x, _y, signed int _icon_n)
{
#define TSZE 25
static libimg_image top_icons;
static dword semi_white=0, bg_col, bg_col_light, bg_col_dark, bg_dark;
if (!semi_white) {
bg_col = system.color.work;
if (GrayScaleImage(#bg_col,1,1)<65) bg_dark=true; else bg_dark=false;
Libimg_LoadImage(#top_icons, "/sys/icons16.png");
semi_white = MixColors(system.color.work, 0xFFFfff, bg_dark*90 + 96);
bg_col_dark = MixColors(system.color.work, system.color.work_graph, 90);
bg_col_light = MixColors(semi_white, 0xFFFfff, bg_dark*90 + 10);
Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffFFFfff, semi_white);
Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffCACBD6, MixColors(semi_white, 0, 220));
}
DrawWideRectangle(_x+1, _y+1, TSZE, TSZE, 5, semi_white);
DrawOvalBorder(_x, _y, TSZE, TSZE, bg_col_light, bg_col_dark, semi_white, system.color.work);
DefineHiddenButton(_x, _y, TSZE+1, TSZE+1, _button_id);
if (_icon_n==-1) {
DrawBar(_x+6, _y+5, 16, 16, semi_white);
} else {
img_draw stdcall(top_icons.image, _x+6, _y+5, 16, 16, 0, _icon_n*16);
}
}

View File

@ -1,6 +1,8 @@
//Leency & SoUrcerer, LGPL //Leency & SoUrcerer, LGPL
//Hidnplayer //Hidnplayer
TWebBrowser WB1;
#define LIST_INFO_H 59 #define LIST_INFO_H 59
int status_bar_h = 15; int status_bar_h = 15;
@ -13,6 +15,8 @@ char *mailstart;
char *mailend; char *mailend;
int mailsize; int mailsize;
int cur_charset;
enum { enum {
GET_MAIL = 20, GET_MAIL = 20,
@ -353,19 +357,13 @@ void InitTWB() {
WB1.list.column_max = WB1.list.w - 30 / 6; WB1.list.column_max = WB1.list.w - 30 / 6;
WB1.list.visible = WB1.list.h / WB1.list.item_h; WB1.list.visible = WB1.list.h / WB1.list.item_h;
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h); WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h);
strcpy(#header, #version);
WB1.list.first = WB1.list.count = 0; WB1.list.first = WB1.list.count = 0;
} }
void DrawLetter() { void DrawLetter() {
bufsize = strlen(mdata); WB1.ParseHtml(mdata, strlen(mdata));
bufpointer = mdata; WB1.DrawPage();
if (bufsize) && (bufpointer) {
WB1.ParseHtml();
WB1.DrawPage();
}
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff); DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff);
} }
@ -389,7 +387,8 @@ void DrawStatusBar() {
SetMailBoxStatus(cur_st_percent, cur_st_text); SetMailBoxStatus(cur_st_percent, cur_st_text);
DrawCaptButton(240, st_y+1, 36, status_bar_h-3, STOP_LOADING, system.color.work_button, system.color.work_button_text,"Stop"); DrawCaptButton(240, st_y+1, 36, status_bar_h-3, STOP_LOADING, system.color.work_button, system.color.work_button_text,"Stop");
} }
DrawCaptButton(Form.cwidth - 100, st_y+1, 70, status_bar_h-2, CHANGE_CHARSET+BT_HIDE, system.color.work, system.color.work_text,charsets[cur_charset]); DrawCaptButton(Form.cwidth - 100, st_y+1, 70, status_bar_h-2, CHANGE_CHARSET+BT_HIDE,
system.color.work, system.color.work_text,cur_charset*10+#charsets);
} }