Merged latest changes from SciTech code base into wxWindows CVS Tree.

Includes updates to remove Watcom compiler warnings and the latest
updates to the wxApplet code.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10461 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kendall Bennett
2001-06-08 19:37:56 +00:00
parent 3febf6845f
commit 38caaa61b1
16 changed files with 387 additions and 144 deletions

View File

@@ -34,7 +34,10 @@
#define __WX_APPLET_H #define __WX_APPLET_H
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/applet/window.h" #include "wx/html/htmlwin.h"
// Forward declaration
class wxHtmlAppletWindow;
/*--------------------------- Class Definitions ---------------------------*/ /*--------------------------- Class Definitions ---------------------------*/
@@ -48,18 +51,19 @@ private:
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
protected: protected:
wxHtmlAppletWindow *m_Parent; wxHtmlAppletWindow *m_parent;
// Special handler for background erase messages // Special handler for background erase messages
void OnEraseBackground(wxEraseEvent&); void OnEraseBackground(wxEraseEvent&);
public: public:
// Constructor (called during dynamic creation) // Constructor (called during dynamic creation)
wxApplet() { m_Parent = NULL; } wxApplet() { m_parent = NULL; };
// Psuedo virtual constructor // Psuedo virtual constructor
virtual bool Create( virtual bool Create(
wxHtmlAppletWindow *parent, wxHtmlAppletWindow *parent,
const wxHtmlTag& params,
const wxSize& size, const wxSize& size,
long style = wxTAB_TRAVERSAL | wxNO_BORDER); long style = wxTAB_TRAVERSAL | wxNO_BORDER);
@@ -79,5 +83,7 @@ public:
virtual void OnMessage(wxEvent& msg) = 0; virtual void OnMessage(wxEvent& msg) = 0;
}; };
#endif // __WX_APPLET_H #endif // __WX_APPLET_H

View File

@@ -35,18 +35,46 @@
#include "wx/html/htmlwin.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 // Declare a linked list of wxApplet pointers
class wxApplet;
WX_DECLARE_LIST(wxApplet, wxAppletList); 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: REMARKS:
Defines the class for wxAppletWindow. This class is derived from the Defines the class for wxAppletWindow. This class is derived from the
wxHtmlWindow class and extends it with functionality to handle embedded wxHtmlWindow class and extends it with functionality to handle embedded
@@ -57,15 +85,22 @@ private:
DECLARE_CLASS(wxHtmlAppletWindow); DECLARE_CLASS(wxHtmlAppletWindow);
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
wxIncludePrep *incPreprocessor; // deleted by list it is added too in constructor
protected: protected:
wxAppletList m_AppletList; wxAppletList m_AppletList;
wxHashTable m_Cookies; static wxHashTable m_Cookies;
wxToolBarBase *m_NavBar;
int m_NavBackId;
int m_NavForwardId;
public: public:
// Constructor // Constructor
wxHtmlAppletWindow( wxHtmlAppletWindow(
wxWindow *parent, wxWindow *parent,
wxWindowID id = -1, wxWindowID id = -1,
wxToolBarBase *navBar = NULL,
int navBackId = -1,
int navForwardId = -1,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxHW_SCROLLBAR_AUTO, long style = wxHW_SCROLLBAR_AUTO,
@@ -76,7 +111,9 @@ public:
// Create an instance of an applet based on it's class name // Create an instance of an applet based on it's class name
wxApplet *CreateApplet( wxApplet *CreateApplet(
const wxString& className, const wxString& classId,
const wxString& iName,
const wxHtmlTag &params,
const wxSize& size); const wxSize& size);
// Find an instance of an applet based on it's class name // Find an instance of an applet based on it's class name
@@ -86,10 +123,10 @@ public:
bool RemoveApplet(const wxApplet *applet); bool RemoveApplet(const wxApplet *applet);
// Load a new URL page // Load a new URL page
bool LoadPage(const wxString& hRef); virtual bool LoadPage(const wxString& location);
// Called when users clicked on hypertext link. // 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 // Handles forward navigation within the HTML stack
bool HistoryForward(); bool HistoryForward();
@@ -108,6 +145,13 @@ public:
// Find a cookie of data given it's public name // Find a cookie of data given it's public name
wxObject *FindCookie(const wxString& 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 #endif // __WX_APPLET_WINDOW_H

View File

@@ -28,7 +28,7 @@ public:
virtual bool CanSave() { return FALSE; } virtual bool CanSave() { return FALSE; }
virtual bool Load(wxInputStream& stream, wxXmlDocument& doc); 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; }
}; };
@@ -36,10 +36,10 @@ class WXXMLDLLEXPORT wxXmlIOHandlerWriter : public wxXmlIOHandler
{ {
public: public:
virtual wxXmlIOType GetType() { return wxXML_IO_TEXT_OUTPUT; } 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 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); virtual bool Save(wxOutputStream& stream, const wxXmlDocument& doc);
}; };

