⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appletwindow.cpp

📁 wxGTK 是 wxWidgets 的 linux GTK+ (>2.2.3)版本。wxWidgets 是一个跨平台的 GUI 框架
💻 CPP
📖 第 1 页 / 共 2 页
字号:
bool wxHtmlAppletWindow::HistoryBack(){    if (!HistoryCanBack())        return false;    for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())        (node->GetData())->OnHistoryBack();    return wxHtmlWindow::HistoryBack();}/****************************************************************************REMARKS:This function is used to disable the navigation bars. If you want totoggle to the navbars off you must call this function.****************************************************************************/void wxHtmlAppletWindow::DisableNavBar(){    m_NavBarEnabled = false;}/****************************************************************************REMARKS:This function is used to enable the nav bars. If you toggle the nav bars onyou must call this function.****************************************************************************/void wxHtmlAppletWindow::EnableNavBar(){    m_NavBarEnabled = true;}/****************************************************************************REMARKS:This function is used to set the nav bar to a new nav bar if you deleted theone that you were useing. Usally this happens when you toggle a nav baron or off.****************************************************************************/void wxHtmlAppletWindow::SetNavBar(wxToolBarBase *navBar){    m_NavBar = navBar;}/****************************************************************************PARAMETERS:msg - wxEvent message to be sent to all wxAppletsREMARKS:This function is called by the wxApplet's when they need to send a messageto all other applets on the current page. This is the primary form ofcommunication between applets on the page if they need to inform eachother of internal information.****************************************************************************/void wxHtmlAppletWindow::SendAppletMessage(    wxAppletEvent& msg){    // TODO: make a named target for messages, only send a message to the correct    // named applet    // Process all applets in turn and send them the message    for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) {        (node->GetData())->OnMessage(msg);        }}/****************************************************************************PARAMETERS:name    - Uniq wxString used as hash keycookie  - wxObject data returned when name is found.RETURNS:True if new cookie was added, false if cookie with same name already exists.REMARKS:This function is called by the wxApplet's when they need register a cookieof data in the applet window's cookie table. Cookies are arbitrary dataobjects that are references by unique name's by the wxApplet. Thesevalues can be used to store and retrieve data that needs to remainpersisent across invocations of the wxApplet. Ie: The first time anapplet is created it would use the cookie to store data to maintainit's present state so that if you navigated back to the same pageis would be able to re-load the prior state as though the appletwas never actually destructed.Note: If a cookie with the same name already exists, this function returns      false. Hence if you wish to replace a cookie you should first call      UnRegisterCookie to ensure the cookie is deleted and then call this      function.****************************************************************************/bool wxHtmlAppletWindow::RegisterCookie(    const wxString& name,    wxObject *cookie){    // Fail if the named cookie already exists!    if (m_Cookies.Get(name))        return false;    m_Cookies.Put(name,cookie);    return true;}/****************************************************************************PARAMETERS:name - wxString uniq haskey used to remove item from hashRETURNS:True if found and deleted, false if not found in table.REMARKS:This function is called by the wxApplet's when they need de-register acookie of data in the applet window's cookie table. The data in thecookie itself is also deleted before it is removed from the table.****************************************************************************/bool wxHtmlAppletWindow::UnRegisterCookie(    const wxString& name){    wxObject *data = m_Cookies.Delete(name);    if (data) {        delete data;        return true;        }    return false;}/****************************************************************************PARAMETERS:msg - wxEvent message to be sent to all wxAppletsRETURNS:Pointer to the cookie data if found, NULL if not found.REMARKS:This function is called by the wxApplet's when they need to find a cookieof data given it's public name. If the cookie is not found, NULL isreturned.****************************************************************************/wxObject *wxHtmlAppletWindow::FindCookie(    const wxString& name){    return m_Cookies.Get(name);}/****************************************************************************PARAMETERS:event   - Event to handleREMARKS:This function handles delayed LoadPage events posted from applets thatneed to change the page for the current window to a new window.****************************************************************************/void wxHtmlAppletWindow::OnLoadPage(    wxLoadPageEvent &event){    // Test the mutex lock.    if (!(IsLocked())) {        Lock();        if (event.GetHtmlWindow() == this) {            if (LoadPage(event.GetHRef())) {                // wxPageLoadedEvent evt;                // NOTE: This is reserved for later use as we might need to send                // page loaded events to applets.                }            }        UnLock();        }}/****************************************************************************PARAMETERS:event   - Event to handleREMARKS:This function handles delayed LoadPage events posted from applets thatneed to change the page for the current window to a new window.****************************************************************************/void wxHtmlAppletWindow::OnPageLoaded(    wxPageLoadedEvent &){    Enable(true);}/****************************************************************************PARAMETERS:noneREMARKS:This function tries to lock the mutex. If it can't, returnsimmediately with false.***************************************************************************/bool wxHtmlAppletWindow::TryLock(){    if (!m_mutexLock) {        m_mutexLock = true;        return true;        }    return false;}/****************************************************************************PARAMETERS:name    - name of the last applet that changed the data in this objectgroup   - name of the group the allplet belongs to.href    - webpage to go to.REMARKS:VirtualData is used to store information on the virtual links.****************************************************************************/VirtualData::VirtualData(    wxString& name,    wxString& group,    wxString& href,    wxString& plugin ){    m_name = name;    m_group = group;    m_href = href;    m_plugIn = plugin;}/****************************************************************************PARAMETERS:REMARKS:VirtualData is used to store information on the virtual links.****************************************************************************/VirtualData::VirtualData(){    m_name.Empty();    m_group.Empty();    m_href.Empty();}#include "wx/html/m_templ.h"/****************************************************************************REMARKS:Implementation for the <embed> HTML tag handler. This handler takes careof automatically constructing the wxApplet objects of the appropriateclass based on the <embed> tag information.****************************************************************************/TAG_HANDLER_BEGIN(wxApplet, "WXAPPLET")TAG_HANDLER_PROC(tag){	wxWindow			*wnd;	wxHtmlAppletWindow	*appletWindow;	wxApplet			*applet;    wxString            classId;    wxString            name;    int 				width, height;    // Get access to our wxHtmlAppletWindow class	wnd = m_WParser->GetWindow();	if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) == NULL)        return false;    // Parse the applet dimensions from the tag    wxSize size = wxDefaultSize;    int al;    if (tag.HasParam("WIDTH")) {        tag.GetParamAsInt("WIDTH", &width);        size.SetWidth(width);        }    if (tag.HasParam("HEIGHT")) {        tag.GetParamAsInt("HEIGHT", &height);        size.SetHeight(height);        }    // Parse the applet alignment from the tag    al = wxHTML_ALIGN_BOTTOM;    if (tag.HasParam(wxT("ALIGN"))) {        wxString alstr = tag.GetParam(wxT("ALIGN"));        alstr.MakeUpper();  // for the case alignment was in ".."        if (alstr == wxT("TEXTTOP") || alstr == wxT("TOP"))            al = wxHTML_ALIGN_TOP;        else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER")))            al = wxHTML_ALIGN_CENTER;        }    // Create the applet based on it's class    if (tag.HasParam("CLASSID")) {        classId = tag.GetParam("CLASSID");        if (classId.IsNull() || classId.Len() == 0) {            wxMessageBox("wxApplet tag error: CLASSID is NULL or empty.","Error",wxICON_ERROR);            return false;            }        if (tag.HasParam("NAME"))            name = tag.GetParam("NAME");        // If the name is NULL or len is zero then we assume that the html guy        // didn't include the name param which is optional.        if (name.IsNull() || name.Len() == 0)            name = classId;        // We got all the params and can now create the applet        if ((applet = appletWindow->CreateApplet(classId, name, tag , size)) != NULL) {            applet->Show(true);            m_WParser->OpenContainer()->InsertCell(new wxHtmlAppletCell(applet,al));            }        else            wxMessageBox("wxApplet error: Could not create:" + classId + "," + name);        }    else {        wxMessageBox("wxApplet tag error: Can not find CLASSID param.","Error",wxICON_ERROR);        return false;        }    // Add more param parsing here. If or when spec changes.    // For now we'll ignore any other params those HTML guys    // might put in our tag.	return true;}TAG_HANDLER_END(wxApplet)TAGS_MODULE_BEGIN(wxApplet)    TAGS_MODULE_ADD(wxApplet)TAGS_MODULE_END(wxApplet)/****************************************************************************REMARKS:Constructor for the HTML cell class to store our wxApplet windows inthe HTML page to be rendered by wxHTML.****************************************************************************/wxHtmlAppletCell::wxHtmlAppletCell(    wxWindow *wnd,    int align)    : wxHtmlCell(){    int sx, sy;    m_Wnd = wnd;    m_Wnd->GetSize(&sx, &sy);    m_Width = sx, m_Height = sy;    switch (align) {        case wxHTML_ALIGN_TOP :            m_Descent = m_Height;            break;        case wxHTML_ALIGN_CENTER :            m_Descent = m_Height / 2;            break;        case wxHTML_ALIGN_BOTTOM :        default :            m_Descent = 0;            break;        }    SetCanLiveOnPagebreak(FALSE);}/****************************************************************************REMARKS:Implementation for the HTML cell class to store our wxApplet windows inthe HTML page to be rendered by wxHTML.****************************************************************************/wxHtmlAppletCell::~wxHtmlAppletCell(){    delete m_Wnd;}/****************************************************************************REMARKS:Code to draw the html applet cell****************************************************************************/void wxHtmlAppletCell::Draw(    wxDC& WXUNUSED(dc),    int WXUNUSED(x),    int WXUNUSED(y),    int WXUNUSED(view_y1),    int WXUNUSED(view_y2)){    int         absx = 0, absy = 0, stx, sty;    wxHtmlCell  *c = this;    while (c) {        absx += c->GetPosX();        absy += c->GetPosY();        c = c->GetParent();        }    ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty);    m_Wnd->Move(absx - wxHTML_SCROLL_STEP * stx, absy  - wxHTML_SCROLL_STEP * sty);}/****************************************************************************REMARKS:Code to draw the html applet cell invisibly****************************************************************************/void wxHtmlAppletCell::DrawInvisible(    wxDC& WXUNUSED(dc),    int WXUNUSED(x),    int WXUNUSED(y)){    int         absx = 0, absy = 0, stx, sty;    wxHtmlCell  *c = this;    while (c) {        absx += c->GetPosX();        absy += c->GetPosY();        c = c->GetParent();        }    ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty);    m_Wnd->Move(absx - wxHTML_SCROLL_STEP * stx, absy  - wxHTML_SCROLL_STEP * sty);}/****************************************************************************REMARKS:Code to layout the html applet cell.****************************************************************************/void wxHtmlAppletCell::Layout(    int w){    int sx, sy;    m_Wnd->GetSize(&sx, &sy);    m_Width = sx, m_Height = sy;    wxHtmlCell::Layout(w);}// This is our little forcelink hack.FORCE_LINK(loadpage)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -