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:
Kendall Bennett
2002-02-07 18:46:31 +00:00
parent 952ae1e88b
commit 574c939ef1
46 changed files with 1131 additions and 633 deletions

View File

@@ -34,7 +34,7 @@
// Forward declaration // Forward declaration
class wxHtmlAppletWindow; class wxHtmlAppletWindow;
class wxAppletEvent;
/*--------------------------- Class Definitions ---------------------------*/ /*--------------------------- Class Definitions ---------------------------*/
/**************************************************************************** /****************************************************************************
@@ -76,7 +76,7 @@ public:
virtual void OnHistoryBack() = 0; virtual void OnHistoryBack() = 0;
// Handle messages from the wxAppletManager and other applets // Handle messages from the wxAppletManager and other applets
virtual void OnMessage(wxEvent& msg) = 0; virtual void OnMessage(wxAppletEvent& msg) = 0;
}; };

View File

@@ -30,23 +30,14 @@
#ifndef __WX_ECHOVAR_H #ifndef __WX_ECHOVAR_H
#define __WX_ECHOVAR_H #define __WX_ECHOVAR_H
#include "wx/object.h"
#include "wx/hash.h"
/*--------------------------- Class Definitions ---------------------------*/ /*--------------------------- Class Definitions ---------------------------*/
/****************************************************************************
REMARKS:
wxEchoVariable class Definition
****************************************************************************/
class wxEchoVariable : public wxObject {
private:
DECLARE_ABSTRACT_CLASS(wxEchoVariable);
public:
wxEchoVariable() : wxObject() {}
~wxEchoVariable() {}
/**************************************************************************** /****************************************************************************
RETURNS: RETURNS:
The boolean value of the variable The string value of the variable
PARAMETERS: PARAMETERS:
parms - Optional parameter string passed from parm= field in HTML parms - Optional parameter string passed from parm= field in HTML
@@ -60,27 +51,77 @@ public:
SEE ALSO: SEE ALSO:
wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE
****************************************************************************/ ****************************************************************************/
virtual wxString GetValue(const char *parms = NULL) const = 0; typedef wxString (*wxEchoVariableGetValueFn)(const char *parms);
/****************************************************************************
REMARKS:
wxEchoVariable class Definition
****************************************************************************/
class wxEchoVariable : public wxObject {
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: public:
// static function to retrieve any variable avaliable // Constructor to create the echo variable and register the class
static wxString FindValue(const wxString &cls, const char *parms = NULL); 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; }
// Static functions to retrieve any variable avaliable
static wxString GetValue(const wxChar *varName,const wxChar *parms = NULL);
static bool Exists(const wxChar *varName);
// Initializes parent pointers and hash table for fast searching.
static void Initialize();
// 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 --------------------------------*/ /*--------------------------------- MACROS --------------------------------*/
#define ECHO_PARM (_BEV_parm)
#define BEGIN_ECHO_VARIABLE(name) \ #define BEGIN_ECHO_VARIABLE(name) \
class wxEchoVariable##name : public wxEchoVariable { \ wxString wxEchoVariableFn##name(const char *parms); \
private: \ wxEchoVariable wxEchoVariable##name(#name,wxEchoVariableFn##name); \
DECLARE_DYNAMIC_CLASS(wxEchoVariable##name##); \ wxString wxEchoVariableFn##name(const char *parms) { \
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 _BEV_parm = wxString(parms); wxString _BEV_parm = wxString(parms);
#define END_ECHO_VARIABLE(returnval) \ #define END_ECHO_VARIABLE(returnval) \

View File

@@ -30,24 +30,11 @@
#ifndef __WX_IFELSEVAR_H #ifndef __WX_IFELSEVAR_H
#define __WX_IFELSEVAR_H #define __WX_IFELSEVAR_H
#include "wx/object.h"
#include "wx/hash.h"
/*--------------------------- Class Definitions ---------------------------*/ /*--------------------------- Class Definitions ---------------------------*/
/****************************************************************************
REMARKS:
This class is used to create variables for the HTML preprocessor #if, #else,
and #endif directives.
SEE ALSO:
wxIfElsePrep
****************************************************************************/
class wxIfElseVariable : public wxObject {
private:
DECLARE_ABSTRACT_CLASS(wxIfElseVariable);
public:
wxIfElseVariable() : wxObject() {}
~wxIfElseVariable() {}
/**************************************************************************** /****************************************************************************
RETURNS: RETURNS:
The boolean value of the variable The boolean value of the variable
@@ -61,26 +48,80 @@ public:
SEE ALSO: SEE ALSO:
wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE
****************************************************************************/ ****************************************************************************/
virtual bool GetValue() const = 0; typedef bool (*wxIfElseVariableGetValueFn)();
/****************************************************************************
REMARKS:
wxIfElseVariable class Definition
****************************************************************************/
class wxIfElseVariable : public wxObject {
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: public:
// static function to retrieve any variable avaliable // Constructor to create the echo variable and register the class
static bool FindValue(const wxString &cls); 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; }
// 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);
// Initializes parent pointers and hash table for fast searching.
static void Initialize();
// 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 --------------------------------*/ /*--------------------------------- MACROS --------------------------------*/
#define BEGIN_IFELSE_VARIABLE(name) \ #define BEGIN_IFELSE_VARIABLE(name) \
class wxIfElseVariable##name : public wxIfElseVariable { \ bool wxIfElseVariableFn##name(); \
private: \ wxIfElseVariable wxIfElseVariable##name(#name,wxIfElseVariableFn##name); \
DECLARE_DYNAMIC_CLASS(wxIfElseVariable##name##); \ bool wxIfElseVariableFn##name() { \
public: \
wxIfElseVariable##name##() : wxIfElseVariable() {} \
virtual bool GetValue() const; \
}; \
IMPLEMENT_DYNAMIC_CLASS(wxIfElseVariable##name##, wxIfElseVariable); \
bool wxIfElseVariable##name :: GetValue() const {
#define END_IFELSE_VARIABLE(returnval) \ #define END_IFELSE_VARIABLE(returnval) \
return returnval; \ return returnval; \

View File

@@ -68,14 +68,15 @@ public:
// Destructor // Destructor
~wxLoadPageEvent() {} ~wxLoadPageEvent() {}
// Clone Virtual
virtual wxEvent *Clone() const { return new wxLoadPageEvent(m_hRef, m_htmlWindow); }
// Return the hmtl window for the load page operation // Return the hmtl window for the load page operation
wxHtmlAppletWindow *GetHtmlWindow() { return m_htmlWindow; }; wxHtmlAppletWindow *GetHtmlWindow() { return m_htmlWindow; };
// Get the hRef string for the load page operation // Get the hRef string for the load page operation
const wxString & GetHRef() { return m_hRef; }; const wxString & GetHRef() { return m_hRef; };
// Copy constructor for the object
void CopyObject(wxObject& obj) const;
}; };
@@ -97,8 +98,10 @@ public:
// Destructor // Destructor
~wxPageLoadedEvent() {} ~wxPageLoadedEvent() {}
// Copy constructor for the object // Clone Virtual
void CopyObject(wxObject& obj) const; virtual wxEvent *Clone() const {
return new wxPageLoadedEvent(); }
}; };
// Define the macro to create our event type // Define the macro to create our event type

View File

@@ -32,17 +32,19 @@
// Forward declaration // Forward declaration
class wxHtmlAppletWindow; class wxHtmlAppletWindow;
#include "wx/event.h"
/*--------------------------- Class Definitions ---------------------------*/ /*--------------------------- Class Definitions ---------------------------*/
/**************************************************************************** /****************************************************************************
REMARKS: 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: private:
wxHtmlAppletWindow *m_parent;
DECLARE_ABSTRACT_CLASS(wxPlugIn); DECLARE_ABSTRACT_CLASS(wxPlugIn);
wxHtmlAppletWindow *m_parent;
public: public:
// Constructor (called during dynamic creation) // Constructor (called during dynamic creation)
wxPlugIn() { m_parent = NULL; }; wxPlugIn() { m_parent = NULL; };
@@ -50,8 +52,12 @@ public:
// Psuedo virtual constructor // Psuedo virtual constructor
virtual bool Create(wxHtmlAppletWindow *parent); virtual bool Create(wxHtmlAppletWindow *parent);
// Function that actually executes the main plugin code
virtual void Run(const wxString& cmdLine);
// Virtual destructor // Virtual destructor
virtual ~wxPlugIn(); virtual ~wxPlugIn();
}; };
#endif // __WX_PLUGIN_H #endif // __WX_PLUGIN_H

View File

@@ -30,6 +30,7 @@
#ifndef __WX_PREPECHO_H #ifndef __WX_PREPECHO_H
#define __WX_PREPECHO_H #define __WX_PREPECHO_H
#include "wx/object.h"
#include "wx/html/htmlproc.h" #include "wx/html/htmlproc.h"
/*--------------------------- Class Definitions ---------------------------*/ /*--------------------------- Class Definitions ---------------------------*/

View File

@@ -30,6 +30,7 @@
#ifndef __WX_PREPIFELSE_H #ifndef __WX_PREPIFELSE_H
#define __WX_PREPIFELSE_H #define __WX_PREPIFELSE_H
#include "wx/object.h"
#include "wx/html/htmlproc.h" #include "wx/html/htmlproc.h"
/*--------------------------- Class Definitions ---------------------------*/ /*--------------------------- Class Definitions ---------------------------*/

View File

