Merges from Scitech Branch (George Davison):
Added wxDisplayChangedEvent and triggering in MSW, when display mode changes this event gets triggered. I don't know what should happen with other OS's since I am not familiar with how they handle mode changes. Watcome Version 11 now compiles with wide character support. Fixed watcom warnings in html/htmlwin.h imagbmp.h listctrl.h imagbmp.cpp quantize.cpp strconv.cpp variant.cpp dirctrlg.cpp treectlg.cpp m_style.cpp fontenum.cpp listctrl.cpp ole\dataobj.cpp textctrl.cpp window.cpp xml.cpp msw/setup.h with watcom version 11 it now compiles with wide character support. xrc/xml.cpp fixed memory leak and compile warnings git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14057 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
|
||||
// Forward declaration
|
||||
class wxHtmlAppletWindow;
|
||||
|
||||
class wxAppletEvent;
|
||||
/*--------------------------- Class Definitions ---------------------------*/
|
||||
|
||||
/****************************************************************************
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
virtual void OnHistoryBack() = 0;
|
||||
|
||||
// Handle messages from the wxAppletManager and other applets
|
||||
virtual void OnMessage(wxEvent& msg) = 0;
|
||||
virtual void OnMessage(wxAppletEvent& msg) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -30,57 +30,98 @@
|
||||
#ifndef __WX_ECHOVAR_H
|
||||
#define __WX_ECHOVAR_H
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/hash.h"
|
||||
|
||||
/*--------------------------- Class Definitions ---------------------------*/
|
||||
|
||||
/****************************************************************************
|
||||
RETURNS:
|
||||
The string value of the variable
|
||||
|
||||
PARAMETERS:
|
||||
parms - Optional parameter string passed from parm= field in HTML
|
||||
|
||||
REMARKS:
|
||||
To create new variables for the #echo HTML preprocessing directives
|
||||
you need to derive classes from wxEchoVariable and override the
|
||||
pure virtual GetValue function. However this should not be done directly
|
||||
but by using the BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros
|
||||
|
||||
SEE ALSO:
|
||||
wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE
|
||||
****************************************************************************/
|
||||
typedef wxString (*wxEchoVariableGetValueFn)(const char *parms);
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
wxEchoVariable class Definition
|
||||
****************************************************************************/
|
||||
class wxEchoVariable : public wxObject {
|
||||
private:
|
||||
DECLARE_ABSTRACT_CLASS(wxEchoVariable);
|
||||
protected:
|
||||
const wxChar *m_varName;
|
||||
wxEchoVariableGetValueFn m_getValueFn;
|
||||
static wxEchoVariable *sm_first;
|
||||
wxEchoVariable *m_next;
|
||||
static wxHashTable *sm_varTable;
|
||||
|
||||
static inline wxEchoVariable *wxEchoVariable::FindVariable(const wxChar *varName);
|
||||
|
||||
public:
|
||||
wxEchoVariable() : wxObject() {}
|
||||
~wxEchoVariable() {}
|
||||
// Constructor to create the echo variable and register the class
|
||||
wxEchoVariable(
|
||||
const char *varName,
|
||||
wxEchoVariableGetValueFn getValueFn);
|
||||
|
||||
// Member variable access functions
|
||||
const wxChar *GetClassName() const { return m_varName; }
|
||||
wxEchoVariableGetValueFn GetValueFn() const { return m_getValueFn; }
|
||||
static const wxEchoVariable* GetFirst() { return sm_first; }
|
||||
const wxEchoVariable* GetNext() const { return m_next; }
|
||||
|
||||
/****************************************************************************
|
||||
RETURNS:
|
||||
The boolean value of the variable
|
||||
// Static functions to retrieve any variable avaliable
|
||||
static wxString GetValue(const wxChar *varName,const wxChar *parms = NULL);
|
||||
static bool Exists(const wxChar *varName);
|
||||
|
||||
PARAMETERS:
|
||||
parms - Optional parameter string passed from parm= field in HTML
|
||||
// Initializes parent pointers and hash table for fast searching.
|
||||
static void Initialize();
|
||||
|
||||
REMARKS:
|
||||
To create new variables for the #echo HTML preprocessing directives
|
||||
you need to derive classes from wxEchoVariable and override the
|
||||
pure virtual GetValue function. However this should not be done directly
|
||||
but by using the BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros
|
||||
|
||||
SEE ALSO:
|
||||
wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE
|
||||
****************************************************************************/
|
||||
virtual wxString GetValue(const char *parms = NULL) const = 0;
|
||||
|
||||
|
||||
public:
|
||||
// static function to retrieve any variable avaliable
|
||||
static wxString FindValue(const wxString &cls, const char *parms = NULL);
|
||||
// Cleans up hash table used for fast searching.
|
||||
static void CleanUp();
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
class - Name of class for echo variable to find
|
||||
|
||||
RETURNS:
|
||||
Pointer to the echo variable class
|
||||
|
||||
REMARKS:
|
||||
Inline helper function to find the echo variable from it's class name.
|
||||
****************************************************************************/
|
||||
inline wxEchoVariable *wxEchoVariable::FindVariable(
|
||||
const wxChar *varName)
|
||||
{
|
||||
if (sm_varTable)
|
||||
return (wxEchoVariable*)sm_varTable->Get(varName);
|
||||
else {
|
||||
wxEchoVariable *info = sm_first;
|
||||
while (info) {
|
||||
if (info->m_varName && wxStrcmp(info->m_varName, varName) == 0)
|
||||
return info;
|
||||
info = info->m_next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------- MACROS --------------------------------*/
|
||||
|
||||
#define ECHO_PARM (_BEV_parm)
|
||||
#define BEGIN_ECHO_VARIABLE(name) \
|
||||
class wxEchoVariable##name : public wxEchoVariable { \
|
||||
private: \
|
||||
DECLARE_DYNAMIC_CLASS(wxEchoVariable##name##); \
|
||||
public: \
|
||||
wxEchoVariable##name##() : wxEchoVariable() {} \
|
||||
virtual wxString GetValue(const char *parms = NULL) const; \
|
||||
}; \
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxEchoVariable##name##, wxEchoVariable); \
|
||||
wxString wxEchoVariable##name :: GetValue(const char *parms) const { \
|
||||
wxString wxEchoVariableFn##name(const char *parms); \
|
||||
wxEchoVariable wxEchoVariable##name(#name,wxEchoVariableFn##name); \
|
||||
wxString wxEchoVariableFn##name(const char *parms) { \
|
||||
wxString _BEV_parm = wxString(parms);
|
||||
|
||||
#define END_ECHO_VARIABLE(returnval) \
|
||||
|
@@ -30,57 +30,98 @@
|
||||
#ifndef __WX_IFELSEVAR_H
|
||||
#define __WX_IFELSEVAR_H
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/hash.h"
|
||||
|
||||
/*--------------------------- Class Definitions ---------------------------*/
|
||||
|
||||
/****************************************************************************
|
||||
RETURNS:
|
||||
The boolean value of the variable
|
||||
|
||||
REMARKS:
|
||||
This class is used to create variables for the HTML preprocessor #if, #else,
|
||||
and #endif directives.
|
||||
To create new variables for the #if, #else and #endif HTML preprocessing
|
||||
blocks you need to derive classes from wxIfElseVariable and override the
|
||||
pure virtual GetValue function. However this should not be done directly
|
||||
but by using the BEGIN_IFELSE_VARIABLE and END_IFELSE_VARIABLE macros
|
||||
|
||||
SEE ALSO:
|
||||
wxIfElsePrep
|
||||
wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE
|
||||
****************************************************************************/
|
||||
typedef bool (*wxIfElseVariableGetValueFn)();
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
wxIfElseVariable class Definition
|
||||
****************************************************************************/
|
||||
class wxIfElseVariable : public wxObject {
|
||||
private:
|
||||
DECLARE_ABSTRACT_CLASS(wxIfElseVariable);
|
||||
protected:
|
||||
const wxChar *m_varName;
|
||||
wxIfElseVariableGetValueFn m_getValueFn;
|
||||
static wxIfElseVariable *sm_first;
|
||||
wxIfElseVariable *m_next;
|
||||
static wxHashTable *sm_varTable;
|
||||
bool forced;
|
||||
bool forceVal;
|
||||
|
||||
static inline wxIfElseVariable *wxIfElseVariable::FindVariable(const wxChar *varName);
|
||||
|
||||
public:
|
||||
wxIfElseVariable() : wxObject() {}
|
||||
~wxIfElseVariable() {}
|
||||
// Constructor to create the echo variable and register the class
|
||||
wxIfElseVariable(
|
||||
const char *varName,
|
||||
wxIfElseVariableGetValueFn getValueFn);
|
||||
|
||||
// Member variable access functions
|
||||
const wxChar *GetClassName() const { return m_varName; }
|
||||
wxIfElseVariableGetValueFn GetValueFn() const { return m_getValueFn; }
|
||||
static const wxIfElseVariable* GetFirst() { return sm_first; }
|
||||
const wxIfElseVariable* GetNext() const { return m_next; }
|
||||
|
||||
/****************************************************************************
|
||||
RETURNS:
|
||||
The boolean value of the variable
|
||||
// Static functions to retrieve any variable avaliable
|
||||
static bool GetValue(const wxChar *varName);
|
||||
static bool Exists(const wxChar *varName);
|
||||
static void Force(const wxChar *varName, bool val);
|
||||
|
||||
REMARKS:
|
||||
To create new variables for the #if, #else and #endif HTML preprocessing
|
||||
blocks you need to derive classes from wxIfElseVariable and override the
|
||||
pure virtual GetValue function. However this should not be done directly
|
||||
but by using the BEGIN_IFELSE_VARIABLE and END_IFELSE_VARIABLE macros
|
||||
// Initializes parent pointers and hash table for fast searching.
|
||||
static void Initialize();
|
||||
|
||||
SEE ALSO:
|
||||
wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE
|
||||
****************************************************************************/
|
||||
virtual bool GetValue() const = 0;
|
||||
|
||||
|
||||
public:
|
||||
// static function to retrieve any variable avaliable
|
||||
static bool FindValue(const wxString &cls);
|
||||
// Cleans up hash table used for fast searching.
|
||||
static void CleanUp();
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
class - Name of class for echo variable to find
|
||||
|
||||
RETURNS:
|
||||
Pointer to the echo variable class
|
||||
|
||||
REMARKS:
|
||||
Inline helper function to find the echo variable from it's class name.
|
||||
****************************************************************************/
|
||||
inline wxIfElseVariable *wxIfElseVariable::FindVariable(
|
||||
const wxChar *varName)
|
||||
{
|
||||
if (sm_varTable)
|
||||
return (wxIfElseVariable*)sm_varTable->Get(varName);
|
||||
else {
|
||||
wxIfElseVariable *info = sm_first;
|
||||
while (info) {
|
||||
if (info->m_varName && wxStrcmp(info->m_varName, varName) == 0)
|
||||
return info;
|
||||
info = info->m_next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------- MACROS --------------------------------*/
|
||||
|
||||
#define BEGIN_IFELSE_VARIABLE(name) \
|
||||
class wxIfElseVariable##name : public wxIfElseVariable { \
|
||||
private: \
|
||||
DECLARE_DYNAMIC_CLASS(wxIfElseVariable##name##); \
|
||||
public: \
|
||||
wxIfElseVariable##name##() : wxIfElseVariable() {} \
|
||||
virtual bool GetValue() const; \
|
||||
}; \
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxIfElseVariable##name##, wxIfElseVariable); \
|
||||
bool wxIfElseVariable##name :: GetValue() const {
|
||||
bool wxIfElseVariableFn##name(); \
|
||||
wxIfElseVariable wxIfElseVariable##name(#name,wxIfElseVariableFn##name); \
|
||||
bool wxIfElseVariableFn##name() { \
|
||||
|
||||
#define END_IFELSE_VARIABLE(returnval) \
|
||||
return returnval; \
|
||||
|
@@ -68,14 +68,15 @@ public:
|
||||
// Destructor
|
||||
~wxLoadPageEvent() {}
|
||||
|
||||
// Clone Virtual
|
||||
virtual wxEvent *Clone() const { return new wxLoadPageEvent(m_hRef, m_htmlWindow); }
|
||||
|
||||
// Return the hmtl window for the load page operation
|
||||
wxHtmlAppletWindow *GetHtmlWindow() { return m_htmlWindow; };
|
||||
|
||||
// Get the hRef string for the load page operation
|
||||
const wxString & GetHRef() { return m_hRef; };
|
||||
|
||||
// Copy constructor for the object
|
||||
void CopyObject(wxObject& obj) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -97,8 +98,10 @@ public:
|
||||
// Destructor
|
||||
~wxPageLoadedEvent() {}
|
||||
|
||||
// Copy constructor for the object
|
||||
void CopyObject(wxObject& obj) const;
|
||||
// Clone Virtual
|
||||
virtual wxEvent *Clone() const {
|
||||
return new wxPageLoadedEvent(); }
|
||||
|
||||
};
|
||||
|
||||
// Define the macro to create our event type
|
||||
|
@@ -32,17 +32,19 @@
|
||||
// Forward declaration
|
||||
class wxHtmlAppletWindow;
|
||||
|
||||
#include "wx/event.h"
|
||||
|
||||
/*--------------------------- Class Definitions ---------------------------*/
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Defines the abstract base class for wxQlet objects.
|
||||
Defines the abstract base class for wxPlugIn objects.
|
||||
****************************************************************************/
|
||||
class wxPlugIn : public wxObject {
|
||||
class wxPlugIn : public wxEvtHandler {
|
||||
private:
|
||||
wxHtmlAppletWindow *m_parent;
|
||||
DECLARE_ABSTRACT_CLASS(wxPlugIn);
|
||||
|
||||
wxHtmlAppletWindow *m_parent;
|
||||
public:
|
||||
// Constructor (called during dynamic creation)
|
||||
wxPlugIn() { m_parent = NULL; };
|
||||
@@ -50,8 +52,12 @@ public:
|
||||
// Psuedo virtual constructor
|
||||
virtual bool Create(wxHtmlAppletWindow *parent);
|
||||
|
||||
// Function that actually executes the main plugin code
|
||||
virtual void Run(const wxString& cmdLine);
|
||||
|
||||
// Virtual destructor
|
||||
virtual ~wxPlugIn();
|
||||
};
|
||||
|
||||
#endif // __WX_PLUGIN_H
|
||||
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#ifndef __WX_PREPECHO_H
|
||||
#define __WX_PREPECHO_H
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/html/htmlproc.h"
|
||||
|
||||
/*--------------------------- Class Definitions ---------------------------*/
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#ifndef __WX_PREPIFELSE_H
|
||||
#define __WX_PREPIFELSE_H
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/html/htmlproc.h"
|
||||
|
||||
/*--------------------------- Class Definitions ---------------------------*/
|
||||
|
@@ -30,8 +30,13 @@
|
||||
#ifndef __WX_PREPINCLUDE_H
|
||||
#define __WX_PREPINCLUDE_H
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/html/htmlproc.h"
|
||||
|
||||
/*------------------------------- Prototypes ------------------------------*/
|
||||
|
||||
class wxFileSystem;
|
||||
|
||||
/*--------------------------- Class Definitions ---------------------------*/
|
||||
|
||||
/****************************************************************************
|
||||
|
@@ -46,6 +46,21 @@ class wxToolBarBase;
|
||||
WX_DECLARE_LIST(wxApplet, wxAppletList);
|
||||
|
||||
/*--------------------------- Class Definitions ---------------------------*/
|
||||
class wxAppletEvent {
|
||||
protected:
|
||||
int m_id;
|
||||
wxObject *m_eventObject;
|
||||
public:
|
||||
wxAppletEvent(int id) { m_eventObject=NULL; m_id = id; }
|
||||
|
||||
int GetId() const { return m_id; }
|
||||
void SetId(int Id) { m_id = Id; }
|
||||
|
||||
wxObject *GetEventObject() const { return m_eventObject; }
|
||||
void SetEventObject(wxObject *obj) { m_eventObject = obj; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
@@ -53,16 +68,21 @@ Defines the class for virtual-link data types
|
||||
****************************************************************************/
|
||||
class VirtualData : public wxObject {
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(VirtualData);
|
||||
|
||||
protected:
|
||||
wxString m_name;
|
||||
wxString m_group;
|
||||
wxString m_href;
|
||||
wxString m_plugIn;
|
||||
|
||||
public:
|
||||
// Ctors
|
||||
VirtualData(
|
||||
wxString& name,
|
||||
wxString& group,
|
||||
wxString& href );
|
||||
wxString& href,
|
||||
wxString& plugin );
|
||||
|
||||
VirtualData();
|
||||
|
||||
@@ -70,11 +90,14 @@ public:
|
||||
wxString GetName(){ return m_name;};
|
||||
wxString GetGroup(){ return m_group;};
|
||||
wxString GetHref(){ return m_href;};
|
||||
wxString GetPlugIn(){ return m_plugIn;};
|
||||
|
||||
// Sets
|
||||
void SetName (wxString& s){ m_name = s; };
|
||||
void SetGroup(wxString& s){ m_group = s; };
|
||||
void SetHref (wxString& s){ m_href = s; };
|
||||
void SetPlugIn (wxString& s){ m_plugIn = s;};
|
||||
void EmptyPlugIn () { m_plugIn = "";};
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -98,7 +121,7 @@ protected:
|
||||
wxToolBarBase *m_NavBar;
|
||||
int m_NavBackId;
|
||||
int m_NavForwardId;
|
||||
wxPalette m_globalPalette;
|
||||
wxString m_openedlast;
|
||||
|
||||
// Override this so we can do proper palette management!!
|
||||
virtual void OnDraw(wxDC& dc);
|
||||
@@ -114,8 +137,7 @@ public:
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxHW_SCROLLBAR_AUTO,
|
||||
const wxString& name = "htmlAppletWindow",
|
||||
const wxPalette& globalPalette = wxNullPalette);
|
||||
const wxString& name = "htmlAppletWindow");
|
||||
|
||||
// Destructor
|
||||
~wxHtmlAppletWindow();
|
||||
@@ -128,7 +150,7 @@ public:
|
||||
const wxSize& size);
|
||||
|
||||
// Create an instance of an Qlet based on it's class name
|
||||
bool CreatePlugIn(const wxString& classId );
|
||||
bool CreatePlugIn(const wxString& classId,const wxString& cmdLine = "");
|
||||
|
||||
// Find an instance of an applet based on it's class name
|
||||
wxApplet *FindApplet(const wxString& className);
|
||||
@@ -157,7 +179,7 @@ public:
|
||||
void SetNavBar(wxToolBarBase *navBar);
|
||||
|
||||
// Broadcast a message to all applets on the page
|
||||
void SendMessage(wxEvent& msg);
|
||||
void SendAppletMessage(wxAppletEvent& msg);
|
||||
|
||||
// Register a cookie of data in the applet manager
|
||||
static bool RegisterCookie(const wxString& name,wxObject *cookie);
|
||||
@@ -184,25 +206,7 @@ public:
|
||||
// Tries to lock the mutex. If it can't, returns immediately with false.
|
||||
bool TryLock();
|
||||
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Defines the class for AppetProcess
|
||||
***************************************************************************/
|
||||
class AppletProcess : public wxProcess {
|
||||
public:
|
||||
AppletProcess(
|
||||
wxWindow *parent)
|
||||
: wxProcess(parent)
|
||||
{
|
||||
}
|
||||
|
||||
// instead of overriding this virtual function we might as well process the
|
||||
// event from it in the frame class - this might be more convenient in some
|
||||
// cases
|
||||
virtual void OnTerminate(int pid, int status);
|
||||
|
||||
wxString GetLastOpened() { return m_openedlast; }
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -213,7 +217,7 @@ class wxHtmlAppletCell : public wxHtmlCell
|
||||
{
|
||||
public:
|
||||
wxHtmlAppletCell(wxWindow *wnd, int w = 0);
|
||||
~wxHtmlAppletCell() { m_Wnd->Destroy(); }
|
||||
virtual ~wxHtmlAppletCell();
|
||||
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
|
||||
virtual void DrawInvisible(wxDC& dc, int x, int y);
|
||||
virtual void Layout(int w);
|
||||
@@ -223,6 +227,5 @@ protected:
|
||||
// width float is used in adjustWidth (it is in percents)
|
||||
};
|
||||
|
||||
|
||||
#endif // __WX_APPLET_WINDOW_H
|
||||
|
||||
|
@@ -26,9 +26,6 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
// Include private headers
|
||||
#include "wx/applet/applet.h"
|
||||
#include "wx/applet/window.h"
|
||||
|
@@ -26,18 +26,6 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/process.h"
|
||||
#include "wx/spawnbrowser.h"
|
||||
#include "wx/html/forcelnk.h"
|
||||
|
||||
// crt
|
||||
#ifdef __WXMSW__
|
||||
#include <process.h> // spawnl()
|
||||
#endif
|
||||
|
||||
// Include private headers
|
||||
#include "wx/applet/applet.h"
|
||||
#include "wx/applet/window.h"
|
||||
@@ -49,6 +37,22 @@
|
||||
#include "wx/applet/prepecho.h"
|
||||
#include "wx/applet/prepifelse.h"
|
||||
|
||||
// wxWindows headers
|
||||
|
||||
// Kind of pointless to use precompiled headers when this is the only
|
||||
// file in this lib that would need them.
|
||||
#include "wx/defs.h"
|
||||
#include "wx/spawnbrowser.h"
|
||||
#include "wx/html/forcelnk.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/tbarbase.h"
|
||||
|
||||
// crt
|
||||
#ifdef __WXMSW__
|
||||
#include <process.h> // spawnl()
|
||||
#endif
|
||||
|
||||
/*---------------------------- Global variables ---------------------------*/
|
||||
|
||||
wxHashTable wxHtmlAppletWindow::m_Cookies;
|
||||
@@ -66,6 +70,9 @@ END_EVENT_TABLE()
|
||||
// Implement the class functions for wxHtmlAppletWindow
|
||||
IMPLEMENT_CLASS(wxHtmlAppletWindow, wxHtmlWindow);
|
||||
|
||||
// Implement the dynamic class so it can be constructed dynamically
|
||||
IMPLEMENT_DYNAMIC_CLASS(VirtualData, wxObject);
|
||||
|
||||
// Define the wxAppletList implementation
|
||||
#include "wx/listimpl.cpp"
|
||||
WX_DEFINE_LIST(wxAppletList);
|
||||
@@ -83,9 +90,8 @@ wxHtmlAppletWindow::wxHtmlAppletWindow(
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
const wxPalette& globalPalette)
|
||||
: wxHtmlWindow(parent,id,pos,size,style,name), m_globalPalette(globalPalette)
|
||||
const wxString& name)
|
||||
: wxHtmlWindow(parent,id,pos,size,style,name), m_AppletList(wxKEY_STRING)
|
||||
{
|
||||
// Init our locks
|
||||
UnLock();
|
||||
@@ -105,22 +111,13 @@ wxHtmlAppletWindow::wxHtmlAppletWindow(
|
||||
m_NavBackId = navBackId;
|
||||
m_NavForwardId = navForwardId;
|
||||
|
||||
|
||||
// Set the key_type for applets
|
||||
m_AppletList = wxAppletList(wxKEY_STRING);
|
||||
|
||||
// Add HTML preprocessors
|
||||
// deleting preprocessors is done by the code within the window
|
||||
|
||||
incPreprocessor = new wxIncludePrep(); // #include preprocessor
|
||||
incPreprocessor->ChangeDirectory(m_FS); // give it access to our filesys object
|
||||
|
||||
wxEchoPrep * echoPreprocessor = new wxEchoPrep(); // #echo preprocessor
|
||||
wxIfElsePrep * ifPreprocessor = new wxIfElsePrep();
|
||||
|
||||
this->AddProcessor(incPreprocessor);
|
||||
this->AddProcessor(echoPreprocessor);
|
||||
this->AddProcessor(ifPreprocessor);
|
||||
this->AddProcessor(new wxEchoPrep());
|
||||
this->AddProcessor(new wxIfElsePrep());
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -131,24 +128,15 @@ wxHtmlAppletWindow::~wxHtmlAppletWindow()
|
||||
{
|
||||
}
|
||||
|
||||
#include "scitech.h"
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
dc - wxDC object to draw on
|
||||
|
||||
REMARKS:
|
||||
This function handles drawing the HTML applet window. Because the standard
|
||||
wxWindows classes don't properly handle palette management, we add code
|
||||
in here to properly select the global palette that we use for all drawing
|
||||
into the DC before we allow the regular wxWindows code to finish the
|
||||
drawing process.
|
||||
****************************************************************************/
|
||||
void wxHtmlAppletWindow::OnDraw(
|
||||
wxDC& dc)
|
||||
{
|
||||
// TODO: Only do this for <= 8bpp modes!
|
||||
dc.SetPalette(m_globalPalette);
|
||||
wxHtmlWindow::OnDraw(dc);
|
||||
}
|
||||
|
||||
@@ -173,12 +161,7 @@ wxApplet *wxHtmlAppletWindow::CreateApplet(
|
||||
const wxSize& size)
|
||||
{
|
||||
// Dynamically create the class instance at runtime
|
||||
wxClassInfo *info = wxClassInfo::FindClass(classId.c_str());
|
||||
if (!info)
|
||||
return NULL;
|
||||
wxObject *obj = info->CreateObject();
|
||||
if (!obj)
|
||||
return NULL;
|
||||
wxObject *obj = wxCreateDynamicObject(classId.c_str());
|
||||
wxApplet *applet = wxDynamicCast(obj,wxApplet);
|
||||
if (!applet)
|
||||
return NULL;
|
||||
@@ -212,15 +195,12 @@ created dynamically based on string values embedded in the custom tags of an
|
||||
HTML page.
|
||||
****************************************************************************/
|
||||
bool wxHtmlAppletWindow::CreatePlugIn(
|
||||
const wxString& classId )
|
||||
const wxString& classId,
|
||||
const wxString& cmdLine)
|
||||
{
|
||||
// Dynamically create the class instance at runtime
|
||||
wxClassInfo *info = wxClassInfo::FindClass(classId.c_str());
|
||||
if (!info)
|
||||
return false;
|
||||
wxObject *obj = info->CreateObject();
|
||||
if (!obj)
|
||||
return false;
|
||||
// Dynamically create the class instance at runtime, execute it
|
||||
// and then destroy it.
|
||||
wxObject *obj = wxCreateDynamicObject(classId.c_str());
|
||||
wxPlugIn *plugIn = wxDynamicCast(obj,wxPlugIn);
|
||||
if (!plugIn)
|
||||
return false;
|
||||
@@ -228,6 +208,8 @@ bool wxHtmlAppletWindow::CreatePlugIn(
|
||||
delete plugIn;
|
||||
return false;
|
||||
}
|
||||
plugIn->Run(cmdLine);
|
||||
delete plugIn;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -293,22 +275,53 @@ bool wxHtmlAppletWindow::LoadPage(
|
||||
wxString cmdValue = link.AfterFirst('=');
|
||||
|
||||
// Launches the default Internet browser for the system.
|
||||
if(!(cmd.CmpNoCase("?EXTERNAL"))){
|
||||
if(!(cmd.CmpNoCase("?EXTERNAL"))) {
|
||||
return wxSpawnBrowser(this, cmdValue.c_str());
|
||||
}
|
||||
|
||||
// Launches an external program on the system.
|
||||
if (!(cmd.CmpNoCase("?EXECUTE"))){
|
||||
int code = spawnl( P_NOWAIT, cmdValue , NULL );
|
||||
return (!code);
|
||||
if (!(cmd.CmpNoCase("?EXECUTE"))) {
|
||||
int waitflag = P_NOWAIT;
|
||||
bool ret;
|
||||
wxString currentdir;
|
||||
wxString filename, path, ext;
|
||||
|
||||
// Parse the params sent to the execute command. For now the only
|
||||
// parm is "wait". wait will cause spawn wait, default is nowait.
|
||||
// Since we only need one param for now I am not going to make this
|
||||
// any smater then it needs to be. If we need more params later i'll
|
||||
// fix it.
|
||||
int i = cmdValue.Find('(');
|
||||
if (i != -1) {
|
||||
wxString param = cmdValue.AfterFirst('(');
|
||||
cmdValue.Truncate(i);
|
||||
if (!param.CmpNoCase("wait)"))
|
||||
waitflag = P_WAIT;
|
||||
}
|
||||
|
||||
currentdir = wxGetCwd();
|
||||
//we don't want to change the path of the virtual file system so we have to use these
|
||||
//functions rather than the filesystem
|
||||
wxSplitPath(cmdValue, &path, &filename, &ext);
|
||||
if (path.CmpNoCase("") != 0) wxSetWorkingDirectory(path);
|
||||
|
||||
ret = !spawnl( waitflag, cmdValue , NULL );
|
||||
//HACK should use wxExecute
|
||||
//ret = wxExecute(filename, bool sync = FALSE, wxProcess *callback = NULL)
|
||||
wxSetWorkingDirectory(currentdir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Looks for a href in a variable stored as a cookie. The href can be
|
||||
// changed on the fly.
|
||||
if (!(cmd.CmpNoCase("?VIRTUAL"))){
|
||||
VirtualData& temp = *((VirtualData*)FindCookie(cmdValue));
|
||||
if (&temp) {
|
||||
href = temp.GetHref();
|
||||
wxObject *obj = FindCookie(cmdValue);
|
||||
VirtualData *virtData = wxDynamicCast(obj,VirtualData);
|
||||
if (virtData) {
|
||||
// recurse and loadpage, just in case the link is like another
|
||||
// ? link
|
||||
return LoadPage(virtData->GetHref());
|
||||
}
|
||||
else {
|
||||
#ifdef CHECKED
|
||||
@@ -320,16 +333,32 @@ bool wxHtmlAppletWindow::LoadPage(
|
||||
|
||||
// This launches a qlet - It is like an applet but is more generic in that it
|
||||
// can be of any wxWin type so it then has the freedom to do more stuff.
|
||||
if (!(cmd.CmpNoCase("?WXAPPLET"))){
|
||||
if (!cmdValue.IsNull()){
|
||||
if (!CreatePlugIn(cmdValue)){
|
||||
if (!(cmd.CmpNoCase("?WXPLUGIN"))){
|
||||
if (!cmdValue.IsNull()) {
|
||||
// TODO: We are going to need to add code to parse the command line
|
||||
// parameters string in here in the future...
|
||||
wxString cmdLine = link.AfterFirst('(');
|
||||
cmdLine = cmdLine.BeforeLast(')');
|
||||
if (!CreatePlugIn(cmdValue,cmdLine)) {
|
||||
#ifdef CHECKED
|
||||
wxLogError(_T("Launch Applet ERROR: '%s' does not exist."), cmdValue.c_str());
|
||||
wxLogError(_T("Launch PlugIn ERROR: '%s' does not exist."), cmdValue.c_str());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// This used in a link or href will take you back in the history.
|
||||
if (!(cmd.CmpNoCase("?BACK"))){
|
||||
HistoryBack();
|
||||
return true;
|
||||
}
|
||||
|
||||
// This used in a link or href will take you forward in the history
|
||||
if (!(cmd.CmpNoCase("?FORWARD"))){
|
||||
HistoryForward();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Inform all the applets that the new page is being loaded
|
||||
@@ -337,6 +366,7 @@ bool wxHtmlAppletWindow::LoadPage(
|
||||
(node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href));
|
||||
Show(false);
|
||||
|
||||
m_openedlast = href;
|
||||
bool stat = wxHtmlWindow::LoadPage(href);
|
||||
Show(true);
|
||||
|
||||
@@ -437,24 +467,16 @@ to all other applets on the current page. This is the primary form of
|
||||
communication between applets on the page if they need to inform each
|
||||
other of internal information.
|
||||
|
||||
Note that the event handling terminates as soon as the first wxApplet
|
||||
handles the event. If the event should be handled by all wxApplet's,
|
||||
the event handlers for the applets should not reset the wxEvent::Skip()
|
||||
value (ie: by default it is true).
|
||||
****************************************************************************/
|
||||
void wxHtmlAppletWindow::SendMessage(
|
||||
wxEvent& msg)
|
||||
void wxHtmlAppletWindow::SendAppletMessage(
|
||||
wxAppletEvent& msg)
|
||||
{
|
||||
// Preset the skip flag
|
||||
msg.Skip();
|
||||
// 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);
|
||||
if (!msg.GetSkipped()){
|
||||
wxMessageBox("BREAK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -546,10 +568,10 @@ void wxHtmlAppletWindow::OnLoadPage(
|
||||
wxLoadPageEvent &event)
|
||||
{
|
||||
// Test the mutex lock.
|
||||
if (!(IsLocked())){
|
||||
if (!(IsLocked())) {
|
||||
Lock();
|
||||
if (event.GetHtmlWindow() == this){
|
||||
if (LoadPage(event.GetHRef())){
|
||||
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.
|
||||
@@ -602,11 +624,13 @@ VirtualData is used to store information on the virtual links.
|
||||
VirtualData::VirtualData(
|
||||
wxString& name,
|
||||
wxString& group,
|
||||
wxString& href )
|
||||
wxString& href,
|
||||
wxString& plugin )
|
||||
{
|
||||
m_name = name;
|
||||
m_group = group;
|
||||
m_href = href;
|
||||
m_plugIn = plugin;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -621,18 +645,6 @@ VirtualData::VirtualData()
|
||||
m_href.Empty();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
REMARKS:
|
||||
****************************************************************************/
|
||||
void AppletProcess::OnTerminate(
|
||||
int,
|
||||
int )
|
||||
{
|
||||
// we're not needed any more
|
||||
delete this;
|
||||
}
|
||||
|
||||
#include "wx/html/m_templ.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -652,63 +664,66 @@ TAG_HANDLER_PROC(tag)
|
||||
wxString name;
|
||||
int width, height;
|
||||
|
||||
// Get access to our wxHtmlAppletWindow class
|
||||
wnd = m_WParser->GetWindow();
|
||||
if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) == NULL)
|
||||
return false;
|
||||
|
||||
if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) != NULL){
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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.
|
||||
// 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);
|
||||
}
|
||||
|
||||
return false;
|
||||
// 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)
|
||||
@@ -717,16 +732,20 @@ TAGS_MODULE_BEGIN(wxApplet)
|
||||
TAGS_MODULE_ADD(wxApplet)
|
||||
TAGS_MODULE_END(wxApplet)
|
||||
|
||||
/*********************************************************************************
|
||||
wxHtmlAppletCell
|
||||
*********************************************************************************/
|
||||
wxHtmlAppletCell::wxHtmlAppletCell(wxWindow *wnd, int align) : wxHtmlCell()
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Constructor for the HTML cell class to store our wxApplet windows in
|
||||
the 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;
|
||||
@@ -739,59 +758,76 @@ wxHtmlAppletCell::wxHtmlAppletCell(wxWindow *wnd, int align) : wxHtmlCell()
|
||||
m_Descent = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
SetCanLiveOnPagebreak(FALSE);
|
||||
}
|
||||
|
||||
|
||||
void wxHtmlAppletCell::Draw(wxDC& WXUNUSED(dc), int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(view_y1), int WXUNUSED(view_y2))
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Implementation for the HTML cell class to store our wxApplet windows in
|
||||
the HTML page to be rendered by wxHTML.
|
||||
****************************************************************************/
|
||||
wxHtmlAppletCell::~wxHtmlAppletCell()
|
||||
{
|
||||
int absx = 0, absy = 0, stx, sty;
|
||||
wxHtmlCell *c = this;
|
||||
delete m_Wnd;
|
||||
}
|
||||
|
||||
while (c)
|
||||
{
|
||||
/****************************************************************************
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxHtmlAppletCell::DrawInvisible(wxDC& WXUNUSED(dc), int WXUNUSED(x), int WXUNUSED(y))
|
||||
/****************************************************************************
|
||||
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;
|
||||
int absx = 0, absy = 0, stx, sty;
|
||||
wxHtmlCell *c = this;
|
||||
|
||||
while (c)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxHtmlAppletCell::Layout(int w)
|
||||
/****************************************************************************
|
||||
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)
|
||||
|
||||
|
@@ -28,64 +28,105 @@
|
||||
****************************************************************************/
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/applet/echovar.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/html/forcelnk.h"
|
||||
|
||||
// Include private headers
|
||||
#include "wx/applet/echovar.h"
|
||||
|
||||
/*---------------------------- Global variables ---------------------------*/
|
||||
|
||||
// Implement the dynamic class so it can be constructed dynamically
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxEchoVariable, wxObject);
|
||||
static wxEchoVariable *wxEchoVariable::sm_first = NULL;
|
||||
static wxHashTable *wxEchoVariable::sm_varTable = NULL;
|
||||
|
||||
/*----------------------------- Implementation ----------------------------*/
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
cls - The String name of the class
|
||||
parms - an optional parameter string to pass off to the child class
|
||||
|
||||
RETURNS:
|
||||
The string value of the variable
|
||||
varName - The String name of the class
|
||||
getValueFn - Pointer to the function that returns the echo variable value
|
||||
|
||||
REMARKS:
|
||||
To grab a value from any class which is derived from this one simple use this
|
||||
static function and the name of the derived class to get the value.
|
||||
This static function is the only function implemented in this base class
|
||||
basically this is provided for an easier method of grabbing a variable. We
|
||||
keep all the dynamic object handling in this class to avoid confusing the source
|
||||
where these are used.
|
||||
|
||||
SEE ALSO:
|
||||
wxEchoPrep
|
||||
Constructor for the wxEchoVariable class that self registers itself with
|
||||
the list of all echo variables when the static class instance is created
|
||||
at program init time (remember all the constructors get called before
|
||||
the main program function!).
|
||||
****************************************************************************/
|
||||
static wxString wxEchoVariable::FindValue(
|
||||
const wxString &cls,
|
||||
const char *parms)
|
||||
wxEchoVariable::wxEchoVariable(
|
||||
const char *varName,
|
||||
wxEchoVariableGetValueFn getValueFn)
|
||||
{
|
||||
wxObject * tmpclass;
|
||||
|
||||
tmpclass = wxCreateDynamicObject(wxString("wxEchoVariable") + cls);
|
||||
if (!tmpclass) {
|
||||
#ifdef CHECKED
|
||||
wxMessageBox(wxString("wxHTML #echo error: Class not found (") + cls + wxString(")."),"Error",wxICON_ERROR);
|
||||
#endif
|
||||
return wxString("");
|
||||
}
|
||||
|
||||
wxEchoVariable * ev = wxDynamicCast(tmpclass, wxEchoVariable);
|
||||
|
||||
if (!ev) {
|
||||
#ifdef CHECKED
|
||||
wxMessageBox(wxString("wxHTML #echo error: Class is not a valid echo variable (") + cls + wxString(")."),"Error",wxICON_ERROR);
|
||||
#endif
|
||||
return wxString("");
|
||||
}
|
||||
|
||||
return ev->GetValue(parms);
|
||||
m_varName = varName;
|
||||
m_getValueFn = getValueFn;
|
||||
m_next = sm_first;
|
||||
sm_first = this;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Initializes parent pointers and hash table for fast searching for echo
|
||||
variables.
|
||||
****************************************************************************/
|
||||
void wxEchoVariable::Initialize()
|
||||
{
|
||||
wxEchoVariable::sm_varTable = new wxHashTable(wxKEY_STRING);
|
||||
|
||||
// Index all class infos by their class name
|
||||
wxEchoVariable *info = sm_first;
|
||||
while (info) {
|
||||
if (info->m_varName)
|
||||
sm_varTable->Put(info->m_varName, info);
|
||||
info = info->m_next;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Clean up echo variable hash tables on application exit.
|
||||
****************************************************************************/
|
||||
void wxEchoVariable::CleanUp()
|
||||
{
|
||||
delete wxEchoVariable::sm_varTable;
|
||||
wxEchoVariable::sm_varTable = NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
varName - The String name of the class
|
||||
parms - Parameter string for the echo variable
|
||||
|
||||
REMARKS:
|
||||
Constructor for the wxEchoVariable class that self registers itself with
|
||||
the list of all echo variables when the static class instance is created
|
||||
at program init time (remember all the constructors get called before
|
||||
the main program function!).
|
||||
****************************************************************************/
|
||||
wxString wxEchoVariable::GetValue(
|
||||
const wxChar *varName,
|
||||
const wxChar *parms)
|
||||
{
|
||||
wxEchoVariable *info = wxEchoVariable::FindVariable(varName);
|
||||
if (info)
|
||||
return info->m_getValueFn(parms);
|
||||
#ifdef CHECKED
|
||||
wxMessageBox(wxString("wxHTML #echo error: Class is not a valid echo variable (") + varName + wxString(")."),"Error",wxICON_ERROR);
|
||||
#endif
|
||||
return wxString("");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
varName - The String name of the class
|
||||
|
||||
RETURNS:
|
||||
True if the echo variable exists, false if not.
|
||||
****************************************************************************/
|
||||
bool wxEchoVariable::Exists(
|
||||
const wxChar *varName)
|
||||
{
|
||||
return wxEchoVariable::FindVariable(varName) != NULL;
|
||||
}
|
||||
|
||||
/*------------------------ Macro Documentation ---------------------------*/
|
||||
|
||||
@@ -177,4 +218,5 @@ void STRING_ECHO_VARIABLE(
|
||||
wxString string);
|
||||
|
||||
// hack to make this file link
|
||||
FORCE_LINK_ME(echovar)
|
||||
FORCE_LINK_ME(echovar)
|
||||
|
||||
|
@@ -27,61 +27,134 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
#include "wx/html/forcelnk.h"
|
||||
|
||||
// Include private headers
|
||||
#include "wx/applet/ifelsevar.h"
|
||||
|
||||
// wxWindows forcelink macro
|
||||
#include "wx/html/forcelnk.h"
|
||||
#include "wx/msgdlg.h"
|
||||
|
||||
/*---------------------------- Global variables ---------------------------*/
|
||||
|
||||
// Implement the dynamic class so it can be constructed dynamically
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxIfElseVariable, wxObject);
|
||||
static wxIfElseVariable *wxIfElseVariable::sm_first = NULL;
|
||||
static wxHashTable *wxIfElseVariable::sm_varTable = NULL;
|
||||
|
||||
/*----------------------------- Implementation ----------------------------*/
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
cls - The String name of the class
|
||||
|
||||
RETURNS:
|
||||
The boolean value of the variable
|
||||
varName - The String name of the class
|
||||
getValueFn - Pointer to the function that returns the echo variable value
|
||||
|
||||
REMARKS:
|
||||
To grab a value from any class which is derived from this one simple use this
|
||||
static function and the name of the derived class to get the value.
|
||||
This static function is the only function implemented in this base class
|
||||
basically this is provided for an easier method of grabbing a variable. We
|
||||
keep all the dynamic object handling in this class to avoid confusing the source
|
||||
where these are used.
|
||||
|
||||
SEE ALSO:
|
||||
wxIfElsePrep
|
||||
Constructor for the wxIfElseVariable class that self registers itself with
|
||||
the list of all echo variables when the static class instance is created
|
||||
at program init time (remember all the constructors get called before
|
||||
the main program function!).
|
||||
****************************************************************************/
|
||||
static bool wxIfElseVariable::FindValue(
|
||||
const wxString &cls)
|
||||
wxIfElseVariable::wxIfElseVariable(
|
||||
const char *varName,
|
||||
wxIfElseVariableGetValueFn getValueFn)
|
||||
{
|
||||
wxObject * tmpclass;
|
||||
m_varName = varName;
|
||||
m_getValueFn = getValueFn;
|
||||
m_next = sm_first;
|
||||
sm_first = this;
|
||||
}
|
||||
|
||||
tmpclass = wxCreateDynamicObject(wxString("wxIfElseVariable") + cls);
|
||||
if (!tmpclass) {
|
||||
#ifdef CHECKED
|
||||
wxMessageBox(wxString("wxHTML #if error: Class not found (") + cls + wxString(")."),"Error",wxICON_ERROR);
|
||||
#endif
|
||||
return wxString("");
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Initializes parent pointers and hash table for fast searching for echo
|
||||
variables.
|
||||
****************************************************************************/
|
||||
void wxIfElseVariable::Initialize()
|
||||
{
|
||||
wxIfElseVariable::sm_varTable = new wxHashTable(wxKEY_STRING);
|
||||
|
||||
// Index all class infos by their class name
|
||||
wxIfElseVariable *info = sm_first;
|
||||
while (info) {
|
||||
if (info->m_varName)
|
||||
sm_varTable->Put(info->m_varName, info);
|
||||
info = info->m_next;
|
||||
}
|
||||
}
|
||||
|
||||
wxIfElseVariable * ev = wxDynamicCast(tmpclass, wxIfElseVariable);
|
||||
|
||||
if (!ev) {
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Clean up echo variable hash tables on application exit.
|
||||
****************************************************************************/
|
||||
void wxIfElseVariable::CleanUp()
|
||||
{
|
||||
delete wxIfElseVariable::sm_varTable;
|
||||
wxIfElseVariable::sm_varTable = NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
varName - The String name of the class
|
||||
|
||||
REMARKS:
|
||||
Constructor for the wxIfElseVariable class that self registers itself with
|
||||
the list of all ifelse variables when the static class instance is created
|
||||
at program init time (remember all the constructors get called before
|
||||
the main program function!).
|
||||
****************************************************************************/
|
||||
bool wxIfElseVariable::GetValue(
|
||||
const wxChar *varName)
|
||||
{
|
||||
wxIfElseVariable *info = wxIfElseVariable::FindVariable(varName);
|
||||
if (info) {
|
||||
// Return the forced value if the variable has been forced.
|
||||
if (info->forced)
|
||||
return info->forceVal;
|
||||
return info->m_getValueFn();
|
||||
}
|
||||
#ifdef CHECKED
|
||||
wxMessageBox(wxString("wxHTML #if error: Class is not a valid ifelse variable (") + cls + wxString(")."),"Error",wxICON_ERROR);
|
||||
wxMessageBox(wxString("wxHTML #if error: Class is not a valid if else variable (") + varName + wxString(")."),"Error",wxICON_ERROR);
|
||||
#endif
|
||||
return wxString("");
|
||||
}
|
||||
return wxString("");
|
||||
}
|
||||
|
||||
return ev->GetValue();
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
varName - The String name of the class
|
||||
|
||||
RETURNS:
|
||||
True if the if/else variable exists, false if not.
|
||||
****************************************************************************/
|
||||
bool wxIfElseVariable::Exists(
|
||||
const wxChar *varName)
|
||||
{
|
||||
return wxIfElseVariable::FindVariable(varName) != NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
varName - The String name of the class
|
||||
val - Value to force the if/else variable with
|
||||
|
||||
REMARKS:
|
||||
Function to forcibly override the value of an if/else variable for
|
||||
testing purposes. Once the variable has been forced, it will always return
|
||||
the forced value until the application exists.
|
||||
|
||||
NOTE: This is only available when compiled in CHECKED mode.
|
||||
****************************************************************************/
|
||||
void wxIfElseVariable::Force(
|
||||
const wxChar *varName,
|
||||
bool val)
|
||||
{
|
||||
wxIfElseVariable *info = wxIfElseVariable::FindVariable(varName);
|
||||
if (info) {
|
||||
info->forced = true;
|
||||
info->forceVal = val;
|
||||
}
|
||||
else {
|
||||
#ifdef CHECKED
|
||||
wxMessageBox(wxString("wxHTML #if error: Class is not a valid if else variable (") + varName + wxString(")."),"Error",wxICON_ERROR);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------ Macro Documentation ---------------------------*/
|
||||
@@ -155,5 +228,5 @@ void IFELSE_VARIABLE(
|
||||
const char *name,
|
||||
bool state);
|
||||
|
||||
|
||||
FORCE_LINK_ME(ifelsevar)
|
||||
|
||||
|
@@ -26,13 +26,12 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
#include "wx/html/forcelnk.h"
|
||||
|
||||
// Include private headers
|
||||
#include "wx/applet/loadpage.h"
|
||||
|
||||
// wxWindows forcelink macro
|
||||
#include "wx/html/forcelnk.h"
|
||||
|
||||
/*------------------------- Implementation --------------------------------*/
|
||||
|
||||
// Implement the class functions for wxLoadPageEvent
|
||||
@@ -59,20 +58,6 @@ wxLoadPageEvent::wxLoadPageEvent(
|
||||
m_eventType = wxEVT_LOAD_PAGE;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Function to copy the wxLoadPageEvent object
|
||||
****************************************************************************/
|
||||
void wxLoadPageEvent::CopyObject(
|
||||
wxObject& obj_d) const
|
||||
{
|
||||
wxLoadPageEvent *obj = (wxLoadPageEvent*)&obj_d;
|
||||
wxEvent::CopyObject(obj_d);
|
||||
obj->m_hRef = m_hRef;
|
||||
obj->m_htmlWindow = m_htmlWindow;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Constructor for the wxPageLoadedEvent class
|
||||
@@ -82,17 +67,6 @@ wxPageLoadedEvent::wxPageLoadedEvent()
|
||||
m_eventType = wxEVT_LOAD_PAGE;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Function to copy the wxPageLoadedEvent object
|
||||
****************************************************************************/
|
||||
void wxPageLoadedEvent::CopyObject(
|
||||
wxObject& obj_d) const
|
||||
{
|
||||
wxPageLoadedEvent *obj = (wxPageLoadedEvent*)&obj_d;
|
||||
wxEvent::CopyObject(obj_d);
|
||||
}
|
||||
|
||||
// This is out little force link hack
|
||||
FORCE_LINK_ME(loadpage)
|
||||
|
||||
|
@@ -26,9 +26,6 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
// Include private headers
|
||||
#include "wx/applet/plugin.h"
|
||||
#include "wx/applet/window.h"
|
||||
@@ -36,7 +33,7 @@
|
||||
/*------------------------- Implementation --------------------------------*/
|
||||
|
||||
// Implement the abstract class functions
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxPlugIn, wxObject);
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxPlugIn, wxEvtHandler);
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
@@ -57,4 +54,12 @@ wxPlugIn::~wxPlugIn()
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
Destructor for the wxPlugIn class.
|
||||
****************************************************************************/
|
||||
void wxPlugIn::Run(
|
||||
const wxString& WXUNUSED(cmdLine))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -27,16 +27,15 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
#include "wx/html/forcelnk.h"
|
||||
|
||||
// Include private headers
|
||||
#include "wx/applet/prepecho.h"
|
||||
#include "wx/applet/echovar.h"
|
||||
|
||||
/*---------------------------- Global variables ---------------------------*/
|
||||
// Force Link macro
|
||||
#include "wx/html/forcelnk.h"
|
||||
|
||||
// wxWindows headers
|
||||
#include "wx/msgdlg.h"
|
||||
|
||||
/*----------------------------- Implementation ----------------------------*/
|
||||
|
||||
@@ -68,7 +67,6 @@ wxString wxEchoPrep::Process(
|
||||
|
||||
while ((i = (output.Lower()).Find(ft)) != -1) {
|
||||
// Loop until every #echo directive is found
|
||||
|
||||
int n, c, end;
|
||||
wxString cname, parms;
|
||||
wxString tag;
|
||||
@@ -97,7 +95,7 @@ wxString wxEchoPrep::Process(
|
||||
cname = tag.Mid(10, n);
|
||||
|
||||
// grab the value from the class, put it in tag since the data is no longer needed
|
||||
tag = wxEchoVariable::FindValue(cname, NULL);
|
||||
tag = wxEchoVariable::GetValue(cname, NULL);
|
||||
}
|
||||
else {
|
||||
// Find the parms
|
||||
@@ -114,9 +112,7 @@ wxString wxEchoPrep::Process(
|
||||
cname = tag.Mid(10, n);
|
||||
|
||||
// grab the value from the class, put it in tag since the data is no longer needed
|
||||
tag = wxEchoVariable::FindValue(cname, parms.c_str());
|
||||
|
||||
|
||||
tag = wxEchoVariable::GetValue(cname, parms.c_str());
|
||||
}
|
||||
// remove ampersands and <> chars
|
||||
tag.Replace("&", "&");
|
||||
@@ -125,7 +121,6 @@ wxString wxEchoPrep::Process(
|
||||
|
||||
output = (output.Mid(0,i) + tag + output.Mid(i));
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@@ -27,16 +27,16 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
#include "wx/html/forcelnk.h"
|
||||
|
||||
// Include private headers
|
||||
#include "wx/applet/prepifelse.h"
|
||||
#include "wx/applet/ifelsevar.h"
|
||||
#include "wx/applet/echovar.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
/*---------------------------- Global variables ---------------------------*/
|
||||
|
||||
// Force link macro
|
||||
#include "wx/html/forcelnk.h"
|
||||
// wxWindows
|
||||
#include "wx/msgdlg.h"
|
||||
|
||||
/*----------------------------- Implementation ----------------------------*/
|
||||
|
||||
@@ -65,10 +65,56 @@ int ReverseFind(
|
||||
return p;
|
||||
p--;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* {SECRET} */
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
tells if a character is a letter.
|
||||
replace this when wxWindows gets regex library. (without strange licensing
|
||||
restrictions)
|
||||
****************************************************************************/
|
||||
bool IsLetter(
|
||||
char c, bool acceptspace = false)
|
||||
{
|
||||
if (acceptspace && (c == ' ')) return true;
|
||||
if (c >= '0' && c <= '9') return true;
|
||||
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '\"' || c == '\'' );
|
||||
}
|
||||
|
||||
#define IsQuote(c) (c == '\'' || c == '\"')
|
||||
|
||||
/* {SECRET} */
|
||||
/****************************************************************************
|
||||
REMARKS:
|
||||
tells if a character is a letter.
|
||||
replace this when wxWindows gets regex library. (without strange licensing
|
||||
restrictions)
|
||||
****************************************************************************/
|
||||
wxString GetEquals(
|
||||
wxString var,
|
||||
wxString value)
|
||||
{
|
||||
if (!wxEchoVariable::Exists(var)) {
|
||||
// TODO: when we implement the set variable, check for a set variable as well
|
||||
#ifdef CHECKED
|
||||
wxMessageBox(wxString("wxHTML #if\\else error: Variable ") + var + wxString(" not found."),"Error",wxICON_ERROR);
|
||||
#endif
|
||||
return wxString("0"); // false
|
||||
}
|
||||
|
||||
wxString tmp = wxEchoVariable::GetValue(var);
|
||||
|
||||
if (IsQuote( value.GetChar(0) ))
|
||||
value = value.Mid(1);
|
||||
if (IsQuote(value.GetChar(value.Length()-1)))
|
||||
value = value.Mid(0,value.Length()-1);
|
||||
|
||||
if (tmp.CmpNoCase(value) == 0) return wxString("1");
|
||||
return wxString("0");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
str - text of #if statement
|
||||
@@ -77,12 +123,14 @@ RETURNS:
|
||||
true or false depending on how it evaluated
|
||||
|
||||
REMARKS:
|
||||
TODO: rewrite this whole thing using regular expressions when they are done.
|
||||
|
||||
SEE ALSO:
|
||||
wxIfElseVariable
|
||||
****************************************************************************/
|
||||
bool ParseIfStatementValue(wxString &str) {
|
||||
|
||||
bool ParseIfStatementValue(
|
||||
wxString &str)
|
||||
{
|
||||
// Find out if the tag has parenthesis
|
||||
// recursive to parse the text within the parenthesis,
|
||||
// replacing the text with 1 or 0, (hardcoded true or false)
|
||||
@@ -93,7 +141,6 @@ bool ParseIfStatementValue(wxString &str) {
|
||||
int nextbeg, nextend;
|
||||
int parencount = 1, min = b+1;
|
||||
do {
|
||||
|
||||
nextbeg = str.find('(', min);
|
||||
nextend = str.find(')', min);
|
||||
if (nextbeg < nextend && nextbeg != wxString::npos) {
|
||||
@@ -106,9 +153,9 @@ bool ParseIfStatementValue(wxString &str) {
|
||||
}
|
||||
|
||||
if (nextend == wxString::npos) {
|
||||
#ifdef CHECKED
|
||||
#ifdef CHECKED
|
||||
wxMessageBox("wxHTML #if\\else error: Unmatched parenthesis in #if expression.","Error",wxICON_ERROR);
|
||||
#endif
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
// once parencount reaches 0 again we have found our matchin )
|
||||
@@ -124,7 +171,6 @@ bool ParseIfStatementValue(wxString &str) {
|
||||
// Add extra spaces just in case of NOT(VAL)
|
||||
if (val) str = str.Mid(0, b) + " 1" + str.Mid(e+1);
|
||||
else str = str.Mid(0, b) + " 0" + str.Mid(e+1);
|
||||
|
||||
}
|
||||
|
||||
// Remove spaces from left and right
|
||||
@@ -135,6 +181,51 @@ bool ParseIfStatementValue(wxString &str) {
|
||||
// this makes only one special case necessary for each later on
|
||||
str.Replace(" AND ", "&&");
|
||||
str.Replace(" OR ", "||");
|
||||
str.Replace(" EQUALS ", "==");
|
||||
|
||||
// Check for equals statements
|
||||
// == statements are special because they are evaluated as a single block
|
||||
int equ;
|
||||
equ = str.find("==");
|
||||
while (equ != wxString::npos) {
|
||||
int begin, end;
|
||||
int begin2, end2; // ends of words
|
||||
begin = equ-1;
|
||||
end = equ+2;
|
||||
|
||||
// remove spaces, find extents
|
||||
while (end < str.Length() && str.GetChar(end) == ' ')
|
||||
end++;
|
||||
while (begin >= 0 && str.GetChar(begin) == ' ')
|
||||
begin--;
|
||||
end2 = end;
|
||||
begin2 = begin;
|
||||
if (str.GetChar(end2) == '\'' || str.GetChar(end2) == '\"') {
|
||||
end2++;
|
||||
while (end2 < str.Length() && str.GetChar(end2) != '\'' && str.GetChar(end2) != '\"' )
|
||||
end2++;
|
||||
end2++;
|
||||
}
|
||||
else {
|
||||
while (end2 < str.Length() && IsLetter(str.GetChar(end2)))
|
||||
end2++;
|
||||
}
|
||||
while (begin >= 0 && IsLetter(str.GetChar(begin)))
|
||||
begin--;
|
||||
|
||||
if (begin < 0) begin = 0;
|
||||
else begin++;
|
||||
if (end2 >= str.Length()) end2 = str.Length();
|
||||
|
||||
wxString tmpeq = GetEquals(str.Mid(begin, begin2-begin+1), str.Mid(end, end2-end));
|
||||
str = str.Mid(0, begin) + wxString(" ") + tmpeq + wxString(" ") +
|
||||
str.Mid(end2);
|
||||
equ = str.find("==");
|
||||
|
||||
// Remove spaces from left and right
|
||||
str.Trim(false);
|
||||
str.Trim(true);
|
||||
}
|
||||
|
||||
// We use ReverseFind so that the whole left expression gets evaluated agains
|
||||
// the right single item, creating a left -> right evaluation
|
||||
@@ -145,7 +236,7 @@ bool ParseIfStatementValue(wxString &str) {
|
||||
if ( (and != -1) || (or != -1) ) {
|
||||
wxString tag1, tag2;
|
||||
// handle the rightmost first to force left->right evaluation
|
||||
if (and > or) {
|
||||
if ( (and > or) ) {
|
||||
return (
|
||||
ParseIfStatementValue(tag2 = str.Mid(and+2)) &&
|
||||
ParseIfStatementValue(tag1 = str.Mid(0, and)) );
|
||||
@@ -155,7 +246,6 @@ bool ParseIfStatementValue(wxString &str) {
|
||||
ParseIfStatementValue(tag2 = str.Mid(or+2)) ||
|
||||
ParseIfStatementValue(tag1 = str.Mid(0, or)) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// By the time we get to this place in the function we are guarenteed to have a single
|
||||
@@ -175,11 +265,10 @@ bool ParseIfStatementValue(wxString &str) {
|
||||
}
|
||||
|
||||
// now all we have left is the name of the class or a hardcoded 0 or 1
|
||||
|
||||
if (str == "") {
|
||||
#ifdef CHECKED
|
||||
#ifdef CHECKED
|
||||
wxMessageBox("wxHTML #if\\else error: Empty expression in #if\\#elif statement.","Error",wxICON_ERROR);
|
||||
#endif
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -189,7 +278,7 @@ bool ParseIfStatementValue(wxString &str) {
|
||||
if (str == "1") return !notval;
|
||||
|
||||
// Grab the value from the variable class identified by cname
|
||||
bool value = wxIfElseVariable::FindValue(str);
|
||||
bool value = wxIfElseVariable::GetValue(str);
|
||||
if (notval) value = !value;
|
||||
return value;
|
||||
|
||||
@@ -220,7 +309,6 @@ wxString wxIfElsePrep::Process(
|
||||
char ftelse[] = "<!--#else-->";
|
||||
char ftnot[] = "<!--#if not ";
|
||||
char ftnot2[] = "<!--#if !";
|
||||
|
||||
char ftelif[] = "<!--#elif ";
|
||||
|
||||
// make a copy so we can replace text as we go without affecting the original
|
||||
@@ -234,9 +322,9 @@ wxString wxIfElsePrep::Process(
|
||||
e = output.find("-->", b + strlen(ftelif));
|
||||
|
||||
if (e == wxString::npos) {
|
||||
#ifdef CHECKED
|
||||
#ifdef CHECKED
|
||||
wxMessageBox("wxHTML #elif error: Premature end of file while parsing #elif.","Error",wxICON_ERROR);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -259,9 +347,9 @@ wxString wxIfElsePrep::Process(
|
||||
}
|
||||
|
||||
if (nextendif == wxString::npos) {
|
||||
#ifdef CHECKED
|
||||
#ifdef CHECKED
|
||||
wxMessageBox("wxHTML #elif error: Premature end of file before finding #endif.","Error",wxICON_ERROR);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
// once ifcount reaches 0 again we have found our matchin #endif
|
||||
@@ -269,9 +357,9 @@ wxString wxIfElsePrep::Process(
|
||||
|
||||
// If it couldn't be found die gracefully
|
||||
if (nextendif == wxString::npos) {
|
||||
// We already displayed a message, just break all the way out
|
||||
break;
|
||||
}
|
||||
// We already displayed a message, just break all the way out
|
||||
break;
|
||||
}
|
||||
|
||||
int elifsize = e - (b + strlen(ftelif)) + strlen("-->");
|
||||
// Create the #if/else block, removing the #elif code
|
||||
@@ -280,7 +368,6 @@ wxString wxIfElsePrep::Process(
|
||||
output.Mid(b+strlen(ftelif), elifsize+nextendif) +
|
||||
wxString(ftend) +
|
||||
output.Mid(b+strlen(ftelif)+elifsize+nextendif);
|
||||
|
||||
}
|
||||
|
||||
// Parse out the if else blocks themselves
|
||||
@@ -350,4 +437,5 @@ wxString wxIfElsePrep::Process(
|
||||
return output;
|
||||
}
|
||||
|
||||
FORCE_LINK(ifelsevar)
|
||||
FORCE_LINK(ifelsevar)
|
||||
|
||||
|
@@ -27,19 +27,53 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// For compilers that support precompilation
|
||||
#include "wx/wxprec.h"
|
||||
//#include "wx/file.h"
|
||||
#include "wx/filesys.h"
|
||||
// Include private headers
|
||||
#include "wx/applet/prepinclude.h"
|
||||
#include "wx/applet/echovar.h"
|
||||
|
||||
#define RECURSE_LIMIT 50
|
||||
/*---------------------------- Global variables ---------------------------*/
|
||||
|
||||
// wxWindows
|
||||
#include "wx/filesys.h"
|
||||
#include "wx/msgdlg.h"
|
||||
|
||||
/*----------------------------- Implementation ----------------------------*/
|
||||
|
||||
#define RECURSE_LIMIT 50
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
text - text to process for echo variables
|
||||
|
||||
RETURNS:
|
||||
The string containing the processed filename
|
||||
|
||||
REMARKS:
|
||||
This routine searches through the text of the filename for variables contained
|
||||
in % percent signs
|
||||
****************************************************************************/
|
||||
wxString ParseFilename(
|
||||
wxString &text)
|
||||
{
|
||||
int f = 0;
|
||||
int e;
|
||||
while ((f = text.find('%', f)) != wxString::npos) {
|
||||
f++;
|
||||
e = text.find('%', f);
|
||||
#ifdef CHECKED
|
||||
if (e == wxString::npos) {
|
||||
wxMessageBox(wxString("wxHTML #include error: % signs should bracket variable names in file attribute. To use a percent sign in a filename write double percents (%%)."), "Error" ,wxICON_ERROR);
|
||||
return text;
|
||||
}
|
||||
#endif
|
||||
if (e == f)
|
||||
text.replace(f-1, 2, "%");
|
||||
else {
|
||||
wxString varname = text.Mid(f, (e-f));
|
||||
text.replace(f-1, (e-f)+2, wxEchoVariable::GetValue(varname));
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
PARAMETERS:
|
||||
text - HTML to process for include directives
|
||||
@@ -58,8 +92,6 @@ wxString wxIncludePrep::Process(
|
||||
{
|
||||
int i;
|
||||
char ft[] = "<!--#include virtual=";
|
||||
|
||||
|
||||
int openedcount = 0;
|
||||
|
||||
// make a copy so we can replace text as we go without affecting the original
|
||||
@@ -91,7 +123,7 @@ wxString wxIncludePrep::Process(
|
||||
output.Remove(i, n+21+3);
|
||||
|
||||
wxFSFile * file;
|
||||
file = m_FS->OpenFile(fname);
|
||||
file = m_FS->OpenFile(ParseFilename(fname));
|
||||
|
||||
if (!file) {
|
||||
#ifdef CHECKED
|
||||
@@ -112,14 +144,12 @@ wxString wxIncludePrep::Process(
|
||||
} while (c == 256);
|
||||
|
||||
output = (output.Mid(0,i) + tmp + output.Mid(i));
|
||||
|
||||
#ifdef CHECKED
|
||||
#ifdef CHECKED
|
||||
if (openedcount > RECURSE_LIMIT) {
|
||||
wxMessageBox(wxString("wxHTML #include error: More than RECURSE_LIMIT files have been #included you may have a file that is directly or indirectly including itself, causing an endless loop"), "Error" ,wxICON_ERROR);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
openedcount++;
|
||||
delete file;
|
||||
}
|
||||
|
@@ -332,7 +332,7 @@ bool wxXmlDocument::Save(const wxString& filename) const
|
||||
// wxXmlDocument loading routines
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
/*
|
||||
FIXME:
|
||||
- process all elements, including CDATA
|
||||
*/
|
||||
@@ -349,12 +349,12 @@ inline static wxString CharToString(wxMBConv *conv,
|
||||
{
|
||||
size_t nLen = (len != wxSTRING_MAXLEN) ? len :
|
||||
nLen = wxConvUTF8.MB2WC((wchar_t*) NULL, s, 0);
|
||||
|
||||
|
||||
wchar_t *buf = new wchar_t[nLen+1];
|
||||
wxConvUTF8.MB2WC(buf, s, nLen);
|
||||
buf[nLen] = 0;
|
||||
return wxString(buf, *conv, len);
|
||||
delete[] buf;
|
||||
return wxString(buf, *conv, len);
|
||||
}
|
||||
else
|
||||
return wxString(s, len);
|
||||
@@ -473,21 +473,21 @@ static int UnknownEncodingHnd(void * WXUNUSED(encodingHandlerData),
|
||||
char mbBuf[255];
|
||||
wchar_t wcBuf[255];
|
||||
size_t i;
|
||||
|
||||
|
||||
for (i = 0; i < 255; i++)
|
||||
mbBuf[i] = i+1;
|
||||
mbBuf[i] = (char) (i+1);
|
||||
mbBuf[255] = 0;
|
||||
conv.MB2WC(wcBuf, mbBuf, 255);
|
||||
wcBuf[255] = 0;
|
||||
|
||||
|
||||
info->map[0] = 0;
|
||||
for (i = 0; i < 255; i++)
|
||||
info->map[i+1] = (int)wcBuf[i];
|
||||
|
||||
|
||||
info->data = NULL;
|
||||
info->convert = NULL;
|
||||
info->release = NULL;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding)
|
||||
if ( encoding != wxT("UTF-8") && encoding != wxT("utf-8") )
|
||||
ctx.conv = new wxCSConv(encoding);
|
||||
#endif
|
||||
|
||||
|
||||
XML_SetUserData(parser, (void*)&ctx);
|
||||
XML_SetElementHandler(parser, StartElementHnd, EndElementHnd);
|
||||
XML_SetCharacterDataHandler(parser, TextHnd);
|
||||
@@ -542,7 +542,7 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding)
|
||||
if ( ctx.conv )
|
||||
delete ctx.conv;
|
||||
#endif
|
||||
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
@@ -572,7 +572,7 @@ inline static void OutputString(wxOutputStream& stream, const wxString& str,
|
||||
#endif
|
||||
}
|
||||
|
||||
// Same as above, but create entities first.
|
||||
// Same as above, but create entities first.
|
||||
// Translates '<' to "<", '>' to ">" and '&' to "&"
|
||||
static void OutputStringEnt(wxOutputStream& stream, const wxString& str,
|
||||
wxMBConv *convMem, wxMBConv *convFile)
|
||||
@@ -580,25 +580,25 @@ static void OutputStringEnt(wxOutputStream& stream, const wxString& str,
|
||||
wxString buf;
|
||||
size_t i, last, len;
|
||||
wxChar c;
|
||||
|
||||
|
||||
len = str.Len();
|
||||
last = 0;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
c = str.GetChar(i);
|
||||
if (c == wxT('<') || c == wxT('>') ||
|
||||
if (c == wxT('<') || c == wxT('>') ||
|
||||
(c == wxT('&') && str.Mid(i+1, 4) != wxT("amp;")))
|
||||
{
|
||||
OutputString(stream, str.Mid(last, i - last), convMem, convFile);
|
||||
switch (c)
|
||||
{
|
||||
case wxT('<'):
|
||||
case wxT('<'):
|
||||
OutputString(stream, wxT("<"), NULL, NULL);
|
||||
break;
|
||||
case wxT('>'):
|
||||
case wxT('>'):
|
||||
OutputString(stream, wxT(">"), NULL, NULL);
|
||||
break;
|
||||
case wxT('&'):
|
||||
case wxT('&'):
|
||||
OutputString(stream, wxT("&"), NULL, NULL);
|
||||
break;
|
||||
default: break;
|
||||
@@ -628,11 +628,11 @@ static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent,
|
||||
case wxXML_TEXT_NODE:
|
||||
OutputStringEnt(stream, node->GetContent(), convMem, convFile);
|
||||
break;
|
||||
|
||||
|
||||
case wxXML_ELEMENT_NODE:
|
||||
OutputString(stream, wxT("<"), NULL, NULL);
|
||||
OutputString(stream, node->GetName(), NULL, NULL);
|
||||
|
||||
|
||||
prop = node->GetProperties();
|
||||
while (prop)
|
||||
{
|
||||
@@ -642,7 +642,7 @@ static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent,
|
||||
// FIXME - what if prop contains '"'?
|
||||
prop = prop->GetNext();
|
||||
}
|
||||
|
||||
|
||||
if (node->GetChildren())
|
||||
{
|
||||
OutputString(stream, wxT(">"), NULL, NULL);
|
||||
@@ -665,13 +665,13 @@ static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent,
|
||||
else
|
||||
OutputString(stream, wxT("/>"), NULL, NULL);
|
||||
break;
|
||||
|
||||
|
||||
case wxXML_COMMENT_NODE:
|
||||
OutputString(stream, wxT("<!--"), NULL, NULL);
|
||||
OutputString(stream, node->GetContent(), convMem, convFile);
|
||||
OutputString(stream, wxT("-->"), NULL, NULL);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("unsupported node type"));
|
||||
}
|
||||
@@ -681,9 +681,9 @@ bool wxXmlDocument::Save(wxOutputStream& stream) const
|
||||
{
|
||||
if ( !IsOk() )
|
||||
return FALSE;
|
||||
|
||||
|
||||
wxString s;
|
||||
|
||||
|
||||
wxMBConv *convMem = NULL, *convFile = NULL;
|
||||
#if wxUSE_UNICODE
|
||||
convFile = new wxCSConv(GetFileEncoding());
|
||||
@@ -694,18 +694,18 @@ bool wxXmlDocument::Save(wxOutputStream& stream) const
|
||||
convMem = new wxCSConv(GetEncoding());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
s.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"),
|
||||
GetVersion().c_str(), GetFileEncoding().c_str());
|
||||
OutputString(stream, s, NULL, NULL);
|
||||
|
||||
|
||||
OutputNode(stream, GetRoot(), 0, convMem, convFile);
|
||||
OutputString(stream, wxT("\n"), NULL, NULL);
|
||||
|
||||
|
||||
if ( convFile )
|
||||
delete convFile;
|
||||
if ( convMem )
|
||||
delete convMem;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user