forked from KolibriOS/kolibrios
WebVIew 2.4: tabs
git-svn-id: svn://kolibrios.org@7771 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
3f59e384f1
commit
672bbcf6a0
@ -1,6 +1,6 @@
|
||||
#include "..\TWB\colors.h"
|
||||
#include "..\TWB\anchors.h"
|
||||
#include "..\TWB\parce_tag.h"
|
||||
#include "..\TWB\parse_tag.h"
|
||||
#include "..\TWB\special.h"
|
||||
#include "..\TWB\img_cache.h"
|
||||
#include "..\TWB\tag_list.h"
|
||||
@ -12,6 +12,9 @@ dword link_color_active;
|
||||
#define BODY_MARGIN 6
|
||||
#define BASIC_LINE_H 18
|
||||
|
||||
DrawBufer DrawBuf;
|
||||
char line[500];
|
||||
|
||||
struct _style {
|
||||
bool
|
||||
b, u, s, h,
|
||||
@ -27,7 +30,6 @@ struct _style {
|
||||
struct TWebBrowser {
|
||||
llist list;
|
||||
_style style;
|
||||
DrawBufer DrawBuf;
|
||||
dword draw_y, stolbec;
|
||||
int zoom;
|
||||
dword o_bufpointer;
|
||||
@ -36,7 +38,7 @@ struct TWebBrowser {
|
||||
dword bufpointer;
|
||||
dword bufsize;
|
||||
|
||||
void DrawStyle();
|
||||
void Paint();
|
||||
void SetPageDefaults();
|
||||
void AddCharToTheLine();
|
||||
void ParseHtml();
|
||||
@ -46,14 +48,13 @@ struct TWebBrowser {
|
||||
void DrawScroller();
|
||||
void ChangeEncoding();
|
||||
void DrawPage();
|
||||
char line[500];
|
||||
char header[150];
|
||||
};
|
||||
|
||||
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
|
||||
|
||||
//============================================================================================
|
||||
void TWebBrowser::DrawStyle()
|
||||
void TWebBrowser::Paint()
|
||||
{
|
||||
dword start_x, line_length, stolbec_len;
|
||||
dword text_color__;
|
||||
@ -96,7 +97,6 @@ void TWebBrowser::DrawStyle()
|
||||
text_color__ = text_colors[text_color_index];
|
||||
if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default;
|
||||
|
||||
|
||||
DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line);
|
||||
if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line);
|
||||
if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__);
|
||||
@ -151,7 +151,7 @@ void TWebBrowser::AddCharToTheLine(unsigned char _char)
|
||||
if (line[line_len-1]==' ') return; //no double spaces
|
||||
if (!stolbec) && (!line) return; //no paces at the beginning of the line
|
||||
}
|
||||
if (line_len < sizeof(TWebBrowser.line)) chrcat(#line, _char);
|
||||
if (line_len < sizeof(line)) chrcat(#line, _char);
|
||||
CheckForLineBreak();
|
||||
}
|
||||
//============================================================================================
|
||||
@ -164,8 +164,12 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
||||
int tab_len;
|
||||
dword bufpos;
|
||||
bufsize = _bufsize;
|
||||
bufpointer = malloc(bufsize);
|
||||
memmov(bufpointer, _bufpointer, bufsize);
|
||||
if (bufpointer != _bufpointer) {
|
||||
bufpointer = malloc(bufsize);
|
||||
memmov(bufpointer, _bufpointer, bufsize);
|
||||
} else {
|
||||
custom_encoding = CH_CP866;
|
||||
}
|
||||
SetPageDefaults();
|
||||
if (strstri(bufpointer, "<body")==-1) {
|
||||
t_body = true;
|
||||
@ -178,7 +182,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
||||
{
|
||||
case 0x0a:
|
||||
if (style.pre) {
|
||||
DrawStyle();
|
||||
Paint();
|
||||
NewLine();
|
||||
} else {
|
||||
AddCharToTheLine(0x0a);
|
||||
@ -199,7 +203,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
||||
bukva = ESBYTE[bufpos+j];
|
||||
chrcat(#unicode_symbol, bukva);
|
||||
}
|
||||
if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(TWebBrowser.line)-1)) {
|
||||
if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) {
|
||||
bufpos += j;
|
||||
CheckForLineBreak();
|
||||
} else {
|
||||
@ -256,7 +260,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
||||
|
||||
if (tag.name) {
|
||||
CheckForLineBreak();
|
||||
DrawStyle();
|
||||
Paint();
|
||||
if (tag.name) SetStyle();
|
||||
}
|
||||
break;
|
||||
@ -264,7 +268,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
||||
AddCharToTheLine(ESBYTE[bufpos]);
|
||||
}
|
||||
}
|
||||
DrawStyle();
|
||||
Paint();
|
||||
NewLine();
|
||||
list.count = draw_y;
|
||||
list.CheckDoesValuesOkey();
|
||||
@ -296,7 +300,7 @@ bool TWebBrowser::CheckForLineBreak()
|
||||
strcpy(#new_line_text, #line + line_break_pos);
|
||||
line[line_break_pos] = 0x00;
|
||||
|
||||
DrawStyle();
|
||||
Paint();
|
||||
|
||||
strcpy(#line, #new_line_text);
|
||||
NewLine();
|
||||
@ -359,12 +363,12 @@ void TWebBrowser::SetStyle() {
|
||||
if (tag.is("iframe")) && (value = tag.get_value_of("src=")) {
|
||||
NewLine();
|
||||
strcpy(#line, "IFRAME: ");
|
||||
DrawStyle();
|
||||
Paint();
|
||||
link=true;
|
||||
PageLinks.AddLink(value);
|
||||
strncpy(#line, value, sizeof(TWebBrowser.line)-1);
|
||||
strncpy(#line, value, sizeof(line)-1);
|
||||
while (CheckForLineBreak()) {};
|
||||
DrawStyle();
|
||||
Paint();
|
||||
link=false;
|
||||
NewLine();
|
||||
}
|
||||
@ -416,8 +420,8 @@ void TWebBrowser::SetStyle() {
|
||||
}
|
||||
if (tag.is("img")) {
|
||||
if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1);
|
||||
if (value = tag.get_value_of("title=")) && (strlen(value)<sizeof(TWebBrowser.line)-3) && (value) sprintf(#line, "[%s]", value);
|
||||
if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(TWebBrowser.line)-3) && (value) sprintf(#line, "[%s]", value);
|
||||
if (value = tag.get_value_of("title=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value);
|
||||
if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value);
|
||||
if (!img_path) { line=0; return; }
|
||||
style.image = true;
|
||||
text_color_index++;
|
||||
@ -429,7 +433,7 @@ void TWebBrowser::SetStyle() {
|
||||
line[50]= NULL;
|
||||
}
|
||||
while (CheckForLineBreak()) {};
|
||||
DrawStyle();
|
||||
Paint();
|
||||
text_color_index--;
|
||||
style.image = false;
|
||||
//ImgCache.Images( list.x, draw_y, list.w);
|
||||
|
@ -7,6 +7,9 @@ dword CursorFile = FROM "../TWB/pointer.cur";
|
||||
|
||||
#define MAXLINKS 2000
|
||||
|
||||
bool open_new_window=false;
|
||||
bool open_new_tab=false;
|
||||
|
||||
struct array_link {
|
||||
dword link;
|
||||
unsigned int x,y,w,h;
|
||||
@ -54,7 +57,6 @@ dword LinksArray::GetURL(int id)
|
||||
return links[id].link;
|
||||
}
|
||||
|
||||
bool open_new_window=false;
|
||||
void LinksArray::Clear()
|
||||
{
|
||||
page_links.drop();
|
||||
@ -95,9 +97,15 @@ bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
|
||||
return false;
|
||||
}
|
||||
if (mouse.mkm) && (mouse.up) {
|
||||
open_new_window = true;
|
||||
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
||||
open_new_window = false;
|
||||
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
||||
open_new_window = true;
|
||||
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
||||
open_new_window = false;
|
||||
} else {
|
||||
open_new_tab = true;
|
||||
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
||||
open_new_tab = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (mouse.lkm) && (mouse.up) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
#endif
|
||||
|
||||
//libraries
|
||||
#define MEMSIZE 1024 * 850
|
||||
#define MEMSIZE 1024 * 1000
|
||||
#include "..\lib\gui.h"
|
||||
#include "..\lib\draw_buf.h"
|
||||
#include "..\lib\list_box.h"
|
||||
@ -29,24 +29,28 @@
|
||||
#include "..\lib\patterns\simple_open_dialog.h"
|
||||
#include "..\lib\patterns\toolbar_button.h"
|
||||
|
||||
#include "show_src.h"
|
||||
#include "download_manager.h"
|
||||
_history history;
|
||||
#include "history.h"
|
||||
bool debug_mode = false;
|
||||
#include "..\TWB\TWB.c" //HTML Parser, a core component
|
||||
#include "texts.h"
|
||||
#include "cache.h"
|
||||
#include "show_src.h"
|
||||
#include "download_manager.h"
|
||||
|
||||
bool debug_mode = false;
|
||||
|
||||
#include "..\TWB\TWB.c" //HTML Parser, a core component
|
||||
|
||||
TWebBrowser WB1;
|
||||
_history history;
|
||||
|
||||
#define URL_SIZE 4000
|
||||
#include "history.h"
|
||||
|
||||
#define PADDING 9
|
||||
#define SKIN_Y 24
|
||||
#define TSZE 25
|
||||
#define STATUSBAR_H 15
|
||||
#define TAB_H 20
|
||||
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
|
||||
dword STATUSBAR_H = 15;
|
||||
|
||||
#define URL_SIZE 4000
|
||||
|
||||
int action_buf;
|
||||
|
||||
@ -59,8 +63,9 @@ char stak[4096];
|
||||
proc_info Form;
|
||||
|
||||
enum {
|
||||
ENCODINGS=900,
|
||||
BACK_BUTTON=1000,
|
||||
NEW_TAB=600,
|
||||
ENCODINGS=700,
|
||||
BACK_BUTTON=800,
|
||||
FORWARD_BUTTON,
|
||||
REFRESH_BUTTON,
|
||||
GOTOURL_BUTTON,
|
||||
@ -76,8 +81,12 @@ enum {
|
||||
UPDATE_BROWSER,
|
||||
COPY_LINK_URL,
|
||||
DOWNLOAD_LINK_CONTENTS,
|
||||
TAB_ID,
|
||||
TAB_CLOSE_ID = 900
|
||||
};
|
||||
|
||||
#include "tabs.h"
|
||||
|
||||
char default_dir[] = "/rd/1";
|
||||
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
|
||||
|
||||
@ -165,18 +174,26 @@ void main()
|
||||
|
||||
case evKey:
|
||||
GetKeys();
|
||||
//if (key_scancode == SCAN_CODE_F1) {DebugTabs();break;}
|
||||
|
||||
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
||||
if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();break;}
|
||||
}
|
||||
|
||||
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
|
||||
if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;}
|
||||
if (key_scancode == SCAN_CODE_KEY_H) {ProcessEvent(VIEW_HISTORY);break;}
|
||||
if (key_scancode == SCAN_CODE_KEY_U) {EventViewSource();break;}
|
||||
if (key_scancode == SCAN_CODE_KEY_T)
|
||||
|| (key_scancode == SCAN_CODE_KEY_N) {RunProgram(#program_path, NULL);break;}
|
||||
if (key_scancode == SCAN_CODE_KEY_J) {ProcessEvent(DOWNLOAD_MANAGER);break;}
|
||||
if (key_scancode == SCAN_CODE_KEY_R) {ProcessEvent(REFRESH_BUTTON);break;}
|
||||
if (key_scancode == SCAN_CODE_ENTER) {EventSeachWeb();break;}
|
||||
if (key_scancode == SCAN_CODE_LEFT) {ProcessEvent(BACK_BUTTON);break;}
|
||||
if (key_scancode == SCAN_CODE_RIGHT) {ProcessEvent(FORWARD_BUTTON);break;}
|
||||
if (key_scancode == SCAN_CODE_KEY_W) {ExitProcess();break;}
|
||||
if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog();
|
||||
else if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY);
|
||||
else if (key_scancode == SCAN_CODE_KEY_U) EventViewSource();
|
||||
else if (key_scancode == SCAN_CODE_KEY_T) EventOpenNewTab(URL_SERVICE_HOMEPAGE);
|
||||
else if (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
|
||||
else if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER);
|
||||
else if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON);
|
||||
else if (key_scancode == SCAN_CODE_ENTER) EventSeachWeb();
|
||||
else if (key_scancode == SCAN_CODE_LEFT) ProcessEvent(BACK_BUTTON);
|
||||
else if (key_scancode == SCAN_CODE_RIGHT) ProcessEvent(FORWARD_BUTTON);
|
||||
else if (key_scancode == SCAN_CODE_KEY_W) EventCloseActiveTab();
|
||||
else if (key_scancode == SCAN_CODE_TAB) EventActivateNextTab();
|
||||
break;
|
||||
}
|
||||
|
||||
if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
|
||||
@ -185,14 +202,11 @@ void main()
|
||||
{
|
||||
if (key_scancode == SCAN_CODE_ENTER) {
|
||||
ProcessEvent(key_scancode);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
EAX = key_editbox;
|
||||
edit_box_key stdcall(#address_box);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#define KEY_SCROLL_N 11
|
||||
if (SCAN_CODE_UP == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyUp();
|
||||
if (SCAN_CODE_DOWN == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyDown();
|
||||
@ -203,7 +217,7 @@ void main()
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),
|
||||
DefineAndDrawWindow(40, //GetScreenWidth()-800/2-random(80),
|
||||
GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
system.color.get();
|
||||
@ -245,8 +259,8 @@ void main()
|
||||
void SetElementSizes()
|
||||
{
|
||||
address_box.width = Form.cwidth - address_box.left - 52 - 16;
|
||||
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x,
|
||||
Form.cheight - TOOLBAR_H - STATUSBAR_H, BASIC_LINE_H);
|
||||
WB1.list.SetSizes(0, TOOLBAR_H+TAB_H, Form.width - 10 - scroll_wv.size_x,
|
||||
Form.cheight - TOOLBAR_H - STATUSBAR_H - TAB_H, BASIC_LINE_H);
|
||||
WB1.list.wheel_size = 7 * BASIC_LINE_H;
|
||||
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
|
||||
WB1.list.visible = WB1.list.h;
|
||||
@ -265,7 +279,7 @@ void draw_window()
|
||||
|
||||
DrawBar(0,0, Form.cwidth,PADDING, system.color.work);
|
||||
DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, system.color.work);
|
||||
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, system.color.work_dark);
|
||||
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(system.color.work_dark, system.color.work, 180));
|
||||
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, system.color.work_graph);
|
||||
DrawBar(0, PADDING, address_box.left-2, TSZE+1, system.color.work);
|
||||
DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, system.color.work);
|
||||
@ -280,23 +294,33 @@ void draw_window()
|
||||
DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x,
|
||||
WB1.list.h-1, scroll_wv.bckg_col);
|
||||
|
||||
if (WB1.list.w!=WB1.DrawBuf.bufw) {
|
||||
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
|
||||
if (!strncmp(history.current(),"http",4)) {
|
||||
//nihuya ne izyashnoe reshenie, no pust' poka butet tak
|
||||
i=source_mode;
|
||||
LoadInternalPage(#loading_text, sizeof(loading_text));
|
||||
source_mode=i;
|
||||
}
|
||||
OpenPage(history.current());
|
||||
} else {
|
||||
if (!BrowserWidthChanged()) {
|
||||
WB1.DrawPage();
|
||||
DrawOmnibox();
|
||||
}
|
||||
DrawProgress();
|
||||
DrawStatusBar(NULL);
|
||||
DrawTabsBar();
|
||||
}
|
||||
|
||||
bool BrowserWidthChanged()
|
||||
{
|
||||
dword source_mode_holder;
|
||||
if (WB1.list.w!=DrawBuf.bufw) {
|
||||
DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
|
||||
if (!strncmp(history.current(),"http",4)) {
|
||||
//nihuya ne izyashnoe reshenie, no pust' poka butet tak
|
||||
source_mode_holder = source_mode;
|
||||
LoadInternalPage(#loading_text, sizeof(loading_text));
|
||||
source_mode = source_mode_holder;
|
||||
}
|
||||
OpenPage(history.current());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void EventChangeEncodingAndLoadPage(int _new_encoding)
|
||||
{
|
||||
dword newbuf, newsize;
|
||||
@ -335,7 +359,7 @@ void ProcessEvent(dword id__)
|
||||
EventSubmitOmnibox();
|
||||
return;
|
||||
case REFRESH_BUTTON:
|
||||
if (http.transfer > 0) {
|
||||
if (http.transfer) {
|
||||
StopLoading();
|
||||
draw_window();
|
||||
} else {
|
||||
@ -393,6 +417,21 @@ void ProcessEvent(dword id__)
|
||||
if (debug_mode) notify("'Debug mode ON'-I");
|
||||
else notify("'Debug mode OFF'-I");
|
||||
return;
|
||||
case NEW_TAB:
|
||||
if (http.transfer) break;
|
||||
EventOpenNewTab(URL_SERVICE_HOMEPAGE);
|
||||
return;
|
||||
case TAB_ID...TAB_ID+TABS_MAX:
|
||||
if (http.transfer) break;
|
||||
if (mouse.mkm) {
|
||||
EventTabClose(id__ - TAB_ID);
|
||||
} else {
|
||||
EventTabClick(id__ - TAB_ID);
|
||||
}
|
||||
return;
|
||||
case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX:
|
||||
EventTabClose(id__ - TAB_CLOSE_ID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -456,9 +495,13 @@ void OpenPage(dword _open_URL)
|
||||
|
||||
StopLoading();
|
||||
|
||||
strcpy(#editURL, _open_URL);
|
||||
address_box.flags=0;
|
||||
DrawOmnibox();
|
||||
if (open_new_tab) {
|
||||
open_new_tab = false;
|
||||
EventOpenNewTab(_open_URL);
|
||||
return;
|
||||
}
|
||||
|
||||
SetOmniboxText(_open_URL);
|
||||
|
||||
strncpy(#new_url, _open_URL, URL_SIZE);
|
||||
|
||||
@ -535,7 +578,7 @@ void EventClickLink(dword _click_URL)
|
||||
return;
|
||||
}
|
||||
|
||||
if (http.transfer > 0) {
|
||||
if (http.transfer) {
|
||||
StopLoading();
|
||||
history.back();
|
||||
}
|
||||
@ -607,6 +650,7 @@ void LoadInternalPage(dword _bufdata, _in_bufsize){
|
||||
}
|
||||
WB1.ParseHtml(_bufdata, _in_bufsize);
|
||||
DrawStatusBar(NULL);
|
||||
DrawActiveTab();
|
||||
if (source_mode) {
|
||||
source_mode = false;
|
||||
ShowSource(WB1.bufpointer, _in_bufsize);
|
||||
@ -689,9 +733,11 @@ void EventOpenDialog()
|
||||
void EventViewSource()
|
||||
{
|
||||
char source_view_param[URL_SIZE+1];
|
||||
strcpy(#source_view_param, "-source ");
|
||||
strncat(#source_view_param, history.current(), URL_SIZE);
|
||||
RunProgram(#program_path, #source_view_param);
|
||||
//strcpy(#source_view_param, "-source ");
|
||||
//strncat(#source_view_param, history.current(), URL_SIZE);
|
||||
//RunProgram(#program_path, #source_view_param);
|
||||
source_mode = true;
|
||||
EventOpenNewTab(history.current());
|
||||
}
|
||||
|
||||
dword GetFileSize(dword _path)
|
||||
@ -781,5 +827,12 @@ void DrawOmnibox()
|
||||
DrawProgress();
|
||||
}
|
||||
|
||||
void SetOmniboxText(dword _text)
|
||||
{
|
||||
strcpy(#editURL, _text);
|
||||
address_box.flags=0;
|
||||
DrawOmnibox();
|
||||
}
|
||||
|
||||
|
||||
stop:
|
209
programs/cmm/browser/tabs.h
Normal file
209
programs/cmm/browser/tabs.h
Normal file
@ -0,0 +1,209 @@
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// MODULE //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
#define TABS_MAX 5
|
||||
|
||||
TWebBrowser data[TABS_MAX+1];
|
||||
_history tabstory[TABS_MAX+1];
|
||||
|
||||
struct TAB
|
||||
{
|
||||
int count;
|
||||
signed int active;
|
||||
bool add();
|
||||
bool close();
|
||||
void save_state();
|
||||
void restore();
|
||||
} tab = {1,0};
|
||||
|
||||
|
||||
bool TAB::add()
|
||||
{
|
||||
if (count==TABS_MAX) return false;
|
||||
save_state();
|
||||
count++;
|
||||
active = count-1;
|
||||
history = tabstory[active];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TAB::close(int _tab_number)
|
||||
{
|
||||
int i;
|
||||
if (count==1) return false;
|
||||
for (i=_tab_number; i<=TABS_MAX; i++) {
|
||||
data[i] = data[i+1];
|
||||
tabstory[i] = tabstory[i+1];
|
||||
}
|
||||
if (_tab_number<active) && (active>0) active--;
|
||||
if (active==count-1) && (active>0) active--;
|
||||
count--;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TAB::save_state()
|
||||
{
|
||||
tabstory[active] = history;
|
||||
data[active] = WB1;
|
||||
}
|
||||
|
||||
void TAB::restore(int _id)
|
||||
{
|
||||
tab.active = _id;
|
||||
WB1 = data[_id];
|
||||
history = tabstory[_id];
|
||||
}
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// WebView Actions //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
#define DEFAULT_TABW 220
|
||||
int tab_w = DEFAULT_TABW;
|
||||
|
||||
int GetTabWidth()
|
||||
{
|
||||
if (tab.count * DEFAULT_TABW + TAB_H < Form.cwidth) return DEFAULT_TABW; else
|
||||
return Form.cwidth - TAB_H - 2 / tab.count;
|
||||
}
|
||||
|
||||
void DrawTab(int _id)
|
||||
{
|
||||
#define CLOSE_S 13
|
||||
dword bgcol, border_bottom_color;
|
||||
char header_no_version[sizeof(TWebBrowser.header)];
|
||||
char name[DEFAULT_TABW/6];
|
||||
int xxx = _id * tab_w;
|
||||
|
||||
if (_id==tab.active) {
|
||||
tab.save_state();
|
||||
bgcol = system.color.work_light;
|
||||
border_bottom_color = system.color.work_light;
|
||||
} else {
|
||||
bgcol=system.color.work;
|
||||
border_bottom_color = system.color.work_graph;
|
||||
}
|
||||
if (data[_id].header) {
|
||||
strncpy(#header_no_version, #data[_id].header, strlen(#data[_id].header)-sizeof(version)-2);
|
||||
strncpy(#name, #header_no_version, tab_w-CLOSE_S/6-2);
|
||||
}
|
||||
DrawBar(xxx, TOOLBAR_H, 1, TAB_H, system.color.work_dark);
|
||||
DrawBar(xxx+1, TOOLBAR_H, tab_w-1, TAB_H-1, bgcol);
|
||||
DrawBar(xxx+1, TOOLBAR_H+TAB_H-1, tab_w-1, 1, border_bottom_color);
|
||||
DefineHiddenButton(xxx, TOOLBAR_H-1, tab_w, TAB_H, TAB_ID+_id);
|
||||
WriteTextCenter(xxx, TOOLBAR_H+6, tab_w-CLOSE_S, system.color.work_text, #name);
|
||||
|
||||
DefineHiddenButton(xxx+tab_w-CLOSE_S-3, TOOLBAR_H+3, CLOSE_S-1, CLOSE_S-1, TAB_CLOSE_ID+_id);
|
||||
DrawBar(xxx+tab_w-CLOSE_S-3, TOOLBAR_H+3, CLOSE_S, CLOSE_S, system.color.work_dark);
|
||||
WriteText(xxx+tab_w-CLOSE_S+1, TOOLBAR_H+5, 0x80, system.color.work_light, "x");
|
||||
}
|
||||
|
||||
void DrawActiveTab()
|
||||
{
|
||||
if (tab_w == GetTabWidth()) DrawTab(tab.active);
|
||||
else DrawTabsBar();
|
||||
}
|
||||
|
||||
void DrawNewTabButton()
|
||||
{
|
||||
dword btn_light = MixColors(system.color.work_button, 0xFFFfff, 220);
|
||||
dword btn_dark = MixColors(system.color.work_button, 0, 180);
|
||||
int xxx = tab.count * tab_w;
|
||||
DrawBar(xxx, TOOLBAR_H, 1, TAB_H, system.color.work_graph);
|
||||
DrawBar(xxx+1, TOOLBAR_H, TAB_H, TAB_H-1, system.color.work_button);
|
||||
DrawRectangle3D(xxx+1, TOOLBAR_H, TAB_H, TAB_H-1, btn_light, btn_dark);
|
||||
PutPixel(xxx+1+TAB_H, TOOLBAR_H, btn_dark);
|
||||
DefineHiddenButton(xxx+1, TOOLBAR_H, TAB_H-1, TAB_H-1, NEW_TAB);
|
||||
WriteText(xxx+7, TOOLBAR_H+2, 0x90, system.color.work_button_text, "+");
|
||||
}
|
||||
|
||||
void DrawTabsBar()
|
||||
{
|
||||
dword i;
|
||||
tab_w = GetTabWidth();
|
||||
for (i=0; i<tab.count; i++) DrawTab(i);
|
||||
DrawNewTabButton();
|
||||
i = tab_w * i + TAB_H + 2;
|
||||
DrawBar(i, TOOLBAR_H, Form.cwidth-i, TAB_H-1, MixColors(system.color.work_dark, system.color.work, 128));
|
||||
DrawBar(i, TOOLBAR_H+TAB_H-1, Form.cwidth-i, 1, system.color.work_graph);
|
||||
}
|
||||
|
||||
void EventTabClose(int _id)
|
||||
{
|
||||
DeleteButton(tab.count);
|
||||
if (_id == tab.active) {
|
||||
tab.close(_id);
|
||||
tab.restore(tab.active);
|
||||
WB1.ParseHtml(WB1.bufpointer, WB1.bufsize);
|
||||
WB1.DrawPage();
|
||||
SetOmniboxText(history.current());
|
||||
} else {
|
||||
tab.close(_id);
|
||||
}
|
||||
DrawTabsBar();
|
||||
}
|
||||
|
||||
void EventCloseActiveTab()
|
||||
{
|
||||
EventTabClose(tab.active);
|
||||
}
|
||||
|
||||
void EventTabClick(int _id)
|
||||
{
|
||||
if (_id>=tab.count) _id = 0;
|
||||
if (_id==-1) _id = tab.count-1;
|
||||
tab.save_state();
|
||||
tab.restore(_id);
|
||||
SetElementSizes();
|
||||
if (!BrowserWidthChanged()) {
|
||||
DrawTabsBar();
|
||||
WB1.ParseHtml(WB1.bufpointer, WB1.bufsize);
|
||||
WB1.DrawPage();
|
||||
}
|
||||
SetOmniboxText(history.current());
|
||||
}
|
||||
|
||||
void EventOpenNewTab(dword _url)
|
||||
{
|
||||
tab.add();
|
||||
OpenPage(_url);
|
||||
DrawTabsBar();
|
||||
}
|
||||
|
||||
void EventActivateNextTab()
|
||||
{
|
||||
EventTabClick(tab.active+1);
|
||||
}
|
||||
|
||||
void EventActivatePreviousTab()
|
||||
{
|
||||
EventTabClick(tab.active-1);
|
||||
}
|
||||
|
||||
|
||||
:void DebugTabs()
|
||||
{
|
||||
debugln("\n\n\nHISTORY==========================");
|
||||
history.add("history");
|
||||
history.debug();
|
||||
|
||||
debugln("\n\n\nTABSTORY[0]======================");
|
||||
tabstory[0].add("tabstory0");
|
||||
tabstory[0].debug();
|
||||
|
||||
debugln("\n\n\nTABSTORY[1]======================");
|
||||
tabstory[1].add("tabstory1");
|
||||
tabstory[1].debug();
|
||||
|
||||
debugln("\n\n\n\n");
|
||||
debugval("history.items.data_start", history.items.data_start);
|
||||
debugval("tabstory[0].items.data_start", tabstory[0].items.data_start);
|
||||
debugval("tabstory[1].items.data_start", tabstory[1].items.data_start);
|
||||
debugln("\n\n\n\n");
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
char version[]="WebView 2.26";
|
||||
char version[]="WebView 2.4";
|
||||
|
||||
#ifdef LANG_RUS
|
||||
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
|
||||
|
@ -158,8 +158,8 @@ void SetElementSizes()
|
||||
WB1.list.wheel_size = 7 * BASIC_LINE_H;
|
||||
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
|
||||
WB1.list.visible = WB1.list.h;
|
||||
if (WB1.list.w!=WB1.DrawBuf.bufw) {
|
||||
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700);
|
||||
if (WB1.list.w!=DrawBuf.bufw) {
|
||||
DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700);
|
||||
OpenPage(#current_path);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
?define T_TAKE_SCREENSHOT " ‘¤¥« âì áªà¨è®â"
|
||||
?define T_SETTINGS "<EFBFBD> áâனª¨"
|
||||
?define T_EDITBOX_FRAME " <20>ãâì á®åà ¥¨ï áªà¨è®â "
|
||||
?define T_MINIMIZE "‘¢¥àãâì ®ª® ¯à¨ ᨬª¥"
|
||||
?define T_CONTINUOUS_SHOOTING "Continuous shooting"
|
||||
?define T_DELAY "‡ ¤¥à¦ª ¢ ᥪ㤠å"
|
||||
?define T_NO_DIR "'<27> ¯ª ¥ áãé¥áâ¢ã¥â!' -E"
|
||||
@ -29,7 +28,6 @@
|
||||
?define T_TAKE_SCREENSHOT " Take a screenshot"
|
||||
?define T_SETTINGS "Settings"
|
||||
?define T_EDITBOX_FRAME " Save path "
|
||||
?define T_MINIMIZE "Minimize window"
|
||||
?define T_CONTINUOUS_SHOOTING "Continuous shooting"
|
||||
?define T_DELAY "Delay in seconds"
|
||||
?define T_NO_DIR "'Directory does not exists!' -E"
|
||||
@ -59,7 +57,6 @@ edit_box edit_save = {250,25,100,0xffffff,0x94AECE,0xFFFfff,0xffffff,
|
||||
0x10000000,sizeof(save_path)-2,#save_path,0, 0b};
|
||||
|
||||
more_less_box delay = { 1, 0, 64, T_DELAY };
|
||||
checkbox minimize = { T_MINIMIZE, true };
|
||||
checkbox continuous_shooting = { T_CONTINUOUS_SHOOTING, true };
|
||||
|
||||
|
||||
@ -136,11 +133,10 @@ void DrawMainContent()
|
||||
}
|
||||
|
||||
void EventTakeScreenshot() {
|
||||
if (minimize.checked) MinimizeWindow();
|
||||
MinimizeWindow();
|
||||
pause(delay.value*100);
|
||||
CopyScreen(screenshot, 0, 0, screen.width, screen.height);
|
||||
ActivateWindow(GetProcessSlot(Form.ID));
|
||||
if (!minimize.checked) DrawMainContent();
|
||||
EventSaveImageFile();
|
||||
}
|
||||
|
||||
@ -150,7 +146,11 @@ void EventSaveImageFile()
|
||||
char save_file_name[4096];
|
||||
do {
|
||||
i++;
|
||||
sprintf(#save_file_name, "%s/screen_%i.png", #save_path_stable, i);
|
||||
//sprintf(, "%s/screen_%i.png", #save_path_stable, i);
|
||||
strcpy(#save_file_name, #save_path_stable);
|
||||
strcat(#save_file_name, "/screen_");
|
||||
strcat(#save_file_name, itoa(i));
|
||||
strcat(#save_file_name, ".png");
|
||||
} while (file_exists(#save_file_name));
|
||||
save_image(screenshot, screen.width, screen.height, #save_file_name);
|
||||
}
|
||||
@ -171,7 +171,7 @@ void SettingsWindow()
|
||||
case evKey:
|
||||
GetKeys();
|
||||
if (SCAN_CODE_ESC == key_scancode) ExitProcess();
|
||||
EAX= key_ascii << 8;
|
||||
EAX = key_editbox;
|
||||
edit_box_key stdcall (#edit_save);
|
||||
break;
|
||||
|
||||
@ -197,7 +197,6 @@ void SettingsWindow()
|
||||
|
||||
}
|
||||
delay.click(id);
|
||||
minimize.click(id);
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
@ -209,8 +208,7 @@ void DrawSettingsWindow()
|
||||
{
|
||||
DefineAndDrawWindow(Form.left+100, Form.top-40, 400, 230, 0x34, system.color.work, T_SETTINGS, 0);
|
||||
GetProcessInfo(#Settings, SelfInfo);
|
||||
minimize.draw(15, 15);
|
||||
delay.draw(15, 45);
|
||||
delay.draw(15, 30);
|
||||
DrawFrame(15, 85, 360, 95, T_EDITBOX_FRAME);
|
||||
DrawEditBoxPos(32, 110, #edit_save);
|
||||
DrawStandartCaptButton(edit_save.left + edit_save.width + 15, edit_save.top-3, BTN_OD, "...");
|
||||
|
@ -67,7 +67,10 @@ struct collection
|
||||
|
||||
:void collection::drop() {
|
||||
if (data_start) free(data_start);
|
||||
data_size = data_start = element_offset[count] = count = 0;
|
||||
data_size = 0;
|
||||
data_start = 0;
|
||||
element_offset[count] = 0;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,4 +51,12 @@ inline fastcall void debugln( EDX)
|
||||
debugln(#tmpch);
|
||||
}
|
||||
|
||||
:void debug_n(dword _text, _size)
|
||||
{
|
||||
dword res_text = malloc(_size);
|
||||
strncpy(res_text, _text, _size-1);
|
||||
debugln(res_text);
|
||||
free(res_text);
|
||||
}
|
||||
|
||||
#endif
|
@ -128,12 +128,26 @@ GETKEYII:
|
||||
key_ascii = AH;
|
||||
$shr eax,16
|
||||
key_scancode = AL;
|
||||
//get alt/shift/ctrl key status
|
||||
key_modifier = GetKeyModifier();
|
||||
EAX = key_editbox;
|
||||
}
|
||||
|
||||
// ECX is a mode: 1 - scancodes, 0 - ascii
|
||||
inline fastcall SetKeyboardMode(ECX)
|
||||
{
|
||||
$mov eax,66
|
||||
$mov ebx,1
|
||||
//$mov ecx,?
|
||||
$int 0x40
|
||||
}
|
||||
|
||||
//get alt/shift/ctrl key status
|
||||
inline fastcall dword GetKeyModifier()
|
||||
{
|
||||
$mov eax,66
|
||||
$mov ebx,3
|
||||
$int 0x40
|
||||
key_modifier = EAX;
|
||||
EAX = key_editbox;
|
||||
}
|
||||
|
||||
#endif
|
@ -3,6 +3,7 @@
|
||||
struct _history {
|
||||
collection items;
|
||||
int active;
|
||||
void clear();
|
||||
int add();
|
||||
int back();
|
||||
int forward();
|
||||
@ -35,4 +36,10 @@ int _history::forward()
|
||||
dword _history::current()
|
||||
{
|
||||
return items.get(active-1);
|
||||
}
|
||||
}
|
||||
|
||||
:void _history::clear()
|
||||
{
|
||||
items.drop();
|
||||
active=0;
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ void InitTWB() {
|
||||
Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 12);
|
||||
WB1.list.column_max = WB1.list.w - 30 / 6;
|
||||
WB1.list.visible = WB1.list.h / WB1.list.item_h;
|
||||
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h);
|
||||
DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h);
|
||||
WB1.list.first = WB1.list.count = 0;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#define MEMSIZE 1024*40
|
||||
#define MEMSIZE 1024*20
|
||||
|
||||
#include "../lib/gui.h"
|
||||
#include "../lib/clipboard.h"
|
||||
@ -10,7 +10,6 @@
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
proc_info Form;
|
||||
dword pick_active = true;
|
||||
dword picked_color = 0;
|
||||
char picked_color_string[11];
|
||||
@ -32,19 +31,16 @@ char picked_color_string[11];
|
||||
void main()
|
||||
{
|
||||
int btn;
|
||||
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
||||
proc_info Form;
|
||||
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE);
|
||||
SetWindowLayerBehaviour(-1, ZPOS_ALWAYS_TOP);
|
||||
loop() switch(WaitEvent())
|
||||
{
|
||||
case evMouse:
|
||||
mouse.get();
|
||||
|
||||
if (mouse.x>0) && (mouse.x<FORM_W) && (mouse.y>0) && (mouse.y<FORM_H)
|
||||
{
|
||||
mouse.get();
|
||||
if (mouse.x>0) && (mouse.x<FORM_W) && (mouse.y>0) && (mouse.y<FORM_H) {
|
||||
EventDragWindow();
|
||||
}
|
||||
else if (pick_active)
|
||||
{
|
||||
} else if (pick_active) {
|
||||
picked_color = GetPixelColorFromScreen(mouse.x + Form.left, mouse.y + Form.top);
|
||||
EventUpdateWindowContent();
|
||||
if (mouse.down) && (mouse.key&MOUSE_LEFT) pick_active = false;
|
||||
@ -61,11 +57,12 @@ void main()
|
||||
case evKey:
|
||||
GetKeys();
|
||||
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
|
||||
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
|
||||
if (key_scancode==SCAN_CODE_KEY_C) EventCopyHex();
|
||||
if (key_scancode == SCAN_CODE_KEY_C) EventCopyHex();
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
DefineUnDragableWindow(215, 100, FORM_W, FORM_H);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
draw_window();
|
||||
break;
|
||||
}
|
||||
@ -73,18 +70,14 @@ void main()
|
||||
|
||||
void draw_window()
|
||||
{
|
||||
DefineDragableWindow(215, 100, FORM_W, FORM_H);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
DrawRectangle3D(0, 0, FORM_W, FORM_H, 0xCCCccc, 0x888888);
|
||||
DrawRectangle3D(1, 1, FORM_W-2, FORM_H-2, 0xCCCccc, 0x888888);
|
||||
DrawBar(2,2,FORM_W-3,FORM_H-3,0xFFFfff);
|
||||
|
||||
DrawRectangle(COLOR_BLOCK_X-2, COLOR_BLOCK_PADDING-2, COLOR_BLOCK_SIZE+3, COLOR_BLOCK_SIZE+3, 0xCBC6C5);
|
||||
|
||||
DefineHiddenButton(0, 0, COLOR_BLOCK_X, skin_height, 476+BT_NOFRAME);
|
||||
DefineHiddenButton(COLOR_BLOCK_X-1, COLOR_BLOCK_PADDING-1, COLOR_BLOCK_SIZE+1, COLOR_BLOCK_SIZE+1, BUTTON_ID_PICK);
|
||||
|
||||
DrawCopyButton(67, 11, 35, 14, 0x777777);
|
||||
DrawCopyButton(67, 11, 35, 14);
|
||||
|
||||
EventUpdateWindowContent();
|
||||
}
|
||||
@ -114,17 +107,17 @@ void EventUpdateWindowContent()
|
||||
WriteTextWithBg(12,12, 0xD0, 0x000111, #picked_color_string+4, 0xFFFfff);
|
||||
|
||||
WriteNumber(12,33, 0xD0, 0xff0000, 3, rgb.r);
|
||||
WriteNumber(43,33, 0xD0, 0x008000, 3, rgb.g);
|
||||
WriteNumber(73,33, 0xD0, 0x0000ff, 3, rgb.b);
|
||||
WriteNumber(44,33, 0xD0, 0x008000, 3, rgb.g);
|
||||
WriteNumber(75,33, 0xD0, 0x0000ff, 3, rgb.b);
|
||||
|
||||
DrawBar(COLOR_BLOCK_X, COLOR_BLOCK_PADDING, COLOR_BLOCK_SIZE, COLOR_BLOCK_SIZE, picked_color);
|
||||
}
|
||||
|
||||
void DrawCopyButton(dword _x, _y, _w, _h, _color)
|
||||
void DrawCopyButton(dword _x, _y, _w, _h)
|
||||
{
|
||||
DefineHiddenButton(_x+1, _y+1, _w-2, _h-2, BUTTON_ID_COPY);
|
||||
DrawRectangle(_x, _y, _w, _h, _color);
|
||||
WriteTextCenter(_x, _h-8/2 + _y, _w, _color, "Copy");
|
||||
DrawRectangle(_x, _y, _w, _h, 0x777777);
|
||||
WriteText(_x+6, _h-8/2 + _y, 0x80, 0x555555, "Copy");
|
||||
}
|
||||
|
||||
void EventCopyHex()
|
||||
|
@ -5,7 +5,7 @@ enum {
|
||||
|
||||
#define DRAW_PADDING 12
|
||||
|
||||
void Parcer(byte mode)
|
||||
void Parse(byte mode)
|
||||
{
|
||||
dword bufoff, buflen;
|
||||
byte ch;
|
||||
@ -51,14 +51,14 @@ void PreparePage()
|
||||
{
|
||||
list.w = Form.cwidth-scroll.size_x-1;
|
||||
list.count=0;
|
||||
Parcer(COUNT_BUF_HEIGHT);
|
||||
Parse(COUNT_BUF_HEIGHT);
|
||||
|
||||
//draw text in buffer
|
||||
list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, kfont.size.pt+6);
|
||||
if (list.count < list.visible) list.count = list.visible;
|
||||
kfont.size.height = list.count+1*list.item_h;
|
||||
kfont.raw_size = 0;
|
||||
Parcer(DRAW_BUF);
|
||||
Parse(DRAW_BUF);
|
||||
|
||||
if (list.count > list.visible * 10) DrawPage();
|
||||
//draw result
|
||||
|
Loading…
Reference in New Issue
Block a user