@@ -30,8 +30,13 @@
#ifndef __WX_PREPINCLUDE_H #ifndef __WX_PREPINCLUDE_H
#define __WX_PREPINCLUDE_H #define __WX_PREPINCLUDE_H
#include "wx/object.h"
#include "wx/html/htmlproc.h" #include "wx/html/htmlproc.h"
/*------------------------------- Prototypes ------------------------------*/
class wxFileSystem;
/*--------------------------- Class Definitions ---------------------------*/ /*--------------------------- Class Definitions ---------------------------*/
/**************************************************************************** /****************************************************************************

View File

@@ -46,6 +46,21 @@ class wxToolBarBase;
WX_DECLARE_LIST(wxApplet, wxAppletList); WX_DECLARE_LIST(wxApplet, wxAppletList);
/*--------------------------- Class Definitions ---------------------------*/ /*--------------------------- 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: REMARKS:
@@ -53,16 +68,21 @@ Defines the class for virtual-link data types
****************************************************************************/ ****************************************************************************/
class VirtualData : public wxObject { class VirtualData : public wxObject {
private: private:
DECLARE_DYNAMIC_CLASS(VirtualData);
protected:
wxString m_name; wxString m_name;
wxString m_group; wxString m_group;
wxString m_href; wxString m_href;
wxString m_plugIn;
public: public:
// Ctors // Ctors
VirtualData( VirtualData(
wxString& name, wxString& name,
wxString& group, wxString& group,
wxString& href ); wxString& href,
wxString& plugin );
VirtualData(); VirtualData();
@@ -70,11 +90,14 @@ public:
wxString GetName(){ return m_name;}; wxString GetName(){ return m_name;};
wxString GetGroup(){ return m_group;}; wxString GetGroup(){ return m_group;};
wxString GetHref(){ return m_href;}; wxString GetHref(){ return m_href;};
wxString GetPlugIn(){ return m_plugIn;};
// Sets // Sets
void SetName (wxString& s){ m_name = s; }; void SetName (wxString& s){ m_name = s; };
void SetGroup(wxString& s){ m_group = s; }; void SetGroup(wxString& s){ m_group = s; };
void SetHref (wxString& s){ m_href = 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; wxToolBarBase *m_NavBar;
int m_NavBackId; int m_NavBackId;
int m_NavForwardId; int m_NavForwardId;
wxPalette m_globalPalette; wxString m_openedlast;
// Override this so we can do proper palette management!! // Override this so we can do proper palette management!!
virtual void OnDraw(wxDC& dc); virtual void OnDraw(wxDC& dc);
@@ -114,8 +137,7 @@ public:
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,
const wxString& name = "htmlAppletWindow", const wxString& name = "htmlAppletWindow");
const wxPalette& globalPalette = wxNullPalette);
// Destructor // Destructor
~wxHtmlAppletWindow(); ~wxHtmlAppletWindow();
@@ -128,7 +150,7 @@ public:
const wxSize& size); const wxSize& size);
// Create an instance of an Qlet based on it's class name // 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 // Find an instance of an applet based on it's class name
wxApplet *FindApplet(const wxString& className); wxApplet *FindApplet(const wxString& className);
@@ -157,7 +179,7 @@ public:
void SetNavBar(wxToolBarBase *navBar); void SetNavBar(wxToolBarBase *navBar);
// Broadcast a message to all applets on the page // 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 // Register a cookie of data in the applet manager
static bool RegisterCookie(const wxString& name,wxObject *cookie); 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. // Tries to lock the mutex. If it can't, returns immediately with false.
bool TryLock(); bool TryLock();
}; wxString GetLastOpened() { return m_openedlast; }
/****************************************************************************
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);
}; };
/**************************************************************************** /****************************************************************************
@@ -213,7 +217,7 @@ class wxHtmlAppletCell : public wxHtmlCell
{ {
public: public:
wxHtmlAppletCell(wxWindow *wnd, int w = 0); 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 Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
virtual void DrawInvisible(wxDC& dc, int x, int y); virtual void DrawInvisible(wxDC& dc, int x, int y);
virtual void Layout(int w); virtual void Layout(int w);
@@ -223,6 +227,5 @@ protected:
// width float is used in adjustWidth (it is in percents) // width float is used in adjustWidth (it is in percents)
}; };
#endif // __WX_APPLET_WINDOW_H #endif // __WX_APPLET_WINDOW_H

View File

@@ -26,9 +26,6 @@
* *
****************************************************************************/ ****************************************************************************/
// For compilers that support precompilation
#include "wx/wxprec.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/window.h"

View File

