//===================================================// // // // MODULE // // // //===================================================// #define TABS_MAX 5 TWebBrowser tabdata[TABS_MAX+1]=0; _history tabstory[TABS_MAX+1]=0; 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; i0) active--; if (active==count-1) && (active>0) active--; count--; return true; } void TAB::save_state() { tabstory[active] = history; tabdata[active] = WB1; } void TAB::restore(int _id) { tab.active = _id; WB1 = tabdata[_id]; history = tabstory[_id]; } //===================================================// // // // WebView Actions // // // //===================================================// #define DEFAULT_TABW 220 int tab_w = DEFAULT_TABW; int GetTabWidth() { if (tab.count == TABS_MAX) return Form.cwidth / tab.count; 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 = sc.work_light; border_bottom_color = sc.work_light; } else { bgcol=sc.work; border_bottom_color = sc.work_graph; } if (tabdata[_id].header) { strncpy(#header_no_version, #tabdata[_id].header, strlen(#tabdata[_id].header)-sizeof(version)-2); strncpy(#name, #header_no_version, tab_w-CLOSE_S/6-2); } DrawBar(xxx, TOOLBAR_H, 1, TAB_H, sc.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, sc.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, sc.work_dark); WriteText(xxx+tab_w-CLOSE_S+1, TOOLBAR_H+5, 0x80, sc.work_light, "x"); } void DrawActiveTab() { if (tab_w == GetTabWidth()) DrawTab(tab.active); else DrawTabsBar(); } int DrawNewTabButton() { dword btn_light = MixColors(sc.button, 0xFFFfff, 220); dword btn_dark = MixColors(sc.button, 0, 180); int xxx = tab.count * tab_w; if (tab.count < TABS_MAX) { DrawBar(xxx, TOOLBAR_H, 1, TAB_H, sc.work_graph); DrawBar(xxx+1, TOOLBAR_H, TAB_H, TAB_H-1, sc.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, sc.button_text, "+"); return xxx + TAB_H + 2; } else { return xxx; } } void DrawTabsBar() { dword i; tab_w = GetTabWidth(); for (i=0; i=tab.count) _id = 0; if (_id==-1) _id = tab.count-1; tab.save_state(); tab.restore(_id); DrawTabsBar(); SetElementSizes(); 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); }