X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/26ffe1fdba1c3b11bb6b870fc477ac460bf6bd17..2dace059ee7aefeea0f2b843f1808b117f112795:/contrib/src/applet/appletwindow.cpp diff --git a/contrib/src/applet/appletwindow.cpp b/contrib/src/applet/appletwindow.cpp index 66c9fe0d93..82c5f851ba 100644 --- a/contrib/src/applet/appletwindow.cpp +++ b/contrib/src/applet/appletwindow.cpp @@ -5,23 +5,19 @@ * Copyright (C) 1991-2001 SciTech Software, Inc. * All rights reserved. * -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code is a proprietary trade secret of | -* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 | -* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, | -* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS | -* |STRICTLY PROHIBITED BY LAW. Unless you have current, express | -* |written authorization from SciTech to possess or use this code, you | -* |may be subject to civil and/or criminal penalties. | -* | | -* |If you received this code in error or you would like to report | -* |improper use, please immediately contact SciTech Software, Inc. at | -* |530-894-8400. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== +* ======================================================================== +* +* The contents of this file are subject to the wxWindows License +* Version 3.0 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.wxwindows.org/licence3.txt +* +* Software distributed under the License is distributed on an +* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* ======================================================================== * * Language: ANSI C++ * Environment: Any @@ -32,16 +28,31 @@ // For compilers that support precompilation #include "wx/wxprec.h" +#include "wx/html/forcelnk.h" // Include private headers #include "wx/applet/applet.h" +#include "wx/applet/window.h" +#include "wx/applet/loadpage.h" + +// Preprocessor Stuff +#include "wx/applet/prepinclude.h" +#include "wx/applet/prepecho.h" +#include "wx/applet/prepifelse.h" + +/*---------------------------- Global variables ---------------------------*/ + +wxHashTable wxHtmlAppletWindow::m_Cookies; + /*------------------------- Implementation --------------------------------*/ // Empty event handler. We include this event handler simply so that // sub-classes of wxApplet can reference wxApplet in the event tables // that they create as necessary. BEGIN_EVENT_TABLE(wxHtmlAppletWindow, wxHtmlWindow) + EVT_LOAD_PAGE(wxHtmlAppletWindow::OnLoadPage) + EVT_PAGE_LOADED(wxHtmlAppletWindow::OnPageLoaded) END_EVENT_TABLE() // Implement the class functions for wxHtmlAppletWindow @@ -58,14 +69,38 @@ Constructor for the applet window class. wxHtmlAppletWindow::wxHtmlAppletWindow( wxWindow *parent, wxWindowID id, + wxToolBarBase *navBar, + int navBackId, + int navForwardId, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxHtmlWindow(parent,id,pos,size,style,name) { - // Ensure all cookie data is destroyed when window is killed - m_Cookies.DeleteContents(true); + // Init our locks + UnLock(); + + // setup client navbars + if (navBar) { + m_NavBar = navBar; + m_NavBackId = navBackId; + m_NavForwardId = navForwardId; + } + else { + m_NavBar = NULL; + } + + // Add HTML preprocessors + // deleting preprocessors is done by the code within the window + + incPreprocessor = new wxIncludePrep(); // #include preprocessor + wxEchoPrep * echoPreprocessor = new wxEchoPrep(); // #echo preprocessor + wxIfElsePrep * ifPreprocessor = new wxIfElsePrep(); + + this->AddProcessor(incPreprocessor); + this->AddProcessor(echoPreprocessor); + this->AddProcessor(ifPreprocessor); } /**************************************************************************** @@ -91,15 +126,13 @@ created dynamically based on string values embedded in the custom tags of an HTML page. ****************************************************************************/ wxApplet *wxHtmlAppletWindow::CreateApplet( - const wxString& className, + const wxString& classId, + const wxString& iName, + const wxHtmlTag& params, const wxSize& size) { - // We presently only allow one applet per page of the same class! - if (m_AppletList.Find(className)) - return NULL; - // Dynamically create the class instance at runtime - wxClassInfo *info = wxClassInfo::FindClass(className.c_str()); + wxClassInfo *info = wxClassInfo::FindClass(classId.c_str()); if (!info) return NULL; wxObject *obj = info->CreateObject(); @@ -108,11 +141,11 @@ wxApplet *wxHtmlAppletWindow::CreateApplet( wxApplet *applet = wxDynamicCast(obj,wxApplet); if (!applet) return NULL; - if (!applet->Create(this,size)) { + if (!applet->Create(this,params,size)) { delete applet; return NULL; } - m_AppletList.Append(className,applet); + m_AppletList.Append(iName,applet); return applet; } @@ -133,7 +166,7 @@ wxApplet *wxHtmlAppletWindow::FindApplet( if (!node) return NULL; return node->GetData(); -} +} /**************************************************************************** PARAMETERS: @@ -156,7 +189,7 @@ bool wxHtmlAppletWindow::RemoveApplet( } } return false; -} +} /**************************************************************************** PARAMETERS: @@ -169,11 +202,62 @@ REMARKS: Remove an applet from the manager. Called during applet destruction ****************************************************************************/ bool wxHtmlAppletWindow::LoadPage( - const wxString& hRef) + const wxString& link) { + wxString href(link); + + // TODO: This needs to be made platform inde if possible. + if (link.GetChar(0) == '?'){ + wxString cmd = link.BeforeFirst('='); + wxString cmdValue = link.AfterFirst('='); + + if(!(cmd.CmpNoCase("?EXTERNAL"))){ +#ifdef __WINDOWS__ + ShellExecute(this ? (HWND)this->GetHWND() : NULL,NULL,cmdValue.c_str(),NULL,"",SW_SHOWNORMAL); +#else + #error Platform not implemented yet! +#endif + return true; + } + if (!(cmd.CmpNoCase("?EXECUTE"))){ + wxMessageBox(cmdValue); + return true; + } + if (!(cmd.CmpNoCase("?VIRTUAL"))){ + VirtualData& temp = *((VirtualData*)FindCookie(cmdValue)); + if (&temp) { + href = temp.GetHref(); + } + else { +#ifdef CHECKED + wxMessageBox("VIRTUAL LINK ERROR: " + cmdValue + " does not exist."); +#endif + return true; + } + } + } + + // Make a copy of the current path the translate for