/****************************************************************************
*
-* wxWindows HTML Applet Package
+* wxWindows HTML Applet Package
*
* Copyright (C) 1991-2001 SciTech Software, Inc.
* All rights reserved.
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
* ======================================================================
*
-* Language: ANSI C++
-* Environment: Any
+* Language: ANSI C++
+* Environment: Any
*
* Description: Main wxHtmlAppletWindow class implementation
*
Constructor for the applet window class.
****************************************************************************/
wxHtmlAppletWindow::wxHtmlAppletWindow(
- wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
- : wxHtmlWindow(parent,id,pos,size,style,name)
+ wxWindow *parent,
+ wxWindowID id,
+ 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);
+ // Ensure all cookie data is destroyed when window is killed
+ m_Cookies.DeleteContents(true);
}
/****************************************************************************
/****************************************************************************
PARAMETERS:
-className - Name of the applet class to create an object for
-size - Initial size of the applet to be created
+className - Name of the applet class to create an object for
+size - Initial size of the applet to be created
RETURNS:
Pointer to the wxApplet created, or NULL if unable to create the applet.
HTML page.
****************************************************************************/
wxApplet *wxHtmlAppletWindow::CreateApplet(
- const wxString& className,
- const wxSize& size)
+ const wxString& className,
+ const wxSize& size)
{
- // We presently only allow one applet per page of the same class!
- if (m_AppletList.Find(className))
- return NULL;
+ // 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());
+ // Dynamically create the class instance at runtime
+ wxClassInfo *info = wxClassInfo::FindClass(className.c_str());
if (!info)
return NULL;
- wxObject *obj = info->CreateObject();
- if (!obj)
- return NULL;
+ wxObject *obj = info->CreateObject();
+ if (!obj)
+ return NULL;
wxApplet *applet = wxDynamicCast(obj,wxApplet);
- if (!applet)
- return NULL;
- if (!applet->Create(this,size)) {
- delete applet;
- return NULL;
- }
- m_AppletList.Append(className,applet);
- return applet;
+ if (!applet)
+ return NULL;
+ if (!applet->Create(this,size)) {
+ delete applet;
+ return NULL;
+ }
+ m_AppletList.Append(className,applet);
+ return applet;
}
/****************************************************************************
PARAMETERS:
-appletName - Name of the applet class to find
+appletName - Name of the applet class to find
RETURNS:
Pointer to the wxApplet found, or NULL if not found.
Find an instance of an applet based on it's name
****************************************************************************/
wxApplet *wxHtmlAppletWindow::FindApplet(
- const wxString& appletName)
+ const wxString& appletName)
{
- wxAppletList::Node *node = m_AppletList.Find(appletName);
- if (!node)
- return NULL;
- return node->GetData();
-}
+ wxAppletList::Node *node = m_AppletList.Find(appletName);
+ if (!node)
+ return NULL;
+ return node->GetData();
+}
/****************************************************************************
PARAMETERS:
-applet - Pointer to the applet object to remove from the list
+applet - Pointer to the applet object to remove from the list
RETURNS:
True if the applet was found and removed, false if not. The applet itself
Remove an applet from the manager. Called during applet destruction
****************************************************************************/
bool wxHtmlAppletWindow::RemoveApplet(
- const wxApplet *applet)
+ const wxApplet *applet)
{
- for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) {
- if (node->GetData() == applet) {
- m_AppletList.DeleteNode(node);
- return true;
- }
- }
- return false;
-}
+ for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) {
+ if (node->GetData() == applet) {
+ m_AppletList.DeleteNode(node);
+ return true;
+ }
+ }
+ return false;
+}
/****************************************************************************
PARAMETERS:
-URL - New URL for the page to load
+URL - New URL for the page to load
RETURNS:
True if page loaded successfully, false if not
Remove an applet from the manager. Called during applet destruction
****************************************************************************/
bool wxHtmlAppletWindow::LoadPage(
- const wxString& hRef)
+ const wxString& hRef)
{
- for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
- (node->GetData())->OnLinkClicked(hRef);
- return wxHtmlWindow::LoadPage(hRef);
+ for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
+ (node->GetData())->OnLinkClicked(hRef);
+ return wxHtmlWindow::LoadPage(hRef);
}
/****************************************************************************
PARAMETERS:
-URL - String URL that we are navigating to
+URL - String URL that we are navigating to
REMARKS:
Called when the user navigates to a new URL from the current page. We simply
call the LoadPage function above to load the new page and display it.
****************************************************************************/
void wxHtmlAppletWindow::OnLinkClicked(
- const wxHtmlLinkInfo& link)
+ const wxHtmlLinkInfo& link)
{
- for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
- (node->GetData())->OnLinkClicked(link);
- wxHtmlWindow::LoadPage(link.GetHref());
+ for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
+ (node->GetData())->OnLinkClicked(link);
+ wxHtmlWindow::LoadPage(link.GetHref());
}
/****************************************************************************
****************************************************************************/
bool wxHtmlAppletWindow::HistoryForward()
{
- if (!HistoryCanForward())
- return false;
- for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
- (node->GetData())->OnHistoryForward();
- return wxHtmlWindow::HistoryForward();
+ if (!HistoryCanForward())
+ return false;
+ for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
+ (node->GetData())->OnHistoryForward();
+ return wxHtmlWindow::HistoryForward();
}
/****************************************************************************
****************************************************************************/
bool wxHtmlAppletWindow::HistoryBack()
{
- if (!HistoryCanBack())
- return false;
- for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
- (node->GetData())->OnHistoryBack();
- return wxHtmlWindow::HistoryBack();
+ if (!HistoryCanBack())
+ return false;
+ for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
+ (node->GetData())->OnHistoryBack();
+ return wxHtmlWindow::HistoryBack();
}
/****************************************************************************
PARAMETERS:
-msg - wxEvent message to be sent to all wxApplets
+msg - wxEvent message to be sent to all wxApplets
REMARKS:
This function is called by the wxApplet's when they need to send a message
value (ie: by default it is true).
****************************************************************************/
void wxHtmlAppletWindow::SendMessage(
- wxEvent& msg)
-{
- // Preset the skip flag
- msg.Skip();
-
- // 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);
- if (!msg.GetSkipped())
- break;
- }
+ wxEvent& msg)
+{
+ // Preset the skip flag
+ msg.Skip();
+
+ // 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);
+ if (!msg.GetSkipped())
+ break;
+ }
}
/****************************************************************************
PARAMETERS:
-msg - wxEvent message to be sent to all wxApplets
+msg - wxEvent message to be sent to all wxApplets
RETURNS:
-True if new cookie was added, false if cookie with same name already exists.
+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 cookie
was 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.
+ 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)
+ 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;
+ // Fail if the named cookie already exists!
+ if (m_Cookies.Get(name))
+ return false;
+ m_Cookies.Put(name,cookie);
+ return true;
}
/****************************************************************************
PARAMETERS:
-msg - wxEvent message to be sent to all wxApplets
+msg - wxEvent message to be sent to all wxApplets
RETURNS:
True if found and deleted, false if not found in table.
cookie itself is also deleted before it is removed from the table.
****************************************************************************/
bool wxHtmlAppletWindow::UnRegisterCookie(
- const wxString& name)
+ const wxString& name)
{
- wxObject *data = m_Cookies.Delete(name);
- if (data) {
- delete data;
- return true;
- }
- return false;
+ wxObject *data = m_Cookies.Delete(name);
+ if (data) {
+ delete data;
+ return true;
+ }
+ return false;
}
/****************************************************************************
PARAMETERS:
-msg - wxEvent message to be sent to all wxApplets
+msg - wxEvent message to be sent to all wxApplets
RETURNS:
Pointer to the cookie data if found, NULL if not found.
returned.
****************************************************************************/
wxObject *wxHtmlAppletWindow::FindCookie(
- const wxString& name)
+ const wxString& name)
{
- return m_Cookies.Get(name);
+ return m_Cookies.Get(name);
}
#include "wx/html/m_templ.h"
TAG_HANDLER_PROC(tag)
{
- wxWindow *wnd;
- wxHtmlAppletWindow *appletWindow;
- wxApplet *applet;
- int width, height;
- int floatPercent = 0;
-
- wnd = m_WParser->GetWindow();
- if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) != NULL) {
- tag.ScanParam("WIDTH", "%i", &width);
- tag.ScanParam("HEIGHT", "%i", &height);
- if (tag.HasParam("FLOAT"))
- tag.ScanParam("FLOAT", "%i", &floatPercent);
- if (tag.HasParam("APPLET")) {
- if ((applet = appletWindow->CreateApplet(tag.GetParam("APPLET"), wxSize(width, height))) != NULL) {
- applet->Show(true);
- m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(applet,floatPercent));
- }
- }
- else if (tag.HasParam("TEXT")) {
- // TODO: Somehow get the text returned from this class displayed on the page!
- }
- }
- return false;
+ wxWindow *wnd;
+ wxHtmlAppletWindow *appletWindow;
+ wxApplet *applet;
+ int width, height;
+ int floatPercent = 0;
+
+ wnd = m_WParser->GetWindow();
+ if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) != NULL) {
+ tag.ScanParam("WIDTH", "%i", &width);
+ tag.ScanParam("HEIGHT", "%i", &height);
+ if (tag.HasParam("FLOAT"))
+ tag.ScanParam("FLOAT", "%i", &floatPercent);
+ if (tag.HasParam("APPLET")) {
+ if ((applet = appletWindow->CreateApplet(tag.GetParam("APPLET"), wxSize(width, height))) != NULL) {
+ applet->Show(true);
+ m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(applet,floatPercent));
+ }
+ }
+ else if (tag.HasParam("TEXT")) {
+ // TODO: Somehow get the text returned from this class displayed on the page!
+ }
+ }
+ return false;
}
TAG_HANDLER_END(Embed)
/****************************************************************************
*
-* wxWindows HTML Applet Package
+* wxWindows HTML Applet Package
*
* Copyright (C) 1991-2001 SciTech Software, Inc.
* All rights reserved.
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
* ======================================================================
*
-* Language: ANSI C++
-* Environment: Any
+* Language: ANSI C++
+* Environment: Any
*
* Description: Header file for the wxHtmlAppletWindow class
*
/****************************************************************************
MEMBERS:
-appletModules - List of register applet modules
-appletList - List of all active applets instances
-cookies - Hash table for managing cookies
+appletModules - List of register applet modules
+appletList - List of all active applets instances
+cookies - Hash table for managing cookies
REMARKS:
Defines the class for wxAppletWindow. This class is derived from the
private:
DECLARE_CLASS(wxHtmlAppletWindow);
DECLARE_EVENT_TABLE();
-
+
protected:
- wxAppletList m_AppletList;
- wxHashTable m_Cookies;
-
+ wxAppletList m_AppletList;
+ wxHashTable m_Cookies;
+
public:
- // Constructor
- wxHtmlAppletWindow(
- wxWindow *parent,
- wxWindowID id = -1,
+ // Constructor
+ wxHtmlAppletWindow(
+ wxWindow *parent,
+ wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxHW_SCROLLBAR_AUTO,
- const wxString& name = "htmlAppletWindow");
-
- // Destructor
- ~wxHtmlAppletWindow();
-
- // Create an instance of an applet based on it's class name
- wxApplet *CreateApplet(
- const wxString& className,
- const wxSize& size);
-
- // Find an instance of an applet based on it's class name
- wxApplet *FindApplet(const wxString& className);
-
- // Remove an applet from the window. Called during applet destruction
- bool RemoveApplet(const wxApplet *applet);
+ const wxSize& size = wxDefaultSize,
+ long style = wxHW_SCROLLBAR_AUTO,
+ const wxString& name = "htmlAppletWindow");
+
+ // Destructor
+ ~wxHtmlAppletWindow();
+
+ // Create an instance of an applet based on it's class name
+ wxApplet *CreateApplet(
+ const wxString& className,
+ const wxSize& size);
+
+ // Find an instance of an applet based on it's class name
+ wxApplet *FindApplet(const wxString& className);
+
+ // Remove an applet from the window. Called during applet destruction
+ bool RemoveApplet(const wxApplet *applet);
- // Load a new URL page
- bool LoadPage(const wxString& hRef);
-
- // Called when users clicked on hypertext link.
- void OnLinkClicked(const wxHtmlLinkInfo& link);
-
- // Handles forward navigation within the HTML stack
- bool HistoryForward();
-
- // Handles backwards navigation within the HTML stack
- bool HistoryBack();
-
- // Broadcast a message to all applets on the page
- void SendMessage(wxEvent& msg);
-
- // Register a cookie of data in the applet manager
- bool RegisterCookie(const wxString& name,wxObject *cookie);
-
- // UnRegister a cookie of data in the applet manager
- bool UnRegisterCookie(const wxString& name);
-
- // Find a cookie of data given it's public name
- wxObject *FindCookie(const wxString& name);
- };
-
+ // Load a new URL page
+ bool LoadPage(const wxString& hRef);
+
+ // Called when users clicked on hypertext link.
+ void OnLinkClicked(const wxHtmlLinkInfo& link);
+
+ // Handles forward navigation within the HTML stack
+ bool HistoryForward();
+
+ // Handles backwards navigation within the HTML stack
+ bool HistoryBack();
+
+ // Broadcast a message to all applets on the page
+ void SendMessage(wxEvent& msg);
+
+ // Register a cookie of data in the applet manager
+ bool RegisterCookie(const wxString& name,wxObject *cookie);
+
+ // UnRegister a cookie of data in the applet manager
+ bool UnRegisterCookie(const wxString& name);
+
+ // Find a cookie of data given it's public name
+ wxObject *FindCookie(const wxString& name);
+ };
+
#endif // __WX_APPLET_WINDOW_H