@@ -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 private headers
#include "wx/applet/applet.h" #include "wx/applet/applet.h"
#include "wx/applet/window.h" #include "wx/applet/window.h"
@@ -49,6 +37,22 @@
#include "wx/applet/prepecho.h" #include "wx/applet/prepecho.h"
#include "wx/applet/prepifelse.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 ---------------------------*/ /*---------------------------- Global variables ---------------------------*/
wxHashTable wxHtmlAppletWindow::m_Cookies; wxHashTable wxHtmlAppletWindow::m_Cookies;
@@ -66,6 +70,9 @@ END_EVENT_TABLE()
// Implement the class functions for wxHtmlAppletWindow // Implement the class functions for wxHtmlAppletWindow
IMPLEMENT_CLASS(wxHtmlAppletWindow, wxHtmlWindow); IMPLEMENT_CLASS(wxHtmlAppletWindow, wxHtmlWindow);
// Implement the dynamic class so it can be constructed dynamically
IMPLEMENT_DYNAMIC_CLASS(VirtualData, wxObject);
// Define the wxAppletList implementation // Define the wxAppletList implementation
#include "wx/listimpl.cpp" #include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxAppletList); WX_DEFINE_LIST(wxAppletList);
@@ -83,9 +90,8 @@ wxHtmlAppletWindow::wxHtmlAppletWindow(
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxString& name, const wxString& name)
const wxPalette& globalPalette) : wxHtmlWindow(parent,id,pos,size,style,name), m_AppletList(wxKEY_STRING)
: wxHtmlWindow(parent,id,pos,size,style,name), m_globalPalette(globalPalette)
{ {
// Init our locks // Init our locks
UnLock(); UnLock();
@@ -105,22 +111,13 @@ wxHtmlAppletWindow::wxHtmlAppletWindow(
m_NavBackId = navBackId; m_NavBackId = navBackId;
m_NavForwardId = navForwardId; m_NavForwardId = navForwardId;
// Set the key_type for applets
m_AppletList = wxAppletList(wxKEY_STRING);
// Add HTML preprocessors // Add HTML preprocessors
// deleting preprocessors is done by the code within the window // deleting preprocessors is done by the code within the window
incPreprocessor = new wxIncludePrep(); // #include preprocessor incPreprocessor = new wxIncludePrep(); // #include preprocessor
incPreprocessor->ChangeDirectory(m_FS); // give it access to our filesys object 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(incPreprocessor);
this->AddProcessor(echoPreprocessor); this->AddProcessor(new wxEchoPrep());
this->AddProcessor(ifPreprocessor); this->AddProcessor(new wxIfElsePrep());
} }
/**************************************************************************** /****************************************************************************
@@ -131,24 +128,15 @@ wxHtmlAppletWindow::~wxHtmlAppletWindow()
{ {
} }
#include "scitech.h"
/**************************************************************************** /****************************************************************************
PARAMETERS: PARAMETERS:
dc - wxDC object to draw on dc - wxDC object to draw on
REMARKS: 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( void wxHtmlAppletWindow::OnDraw(
wxDC& dc) wxDC& dc)
{ {
// TODO: Only do this for <= 8bpp modes!
dc.SetPalette(m_globalPalette);
wxHtmlWindow::OnDraw(dc); wxHtmlWindow::OnDraw(dc);
} }
@@ -173,12 +161,7 @@ wxApplet *wxHtmlAppletWindow::CreateApplet(
const wxSize& size) const wxSize& size)
{ {
// Dynamically create the class instance at runtime // Dynamically create the class instance at runtime
wxClassInfo *info = wxClassInfo::FindClass(classId.c_str()); wxObject *obj = wxCreateDynamicObject(classId.c_str());
if (!info)
return NULL;
wxObject *obj = info->CreateObject();
if (!obj)
return NULL;
wxApplet *applet = wxDynamicCast(obj,wxApplet); wxApplet *applet = wxDynamicCast(obj,wxApplet);
if (!applet) if (!applet)
return NULL; return NULL;
@@ -212,15 +195,12 @@ created dynamically based on string values embedded in the custom tags of an
HTML page. HTML page.
****************************************************************************/ ****************************************************************************/
bool wxHtmlAppletWindow::CreatePlugIn( bool wxHtmlAppletWindow::CreatePlugIn(
const wxString& classId ) const wxString& classId,
const wxString& cmdLine)
{ {
// Dynamically create the class instance at runtime // Dynamically create the class instance at runtime, execute it
wxClassInfo *info = wxClassInfo::FindClass(classId.c_str()); // and then destroy it.
if (!info) wxObject *obj = wxCreateDynamicObject(classId.c_str());
return false;
wxObject *obj = info->CreateObject();
if (!obj)
return false;
wxPlugIn *plugIn = wxDynamicCast(obj,wxPlugIn); wxPlugIn *plugIn = wxDynamicCast(obj,wxPlugIn);
if (!plugIn) if (!plugIn)
return false; return false;
@@ -228,6 +208,8 @@ bool wxHtmlAppletWindow::CreatePlugIn(
delete plugIn; delete plugIn;
return false; return false;
} }
plugIn->Run(cmdLine);
delete plugIn;
return true; return true;
} }
@@ -299,16 +281,47 @@ bool wxHtmlAppletWindow::LoadPage(
// Launches an external program on the system. // Launches an external program on the system.
if (!(cmd.CmpNoCase("?EXECUTE"))) { if (!(cmd.CmpNoCase("?EXECUTE"))) {
int code = spawnl( P_NOWAIT, cmdValue , NULL ); int waitflag = P_NOWAIT;
return (!code); 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 // Looks for a href in a variable stored as a cookie. The href can be
// changed on the fly. // changed on the fly.
if (!(cmd.CmpNoCase("?VIRTUAL"))){ if (!(cmd.CmpNoCase("?VIRTUAL"))){
VirtualData& temp = *((VirtualData*)FindCookie(cmdValue)); wxObject *obj = FindCookie(cmdValue);
if (&temp) { VirtualData *virtData = wxDynamicCast(obj,VirtualData);
href = temp.GetHref(); if (virtData) {
// recurse and loadpage, just in case the link is like another
// ? link
return LoadPage(virtData->GetHref());
} }
else { else {
#ifdef CHECKED #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 // 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. // can be of any wxWin type so it then has the freedom to do more stuff.
if (!(cmd.CmpNoCase("?WXAPPLET"))){ if (!(cmd.CmpNoCase("?WXPLUGIN"))){
if (!cmdValue.IsNull()) { if (!cmdValue.IsNull()) {
if (!CreatePlugIn(cmdValue)){ // 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 #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 #endif
} }
} }
return true; 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 // Inform all the applets that the new page is being loaded
@@ -337,6 +366,7 @@ bool wxHtmlAppletWindow::LoadPage(
(node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href)); (node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href));
Show(false); Show(false);
m_openedlast = href;
bool stat = wxHtmlWindow::LoadPage(href); bool stat = wxHtmlWindow::LoadPage(href);
Show(true); 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 communication between applets on the page if they need to inform each
other of internal information. 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( void wxHtmlAppletWindow::SendAppletMessage(
wxEvent& msg) wxAppletEvent& msg)
{ {
// Preset the skip flag // TODO: make a named target for messages, only send a message to the correct
msg.Skip(); // named applet
// 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()){
wxMessageBox("BREAK");
break;
}
} }
} }
@@ -602,11 +624,13 @@ VirtualData is used to store information on the virtual links.
VirtualData::VirtualData( VirtualData::VirtualData(
wxString& name, wxString& name,
wxString& group, wxString& group,
wxString& href ) wxString& href,
wxString& plugin )
{ {
m_name = name; m_name = name;
m_group = group; m_group = group;
m_href = href; m_href = href;
m_plugIn = plugin;
} }
/**************************************************************************** /****************************************************************************
@@ -621,18 +645,6 @@ VirtualData::VirtualData()
m_href.Empty(); m_href.Empty();
} }
/****************************************************************************
PARAMETERS:
REMARKS:
****************************************************************************/
void AppletProcess::OnTerminate(
int,
int )
{
// we're not needed any more
delete this;
}
#include "wx/html/m_templ.h" #include "wx/html/m_templ.h"
/**************************************************************************** /****************************************************************************
@@ -652,21 +664,24 @@ TAG_HANDLER_PROC(tag)
wxString name; wxString name;
int width, height; int width, height;
// Get access to our wxHtmlAppletWindow class
wnd = m_WParser->GetWindow(); wnd = m_WParser->GetWindow();
if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) == NULL)
return false;
if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) != NULL){ // Parse the applet dimensions from the tag
wxSize size = wxDefaultSize; wxSize size = wxDefaultSize;
int al; int al;
if (tag.HasParam("WIDTH")) { if (tag.HasParam("WIDTH")) {
tag.GetParamAsInt("WIDTH", &width); tag.GetParamAsInt("WIDTH", &width);
size.SetWidth(width); size.SetWidth(width);
} }
if (tag.HasParam("HEIGHT")) { if (tag.HasParam("HEIGHT")) {
tag.GetParamAsInt("HEIGHT", &height); tag.GetParamAsInt("HEIGHT", &height);
size.SetHeight(height); size.SetHeight(height);
} }
// Parse the applet alignment from the tag
al = wxHTML_ALIGN_BOTTOM; al = wxHTML_ALIGN_BOTTOM;
if (tag.HasParam(wxT("ALIGN"))) { if (tag.HasParam(wxT("ALIGN"))) {
wxString alstr = tag.GetParam(wxT("ALIGN")); wxString alstr = tag.GetParam(wxT("ALIGN"));
@@ -677,6 +692,7 @@ TAG_HANDLER_PROC(tag)
al = wxHTML_ALIGN_CENTER; al = wxHTML_ALIGN_CENTER;
} }
// Create the applet based on it's class
if (tag.HasParam("CLASSID")) { if (tag.HasParam("CLASSID")) {
classId = tag.GetParam("CLASSID"); classId = tag.GetParam("CLASSID");
if (classId.IsNull() || classId.Len() == 0) { if (classId.IsNull() || classId.Len() == 0) {
@@ -703,12 +719,11 @@ TAG_HANDLER_PROC(tag)
wxMessageBox("wxApplet tag error: Can not find CLASSID param.","Error",wxICON_ERROR); wxMessageBox("wxApplet tag error: Can not find CLASSID param.","Error",wxICON_ERROR);
return false; return false;
} }
// Add more param parsing here. If or when spec changes. // Add more param parsing here. If or when spec changes.
// For now we'll ignore any other params those HTML guys // For now we'll ignore any other params those HTML guys
// might put in our tag. // might put in our tag.
} return true;
return false;
} }
TAG_HANDLER_END(wxApplet) TAG_HANDLER_END(wxApplet)
@@ -717,16 +732,20 @@ TAGS_MODULE_BEGIN(wxApplet)
TAGS_MODULE_ADD(wxApplet) TAGS_MODULE_ADD(wxApplet)
TAGS_MODULE_END(wxApplet) TAGS_MODULE_END(wxApplet)
/********************************************************************************* /****************************************************************************
wxHtmlAppletCell REMARKS:
*********************************************************************************/ Constructor for the HTML cell class to store our wxApplet windows in
wxHtmlAppletCell::wxHtmlAppletCell(wxWindow *wnd, int align) : wxHtmlCell() the HTML page to be rendered by wxHTML.
****************************************************************************/
wxHtmlAppletCell::wxHtmlAppletCell(
wxWindow *wnd,
int align)
: wxHtmlCell()
{ {
int sx, sy; int sx, sy;
m_Wnd = wnd; m_Wnd = wnd;
m_Wnd->GetSize(&sx, &sy); m_Wnd->GetSize(&sx, &sy);
m_Width = sx, m_Height = sy; m_Width = sx, m_Height = sy;
switch (align) { switch (align) {
case wxHTML_ALIGN_TOP : case wxHTML_ALIGN_TOP :
m_Descent = m_Height; m_Descent = m_Height;
@@ -739,59 +758,76 @@ wxHtmlAppletCell::wxHtmlAppletCell(wxWindow *wnd, int align) : wxHtmlCell()
m_Descent = 0; m_Descent = 0;
break; break;
} }
SetCanLiveOnPagebreak(FALSE); SetCanLiveOnPagebreak(FALSE);
} }
/****************************************************************************
REMARKS:
Implementation for the HTML cell class to store our wxApplet windows in
the HTML page to be rendered by wxHTML.
****************************************************************************/
wxHtmlAppletCell::~wxHtmlAppletCell()
{
delete m_Wnd;
}
void wxHtmlAppletCell::Draw(wxDC& WXUNUSED(dc), int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(view_y1), int WXUNUSED(view_y2)) /****************************************************************************
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; int absx = 0, absy = 0, stx, sty;
wxHtmlCell *c = this; wxHtmlCell *c = this;
while (c) while (c) {
{
absx += c->GetPosX(); absx += c->GetPosX();
absy += c->GetPosY(); absy += c->GetPosY();
c = c->GetParent(); c = c->GetParent();
} }
((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty);
m_Wnd->Move(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty); m_Wnd->Move(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty);
} }
/****************************************************************************
REMARKS:
void wxHtmlAppletCell::DrawInvisible(wxDC& WXUNUSED(dc), int WXUNUSED(x), int WXUNUSED(y)) 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; int absx = 0, absy = 0, stx, sty;
wxHtmlCell *c = this; wxHtmlCell *c = this;
while (c) while (c) {
{
absx += c->GetPosX(); absx += c->GetPosX();
absy += c->GetPosY(); absy += c->GetPosY();
c = c->GetParent(); c = c->GetParent();
} }
((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty);
m_Wnd->Move(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty); m_Wnd->Move(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty);
} }
/****************************************************************************
REMARKS:
void wxHtmlAppletCell::Layout(int w) Code to layout the html applet cell.
****************************************************************************/
void wxHtmlAppletCell::Layout(
int w)
{ {
int sx, sy; int sx, sy;
m_Wnd->GetSize(&sx, &sy); m_Wnd->GetSize(&sx, &sy);
m_Width = sx, m_Height = sy; m_Width = sx, m_Height = sy;
wxHtmlCell::Layout(w); wxHtmlCell::Layout(w);
} }
// This is our little forcelink hack. // This is our little forcelink hack.
FORCE_LINK(loadpage) FORCE_LINK(loadpage)

View File

@@ -28,65 +28,106 @@
****************************************************************************/ ****************************************************************************/
// For compilers that support precompilation // For compilers that support precompilation
#include "wx/wxprec.h"
#include "wx/applet/echovar.h"
#include "wx/msgdlg.h"
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
// Include private headers // Include private headers
#include "wx/applet/echovar.h"
/*---------------------------- Global variables ---------------------------*/ /*---------------------------- Global variables ---------------------------*/
// Implement the dynamic class so it can be constructed dynamically static wxEchoVariable *wxEchoVariable::sm_first = NULL;
IMPLEMENT_ABSTRACT_CLASS(wxEchoVariable, wxObject); static wxHashTable *wxEchoVariable::sm_varTable = NULL;
/*----------------------------- Implementation ----------------------------*/ /*----------------------------- Implementation ----------------------------*/
/**************************************************************************** /****************************************************************************
PARAMETERS: PARAMETERS:
cls - The String name of the class varName - The String name of the class
parms - an optional parameter string to pass off to the child class getValueFn - Pointer to the function that returns the echo variable value
RETURNS:
The string value of the variable
REMARKS: REMARKS:
To grab a value from any class which is derived from this one simple use this Constructor for the wxEchoVariable class that self registers itself with
static function and the name of the derived class to get the value. the list of all echo variables when the static class instance is created
This static function is the only function implemented in this base class at program init time (remember all the constructors get called before
basically this is provided for an easier method of grabbing a variable. We the main program function!).
keep all the dynamic object handling in this class to avoid confusing the source
where these are used.
SEE ALSO:
wxEchoPrep
****************************************************************************/ ****************************************************************************/
static wxString wxEchoVariable::FindValue( wxEchoVariable::wxEchoVariable(
const wxString &cls, const char *varName,
const char *parms) wxEchoVariableGetValueFn getValueFn)
{ {
wxObject * tmpclass; m_varName = varName;
m_getValueFn = getValueFn;
m_next = sm_first;
sm_first = this;
}
tmpclass = wxCreateDynamicObject(wxString("wxEchoVariable") + cls); /****************************************************************************
if (!tmpclass) { 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 #ifdef CHECKED
wxMessageBox(wxString("wxHTML #echo error: Class not found (") + cls + wxString(")."),"Error",wxICON_ERROR); wxMessageBox(wxString("wxHTML #echo error: Class is not a valid echo variable (") + varName + wxString(")."),"Error",wxICON_ERROR);
#endif #endif
return wxString(""); return wxString("");
} }
wxEchoVariable * ev = wxDynamicCast(tmpclass, wxEchoVariable); /****************************************************************************
PARAMETERS:
varName - The String name of the class
if (!ev) { RETURNS:
#ifdef CHECKED True if the echo variable exists, false if not.
wxMessageBox(wxString("wxHTML #echo error: Class is not a valid echo variable (") + cls + wxString(")."),"Error",wxICON_ERROR); ****************************************************************************/
#endif bool wxEchoVariable::Exists(
return wxString(""); const wxChar *varName)
{
return wxEchoVariable::FindVariable(varName) != NULL;
} }
return ev->GetValue(parms);
}
/*------------------------ Macro Documentation ---------------------------*/ /*------------------------ Macro Documentation ---------------------------*/
// Here we declare some fake functions to get doc-jet to properly document the macros // Here we declare some fake functions to get doc-jet to properly document the macros
@@ -178,3 +219,4 @@ void STRING_ECHO_VARIABLE(
// hack to make this file link // hack to make this file link
FORCE_LINK_ME(echovar) FORCE_LINK_ME(echovar)

View File

@@ -27,61 +27,134 @@
* *
****************************************************************************/ ****************************************************************************/
// For compilers that support precompilation
#include "wx/wxprec.h"
#include "wx/html/forcelnk.h"
// Include private headers // Include private headers
#include "wx/applet/ifelsevar.h" #include "wx/applet/ifelsevar.h"
// wxWindows forcelink macro
#include "wx/html/forcelnk.h"
#include "wx/msgdlg.h"
/*---------------------------- Global variables ---------------------------*/ /*---------------------------- Global variables ---------------------------*/
// Implement the dynamic class so it can be constructed dynamically static wxIfElseVariable *wxIfElseVariable::sm_first = NULL;
IMPLEMENT_ABSTRACT_CLASS(wxIfElseVariable, wxObject); static wxHashTable *wxIfElseVariable::sm_varTable = NULL;
/*----------------------------- Implementation ----------------------------*/ /*----------------------------- Implementation ----------------------------*/
/**************************************************************************** /****************************************************************************
PARAMETERS: PARAMETERS:
cls - The String name of the class varName - The String name of the class
getValueFn - Pointer to the function that returns the echo variable value
RETURNS:
The boolean value of the variable
REMARKS: REMARKS:
To grab a value from any class which is derived from this one simple use this Constructor for the wxIfElseVariable class that self registers itself with
static function and the name of the derived class to get the value. the list of all echo variables when the static class instance is created
This static function is the only function implemented in this base class at program init time (remember all the constructors get called before
basically this is provided for an easier method of grabbing a variable. We the main program function!).
keep all the dynamic object handling in this class to avoid confusing the source
where these are used.
SEE ALSO:
wxIfElsePrep
****************************************************************************/ ****************************************************************************/
static bool wxIfElseVariable::FindValue( wxIfElseVariable::wxIfElseVariable(
const wxString &cls) 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) { 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;
}
}
/****************************************************************************
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 #ifdef CHECKED
wxMessageBox(wxString("wxHTML #if error: Class not found (") + cls + wxString(")."),"Error",wxICON_ERROR); wxMessageBox(wxString("wxHTML #if error: Class is not a valid if else variable (") + varName + wxString(")."),"Error",wxICON_ERROR);
#endif #endif
return wxString(""); return wxString("");
} }
wxIfElseVariable * ev = wxDynamicCast(tmpclass, wxIfElseVariable); /****************************************************************************
PARAMETERS:
varName - The String name of the class
if (!ev) { RETURNS:
#ifdef CHECKED True if the if/else variable exists, false if not.
wxMessageBox(wxString("wxHTML #if error: Class is not a valid ifelse variable (") + cls + wxString(")."),"Error",wxICON_ERROR); ****************************************************************************/
#endif bool wxIfElseVariable::Exists(
return wxString(""); const wxChar *varName)
{
return wxIfElseVariable::FindVariable(varName) != NULL;
} }
return ev->GetValue(); /****************************************************************************
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 ---------------------------*/ /*------------------------ Macro Documentation ---------------------------*/
@@ -155,5 +228,5 @@ void IFELSE_VARIABLE(
const char *name, const char *name,
bool state); bool state);
FORCE_LINK_ME(ifelsevar) FORCE_LINK_ME(ifelsevar)

