#define __WX_APPLET_H
#include "wx/panel.h"
-#include "wx/applet/window.h"
+#include "wx/html/htmlwin.h"
+
+// Forward declaration
+class wxHtmlAppletWindow;
/*--------------------------- Class Definitions ---------------------------*/
private:
DECLARE_ABSTRACT_CLASS(wxApplet);
DECLARE_EVENT_TABLE();
-
+
protected:
- wxHtmlAppletWindow *m_Parent;
+ wxHtmlAppletWindow *m_parent;
- // Special handler for background erase messages
+ // Special handler for background erase messages
void OnEraseBackground(wxEraseEvent&);
-
+
public:
// Constructor (called during dynamic creation)
- wxApplet() { m_Parent = NULL; }
-
+ wxApplet() { m_parent = NULL; };
+
// Psuedo virtual constructor
virtual bool Create(
wxHtmlAppletWindow *parent,
+ const wxHtmlTag& params,
const wxSize& size,
long style = wxTAB_TRAVERSAL | wxNO_BORDER);
-
+
// Virtual destructor
virtual ~wxApplet();
// Handle HTML navigation to a new URL
- virtual void OnLinkClicked(const wxHtmlLinkInfo& link) = 0;
-
+ virtual void OnLinkClicked(const wxHtmlLinkInfo& link) = 0;
+
// Handle HTML navigation forward command in applet
virtual void OnHistoryForward() = 0;
-
+
// Handle HTML navigation back command in applet
virtual void OnHistoryBack() = 0;
-
+
// Handle messages from the wxAppletManager and other applets
virtual void OnMessage(wxEvent& msg) = 0;
};
-
+
+
+
#endif // __WX_APPLET_H
#include "wx/html/htmlwin.h"
-/*--------------------------- Class Definitions ---------------------------*/
+// Forward declare
+class wxApplet;
+class wxLoadPageEvent;
+class wxPageLoadedEvent;
+class wxIncludePrep;
// Declare a linked list of wxApplet pointers
-class wxApplet;
WX_DECLARE_LIST(wxApplet, wxAppletList);
+/*--------------------------- Class Definitions ---------------------------*/
+
/****************************************************************************
-MEMBERS:
-appletModules - List of register applet modules
-appletList - List of all active applets instances
-cookies - Hash table for managing cookies
+REMARKS:
+Defines the class for virtual-link data types
+****************************************************************************/
+class VirtualData : public wxObject {
+private:
+ wxString m_name;
+ wxString m_group;
+ wxString m_href;
+public:
+ // Ctors
+ VirtualData(
+ wxString& name,
+ wxString& group,
+ wxString& href );
+
+ // Gets
+ wxString GetName(){ return m_name;};
+ wxString GetGroup(){ return m_group;};
+ wxString GetHref(){ return m_href;};
+
+ // Sets
+ void SetName (wxString& s){ m_name = s; };
+ void SetGroup(wxString& s){ m_group = s; };
+ void SetHref (wxString& s){ m_href = s; };
+ };
+
+/****************************************************************************
REMARKS:
Defines the class for wxAppletWindow. This class is derived from the
wxHtmlWindow class and extends it with functionality to handle embedded
private:
DECLARE_CLASS(wxHtmlAppletWindow);
DECLARE_EVENT_TABLE();
-
+
+ wxIncludePrep *incPreprocessor; // deleted by list it is added too in constructor
protected:
- wxAppletList m_AppletList;
- wxHashTable m_Cookies;
-
+ wxAppletList m_AppletList;
+ static wxHashTable m_Cookies;
+ wxToolBarBase *m_NavBar;
+ int m_NavBackId;
+ int m_NavForwardId;
+
public:
// Constructor
wxHtmlAppletWindow(
wxWindow *parent,
wxWindowID id = -1,
+ wxToolBarBase *navBar = NULL,
+ int navBackId = -1,
+ int navForwardId = -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 wxString& classId,
+ const wxString& iName,
+ const wxHtmlTag ¶ms,
const wxSize& size);
-
+
// Find an instance of an applet based on it's class name
- wxApplet *FindApplet(const wxString& className);
-
+ wxApplet *FindApplet(const wxString& className);
+
// Remove an applet from the window. Called during applet destruction
- bool RemoveApplet(const wxApplet *applet);
+ bool RemoveApplet(const wxApplet *applet);
// Load a new URL page
- bool LoadPage(const wxString& hRef);
-
+ virtual bool LoadPage(const wxString& location);
+
// Called when users clicked on hypertext link.
- void OnLinkClicked(const wxHtmlLinkInfo& link);
-
+ virtual 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);
+
+ // Event handlers to load a new page
+ void OnLoadPage(wxLoadPageEvent &event);
+
+ // Event handlers to load a new page
+ void OnPageLoaded(wxPageLoadedEvent &event);
+
};
-
+
#endif // __WX_APPLET_WINDOW_H
virtual bool CanSave() { return FALSE; }
virtual bool Load(wxInputStream& stream, wxXmlDocument& doc);
- virtual bool Save(wxOutputStream& stream, const wxXmlDocument& doc) { return FALSE; }
+ virtual bool Save(wxOutputStream& stream, const wxXmlDocument& doc) { (void)stream; (void)doc; return FALSE; }
};
{
public:
virtual wxXmlIOType GetType() { return wxXML_IO_TEXT_OUTPUT; }
- virtual bool CanLoad(wxInputStream& stream) { return FALSE; }
+ virtual bool CanLoad(wxInputStream& stream) { (void)stream; return FALSE; }
virtual bool CanSave() { return TRUE; }
- virtual bool Load(wxInputStream& stream, wxXmlDocument& doc) { return FALSE; }
+ virtual bool Load(wxInputStream& stream, wxXmlDocument& doc) { (void)stream; (void)doc; return FALSE; }
virtual bool Save(wxOutputStream& stream, const wxXmlDocument& doc);
};
// Include private headers
#include "wx/applet/applet.h"
+#include "wx/applet/window.h"
/*------------------------- Implementation --------------------------------*/
****************************************************************************/
bool wxApplet::Create(
wxHtmlAppletWindow *parent,
+ const wxHtmlTag& ,
const wxSize& size,
long style)
{
bool ret = wxPanel::Create(parent, -1, wxDefaultPosition, size, style);
if (ret) {
- m_Parent = parent;
+ m_parent = parent;
}
return ret;
}
****************************************************************************/
wxApplet::~wxApplet()
{
- m_Parent->RemoveApplet(this);
+ m_parent->RemoveApplet(this);
}
/****************************************************************************
Special handler for background erase messages. We do nothing in here which
causes the background to not be erased which is exactly what we want. All
the wxApplet classes display over an HTML window, so we want the HTML
-background to show through.
+background to show through.
****************************************************************************/
void wxApplet::OnEraseBackground(wxEraseEvent&)
{
// 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
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);
+ //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);
+
+
}
/****************************************************************************
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();
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;
}
if (!node)
return NULL;
return node->GetData();
-}
+}
/****************************************************************************
PARAMETERS:
}
}
return false;
-}
+}
/****************************************************************************
PARAMETERS:
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;
+ }
+ }
+ }
+
+ // Grab the directory from the string for use in the include preprocessor
+ // make sure we get either type of / or \.
+ int ch = link.Find('\\', true);
+ if (ch == -1) ch = link.Find('/', true);
+ if (ch != -1) {
+ wxFileSystem fs;
+ wxString tmp = link.Mid(0, ch+1);
+ fs.ChangePathTo(incPreprocessor->GetDirectory(), true);
+ fs.ChangePathTo(tmp, true);
+ incPreprocessor->ChangeDirectory(fs.GetPath());
+ }
+
+ // Inform all the applets that the new page is being loaded
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
- (node->GetData())->OnLinkClicked(hRef);
- return wxHtmlWindow::LoadPage(hRef);
+ (node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href));
+ bool stat = wxHtmlWindow::LoadPage(href);
+
+ // Enable/Dis the navbar tools
+ if (m_NavBar) {
+ m_NavBar->EnableTool(m_NavForwardId,HistoryCanForward());
+ m_NavBar->EnableTool(m_NavBackId,HistoryCanBack());
+ }
+ return stat;
}
/****************************************************************************
void wxHtmlAppletWindow::OnLinkClicked(
const wxHtmlLinkInfo& link)
{
- for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
- (node->GetData())->OnLinkClicked(link);
- wxHtmlWindow::LoadPage(link.GetHref());
+ LoadPage(link.GetHref());
}
/****************************************************************************
****************************************************************************/
bool wxHtmlAppletWindow::HistoryForward()
{
- if (!HistoryCanForward())
+ 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())
+ if (!HistoryCanBack())
return false;
+
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
(node->GetData())->OnHistoryBack();
+
return wxHtmlWindow::HistoryBack();
}
****************************************************************************/
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())
+ if (!msg.GetSkipped()){
+ wxMessageBox("BREAK");
break;
+ }
}
}
/****************************************************************************
PARAMETERS:
-msg - wxEvent message to be sent to all wxApplets
+name - Uniq wxString used as hash key
+cookie - wxObject data returned when name is found.
RETURNS:
True if new cookie was added, false if cookie with same name already exists.
// Fail if the named cookie already exists!
if (m_Cookies.Get(name))
return false;
- m_Cookies.Put(name,cookie);
+ m_Cookies.Put(name,cookie);
return true;
}
/****************************************************************************
PARAMETERS:
-msg - wxEvent message to be sent to all wxApplets
+name - wxString uniq haskey used to remove item from hash
RETURNS:
True if found and deleted, false if not found in table.
return m_Cookies.Get(name);
}
+/****************************************************************************
+PARAMETERS:
+event - Event to handle
+
+REMARKS:
+This function handles delayed LoadPage events posted from applets that
+need to change the page for the current window to a new window.
+****************************************************************************/
+void wxHtmlAppletWindow::OnLoadPage(
+ wxLoadPageEvent &event)
+{
+ if (event.GetHtmlWindow() == this){
+ if (LoadPage(event.GetHRef())){
+ wxPageLoadedEvent evt;
+ }
+ }
+}
+
+/****************************************************************************
+PARAMETERS:
+event - Event to handle
+
+REMARKS:
+This function handles delayed LoadPage events posted from applets that
+need to change the page for the current window to a new window.
+****************************************************************************/
+void wxHtmlAppletWindow::OnPageLoaded(
+ wxPageLoadedEvent &)
+{
+ Enable(true);
+}
+
+/****************************************************************************
+PARAMETERS:
+name - name of the last applet that changed the data in this object
+group - 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 )
+{
+ m_name = name;
+ m_group = group;
+ m_href = href;
+}
+
#include "wx/html/m_templ.h"
/****************************************************************************
of automatically constructing the wxApplet objects of the appropriate
class based on the <embed> tag information.
****************************************************************************/
-TAG_HANDLER_BEGIN(Embed, "EMBED")
+TAG_HANDLER_BEGIN(wxApplet, "WXAPPLET")
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));
+ wxWindow *wnd;
+ wxHtmlAppletWindow *appletWindow;
+ wxApplet *applet;
+ wxString classId;
+ wxString name;
+ int width, height;
+
+ wnd = m_WParser->GetWindow();
+
+ if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) != NULL){
+ tag.ScanParam("WIDTH", "%i", &width);
+ tag.ScanParam("HEIGHT", "%i", &height);
+ 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 , wxSize(width, height))) != NULL){
+ applet->Show(true);
+ m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(applet,0));
+ }
+ else
+ wxMessageBox("wxApplet error: Could not create:" + classId + "," + name);
+ }
+ else{
+ wxMessageBox("wxApplet tag error: Can not find CLASSID param.","Error",wxICON_ERROR);
+ return false;
}
- else if (tag.HasParam("TEXT")) {
- // TODO: Somehow get the text returned from this class displayed on the page!
- }
+ //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 false;
+
+ return false;
}
-TAG_HANDLER_END(Embed)
+TAG_HANDLER_END(wxApplet)
+
+TAGS_MODULE_BEGIN(wxApplet)
+ TAGS_MODULE_ADD(wxApplet)
+TAGS_MODULE_END(wxApplet)
-TAGS_MODULE_BEGIN(Embed)
- TAGS_MODULE_ADD(Embed)
-TAGS_MODULE_END(Embed)
+// This is our little forcelink hack.
+FORCE_LINK(loadpage)
static const char KW_ID[] = { ASCII_I, ASCII_D, '\0' };
static const char KW_IDREF[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
static const char KW_IDREFS[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
+/* Remove compiler warnings for not using when XML_DTD is not defined */
+#ifdef XML_DTD
+static const char KW_INCLUDE[] = { ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' };
static const char KW_IGNORE[] = { ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' };
+#endif
static const char KW_IMPLIED[] = { ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' };
-static const char KW_INCLUDE[] = { ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' };
static const char KW_NDATA[] = { ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
static const char KW_NMTOKEN[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' };
static const char KW_NMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' };
See the file copying.txt for copying permission.
*/
+#undef INVALID_LEAD_CASE
+
#ifndef IS_INVALID_CHAR
#define IS_INVALID_CHAR(enc, ptr, n) (0)
-#endif
-
+#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
+ case BT_LEAD ## n: \
+ if (end - ptr < n) \
+ return XML_TOK_PARTIAL_CHAR; \
+ ptr += n; \
+ break;
+#else
#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
case BT_LEAD ## n: \
if (end - ptr < n) \
} \
ptr += n; \
break;
+#endif
#define INVALID_CASES(ptr, nextTokPtr) \
INVALID_LEAD_CASE(2, ptr, nextTokPtr) \
{
if (ptr == end)
return XML_TOK_NONE;
+#if !(MINBPC(enc) == 1)
if (MINBPC(enc) > 1) {
size_t n = end - ptr;
if (n & (MINBPC(enc) - 1)) {
return XML_TOK_PARTIAL;
end = ptr + n;
}
- }
+ }
+#endif
switch (BYTE_TYPE(enc, ptr)) {
case BT_RSQB:
ptr += MINBPC(enc);
hadColon = 0;
#endif
for (;;) {
-
+
ptr += MINBPC(enc);
if (ptr == end)
return XML_TOK_PARTIAL;
{
if (ptr == end)
return XML_TOK_NONE;
+#if !(MINBPC(enc) == 1)
if (MINBPC(enc) > 1) {
size_t n = end - ptr;
if (n & (MINBPC(enc) - 1)) {
end = ptr + n;
}
}
+#endif
switch (BYTE_TYPE(enc, ptr)) {
case BT_LT:
return PREFIX(scanLt)(enc, ptr + MINBPC(enc), end, nextTokPtr);
int tok;
if (ptr == end)
return XML_TOK_NONE;
+#if !(MINBPC(enc) == 1)
if (MINBPC(enc) > 1) {
size_t n = end - ptr;
if (n & (MINBPC(enc) - 1)) {
end = ptr + n;
}
}
+#endif
switch (BYTE_TYPE(enc, ptr)) {
case BT_QUOT:
return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr);
return XML_TOK_DECL_CLOSE;
case BT_NUM:
return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+#ifdef XML_MIN_SIZE
#define LEAD_CASE(n) \
case BT_LEAD ## n: \
if (end - ptr < n) \
} \
*nextTokPtr = ptr; \
return XML_TOK_INVALID;
+#else
+#define LEAD_CASE(n) \
+ case BT_LEAD ## n: \
+ if (end - ptr < n) \
+ return XML_TOK_PARTIAL_CHAR; \
+ *nextTokPtr = ptr; \
+ return XML_TOK_INVALID;
+#endif
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
#undef LEAD_CASE
case BT_NMSTRT:
ptr += MINBPC(enc);
break;
case BT_NONASCII:
+#ifdef XML_MIN_SIZE
if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) {
ptr += MINBPC(enc);
tok = XML_TOK_NAME;
tok = XML_TOK_NMTOKEN;
break;
}
+#endif
/* fall through */
default:
*nextTokPtr = ptr;
}
/* This must only be called for a well-formed start-tag or empty element tag.
-Returns the number of attributes. Pointers to the first attsMax attributes
+Returns the number of attributes. Pointers to the first attsMax attributes
are stored in atts. */
static
// Copyright: (c) 2001 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
// nothing - already in xml.cpp
#endif
ctx->lastAsText = NULL;
}
-static void EndElementHnd(void *userData, const char *name)
+static void EndElementHnd(void *userData, const char* WXUNUSED(name))
{
- wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
+ wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
ctx->node = ctx->node->GetParent();
ctx->lastAsText = NULL;
static void TextHnd(void *userData, const char *s, int len)
{
- wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
+ wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
char *buf = new char[len + 1];
-
+
buf[len] = '\0';
memcpy(buf, s, (size_t)len);
-
+
if (ctx->lastAsText)
{
- ctx->lastAsText->SetContent(ctx->lastAsText->GetContent() +
+ ctx->lastAsText->SetContent(ctx->lastAsText->GetContent() +
CharToString(buf));
}
else
- {
+ {
bool whiteOnly = TRUE;
for (char *c = buf; *c != '\0'; c++)
if (*c != ' ' && *c != '\t' && *c != '\n' && *c != '\r')
}
if (!whiteOnly)
{
- ctx->lastAsText = new wxXmlNode(wxXML_TEXT_NODE, wxT("text"),
+ ctx->lastAsText = new wxXmlNode(wxXML_TEXT_NODE, wxT("text"),
CharToString(buf));
ctx->node->AddChild(ctx->lastAsText);
}
static void CommentHnd(void *userData, const char *data)
{
- wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
-
+ wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
+
if (ctx->node)
{
// VS: ctx->node == NULL happens if there is a comment before
// the root element (e.g. wxDesigner's output). We ignore such
// comments, no big deal...
- ctx->node->AddChild(new wxXmlNode(wxXML_COMMENT_NODE,
+ ctx->node->AddChild(new wxXmlNode(wxXML_COMMENT_NODE,
wxT("comment"), CharToString(data)));
}
ctx->lastAsText = NULL;
// XML header:
if (len > 6 && memcmp(s, "<?xml ", 6) == 0)
{
- wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
+ wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
wxString buf = CharToString(s, (size_t)len);
int pos;
pos = buf.Find(wxT("version="));
if (pos != wxNOT_FOUND)
ctx->version = buf.Mid(pos + 9).BeforeFirst(buf[(size_t)pos+8]);
- }
+ }
}
bool wxXmlIOHandlerExpat::Load(wxInputStream& stream, wxXmlDocument& doc)
XML_Parser parser = XML_ParserCreate(NULL);
ctx.root = ctx.node = NULL;
- XML_SetUserData(parser, (void*)&ctx);
+ XML_SetUserData(parser, (void*)&ctx);
XML_SetElementHandler(parser, StartElementHnd, EndElementHnd);
XML_SetCharacterDataHandler(parser, TextHnd);
XML_SetCommentHandler(parser, CommentHnd);
XML_SetDefaultHandler(parser, DefaultHnd);
- do
+ do
{
size_t len = stream.Read(buf, BUFSIZE).LastRead();
done = (len < BUFSIZE);
- if (!XML_Parse(parser, buf, len, done))
+ if (!XML_Parse(parser, buf, len, done))
{
wxLogError(_("XML parsing error: '%s' at line %d"),
XML_ErrorString(XML_GetErrorCode(parser)),
XML_GetCurrentLineNumber(parser));
return FALSE;
- }
+ }
} while (!done);
doc.SetVersion(ctx.version);
return wxNullColour;
}
- return wxColour((tmp & 0xFF0000) >> 16 ,
- (tmp & 0x00FF00) >> 8,
- (tmp & 0x0000FF));
+ return wxColour((unsigned char) ((tmp & 0xFF0000) >> 16) ,
+ (unsigned char) ((tmp & 0x00FF00) >> 8),
+ (unsigned char) ((tmp & 0x0000FF)));
}
wxDataInputStream& operator>>(float& f);
void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
-
+
protected:
wxInputStream *m_input;
bool m_be_order;
void WriteString(const wxString& string);
wxDataOutputStream& operator<<(const wxChar *string);
- wxDataOutputStream& operator<<(wxString& string);
+ wxDataOutputStream& operator<<(const wxString& string);
wxDataOutputStream& operator<<(wxInt8 c);
wxDataOutputStream& operator<<(wxInt16 i);
wxDataOutputStream& operator<<(wxInt32 i);
wxDataOutputStream& operator<<(double f);
wxDataOutputStream& operator<<(float f);
- void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
-
+ void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
+
protected:
wxOutputStream *m_output;
bool m_be_order;
// After the page is loaded, the method calls SetPage() to display it.
// Note : you can also use path relative to previously loaded page
// Return value : same as SetPage
- bool LoadPage(const wxString& location);
+ virtual bool LoadPage(const wxString& location);
// Returns full location of opened page
wxString GetOpenedPage() const {return m_OpenedPage;}
// check that the algorithm gave us something reasonable
wxASSERT_MSG( (0 < month) && (month <= 12), _T("invalid month") );
wxASSERT_MSG( (1 <= day) && (day < 32), _T("invalid day") );
- wxASSERT_MSG( (INT_MIN <= year) && (year <= INT_MAX),
- _T("year range overflow") );
// construct Tm from these values
Tm tm;
#endif
return s;
}
- else
+ else
return wxEmptyString;
}
return *this;
}
-wxDataOutputStream& wxDataOutputStream::operator<<(wxString& string)
+wxDataOutputStream& wxDataOutputStream::operator<<(const wxString& string)
{
WriteString(string);
return *this;
bool wxXPMHandler::LoadFile(wxImage *image,
wxInputStream& stream,
- bool verbose, int WXUNUSED(index))
+ bool WXUNUSED(verbose), int WXUNUSED(index))
{
wxXPMDecoder decoder;
else {
// otherwise when it's called for the first time, nIncrement would be 0
// and the array would never be expanded
-#if defined(__VISAGECPP__) && defined(__WXDEBUG__)
- int array_size = ARRAY_DEFAULT_INITIAL_SIZE;
- wxASSERT( array_size != 0 );
-#else
- wxASSERT( ARRAY_DEFAULT_INITIAL_SIZE != 0 );
-#endif
-
// add 50% but not too much
size_t nIncrement = m_nSize < ARRAY_DEFAULT_INITIAL_SIZE
? ARRAY_DEFAULT_INITIAL_SIZE : m_nSize >> 1;
m_isBeingDeleted = TRUE;
MSWDetachWindowMenu();
-
+
// VS: make sure there's no wxFrame with last focus set to us:
for (wxWindow *win = GetParent(); win; win = win->GetParent())
{
return GetEventHandler()->ProcessEvent(event);
#else
+ (void) wParam;
+ (void) lParam;
+
return FALSE;
#endif
}