WebView: scancodes, fonts (part1: prepare)

git-svn-id: svn://kolibrios.org@5711 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2015-08-10 15:08:16 +00:00
parent abde4bc0d8
commit 5c8f8dc889
2 changed files with 84 additions and 85 deletions

View File

@ -61,7 +61,6 @@ char anchor[256];
void TWebBrowser::DrawPage()
{
int start_x, start_y, line_length, stolbec_len, magrin_left=5;
dword font_type;
if (!header)
{
@ -80,16 +79,14 @@ void TWebBrowser::DrawPage()
stolbec_len = strlen(#line);
line_length = stolbec_len * list.font_w * DrawBuf.zoom;
if (DrawBuf.zoom==1) font_type = 0x88; else font_type = 0x89;
WriteBufText(start_x, 0, font_type, text_colors[text_color_index], #line, buf_data);
if (b_text) WriteBufText(start_x+1, 0, font_type, text_colors[text_color_index], #line, buf_data);
WriteBufText(start_x, 0, list.font_type, text_colors[text_color_index], #line, buf_data);
if (b_text) WriteBufText(start_x+1, 0, list.font_type, text_colors[text_color_index], #line, buf_data);
if (i_text) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); } // bug with zoom>1
if (s_text) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
if (u_text) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
if (link) {
DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
UnsafeDefineButton(start_x-2, start_y-1, line_length + 3, DrawBuf.zoom * 10, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
UnsafeDefineButton(start_x-2, start_y-1, line_length + 3, DrawBuf.zoom * list.font_h, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE);
}
stolbec += stolbec_len;
@ -352,7 +349,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
link = 1;
text_colors[text_color_index] = link_color_inactive;
PageLinks.AddLink(#options, DrawBuf.zoom * stolbec*6+left1, top1-DrawBuf.zoom);
PageLinks.AddLink(#options, DrawBuf.zoom * stolbec * list.font_w + left1, top1-DrawBuf.zoom);
}
if (anchor) && (!strcmp(#parametr, "name="))
{
@ -521,7 +518,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
{
NewLine();
if (stroka > -1) && (stroka - 2 < list.visible)
DrawBuf.DrawBar(li_tab * 5 * 6 * DrawBuf.zoom + list.x, list.line_h / 2 - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x555555);
DrawBuf.DrawBar(li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, list.line_h / 2 - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x555555);
}
return;
}
@ -588,7 +585,6 @@ void BufEncode(int set_new_encoding)
{
strcpy(bufpointer, o_bufpointer);
}
debugln(charsets[set_new_encoding]);
bufpointer = ChangeCharset(charsets[set_new_encoding], "CP866", bufpointer);
}
@ -620,8 +616,8 @@ void TWebBrowser::NewLine()
if (t_html) && (!t_body) return;
if (stroka * list.line_h + 5 >= 0) && ( stroka + 1 * list.line_h + 5 < list.h) && (!anchor)
{
if (text_align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.line_h,stolbec * 6);
if (text_align == ALIGN_RIGHT) && (DrawBuf.zoom==1) DrawBuf.AlignRight(onleft,ontop,list.w,list.line_h,stolbec * 6);
if (text_align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.line_h,stolbec * list.font_w);
if (text_align == ALIGN_RIGHT) && (DrawBuf.zoom==1) DrawBuf.AlignRight(onleft,ontop,list.w,list.line_h,stolbec * list.font_w);
DrawBuf.bufy = ontop;
DrawBuf.Show();
DrawBuf.Fill(bg_color);

View File

@ -88,7 +88,7 @@ edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(U
#define URL_SERVICE_HOME "WebView://home"
#define URL_SERVICE_SOURCE "WebView://source:"
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
enum { BUTTON_BACK=1000, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT };
libimg_image skin;
@ -119,7 +119,7 @@ void DrawProgress()
void main()
{
unsigned long key, btn;
dword btn;
int half_scroll_size;
int scroll_used=0, show_menu;
@ -133,6 +133,7 @@ void main()
SetSkinColors();
WB1.DrawBuf.zoom = 1;
WB1.list.SetFont(6, 9, 10001000b);
Form.width=WIN_W;
Form.height=WIN_H;
SetElementSizes();
@ -188,19 +189,24 @@ void main()
if (btn!=WB1.list.first) WB1.Parse();
}
break;
case evButton:
btn=GetButtonID();
if (btn==1) ExitProcess();
Scan(btn);
break;
case evKey:
key = GetKey();
GetKeys();
if (address_box.flags & 0b10)
{
if (key==ASCII_KEY_ENTER) Scan(key); else
if (key!=0x0d) && (key!=183) && (key!=184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else
if (key_ascii != 0x0d) && (key_ascii != 183) && (key_ascii != 184) {EAX = key_ascii << 8; edit_box_key stdcall(#address_box);}
}
else
{
Scan(key_scancode);
}
else Scan(key);
break;
case evReDraw:
@ -285,8 +291,7 @@ void SetElementSizes()
address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H;
address_box.width = Form.cwidth - address_box.left - 25 - 22;
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom,
Form.cheight - TOOLBAR_H - STATUSBAR_H, 11*WB1.DrawBuf.zoom);
WB1.list.SetFont(6, 9, 0x88);
Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom);
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
@ -314,8 +319,8 @@ void Draw_Window()
DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color);
DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color);
// < / >
DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, 300+BT_HIDE, 0);
DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, 301+BT_HIDE, 0);
DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, BUTTON_BACK+BT_HIDE, 0);
DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, FORWARD+BT_HIDE, 0);
img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0);
// refrash
DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0);
@ -334,16 +339,71 @@ void Draw_Window()
}
void Scan(int id)
void Scan(dword id__)
{
action_buf=0;
if (id >= 400)
if (id__ >= 400)
{
ProcessLinks(id);
ProcessLinks(id__);
return;
}
switch (id)
switch (id__)
{
case SCAN_CODE_BS:
case BUTTON_BACK:
if (!BrowserHistory.GoBack()) return;
OpenPage();
return;
case FORWARD:
if (!BrowserHistory.GoForward()) return;
OpenPage();
return;
case SCAN_CODE_HOME:
case SCAN_CODE_END:
case SCAN_CODE_PGUP:
case SCAN_CODE_PGDN:
if (WB1.list.ProcessKey(key_scancode)) WB1.Parse();
return;
case SCAN_CODE_UP:
if (WB1.list.first <= 0) return;
WB1.list.first--;
WB1.Parse();
return;
case SCAN_CODE_DOWN:
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
WB1.list.first++;
WB1.Parse();
return;
case 44: //Z-key down
if (WB1.DrawBuf.zoom==2)
{
WB1.DrawBuf.zoom=1;
WB1.list.SetFont(6, 9, 10001000b);
}
else
{
WB1.DrawBuf.zoom=2;
WB1.list.SetFont(6, 9, 10001001b);
}
Draw_Window();
return;
case GOTOURL:
case SCAN_CODE_ENTER: //enter
if (!editURL[0]) return;
if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7);
else
URL[0] = 0;
strcat(#URL, #editURL);
OpenPage();
return;
/*
case 011: //Ctrk+K
BufEncode(CH_KOI8);
WB1.Parse();
@ -375,15 +435,7 @@ void Scan(int id)
CreateThread(#Downloader,#downloader_stak+4092);
}
return;
case ASCII_KEY_BS:
case BACK:
if (!BrowserHistory.GoBack()) return;
OpenPage();
return;
case FORWARD:
if (!BrowserHistory.GoForward()) return;
OpenPage();
return;
case 052: //F3
WB1.list.first = 0;
ShowSource();
@ -407,73 +459,24 @@ void Scan(int id)
}
else OpenPage();
return;
case 014:
case 020:
case NEWTAB:
MoveSize(190,80,OLD,OLD);
RunProgram(#program_path, #URL);
return;
case GOTOURL:
case 0x0D: //enter
if (!editURL[0]) return;
if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7);
else
URL[0] = 0;
strcat(#URL, #editURL);
OpenPage();
return;
case SEARCHWEB:
sprintf(#URL,"%s%s",#search_path,#editURL);
OpenPage();
return;
case 183: //PgDown
if (WB1.list.count < WB1.list.visible) return;
IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
WB1.list.first += WB1.list.visible + 2;
IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
WB1.Parse();
return;
case 184: //PgUp
if (WB1.list.count < WB1.list.visible) return;
IF(WB1.list.first == 0) return;
WB1.list.first -= WB1.list.visible - 2;
IF(WB1.list.first < 0) WB1.list.first = 0;
WB1.Parse();
return;
case 178:
case BTN_UP:
if (WB1.list.first <= 0) return;
WB1.list.first--;
WB1.Parse();
return;
case 177:
case BTN_DOWN:
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
WB1.list.first++;
WB1.Parse();
return;
case 180: //home
if (WB1.list.KeyHome()) WB1.Parse();
return;
case 181: //end
if (WB1.list.count < WB1.list.visible) return;
if (WB1.list.KeyEnd()) WB1.Parse();
return;
case 312:
SwitchToAnotherThread();
mouse.y = TOOLBAR_H-6;
mouse.x = Form.cwidth - 167;
CreateThread(#menu_rmb,#stak+4092);
return;
case 122:
if (WB1.DrawBuf.zoom==1) WB1.DrawBuf.zoom=2; else WB1.DrawBuf.zoom=1;
Draw_Window();
*/
}
}