forked from KolibriOS/kolibrios
HTMLv: a little bit more code refactoring
git-svn-id: svn://kolibrios.org@4486 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
5501dd00fe
commit
a48c1e2408
@ -17,7 +17,6 @@ char page_links[12000];
|
|||||||
char header[2048];
|
char header[2048];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char download_path[]="/rd/1/.download";
|
char download_path[]="/rd/1/.download";
|
||||||
|
|
||||||
struct TWebBrowser {
|
struct TWebBrowser {
|
||||||
@ -32,6 +31,7 @@ struct TWebBrowser {
|
|||||||
void DrawScroller();
|
void DrawScroller();
|
||||||
void TextGoDown();
|
void TextGoDown();
|
||||||
};
|
};
|
||||||
|
|
||||||
TWebBrowser WB1;
|
TWebBrowser WB1;
|
||||||
|
|
||||||
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
|
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;
|
if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
|
||||||
TextGoDown(left1, top1, width1);
|
TextGoDown(left1, top1, width1);
|
||||||
DrawBuf.DrawBar(5, WB1.list.line_h/2, WB1.list.w-10, 1, hr_color);
|
DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
|
||||||
TextGoDown(left1, top1+WB1.list.line_h, width1);
|
TextGoDown(left1, top1+list.line_h, width1);
|
||||||
}
|
}
|
||||||
if (!chTag("img"))
|
if (!chTag("img"))
|
||||||
{
|
{
|
||||||
Images( left1, top1, width1);
|
ImgCache1.Images( left1, top1, width1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!chTag("meta")) || (!chTag("?xml"))
|
if (!chTag("meta")) || (!chTag("?xml"))
|
||||||
@ -624,8 +624,8 @@ void TWebBrowser::DrawScroller() //
|
|||||||
scroll_wv.position = list.first;
|
scroll_wv.position = list.first;
|
||||||
|
|
||||||
scroll_wv.all_redraw=1;
|
scroll_wv.all_redraw=1;
|
||||||
scroll_wv.start_x = WB1.list.x + WB1.list.w;
|
scroll_wv.start_x = list.x + list.w;
|
||||||
scroll_wv.size_y=WB1.list.h;
|
scroll_wv.size_y=list.h;
|
||||||
|
|
||||||
scrollbar_v_draw(#scroll_wv);
|
scrollbar_v_draw(#scroll_wv);
|
||||||
}
|
}
|
||||||
@ -633,12 +633,12 @@ void TWebBrowser::DrawScroller() //
|
|||||||
|
|
||||||
void TWebBrowser::TextGoDown(int left1, top1, width1)
|
void TWebBrowser::TextGoDown(int left1, top1, width1)
|
||||||
{
|
{
|
||||||
if (!stroka) DrawBar(WB1.list.x, WB1.list.y, WB1.list.w, 5, bg_color); //çàêðàøèâàåì ôîí íàä ïåðâîé ñòðîêîé
|
if (!stroka) DrawBar(list.x, list.y, list.w, 5, bg_color); //çàêðàøèâàåì ôîí íàä ïåðâîé ñòðîêîé
|
||||||
if (top1>=WB1.list.y) && ( top1 < WB1.list.h+WB1.list.y-10) && (!anchor)
|
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_CENTER) DrawBuf.AlignCenter(left1,top1,list.w,list.line_h,stolbec * 6);
|
||||||
if (text_align == ALIGN_RIGHT) DrawBuf.AlignRight(left1,top1,WB1.list.w,WB1.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, WB1.list.w, WB1.list.line_h, left1-5, top1, 32,0);
|
PutPaletteImage(buf_data+8, list.w, list.line_h, left1-5, top1, 32,0);
|
||||||
DrawBuf.Fill(bg_color);
|
DrawBuf.Fill(bg_color);
|
||||||
}
|
}
|
||||||
stroka++;
|
stroka++;
|
||||||
|
@ -3,31 +3,38 @@ struct s_image
|
|||||||
dword *image;
|
dword *image;
|
||||||
char path[4096];
|
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;
|
int i;
|
||||||
for (i=0; i<num_of_pics; i++)
|
for (i=0; i<pics_count; i++) if (!strcmp(#pics[i].path, i_path)) return i; //image exists
|
||||||
{
|
// Load image and add it to Cache
|
||||||
if (!strcmp(#pics[i].path, i_path)) return i;
|
pics_count++;
|
||||||
}
|
pics[pics_count].image = load_image(i_path);
|
||||||
num_of_pics++;
|
strcpy(#pics[pics_count].path, i_path);
|
||||||
return num_of_pics;
|
return pics_count;
|
||||||
}
|
|
||||||
|
|
||||||
void FreeImgCache()
|
|
||||||
{
|
|
||||||
for ( ; num_of_pics>0; num_of_pics--)
|
|
||||||
{
|
|
||||||
if (pics[num_of_pics].image) img_destroy stdcall (pics[num_of_pics].image);
|
|
||||||
pics[num_of_pics].path = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Images(int left1, top1, width1)
|
void ImgCache::Images(int left1, top1, width1)
|
||||||
{
|
{
|
||||||
dword image;
|
dword image;
|
||||||
char img_path[4096], alt[4096];
|
char img_path[4096], alt[4096];
|
||||||
@ -49,12 +56,7 @@ void Images(int left1, top1, width1)
|
|||||||
img_path[strrchr(#img_path, '/')] = '\0';
|
img_path[strrchr(#img_path, '/')] = '\0';
|
||||||
strcat(#img_path, #options);
|
strcat(#img_path, #options);
|
||||||
}
|
}
|
||||||
cur_pic=GetOrSetPicNum(#img_path);
|
cur_pic = GetImage(#img_path);
|
||||||
if (!pics[cur_pic].path)
|
|
||||||
{
|
|
||||||
pics[cur_pic].image=load_image(#img_path);
|
|
||||||
strcpy(#pics[cur_pic].path, #img_path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!strcmp(#parametr,"alt="))
|
if (!strcmp(#parametr,"alt="))
|
||||||
|
@ -45,8 +45,6 @@ char stak[4096];
|
|||||||
mouse m;
|
mouse m;
|
||||||
int action_buf;
|
int action_buf;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "..\TWB\TWB.c"
|
#include "..\TWB\TWB.c"
|
||||||
#include "menu_rmb.h"
|
#include "menu_rmb.h"
|
||||||
|
|
||||||
@ -239,7 +237,7 @@ void Scan(int id)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case 002: //free img cache
|
case 002: //free img cache
|
||||||
FreeImgCache();
|
ImgCache1.Free();
|
||||||
notify(IMAGES_CACHE_CLEARED);
|
notify(IMAGES_CACHE_CLEARED);
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(buf);
|
||||||
return;
|
return;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
dword buf_data;
|
dword buf_data;
|
||||||
|
|
||||||
struct DrawBufer {
|
struct DrawBufer {
|
||||||
@ -27,8 +28,8 @@ void DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh, i_buf_line_h)
|
|||||||
void DrawBufer::Fill(dword fill_color)
|
void DrawBufer::Fill(dword fill_color)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max_i = bufw * buf_line_h + 4 * 4 + buf_data;
|
int max_i = bufw * buf_line_h + 4 * 4 + buf_data +8;
|
||||||
for (i=buf_data; i<max_i; i+=4) ESDWORD[i+8] = fill_color;
|
for (i=buf_data+8; i<max_i; i+=4) ESDWORD[i] = fill_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBufer::DrawBar(dword x, y, w, h, color)
|
void DrawBufer::DrawBar(dword x, y, w, h, color)
|
||||||
@ -36,7 +37,7 @@ void DrawBufer::DrawBar(dword x, y, w, h, color)
|
|||||||
int i, j;
|
int i, j;
|
||||||
for (j=0; j<h; j++)
|
for (j=0; j<h; j++)
|
||||||
{
|
{
|
||||||
for (i = y+j*bufw+x*4; i<y+j*bufw+x+w*4 ; i+=4) ESDWORD[buf_data+i+8] = color;
|
for (i = y+j*bufw+x*4+8+buf_data; i<y+j*bufw+x+w*4+8+buf_data; i+=4) ESDWORD[i] = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user