From a48c1e24082daf8e2ad2815d6d3b80b01a3a2d52 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 19 Jan 2014 17:12:45 +0000 Subject: [PATCH] HTMLv: a little bit more code refactoring git-svn-id: svn://kolibrios.org@4486 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 24 ++++++++-------- programs/cmm/TWB/img_cache.h | 54 +++++++++++++++++++----------------- programs/cmm/browser/HTMLv.c | 4 +-- programs/cmm/lib/draw_buf.h | 7 +++-- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index 782b6ec84..00cda50c6 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -17,7 +17,6 @@ char page_links[12000]; char header[2048]; - char download_path[]="/rd/1/.download"; struct TWebBrowser { @@ -31,7 +30,8 @@ struct TWebBrowser { void DrawPage(); void DrawScroller(); void TextGoDown(); -}; +}; + TWebBrowser WB1; byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, @@ -593,12 +593,12 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { } if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999; TextGoDown(left1, top1, width1); - DrawBuf.DrawBar(5, WB1.list.line_h/2, WB1.list.w-10, 1, hr_color); - TextGoDown(left1, top1+WB1.list.line_h, width1); + DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color); + TextGoDown(left1, top1+list.line_h, width1); } if (!chTag("img")) { - Images( left1, top1, width1); + ImgCache1.Images( left1, top1, width1); return; } if (!chTag("meta")) || (!chTag("?xml")) @@ -624,8 +624,8 @@ void TWebBrowser::DrawScroller() // scroll_wv.position = list.first; scroll_wv.all_redraw=1; - scroll_wv.start_x = WB1.list.x + WB1.list.w; - scroll_wv.size_y=WB1.list.h; + scroll_wv.start_x = list.x + list.w; + scroll_wv.size_y=list.h; scrollbar_v_draw(#scroll_wv); } @@ -633,12 +633,12 @@ void TWebBrowser::DrawScroller() // void TWebBrowser::TextGoDown(int left1, top1, width1) { - if (!stroka) DrawBar(WB1.list.x, WB1.list.y, WB1.list.w, 5, bg_color); //закрашиваем фон над первой строкой - if (top1>=WB1.list.y) && ( top1 < WB1.list.h+WB1.list.y-10) && (!anchor) + if (!stroka) DrawBar(list.x, list.y, list.w, 5, bg_color); //закрашиваем фон над первой строкой + if (top1>=list.y) && ( top1 < list.h+list.y-10) && (!anchor) { - if (text_align == ALIGN_CENTER) DrawBuf.AlignCenter(left1,top1,WB1.list.w,WB1.list.line_h,stolbec * 6); - if (text_align == ALIGN_RIGHT) DrawBuf.AlignRight(left1,top1,WB1.list.w,WB1.list.line_h,stolbec * 6); - PutPaletteImage(buf_data+8, WB1.list.w, WB1.list.line_h, left1-5, top1, 32,0); + if (text_align == ALIGN_CENTER) DrawBuf.AlignCenter(left1,top1,list.w,list.line_h,stolbec * 6); + if (text_align == ALIGN_RIGHT) DrawBuf.AlignRight(left1,top1,list.w,list.line_h,stolbec * 6); + PutPaletteImage(buf_data+8, list.w, list.line_h, left1-5, top1, 32,0); DrawBuf.Fill(bg_color); } stroka++; diff --git a/programs/cmm/TWB/img_cache.h b/programs/cmm/TWB/img_cache.h index ad940b9b4..da15976b8 100644 --- a/programs/cmm/TWB/img_cache.h +++ b/programs/cmm/TWB/img_cache.h @@ -3,31 +3,38 @@ struct s_image dword *image; char path[4096]; }; -s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) ); -int num_of_pics; -int GetOrSetPicNum(dword i_path) +s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) ); + +struct ImgCache { + int pics_count; + void Free(); + int GetImage(); + void Images(); +} ImgCache1; + +void ImgCache::Free() +{ + for ( ; pics_count>0; pics_count--) + { + if (pics[pics_count].image) img_destroy stdcall (pics[pics_count].image); + pics[pics_count].path = NULL; + } +} + +int ImgCache::GetImage(dword i_path) { int i; - for (i=0; i0; num_of_pics--) - { - if (pics[num_of_pics].image) img_destroy stdcall (pics[num_of_pics].image); - pics[num_of_pics].path = NULL; - } + for (i=0; i