/programs/cmm/TWB/TWB.c |
---|
3,12 → 3,14 |
#include "..\TWB\parce_tag.h" |
#include "..\TWB\special.h" |
#include "..\TWB\img_cache.h" |
#include "..\TWB\tag_list.h" |
dword page_bg; |
dword link_color_inactive; |
dword link_color_default; |
dword link_color_active; |
#include "..\TWB\links.h" |
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
#define BODY_MARGIN 6 |
#define BASIC_LINE_H 18 |
struct _style { |
bool |
15,14 → 17,11 |
b, u, s, h, |
pre, |
blq, |
li, |
li_tab, |
button, |
image, |
align; |
image; |
dword bg_color; |
dword main_title; |
LIST tag_list; |
dword tag_title; |
}; |
struct TWebBrowser { |
32,6 → 31,11 |
dword draw_y, stolbec; |
int zoom; |
dword o_bufpointer; |
int cur_encoding, custom_encoding; |
bool link, t_html, t_body; |
dword bufpointer; |
dword bufsize; |
void SetPageDefaults(); |
void AddCharToTheLine(); |
void ParseHtml(); |
41,22 → 45,10 |
void DrawScroller(); |
void NewLine(); |
bool CheckForLineBreak(); |
void BufEncode(); |
} WB1; |
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}; |
//============================================================================================ |
64,11 → 56,11 |
{ |
dword start_x, line_length, stolbec_len; |
if (style.main_title) |
if (style.tag_title) |
{ |
strncpy(#header, #line, sizeof(header)-1); |
strncat(#header, " - ", sizeof(header)-1); |
strncat(#header, #version, sizeof(header)-1); |
strncpy(#header, #line, sizeof(TWebBrowser.header)-1); |
strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
line = 0; |
return; |
} |
79,7 → 71,7 |
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; |
line_length = stolbec_len * list.font_w; |
105,8 → 97,8 |
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 (line[0]==' ') && (line[1]==NULL) {} else { |
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, link_color_inactive); |
PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); |
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)-1, UNDERLINE, zoom); |
} |
} |
stolbec += stolbec_len; |
118,9 → 110,9 |
void TWebBrowser::SetPageDefaults() |
{ |
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; |
style.align = ALIGN_LEFT; |
link_color_inactive = 0x0000FF; |
link = text_color_index = text_colors[0] = style.tag_title = false; |
style.tag_list.reset(); |
link_color_default = 0x0000FF; |
link_color_active = 0xFF0000; |
page_bg = 0xFFFFFF; |
style.bg_color = page_bg; |
128,8 → 120,8 |
PageLinks.Clear(); |
anchors.clear(); |
header = NULL; |
cur_encoding = CH_NULL; |
draw_y = body_magrin; |
cur_encoding = CH_CP866; |
draw_y = BODY_MARGIN; |
stolbec = 0; |
line = 0; |
zoom = 1; |
137,7 → 129,11 |
if (o_bufpointer) o_bufpointer=free(o_bufpointer); |
o_bufpointer = malloc(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) |
{ |
149,11 → 145,11 |
if (line[line_len-1]==' ') return; //no double spaces |
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(); |
} |
//============================================================================================ |
void TWebBrowser::ParseHtml(){ |
void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ |
word bukva[2]; |
char unicode_symbol[10]; |
dword unicode_symbol_result; |
161,6 → 157,9 |
bool ignor_param=false; |
int tab_len; |
dword bufpos; |
bufsize = _bufsize; |
bufpointer = malloc(bufsize); |
memmov(bufpointer, _bufpointer, bufsize); |
SetPageDefaults(); |
if (strstri(bufpointer, "<body")==-1) { |
t_body = true; |
194,7 → 193,7 |
bukva = ESBYTE[bufpos+j]; |
chrcat(#unicode_symbol, bukva); |
} |
if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) { |
if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(TWebBrowser.line)-1)) { |
bufpos += j; |
CheckForLineBreak(); |
} else { |
264,8 → 263,9 |
list.count = draw_y; |
list.CheckDoesValuesOkey(); |
anchors.current = NULL; |
custom_encoding = -1; |
if (!header) { |
strncpy(#header, #version, sizeof(header)-1); |
strncpy(#header, #version, sizeof(TWebBrowser.header)-1); |
DrawTitle(#header); |
} |
} |
284,7 → 284,7 |
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 |
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; |
} |
strcpy(#new_line_text, #line + line_break_pos); |
326,13 → 326,13 |
return; |
} |
if (tag.is("title")) { |
style.main_title = tag.opened; |
style.tag_title = tag.opened; |
if (!tag.opened) DrawTitle(#header); |
return; |
} |
if (tag.is("body")) { |
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("text=")) text_colors[0]=GetColor(value); |
if (value = tag.get_value_of("bgcolor=")) { |
350,7 → 350,7 |
text_color_index++; |
text_colors[text_color_index] = text_colors[text_color_index-1]; |
link = 1; |
text_colors[text_color_index] = link_color_inactive; |
text_colors[text_color_index] = link_color_default; |
PageLinks.AddLink(value); |
} |
} else { |
394,11 → 394,15 |
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("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 (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("alt=")) && (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(TWebBrowser.line)-3) && (value) sprintf(#line, "[%s]", value); |
if (!img_path) { line=0; return; } |
style.image = true; |
text_color_index++; |
413,11 → 417,12 |
DrawStyle(); |
text_color_index--; |
style.image = false; |
//ImgCache.Images( list.x, draw_y, WB1.list.w); |
//ImgCache.Images( list.x, draw_y, list.w); |
return; |
} |
if (tag.is("h4")) { |
NewLine(); |
NewLine(); |
style.h = tag.opened; |
style.b = tag.opened; |
} |
424,49 → 429,49 |
if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) { |
style.h = tag.opened; |
if (tag.opened) { |
NewLine(); |
if (!style.pre) NewLine(); |
draw_y += 10; |
WB1.zoom=2; |
WB1.list.font_type |= 10011001b; |
list.item_h = basic_line_h * 2 - 2; |
zoom=2; |
list.font_type |= 10011001b; |
list.item_h = BASIC_LINE_H * 2 - 2; |
if (tag.is("h1")) style.b = true; |
} else { |
if (tag.is("h1")) style.b = false; |
NewLine(); |
WB1.zoom=1; |
WB1.list.font_type = 10011000b; |
list.item_h = basic_line_h; |
zoom=1; |
list.font_type = 10011000b; |
list.item_h = BASIC_LINE_H; |
} |
return; |
} |
if (tag.is("dt")) { |
style.li = tag.opened; |
style.tag_list.upd_level(tag.opened, DT); |
if (tag.opened) NewLine(); |
return; |
} |
if (tag.is("li")) || (tag.is("dt")) |
{ |
style.li = tag.opened; |
if (tag.opened) |
{ |
if (style.li_tab==0) style.li_tab++; |
NewLine(); |
stolbec = style.li_tab * 5 - 2; |
strcpy(#line, "\31 "); |
//stolbec-=2; |
if (tag.is("ul")) { |
style.tag_list.upd_level(tag.opened, UL); |
if (!tag.opened) && (!style.pre) NewLine(); |
return; |
} |
if (tag.is("ol")) { |
style.tag_list.upd_level(tag.opened, OL); |
if (!tag.opened) && (!style.pre) NewLine(); |
return; |
} |
if (tag.is("ul")) || (tag.is("ol")) { |
if (!tag.opened) |
if (tag.is("li")) && (tag.opened) |
{ |
style.li = false; |
if (style.li_tab>0) style.li_tab--; |
NewLine(); |
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.li_tab<5) style.li_tab++; |
if (style.tag_list.get_order_type() == OL) { |
sprintf(#line, "%i. ", style.tag_list.inc_counter()); |
stolbec = style.tag_list.level * 5 - strlen(#line); |
} |
return; |
} |
if (tag.is("hr")) { |
if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999; |
479,8 → 484,8 |
draw_y += 10; |
return; |
} |
if (tag.is("meta")) || (tag.is("?xml")) { |
meta_encoding = CH_NULL; |
if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) { |
meta_encoding = CH_CP866; |
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= |
491,10 → 496,11 |
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; |
} |
if (meta_encoding!=CH_NULL) { |
BufEncode(meta_encoding); |
if (meta_encoding != CH_CP866) && (cur_encoding != meta_encoding) { |
cur_encoding = meta_encoding; |
bufpointer = ChangeCharset(cur_encoding*10+#charsets, "CP866", bufpointer); |
if (header) { |
ChangeCharset(charsets[cur_encoding], "CP866", #header); |
ChangeCharset(cur_encoding*10+#charsets, "CP866", #header); |
DrawTitle(#header); |
} |
} |
502,14 → 508,6 |
} |
} |
//============================================================================================ |
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() |
{ |
scroll_wv.max_area = list.count; |
527,9 → 525,9 |
dword onleft, ontop; |
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++; |
else return; |
} else if (!stolbec) { |
539,12 → 537,12 |
empty_line=0; |
} |
onleft = list.x + body_magrin; |
onleft = list.x + BODY_MARGIN; |
ontop = draw_y + list.y; |
if (t_html) && (!t_body) return; |
draw_y += list.item_h; |
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); |
} |
//============================================================================================ |
/programs/cmm/TWB/links.h |
---|
114,7 → 114,7 |
CursorPointer.Set(); |
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) { |
130,7 → 130,7 |
{ |
CursorPointer.Restore(); |
if (links[active].underline) { |
DrawUnderline(active, list_first, list_y, link_color_inactive); |
DrawUnderline(active, list_first, list_y, link_color_default); |
} |
DrawStatusBar(NULL); |
active = -1; |
/programs/cmm/TWB/tag_list.h |
---|
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]; |
} |
/programs/cmm/browser/WebView.c |
---|
1,4 → 1,3 |
//HTML Viewer in C-- |
//Copyright 2007-2020 by Veliant & Leency |
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr... |
28,6 → 27,7 |
#include "..\lib\patterns\history.h" |
#include "..\lib\patterns\http_downloader.h" |
#include "..\lib\patterns\simple_open_dialog.h" |
#include "..\lib\patterns\toolbar_button.h" |
#include "show_src.h" |
#include "download_manager.h" |
34,10 → 34,12 |
_history history; |
#include "history.h" |
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 |
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
88,7 → 90,7 |
int action_buf; |
_http http = {0, 0, 0, 0, 0, 0, 0}; |
_http http = 0; |
bool source_mode = false; |
97,10 → 99,12 |
proc_info Form; |
enum { |
ENCODINGS=900, |
BACK_BUTTON=1000, |
FORWARD_BUTTON, |
REFRESH_BUTTON, |
GOTOURL_BUTTON, |
CHANGE_ENCODING, |
SANDWICH_BUTTON, |
VIEW_SOURCE, |
EDIT_SOURCE, |
159,6 → 163,7 |
skin.h = 26; |
WB1.list.SetFont(8, 14, 10011000b); |
WB1.list.no_selection = true; |
WB1.custom_encoding = -1; |
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
loop() switch(WaitEvent()) |
{ |
237,7 → 242,7 |
GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); |
GetProcessInfo(#Form, SelfInfo); |
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.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
draw_window(); |
273,17 → 278,15 |
void SetElementSizes() |
{ |
basic_line_h = calc(WB1.list.font_h * 130) / 100; |
address_box.width = Form.cwidth - address_box.left - 52 - 16; |
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); |
WB1.list.wheel_size = 7 * basic_line_h; |
Form.cheight - TOOLBAR_H - STATUSBAR_H, 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.visible = WB1.list.h; |
} |
void draw_window() |
{ |
int i; |
296,12 → 299,11 |
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); |
DrawTopPanelButton(BACK_BUTTON, PADDING-1, 30); |
DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, 31); |
DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, -1); |
DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30); |
DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31); |
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); |
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); |
DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, |
310,12 → 312,10 |
if (WB1.list.w!=WB1.DrawBuf.bufw) { |
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20); |
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; |
debugval("source_mode", source_mode); |
LoadInternalPage(#loading_text, sizeof(loading_text)); |
source_mode=i; |
debugval("source_mode", source_mode); |
} |
OpenPage(history.current()); |
} else { |
323,13 → 323,28 |
DrawOmnibox(); |
} |
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); |
} |
void ProcessEvent(dword id__) |
{ |
switch (id__) |
{ |
case ENCODINGS...ENCODINGS+6: |
EventChangeEncodingAndLoadPage(id__-ENCODINGS); |
return; |
case NEW_WINDOW: |
RunProgram(#program_path, NULL); |
return; |
356,6 → 371,9 |
OpenPage(history.current()); |
} |
return; |
case CHANGE_ENCODING: |
EventShowEncodingsList(Form.cwidth - 150, status_text.start_y-117); |
return; |
case SANDWICH_BUTTON: |
EventShowMainMenu(Form.cwidth - 215, TOOLBAR_H-6); |
return; |
366,7 → 384,7 |
if (check_is_the_adress_local(history.current())) { |
RunProgram("/rd/1/tinypad", history.current()); |
} 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"); |
} |
return; |
598,10 → 616,6 |
if (!_bufdata) || (!_in_bufsize) { |
LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
} 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 |
DrawOmnibox(); |
if(!strrchr(#editURL, '#')) { |
608,10 → 622,11 |
strcat(#editURL, #anchors.current); |
DrawOmnibox(); |
} |
WB1.ParseHtml(); |
WB1.ParseHtml(_bufdata, _in_bufsize); |
DrawStatusBar(NULL); |
if (source_mode) { |
source_mode = false; |
ShowSource(bufpointer, bufsize); |
ShowSource(WB1.bufpointer, _in_bufsize); |
} else { |
WB1.DrawPage(); |
} |
638,16 → 653,26 |
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); |
} |
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) |
{ |
menu.selected = 0; |
menu.show(Form.left+_left-6+77,Form.top+_top+skin_height-3, 140, #main_menu, OPEN_FILE); |
} |
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); |
} |
688,72 → 713,29 |
void DrawStatusBar(dword _status_text) |
{ |
status_text.font_color = system.color.work_text; |
status_text.start_x = 10; |
status_text.start_y = Form.cheight - STATUSBAR_H + 3; |
status_text.area_size_x = Form.cwidth - status_text.start_x -3; |
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, system.color.work); |
status_text.start_y = Form.cheight - STATUSBAR_H + 4; |
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(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, system.color.work); |
if (_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); |
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); |
} |
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); |
} |
} |
void DrawOmnibox() |
{ |
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-1, address_box.width+18, 1, address_box.color); |
DrawBar(address_box.left-1, address_box.top, 1, 22, address_box.color); |
/programs/cmm/codeview/codeview.c |
---|
19,6 → 19,7 |
//useful patterns |
#include "..\lib\patterns\simple_open_dialog.h" |
#include "..\lib\patterns\toolbar_button.h" |
char homepage[] = FROM "html\\homepage.htm""\0"; |
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
28,6 → 29,8 |
#define URL_SERVICE_HOME "CodeView:home" |
proc_info Form; |
35,10 → 38,6 |
dword STATUSBAR_H = 0; |
dword col_bg = 0xE3E2E2; |
dword panel_color = 0xE3E2E2; |
dword border_color = 0x8C8C8C; |
bool debug_mode = false; |
bool open_in_a_new_window = false; |
46,10 → 45,12 |
enum { |
REFRESH_BUTTON, |
EDIT_SOURCE, |
OPEN_PAGE, |
}; |
#define URL_SIZE 4000; |
#include "..\TWB\TWB.c" |
TWebBrowser WB1; |
#include "highlight_c.h" |
char default_dir[] = "/rd/1"; |
74,7 → 75,7 |
void main() |
{ |
int i; |
int i, id; |
LoadLibraries(); |
if (param) strcpy(#current_path, #param); else strcpy(#current_path, URL_SERVICE_HOME); |
WB1.list.SetFont(8, 14, 10011000b); |
96,7 → 97,9 |
break; |
case evButton: |
if (GetButtonID()==1) ExitProcess(); |
id = GetButtonID(); |
if (1==id) ExitProcess(); |
if (OPEN_PAGE==id) EventOpenDialog(); |
break; |
case evKey: |
133,9 → 136,10 |
break; |
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); |
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.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
SetElementSizes(); |
147,12 → 151,11 |
void SetElementSizes() |
{ |
address_box.top = TOOLBAR_H/2-10; |
basic_line_h = calc(WB1.list.font_h * 130) / 100; |
address_box.left = address_box.top; |
address_box.left = address_box.top+43; |
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, |
Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); |
WB1.list.wheel_size = 7 * basic_line_h; |
Form.cheight - TOOLBAR_H - STATUSBAR_H, 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.visible = WB1.list.h; |
if (WB1.list.w!=WB1.DrawBuf.bufw) { |
163,14 → 166,14 |
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-1, Form.cwidth,1, border_color); |
DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,border_color); |
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
DrawBar(0,Form.cheight - STATUSBAR_H, 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,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); |
DrawEditBoxWebView(); |
if (!header) { |
if (!WB1.header) { |
OpenPage(#current_path); |
} else { |
WB1.DrawPage(); |
177,6 → 180,7 |
DrawEditBoxWebView(); |
} |
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 |
void LoadInternalPage(dword _bufpos, _bufsize) |
{ |
if (bufpointer) free(bufpointer); |
if (!_bufpos) || (!_bufsize) { |
LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
return; |
224,13 → 226,8 |
strcpy(#edit_path, #current_path); |
DrawEditBoxWebView(); |
bufpointer = _bufpos; |
bufsize = _bufsize; |
bufpointer = malloc(bufsize); |
strcpy(bufpointer, _bufpos); |
WB1.list.first = 0; |
WB1.ParseHtml(); |
WB1.ParseHtml(_bufpos, _bufsize); |
WB1.DrawPage(); |
} |
/programs/cmm/lib/gui.h |
---|
274,6 → 274,23 |
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 |
//useful for list of controls which goes one after one |
:struct incn |
/programs/cmm/lib/obj/iconv.h |
---|
16,17 → 16,19 |
char aIconv_open[] = "iconv_open"; |
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 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 |
if (EAX==-1) |
{ |
debugln(from_chs); |
debugln(to_chs); |
debugln("iconv: wrong charset,\nuse only CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5"); |
if (EAX==-1) { |
debugln("iconv: unsupported charset"); |
return 0; |
} |
cd = EAX; |
41,7 → 43,7 |
debugval("in_len", in_len); |
debugval("out_len", out_len); |
new_buf = free(new_buf); |
return 0; |
return conv_buf; |
} |
strcpy(conv_buf, new_buf); |
free(new_buf); |
48,9 → 50,4 |
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 |
/programs/cmm/lib/patterns/toolbar_button.h |
---|
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); |
} |
} |
/programs/cmm/liza/mail_box.c |
---|
1,6 → 1,8 |
//Leency & SoUrcerer, LGPL |
//Hidnplayer |
TWebBrowser WB1; |
#define LIST_INFO_H 59 |
int status_bar_h = 15; |
13,7 → 15,9 |
char *mailend; |
int mailsize; |
int cur_charset; |
enum { |
GET_MAIL = 20, |
SEND_MAIL, |
353,19 → 357,13 |
WB1.list.column_max = WB1.list.w - 30 / 6; |
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); |
strcpy(#header, #version); |
WB1.list.first = WB1.list.count = 0; |
} |
void DrawLetter() { |
bufsize = strlen(mdata); |
bufpointer = mdata; |
if (bufsize) && (bufpointer) { |
WB1.ParseHtml(); |
WB1.ParseHtml(mdata, strlen(mdata)); |
WB1.DrawPage(); |
} |
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff); |
} |
389,7 → 387,8 |
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(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); |
} |