View File

@@ -26,13 +26,12 @@
* *
****************************************************************************/ ****************************************************************************/
// For compilers that support precompilation
#include "wx/wxprec.h"
#include "wx/html/forcelnk.h"
// Include private headers // Include private headers
#include "wx/applet/loadpage.h" #include "wx/applet/loadpage.h"
// wxWindows forcelink macro
#include "wx/html/forcelnk.h"
/*------------------------- Implementation --------------------------------*/ /*------------------------- Implementation --------------------------------*/
// Implement the class functions for wxLoadPageEvent // Implement the class functions for wxLoadPageEvent
@@ -59,20 +58,6 @@ wxLoadPageEvent::wxLoadPageEvent(
m_eventType = wxEVT_LOAD_PAGE; 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: REMARKS:
Constructor for the wxPageLoadedEvent class Constructor for the wxPageLoadedEvent class
@@ -82,17 +67,6 @@ wxPageLoadedEvent::wxPageLoadedEvent()
m_eventType = wxEVT_LOAD_PAGE; 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 // This is out little force link hack
FORCE_LINK_ME(loadpage) FORCE_LINK_ME(loadpage)

View File

@@ -26,9 +26,6 @@
* *
****************************************************************************/ ****************************************************************************/
// For compilers that support precompilation
#include "wx/wxprec.h"
// Include private headers // Include private headers
#include "wx/applet/plugin.h" #include "wx/applet/plugin.h"
#include "wx/applet/window.h" #include "wx/applet/window.h"
@@ -36,7 +33,7 @@
/*------------------------- Implementation --------------------------------*/ /*------------------------- Implementation --------------------------------*/
// Implement the abstract class functions // Implement the abstract class functions
IMPLEMENT_ABSTRACT_CLASS(wxPlugIn, wxObject); IMPLEMENT_ABSTRACT_CLASS(wxPlugIn, wxEvtHandler);
/**************************************************************************** /****************************************************************************
REMARKS: REMARKS:
@@ -57,4 +54,12 @@ wxPlugIn::~wxPlugIn()
{ {
} }
/****************************************************************************
REMARKS:
Destructor for the wxPlugIn class.
****************************************************************************/
void wxPlugIn::Run(
const wxString& WXUNUSED(cmdLine))
{
}

View File

@@ -27,16 +27,15 @@
* *
****************************************************************************/ ****************************************************************************/
// For compilers that support precompilation
#include "wx/wxprec.h"
#include "wx/html/forcelnk.h"
// Include private headers // Include private headers
#include "wx/applet/prepecho.h" #include "wx/applet/prepecho.h"
#include "wx/applet/echovar.h" #include "wx/applet/echovar.h"
/*---------------------------- Global variables ---------------------------*/ // Force Link macro
#include "wx/html/forcelnk.h"
// wxWindows headers
#include "wx/msgdlg.h"
/*----------------------------- Implementation ----------------------------*/ /*----------------------------- Implementation ----------------------------*/
@@ -68,7 +67,6 @@ wxString wxEchoPrep::Process(
while ((i = (output.Lower()).Find(ft)) != -1) { while ((i = (output.Lower()).Find(ft)) != -1) {
// Loop until every #echo directive is found // Loop until every #echo directive is found
int n, c, end; int n, c, end;
wxString cname, parms; wxString cname, parms;
wxString tag; wxString tag;
@@ -97,7 +95,7 @@ wxString wxEchoPrep::Process(
cname = tag.Mid(10, n); cname = tag.Mid(10, n);
// grab the value from the class, put it in tag since the data is no longer needed // 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 { else {
// Find the parms // Find the parms
@@ -114,9 +112,7 @@ wxString wxEchoPrep::Process(
cname = tag.Mid(10, n); cname = tag.Mid(10, n);
// grab the value from the class, put it in tag since the data is no longer needed // 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 // remove ampersands and <> chars
tag.Replace("&", "&amp;"); tag.Replace("&", "&amp;");
@@ -125,7 +121,6 @@ wxString wxEchoPrep::Process(
output = (output.Mid(0,i) + tag + output.Mid(i)); output = (output.Mid(0,i) + tag + output.Mid(i));
} }
return output; return output;
} }

View File

@@ -27,16 +27,16 @@
* *
****************************************************************************/ ****************************************************************************/
// For compilers that support precompilation
#include "wx/wxprec.h"
#include "wx/html/forcelnk.h"
// Include private headers // Include private headers
#include "wx/applet/prepifelse.h" #include "wx/applet/prepifelse.h"
#include "wx/applet/ifelsevar.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 ----------------------------*/ /*----------------------------- Implementation ----------------------------*/
@@ -65,10 +65,56 @@ int ReverseFind(
return p; return p;
p--; p--;
} }
return -1; 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: PARAMETERS:
str - text of #if statement str - text of #if statement
@@ -77,12 +123,14 @@ RETURNS:
true or false depending on how it evaluated true or false depending on how it evaluated
REMARKS: REMARKS:
TODO: rewrite this whole thing using regular expressions when they are done.
SEE ALSO: SEE ALSO:
wxIfElseVariable wxIfElseVariable
****************************************************************************/ ****************************************************************************/
bool ParseIfStatementValue(wxString &str) { bool ParseIfStatementValue(
wxString &str)
{
// Find out if the tag has parenthesis // Find out if the tag has parenthesis
// recursive to parse the text within the parenthesis, // recursive to parse the text within the parenthesis,
// replacing the text with 1 or 0, (hardcoded true or false) // replacing the text with 1 or 0, (hardcoded true or false)
@@ -93,7 +141,6 @@ bool ParseIfStatementValue(wxString &str) {
int nextbeg, nextend; int nextbeg, nextend;
int parencount = 1, min = b+1; int parencount = 1, min = b+1;
do { do {
nextbeg = str.find('(', min); nextbeg = str.find('(', min);
nextend = str.find(')', min); nextend = str.find(')', min);
if (nextbeg < nextend && nextbeg != wxString::npos) { if (nextbeg < nextend && nextbeg != wxString::npos) {
@@ -124,7 +171,6 @@ bool ParseIfStatementValue(wxString &str) {
// Add extra spaces just in case of NOT(VAL) // Add extra spaces just in case of NOT(VAL)
if (val) str = str.Mid(0, b) + " 1" + str.Mid(e+1); if (val) str = str.Mid(0, b) + " 1" + str.Mid(e+1);
else str = str.Mid(0, b) + " 0" + str.Mid(e+1); else str = str.Mid(0, b) + " 0" + str.Mid(e+1);
} }
// Remove spaces from left and right // 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 // this makes only one special case necessary for each later on
str.Replace(" AND ", "&&"); str.Replace(" AND ", "&&");
str.Replace(" OR ", "||"); 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 // We use ReverseFind so that the whole left expression gets evaluated agains
// the right single item, creating a left -> right evaluation // the right single item, creating a left -> right evaluation
@@ -145,7 +236,7 @@ bool ParseIfStatementValue(wxString &str) {
if ( (and != -1) || (or != -1) ) { if ( (and != -1) || (or != -1) ) {
wxString tag1, tag2; wxString tag1, tag2;
// handle the rightmost first to force left->right evaluation // handle the rightmost first to force left->right evaluation
if (and > or) { if ( (and > or) ) {
return ( return (
ParseIfStatementValue(tag2 = str.Mid(and+2)) && ParseIfStatementValue(tag2 = str.Mid(and+2)) &&
ParseIfStatementValue(tag1 = str.Mid(0, and)) ); ParseIfStatementValue(tag1 = str.Mid(0, and)) );
@@ -155,7 +246,6 @@ bool ParseIfStatementValue(wxString &str) {
ParseIfStatementValue(tag2 = str.Mid(or+2)) || ParseIfStatementValue(tag2 = str.Mid(or+2)) ||
ParseIfStatementValue(tag1 = str.Mid(0, or)) ); ParseIfStatementValue(tag1 = str.Mid(0, or)) );
} }
} }
// By the time we get to this place in the function we are guarenteed to have a single // By the time we get to this place in the function we are guarenteed to have a single
@@ -175,7 +265,6 @@ bool ParseIfStatementValue(wxString &str) {
} }
// now all we have left is the name of the class or a hardcoded 0 or 1 // now all we have left is the name of the class or a hardcoded 0 or 1
if (str == "") { if (str == "") {
#ifdef CHECKED #ifdef CHECKED
wxMessageBox("wxHTML #if\\else error: Empty expression in #if\\#elif statement.","Error",wxICON_ERROR); wxMessageBox("wxHTML #if\\else error: Empty expression in #if\\#elif statement.","Error",wxICON_ERROR);
@@ -189,7 +278,7 @@ bool ParseIfStatementValue(wxString &str) {
if (str == "1") return !notval; if (str == "1") return !notval;
// Grab the value from the variable class identified by cname // Grab the value from the variable class identified by cname
bool value = wxIfElseVariable::FindValue(str); bool value = wxIfElseVariable::GetValue(str);
if (notval) value = !value; if (notval) value = !value;
return value; return value;
@@ -220,7 +309,6 @@ wxString wxIfElsePrep::Process(
char ftelse[] = "<!--#else-->"; char ftelse[] = "<!--#else-->";
char ftnot[] = "<!--#if not "; char ftnot[] = "<!--#if not ";
char ftnot2[] = "<!--#if !"; char ftnot2[] = "<!--#if !";
char ftelif[] = "<!--#elif "; char ftelif[] = "<!--#elif ";
// make a copy so we can replace text as we go without affecting the original // make a copy so we can replace text as we go without affecting the original
@@ -280,7 +368,6 @@ wxString wxIfElsePrep::Process(
output.Mid(b+strlen(ftelif), elifsize+nextendif) + output.Mid(b+strlen(ftelif), elifsize+nextendif) +
wxString(ftend) + wxString(ftend) +
output.Mid(b+strlen(ftelif)+elifsize+nextendif); output.Mid(b+strlen(ftelif)+elifsize+nextendif);
} }
// Parse out the if else blocks themselves // Parse out the if else blocks themselves
@@ -351,3 +438,4 @@ wxString wxIfElsePrep::Process(
} }
FORCE_LINK(ifelsevar) FORCE_LINK(ifelsevar)

View File

@@ -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 private headers
#include "wx/applet/prepinclude.h" #include "wx/applet/prepinclude.h"
#include "wx/applet/echovar.h"
#define RECURSE_LIMIT 50 // wxWindows
/*---------------------------- Global variables ---------------------------*/ #include "wx/filesys.h"
#include "wx/msgdlg.h"
/*----------------------------- Implementation ----------------------------*/ /*----------------------------- 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: PARAMETERS:
text - HTML to process for include directives text - HTML to process for include directives
@@ -58,8 +92,6 @@ wxString wxIncludePrep::Process(
{ {
int i; int i;
char ft[] = "<!--#include virtual="; char ft[] = "<!--#include virtual=";
int openedcount = 0; int openedcount = 0;
// make a copy so we can replace text as we go without affecting the original // 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); output.Remove(i, n+21+3);
wxFSFile * file; wxFSFile * file;
file = m_FS->OpenFile(fname); file = m_FS->OpenFile(ParseFilename(fname));
if (!file) { if (!file) {
#ifdef CHECKED #ifdef CHECKED
@@ -112,14 +144,12 @@ wxString wxIncludePrep::Process(
} while (c == 256); } while (c == 256);
output = (output.Mid(0,i) + tmp + output.Mid(i)); output = (output.Mid(0,i) + tmp + output.Mid(i));
#ifdef CHECKED #ifdef CHECKED
if (openedcount > RECURSE_LIMIT) { 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); 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; break;
} }
#endif #endif
openedcount++; openedcount++;
delete file; delete file;
} }

View File

@@ -353,8 +353,8 @@ inline static wxString CharToString(wxMBConv *conv,
wchar_t *buf = new wchar_t[nLen+1]; wchar_t *buf = new wchar_t[nLen+1];
wxConvUTF8.MB2WC(buf, s, nLen); wxConvUTF8.MB2WC(buf, s, nLen);
buf[nLen] = 0; buf[nLen] = 0;
return wxString(buf, *conv, len);
delete[] buf; delete[] buf;
return wxString(buf, *conv, len);
} }
else else
return wxString(s, len); return wxString(s, len);
@@ -475,7 +475,7 @@ static int UnknownEncodingHnd(void * WXUNUSED(encodingHandlerData),
size_t i; size_t i;
for (i = 0; i < 255; i++) for (i = 0; i < 255; i++)
mbBuf[i] = i+1; mbBuf[i] = (char) (i+1);
mbBuf[255] = 0; mbBuf[255] = 0;
conv.MB2WC(wcBuf, mbBuf, 255); conv.MB2WC(wcBuf, mbBuf, 255);
wcBuf[255] = 0; wcBuf[255] = 0;

View File

@@ -28,7 +28,6 @@
#include "wx/brush.h" #include "wx/brush.h"
#include "wx/pen.h" #include "wx/pen.h"
#include "wx/palette.h" #include "wx/palette.h"
#include "wx/list.h" // we use wxList in inline functions #include "wx/list.h" // we use wxList in inline functions
class WXDLLEXPORT wxDCBase; class WXDLLEXPORT wxDCBase;
@@ -741,6 +740,7 @@ protected:
#if wxUSE_PALETTE #if wxUSE_PALETTE
wxPalette m_palette; wxPalette m_palette;
bool m_custompalette;
#endif // wxUSE_PALETTE #endif // wxUSE_PALETTE
private: private:

View File

@@ -230,20 +230,21 @@ BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(wxEVT_POPUP_MENU_INIT, 423) DECLARE_EVENT_TYPE(wxEVT_POPUP_MENU_INIT, 423)
DECLARE_EVENT_TYPE(wxEVT_CONTEXT_MENU, 424) DECLARE_EVENT_TYPE(wxEVT_CONTEXT_MENU, 424)
DECLARE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED, 425) DECLARE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED, 425)
DECLARE_EVENT_TYPE(wxEVT_SETTING_CHANGED, 426) DECLARE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED, 426)
DECLARE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE, 427) DECLARE_EVENT_TYPE(wxEVT_SETTING_CHANGED, 427)
DECLARE_EVENT_TYPE(wxEVT_PALETTE_CHANGED, 428) DECLARE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE, 428)
DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN, 429) DECLARE_EVENT_TYPE(wxEVT_PALETTE_CHANGED, 429)
DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP, 430) DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN, 430)
DECLARE_EVENT_TYPE(wxEVT_JOY_MOVE, 431) DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP, 431)
DECLARE_EVENT_TYPE(wxEVT_JOY_ZMOVE, 432) DECLARE_EVENT_TYPE(wxEVT_JOY_MOVE, 432)
DECLARE_EVENT_TYPE(wxEVT_DROP_FILES, 433) DECLARE_EVENT_TYPE(wxEVT_JOY_ZMOVE, 433)
DECLARE_EVENT_TYPE(wxEVT_DRAW_ITEM, 434) DECLARE_EVENT_TYPE(wxEVT_DROP_FILES, 434)
DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 435) DECLARE_EVENT_TYPE(wxEVT_DRAW_ITEM, 435)
DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 436) DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 436)
DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 437) DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 437)
DECLARE_EVENT_TYPE(wxEVT_IDLE, 438) DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 438)
DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 439) DECLARE_EVENT_TYPE(wxEVT_IDLE, 439)
DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 440)
// Generic command events // Generic command events
// Note: a click is a higher-level event than button down/up // Note: a click is a higher-level event than button down/up
@@ -1380,6 +1381,21 @@ private:
DECLARE_DYNAMIC_CLASS(wxSysColourChangedEvent) DECLARE_DYNAMIC_CLASS(wxSysColourChangedEvent)
}; };
/*
wxEVT_DISPLAY_CHANGED
*/
class WXDLLEXPORT wxDisplayChangedEvent : public wxEvent
{
private:
DECLARE_DYNAMIC_CLASS(wxDisplayChangedEvent)
public:
wxDisplayChangedEvent()
{ m_eventType = wxEVT_DISPLAY_CHANGED; }
virtual wxEvent *Clone() const { return new wxDisplayChangedEvent(*this); }
};
/* /*
wxEVT_PALETTE_CHANGED wxEVT_PALETTE_CHANGED
*/ */
@@ -1899,6 +1915,7 @@ typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&);
typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&); typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&);
typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&); typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&);
typedef void (wxEvtHandler::*wxSysColourChangedFunction)(wxSysColourChangedEvent&); typedef void (wxEvtHandler::*wxSysColourChangedFunction)(wxSysColourChangedEvent&);
typedef void (wxEvtHandler::*wxDisplayChangedFunction)(wxDisplayChangedEvent&);
typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&); typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&);
typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&); typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&);
typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&); typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&);
@@ -1968,6 +1985,7 @@ typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&);
#define EVT_DROP_FILES(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_DROP_FILES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxDropFilesEventFunction) & func, (wxObject *) NULL ), #define EVT_DROP_FILES(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_DROP_FILES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxDropFilesEventFunction) & func, (wxObject *) NULL ),
#define EVT_INIT_DIALOG(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_INIT_DIALOG, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxInitDialogEventFunction) & func, (wxObject *) NULL ), #define EVT_INIT_DIALOG(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_INIT_DIALOG, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxInitDialogEventFunction) & func, (wxObject *) NULL ),
#define EVT_SYS_COLOUR_CHANGED(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SYS_COLOUR_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSysColourChangedFunction) & func, (wxObject *) NULL ), #define EVT_SYS_COLOUR_CHANGED(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SYS_COLOUR_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSysColourChangedFunction) & func, (wxObject *) NULL ),
#define EVT_DISPLAY_CHANGED(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_DISPLAY_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxDisplayChangedFunction) & func, (wxObject *) NULL ),
#define EVT_SHOW(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SHOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxShowEventFunction) & func, (wxObject *) NULL ), #define EVT_SHOW(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SHOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxShowEventFunction) & func, (wxObject *) NULL ),
#define EVT_MAXIMIZE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MAXIMIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMaximizeEventFunction) & func, (wxObject *) NULL ), #define EVT_MAXIMIZE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MAXIMIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMaximizeEventFunction) & func, (wxObject *) NULL ),
#define EVT_ICONIZE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_ICONIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxIconizeEventFunction) & func, (wxObject *) NULL ), #define EVT_ICONIZE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_ICONIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxIconizeEventFunction) & func, (wxObject *) NULL ),

