1,4 → 1,5 |
|
|
scroll_bar scroll_wv = { 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}; |
|
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
5,7 → 6,7 |
|
struct _style { |
byte |
b, u, s, h, |
b, i, u, s, h, |
pre, |
blq, |
li, |
46,14 → 47,11 |
dword link_color_active; |
dword bg_color; |
|
int draw_y; |
int stroka; |
int stolbec; |
int tab_len; |
int anchor_y; |
int anchor_line_num; |
|
int body_magrin=5; |
int basic_line_h=22; |
|
char URL[10000]; |
char header[2048]; |
char line[500]; |
75,12 → 73,14 |
//============================================================================================ |
void TWebBrowser::DrawStyle() |
{ |
int start_x, line_length, stolbec_len; |
int start_x, start_y, line_length, stolbec_len, body_magrin=5; |
|
if (!header) |
{ |
ChangeCharset("UTF-8", "CP866", #line); |
sprintf(#header, "%s - %s", #line, #version); |
strcpy(#header, #line); |
strcat(#header, " - "); |
strcat(#header, #version); |
line = 0; |
return; |
} |
88,17 → 88,20 |
|
if (line) && (!anchor) |
{ |
start_x = stolbec * list.font_w + body_magrin + list.x; |
start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x; |
start_y = stroka * list.item_h + body_magrin; |
stolbec_len = strlen(#line) * DrawBuf.zoom; |
line_length = stolbec_len * list.font_w; |
|
WriteBufText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
if (style.b) WriteBufText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - DrawBuf.zoom + draw_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
if (style.u) DrawBuf.DrawBar(start_x, list.item_h - DrawBuf.zoom - DrawBuf.zoom + draw_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
if (style.h) stroka++; |
WriteBufText(start_x, start_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
if (style.b) WriteBufText(start_x+1, start_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
if (style.i) { stolbec++; DrawBuf.Skew(start_x, start_y, line_length, list.item_h); } // bug with zoom>1 |
if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
if (style.u) DrawBuf.DrawBar(start_x, list.item_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
if (link) { |
DrawBuf.DrawBar(start_x, draw_y + list.item_h - 2, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
PageLinks.AddText(line_length, list.item_h - 2, UNDERLINE, 1, #line); //TODO: set bigger underline_h for style.h |
DrawBuf.DrawBar(start_x, list.item_h*style.h + list.item_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
PageLinks.AddText(#line, line_length, list.item_h*style.h + list.item_h, UNDERLINE); |
} |
stolbec += stolbec_len; |
} |
116,7 → 119,7 |
byte ignor_param; |
dword bufpos; |
int line_len; |
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = |
style.b = style.i = style.u = style.s = style.h = style.blq = t_html = t_body = |
style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0; |
style.align = ALIGN_LEFT; |
link_color_inactive = 0x0000FF; |
125,7 → 128,7 |
DrawBuf.Fill(bg_color); |
PageLinks.Clear(); |
strcpy(#header, #version); |
draw_y = body_magrin; |
stroka = -list.first; |
stolbec = 0; |
line = 0; |
//for plaint text use CP866 for other UTF |
224,12 → 227,12 |
} |
DrawStyle(); |
NewLine(); |
if (list.first == 0) list.count = draw_y; |
if (list.first == 0) list.count = stroka; |
DrawPage(); |
if (anchor) |
{ |
anchor=NULL; |
list.first = anchor_y; |
list.first=anchor_line_num; |
Prepare(); |
} |
} |
249,7 → 252,8 |
} |
//============================================================================================ |
void TWebBrowser::SetStyle() { |
int left1 = body_magrin + list.x; |
int left1 = 5 + list.x; |
int top1 = stroka * list.item_h + list.y + 5; |
byte opened; |
byte meta_encoding; |
if (tag[0] == '/') |
266,7 → 270,7 |
if (istag("form")) if (!opened) ignor_text = false; |
if(istag("title")) { |
if (opened) header=NULL; |
else DrawTitle(#header); |
else if (!stroka) DrawTitle(#header); |
return; |
} |
if (ignor_text) return; |
278,7 → 282,7 |
return; |
} |
if (anchor) if (isattr("id=")) || (isattr("name=")) { //very bad: if the tag is not the last it wound work |
if (!strcmp(#anchor, #val)) anchor_y=draw_y; |
if (!strcmp(#anchor, #val)) anchor_line_num=list.first+stroka; |
} |
if (istag("body")) { |
t_body = opened; |
306,7 → 310,7 |
text_colors[text_color_index] = text_colors[text_color_index-1]; |
link = 1; |
text_colors[text_color_index] = link_color_inactive; |
PageLinks.AddLink(#val, DrawBuf.zoom * stolbec * list.font_w + left1, draw_y + list.y); |
PageLinks.AddLink(#val, DrawBuf.zoom * stolbec * list.font_w + left1, top1-DrawBuf.zoom); |
} |
} while(GetNextParam()); |
} |
341,31 → 345,29 |
if (istag("br")) { NewLine(); return; } |
if (istag("tr")) { if (opened) NewLine(); return; } |
if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
if (istag("i")) || (istag("em")) || (istag("subtitle")) { style.i=opened; return; } |
if (istag("u")) || (istag("ins")) { style.u=opened; return;} |
if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } |
if (istag("dd")) { stolbec += 5; return; } |
if (istag("blockquote")) { style.blq = opened; return; } |
if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
if (istag("img")) { ImgCache.Images( left1, draw_y, WB1.list.w); return; } |
if (istag("img")) { ImgCache.Images( left1, top1, WB1.list.w); return; } |
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) { |
style.h = opened; |
NewLine(); |
if (opened) |
{ |
NewLine(); |
draw_y += 10; |
WB1.DrawBuf.zoom=2; |
WB1.list.font_type |= 10011001b; |
if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
list.item_h = basic_line_h * 2; |
if (stroka>1) NewLine(); |
} |
else |
{ |
NewLine(); |
WB1.DrawBuf.zoom=1; |
WB1.list.font_type = 10011000b; |
style.align = ALIGN_LEFT; |
list.item_h = basic_line_h; |
} |
return; |
} |
380,8 → 382,8 |
if (opened) |
{ |
NewLine(); |
DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, |
list.item_h - calc(DrawBuf.zoom*2) /2 + draw_y, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x454545); |
DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, stroka +1 * list.item_h - 3 |
- DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x454545); |
} |
return; |
} |
399,7 → 401,7 |
$push edi; |
NewLine(); |
$pop edi; |
DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
DrawBuf.DrawBar(5, list.item_h*stroka+4, list.w-10, 1, EDI); |
NewLine(); |
return; |
} |
446,11 → 448,14 |
scroll_wv.max_area = list.count; |
scroll_wv.cur_area = list.visible; |
scroll_wv.position = list.first; |
|
scroll_wv.all_redraw = 0; |
scroll_wv.start_x = list.x + list.w; |
scroll_wv.start_y = list.y; |
|
scroll_wv.size_y = list.h; |
scroll_wv.start_x = list.w + list.x; |
scroll_wv.start_x = list.w * DrawBuf.zoom + list.x; |
|
scrollbar_v_draw(#scroll_wv); |
} |
//============================================================================================ |
458,12 → 463,15 |
{ |
int onleft, ontop; |
|
if (!stolbec) && (draw_y==body_magrin) return; |
|
onleft = list.x + body_magrin; |
ontop = draw_y + list.y; |
onleft = list.x + 5; |
ontop = stroka * list.item_h + list.y + 5; |
if (t_html) && (!t_body) return; |
draw_y += list.item_h; |
if (stroka * list.item_h + 5 >= 0) && ( stroka + 1 * list.item_h + 5 < list.h) && (!anchor) |
{ |
if (style.align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.item_h,stolbec * list.font_w); |
if (style.align == ALIGN_RIGHT) && (DrawBuf.zoom==1) DrawBuf.AlignRight(onleft,ontop,list.w,list.item_h,stolbec * list.font_w); |
} |
stroka++; |
if (style.blq) stolbec = 6; else stolbec = 0; |
if (style.li) stolbec = style.li_tab * 5; |
} |
474,6 → 482,6 |
//============================================================================================ |
void TWebBrowser::DrawPage() |
{ |
PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
PutPaletteImage(list.first * list.item_h * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
DrawScroller(); |
} |