Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8011 → Rev 8016

/programs/cmm/TWB/TWB.c
18,6 → 18,7
struct _style {
bool
b, u, s, h,
font,
pre,
blq,
button,
30,6 → 31,7
struct TWebBrowser {
llist list;
_style style;
_img page_img;
dword draw_y, stolbec;
int zoom;
dword o_bufpointer;
95,8 → 97,8
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999);
}
 
text_color__ = text_colors[text_color_index];
if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default;
text_color__ = text_colors.get_last();
if (link) && (text_color__ == text_colors.get(0)) text_color__ = link_color_default;
 
DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL);
if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL);
117,7 → 119,7
void TWebBrowser::SetPageDefaults()
{
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
link = text_color_index = text_colors[0] = style.tag_title = false;
link = style.tag_title = style.font = false;
style.tag_list.reset();
link_color_default = 0x0000FF;
link_color_active = 0xFF0000;
126,6 → 128,9
DrawBuf.Fill(0, page_bg);
links.clear();
anchors.clear();
page_img.clear();
text_colors.drop();
text_colors.add(0);
header = NULL;
cur_encoding = CH_CP866;
draw_y = BODY_MARGIN;
339,7 → 344,7
t_body = tag.opened;
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("text=")) text_colors.set(0, GetColor(value));
if (value = tag.get_value_of("bgcolor=")) {
style.bg_color = page_bg = GetColor(value);
DrawBuf.Fill(0, page_bg);
384,19 → 389,23
NewLine();
}
if (tag.is("font")) {
style.font = tag.opened;
style.bg_color = page_bg;
if (tag.opened)
{
text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1];
if (value = tag.get_value_of("color=")) text_colors[text_color_index] = GetColor(value);
if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value);
if (value = tag.get_value_of("color=")) {
text_colors.add(GetColor(value));
} else {
text_colors.add(text_colors.get_last());
}
else if (text_color_index > 0) text_color_index--;
}
else text_colors.pop();
return;
}
if (tag.is("div")) {
if (streq(#tag.prior,"div")) && (tag.opened) return;
if (!tag.opened) && (style.font) text_colors.pop();
NewLine();
return;
}
435,8 → 444,8
if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value);
if (!img_path) { line=0; return; }
style.image = true;
text_color_index++;
text_colors[text_color_index] = 0x9A6F29;
page_img.add(#img_path, stolbec+1*list.font_w+3, draw_y);
text_colors.add(0x9A6F29);
if (!line) {
if (!strncmp(#img_path, "data:", 5)) img_path=0;
replace_char(#img_path, '?', NULL, strlen(#img_path));
445,9 → 454,8
}
while (CheckForLineBreak()) {};
Paint();
text_color_index--;
text_colors.pop();
style.image = false;
//ImgCache.Images( list.x, draw_y, list.w);
return;
}
if (tag.is("h4")) {
591,5 → 599,6
void TWebBrowser::DrawPage()
{
PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);
page_img.draw(list.x, list.y, list.first, list.h);
DrawScroller();
}
/programs/cmm/TWB/colors.h
6,8 → 6,7
int rgb;
};
 
dword text_colors[300];
dword text_color_index;
collection_int text_colors;
 
struct color_spec color_specs[] = {
"aliceblue", 0xF0F8FF,
159,7 → 158,7
textlen=0;
char ch=0x00;
 
if (ESBYTE[htmlcolor]<>'#') return text_colors[0];
if (ESBYTE[htmlcolor]<>'#') return text_colors.get(0);
 
textlen = strlen(htmlcolor);
 
177,7 → 176,7
return color;
}
 
return text_colors[0];
return text_colors.get(0);
}
 
dword GetColor(char* color_str)
192,5 → 191,5
if (!strcmpi(color_str, color_specs[ii].name)) return color_specs[ii].rgb;
}
 
return text_colors[0];
return text_colors.get(0);
}
/programs/cmm/TWB/img.h
1,17 → 1,88
struct img
struct _img
{
collection src;
collection url;
collection_int xywh;
collection_int data;
collection_int xywh;
void drop();
int getid;
dword add();
void clear();
dword current_url();
bool next_url();
void set_data();
void draw();
};
 
void img::drop()
dword _img::add(dword _path, _x, _y)
{
src.drop();
char full_path[URL_SIZE];
strncpy(#full_path, _path, URL_SIZE);
GetAbsoluteURL(#full_path, history.current());
 
url.add(#full_path);
xywh.add(_x);
xywh.add(_y);
xywh.add(0);
xywh.add(0);
return full_path;
}
 
void _img::clear()
{
url.drop();
xywh.drop();
data.drop();
getid = 0;
}
 
dword _img::current_url()
{
return url.get(getid);
}
 
bool _img::next_url()
{
if (getid < url.count-1) {
getid++;
return 1;
}
return 0;
}
 
void _img::set_data(dword _data, _data_len)
{
data.set(getid, _data);
}
 
void DrawLibimgImage(dword _x, _y, _data, _data_len)
{
libimg_image im;
img_decode stdcall (_data, _data_len, 0);
$or eax, eax
$jz __ERROR__
im.image = EAX;
im.set_vars();
im.draw(_x, _y, im.w, im.h, 0, 0);
__ERROR__:
}
 
void _img::draw(int _x, _y, _start, _height)
{
int i, img_x, img_y;
 
for (i=0; i<url.count; i++)
{
img_x = xywh.get(i*4);
img_y = xywh.get(i*4 + 1);
 
if (img_y > _start) && (img_y < _start + _height)
{
if (cache.has(url.get(i)))
DrawLibimgImage(img_x + _x, img_y-_start + _y, cache.current_buf, cache.current_size);
}
}
}
 
/*
 
void ImageCache::Images(dword left1, top1, width1)