View File

@@ -35,6 +35,7 @@
// Include private headers // Include private headers
#include "wx/applet/applet.h" #include "wx/applet/applet.h"
#include "wx/applet/window.h"
/*------------------------- Implementation --------------------------------*/ /*------------------------- Implementation --------------------------------*/
@@ -54,12 +55,13 @@ Psuedo virtual constructor for the wxApplet class.
****************************************************************************/ ****************************************************************************/
bool wxApplet::Create( bool wxApplet::Create(
wxHtmlAppletWindow *parent, wxHtmlAppletWindow *parent,
const wxHtmlTag& ,
const wxSize& size, const wxSize& size,
long style) long style)
{ {
bool ret = wxPanel::Create(parent, -1, wxDefaultPosition, size, style); bool ret = wxPanel::Create(parent, -1, wxDefaultPosition, size, style);
if (ret) { if (ret) {
m_Parent = parent; m_parent = parent;
} }
return ret; return ret;
} }
@@ -70,7 +72,7 @@ Destructor for the wxApplet class.
****************************************************************************/ ****************************************************************************/
wxApplet::~wxApplet() wxApplet::~wxApplet()
{ {
m_Parent->RemoveApplet(this); m_parent->RemoveApplet(this);
} }
/**************************************************************************** /****************************************************************************

View File

@@ -32,9 +32,22 @@
// For compilers that support precompilation // For compilers that support precompilation
#include "wx/wxprec.h" #include "wx/wxprec.h"
#include "wx/html/forcelnk.h"
// Include private headers // Include private headers
#include "wx/applet/applet.h" #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 --------------------------------*/ /*------------------------- Implementation --------------------------------*/
@@ -42,6 +55,8 @@
// sub-classes of wxApplet can reference wxApplet in the event tables // sub-classes of wxApplet can reference wxApplet in the event tables
// that they create as necessary. // that they create as necessary.
BEGIN_EVENT_TABLE(wxHtmlAppletWindow, wxHtmlWindow) BEGIN_EVENT_TABLE(wxHtmlAppletWindow, wxHtmlWindow)
EVT_LOAD_PAGE(wxHtmlAppletWindow::OnLoadPage)
EVT_PAGE_LOADED(wxHtmlAppletWindow::OnPageLoaded)
END_EVENT_TABLE() END_EVENT_TABLE()
// Implement the class functions for wxHtmlAppletWindow // Implement the class functions for wxHtmlAppletWindow
@@ -58,14 +73,37 @@ Constructor for the applet window class.
wxHtmlAppletWindow::wxHtmlAppletWindow( wxHtmlAppletWindow::wxHtmlAppletWindow(
wxWindow *parent, wxWindow *parent,
wxWindowID id, wxWindowID id,
wxToolBarBase *navBar,
int navBackId,
int navForwardId,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxString& name) const wxString& name)
: wxHtmlWindow(parent,id,pos,size,style,name) : wxHtmlWindow(parent,id,pos,size,style,name)
{ {
// Ensure all cookie data is destroyed when window is killed //setup client navbars
m_Cookies.DeleteContents(true); 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 +129,13 @@ created dynamically based on string values embedded in the custom tags of an
HTML page. HTML page.
****************************************************************************/ ****************************************************************************/
wxApplet *wxHtmlAppletWindow::CreateApplet( wxApplet *wxHtmlAppletWindow::CreateApplet(
const wxString& className, const wxString& classId,
const wxString& iName,
const wxHtmlTag& params,
const wxSize& size) 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 // Dynamically create the class instance at runtime
wxClassInfo *info = wxClassInfo::FindClass(className.c_str()); wxClassInfo *info = wxClassInfo::FindClass(classId.c_str());
if (!info) if (!info)
return NULL; return NULL;
wxObject *obj = info->CreateObject(); wxObject *obj = info->CreateObject();
@@ -108,11 +144,11 @@ wxApplet *wxHtmlAppletWindow::CreateApplet(
wxApplet *applet = wxDynamicCast(obj,wxApplet); wxApplet *applet = wxDynamicCast(obj,wxApplet);
if (!applet) if (!applet)
return NULL; return NULL;
if (!applet->Create(this,size)) { if (!applet->Create(this,params,size)) {
delete applet; delete applet;
return NULL; return NULL;
} }
m_AppletList.Append(className,applet); m_AppletList.Append(iName,applet);
return applet; return applet;
} }
@@ -169,11 +205,64 @@ REMARKS:
Remove an applet from the manager. Called during applet destruction Remove an applet from the manager. Called during applet destruction
****************************************************************************/ ****************************************************************************/
bool wxHtmlAppletWindow::LoadPage( 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()) for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
(node->GetData())->OnLinkClicked(hRef); (node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href));
return wxHtmlWindow::LoadPage(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;
} }
/**************************************************************************** /****************************************************************************
@@ -187,9 +276,7 @@ call the LoadPage function above to load the new page and display it.
void wxHtmlAppletWindow::OnLinkClicked( void wxHtmlAppletWindow::OnLinkClicked(
const wxHtmlLinkInfo& link) const wxHtmlLinkInfo& link)
{ {
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) LoadPage(link.GetHref());
(node->GetData())->OnLinkClicked(link);
wxHtmlWindow::LoadPage(link.GetHref());
} }
/**************************************************************************** /****************************************************************************
@@ -202,8 +289,10 @@ bool wxHtmlAppletWindow::HistoryForward()
{ {
if (!HistoryCanForward()) if (!HistoryCanForward())
return false; return false;
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
(node->GetData())->OnHistoryForward(); (node->GetData())->OnHistoryForward();
return wxHtmlWindow::HistoryForward(); return wxHtmlWindow::HistoryForward();
} }
@@ -217,8 +306,10 @@ bool wxHtmlAppletWindow::HistoryBack()
{ {
if (!HistoryCanBack()) if (!HistoryCanBack())
return false; return false;
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
(node->GetData())->OnHistoryBack(); (node->GetData())->OnHistoryBack();
return wxHtmlWindow::HistoryBack(); return wxHtmlWindow::HistoryBack();
} }
@@ -246,14 +337,17 @@ void wxHtmlAppletWindow::SendMessage(
// Process all applets in turn and send them the message // Process all applets in turn and send them the message
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) { for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) {
(node->GetData())->OnMessage(msg); (node->GetData())->OnMessage(msg);
if (!msg.GetSkipped()) if (!msg.GetSkipped()){
wxMessageBox("BREAK");
break; break;
} }
}
} }
/**************************************************************************** /****************************************************************************
PARAMETERS: 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: 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.
@@ -287,7 +381,7 @@ bool wxHtmlAppletWindow::RegisterCookie(
/**************************************************************************** /****************************************************************************
PARAMETERS: PARAMETERS:
msg - wxEvent message to be sent to all wxApplets name - wxString uniq haskey used to remove item from hash
RETURNS: RETURNS:
True if found and deleted, false if not found in table. True if found and deleted, false if not found in table.
@@ -326,6 +420,57 @@ wxObject *wxHtmlAppletWindow::FindCookie(
return m_Cookies.Get(name); 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" #include "wx/html/m_templ.h"
/**************************************************************************** /****************************************************************************
@@ -334,38 +479,62 @@ Implementation for the <embed> HTML tag handler. This handler takes care
of automatically constructing the wxApplet objects of the appropriate of automatically constructing the wxApplet objects of the appropriate
class based on the <embed> tag information. class based on the <embed> tag information.
****************************************************************************/ ****************************************************************************/
TAG_HANDLER_BEGIN(Embed, "EMBED") TAG_HANDLER_BEGIN(wxApplet, "WXAPPLET")
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(tag)
{ {
wxWindow *wnd; wxWindow *wnd;
wxHtmlAppletWindow *appletWindow; wxHtmlAppletWindow *appletWindow;
wxApplet *applet; wxApplet *applet;
wxString classId;
wxString name;
int width, height; int width, height;
int floatPercent = 0;
wnd = m_WParser->GetWindow(); wnd = m_WParser->GetWindow();
if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) != NULL) {
if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) != NULL){
tag.ScanParam("WIDTH", "%i", &width); tag.ScanParam("WIDTH", "%i", &width);
tag.ScanParam("HEIGHT", "%i", &height); tag.ScanParam("HEIGHT", "%i", &height);
if (tag.HasParam("FLOAT")) if (tag.HasParam("CLASSID")){
tag.ScanParam("FLOAT", "%i", &floatPercent); classId = tag.GetParam("CLASSID");
if (tag.HasParam("APPLET")) { if ( classId.IsNull() || classId.Len() == 0 ){
if ((applet = appletWindow->CreateApplet(tag.GetParam("APPLET"), wxSize(width, height))) != NULL) { 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); applet->Show(true);
m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(applet,floatPercent)); m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(applet,0));
} }
else
wxMessageBox("wxApplet error: Could not create:" + classId + "," + name);
} }
else if (tag.HasParam("TEXT")) { else{
// TODO: Somehow get the text returned from this class displayed on the page! 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 false; return false;
} }
TAG_HANDLER_END(Embed) TAG_HANDLER_END(wxApplet)
TAGS_MODULE_BEGIN(Embed) TAGS_MODULE_BEGIN(wxApplet)
TAGS_MODULE_ADD(Embed) TAGS_MODULE_ADD(wxApplet)
TAGS_MODULE_END(Embed) TAGS_MODULE_END(wxApplet)
// This is our little forcelink hack.
FORCE_LINK(loadpage)