View File

@@ -180,9 +180,9 @@ public:
// loading a page or loading an image). The data are downloaded if and only if // loading a page or loading an image). The data are downloaded if and only if
// OnOpeningURL returns TRUE. If OnOpeningURL returns wxHTML_REDIRECT, // OnOpeningURL returns TRUE. If OnOpeningURL returns wxHTML_REDIRECT,
// it must set *redirect to the new URL // it must set *redirect to the new URL
virtual wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type, virtual wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType WXUNUSED(type),
const wxString& url, const wxString& WXUNUSED(url),
wxString *redirect) const wxString *WXUNUSED(redirect)) const
{ return wxHTML_OPEN; } { return wxHTML_OPEN; }
protected: protected:

View File

@@ -144,7 +144,7 @@ public:
#if wxUSE_STREAMS #if wxUSE_STREAMS
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE ) {return FALSE ;}; virtual bool SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream), bool WXUNUSED(verbose=TRUE) ){return FALSE ;};
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 ); virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 );
virtual bool DoCanRead( wxInputStream& stream ); virtual bool DoCanRead( wxInputStream& stream );
virtual int GetImageCount( wxInputStream& stream ); virtual int GetImageCount( wxInputStream& stream );

View File

@@ -300,7 +300,7 @@ public:
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString &name = "listctrl" ) const wxString &name = "listctrl" )
{ {
Create(parent, id, pos, size, style, wxDefaultValidator, name); Create(parent, id, pos, size, style, validator, name);
} }
// focus/selection stuff // focus/selection stuff

