From f3fcde3a957cabe04cf5143a2a1cf43502d29654 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Fri, 1 May 2020 19:04:12 +0000 Subject: [PATCH] aelia: last update before deletion git-svn-id: svn://kolibrios.org@7852 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/aelia/aelia.c | 4 +- .../cmm/aelia/{toolbar.png => atoolbar.png} | Bin programs/cmm/aelia/canvas.h | 8 +- programs/cmm/aelia/prepare_page.h | 126 +++++------------- 4 files changed, 39 insertions(+), 99 deletions(-) rename programs/cmm/aelia/{toolbar.png => atoolbar.png} (100%) diff --git a/programs/cmm/aelia/aelia.c b/programs/cmm/aelia/aelia.c index fc4913197a..ea8360a3a1 100644 --- a/programs/cmm/aelia/aelia.c +++ b/programs/cmm/aelia/aelia.c @@ -1,4 +1,4 @@ -#define MEMSIZE 4096*100 +#define MEMSIZE 1024*400 #include "../lib/gui.h" #include "../lib/kfont.h" @@ -94,7 +94,7 @@ void main() OpenDialog_init stdcall (#o_dialog); LoadIniSettings(); kfont.init(DEFAULT_FONT); - Libimg_LoadImage(#skin, abspath("toolbar.png")); + Libimg_LoadImage(#skin, abspath("atoolbar.png")); list.no_selection = true; SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); loop() diff --git a/programs/cmm/aelia/toolbar.png b/programs/cmm/aelia/atoolbar.png similarity index 100% rename from programs/cmm/aelia/toolbar.png rename to programs/cmm/aelia/atoolbar.png diff --git a/programs/cmm/aelia/canvas.h b/programs/cmm/aelia/canvas.h index 186de6dcc9..3e53c0aba5 100644 --- a/programs/cmm/aelia/canvas.h +++ b/programs/cmm/aelia/canvas.h @@ -1,13 +1,14 @@ struct _canvas { - void write_text(); + dword write_text(); void draw_hor_line(); }; -void _canvas::write_text(int _x, _y; dword _text_col, _text_off) +dword _canvas::write_text(int _x, _y; dword _text_col, _text_off) { char error_message[128]; + dword new_x; if (_x > list.w) { sprintf(#error_message, "ERROR: canvas.x overflow: H %d X %d", kfont.size.height, _x); @@ -18,8 +19,9 @@ void _canvas::write_text(int _x, _y; dword _text_col, _text_off) debugln(#error_message); return; } - kfont.WriteIntoBuffer(_x, _y, list.w, kfont.size.height, 0xFFFFFF, _text_col, kfont.size.pt, _text_off); + new_x = kfont.WriteIntoBuffer(_x, _y, list.w, kfont.size.height, 0xFFFFFF, _text_col, kfont.size.pt, _text_off); if (_y/list.item_h-list.first==list.visible) DrawPage(); + return new_x; } diff --git a/programs/cmm/aelia/prepare_page.h b/programs/cmm/aelia/prepare_page.h index 5fc7aacc8f..8180b17025 100644 --- a/programs/cmm/aelia/prepare_page.h +++ b/programs/cmm/aelia/prepare_page.h @@ -137,50 +137,6 @@ struct _text { dword width; }; -/* -dword line_break; -byte char_holder; - -if (ESBYTE[buf.pos]==0x0A) { - if (style.pre) { - draw.line_break(); - continue; - } -} - -while (get_label_len(text.start) + draw.x + 30 > list.w) -{ - for (line_break=tag.start-1; line_break>text.start; line_break--;) - { - char_holder = ESBYTE[line_break]; //set line end - ESBYTE[line_break] = '\0'; - if (get_label_len(text.start) + draw.x + 30 <= list.w) break; - ESBYTE[line_break] = char_holder; //restore line - } - if (draw_on) { - if (style.a) { - link.add(draw.x,draw.y + size_pt_change,get_label_len(text.start),list.item_h,text.start," "); - label_draw_bar(draw.x, draw.y+kfont.size.pt+1, get_label_len(text.start), style.color); - } - WriteTextIntoBuf(draw.x, draw.y, style.color, text.start); - } - draw.x+=char_width[' ']; - ESBYTE[line_break] = char_holder; //restore line - text.start = line_break; - draw.line_break(); -} -if (draw_on) { - if (style.a) { - link.add(draw.x,draw.y + size_pt_change,get_label_len(text.start),list.item_h,text.start," "); - label_draw_bar(draw.x, draw.y+kfont.size.pt+1, get_label_len(text.start), style.color); - } - WriteTextIntoBuf(draw.x, draw.y, style.color, text.start); -} -draw.x += char_width[' ']; -draw.x += get_label_len(text.start); -*/ - - /*======================================================== = = = DOM = @@ -275,15 +231,38 @@ void _dom::set_style() */ } -void _dom::apply_text() +void _dom::apply_text(dword _intext) { - if (kfont.size.height) && (style.body) { - kfont.bold = style.bold; - canvas.write_text(draw.x, draw.y, style.color, text.start); + int label_w; + int textlen = strlen(_intext); + dword curline = malloc(textlen); + + if (!textlen) || (!style.body) return; + + do { + strlcpy(curline, _intext, textlen); + label_w = kfont.get_label_width(curline); + textlen--; + } while (label_w > list.w - draw.x - 10) && (textlen); + + kfont.bold = style.bold; + + if (kfont.size.height) { + canvas.write_text(draw.x, draw.y, style.color, curline); if (style.a) { - canvas.draw_hor_line(draw.x, draw.y + list.item_h-2, kfont.get_label_width(text.start), style.color); - link.add(draw.x, draw.y, kfont.get_label_width(text.start), list.item_h, text.start, "http://kolibrios.org"); - } + canvas.draw_hor_line(draw.x, draw.y + list.item_h-2, + kfont.get_label_width(curline), style.color); + link.add(draw.x, draw.y, kfont.get_label_width(curline), + list.item_h, curline, "http://kolibrios.org"); + } + } + draw.x += label_w; + strcpy(curline, _intext + textlen); + + if (textlen) && (textlen < strlen(_intext)-1) { + draw.x = 0; + draw.y += list.item_h; + apply_text(_intext + textlen); } } @@ -300,7 +279,7 @@ void _dom::parse() tag.start = i+1; text.end = i-1; ESBYTE[i] = '\0'; - apply_text(); + apply_text(text.start); } if (ESBYTE[i]=='>') { tag.end = i-1; @@ -338,50 +317,9 @@ void PreparePage() kfont.size.height = 0; - if ( strstri(io.buffer_data, "=list.w-30) || (ch==10) { - srch_pos = bufoff; - loop() - { - if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break - if (srch_pos == line_start) break; //no white space found in whole line - srch_pos--; - } - if (kfont.size.height) { - ESBYTE[bufoff] >< zeroch; //set line end - canvas.write_text(8, stroka_y, 0x000000, line_start); - ESBYTE[bufoff] >< zeroch; //restore line - } - stroka_y += list.item_h; - line_start = bufoff; - line_length = 0; - } - } - if (!kfont.size.height) { - list.count = stroka_y/list.item_h+3; - if (list.count < list.visible) list.count = list.visible; - kfont.size.height = list.count+5*list.item_h; - kfont.raw_size = 0; - ParseTxt(); - } - else canvas.write_text(8, stroka_y, 0x000000, line_start); -} \ No newline at end of file