View File

@@ -26,9 +26,12 @@ static const char KW_FIXED[] = { ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\
static const char KW_ID[] = { ASCII_I, ASCII_D, '\0' }; 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_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' }; static const char KW_IDREFS[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
static const char KW_IGNORE[] = { ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; /* Remove compiler warnings for not using when XML_DTD is not defined */
static const char KW_IMPLIED[] = { ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; #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_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_NDATA[] = { ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\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_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' }; static const char KW_NMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' };

View File

@@ -3,10 +3,17 @@ Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission. See the file copying.txt for copying permission.
*/ */
#undef INVALID_LEAD_CASE
#ifndef IS_INVALID_CHAR #ifndef IS_INVALID_CHAR
#define IS_INVALID_CHAR(enc, ptr, n) (0) #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) \ #define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
case BT_LEAD ## n: \ case BT_LEAD ## n: \
if (end - ptr < n) \ if (end - ptr < n) \
@@ -17,6 +24,7 @@ See the file copying.txt for copying permission.
} \ } \
ptr += n; \ ptr += n; \
break; break;
#endif
#define INVALID_CASES(ptr, nextTokPtr) \ #define INVALID_CASES(ptr, nextTokPtr) \
INVALID_LEAD_CASE(2, ptr, nextTokPtr) \ INVALID_LEAD_CASE(2, ptr, nextTokPtr) \
@@ -304,6 +312,7 @@ int PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *en
{ {
if (ptr == end) if (ptr == end)
return XML_TOK_NONE; return XML_TOK_NONE;
#if !(MINBPC(enc) == 1)
if (MINBPC(enc) > 1) { if (MINBPC(enc) > 1) {
size_t n = end - ptr; size_t n = end - ptr;
if (n & (MINBPC(enc) - 1)) { if (n & (MINBPC(enc) - 1)) {
@@ -313,6 +322,7 @@ int PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *en
end = ptr + n; end = ptr + n;
} }
} }
#endif
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
case BT_RSQB: case BT_RSQB:
ptr += MINBPC(enc); ptr += MINBPC(enc);
@@ -783,6 +793,7 @@ int PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
{ {
if (ptr == end) if (ptr == end)
return XML_TOK_NONE; return XML_TOK_NONE;
#if !(MINBPC(enc) == 1)
if (MINBPC(enc) > 1) { if (MINBPC(enc) > 1) {
size_t n = end - ptr; size_t n = end - ptr;
if (n & (MINBPC(enc) - 1)) { if (n & (MINBPC(enc) - 1)) {
@@ -792,6 +803,7 @@ int PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
end = ptr + n; end = ptr + n;
} }
} }
#endif
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
case BT_LT: case BT_LT:
return PREFIX(scanLt)(enc, ptr + MINBPC(enc), end, nextTokPtr); return PREFIX(scanLt)(enc, ptr + MINBPC(enc), end, nextTokPtr);
@@ -971,6 +983,7 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
int tok; int tok;
if (ptr == end) if (ptr == end)
return XML_TOK_NONE; return XML_TOK_NONE;
#if !(MINBPC(enc) == 1)
if (MINBPC(enc) > 1) { if (MINBPC(enc) > 1) {
size_t n = end - ptr; size_t n = end - ptr;
if (n & (MINBPC(enc) - 1)) { if (n & (MINBPC(enc) - 1)) {
@@ -980,6 +993,7 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
end = ptr + n; end = ptr + n;
} }
} }
#endif
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
case BT_QUOT: case BT_QUOT:
return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr); return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr);
@@ -1086,6 +1100,7 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
return XML_TOK_DECL_CLOSE; return XML_TOK_DECL_CLOSE;
case BT_NUM: case BT_NUM:
return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr); return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr);
#ifdef XML_MIN_SIZE
#define LEAD_CASE(n) \ #define LEAD_CASE(n) \
case BT_LEAD ## n: \ case BT_LEAD ## n: \
if (end - ptr < n) \ if (end - ptr < n) \
@@ -1102,6 +1117,14 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
} \ } \
*nextTokPtr = ptr; \ *nextTokPtr = ptr; \
return XML_TOK_INVALID; 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) LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
#undef LEAD_CASE #undef LEAD_CASE
case BT_NMSTRT: case BT_NMSTRT:
@@ -1119,6 +1142,7 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
ptr += MINBPC(enc); ptr += MINBPC(enc);
break; break;
case BT_NONASCII: case BT_NONASCII:
#ifdef XML_MIN_SIZE
if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) {
ptr += MINBPC(enc); ptr += MINBPC(enc);
tok = XML_TOK_NAME; tok = XML_TOK_NAME;
@@ -1129,6 +1153,7 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
tok = XML_TOK_NMTOKEN; tok = XML_TOK_NMTOKEN;
break; break;
} }
#endif
/* fall through */ /* fall through */
default: default:
*nextTokPtr = ptr; *nextTokPtr = ptr;