View File

@@ -102,7 +102,13 @@ public:
virtual void SelectOldObjects(WXHDC dc); virtual void SelectOldObjects(WXHDC dc);
wxWindow *GetWindow() const { return m_canvas; } wxWindow *GetWindow() const { return m_canvas; }
void SetWindow(wxWindow *win) { m_canvas = win; } void SetWindow(wxWindow *win) {
m_canvas = win;
#if wxUSE_PALETTE
// if we have palettes use the correct one for this window
InitializePalette();
#endif
}
WXHDC GetHDC() const { return m_hDC; } WXHDC GetHDC() const { return m_hDC; }
void SetHDC(WXHDC dc, bool bOwnsDC = FALSE) void SetHDC(WXHDC dc, bool bOwnsDC = FALSE)
@@ -184,6 +190,15 @@ protected:
int fillStyle = wxODDEVEN_RULE); int fillStyle = wxODDEVEN_RULE);
#if wxUSE_PALETTE
// MSW specific, select a logical palette into the HDC
// (tell windows to translate pixel from other palettes to our custom one
// and vice versa)
// Realize tells it to also reset the system palette to this one.
void DoSelectPalette(bool realize = false);
// Find out what palette our parent window has, then select it into the dc
void InitializePalette();
#endif
// common part of DoDrawText() and DoDrawRotatedText() // common part of DoDrawText() and DoDrawRotatedText()
void DrawAnyText(const wxString& text, wxCoord x, wxCoord y); void DrawAnyText(const wxString& text, wxCoord x, wxCoord y);

View File

@@ -331,6 +331,8 @@ public:
bool HandlePaletteChanged(WXHWND hWndPalChange); bool HandlePaletteChanged(WXHWND hWndPalChange);
bool HandleQueryNewPalette(); bool HandleQueryNewPalette();
bool HandleSysColorChange(); bool HandleSysColorChange();
bool HandleDisplayChange();
bool HandleQueryEndSession(long logOff, bool *mayEnd); bool HandleQueryEndSession(long logOff, bool *mayEnd);
bool HandleEndSession(bool endSession, long logOff); bool HandleEndSession(bool endSession, long logOff);

View File

@@ -32,6 +32,11 @@
#include "wx/validate.h" // for wxDefaultValidator (always include it) #include "wx/validate.h" // for wxDefaultValidator (always include it)
#if wxUSE_PALETTE
#include "wx/dcclient.h"
#include "wx/palette.h"
#endif // wxUSE_PALETTE
#if wxUSE_ACCEL #if wxUSE_ACCEL
#include "wx/accel.h" #include "wx/accel.h"
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
@@ -761,6 +766,21 @@ public:
// platform-specific APIs // platform-specific APIs
virtual WXWidget GetHandle() const = 0; virtual WXWidget GetHandle() const = 0;
#if wxUSE_PALETTE
// Store the palette used by DCs in wxWindow so that the dcs can share
// a palette. And we can respond to palette messages.
wxPalette GetPalette() const { return m_palette; }
// When palette is changed tell the DC to set the system palette to the
// new one.
void SetPalette(wxPalette &pal) {
m_custompalette=true;
m_palette=pal;
wxWindowDC d((wxWindow *) this);
d.SetPalette(pal);
}
bool HasCustomPalette() { return m_custompalette; }
#endif // wxUSE_PALETTE
protected: protected:
// the window id - a number which uniquely identifies a window among // the window id - a number which uniquely identifies a window among
// its siblings unless it is -1 // its siblings unless it is -1
@@ -844,6 +864,11 @@ protected:
wxString m_windowName; wxString m_windowName;
bool m_themeEnabled; bool m_themeEnabled;
#ifdef wxUSE_PALETTE
wxPalette m_palette;
bool m_custompalette;
#endif
protected: protected:
// common part of all ctors: it is not virtual because it is called from // common part of all ctors: it is not virtual because it is called from

View File

@@ -79,6 +79,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxSetCursorEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxSetCursorEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxDisplayChangedEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxCommandEvent)
IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent, wxCommandEvent)
IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent, wxEvent)
@@ -224,6 +225,7 @@ DEFINE_EVENT_TYPE(wxEVT_MENU_HIGHLIGHT)
DEFINE_EVENT_TYPE(wxEVT_POPUP_MENU_INIT) DEFINE_EVENT_TYPE(wxEVT_POPUP_MENU_INIT)
DEFINE_EVENT_TYPE(wxEVT_CONTEXT_MENU) DEFINE_EVENT_TYPE(wxEVT_CONTEXT_MENU)
DEFINE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED) DEFINE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED)
DEFINE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED)
DEFINE_EVENT_TYPE(wxEVT_SETTING_CHANGED) DEFINE_EVENT_TYPE(wxEVT_SETTING_CHANGED)
DEFINE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE) DEFINE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE)
DEFINE_EVENT_TYPE(wxEVT_PALETTE_CHANGED) DEFINE_EVENT_TYPE(wxEVT_PALETTE_CHANGED)

View File

