forked from KolibriOS/kolibrios
HTMLv 0.99: draw into buffer, code update
git-svn-id: svn://kolibrios.org@3466 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
4d700e6239
commit
d03aa79066
@ -35,7 +35,7 @@ struct lines{
|
||||
};
|
||||
|
||||
int mouse_dd;
|
||||
edit_box edit1= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(editURL),#editURL,#mouse_dd,2,19,19};
|
||||
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(editURL),#editURL,#mouse_dd,2,19,19};
|
||||
scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
|
||||
|
||||
|
||||
@ -69,9 +69,7 @@ void main()
|
||||
|
||||
Form.width=WIN_W;
|
||||
Form.height=WIN_H;
|
||||
|
||||
SetElementSizes();
|
||||
|
||||
WB1.OpenPage();
|
||||
|
||||
SetEventMask(0x27);
|
||||
@ -92,7 +90,7 @@ void main()
|
||||
btn=GetProcessSlot(Form.ID);
|
||||
IF (btn<>GetActiveProcess()) break; //åñëè îêíî íå àêòèâíî íà ñîáûòèÿ ìûøè íå ðåàãèðóåì
|
||||
|
||||
edit_box_mouse stdcall (#edit1);
|
||||
edit_box_mouse stdcall (#address_box);
|
||||
|
||||
m.get();
|
||||
|
||||
@ -150,13 +148,13 @@ void main()
|
||||
case evKey:
|
||||
key = GetKey();
|
||||
|
||||
if (edit1.flags & 0b10) SWITCH(key) //åñëè àêòèâíà ñòðîêà àäðåñà èãíîðèðóåì íåêîòîðûå êíîïêè
|
||||
if (address_box.flags & 0b10) SWITCH(key) //åñëè àêòèâíà ñòðîêà àäðåñà èãíîðèðóåì íåêîòîðûå êíîïêè
|
||||
{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
|
||||
|
||||
WB1.Scan(key);
|
||||
|
||||
_EDIT_MARK:
|
||||
if (key<>0x0d) && (key<>183) && (key<>184) && (key<>173) {EAX=key<<8; edit_box_key stdcall(#edit1);} //àäðåñíàÿ ñòðîêà
|
||||
if (key<>0x0d) && (key<>183) && (key<>184) && (key<>173) {EAX=key<<8; edit_box_key stdcall(#address_box);} //àäðåñíàÿ ñòðîêà
|
||||
break;
|
||||
case evReDraw:
|
||||
Draw_Window();
|
||||
@ -176,10 +174,10 @@ void main()
|
||||
|
||||
void SetElementSizes()
|
||||
{
|
||||
edit1.width = Form.width-266;
|
||||
address_box.width = Form.width-266;
|
||||
WB1.top = 44;
|
||||
WB1.width = Form.cwidth - 4;
|
||||
WB1.height = Form.cheight - WB1.top;
|
||||
WB1.width = Form.width - 10 - scroll1.size_x;
|
||||
WB1.height = Form.height - WB1.top - GetSkinHeight() - 4;
|
||||
WB1.line_h = 10;
|
||||
lines.column_max = WB1.width - 30 / 6;
|
||||
lines.visible = WB1.height - 3 / WB1.line_h - 2;
|
||||
@ -189,7 +187,7 @@ void SetElementSizes()
|
||||
void Draw_Window()
|
||||
{
|
||||
int j;
|
||||
DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0x00E4DFE1,0,0);
|
||||
DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0xE4DFE1,0,0);
|
||||
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
if (Form.status_window>2)
|
||||
|
@ -1,3 +1,7 @@
|
||||
12.04.13 - 0.99
|
||||
- отрисовка в буфер;
|
||||
- исправление ошибок и обновление кода.
|
||||
|
||||
20.11.12 - 0.98
|
||||
- интелектуальная система кеширования изображений.
|
||||
|
||||
|
@ -8,7 +8,7 @@ dword
|
||||
|
||||
char download_path[]="/rd/1/.download";
|
||||
char search_path[]="http://nigma.ru/index.php?s=";
|
||||
char version[]=" Text-based Browser 0.98.2";
|
||||
char version[]=" Text-based Browser 0.99";
|
||||
|
||||
|
||||
struct TWebBrowser {
|
||||
@ -23,12 +23,10 @@ struct TWebBrowser {
|
||||
void DrawPage();
|
||||
void DrawScroller();
|
||||
};
|
||||
|
||||
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
|
||||
link, ignor_text, li_tab, first_line_drawed, cur_encoding;
|
||||
|
||||
TWebBrowser WB1;
|
||||
|
||||
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
|
||||
link, ignor_text, li_tab, cur_encoding;
|
||||
|
||||
dword text_colors[300],
|
||||
text_color_index,
|
||||
@ -37,23 +35,112 @@ dword text_colors[300],
|
||||
|
||||
int stroka,
|
||||
stolbec,
|
||||
tab_len;
|
||||
|
||||
char anchor[256];
|
||||
int anchor_line_num;
|
||||
tab_len,
|
||||
anchor_line_num;
|
||||
|
||||
char line[500],
|
||||
tag[100],
|
||||
tagparam[10000],
|
||||
parametr[1200],
|
||||
options[4096];
|
||||
options[4096],
|
||||
anchor[256];
|
||||
|
||||
#include "include\history.h"
|
||||
#include "include\colors.h"
|
||||
#include "include\unicode_tags.h"
|
||||
#include "include\img_cache.h"
|
||||
#include "include\some_code.h"
|
||||
#include "include\parce_tag.h"
|
||||
|
||||
//=======================================================================
|
||||
dword drawbuf;
|
||||
void DrawBufInit()
|
||||
{
|
||||
free(drawbuf);
|
||||
drawbuf = malloc(WB1.width * WB1.line_h +4 * 4 + 8); //+1 for good luck
|
||||
ESDWORD[drawbuf] = WB1.width;
|
||||
ESDWORD[drawbuf+4] = WB1.line_h;
|
||||
DrawBufFill();
|
||||
}
|
||||
void DrawBufFill()
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<WB1.width* WB1.line_h +4 * 4; i+=4) ESDWORD[drawbuf+i+8] = bg_color;
|
||||
}
|
||||
void DrawBufBar(dword x, y, w, h, color)
|
||||
{
|
||||
int i, j;
|
||||
for (j=0; j<h; j++)
|
||||
{
|
||||
for (i = y+j*WB1.width+x*4; i<y+j*WB1.width+x+w*4 ; i+=4) ESDWORD[drawbuf+i+8] = color;
|
||||
}
|
||||
}
|
||||
|
||||
char shift[]={8,8,4,4};
|
||||
void DrawBufSkew(dword x, y, w, h)
|
||||
{
|
||||
int i, j;
|
||||
stolbec++;
|
||||
for (j=0; j<=3; j++)
|
||||
{
|
||||
for (i = y+j*WB1.width+x+w+h*4; i>y+j*WB1.width+x+h-12*4 ; i-=4)
|
||||
ESDWORD[drawbuf+i+8] = ESDWORD[-shift[j]+drawbuf+i+8];
|
||||
}
|
||||
}
|
||||
|
||||
void TextGoDown(int left1, top1, width1)
|
||||
{
|
||||
if (!stroka) DrawBar(WB1.left, WB1.top, WB1.width, 5, bg_color); //çàêðàøèâàåì ôîí íàä ïåðâîé ñòðîêîé
|
||||
stroka++;
|
||||
if (blq_text) stolbec = 8; else stolbec = 0;
|
||||
if (li_text) stolbec = li_tab * 5;
|
||||
if (top1>=WB1.top) && ( top1 < WB1.height+WB1.top-10) && (!anchor)
|
||||
{
|
||||
PutPaletteImage(drawbuf+8, WB1.width, WB1.line_h, left1-5, top1, 32,0);
|
||||
DrawBufFill();
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::DrawPage()
|
||||
{
|
||||
int start_x, start_y, line_length, magrin_left=5;
|
||||
|
||||
if (!header)
|
||||
{
|
||||
strcpy(#header, #line);
|
||||
strcat(#header, " -");
|
||||
strcat(#header, #version);
|
||||
line = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
|
||||
{
|
||||
start_x = stolbec * 6 + left + magrin_left;
|
||||
start_y = stroka * 10 + top + magrin_left;
|
||||
line_length = strlen(#line) * 6;
|
||||
|
||||
if (use_truetype == 1)
|
||||
{
|
||||
//line_length = get_length stdcall (#line,-1,16,line_length);
|
||||
text_out stdcall (#line, #fontlol, 17, text_colors[text_color_index], start_x, start_y-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, drawbuf);
|
||||
}
|
||||
IF (b_text) WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, drawbuf);
|
||||
IF (i_text) DrawBufSkew(start_x, 0, line_length, line_h);
|
||||
IF (s_text) DrawBufBar(start_x, 4, line_length, 1, text_colors[text_color_index]);
|
||||
IF (u_text) DrawBufBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
|
||||
IF (link) {
|
||||
UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9);
|
||||
DrawBufBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
|
||||
}
|
||||
stolbec += strlen(#line);
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
void TWebBrowser::Scan(int id)
|
||||
{
|
||||
@ -138,11 +225,14 @@ void TWebBrowser::Scan(int id)
|
||||
if (!BrowserHistory.GoForward()) return;
|
||||
OpenPage();
|
||||
return;
|
||||
case 052: //Íàæàòà F3
|
||||
//case 255: //F12
|
||||
// RunProgram("/rd/1/HTMLv_old", #URL);
|
||||
// return;
|
||||
case 052: //F3
|
||||
if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path);
|
||||
return;
|
||||
case 054: //F5
|
||||
IF(edit1.flags & 0b10) break;
|
||||
IF(address_box.flags & 0b10) break;
|
||||
case REFRESH:
|
||||
if (GetProcessSlot(downloader_id)<>0)
|
||||
{
|
||||
@ -210,7 +300,6 @@ void TWebBrowser::Scan(int id)
|
||||
|
||||
|
||||
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/rd/", "/fd/", "/bd/", "/hd/", "/cd/", "/tmp/", 0};
|
||||
|
||||
//dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){
|
||||
void TWebBrowser::GetNewUrl(){
|
||||
int i, len;
|
||||
@ -307,13 +396,13 @@ void TWebBrowser::OpenPage()
|
||||
|
||||
void TWebBrowser::ShowPage()
|
||||
{
|
||||
edit1.size = edit1.pos = strlen(#editURL);
|
||||
edit1.offset=0;
|
||||
edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà
|
||||
address_box.size = address_box.pos = strlen(#editURL);
|
||||
address_box.offset=0;
|
||||
edit_box_draw stdcall(#address_box);
|
||||
|
||||
if (!filesize)
|
||||
{
|
||||
DrawBar(left, top, width+4, height, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äîíèçó
|
||||
DrawBar(left, top, width+scroll1.size_x+1, height, 0xFFFFFF); //fill all
|
||||
if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...");
|
||||
else
|
||||
{
|
||||
@ -343,13 +432,14 @@ void TWebBrowser::ParseHTML(dword bword){
|
||||
for (j = 400; j < blink + 1; j++;) DeleteButton(j);
|
||||
blink = 400;
|
||||
|
||||
b_text = i_text = u_text = s_text = blq_text = first_line_drawed =
|
||||
b_text = i_text = u_text = s_text = blq_text =
|
||||
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
|
||||
link_color = 0x0000FF;
|
||||
bg_color = 0xFFFFFF;
|
||||
line = NULL;
|
||||
strcpy(#page_links,"|");
|
||||
strcpy(#header, #version);
|
||||
DrawBufInit();
|
||||
|
||||
if (pre_text<>2)
|
||||
{
|
||||
@ -449,16 +539,15 @@ void TWebBrowser::ParseHTML(dword bword){
|
||||
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
|
||||
if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
|
||||
|
||||
if (stolbec + strlen(#line) > lines.column_max)
|
||||
if (stolbec + strlen(#line) > lines.column_max) //============the same as NEXT_MARK
|
||||
{
|
||||
perenos_num = strrchr(#line, ' ');
|
||||
if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
|
||||
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
|
||||
line[perenos_num] = 0x00;
|
||||
if (stroka >= lines.visible) && (lines.first <>0) break 1; //óõîäèì...
|
||||
if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
|
||||
DrawPage();
|
||||
strcpy(#line, #temp);
|
||||
|
||||
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
}
|
||||
DrawPage();
|
||||
@ -484,20 +573,21 @@ void TWebBrowser::ParseHTML(dword bword){
|
||||
if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
|
||||
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
|
||||
line[perenos_num] = 0x00;
|
||||
if (stroka >= lines.visible) && (lines.first <>0) break 1; //óõîäèì...
|
||||
if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
|
||||
DrawPage();
|
||||
strcpy(#line, #temp);
|
||||
|
||||
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä
|
||||
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
|
||||
if (lines.visible * 10 + 25 <= height)
|
||||
DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
|
||||
if (stroka * 10 + 15 <= height)
|
||||
DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
|
||||
DrawBar(left, lines.visible * 10 + top + 25, width, -lines.visible * 10 + height - 25, bg_color);
|
||||
if (stroka * 10 + 5 <= height)
|
||||
DrawBar(left, stroka * 10 + top + 5, width, -stroka * 10 + height - 5, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
|
||||
if (lines.first == 0) lines.all = stroka;
|
||||
if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
|
||||
{
|
||||
@ -510,53 +600,6 @@ void TWebBrowser::ParseHTML(dword bword){
|
||||
|
||||
|
||||
|
||||
void TWebBrowser::DrawPage()
|
||||
{
|
||||
int start_x, start_y, line_length;
|
||||
|
||||
if (!header)
|
||||
{
|
||||
strcpy(#header, #line);
|
||||
strcat(#header, " -");
|
||||
strcat(#header, #version);
|
||||
line = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
|
||||
{
|
||||
if (!stroka) && (!stolbec)
|
||||
{
|
||||
DrawBar(left, top, width-15, 15, bg_color); //first line
|
||||
first_line_drawed=1;
|
||||
}
|
||||
|
||||
start_x = stolbec * 6 + left + 5;
|
||||
start_y = stroka * 10 + top + 5;
|
||||
line_length = strlen(#line) * 6;
|
||||
|
||||
if (use_truetype == 1)
|
||||
{
|
||||
//line_length = get_length stdcall (#line,-1,16,line_length);
|
||||
text_out stdcall (#line, #fontlol, 17, text_colors[text_color_index], start_x, start_y-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteText(start_x, start_y, 0x80, text_colors[text_color_index], #line);
|
||||
IF (b_text) { $add ebx, 1<<16 $int 0x40 }
|
||||
}
|
||||
IF (i_text) Skew(start_x, start_y, line_length+6, 10);
|
||||
IF (s_text) DrawBar(start_x, start_y + 4, line_length, 1, text_colors[text_color_index]);
|
||||
IF (u_text) DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]);
|
||||
IF (link) {
|
||||
UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9);
|
||||
DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]);
|
||||
}
|
||||
stolbec += strlen(#line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char oldtag[100];
|
||||
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
dword hr_color;
|
||||
@ -600,7 +643,11 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
do{
|
||||
if (!strcmp(#parametr, "link=")) link_color = GetColor(#options);
|
||||
if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
|
||||
if (!strcmp(#parametr, "bgcolor=")) bg_color=GetColor(#options);
|
||||
if (!strcmp(#parametr, "bgcolor="))
|
||||
{
|
||||
bg_color=GetColor(#options);
|
||||
DrawBufFill();
|
||||
}
|
||||
} while(GetNextParam());
|
||||
return;
|
||||
}
|
||||
@ -701,9 +748,11 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
|
||||
{
|
||||
li_text = rez;
|
||||
IF(rez == 0) return;
|
||||
if (rez)
|
||||
{
|
||||
TextGoDown(left1, top1, width1);
|
||||
IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
|
||||
if (stroka > -1) && (stroka - 2 < lines.visible) DrawBufBar(li_tab * 5 * 6 + left1 - 5, line_h/2-3, 2, 2, 0x555555);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!chTag("u")) || (!chTag("ins")) u_text = rez;
|
||||
@ -719,33 +768,41 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
if (!chTag("pre")) pre_text = rez;
|
||||
if (!chTag("hr"))
|
||||
{
|
||||
TextGoDown(left1, top1, width1);
|
||||
TextGoDown(left1, top1 + 10, width1);
|
||||
if (anchor) return;
|
||||
IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options);
|
||||
ELSE hr_color = 0x999999;
|
||||
IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color);
|
||||
if (anchor) || (stroka < -1)
|
||||
{
|
||||
stroka+=2;
|
||||
return;
|
||||
}
|
||||
if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
|
||||
TextGoDown(left1, top1, width1);
|
||||
DrawBufBar(5, WB1.line_h/2, WB1.width-10, 1, hr_color);
|
||||
TextGoDown(left1, top1+WB1.line_h, width1);
|
||||
}
|
||||
/*
|
||||
if (!chTag("input"))
|
||||
{
|
||||
do{
|
||||
if (!strcmp(#parametr, "type=")) if ((!strcmp(#options, "radio")) || (!strcmp(#options, "checkbox")))
|
||||
if (!strcmp(#parametr, "type="))
|
||||
{
|
||||
if ((!strcmp(#options, "radio")) || (!strcmp(#options, "checkbox")))
|
||||
{
|
||||
if (!anchor) && (stroka > 0) CheckBox(stolbec*6 + left1,top1-2,10,10, 0, "\0", 0x888888, text_colors[text_color_index], 0);
|
||||
stolbec+=2;
|
||||
}
|
||||
if (!strcmp(#parametr, "type=")) if ((!strcmp(#options, "text")) || (!strcmp(#options, "password")))
|
||||
if ((!strcmp(#options, "text")) || (!strcmp(#options, "password")))
|
||||
{
|
||||
if (!anchor) && (stroka > 0) CheckBox(stolbec*6 + left1,top1-2,90,10, 0, "\0", 0x555555, 0, 0);
|
||||
stolbec+=16;
|
||||
}
|
||||
if (!strcmp(#parametr, "type=")) if ((!strcmp(#options, "button")) || (!strcmp(#options, "file")) || (!strcmp(#options, "submit")))
|
||||
if ((!strcmp(#options, "button")) || (!strcmp(#options, "file")) || (!strcmp(#options, "submit")))
|
||||
{
|
||||
if (!anchor) && (stroka > 0) DrawCaptButton(stolbec*6 + left1,top1-2,60,10, 0, 0xCCCccc, 0, "Button");
|
||||
stolbec+=21;
|
||||
}
|
||||
}
|
||||
} while(GetNextParam());
|
||||
}
|
||||
*/
|
||||
if (!chTag("img"))
|
||||
{
|
||||
Images( left1, top1, width1);
|
||||
@ -767,120 +824,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
}
|
||||
|
||||
|
||||
void TextGoDown(int left1, top1, width1)
|
||||
{
|
||||
if (!stroka) && (!stolbec) && (!first_line_drawed)
|
||||
{
|
||||
DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
|
||||
first_line_drawed=1;
|
||||
}
|
||||
stroka++;
|
||||
if (blq_text) stolbec = 8;
|
||||
ELSE stolbec = 0;
|
||||
if (li_text) stolbec = li_tab * 5;
|
||||
IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<num_of_pics; i++)
|
||||
{
|
||||
if (!strcmp(#pics[i].path, i_path)) return i;
|
||||
}
|
||||
num_of_pics++;
|
||||
return num_of_pics;
|
||||
}
|
||||
|
||||
void FreeImgCache()
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<=num_of_pics; i++)
|
||||
{
|
||||
img_destroy stdcall (pics[num_of_pics].image);
|
||||
pics[num_of_pics].path = NULL;
|
||||
}
|
||||
num_of_pics=0;
|
||||
}
|
||||
|
||||
|
||||
void Images(int left1, top1, width1)
|
||||
{
|
||||
dword image;
|
||||
char img_path[4096], alt[4096];
|
||||
int w=0, h=0, img_lines_first=0, cur_pic=0;
|
||||
|
||||
do{
|
||||
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
|
||||
{
|
||||
if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item);
|
||||
else strcpy(#img_path, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
|
||||
|
||||
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
|
||||
{
|
||||
img_path[strrchr(#img_path, '/')] = '\0'; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
|
||||
strcat(#img_path, #options);
|
||||
|
||||
cur_pic=GetOrSetPicNum(#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="))
|
||||
{
|
||||
strcpy(#alt, "[");
|
||||
strcat(#alt, #options);
|
||||
strcat(#alt, "]");
|
||||
}
|
||||
|
||||
} while(GetNextParam());
|
||||
|
||||
if (!pics[cur_pic].image)
|
||||
{
|
||||
if (alt) && (link) strcat(#line, #alt);
|
||||
return;
|
||||
}
|
||||
|
||||
w=DSWORD[pics[cur_pic].image+4];
|
||||
h=DSWORD[pics[cur_pic].image+8];
|
||||
if (w>width1) w=width1;
|
||||
|
||||
if (stroka==0) DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
|
||||
stroka+=h/10;
|
||||
if (top1+h<WB1.top) || (top1>WB1.top+WB1.height-10) return; //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
|
||||
if (top1<WB1.top) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
|
||||
{
|
||||
DrawBar(WB1.left, WB1.top, WB1.width-15, 10, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
|
||||
img_lines_first=WB1.top-top1;
|
||||
h=h-img_lines_first;
|
||||
top1=WB1.top;
|
||||
}
|
||||
if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó
|
||||
{
|
||||
h=WB1.top+WB1.height-top1-15;
|
||||
}
|
||||
if (h<=0) return;
|
||||
if (anchor) return;
|
||||
|
||||
img_draw stdcall (pics[cur_pic].image,left1-5,top1+10,w, h,0,img_lines_first);
|
||||
DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color);
|
||||
IF (link) UnsafeDefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9);
|
||||
}
|
||||
|
||||
|
||||
//ñêðîëë
|
||||
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
|
||||
{
|
||||
scroll1.max_area = lines.all;
|
||||
@ -888,8 +832,9 @@ void TWebBrowser::DrawScroller() //
|
||||
scroll1.position = lines.first;
|
||||
|
||||
scroll1.all_redraw=1;
|
||||
scroll1.start_x=Form.width-28; //left + width - 15
|
||||
scroll1.start_x = WB1.left + WB1.width;
|
||||
scroll1.size_y=WB1.height;
|
||||
|
||||
scrollbar_v_draw(#scroll1);
|
||||
}
|
||||
|
||||
|
95
programs/cmm/browser/include/img_cache.h
Normal file
95
programs/cmm/browser/include/img_cache.h
Normal file
@ -0,0 +1,95 @@
|
||||
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)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<num_of_pics; i++)
|
||||
{
|
||||
if (!strcmp(#pics[i].path, i_path)) return i;
|
||||
}
|
||||
num_of_pics++;
|
||||
return num_of_pics;
|
||||
}
|
||||
|
||||
void FreeImgCache()
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<=num_of_pics; i++)
|
||||
{
|
||||
img_destroy stdcall (pics[num_of_pics].image);
|
||||
pics[num_of_pics].path = NULL;
|
||||
}
|
||||
num_of_pics=0;
|
||||
}
|
||||
|
||||
|
||||
void Images(int left1, top1, width1)
|
||||
{
|
||||
dword image;
|
||||
char img_path[4096], alt[4096];
|
||||
int w=0, h=0, img_lines_first=0, cur_pic=0;
|
||||
|
||||
do{
|
||||
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
|
||||
{
|
||||
if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item);
|
||||
else strcpy(#img_path, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
|
||||
|
||||
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
|
||||
{
|
||||
img_path[strrchr(#img_path, '/')] = '\0'; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
|
||||
strcat(#img_path, #options);
|
||||
|
||||
cur_pic=GetOrSetPicNum(#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="))
|
||||
{
|
||||
strcpy(#alt, "[");
|
||||
strcat(#alt, #options);
|
||||
strcat(#alt, "]");
|
||||
}
|
||||
|
||||
} while(GetNextParam());
|
||||
|
||||
if (!pics[cur_pic].image)
|
||||
{
|
||||
if (alt) && (link) strcat(#line, #alt);
|
||||
return;
|
||||
}
|
||||
|
||||
w = DSWORD[pics[cur_pic].image+4];
|
||||
h = DSWORD[pics[cur_pic].image+8];
|
||||
if (w > width1) w = width1;
|
||||
|
||||
if (stroka==0) DrawBar(WB1.left, WB1.top, WB1.width-15, 5, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
|
||||
stroka+=h/10;
|
||||
if (top1+h<WB1.top) || (top1>WB1.top+WB1.height-10) return; //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
|
||||
if (top1<WB1.top) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
|
||||
{
|
||||
img_lines_first=WB1.top-top1;
|
||||
h=h-img_lines_first;
|
||||
top1=WB1.top;
|
||||
}
|
||||
if (top1>WB1.top+WB1.height-h-5) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó
|
||||
{
|
||||
h=WB1.top+WB1.height-top1-5;
|
||||
}
|
||||
if (h<=0) return;
|
||||
if (anchor) return;
|
||||
|
||||
img_draw stdcall (pics[cur_pic].image, left1-5, top1, w, h,0,img_lines_first);
|
||||
DrawBar(left1+w - 5, top1, WB1.width-w, h, bg_color);
|
||||
IF (link) UnsafeDefineButton(left1 - 5, top1, w, h-1, blink + BT_HIDE, 0xB5BFC9);
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
#define ITEM_WIDTH 138
|
||||
|
||||
char *ITEMS_LIST[]={
|
||||
//"Old HTMLv F12",255,
|
||||
"View in Tinypad F3",52,
|
||||
"WIN F5",54,
|
||||
"DOS Ctrl+D",04,
|
||||
|
@ -32,27 +32,3 @@ void GetURLfromPageLinks(int id)
|
||||
page_links[j] = 0x00;
|
||||
strcpy(#URL, #page_links+strrchr(#page_links, '|'));
|
||||
}
|
||||
|
||||
|
||||
//У нас нет наклонных шрифтов, поэтому делаем костыль из
|
||||
//палочек для мороженого и жевательной резинки:
|
||||
//Снимаем область экрана и выводим её обратно полосками со смещением,
|
||||
//что даёт перекос картинки
|
||||
//При наличии фона и т.п. проявится вся костыльность решения :)
|
||||
|
||||
inline void Skew(dword x,y,w,h)
|
||||
{
|
||||
dword italic_buf;
|
||||
int tile_height=2,
|
||||
shift=-2,
|
||||
i, skin_height;
|
||||
|
||||
italic_buf = mem_Alloc(w*h*3);
|
||||
skin_height = GetSkinHeight();
|
||||
CopyScreen(italic_buf, x+Form.left+2, y+Form.top+skin_height, w, h);
|
||||
|
||||
FOR (i=0;i*tile_height<h;i++)
|
||||
_PutImage(x+shift-i+1,i*tile_height+y, w,tile_height, w*3*tile_height*i+italic_buf);
|
||||
|
||||
mem_Free(italic_buf);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user