View File

@@ -87,7 +87,7 @@ static void StartElementHnd(void *userData, const char *name, const char **atts)
ctx->lastAsText = NULL; 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;

View File

@@ -603,9 +603,9 @@ wxColour wxXmlResourceHandler::GetColour(const wxString& param)
return wxNullColour; return wxNullColour;
} }
return wxColour((tmp & 0xFF0000) >> 16 , return wxColour((unsigned char) ((tmp & 0xFF0000) >> 16) ,
(tmp & 0x00FF00) >> 8, (unsigned char) ((tmp & 0x00FF00) >> 8),
(tmp & 0x0000FF)); (unsigned char) ((tmp & 0x0000FF)));
} }

View File

@@ -62,7 +62,7 @@ public:
void WriteString(const wxString& string); void WriteString(const wxString& string);
wxDataOutputStream& operator<<(const wxChar *string); wxDataOutputStream& operator<<(const wxChar *string);
wxDataOutputStream& operator<<(wxString& string); wxDataOutputStream& operator<<(const wxString& string);
wxDataOutputStream& operator<<(wxInt8 c); wxDataOutputStream& operator<<(wxInt8 c);
wxDataOutputStream& operator<<(wxInt16 i); wxDataOutputStream& operator<<(wxInt16 i);
wxDataOutputStream& operator<<(wxInt32 i); wxDataOutputStream& operator<<(wxInt32 i);