@@ -1043,8 +1043,10 @@ wxString wxFileName::GetFullName() const
return fullname; return fullname;
} }
wxString wxFileName::GetPath( bool add_separator, wxPathFormat format ) const wxString wxFileName::GetPath( bool, wxPathFormat format ) const
{ {
// Should add_seperator parameter be used?
format = GetFormat( format ); format = GetFormat( format );
wxString fullpath; wxString fullpath;
@@ -1776,4 +1778,3 @@ void wxFileName::MacRegisterDefaultTypeAndCreator( const wxString& ext , wxUint3
gMacDefaultExtensions.Add( rec ) ; gMacDefaultExtensions.Add( rec ) ;
} }
#endif #endif

View File

@@ -92,7 +92,7 @@ bool wxBMPHandler::SaveDib(wxImage *image,
if ( image->HasOption(wxBMP_FORMAT) ) if ( image->HasOption(wxBMP_FORMAT) )
format = image->GetOptionInt(wxBMP_FORMAT); format = image->GetOptionInt(wxBMP_FORMAT);
unsigned bpp; // # of bits per pixel wxUint16 bpp; // # of bits per pixel
int palette_size; // # of color map entries, ie. 2^bpp colors int palette_size; // # of color map entries, ie. 2^bpp colors
// set the bpp and appropriate palette_size, and do additional checks // set the bpp and appropriate palette_size, and do additional checks
@@ -1116,6 +1116,7 @@ bool wxICOHandler::LoadFile(wxImage *image, wxInputStream& stream,
bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream,
bool verbose, int index) bool verbose, int index)
{ {
(void) verbose;
bool bResult = FALSE; bool bResult = FALSE;
bool IsBmp = FALSE; bool IsBmp = FALSE;

View File

@@ -334,7 +334,7 @@ typedef my_cquantizer * my_cquantize_ptr;
void void
prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY output_buf, int num_rows) JSAMPARRAY WXUNUSED(output_buf), int num_rows)
{ {
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
register JSAMPROW ptr; register JSAMPROW ptr;
@@ -1284,7 +1284,7 @@ finish_pass1 (j_decompress_ptr cinfo)
void void
finish_pass2 (j_decompress_ptr cinfo) finish_pass2 (j_decompress_ptr WXUNUSED(cinfo))
{ {
/* no work */ /* no work */
} }

View File

@@ -124,7 +124,7 @@ static size_t encode_utf16(wxUint32 input, wchar_t *output)
{ {
if (input<=0xffff) if (input<=0xffff)
{ {
if (output) *output++ = input; if (output) *output++ = (wchar_t) input;
return 1; return 1;
} }
else if (input>=0x110000) else if (input>=0x110000)
@@ -135,8 +135,8 @@ static size_t encode_utf16(wxUint32 input, wchar_t *output)
{ {
if (output) if (output)
{ {
*output++ = (input >> 10)+0xd7c0; *output++ = (wchar_t) ((input >> 10)+0xd7c0);
*output++ = (input&0x3ff)+0xdc00; *output++ = (wchar_t) ((input&0x3ff)+0xdc00);
} }
return 2; return 2;
} }
@@ -389,7 +389,7 @@ size_t wxMBConvUTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const
{ {
// plain ASCII char // plain ASCII char
if (buf) if (buf)
*buf++ = cc; *buf++ = (char) cc;
len++; len++;
} }
@@ -398,9 +398,9 @@ size_t wxMBConvUTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const
len += cnt + 1; len += cnt + 1;
if (buf) if (buf)
{ {
*buf++ = (-128 >> cnt) | ((cc >> (cnt * 6)) & (0x3f >> cnt)); *buf++ = (char) ((-128 >> cnt) | ((cc >> (cnt * 6)) & (0x3f >> cnt)));
while (cnt--) while (cnt--)
*buf++ = 0x80 | ((cc >> (cnt * 6)) & 0x3f); *buf++ = (char) (0x80 | ((cc >> (cnt * 6)) & 0x3f));
} }
} }
} }
@@ -778,7 +778,7 @@ public:
w2m.Init(wxFONTENCODING_UNICODE, enc); w2m.Init(wxFONTENCODING_UNICODE, enc);
} }
size_t MB2WC(wchar_t *buf, const char *psz, size_t n) size_t MB2WC(wchar_t *buf, const char *psz, size_t WXUNUSED(n))
{ {
size_t inbuf = strlen(psz); size_t inbuf = strlen(psz);
if (buf) if (buf)
@@ -786,7 +786,7 @@ public:
return inbuf; return inbuf;
} }
size_t WC2MB(char *buf, const wchar_t *psz, size_t n) size_t WC2MB(char *buf, const wchar_t *psz, size_t WXUNUSED(n))
{ {
#if ( defined(__BORLANDC__) && (__BORLANDC__ > 0x530) ) \ #if ( defined(__BORLANDC__) && (__BORLANDC__ > 0x530) ) \
|| ( defined(__MWERKS__) && defined(__WXMSW__) ) || ( defined(__MWERKS__) && defined(__WXMSW__) )

View File

@@ -1810,7 +1810,7 @@ void wxVariant::operator= (const TIMESTAMP_STRUCT* value)
#endif // wxUSE_ODBC #endif // wxUSE_ODBC
bool wxVariant::operator==(const wxArrayString& value) const bool wxVariant::operator==(const wxArrayString& WXUNUSED(value)) const
{ {
wxFAIL_MSG( _T("TODO") ); wxFAIL_MSG( _T("TODO") );

View File

@@ -167,6 +167,10 @@ void wxWindowBase::InitBase()
m_caret = (wxCaret *)NULL; m_caret = (wxCaret *)NULL;
#endif // wxUSE_CARET #endif // wxUSE_CARET
#if wxUSE_PALETTE
m_custompalette = false;
#endif // wxUSE_PALETTE
// Whether we're using the current theme for this window (wxGTK only for now) // Whether we're using the current theme for this window (wxGTK only for now)
m_themeEnabled = FALSE; m_themeEnabled = FALSE;
} }
@@ -1002,7 +1006,7 @@ void wxWindowBase::OnHelp(wxHelpEvent& event)
#endif // wxUSE_HELP #endif // wxUSE_HELP
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// tooltips // tooltipsroot.Replace("\\", "/");
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS

View File

@@ -454,7 +454,7 @@ bool wxDirItemData::HasSubDirs() const
return dir.HasSubDirs(); return dir.HasSubDirs();
} }
bool wxDirItemData::HasFiles(const wxString& spec) const bool wxDirItemData::HasFiles(const wxString& WXUNUSED(spec)) const
{ {
if (m_path.IsEmpty()) if (m_path.IsEmpty())
return FALSE; return FALSE;

View File

@@ -108,6 +108,16 @@ wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* par
wxWindow(parent, id, pos, size, style) wxWindow(parent, id, pos, size, style)
{ {
m_bitmap = bitmap; m_bitmap = bitmap;
#ifndef __WXGTK__
bool hiColour = (wxDisplayDepth() >= 16) ;
if (bitmap.GetPalette() && !hiColour)
{
SetPalette(* bitmap.GetPalette());
}
#endif
} }
void wxSplashScreenWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) void wxSplashScreenWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
@@ -131,7 +141,6 @@ static void wxDrawSplashBitmap(wxDC& dc, const wxBitmap& bitmap, int WXUNUSED(x)
if (bitmap.GetPalette() && !hiColour) if (bitmap.GetPalette() && !hiColour)
{ {
dc.SetPalette(* bitmap.GetPalette());
dcMem.SetPalette(* bitmap.GetPalette()); dcMem.SetPalette(* bitmap.GetPalette());
} }
#endif // USE_PALETTE_IN_SPLASH #endif // USE_PALETTE_IN_SPLASH
@@ -143,7 +152,6 @@ static void wxDrawSplashBitmap(wxDC& dc, const wxBitmap& bitmap, int WXUNUSED(x)
#ifdef USE_PALETTE_IN_SPLASH #ifdef USE_PALETTE_IN_SPLASH
if (bitmap.GetPalette() && !hiColour) if (bitmap.GetPalette() && !hiColour)
{ {
dc.SetPalette(wxNullPalette);
dcMem.SetPalette(wxNullPalette); dcMem.SetPalette(wxNullPalette);
} }
#endif // USE_PALETTE_IN_SPLASH #endif // USE_PALETTE_IN_SPLASH

View File

@@ -789,13 +789,13 @@ size_t wxGenericTreeCtrl::GetCount() const
void wxGenericTreeCtrl::SetIndent(unsigned int indent) void wxGenericTreeCtrl::SetIndent(unsigned int indent)
{ {
m_indent = indent; m_indent = (unsigned short) indent;
m_dirty = TRUE; m_dirty = TRUE;
} }
void wxGenericTreeCtrl::SetSpacing(unsigned int spacing) void wxGenericTreeCtrl::SetSpacing(unsigned int spacing)
{ {
m_spacing = spacing; m_spacing = (unsigned short) spacing;
m_dirty = TRUE; m_dirty = TRUE;
} }

View File

@@ -32,7 +32,7 @@ FORCE_LINK_ME(m_style)
TAG_HANDLER_BEGIN(STYLE, "STYLE") TAG_HANDLER_BEGIN(STYLE, "STYLE")
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(WXUNUSED(tag))
{ {
// VS: Ignore styles for now. We must have this handler present, // VS: Ignore styles for now. We must have this handler present,
// because CSS style text would be rendered verbatim otherwise // because CSS style text would be rendered verbatim otherwise

View File

@@ -1143,7 +1143,7 @@ void wxDC::DoDrawRotatedText(const wxString& text,
#if wxUSE_PALETTE #if wxUSE_PALETTE
void wxDC::SetPalette(const wxPalette& palette) void wxDC::DoSelectPalette(bool realize)
{ {
#ifdef __WXMICROWIN__ #ifdef __WXMICROWIN__
if (!GetHDC()) return; if (!GetHDC()) return;
@@ -1157,31 +1157,44 @@ void wxDC::SetPalette(const wxPalette& palette)
m_oldPalette = 0; m_oldPalette = 0;
} }
m_palette = palette;
if (!m_palette.Ok())
{
// Setting a NULL colourmap is a way of restoring
// the original colourmap
if (m_oldPalette)
{
::SelectPalette(GetHdc(), (HPALETTE) m_oldPalette, FALSE);
m_oldPalette = 0;
}
return;
}
if (m_palette.Ok() && m_palette.GetHPALETTE()) if (m_palette.Ok() && m_palette.GetHPALETTE())
{ {
HPALETTE oldPal = ::SelectPalette(GetHdc(), (HPALETTE) m_palette.GetHPALETTE(), FALSE); HPALETTE oldPal = ::SelectPalette(GetHdc(), (HPALETTE) m_palette.GetHPALETTE(), FALSE);
if (!m_oldPalette) if (!m_oldPalette)
m_oldPalette = (WXHPALETTE) oldPal; m_oldPalette = (WXHPALETTE) oldPal;
if (realize)
::RealizePalette(GetHdc()); ::RealizePalette(GetHdc());
} }
}
void wxDC::SetPalette(const wxPalette& palette)
{
if (palette.Ok()) {
m_palette = palette;
DoSelectPalette(true);
}
} }
void wxDC::InitializePalette()
{
if (wxDisplayDepth() <= 8) {
// look for any window or parent that has a custom palette. If any has
// one then we need to use it in drawing operations
wxWindow *win = m_canvas;
while (!win->HasCustomPalette() && win->GetParent()) win = win->GetParent();
if (win->HasCustomPalette()) {
m_palette = win->GetPalette();
m_custompalette = true;
// turn on MSW translation for this palette
DoSelectPalette();
}
else
m_custompalette = false;
}
}
#endif // wxUSE_PALETTE #endif // wxUSE_PALETTE
void wxDC::SetFont(const wxFont& the_font) void wxDC::SetFont(const wxFont& the_font)

View File

@@ -113,6 +113,11 @@ void wxWindowDC::InitDC()
// default bg colour is pne of the window // default bg colour is pne of the window
SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID)); SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
// since we are a window dc we need to grab the palette from the window
#if wxUSE_PALETTE
InitializePalette();
#endif
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -275,8 +275,9 @@ bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
#ifndef __WXMICROWIN__ #ifndef __WXMICROWIN__
int CALLBACK wxFontEnumeratorProc(LPLOGFONT lplf, LPTEXTMETRIC lptm, int CALLBACK wxFontEnumeratorProc(LPLOGFONT lplf, LPTEXTMETRIC lptm,
DWORD dwStyle, LONG lParam) DWORD WXUNUSED(dwStyle), LONG lParam)
{ {
// we used to process TrueType fonts only, but there doesn't seem to be any // we used to process TrueType fonts only, but there doesn't seem to be any
// reasons to restrict ourselves to them here // reasons to restrict ourselves to them here
#if 0 #if 0

View File

@@ -2339,7 +2339,7 @@ static void wxConvertToMSWListItem(const wxListCtrl *ctrl,
lvItem.mask |= LVIF_PARAM; lvItem.mask |= LVIF_PARAM;
} }
static void wxConvertToMSWListCol(int col, const wxListItem& item, static void wxConvertToMSWListCol(int WXUNUSED(col), const wxListItem& item,
LV_COLUMN& lvCol) LV_COLUMN& lvCol)
{ {
wxZeroMemory(lvCol); wxZeroMemory(lvCol);

View File

@@ -685,13 +685,13 @@ void wxDataObject::SetAutoDelete()
m_pIDataObject = NULL; m_pIDataObject = NULL;
} }
size_t wxDataObject::GetBufferOffset( const wxDataFormat& format ) size_t wxDataObject::GetBufferOffset( const wxDataFormat& WXUNUSED(format) )
{ {
return sizeof(size_t); return sizeof(size_t);
} }
const void* wxDataObject::GetSizeFromBuffer( const void* buffer, size_t* size, const void* wxDataObject::GetSizeFromBuffer( const void* buffer, size_t* size,
const wxDataFormat& format ) const wxDataFormat& WXUNUSED(format) )
{ {
size_t* p = (size_t*)buffer; size_t* p = (size_t*)buffer;
*size = *p; *size = *p;
@@ -700,7 +700,7 @@ const void* wxDataObject::GetSizeFromBuffer( const void* buffer, size_t* size,
} }
void* wxDataObject::SetSizeInBuffer( void* buffer, size_t size, void* wxDataObject::SetSizeInBuffer( void* buffer, size_t size,
const wxDataFormat& format ) const wxDataFormat& WXUNUSED(format) )
{ {
size_t* p = (size_t*)buffer; size_t* p = (size_t*)buffer;
*p = size; *p = size;
@@ -1070,13 +1070,13 @@ class CFSTR_SHELLURLDataObject:public wxCustomDataObject
public: public:
CFSTR_SHELLURLDataObject() : wxCustomDataObject(CFSTR_SHELLURL) {} CFSTR_SHELLURLDataObject() : wxCustomDataObject(CFSTR_SHELLURL) {}
protected: protected:
virtual size_t GetBufferOffset( const wxDataFormat& format ) virtual size_t GetBufferOffset( const wxDataFormat& WXUNUSED(format) )
{ {
return 0; return 0;
} }
virtual const void* GetSizeFromBuffer( const void* buffer, size_t* size, virtual const void* GetSizeFromBuffer( const void* buffer, size_t* size,
const wxDataFormat& format ) const wxDataFormat& WXUNUSED(format) )
{ {
// CFSTR_SHELLURL is _always_ ANSI text // CFSTR_SHELLURL is _always_ ANSI text
*size = strlen( (const char*)buffer ); *size = strlen( (const char*)buffer );
@@ -1084,8 +1084,8 @@ protected:
return buffer; return buffer;
} }
virtual void* SetSizeInBuffer( void* buffer, size_t size, virtual void* SetSizeInBuffer( void* buffer, size_t WXUNUSED(size),
const wxDataFormat& format ) const wxDataFormat& WXUNUSED(format) )
{ {
return buffer; return buffer;
} }

View File

@@ -1087,7 +1087,7 @@ bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* pMsg)
// usual preprocessing for them // usual preprocessing for them
if ( msg->message == WM_KEYDOWN ) if ( msg->message == WM_KEYDOWN )
{ {
WORD vkey = msg->wParam; WORD vkey = (WORD) msg->wParam;
if ( (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN ) if ( (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN )
{ {
if ( vkey == VK_BACK ) if ( vkey == VK_BACK )
@@ -1437,7 +1437,7 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
// EN_LINK processing // EN_LINK processing
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) bool wxTextCtrl::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *result)
{ {
NMHDR *hdr = (NMHDR* )lParam; NMHDR *hdr = (NMHDR* )lParam;
if ( hdr->code == EN_LINK ) if ( hdr->code == EN_LINK )

View File

@@ -890,14 +890,14 @@ void wxWindowMSW::SetScrollbar(int orient, int pos, int thumbVisible,
void wxWindowMSW::ScrollWindow(int dx, int dy, const wxRect *prect) void wxWindowMSW::ScrollWindow(int dx, int dy, const wxRect *prect)
{ {
RECT rect, *pr; RECT rect;
RECT *pr;
if ( prect ) if ( prect )
{ {
rect.left = prect->x; rect.left = prect->x;
rect.top = prect->y; rect.top = prect->y;
rect.right = prect->x + prect->width; rect.right = prect->x + prect->width;
rect.bottom = prect->y + prect->height; rect.bottom = prect->y + prect->height;
pr = &rect; pr = &rect;
} }
else else
@@ -1951,11 +1951,12 @@ bool wxWindowMSW::MSWTranslateMessage(WXMSG* pMsg)
#if wxUSE_ACCEL && !defined(__WXUNIVERSAL__) #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
return m_acceleratorTable.Translate(this, pMsg); return m_acceleratorTable.Translate(this, pMsg);
#else #else
(void) pMsg;
return FALSE; return FALSE;
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
} }
bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* pMsg) bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* WXUNUSED(pMsg))
{ {
// preprocess all messages by default // preprocess all messages by default
return TRUE; return TRUE;
@@ -2501,6 +2502,10 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
processed = HandleSysColorChange(); processed = HandleSysColorChange();
break; break;
case WM_DISPLAYCHANGE:
processed = HandleDisplayChange();
break;
case WM_PALETTECHANGED: case WM_PALETTECHANGED:
processed = HandlePaletteChanged((WXHWND) (HWND) wParam); processed = HandlePaletteChanged((WXHWND) (HWND) wParam);
break; break;
@@ -3289,6 +3294,14 @@ bool wxWindowMSW::HandleSysColorChange()
return FALSE; return FALSE;
} }
bool wxWindowMSW::HandleDisplayChange()
{
wxDisplayChangedEvent event;
event.SetEventObject(this);
return GetEventHandler()->ProcessEvent(event);
}
bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush, bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush,
WXHDC pDC, WXHDC pDC,
WXHWND pWnd, WXHWND pWnd,
@@ -3335,6 +3348,32 @@ WXHBRUSH wxWindowMSW::OnCtlColor(WXHDC WXUNUSED(hDC),
bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange) bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange)
{ {
#if wxUSE_PALETTE
// same as below except we don't respond to our own messages
if (hWndPalChange != GetHWND()) {
// check to see if we our our parents have a custom palette
wxWindow *win = this;
while (!win->HasCustomPalette() && win->GetParent()) win = win->GetParent();
if (win->HasCustomPalette()) {
/* realize the palette to see whether redrawing is needed */
HDC hdc = GetDC((HWND) hWndPalChange);
win->m_palette.SetHPALETTE( (WXHPALETTE)
::SelectPalette(hdc, (HPALETTE) win->m_palette.GetHPALETTE(), false) );
int result = ::RealizePalette(hdc);
/* restore the palette (before releasing the DC) */
win->m_palette.SetHPALETTE( (WXHPALETTE)
::SelectPalette(hdc, (HPALETTE) win->m_palette.GetHPALETTE(), true) );
RealizePalette(hdc);
ReleaseDC((HWND) hWndPalChange, hdc);
/* now check for the need to redraw */
if (result > 0)
InvalidateRect((HWND) hWndPalChange, NULL, TRUE);
}
}
#endif
wxPaletteChangedEvent event(GetId()); wxPaletteChangedEvent event(GetId());
event.SetEventObject(this); event.SetEventObject(this);
event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
@@ -3344,6 +3383,29 @@ bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange)
bool wxWindowMSW::HandleQueryNewPalette() bool wxWindowMSW::HandleQueryNewPalette()
{ {
#if wxUSE_PALETTE
// check to see if we our our parents have a custom palette
wxWindow *win = this;
while (!win->HasCustomPalette() && win->GetParent()) win = win->GetParent();
if (win->HasCustomPalette()) {
/* realize the palette to see whether redrawing is needed */
HDC hdc = GetDC((HWND) GetHWND());
win->m_palette.SetHPALETTE( (WXHPALETTE)
::SelectPalette(hdc, (HPALETTE) win->m_palette.GetHPALETTE(), false) );
int result = ::RealizePalette(hdc);
/* restore the palette (before releasing the DC) */
win->m_palette.SetHPALETTE( (WXHPALETTE)
::SelectPalette(hdc, (HPALETTE) win->m_palette.GetHPALETTE(), true) );
::RealizePalette(hdc);
::ReleaseDC((HWND) GetHWND(), hdc);
/* now check for the need to redraw */
if (result > 0)
::InvalidateRect((HWND) GetHWND(), NULL, TRUE);
}
#endif
wxQueryNewPaletteEvent event(GetId()); wxQueryNewPaletteEvent event(GetId());
event.SetEventObject(this); event.SetEventObject(this);
@@ -3351,7 +3413,7 @@ bool wxWindowMSW::HandleQueryNewPalette()
} }
// Responds to colour changes: passes event on to children. // Responds to colour changes: passes event on to children.
void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& event) void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{ {
// the top level window also reset the standard colour map as it might have // the top level window also reset the standard colour map as it might have
// changed (there is no need to do it for the non top level windows as we // changed (there is no need to do it for the non top level windows as we

View File

@@ -353,8 +353,8 @@ inline static wxString CharToString(wxMBConv *conv,
wchar_t *buf = new wchar_t[nLen+1]; wchar_t *buf = new wchar_t[nLen+1];
wxConvUTF8.MB2WC(buf, s, nLen); wxConvUTF8.MB2WC(buf, s, nLen);
buf[nLen] = 0; buf[nLen] = 0;
return wxString(buf, *conv, len);
delete[] buf; delete[] buf;
return wxString(buf, *conv, len);
} }
else else
return wxString(s, len); return wxString(s, len);
@@ -475,7 +475,7 @@ static int UnknownEncodingHnd(void * WXUNUSED(encodingHandlerData),
size_t i; size_t i;
for (i = 0; i < 255; i++) for (i = 0; i < 255; i++)
mbBuf[i] = i+1; mbBuf[i] = (char) (i+1);
mbBuf[255] = 0; mbBuf[255] = 0;
conv.MB2WC(wcBuf, mbBuf, 255); conv.MB2WC(wcBuf, mbBuf, 255);
wcBuf[255] = 0; wcBuf[255] = 0;