View File

@@ -72,7 +72,7 @@ public:
// After the page is loaded, the method calls SetPage() to display it. // After the page is loaded, the method calls SetPage() to display it.
// Note : you can also use path relative to previously loaded page // Note : you can also use path relative to previously loaded page
// Return value : same as SetPage // Return value : same as SetPage
bool LoadPage(const wxString& location); virtual bool LoadPage(const wxString& location);
// Returns full location of opened page // Returns full location of opened page
wxString GetOpenedPage() const {return m_OpenedPage;} wxString GetOpenedPage() const {return m_OpenedPage;}

View File

@@ -1330,8 +1330,6 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const
// check that the algorithm gave us something reasonable // check that the algorithm gave us something reasonable
wxASSERT_MSG( (0 < month) && (month <= 12), _T("invalid month") ); wxASSERT_MSG( (0 < month) && (month <= 12), _T("invalid month") );
wxASSERT_MSG( (1 <= day) && (day < 32), _T("invalid day") ); 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 // construct Tm from these values
Tm tm; Tm tm;

View File

@@ -237,7 +237,7 @@ wxDataOutputStream& wxDataOutputStream::operator<<(const wxChar *string)
return *this; return *this;
} }
wxDataOutputStream& wxDataOutputStream::operator<<(wxString& string) wxDataOutputStream& wxDataOutputStream::operator<<(const wxString& string)
{ {
WriteString(string); WriteString(string);
return *this; return *this;

View File

@@ -96,7 +96,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxXPMHandler,wxImageHandler)
bool wxXPMHandler::LoadFile(wxImage *image, bool wxXPMHandler::LoadFile(wxImage *image,
wxInputStream& stream, wxInputStream& stream,
bool verbose, int WXUNUSED(index)) bool WXUNUSED(verbose), int WXUNUSED(index))
{ {
wxXPMDecoder decoder; wxXPMDecoder decoder;

View File

@@ -1879,13 +1879,6 @@ void wxArrayString::Grow()
else { else {
// otherwise when it's called for the first time, nIncrement would be 0 // otherwise when it's called for the first time, nIncrement would be 0
// and the array would never be expanded // 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 // add 50% but not too much
size_t nIncrement = m_nSize < ARRAY_DEFAULT_INITIAL_SIZE size_t nIncrement = m_nSize < ARRAY_DEFAULT_INITIAL_SIZE
? ARRAY_DEFAULT_INITIAL_SIZE : m_nSize >> 1; ? ARRAY_DEFAULT_INITIAL_SIZE : m_nSize >> 1;

View File

@@ -3461,6 +3461,9 @@ bool wxWindow::HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam)
return GetEventHandler()->ProcessEvent(event); return GetEventHandler()->ProcessEvent(event);
#else #else
(void) wParam;
(void) lParam;
return FALSE; return FALSE;
#endif #endif
} }