From 574c939ef1c1b835a8bc65c0fe724548fa04ec49 Mon Sep 17 00:00:00 2001 From: Kendall Bennett Date: Thu, 7 Feb 2002 18:46:31 +0000 Subject: [PATCH] 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 --- contrib/include/wx/applet/applet.h | 4 +- contrib/include/wx/applet/echovar.h | 107 ++++--- contrib/include/wx/applet/ifelsevar.h | 105 ++++--- contrib/include/wx/applet/loadpage.h | 11 +- contrib/include/wx/applet/plugin.h | 12 +- contrib/include/wx/applet/prepecho.h | 1 + contrib/include/wx/applet/prepifelse.h | 1 + contrib/include/wx/applet/prepinclude.h | 5 + contrib/include/wx/applet/window.h | 57 ++-- contrib/src/applet/applet.cpp | 3 - contrib/src/applet/appletwindow.cpp | 368 +++++++++++++----------- contrib/src/applet/echovar.cpp | 114 +++++--- contrib/src/applet/ifelsevar.cpp | 143 ++++++--- contrib/src/applet/loadpage.cpp | 32 +-- contrib/src/applet/plugin.cpp | 13 +- contrib/src/applet/prepecho.cpp | 17 +- contrib/src/applet/prepifelse.cpp | 146 ++++++++-- contrib/src/applet/prepinclude.cpp | 56 +++- contrib/src/xrc/xml.cpp | 54 ++-- include/wx/dc.h | 2 +- include/wx/event.h | 46 ++- include/wx/html/htmlwin.h | 14 +- include/wx/imagbmp.h | 12 +- include/wx/listctrl.h | 2 +- include/wx/msw/dc.h | 17 +- include/wx/msw/window.h | 2 + include/wx/window.h | 25 ++ src/common/event.cpp | 2 + src/common/filename.cpp | 7 +- src/common/imagbmp.cpp | 93 +++--- src/common/quantize.cpp | 4 +- src/common/strconv.cpp | 16 +- src/common/variant.cpp | 2 +- src/common/wincmn.cpp | 6 +- src/generic/dirctrlg.cpp | 8 +- src/generic/splash.cpp | 12 +- src/generic/treectlg.cpp | 14 +- src/html/m_style.cpp | 2 +- src/msw/dc.cpp | 47 +-- src/msw/dcclient.cpp | 5 + src/msw/fontenum.cpp | 3 +- src/msw/listctrl.cpp | 2 +- src/msw/ole/dataobj.cpp | 14 +- src/msw/textctrl.cpp | 4 +- src/msw/window.cpp | 70 ++++- src/xrc/xml.cpp | 54 ++-- 46 files changed, 1116 insertions(+), 618 deletions(-) diff --git a/contrib/include/wx/applet/applet.h b/contrib/include/wx/applet/applet.h index 3965ca1fc2..42c8e18dde 100644 --- a/contrib/include/wx/applet/applet.h +++ b/contrib/include/wx/applet/applet.h @@ -34,7 +34,7 @@ // Forward declaration class wxHtmlAppletWindow; - +class wxAppletEvent; /*--------------------------- Class Definitions ---------------------------*/ /**************************************************************************** @@ -76,7 +76,7 @@ public: virtual void OnHistoryBack() = 0; // Handle messages from the wxAppletManager and other applets - virtual void OnMessage(wxEvent& msg) = 0; + virtual void OnMessage(wxAppletEvent& msg) = 0; }; diff --git a/contrib/include/wx/applet/echovar.h b/contrib/include/wx/applet/echovar.h index 9fd5708f5c..33b91e244e 100644 --- a/contrib/include/wx/applet/echovar.h +++ b/contrib/include/wx/applet/echovar.h @@ -30,57 +30,98 @@ #ifndef __WX_ECHOVAR_H #define __WX_ECHOVAR_H +#include "wx/object.h" +#include "wx/hash.h" + /*--------------------------- Class Definitions ---------------------------*/ +/**************************************************************************** +RETURNS: +The string value of the variable + +PARAMETERS: +parms - Optional parameter string passed from parm= field in HTML + +REMARKS: +To create new variables for the #echo HTML preprocessing directives +you need to derive classes from wxEchoVariable and override the +pure virtual GetValue function. However this should not be done directly +but by using the BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros + +SEE ALSO: +wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE +****************************************************************************/ +typedef wxString (*wxEchoVariableGetValueFn)(const char *parms); + /**************************************************************************** REMARKS: wxEchoVariable class Definition ****************************************************************************/ class wxEchoVariable : public wxObject { -private: - DECLARE_ABSTRACT_CLASS(wxEchoVariable); +protected: + const wxChar *m_varName; + wxEchoVariableGetValueFn m_getValueFn; + static wxEchoVariable *sm_first; + wxEchoVariable *m_next; + static wxHashTable *sm_varTable; + + static inline wxEchoVariable *wxEchoVariable::FindVariable(const wxChar *varName); public: - wxEchoVariable() : wxObject() {} - ~wxEchoVariable() {} + // Constructor to create the echo variable and register the class + wxEchoVariable( + const char *varName, + wxEchoVariableGetValueFn getValueFn); + + // Member variable access functions + const wxChar *GetClassName() const { return m_varName; } + wxEchoVariableGetValueFn GetValueFn() const { return m_getValueFn; } + static const wxEchoVariable* GetFirst() { return sm_first; } + const wxEchoVariable* GetNext() const { return m_next; } - /**************************************************************************** - RETURNS: - The boolean value of the variable + // Static functions to retrieve any variable avaliable + static wxString GetValue(const wxChar *varName,const wxChar *parms = NULL); + static bool Exists(const wxChar *varName); - PARAMETERS: - parms - Optional parameter string passed from parm= field in HTML + // Initializes parent pointers and hash table for fast searching. + static void Initialize(); - REMARKS: - To create new variables for the #echo HTML preprocessing directives - you need to derive classes from wxEchoVariable and override the - pure virtual GetValue function. However this should not be done directly - but by using the BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros + // Cleans up hash table used for fast searching. + static void CleanUp(); + }; + +/**************************************************************************** +PARAMETERS: +class - Name of class for echo variable to find - SEE ALSO: - wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE - ****************************************************************************/ - virtual wxString GetValue(const char *parms = NULL) const = 0; +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; + } +} -public: - // static function to retrieve any variable avaliable - static wxString FindValue(const wxString &cls, const char *parms = NULL); - }; - /*--------------------------------- MACROS --------------------------------*/ -#define ECHO_PARM (_BEV_parm) #define BEGIN_ECHO_VARIABLE(name) \ - class wxEchoVariable##name : public wxEchoVariable { \ - private: \ - DECLARE_DYNAMIC_CLASS(wxEchoVariable##name##); \ - public: \ - wxEchoVariable##name##() : wxEchoVariable() {} \ - virtual wxString GetValue(const char *parms = NULL) const; \ - }; \ - IMPLEMENT_DYNAMIC_CLASS(wxEchoVariable##name##, wxEchoVariable); \ - wxString wxEchoVariable##name :: GetValue(const char *parms) const { \ +wxString wxEchoVariableFn##name(const char *parms); \ +wxEchoVariable wxEchoVariable##name(#name,wxEchoVariableFn##name); \ +wxString wxEchoVariableFn##name(const char *parms) { \ wxString _BEV_parm = wxString(parms); #define END_ECHO_VARIABLE(returnval) \ diff --git a/contrib/include/wx/applet/ifelsevar.h b/contrib/include/wx/applet/ifelsevar.h index 5a95b84ff7..b857b2bfc6 100644 --- a/contrib/include/wx/applet/ifelsevar.h +++ b/contrib/include/wx/applet/ifelsevar.h @@ -30,57 +30,98 @@ #ifndef __WX_IFELSEVAR_H #define __WX_IFELSEVAR_H +#include "wx/object.h" +#include "wx/hash.h" + /*--------------------------- Class Definitions ---------------------------*/ /**************************************************************************** +RETURNS: +The boolean value of the variable + REMARKS: -This class is used to create variables for the HTML preprocessor #if, #else, -and #endif directives. +To create new variables for the #if, #else and #endif HTML preprocessing +blocks you need to derive classes from wxIfElseVariable and override the +pure virtual GetValue function. However this should not be done directly +but by using the BEGIN_IFELSE_VARIABLE and END_IFELSE_VARIABLE macros SEE ALSO: -wxIfElsePrep +wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE +****************************************************************************/ +typedef bool (*wxIfElseVariableGetValueFn)(); + +/**************************************************************************** +REMARKS: +wxIfElseVariable class Definition ****************************************************************************/ class wxIfElseVariable : public wxObject { -private: - DECLARE_ABSTRACT_CLASS(wxIfElseVariable); +protected: + const wxChar *m_varName; + wxIfElseVariableGetValueFn m_getValueFn; + static wxIfElseVariable *sm_first; + wxIfElseVariable *m_next; + static wxHashTable *sm_varTable; + bool forced; + bool forceVal; + + static inline wxIfElseVariable *wxIfElseVariable::FindVariable(const wxChar *varName); public: - wxIfElseVariable() : wxObject() {} - ~wxIfElseVariable() {} + // Constructor to create the echo variable and register the class + wxIfElseVariable( + const char *varName, + wxIfElseVariableGetValueFn getValueFn); + + // Member variable access functions + const wxChar *GetClassName() const { return m_varName; } + wxIfElseVariableGetValueFn GetValueFn() const { return m_getValueFn; } + static const wxIfElseVariable* GetFirst() { return sm_first; } + const wxIfElseVariable* GetNext() const { return m_next; } - /**************************************************************************** - RETURNS: - The boolean value of the variable + // Static functions to retrieve any variable avaliable + static bool GetValue(const wxChar *varName); + static bool Exists(const wxChar *varName); + static void Force(const wxChar *varName, bool val); - REMARKS: - To create new variables for the #if, #else and #endif HTML preprocessing - blocks you need to derive classes from wxIfElseVariable and override the - pure virtual GetValue function. However this should not be done directly - but by using the BEGIN_IFELSE_VARIABLE and END_IFELSE_VARIABLE macros + // Initializes parent pointers and hash table for fast searching. + static void Initialize(); - SEE ALSO: - wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE - ****************************************************************************/ - virtual bool GetValue() const = 0; + // 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 -public: - // static function to retrieve any variable avaliable - static bool FindValue(const wxString &cls); - }; +REMARKS: +Inline helper function to find the echo variable from it's class name. +****************************************************************************/ +inline wxIfElseVariable *wxIfElseVariable::FindVariable( + const wxChar *varName) +{ + if (sm_varTable) + return (wxIfElseVariable*)sm_varTable->Get(varName); + else { + wxIfElseVariable *info = sm_first; + while (info) { + if (info->m_varName && wxStrcmp(info->m_varName, varName) == 0) + return info; + info = info->m_next; + } + return NULL; + } +} /*--------------------------------- MACROS --------------------------------*/ #define BEGIN_IFELSE_VARIABLE(name) \ - class wxIfElseVariable##name : public wxIfElseVariable { \ - private: \ - DECLARE_DYNAMIC_CLASS(wxIfElseVariable##name##); \ - public: \ - wxIfElseVariable##name##() : wxIfElseVariable() {} \ - virtual bool GetValue() const; \ - }; \ - IMPLEMENT_DYNAMIC_CLASS(wxIfElseVariable##name##, wxIfElseVariable); \ - bool wxIfElseVariable##name :: GetValue() const { +bool wxIfElseVariableFn##name(); \ +wxIfElseVariable wxIfElseVariable##name(#name,wxIfElseVariableFn##name); \ +bool wxIfElseVariableFn##name() { \ #define END_IFELSE_VARIABLE(returnval) \ return returnval; \ diff --git a/contrib/include/wx/applet/loadpage.h b/contrib/include/wx/applet/loadpage.h index f20cd0c3fe..4be49c0dc9 100644 --- a/contrib/include/wx/applet/loadpage.h +++ b/contrib/include/wx/applet/loadpage.h @@ -68,14 +68,15 @@ public: // Destructor ~wxLoadPageEvent() {} + // Clone Virtual + virtual wxEvent *Clone() const { return new wxLoadPageEvent(m_hRef, m_htmlWindow); } + // Return the hmtl window for the load page operation wxHtmlAppletWindow *GetHtmlWindow() { return m_htmlWindow; }; // Get the hRef string for the load page operation const wxString & GetHRef() { return m_hRef; }; - // Copy constructor for the object - void CopyObject(wxObject& obj) const; }; @@ -97,8 +98,10 @@ public: // Destructor ~wxPageLoadedEvent() {} - // Copy constructor for the object - void CopyObject(wxObject& obj) const; + // Clone Virtual + virtual wxEvent *Clone() const { + return new wxPageLoadedEvent(); } + }; // Define the macro to create our event type diff --git a/contrib/include/wx/applet/plugin.h b/contrib/include/wx/applet/plugin.h index 1aff089a25..dbbecb0e71 100644 --- a/contrib/include/wx/applet/plugin.h +++ b/contrib/include/wx/applet/plugin.h @@ -32,17 +32,19 @@ // Forward declaration class wxHtmlAppletWindow; +#include "wx/event.h" + /*--------------------------- Class Definitions ---------------------------*/ /**************************************************************************** REMARKS: -Defines the abstract base class for wxQlet objects. +Defines the abstract base class for wxPlugIn objects. ****************************************************************************/ -class wxPlugIn : public wxObject { +class wxPlugIn : public wxEvtHandler { private: + wxHtmlAppletWindow *m_parent; DECLARE_ABSTRACT_CLASS(wxPlugIn); - wxHtmlAppletWindow *m_parent; public: // Constructor (called during dynamic creation) wxPlugIn() { m_parent = NULL; }; @@ -50,8 +52,12 @@ public: // Psuedo virtual constructor virtual bool Create(wxHtmlAppletWindow *parent); + // Function that actually executes the main plugin code + virtual void Run(const wxString& cmdLine); + // Virtual destructor virtual ~wxPlugIn(); }; + #endif // __WX_PLUGIN_H diff --git a/contrib/include/wx/applet/prepecho.h b/contrib/include/wx/applet/prepecho.h index 50cde400b0..118174a05a 100644 --- a/contrib/include/wx/applet/prepecho.h +++ b/contrib/include/wx/applet/prepecho.h @@ -30,6 +30,7 @@ #ifndef __WX_PREPECHO_H #define __WX_PREPECHO_H +#include "wx/object.h" #include "wx/html/htmlproc.h" /*--------------------------- Class Definitions ---------------------------*/ diff --git a/contrib/include/wx/applet/prepifelse.h b/contrib/include/wx/applet/prepifelse.h index 216f5d5ba5..67f28bd75a 100644 --- a/contrib/include/wx/applet/prepifelse.h +++ b/contrib/include/wx/applet/prepifelse.h @@ -30,6 +30,7 @@ #ifndef __WX_PREPIFELSE_H #define __WX_PREPIFELSE_H +#include "wx/object.h" #include "wx/html/htmlproc.h" /*--------------------------- Class Definitions ---------------------------*/ diff --git a/contrib/include/wx/applet/prepinclude.h b/contrib/include/wx/applet/prepinclude.h index 21178334d1..c021cf56dc 100644 --- a/contrib/include/wx/applet/prepinclude.h +++ b/contrib/include/wx/applet/prepinclude.h @@ -30,8 +30,13 @@ #ifndef __WX_PREPINCLUDE_H #define __WX_PREPINCLUDE_H +#include "wx/object.h" #include "wx/html/htmlproc.h" +/*------------------------------- Prototypes ------------------------------*/ + +class wxFileSystem; + /*--------------------------- Class Definitions ---------------------------*/ /**************************************************************************** diff --git a/contrib/include/wx/applet/window.h b/contrib/include/wx/applet/window.h index 340023b886..5746a12543 100644 --- a/contrib/include/wx/applet/window.h +++ b/contrib/include/wx/applet/window.h @@ -46,6 +46,21 @@ class wxToolBarBase; WX_DECLARE_LIST(wxApplet, wxAppletList); /*--------------------------- Class Definitions ---------------------------*/ +class wxAppletEvent { +protected: + int m_id; + wxObject *m_eventObject; +public: + wxAppletEvent(int id) { m_eventObject=NULL; m_id = id; } + + int GetId() const { return m_id; } + void SetId(int Id) { m_id = Id; } + + wxObject *GetEventObject() const { return m_eventObject; } + void SetEventObject(wxObject *obj) { m_eventObject = obj; } + +}; + /**************************************************************************** REMARKS: @@ -53,16 +68,21 @@ Defines the class for virtual-link data types ****************************************************************************/ class VirtualData : public wxObject { private: + DECLARE_DYNAMIC_CLASS(VirtualData); + +protected: wxString m_name; wxString m_group; wxString m_href; + wxString m_plugIn; public: // Ctors VirtualData( wxString& name, wxString& group, - wxString& href ); + wxString& href, + wxString& plugin ); VirtualData(); @@ -70,11 +90,14 @@ public: wxString GetName(){ return m_name;}; wxString GetGroup(){ return m_group;}; wxString GetHref(){ return m_href;}; + wxString GetPlugIn(){ return m_plugIn;}; // Sets void SetName (wxString& s){ m_name = s; }; void SetGroup(wxString& s){ m_group = s; }; void SetHref (wxString& s){ m_href = s; }; + void SetPlugIn (wxString& s){ m_plugIn = s;}; + void EmptyPlugIn () { m_plugIn = "";}; }; /**************************************************************************** @@ -98,7 +121,7 @@ protected: wxToolBarBase *m_NavBar; int m_NavBackId; int m_NavForwardId; - wxPalette m_globalPalette; + wxString m_openedlast; // Override this so we can do proper palette management!! virtual void OnDraw(wxDC& dc); @@ -114,8 +137,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxHW_SCROLLBAR_AUTO, - const wxString& name = "htmlAppletWindow", - const wxPalette& globalPalette = wxNullPalette); + const wxString& name = "htmlAppletWindow"); // Destructor ~wxHtmlAppletWindow(); @@ -128,7 +150,7 @@ public: const wxSize& size); // Create an instance of an Qlet based on it's class name - bool CreatePlugIn(const wxString& classId ); + bool CreatePlugIn(const wxString& classId,const wxString& cmdLine = ""); // Find an instance of an applet based on it's class name wxApplet *FindApplet(const wxString& className); @@ -157,7 +179,7 @@ public: void SetNavBar(wxToolBarBase *navBar); // Broadcast a message to all applets on the page - void SendMessage(wxEvent& msg); + void SendAppletMessage(wxAppletEvent& msg); // Register a cookie of data in the applet manager static bool RegisterCookie(const wxString& name,wxObject *cookie); @@ -184,25 +206,7 @@ public: // Tries to lock the mutex. If it can't, returns immediately with false. bool TryLock(); - }; - -/**************************************************************************** -REMARKS: -Defines the class for AppetProcess -***************************************************************************/ -class AppletProcess : public wxProcess { -public: - AppletProcess( - wxWindow *parent) - : wxProcess(parent) - { - } - - // instead of overriding this virtual function we might as well process the - // event from it in the frame class - this might be more convenient in some - // cases - virtual void OnTerminate(int pid, int status); - + wxString GetLastOpened() { return m_openedlast; } }; /**************************************************************************** @@ -213,7 +217,7 @@ class wxHtmlAppletCell : public wxHtmlCell { public: wxHtmlAppletCell(wxWindow *wnd, int w = 0); - ~wxHtmlAppletCell() { m_Wnd->Destroy(); } + virtual ~wxHtmlAppletCell(); virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); virtual void DrawInvisible(wxDC& dc, int x, int y); virtual void Layout(int w); @@ -223,6 +227,5 @@ protected: // width float is used in adjustWidth (it is in percents) }; - #endif // __WX_APPLET_WINDOW_H diff --git a/contrib/src/applet/applet.cpp b/contrib/src/applet/applet.cpp index 660f609ae2..1765f9b54e 100644 --- a/contrib/src/applet/applet.cpp +++ b/contrib/src/applet/applet.cpp @@ -26,9 +26,6 @@ * ****************************************************************************/ -// For compilers that support precompilation -#include "wx/wxprec.h" - // Include private headers #include "wx/applet/applet.h" #include "wx/applet/window.h" diff --git a/contrib/src/applet/appletwindow.cpp b/contrib/src/applet/appletwindow.cpp index cd9cc4e7dc..9329a0bb20 100644 --- a/contrib/src/applet/appletwindow.cpp +++ b/contrib/src/applet/appletwindow.cpp @@ -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 // spawnl() -#endif - // Include private headers #include "wx/applet/applet.h" #include "wx/applet/window.h" @@ -49,6 +37,22 @@ #include "wx/applet/prepecho.h" #include "wx/applet/prepifelse.h" +// wxWindows headers + +// Kind of pointless to use precompiled headers when this is the only +// file in this lib that would need them. +#include "wx/defs.h" +#include "wx/spawnbrowser.h" +#include "wx/html/forcelnk.h" +#include "wx/log.h" +#include "wx/msgdlg.h" +#include "wx/tbarbase.h" + +// crt +#ifdef __WXMSW__ +#include // spawnl() +#endif + /*---------------------------- Global variables ---------------------------*/ wxHashTable wxHtmlAppletWindow::m_Cookies; @@ -66,6 +70,9 @@ END_EVENT_TABLE() // Implement the class functions for wxHtmlAppletWindow IMPLEMENT_CLASS(wxHtmlAppletWindow, wxHtmlWindow); +// Implement the dynamic class so it can be constructed dynamically +IMPLEMENT_DYNAMIC_CLASS(VirtualData, wxObject); + // Define the wxAppletList implementation #include "wx/listimpl.cpp" WX_DEFINE_LIST(wxAppletList); @@ -83,9 +90,8 @@ wxHtmlAppletWindow::wxHtmlAppletWindow( const wxPoint& pos, const wxSize& size, long style, - const wxString& name, - const wxPalette& globalPalette) - : wxHtmlWindow(parent,id,pos,size,style,name), m_globalPalette(globalPalette) + const wxString& name) + : wxHtmlWindow(parent,id,pos,size,style,name), m_AppletList(wxKEY_STRING) { // Init our locks UnLock(); @@ -105,22 +111,13 @@ wxHtmlAppletWindow::wxHtmlAppletWindow( m_NavBackId = navBackId; m_NavForwardId = navForwardId; - - // Set the key_type for applets - m_AppletList = wxAppletList(wxKEY_STRING); - // Add HTML preprocessors // deleting preprocessors is done by the code within the window - incPreprocessor = new wxIncludePrep(); // #include preprocessor incPreprocessor->ChangeDirectory(m_FS); // give it access to our filesys object - - wxEchoPrep * echoPreprocessor = new wxEchoPrep(); // #echo preprocessor - wxIfElsePrep * ifPreprocessor = new wxIfElsePrep(); - this->AddProcessor(incPreprocessor); - this->AddProcessor(echoPreprocessor); - this->AddProcessor(ifPreprocessor); + this->AddProcessor(new wxEchoPrep()); + this->AddProcessor(new wxIfElsePrep()); } /**************************************************************************** @@ -131,24 +128,15 @@ wxHtmlAppletWindow::~wxHtmlAppletWindow() { } -#include "scitech.h" - /**************************************************************************** PARAMETERS: dc - wxDC object to draw on REMARKS: -This function handles drawing the HTML applet window. Because the standard -wxWindows classes don't properly handle palette management, we add code -in here to properly select the global palette that we use for all drawing -into the DC before we allow the regular wxWindows code to finish the -drawing process. ****************************************************************************/ void wxHtmlAppletWindow::OnDraw( wxDC& dc) { - // TODO: Only do this for <= 8bpp modes! - dc.SetPalette(m_globalPalette); wxHtmlWindow::OnDraw(dc); } @@ -173,12 +161,7 @@ wxApplet *wxHtmlAppletWindow::CreateApplet( const wxSize& size) { // Dynamically create the class instance at runtime - wxClassInfo *info = wxClassInfo::FindClass(classId.c_str()); - if (!info) - return NULL; - wxObject *obj = info->CreateObject(); - if (!obj) - return NULL; + wxObject *obj = wxCreateDynamicObject(classId.c_str()); wxApplet *applet = wxDynamicCast(obj,wxApplet); if (!applet) return NULL; @@ -212,15 +195,12 @@ created dynamically based on string values embedded in the custom tags of an HTML page. ****************************************************************************/ bool wxHtmlAppletWindow::CreatePlugIn( - const wxString& classId ) + const wxString& classId, + const wxString& cmdLine) { - // Dynamically create the class instance at runtime - wxClassInfo *info = wxClassInfo::FindClass(classId.c_str()); - if (!info) - return false; - wxObject *obj = info->CreateObject(); - if (!obj) - return false; + // Dynamically create the class instance at runtime, execute it + // and then destroy it. + wxObject *obj = wxCreateDynamicObject(classId.c_str()); wxPlugIn *plugIn = wxDynamicCast(obj,wxPlugIn); if (!plugIn) return false; @@ -228,6 +208,8 @@ bool wxHtmlAppletWindow::CreatePlugIn( delete plugIn; return false; } + plugIn->Run(cmdLine); + delete plugIn; return true; } @@ -293,22 +275,53 @@ bool wxHtmlAppletWindow::LoadPage( wxString cmdValue = link.AfterFirst('='); // Launches the default Internet browser for the system. - if(!(cmd.CmpNoCase("?EXTERNAL"))){ + if(!(cmd.CmpNoCase("?EXTERNAL"))) { return wxSpawnBrowser(this, cmdValue.c_str()); } // Launches an external program on the system. - if (!(cmd.CmpNoCase("?EXECUTE"))){ - int code = spawnl( P_NOWAIT, cmdValue , NULL ); - return (!code); + if (!(cmd.CmpNoCase("?EXECUTE"))) { + int waitflag = P_NOWAIT; + bool ret; + wxString currentdir; + wxString filename, path, ext; + + // Parse the params sent to the execute command. For now the only + // parm is "wait". wait will cause spawn wait, default is nowait. + // Since we only need one param for now I am not going to make this + // any smater then it needs to be. If we need more params later i'll + // fix it. + int i = cmdValue.Find('('); + if (i != -1) { + wxString param = cmdValue.AfterFirst('('); + cmdValue.Truncate(i); + if (!param.CmpNoCase("wait)")) + waitflag = P_WAIT; + } + + currentdir = wxGetCwd(); + //we don't want to change the path of the virtual file system so we have to use these + //functions rather than the filesystem + wxSplitPath(cmdValue, &path, &filename, &ext); + if (path.CmpNoCase("") != 0) wxSetWorkingDirectory(path); + + ret = !spawnl( waitflag, cmdValue , NULL ); + //HACK should use wxExecute + //ret = wxExecute(filename, bool sync = FALSE, wxProcess *callback = NULL) + wxSetWorkingDirectory(currentdir); + + return ret; } // Looks for a href in a variable stored as a cookie. The href can be // changed on the fly. if (!(cmd.CmpNoCase("?VIRTUAL"))){ - VirtualData& temp = *((VirtualData*)FindCookie(cmdValue)); - if (&temp) { - href = temp.GetHref(); + wxObject *obj = FindCookie(cmdValue); + VirtualData *virtData = wxDynamicCast(obj,VirtualData); + if (virtData) { + // recurse and loadpage, just in case the link is like another + // ? link + return LoadPage(virtData->GetHref()); } else { #ifdef CHECKED @@ -320,16 +333,32 @@ bool wxHtmlAppletWindow::LoadPage( // This launches a qlet - It is like an applet but is more generic in that it // can be of any wxWin type so it then has the freedom to do more stuff. - if (!(cmd.CmpNoCase("?WXAPPLET"))){ - if (!cmdValue.IsNull()){ - if (!CreatePlugIn(cmdValue)){ + if (!(cmd.CmpNoCase("?WXPLUGIN"))){ + if (!cmdValue.IsNull()) { + // TODO: We are going to need to add code to parse the command line + // parameters string in here in the future... + wxString cmdLine = link.AfterFirst('('); + cmdLine = cmdLine.BeforeLast(')'); + if (!CreatePlugIn(cmdValue,cmdLine)) { #ifdef CHECKED - wxLogError(_T("Launch Applet ERROR: '%s' does not exist."), cmdValue.c_str()); + wxLogError(_T("Launch PlugIn ERROR: '%s' does not exist."), cmdValue.c_str()); #endif } } return true; } + + // This used in a link or href will take you back in the history. + if (!(cmd.CmpNoCase("?BACK"))){ + HistoryBack(); + return true; + } + + // This used in a link or href will take you forward in the history + if (!(cmd.CmpNoCase("?FORWARD"))){ + HistoryForward(); + return true; + } } // Inform all the applets that the new page is being loaded @@ -337,6 +366,7 @@ bool wxHtmlAppletWindow::LoadPage( (node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href)); Show(false); + m_openedlast = href; bool stat = wxHtmlWindow::LoadPage(href); Show(true); @@ -437,24 +467,16 @@ to all other applets on the current page. This is the primary form of communication between applets on the page if they need to inform each other of internal information. -Note that the event handling terminates as soon as the first wxApplet -handles the event. If the event should be handled by all wxApplet's, -the event handlers for the applets should not reset the wxEvent::Skip() -value (ie: by default it is true). ****************************************************************************/ -void wxHtmlAppletWindow::SendMessage( - wxEvent& msg) +void wxHtmlAppletWindow::SendAppletMessage( + wxAppletEvent& msg) { - // Preset the skip flag - msg.Skip(); + // TODO: make a named target for messages, only send a message to the correct + // named applet // Process all applets in turn and send them the message for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) { (node->GetData())->OnMessage(msg); - if (!msg.GetSkipped()){ - wxMessageBox("BREAK"); - break; - } } } @@ -546,10 +568,10 @@ void wxHtmlAppletWindow::OnLoadPage( wxLoadPageEvent &event) { // Test the mutex lock. - if (!(IsLocked())){ + if (!(IsLocked())) { Lock(); - if (event.GetHtmlWindow() == this){ - if (LoadPage(event.GetHRef())){ + if (event.GetHtmlWindow() == this) { + if (LoadPage(event.GetHRef())) { // wxPageLoadedEvent evt; // NOTE: This is reserved for later use as we might need to send // page loaded events to applets. @@ -602,11 +624,13 @@ VirtualData is used to store information on the virtual links. VirtualData::VirtualData( wxString& name, wxString& group, - wxString& href ) + wxString& href, + wxString& plugin ) { m_name = name; m_group = group; m_href = href; + m_plugIn = plugin; } /**************************************************************************** @@ -621,18 +645,6 @@ VirtualData::VirtualData() m_href.Empty(); } -/**************************************************************************** -PARAMETERS: -REMARKS: -****************************************************************************/ -void AppletProcess::OnTerminate( - int, - int ) -{ - // we're not needed any more - delete this; -} - #include "wx/html/m_templ.h" /**************************************************************************** @@ -652,63 +664,66 @@ TAG_HANDLER_PROC(tag) wxString name; int width, height; + // Get access to our wxHtmlAppletWindow class wnd = m_WParser->GetWindow(); + if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) == NULL) + return false; - if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) != NULL){ - wxSize size = wxDefaultSize; - int al; - if (tag.HasParam("WIDTH")) { - tag.GetParamAsInt("WIDTH", &width); - size.SetWidth(width); - } - - if (tag.HasParam("HEIGHT")) { - tag.GetParamAsInt("HEIGHT", &height); - size.SetHeight(height); - } + // Parse the applet dimensions from the tag + wxSize size = wxDefaultSize; + int al; + if (tag.HasParam("WIDTH")) { + tag.GetParamAsInt("WIDTH", &width); + size.SetWidth(width); + } + if (tag.HasParam("HEIGHT")) { + tag.GetParamAsInt("HEIGHT", &height); + size.SetHeight(height); + } - al = wxHTML_ALIGN_BOTTOM; - if (tag.HasParam(wxT("ALIGN"))) { - wxString alstr = tag.GetParam(wxT("ALIGN")); - alstr.MakeUpper(); // for the case alignment was in ".." - if (alstr == wxT("TEXTTOP") || alstr == wxT("TOP")) - al = wxHTML_ALIGN_TOP; - else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER"))) - al = wxHTML_ALIGN_CENTER; - } + // Parse the applet alignment from the tag + al = wxHTML_ALIGN_BOTTOM; + if (tag.HasParam(wxT("ALIGN"))) { + wxString alstr = tag.GetParam(wxT("ALIGN")); + alstr.MakeUpper(); // for the case alignment was in ".." + if (alstr == wxT("TEXTTOP") || alstr == wxT("TOP")) + al = wxHTML_ALIGN_TOP; + else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER"))) + al = wxHTML_ALIGN_CENTER; + } - if (tag.HasParam("CLASSID")){ - classId = tag.GetParam("CLASSID"); - if ( classId.IsNull() || classId.Len() == 0 ){ - wxMessageBox("wxApplet tag error: CLASSID is NULL or empty.","Error",wxICON_ERROR); - return false; - } - if (tag.HasParam("NAME")) - name = tag.GetParam("NAME"); - - // If the name is NULL or len is zero then we assume that the html guy - // didn't include the name param which is optional. - if ( name.IsNull() || name.Len() == 0 ) - name = classId; - - // We got all the params and can now create the applet - if ((applet = appletWindow->CreateApplet(classId, name, tag , size)) != NULL){ - applet->Show(true); - m_WParser->OpenContainer()->InsertCell(new wxHtmlAppletCell(applet,al)); - } - else - wxMessageBox("wxApplet error: Could not create:" + classId + "," + name); - } - else{ - wxMessageBox("wxApplet tag error: Can not find CLASSID param.","Error",wxICON_ERROR); + // Create the applet based on it's class + if (tag.HasParam("CLASSID")) { + classId = tag.GetParam("CLASSID"); + if (classId.IsNull() || classId.Len() == 0) { + wxMessageBox("wxApplet tag error: CLASSID is NULL or empty.","Error",wxICON_ERROR); return false; } - //Add more param parsing here. If or when spec changes. - //For now we'll ignore any other params those HTML guys - //might put in our tag. + if (tag.HasParam("NAME")) + name = tag.GetParam("NAME"); + + // If the name is NULL or len is zero then we assume that the html guy + // didn't include the name param which is optional. + if (name.IsNull() || name.Len() == 0) + name = classId; + + // We got all the params and can now create the applet + if ((applet = appletWindow->CreateApplet(classId, name, tag , size)) != NULL) { + applet->Show(true); + m_WParser->OpenContainer()->InsertCell(new wxHtmlAppletCell(applet,al)); + } + else + wxMessageBox("wxApplet error: Could not create:" + classId + "," + name); + } + else { + wxMessageBox("wxApplet tag error: Can not find CLASSID param.","Error",wxICON_ERROR); + return false; } - return false; + // Add more param parsing here. If or when spec changes. + // For now we'll ignore any other params those HTML guys + // might put in our tag. + return true; } TAG_HANDLER_END(wxApplet) @@ -717,16 +732,20 @@ TAGS_MODULE_BEGIN(wxApplet) TAGS_MODULE_ADD(wxApplet) TAGS_MODULE_END(wxApplet) -/********************************************************************************* -wxHtmlAppletCell -*********************************************************************************/ -wxHtmlAppletCell::wxHtmlAppletCell(wxWindow *wnd, int align) : wxHtmlCell() +/**************************************************************************** +REMARKS: +Constructor for the HTML cell class to store our wxApplet windows in +the HTML page to be rendered by wxHTML. +****************************************************************************/ +wxHtmlAppletCell::wxHtmlAppletCell( + wxWindow *wnd, + int align) + : wxHtmlCell() { int sx, sy; m_Wnd = wnd; m_Wnd->GetSize(&sx, &sy); m_Width = sx, m_Height = sy; - switch (align) { case wxHTML_ALIGN_TOP : m_Descent = m_Height; @@ -739,59 +758,76 @@ wxHtmlAppletCell::wxHtmlAppletCell(wxWindow *wnd, int align) : wxHtmlCell() m_Descent = 0; break; } - SetCanLiveOnPagebreak(FALSE); } +/**************************************************************************** +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; - wxHtmlCell *c = this; + int absx = 0, absy = 0, stx, sty; + wxHtmlCell *c = this; - while (c) - { + while (c) { absx += c->GetPosX(); absy += c->GetPosY(); c = c->GetParent(); - } - + } ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); m_Wnd->Move(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty); } - - -void wxHtmlAppletCell::DrawInvisible(wxDC& WXUNUSED(dc), int WXUNUSED(x), int WXUNUSED(y)) +/**************************************************************************** +REMARKS: +Code to draw the html applet cell invisibly +****************************************************************************/ +void wxHtmlAppletCell::DrawInvisible( + wxDC& WXUNUSED(dc), + int WXUNUSED(x), + int WXUNUSED(y)) { - int absx = 0, absy = 0, stx, sty; - wxHtmlCell *c = this; + int absx = 0, absy = 0, stx, sty; + wxHtmlCell *c = this; - while (c) - { + while (c) { absx += c->GetPosX(); absy += c->GetPosY(); c = c->GetParent(); - } - + } ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); m_Wnd->Move(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty); } - - -void wxHtmlAppletCell::Layout(int w) +/**************************************************************************** +REMARKS: +Code to layout the html applet cell. +****************************************************************************/ +void wxHtmlAppletCell::Layout( + int w) { int sx, sy; m_Wnd->GetSize(&sx, &sy); m_Width = sx, m_Height = sy; - wxHtmlCell::Layout(w); } - - - // This is our little forcelink hack. FORCE_LINK(loadpage) diff --git a/contrib/src/applet/echovar.cpp b/contrib/src/applet/echovar.cpp index 5f98f1dd63..3da0f23d45 100644 --- a/contrib/src/applet/echovar.cpp +++ b/contrib/src/applet/echovar.cpp @@ -28,64 +28,105 @@ ****************************************************************************/ // For compilers that support precompilation -#include "wx/wxprec.h" + +#include "wx/applet/echovar.h" +#include "wx/msgdlg.h" #include "wx/html/forcelnk.h" // Include private headers -#include "wx/applet/echovar.h" /*---------------------------- Global variables ---------------------------*/ -// Implement the dynamic class so it can be constructed dynamically -IMPLEMENT_ABSTRACT_CLASS(wxEchoVariable, wxObject); +static wxEchoVariable *wxEchoVariable::sm_first = NULL; +static wxHashTable *wxEchoVariable::sm_varTable = NULL; /*----------------------------- Implementation ----------------------------*/ /**************************************************************************** PARAMETERS: -cls - The String name of the class -parms - an optional parameter string to pass off to the child class +varName - The String name of the class +getValueFn - Pointer to the function that returns the echo variable value -RETURNS: -The string value of the 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!). +****************************************************************************/ +wxEchoVariable::wxEchoVariable( + const char *varName, + wxEchoVariableGetValueFn getValueFn) +{ + m_varName = varName; + m_getValueFn = getValueFn; + m_next = sm_first; + sm_first = this; +} +/**************************************************************************** REMARKS: -To grab a value from any class which is derived from this one simple use this -static function and the name of the derived class to get the value. -This static function is the only function implemented in this base class -basically this is provided for an easier method of grabbing a variable. We -keep all the dynamic object handling in this class to avoid confusing the source -where these are used. +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; + } +} -SEE ALSO: -wxEchoPrep +/**************************************************************************** +REMARKS: +Clean up echo variable hash tables on application exit. ****************************************************************************/ -static wxString wxEchoVariable::FindValue( - const wxString &cls, - const char *parms) +void wxEchoVariable::CleanUp() { - wxObject * tmpclass; + delete wxEchoVariable::sm_varTable; + wxEchoVariable::sm_varTable = NULL; +} - tmpclass = wxCreateDynamicObject(wxString("wxEchoVariable") + cls); - if (!tmpclass) { -#ifdef CHECKED - wxMessageBox(wxString("wxHTML #echo error: Class not found (") + cls + wxString(")."),"Error",wxICON_ERROR); -#endif - return wxString(""); - } +/**************************************************************************** +PARAMETERS: +varName - The String name of the class +parms - Parameter string for the echo variable - wxEchoVariable * ev = wxDynamicCast(tmpclass, wxEchoVariable); - - if (!ev) { +REMARKS: +Constructor for the wxEchoVariable class that self registers itself with +the list of all echo variables when the static class instance is created +at program init time (remember all the constructors get called before +the main program function!). +****************************************************************************/ +wxString wxEchoVariable::GetValue( + const wxChar *varName, + const wxChar *parms) +{ + wxEchoVariable *info = wxEchoVariable::FindVariable(varName); + if (info) + return info->m_getValueFn(parms); #ifdef CHECKED - wxMessageBox(wxString("wxHTML #echo error: Class is not a valid echo variable (") + cls + wxString(")."),"Error",wxICON_ERROR); + wxMessageBox(wxString("wxHTML #echo error: Class is not a valid echo variable (") + varName + wxString(")."),"Error",wxICON_ERROR); #endif - return wxString(""); - } - - return ev->GetValue(parms); + return wxString(""); } +/**************************************************************************** +PARAMETERS: +varName - The String name of the class + +RETURNS: +True if the echo variable exists, false if not. +****************************************************************************/ +bool wxEchoVariable::Exists( + const wxChar *varName) +{ + return wxEchoVariable::FindVariable(varName) != NULL; +} /*------------------------ Macro Documentation ---------------------------*/ @@ -177,4 +218,5 @@ void STRING_ECHO_VARIABLE( wxString string); // hack to make this file link -FORCE_LINK_ME(echovar) +FORCE_LINK_ME(echovar) + diff --git a/contrib/src/applet/ifelsevar.cpp b/contrib/src/applet/ifelsevar.cpp index 7c82bb5a74..e7280b23fe 100644 --- a/contrib/src/applet/ifelsevar.cpp +++ b/contrib/src/applet/ifelsevar.cpp @@ -27,61 +27,134 @@ * ****************************************************************************/ -// For compilers that support precompilation -#include "wx/wxprec.h" -#include "wx/html/forcelnk.h" - // Include private headers #include "wx/applet/ifelsevar.h" +// wxWindows forcelink macro +#include "wx/html/forcelnk.h" +#include "wx/msgdlg.h" + /*---------------------------- Global variables ---------------------------*/ -// Implement the dynamic class so it can be constructed dynamically -IMPLEMENT_ABSTRACT_CLASS(wxIfElseVariable, wxObject); +static wxIfElseVariable *wxIfElseVariable::sm_first = NULL; +static wxHashTable *wxIfElseVariable::sm_varTable = NULL; /*----------------------------- Implementation ----------------------------*/ /**************************************************************************** PARAMETERS: -cls - The String name of the class +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: +Constructor for the wxIfElseVariable class that self registers itself with +the list of all echo variables when the static class instance is created +at program init time (remember all the constructors get called before +the main program function!). +****************************************************************************/ +wxIfElseVariable::wxIfElseVariable( + const char *varName, + wxIfElseVariableGetValueFn getValueFn) +{ + m_varName = varName; + m_getValueFn = getValueFn; + m_next = sm_first; + sm_first = this; +} +/**************************************************************************** REMARKS: -To grab a value from any class which is derived from this one simple use this -static function and the name of the derived class to get the value. -This static function is the only function implemented in this base class -basically this is provided for an easier method of grabbing a variable. We -keep all the dynamic object handling in this class to avoid confusing the source -where these are used. +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; + } +} -SEE ALSO: -wxIfElsePrep +/**************************************************************************** +REMARKS: +Clean up echo variable hash tables on application exit. ****************************************************************************/ -static bool wxIfElseVariable::FindValue( - const wxString &cls) +void wxIfElseVariable::CleanUp() { - wxObject * tmpclass; + delete wxIfElseVariable::sm_varTable; + wxIfElseVariable::sm_varTable = NULL; +} - tmpclass = wxCreateDynamicObject(wxString("wxIfElseVariable") + cls); - if (!tmpclass) { -#ifdef CHECKED - wxMessageBox(wxString("wxHTML #if error: Class not found (") + cls + wxString(")."),"Error",wxICON_ERROR); -#endif - return wxString(""); - } +/**************************************************************************** +PARAMETERS: +varName - The String name of the class - wxIfElseVariable * ev = wxDynamicCast(tmpclass, wxIfElseVariable); - - if (!ev) { +REMARKS: +Constructor for the wxIfElseVariable class that self registers itself with +the list of all ifelse variables when the static class instance is created +at program init time (remember all the constructors get called before +the main program function!). +****************************************************************************/ +bool wxIfElseVariable::GetValue( + const wxChar *varName) +{ + wxIfElseVariable *info = wxIfElseVariable::FindVariable(varName); + if (info) { + // Return the forced value if the variable has been forced. + if (info->forced) + return info->forceVal; + return info->m_getValueFn(); + } #ifdef CHECKED - wxMessageBox(wxString("wxHTML #if error: Class is not a valid ifelse variable (") + cls + wxString(")."),"Error",wxICON_ERROR); + wxMessageBox(wxString("wxHTML #if error: Class is not a valid if else variable (") + varName + wxString(")."),"Error",wxICON_ERROR); #endif - return wxString(""); - } + return wxString(""); +} + +/**************************************************************************** +PARAMETERS: +varName - The String name of the class + +RETURNS: +True if the if/else variable exists, false if not. +****************************************************************************/ +bool wxIfElseVariable::Exists( + const wxChar *varName) +{ + return wxIfElseVariable::FindVariable(varName) != NULL; +} - 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 ---------------------------*/ @@ -155,5 +228,5 @@ void IFELSE_VARIABLE( const char *name, bool state); - FORCE_LINK_ME(ifelsevar) + diff --git a/contrib/src/applet/loadpage.cpp b/contrib/src/applet/loadpage.cpp index 32f8af20c4..705a2e4a61 100644 --- a/contrib/src/applet/loadpage.cpp +++ b/contrib/src/applet/loadpage.cpp @@ -26,13 +26,12 @@ * ****************************************************************************/ -// For compilers that support precompilation -#include "wx/wxprec.h" -#include "wx/html/forcelnk.h" - // Include private headers #include "wx/applet/loadpage.h" +// wxWindows forcelink macro +#include "wx/html/forcelnk.h" + /*------------------------- Implementation --------------------------------*/ // Implement the class functions for wxLoadPageEvent @@ -59,20 +58,6 @@ wxLoadPageEvent::wxLoadPageEvent( m_eventType = wxEVT_LOAD_PAGE; } -/**************************************************************************** -REMARKS: -Function to copy the wxLoadPageEvent object -****************************************************************************/ -void wxLoadPageEvent::CopyObject( - wxObject& obj_d) const -{ - wxLoadPageEvent *obj = (wxLoadPageEvent*)&obj_d; - wxEvent::CopyObject(obj_d); - obj->m_hRef = m_hRef; - obj->m_htmlWindow = m_htmlWindow; -} - - /**************************************************************************** REMARKS: Constructor for the wxPageLoadedEvent class @@ -82,17 +67,6 @@ wxPageLoadedEvent::wxPageLoadedEvent() m_eventType = wxEVT_LOAD_PAGE; } -/**************************************************************************** -REMARKS: -Function to copy the wxPageLoadedEvent object -****************************************************************************/ -void wxPageLoadedEvent::CopyObject( - wxObject& obj_d) const -{ - wxPageLoadedEvent *obj = (wxPageLoadedEvent*)&obj_d; - wxEvent::CopyObject(obj_d); -} - // This is out little force link hack FORCE_LINK_ME(loadpage) diff --git a/contrib/src/applet/plugin.cpp b/contrib/src/applet/plugin.cpp index 9802ce7991..2e67780b98 100644 --- a/contrib/src/applet/plugin.cpp +++ b/contrib/src/applet/plugin.cpp @@ -26,9 +26,6 @@ * ****************************************************************************/ -// For compilers that support precompilation -#include "wx/wxprec.h" - // Include private headers #include "wx/applet/plugin.h" #include "wx/applet/window.h" @@ -36,7 +33,7 @@ /*------------------------- Implementation --------------------------------*/ // Implement the abstract class functions -IMPLEMENT_ABSTRACT_CLASS(wxPlugIn, wxObject); +IMPLEMENT_ABSTRACT_CLASS(wxPlugIn, wxEvtHandler); /**************************************************************************** REMARKS: @@ -57,4 +54,12 @@ wxPlugIn::~wxPlugIn() { } +/**************************************************************************** +REMARKS: +Destructor for the wxPlugIn class. +****************************************************************************/ +void wxPlugIn::Run( + const wxString& WXUNUSED(cmdLine)) +{ +} diff --git a/contrib/src/applet/prepecho.cpp b/contrib/src/applet/prepecho.cpp index 67b38016fe..8181077116 100644 --- a/contrib/src/applet/prepecho.cpp +++ b/contrib/src/applet/prepecho.cpp @@ -27,16 +27,15 @@ * ****************************************************************************/ -// For compilers that support precompilation -#include "wx/wxprec.h" -#include "wx/html/forcelnk.h" - // Include private headers #include "wx/applet/prepecho.h" #include "wx/applet/echovar.h" -/*---------------------------- Global variables ---------------------------*/ +// Force Link macro +#include "wx/html/forcelnk.h" +// wxWindows headers +#include "wx/msgdlg.h" /*----------------------------- Implementation ----------------------------*/ @@ -68,7 +67,6 @@ wxString wxEchoPrep::Process( while ((i = (output.Lower()).Find(ft)) != -1) { // Loop until every #echo directive is found - int n, c, end; wxString cname, parms; wxString tag; @@ -97,7 +95,7 @@ wxString wxEchoPrep::Process( cname = tag.Mid(10, n); // grab the value from the class, put it in tag since the data is no longer needed - tag = wxEchoVariable::FindValue(cname, NULL); + tag = wxEchoVariable::GetValue(cname, NULL); } else { // Find the parms @@ -114,9 +112,7 @@ wxString wxEchoPrep::Process( cname = tag.Mid(10, n); // grab the value from the class, put it in tag since the data is no longer needed - tag = wxEchoVariable::FindValue(cname, parms.c_str()); - - + tag = wxEchoVariable::GetValue(cname, parms.c_str()); } // remove ampersands and <> chars tag.Replace("&", "&"); @@ -125,7 +121,6 @@ wxString wxEchoPrep::Process( output = (output.Mid(0,i) + tag + output.Mid(i)); } - return output; } diff --git a/contrib/src/applet/prepifelse.cpp b/contrib/src/applet/prepifelse.cpp index 7cda90bc5f..0724dae644 100644 --- a/contrib/src/applet/prepifelse.cpp +++ b/contrib/src/applet/prepifelse.cpp @@ -27,16 +27,16 @@ * ****************************************************************************/ -// For compilers that support precompilation -#include "wx/wxprec.h" -#include "wx/html/forcelnk.h" - // Include private headers #include "wx/applet/prepifelse.h" #include "wx/applet/ifelsevar.h" +#include "wx/applet/echovar.h" +#include "wx/string.h" -/*---------------------------- Global variables ---------------------------*/ - +// Force link macro +#include "wx/html/forcelnk.h" +// wxWindows +#include "wx/msgdlg.h" /*----------------------------- Implementation ----------------------------*/ @@ -65,10 +65,56 @@ int ReverseFind( return p; p--; } - return -1; } +/* {SECRET} */ +/**************************************************************************** +REMARKS: +tells if a character is a letter. +replace this when wxWindows gets regex library. (without strange licensing +restrictions) +****************************************************************************/ +bool IsLetter( + char c, bool acceptspace = false) +{ + if (acceptspace && (c == ' ')) return true; + if (c >= '0' && c <= '9') return true; + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '\"' || c == '\'' ); +} + +#define IsQuote(c) (c == '\'' || c == '\"') + +/* {SECRET} */ +/**************************************************************************** +REMARKS: +tells if a character is a letter. +replace this when wxWindows gets regex library. (without strange licensing +restrictions) +****************************************************************************/ +wxString GetEquals( + wxString var, + wxString value) +{ + if (!wxEchoVariable::Exists(var)) { + // TODO: when we implement the set variable, check for a set variable as well + #ifdef CHECKED + wxMessageBox(wxString("wxHTML #if\\else error: Variable ") + var + wxString(" not found."),"Error",wxICON_ERROR); + #endif + return wxString("0"); // false + } + + wxString tmp = wxEchoVariable::GetValue(var); + + if (IsQuote( value.GetChar(0) )) + value = value.Mid(1); + if (IsQuote(value.GetChar(value.Length()-1))) + value = value.Mid(0,value.Length()-1); + + if (tmp.CmpNoCase(value) == 0) return wxString("1"); + return wxString("0"); +} + /**************************************************************************** PARAMETERS: str - text of #if statement @@ -77,12 +123,14 @@ RETURNS: true or false depending on how it evaluated REMARKS: +TODO: rewrite this whole thing using regular expressions when they are done. SEE ALSO: wxIfElseVariable ****************************************************************************/ -bool ParseIfStatementValue(wxString &str) { - +bool ParseIfStatementValue( + wxString &str) +{ // Find out if the tag has parenthesis // recursive to parse the text within the parenthesis, // replacing the text with 1 or 0, (hardcoded true or false) @@ -93,7 +141,6 @@ bool ParseIfStatementValue(wxString &str) { int nextbeg, nextend; int parencount = 1, min = b+1; do { - nextbeg = str.find('(', min); nextend = str.find(')', min); if (nextbeg < nextend && nextbeg != wxString::npos) { @@ -106,9 +153,9 @@ bool ParseIfStatementValue(wxString &str) { } if (nextend == wxString::npos) { - #ifdef CHECKED +#ifdef CHECKED wxMessageBox("wxHTML #if\\else error: Unmatched parenthesis in #if expression.","Error",wxICON_ERROR); - #endif +#endif return true; } // once parencount reaches 0 again we have found our matchin ) @@ -124,7 +171,6 @@ bool ParseIfStatementValue(wxString &str) { // Add extra spaces just in case of NOT(VAL) if (val) str = str.Mid(0, b) + " 1" + str.Mid(e+1); else str = str.Mid(0, b) + " 0" + str.Mid(e+1); - } // Remove spaces from left and right @@ -135,6 +181,51 @@ bool ParseIfStatementValue(wxString &str) { // this makes only one special case necessary for each later on str.Replace(" AND ", "&&"); str.Replace(" OR ", "||"); + str.Replace(" EQUALS ", "=="); + + // Check for equals statements + // == statements are special because they are evaluated as a single block + int equ; + equ = str.find("=="); + while (equ != wxString::npos) { + int begin, end; + int begin2, end2; // ends of words + begin = equ-1; + end = equ+2; + + // remove spaces, find extents + while (end < str.Length() && str.GetChar(end) == ' ') + end++; + while (begin >= 0 && str.GetChar(begin) == ' ') + begin--; + end2 = end; + begin2 = begin; + if (str.GetChar(end2) == '\'' || str.GetChar(end2) == '\"') { + end2++; + while (end2 < str.Length() && str.GetChar(end2) != '\'' && str.GetChar(end2) != '\"' ) + end2++; + end2++; + } + else { + while (end2 < str.Length() && IsLetter(str.GetChar(end2))) + end2++; + } + while (begin >= 0 && IsLetter(str.GetChar(begin))) + begin--; + + if (begin < 0) begin = 0; + else begin++; + if (end2 >= str.Length()) end2 = str.Length(); + + wxString tmpeq = GetEquals(str.Mid(begin, begin2-begin+1), str.Mid(end, end2-end)); + str = str.Mid(0, begin) + wxString(" ") + tmpeq + wxString(" ") + + str.Mid(end2); + equ = str.find("=="); + + // Remove spaces from left and right + str.Trim(false); + str.Trim(true); + } // We use ReverseFind so that the whole left expression gets evaluated agains // the right single item, creating a left -> right evaluation @@ -145,7 +236,7 @@ bool ParseIfStatementValue(wxString &str) { if ( (and != -1) || (or != -1) ) { wxString tag1, tag2; // handle the rightmost first to force left->right evaluation - if (and > or) { + if ( (and > or) ) { return ( ParseIfStatementValue(tag2 = str.Mid(and+2)) && ParseIfStatementValue(tag1 = str.Mid(0, and)) ); @@ -155,7 +246,6 @@ bool ParseIfStatementValue(wxString &str) { ParseIfStatementValue(tag2 = str.Mid(or+2)) || ParseIfStatementValue(tag1 = str.Mid(0, or)) ); } - } // By the time we get to this place in the function we are guarenteed to have a single @@ -175,11 +265,10 @@ bool ParseIfStatementValue(wxString &str) { } // now all we have left is the name of the class or a hardcoded 0 or 1 - if (str == "") { - #ifdef CHECKED +#ifdef CHECKED wxMessageBox("wxHTML #if\\else error: Empty expression in #if\\#elif statement.","Error",wxICON_ERROR); - #endif +#endif return true; } @@ -189,7 +278,7 @@ bool ParseIfStatementValue(wxString &str) { if (str == "1") return !notval; // Grab the value from the variable class identified by cname - bool value = wxIfElseVariable::FindValue(str); + bool value = wxIfElseVariable::GetValue(str); if (notval) value = !value; return value; @@ -220,7 +309,6 @@ wxString wxIfElsePrep::Process( char ftelse[] = ""; char ftnot[] = "", b + strlen(ftelif)); if (e == wxString::npos) { - #ifdef CHECKED +#ifdef CHECKED wxMessageBox("wxHTML #elif error: Premature end of file while parsing #elif.","Error",wxICON_ERROR); - #endif +#endif break; } @@ -259,9 +347,9 @@ wxString wxIfElsePrep::Process( } if (nextendif == wxString::npos) { - #ifdef CHECKED +#ifdef CHECKED wxMessageBox("wxHTML #elif error: Premature end of file before finding #endif.","Error",wxICON_ERROR); - #endif +#endif break; } // once ifcount reaches 0 again we have found our matchin #endif @@ -269,9 +357,9 @@ wxString wxIfElsePrep::Process( // If it couldn't be found die gracefully if (nextendif == wxString::npos) { - // We already displayed a message, just break all the way out - break; - } + // We already displayed a message, just break all the way out + break; + } int elifsize = e - (b + strlen(ftelif)) + strlen("-->"); // Create the #if/else block, removing the #elif code @@ -280,7 +368,6 @@ wxString wxIfElsePrep::Process( output.Mid(b+strlen(ftelif), elifsize+nextendif) + wxString(ftend) + output.Mid(b+strlen(ftelif)+elifsize+nextendif); - } // Parse out the if else blocks themselves @@ -350,4 +437,5 @@ wxString wxIfElsePrep::Process( return output; } -FORCE_LINK(ifelsevar) +FORCE_LINK(ifelsevar) + diff --git a/contrib/src/applet/prepinclude.cpp b/contrib/src/applet/prepinclude.cpp index 83d494875e..bf03a84ef8 100644 --- a/contrib/src/applet/prepinclude.cpp +++ b/contrib/src/applet/prepinclude.cpp @@ -27,18 +27,52 @@ * ****************************************************************************/ -// For compilers that support precompilation -#include "wx/wxprec.h" -//#include "wx/file.h" -#include "wx/filesys.h" // Include private headers #include "wx/applet/prepinclude.h" +#include "wx/applet/echovar.h" + +// wxWindows +#include "wx/filesys.h" +#include "wx/msgdlg.h" + +/*----------------------------- Implementation ----------------------------*/ #define RECURSE_LIMIT 50 -/*---------------------------- Global variables ---------------------------*/ +/**************************************************************************** +PARAMETERS: +text - text to process for echo variables -/*----------------------------- Implementation ----------------------------*/ +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: @@ -58,8 +92,6 @@ wxString wxIncludePrep::Process( { int i; char ft[] = ""), NULL, NULL); break; - + default: wxFAIL_MSG(wxT("unsupported node type")); } @@ -681,9 +681,9 @@ bool wxXmlDocument::Save(wxOutputStream& stream) const { if ( !IsOk() ) return FALSE; - + wxString s; - + wxMBConv *convMem = NULL, *convFile = NULL; #if wxUSE_UNICODE convFile = new wxCSConv(GetFileEncoding()); @@ -694,18 +694,18 @@ bool wxXmlDocument::Save(wxOutputStream& stream) const convMem = new wxCSConv(GetEncoding()); } #endif - + s.Printf(wxT("\n"), GetVersion().c_str(), GetFileEncoding().c_str()); OutputString(stream, s, NULL, NULL); - + OutputNode(stream, GetRoot(), 0, convMem, convFile); OutputString(stream, wxT("\n"), NULL, NULL); - + if ( convFile ) delete convFile; if ( convMem ) delete convMem; - + return TRUE; } diff --git a/include/wx/dc.h b/include/wx/dc.h index 9eb23674a1..b13bc4bcb7 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -28,7 +28,6 @@ #include "wx/brush.h" #include "wx/pen.h" #include "wx/palette.h" - #include "wx/list.h" // we use wxList in inline functions class WXDLLEXPORT wxDCBase; @@ -741,6 +740,7 @@ protected: #if wxUSE_PALETTE wxPalette m_palette; + bool m_custompalette; #endif // wxUSE_PALETTE private: diff --git a/include/wx/event.h b/include/wx/event.h index b96e4458be..cedaf922eb 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -230,20 +230,21 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_POPUP_MENU_INIT, 423) DECLARE_EVENT_TYPE(wxEVT_CONTEXT_MENU, 424) DECLARE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED, 425) - DECLARE_EVENT_TYPE(wxEVT_SETTING_CHANGED, 426) - DECLARE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE, 427) - DECLARE_EVENT_TYPE(wxEVT_PALETTE_CHANGED, 428) - DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN, 429) - DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP, 430) - DECLARE_EVENT_TYPE(wxEVT_JOY_MOVE, 431) - DECLARE_EVENT_TYPE(wxEVT_JOY_ZMOVE, 432) - DECLARE_EVENT_TYPE(wxEVT_DROP_FILES, 433) - DECLARE_EVENT_TYPE(wxEVT_DRAW_ITEM, 434) - DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 435) - DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 436) - DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 437) - DECLARE_EVENT_TYPE(wxEVT_IDLE, 438) - DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 439) + DECLARE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED, 426) + DECLARE_EVENT_TYPE(wxEVT_SETTING_CHANGED, 427) + DECLARE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE, 428) + DECLARE_EVENT_TYPE(wxEVT_PALETTE_CHANGED, 429) + DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN, 430) + DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP, 431) + DECLARE_EVENT_TYPE(wxEVT_JOY_MOVE, 432) + DECLARE_EVENT_TYPE(wxEVT_JOY_ZMOVE, 433) + DECLARE_EVENT_TYPE(wxEVT_DROP_FILES, 434) + DECLARE_EVENT_TYPE(wxEVT_DRAW_ITEM, 435) + DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 436) + DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 437) + DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 438) + DECLARE_EVENT_TYPE(wxEVT_IDLE, 439) + DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 440) // Generic command events // Note: a click is a higher-level event than button down/up @@ -1380,6 +1381,21 @@ private: 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 */ @@ -1899,6 +1915,7 @@ typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&); typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&); typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&); typedef void (wxEvtHandler::*wxSysColourChangedFunction)(wxSysColourChangedEvent&); +typedef void (wxEvtHandler::*wxDisplayChangedFunction)(wxDisplayChangedEvent&); typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&); typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&); 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_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_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_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 ), diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index cbda2b6ad3..d31dd8b880 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -85,7 +85,7 @@ public: // specify document location, use LoadPage() istead // Return value : FALSE if an error occured, TRUE otherwise bool SetPage(const wxString& source); - + // Append to current page bool AppendToPage(const wxString& source); @@ -175,14 +175,14 @@ public: // Called when user clicked on hypertext link. Default behavior is to // call LoadPage(loc) virtual void OnLinkClicked(const wxHtmlLinkInfo& link); - - // Called when wxHtmlWindow wants to fetch data from an URL (e.g. when - // loading a page or loading an image). The data are downloaded if and only if + + // Called when wxHtmlWindow wants to fetch data from an URL (e.g. when + // loading a page or loading an image). The data are downloaded if and only if // OnOpeningURL returns TRUE. If OnOpeningURL returns wxHTML_REDIRECT, // it must set *redirect to the new URL - virtual wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type, - const wxString& url, - wxString *redirect) const + virtual wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType WXUNUSED(type), + const wxString& WXUNUSED(url), + wxString *WXUNUSED(redirect)) const { return wxHTML_OPEN; } protected: diff --git a/include/wx/imagbmp.h b/include/wx/imagbmp.h index 0d67d7a8fb..d687121f67 100644 --- a/include/wx/imagbmp.h +++ b/include/wx/imagbmp.h @@ -53,11 +53,11 @@ public: virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE ); virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=-1 ); virtual bool DoCanRead( wxInputStream& stream ); - + protected: - bool SaveDib(wxImage *image, wxOutputStream& stream, bool verbose, + bool SaveDib(wxImage *image, wxOutputStream& stream, bool verbose, bool IsBmp, bool IsMask); - bool DoLoadDib(wxImage *image, int width, int height, int bpp, int ncolors, + bool DoLoadDib(wxImage *image, int width, int height, int bpp, int ncolors, int comp, off_t bmpOffset, wxInputStream& stream, bool verbose, bool IsBmp, bool hasPalette); bool LoadDib(wxImage *image, wxInputStream& stream, bool verbose, bool IsBmp); @@ -115,7 +115,7 @@ public: m_type = wxBITMAP_TYPE_CUR; m_mime = _T("image/x-cur"); }; - + // VS: This handler's meat is implemented inside wxICOHandler (the two // formats are almost identical), but we hide this fact at // the API level, since it is a mere implementation detail. @@ -141,10 +141,10 @@ public: m_type = wxBITMAP_TYPE_ANI; m_mime = _T("image/x-ani"); }; - + #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 DoCanRead( wxInputStream& stream ); virtual int GetImageCount( wxInputStream& stream ); diff --git a/include/wx/listctrl.h b/include/wx/listctrl.h index 63d8e981b0..4609981ce7 100644 --- a/include/wx/listctrl.h +++ b/include/wx/listctrl.h @@ -300,7 +300,7 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString &name = "listctrl" ) { - Create(parent, id, pos, size, style, wxDefaultValidator, name); + Create(parent, id, pos, size, style, validator, name); } // focus/selection stuff diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index 9087250fe7..682bdb16b2 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -102,7 +102,13 @@ public: virtual void SelectOldObjects(WXHDC dc); 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; } void SetHDC(WXHDC dc, bool bOwnsDC = FALSE) @@ -184,6 +190,15 @@ protected: 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() void DrawAnyText(const wxString& text, wxCoord x, wxCoord y); diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index d16f521fd6..0df7b55a36 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -331,6 +331,8 @@ public: bool HandlePaletteChanged(WXHWND hWndPalChange); bool HandleQueryNewPalette(); bool HandleSysColorChange(); + bool HandleDisplayChange(); + bool HandleQueryEndSession(long logOff, bool *mayEnd); bool HandleEndSession(bool endSession, long logOff); diff --git a/include/wx/window.h b/include/wx/window.h index 0fd38143f0..1e4736b97b 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -32,6 +32,11 @@ #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 #include "wx/accel.h" #endif // wxUSE_ACCEL @@ -761,6 +766,21 @@ public: // platform-specific APIs 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: // the window id - a number which uniquely identifies a window among // its siblings unless it is -1 @@ -844,6 +864,11 @@ protected: wxString m_windowName; bool m_themeEnabled; +#ifdef wxUSE_PALETTE + wxPalette m_palette; + bool m_custompalette; +#endif + protected: // common part of all ctors: it is not virtual because it is called from diff --git a/src/common/event.cpp b/src/common/event.cpp index 914df70855..97d84b676c 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -79,6 +79,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxSetCursorEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxDisplayChangedEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent, wxCommandEvent) 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_CONTEXT_MENU) DEFINE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED) +DEFINE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED) DEFINE_EVENT_TYPE(wxEVT_SETTING_CHANGED) DEFINE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE) DEFINE_EVENT_TYPE(wxEVT_PALETTE_CHANGED) diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 5474b78d00..99832bf995 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -359,7 +359,7 @@ void wxFileName::Assign(const wxString& fullpathOrig, _T("the path shouldn't contain file name nor extension") ); #else // !__WXDEBUG__ - SplitPath(fullname, NULL /* no path */, &name, &ext, format); + SplitPath(fullname, NULL /* no path */, &name, &ext, format); SplitPath(fullpath, &volume, &path, NULL, NULL, format); #endif // __WXDEBUG__/!__WXDEBUG__ @@ -1043,8 +1043,10 @@ wxString wxFileName::GetFullName() const 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 ); wxString fullpath; @@ -1776,4 +1778,3 @@ void wxFileName::MacRegisterDefaultTypeAndCreator( const wxString& ext , wxUint3 gMacDefaultExtensions.Add( rec ) ; } #endif - diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp index 48e6ccdc61..bd8a08abeb 100644 --- a/src/common/imagbmp.cpp +++ b/src/common/imagbmp.cpp @@ -67,7 +67,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxBMPHandler,wxImageHandler) bool wxBMPHandler::SaveFile(wxImage *image, wxOutputStream& stream, bool verbose) -{ +{ return SaveDib(image, stream, verbose, TRUE/*IsBmp*/, FALSE/*IsMask*/); } @@ -82,7 +82,7 @@ bool wxBMPHandler::SaveDib(wxImage *image, if ( !image->Ok() ) { - if ( verbose ) + if ( verbose ) wxLogError(_("BMP: Couldn't save invalid image.")); return FALSE; } @@ -92,7 +92,7 @@ bool wxBMPHandler::SaveDib(wxImage *image, if ( image->HasOption(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 // set the bpp and appropriate palette_size, and do additional checks @@ -179,7 +179,7 @@ bool wxBMPHandler::SaveDib(wxImage *image, hdr.h_res = hdr.v_res = wxUINT32_SWAP_ON_BE(72); // 72dpi is standard hdr.num_clrs = wxUINT32_SWAP_ON_BE(palette_size); // # colors in colormap hdr.num_signif_clrs = 0; // all colors are significant - + if ( IsBmp ) { if (// VS: looks ugly but compilers tend to do ugly things with structs, @@ -188,7 +188,7 @@ bool wxBMPHandler::SaveDib(wxImage *image, !stream.Write(&hdr.magic, 2) || !stream.Write(&hdr.filesize, 4) || !stream.Write(&hdr.reserved, 4) || - !stream.Write(&hdr.data_offset, 4) + !stream.Write(&hdr.data_offset, 4) ) { if (verbose) @@ -443,7 +443,7 @@ typedef struct unsigned char r, g, b; } _cmap; -bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height, +bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height, int bpp, int ncolors, int comp, off_t bmpOffset, wxInputStream& stream, bool verbose, bool IsBmp, bool hasPalette) @@ -474,7 +474,7 @@ bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height, // destroy existing here instead of: image->Destroy(); image->Create(width, height); - + unsigned char *ptr = image->GetData(); if ( !ptr ) @@ -753,7 +753,7 @@ bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height, return stream.IsOk(); } -bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream, +bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream, bool verbose, bool IsBmp) { wxUint16 aWord; @@ -785,7 +785,7 @@ bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream, int width = (int)wxINT32_SWAP_ON_BE(dbuf[0]); int height = (int)wxINT32_SWAP_ON_BE(dbuf[1]); if ( !IsBmp)height = height / 2; // for icons divide by 2 - + if ( width > 32767 ) { if (verbose) @@ -815,7 +815,7 @@ bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream, stream.Read(dbuf, 4 * 4); int comp = (int)wxINT32_SWAP_ON_BE(dbuf[0]); - if ( comp != BI_RGB && comp != BI_RLE4 && comp != BI_RLE8 && + if ( comp != BI_RGB && comp != BI_RLE4 && comp != BI_RLE8 && comp != BI_BITFIELDS ) { if (verbose) @@ -865,7 +865,7 @@ bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream, return TRUE; } -bool wxBMPHandler::LoadFile(wxImage *image, wxInputStream& stream, +bool wxBMPHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index)) { // Read a single DIB fom the file: @@ -935,7 +935,7 @@ bool wxICOHandler::SaveFile(wxImage *image, int images = 1; // only generate one image - // VS: This is a hack of sort - since ICO and CUR files are almost + // VS: This is a hack of sort - since ICO and CUR files are almost // identical, we have all the meat in wxICOHandler and check for // the actual (handler) type when the code has to distinguish between // the two formats @@ -966,7 +966,7 @@ bool wxICOHandler::SaveFile(wxImage *image, wxImage mask; if ( image->HasMask() ) - { + { // make another image with black/white: mask = image->ConvertToMono (image->GetMaskRed(), image->GetMaskGreen(), image->GetMaskBlue() ); @@ -982,8 +982,8 @@ bool wxICOHandler::SaveFile(wxImage *image, { for (j = 0; j < mask.GetHeight(); j++) { - if ((r == mask.GetRed(i, j)) && - (g == mask.GetGreen(i, j))&& + if ((r == mask.GetRed(i, j)) && + (g == mask.GetGreen(i, j))&& (b == mask.GetBlue(i, j)) ) image->SetRGB(i, j, 0, 0, 0 ); } @@ -1106,16 +1106,17 @@ bool wxICOHandler::SaveFile(wxImage *image, return TRUE; } -bool wxICOHandler::LoadFile(wxImage *image, wxInputStream& stream, +bool wxICOHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, int index) { stream.SeekI(0); return DoLoadFile(image, stream, verbose, index); } -bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, +bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, bool verbose, int index) { + (void) verbose; bool bResult = FALSE; bool IsBmp = FALSE; @@ -1126,7 +1127,7 @@ bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, wxUint16 nIcons = wxUINT16_SWAP_ON_BE(IconDir.idCount); // nType is 1 for Icons, 2 for Cursors: wxUint16 nType = wxUINT16_SWAP_ON_BE(IconDir.idType); - + // loop round the icons and choose the best one: ICONDIRENTRY *pIconDirEntry = new ICONDIRENTRY[nIcons]; ICONDIRENTRY *pCurrentEntry = pIconDirEntry; @@ -1144,7 +1145,7 @@ bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, if ( pCurrentEntry->bColorCount == 0 ) pCurrentEntry->bColorCount = 255; if ( pCurrentEntry->bColorCount >= colmax ) - { + { iSel = i; wMax = pCurrentEntry->bWidth; colmax = pCurrentEntry->bColorCount; @@ -1152,14 +1153,14 @@ bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, } pCurrentEntry++; } - + if ( index != -1 ) { // VS: Note that we *have* to run the loop above even if index != -1, because // it reads ICONDIRENTRies. iSel = index; } - + if ( iSel == wxNOT_FOUND || iSel < 0 || iSel >= nIcons ) { wxLogError(_("ICO: Invalid icon index.")); @@ -1230,11 +1231,11 @@ bool wxCURHandler::DoCanRead(wxInputStream& stream) IMPLEMENT_DYNAMIC_CLASS(wxANIHandler, wxCURHandler) -bool wxANIHandler::LoadFile(wxImage *image, wxInputStream& stream, +bool wxANIHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, int index) { - wxInt32 FCC1, FCC2; - wxUint32 datalen; + wxInt32 FCC1, FCC2; + wxUint32 datalen; static const char *rifftxt = "RIFF"; static const char *listtxt = "LIST"; static const char *icotxt = "icon"; @@ -1244,15 +1245,15 @@ bool wxANIHandler::LoadFile(wxImage *image, wxInputStream& stream, wxInt32 *ico32 = (wxInt32 *) icotxt; int iIcon = 0; - + stream.SeekI(0); stream.Read(&FCC1, 4); - if ( FCC1 != *riff32 ) + if ( FCC1 != *riff32 ) return FALSE; // we have a riff file: while (stream.IsOk()) - { + { // we always have a data size stream.Read(&datalen, 4); @@ -1261,12 +1262,12 @@ bool wxANIHandler::LoadFile(wxImage *image, wxInputStream& stream, { stream.Read(&FCC2, 4); } - else + else { if (FCC1 == *ico32 && iIcon >= index) { return DoLoadFile(image, stream, verbose, -1); - } + } else { stream.SeekI(stream.TellI() + datalen); @@ -1274,7 +1275,7 @@ bool wxANIHandler::LoadFile(wxImage *image, wxInputStream& stream, iIcon ++; } } - + // try to read next data chunk: stream.Read(&FCC1, 4); } @@ -1283,8 +1284,8 @@ bool wxANIHandler::LoadFile(wxImage *image, wxInputStream& stream, bool wxANIHandler::DoCanRead(wxInputStream& stream) { - wxInt32 FCC1, FCC2; - wxUint32 datalen ; + wxInt32 FCC1, FCC2; + wxUint32 datalen ; static const char *rifftxt = "RIFF"; static const char *listtxt = "LIST"; static const char *anihtxt = "anih"; @@ -1292,30 +1293,30 @@ bool wxANIHandler::DoCanRead(wxInputStream& stream) wxInt32 *riff32 = (wxInt32 *) rifftxt; wxInt32 *list32 = (wxInt32 *) listtxt; wxInt32 *anih32 = (wxInt32 *) anihtxt; - + stream.SeekI(0); stream.Read(&FCC1, 4); - if ( FCC1 != *riff32 ) + if ( FCC1 != *riff32 ) return FALSE; // we have a riff file: while ( stream.IsOk() ) { if ( FCC1 != *anih32 ) - return TRUE; + return TRUE; // we always have a data size: stream.Read(&datalen, 4); - + // now either data or a FCC: - if ( (FCC1 == *riff32) || (FCC1 == *list32) ) + if ( (FCC1 == *riff32) || (FCC1 == *list32) ) { stream.Read(&FCC2, 4); } - else + else { stream.SeekI(stream.TellI() + datalen); } - + // try to read next data chunk: stream.Read(&FCC1, 4); } @@ -1325,8 +1326,8 @@ bool wxANIHandler::DoCanRead(wxInputStream& stream) int wxANIHandler::GetImageCount(wxInputStream& stream) { - wxInt32 FCC1, FCC2; - wxUint32 datalen ; + wxInt32 FCC1, FCC2; + wxUint32 datalen ; static const char *rifftxt = "RIFF"; static const char *listtxt = "LIST"; static const char *anihtxt = "anih"; @@ -1334,7 +1335,7 @@ int wxANIHandler::GetImageCount(wxInputStream& stream) wxInt32 *riff32 = (wxInt32 *) rifftxt; wxInt32 *list32 = (wxInt32 *) listtxt; wxInt32 *anih32 = (wxInt32 *) anihtxt; - + stream.SeekI(0); stream.Read(&FCC1, 4); if ( FCC1 != *riff32 ) @@ -1345,9 +1346,9 @@ int wxANIHandler::GetImageCount(wxInputStream& stream) { // we always have a data size: stream.Read(&datalen, 4); - + // now either data or a FCC: - if ( (FCC1 == *riff32) || (FCC1 == *list32) ) + if ( (FCC1 == *riff32) || (FCC1 == *list32) ) { stream.Read(&FCC2, 4); } @@ -1361,10 +1362,10 @@ int wxANIHandler::GetImageCount(wxInputStream& stream) delete[] pData; return nIcons; } - else + else stream.SeekI(stream.TellI() + datalen); } - + // try to read next data chunk: stream.Read(&FCC1, 4); } diff --git a/src/common/quantize.cpp b/src/common/quantize.cpp index a29113876e..1d1e1500fb 100644 --- a/src/common/quantize.cpp +++ b/src/common/quantize.cpp @@ -334,7 +334,7 @@ typedef my_cquantizer * my_cquantize_ptr; void 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; register JSAMPROW ptr; @@ -1284,7 +1284,7 @@ finish_pass1 (j_decompress_ptr cinfo) void -finish_pass2 (j_decompress_ptr cinfo) +finish_pass2 (j_decompress_ptr WXUNUSED(cinfo)) { /* no work */ } diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 5f069277de..c8207ca44e 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -124,7 +124,7 @@ static size_t encode_utf16(wxUint32 input, wchar_t *output) { if (input<=0xffff) { - if (output) *output++ = input; + if (output) *output++ = (wchar_t) input; return 1; } else if (input>=0x110000) @@ -135,8 +135,8 @@ static size_t encode_utf16(wxUint32 input, wchar_t *output) { if (output) { - *output++ = (input >> 10)+0xd7c0; - *output++ = (input&0x3ff)+0xdc00; + *output++ = (wchar_t) ((input >> 10)+0xd7c0); + *output++ = (wchar_t) ((input&0x3ff)+0xdc00); } return 2; } @@ -389,7 +389,7 @@ size_t wxMBConvUTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const { // plain ASCII char if (buf) - *buf++ = cc; + *buf++ = (char) cc; len++; } @@ -398,9 +398,9 @@ size_t wxMBConvUTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const len += cnt + 1; if (buf) { - *buf++ = (-128 >> cnt) | ((cc >> (cnt * 6)) & (0x3f >> cnt)); + *buf++ = (char) ((-128 >> cnt) | ((cc >> (cnt * 6)) & (0x3f >> 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); } - 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); if (buf) @@ -786,7 +786,7 @@ public: 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) ) \ || ( defined(__MWERKS__) && defined(__WXMSW__) ) diff --git a/src/common/variant.cpp b/src/common/variant.cpp index 6449a5fdd4..859f722a79 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -1810,7 +1810,7 @@ void wxVariant::operator= (const TIMESTAMP_STRUCT* value) #endif // wxUSE_ODBC -bool wxVariant::operator==(const wxArrayString& value) const +bool wxVariant::operator==(const wxArrayString& WXUNUSED(value)) const { wxFAIL_MSG( _T("TODO") ); diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index ce68b5ac34..83253625ef 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -167,6 +167,10 @@ void wxWindowBase::InitBase() m_caret = (wxCaret *)NULL; #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) m_themeEnabled = FALSE; } @@ -1002,7 +1006,7 @@ void wxWindowBase::OnHelp(wxHelpEvent& event) #endif // wxUSE_HELP // ---------------------------------------------------------------------------- -// tooltips +// tooltipsroot.Replace("\\", "/"); // ---------------------------------------------------------------------------- #if wxUSE_TOOLTIPS diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index 417ad1069f..c56008620e 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -407,7 +407,7 @@ static int LINKAGEMODE wxDirCtrlStringCompareFunction(const void *first, const v { wxString *strFirst = (wxString *)first; wxString *strSecond = (wxString *)second; - + return strFirst->CmpNoCase(*strSecond); } @@ -454,7 +454,7 @@ bool wxDirItemData::HasSubDirs() const return dir.HasSubDirs(); } -bool wxDirItemData::HasFiles(const wxString& spec) const +bool wxDirItemData::HasFiles(const wxString& WXUNUSED(spec)) const { if (m_path.IsEmpty()) return FALSE; @@ -578,8 +578,8 @@ void wxGenericDirCtrl::Init() void wxGenericDirCtrl::ShowHidden( bool show ) { m_showHidden = show; - - // reparse FIXME + + // reparse FIXME } void wxGenericDirCtrl::AddSection(const wxString& path, const wxString& name, int imageId) diff --git a/src/generic/splash.cpp b/src/generic/splash.cpp index 144bac6469..dfb01335a6 100644 --- a/src/generic/splash.cpp +++ b/src/generic/splash.cpp @@ -108,6 +108,16 @@ wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* par wxWindow(parent, id, pos, size, style) { m_bitmap = bitmap; + +#ifndef __WXGTK__ + bool hiColour = (wxDisplayDepth() >= 16) ; + + if (bitmap.GetPalette() && !hiColour) + { + SetPalette(* bitmap.GetPalette()); + } +#endif + } 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) { - dc.SetPalette(* bitmap.GetPalette()); dcMem.SetPalette(* bitmap.GetPalette()); } #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 if (bitmap.GetPalette() && !hiColour) { - dc.SetPalette(wxNullPalette); dcMem.SetPalette(wxNullPalette); } #endif // USE_PALETTE_IN_SPLASH diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index d16901dee4..89e0197b8b 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -368,7 +368,7 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event ) if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); - + m_finished = TRUE; m_owner->SetFocus(); // This doesn't work. TODO. @@ -424,7 +424,7 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event ) (*m_accept) = TRUE; (*m_res) = GetValue(); - + if ((*m_res) != m_startValue) m_owner->OnRenameAccept(); } @@ -716,7 +716,7 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, #ifdef __WXMAC__ int major,minor; wxGetOsVersion( &major, &minor ); - + if (style & wxTR_HAS_BUTTONS) style |= wxTR_MAC_BUTTONS; if (style & wxTR_HAS_BUTTONS) style &= ~wxTR_HAS_BUTTONS; style &= ~wxTR_LINES_AT_ROOT; @@ -766,7 +766,7 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl() { delete m_hilightBrush; delete m_hilightUnfocusedBrush; - + if (m_arrowRight) delete m_arrowRight; if (m_arrowDown) delete m_arrowDown; @@ -789,13 +789,13 @@ size_t wxGenericTreeCtrl::GetCount() const void wxGenericTreeCtrl::SetIndent(unsigned int indent) { - m_indent = indent; + m_indent = (unsigned short) indent; m_dirty = TRUE; } void wxGenericTreeCtrl::SetSpacing(unsigned int spacing) { - m_spacing = spacing; + m_spacing = (unsigned short) spacing; m_dirty = TRUE; } @@ -2115,7 +2115,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level else if (HasFlag(wxTR_TWIST_BUTTONS)) { // draw the twisty button here - + if (HasFlag(wxTR_AQUA_BUTTONS)) { if (item->IsExpanded()) diff --git a/src/html/m_style.cpp b/src/html/m_style.cpp index 112bf3aff4..9355867e81 100644 --- a/src/html/m_style.cpp +++ b/src/html/m_style.cpp @@ -32,7 +32,7 @@ FORCE_LINK_ME(m_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, // because CSS style text would be rendered verbatim otherwise diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index bfc738c185..05445fae71 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1143,7 +1143,7 @@ void wxDC::DoDrawRotatedText(const wxString& text, #if wxUSE_PALETTE -void wxDC::SetPalette(const wxPalette& palette) +void wxDC::DoSelectPalette(bool realize) { #ifdef __WXMICROWIN__ if (!GetHDC()) return; @@ -1157,31 +1157,44 @@ void wxDC::SetPalette(const wxPalette& palette) 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()) { HPALETTE oldPal = ::SelectPalette(GetHdc(), (HPALETTE) m_palette.GetHPALETTE(), FALSE); if (!m_oldPalette) m_oldPalette = (WXHPALETTE) oldPal; - ::RealizePalette(GetHdc()); + if (realize) + ::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 void wxDC::SetFont(const wxFont& the_font) diff --git a/src/msw/dcclient.cpp b/src/msw/dcclient.cpp index d853cf580e..6d5df17f48 100644 --- a/src/msw/dcclient.cpp +++ b/src/msw/dcclient.cpp @@ -113,6 +113,11 @@ void wxWindowDC::InitDC() // default bg colour is pne of the window 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 } // ---------------------------------------------------------------------------- diff --git a/src/msw/fontenum.cpp b/src/msw/fontenum.cpp index dec87f4fc1..80ce3c606e 100644 --- a/src/msw/fontenum.cpp +++ b/src/msw/fontenum.cpp @@ -275,8 +275,9 @@ bool wxFontEnumerator::EnumerateEncodings(const wxString& family) #ifndef __WXMICROWIN__ 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 // reasons to restrict ourselves to them here #if 0 diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 91284a31d6..0646ed7814 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -2339,7 +2339,7 @@ static void wxConvertToMSWListItem(const wxListCtrl *ctrl, lvItem.mask |= LVIF_PARAM; } -static void wxConvertToMSWListCol(int col, const wxListItem& item, +static void wxConvertToMSWListCol(int WXUNUSED(col), const wxListItem& item, LV_COLUMN& lvCol) { wxZeroMemory(lvCol); diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index 65151fbf5e..e816a3d629 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -685,13 +685,13 @@ void wxDataObject::SetAutoDelete() m_pIDataObject = NULL; } -size_t wxDataObject::GetBufferOffset( const wxDataFormat& format ) +size_t wxDataObject::GetBufferOffset( const wxDataFormat& WXUNUSED(format) ) { return sizeof(size_t); } const void* wxDataObject::GetSizeFromBuffer( const void* buffer, size_t* size, - const wxDataFormat& format ) + const wxDataFormat& WXUNUSED(format) ) { size_t* p = (size_t*)buffer; *size = *p; @@ -700,7 +700,7 @@ const void* wxDataObject::GetSizeFromBuffer( const 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; *p = size; @@ -1070,13 +1070,13 @@ class CFSTR_SHELLURLDataObject:public wxCustomDataObject public: CFSTR_SHELLURLDataObject() : wxCustomDataObject(CFSTR_SHELLURL) {} protected: - virtual size_t GetBufferOffset( const wxDataFormat& format ) + virtual size_t GetBufferOffset( const wxDataFormat& WXUNUSED(format) ) { return 0; } virtual const void* GetSizeFromBuffer( const void* buffer, size_t* size, - const wxDataFormat& format ) + const wxDataFormat& WXUNUSED(format) ) { // CFSTR_SHELLURL is _always_ ANSI text *size = strlen( (const char*)buffer ); @@ -1084,8 +1084,8 @@ protected: return buffer; } - virtual void* SetSizeInBuffer( void* buffer, size_t size, - const wxDataFormat& format ) + virtual void* SetSizeInBuffer( void* buffer, size_t WXUNUSED(size), + const wxDataFormat& WXUNUSED(format) ) { return buffer; } diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 6f16032cc9..eb7c59e6ec 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1087,7 +1087,7 @@ bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* pMsg) // usual preprocessing for them if ( msg->message == WM_KEYDOWN ) { - WORD vkey = msg->wParam; + WORD vkey = (WORD) msg->wParam; if ( (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN ) { if ( vkey == VK_BACK ) @@ -1437,7 +1437,7 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event) // 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; if ( hdr->code == EN_LINK ) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 0d91882294..b47f269cfd 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -890,14 +890,14 @@ void wxWindowMSW::SetScrollbar(int orient, int pos, int thumbVisible, void wxWindowMSW::ScrollWindow(int dx, int dy, const wxRect *prect) { - RECT rect, *pr; + RECT rect; + RECT *pr; if ( prect ) { rect.left = prect->x; rect.top = prect->y; rect.right = prect->x + prect->width; rect.bottom = prect->y + prect->height; - pr = ▭ } else @@ -1951,11 +1951,12 @@ bool wxWindowMSW::MSWTranslateMessage(WXMSG* pMsg) #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__) return m_acceleratorTable.Translate(this, pMsg); #else + (void) pMsg; return FALSE; #endif // wxUSE_ACCEL } -bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* pMsg) +bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* WXUNUSED(pMsg)) { // preprocess all messages by default return TRUE; @@ -2501,6 +2502,10 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam processed = HandleSysColorChange(); break; + case WM_DISPLAYCHANGE: + processed = HandleDisplayChange(); + break; + case WM_PALETTECHANGED: processed = HandlePaletteChanged((WXHWND) (HWND) wParam); break; @@ -3289,6 +3294,14 @@ bool wxWindowMSW::HandleSysColorChange() return FALSE; } +bool wxWindowMSW::HandleDisplayChange() +{ + wxDisplayChangedEvent event; + event.SetEventObject(this); + + return GetEventHandler()->ProcessEvent(event); +} + bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush, WXHDC pDC, WXHWND pWnd, @@ -3335,6 +3348,32 @@ WXHBRUSH wxWindowMSW::OnCtlColor(WXHDC WXUNUSED(hDC), 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()); event.SetEventObject(this); event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); @@ -3344,6 +3383,29 @@ bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange) 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()); event.SetEventObject(this); @@ -3351,7 +3413,7 @@ bool wxWindowMSW::HandleQueryNewPalette() } // 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 // changed (there is no need to do it for the non top level windows as we diff --git a/src/xrc/xml.cpp b/src/xrc/xml.cpp index d7001dd1e9..32ee02a04b 100644 --- a/src/xrc/xml.cpp +++ b/src/xrc/xml.cpp @@ -332,7 +332,7 @@ bool wxXmlDocument::Save(const wxString& filename) const // wxXmlDocument loading routines //----------------------------------------------------------------------------- -/* +/* FIXME: - process all elements, including CDATA */ @@ -349,12 +349,12 @@ inline static wxString CharToString(wxMBConv *conv, { size_t nLen = (len != wxSTRING_MAXLEN) ? len : nLen = wxConvUTF8.MB2WC((wchar_t*) NULL, s, 0); - + wchar_t *buf = new wchar_t[nLen+1]; wxConvUTF8.MB2WC(buf, s, nLen); buf[nLen] = 0; - return wxString(buf, *conv, len); delete[] buf; + return wxString(buf, *conv, len); } else return wxString(s, len); @@ -473,21 +473,21 @@ static int UnknownEncodingHnd(void * WXUNUSED(encodingHandlerData), char mbBuf[255]; wchar_t wcBuf[255]; size_t i; - + for (i = 0; i < 255; i++) - mbBuf[i] = i+1; + mbBuf[i] = (char) (i+1); mbBuf[255] = 0; conv.MB2WC(wcBuf, mbBuf, 255); wcBuf[255] = 0; - + info->map[0] = 0; for (i = 0; i < 255; i++) info->map[i+1] = (int)wcBuf[i]; - + info->data = NULL; info->convert = NULL; info->release = NULL; - + return 1; } @@ -512,7 +512,7 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding) if ( encoding != wxT("UTF-8") && encoding != wxT("utf-8") ) ctx.conv = new wxCSConv(encoding); #endif - + XML_SetUserData(parser, (void*)&ctx); XML_SetElementHandler(parser, StartElementHnd, EndElementHnd); XML_SetCharacterDataHandler(parser, TextHnd); @@ -542,7 +542,7 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding) if ( ctx.conv ) delete ctx.conv; #endif - + return TRUE; } @@ -572,7 +572,7 @@ inline static void OutputString(wxOutputStream& stream, const wxString& str, #endif } -// Same as above, but create entities first. +// Same as above, but create entities first. // Translates '<' to "<", '>' to ">" and '&' to "&" static void OutputStringEnt(wxOutputStream& stream, const wxString& str, wxMBConv *convMem, wxMBConv *convFile) @@ -580,25 +580,25 @@ static void OutputStringEnt(wxOutputStream& stream, const wxString& str, wxString buf; size_t i, last, len; wxChar c; - + len = str.Len(); last = 0; for (i = 0; i < len; i++) { c = str.GetChar(i); - if (c == wxT('<') || c == wxT('>') || + if (c == wxT('<') || c == wxT('>') || (c == wxT('&') && str.Mid(i+1, 4) != wxT("amp;"))) { OutputString(stream, str.Mid(last, i - last), convMem, convFile); switch (c) { - case wxT('<'): + case wxT('<'): OutputString(stream, wxT("<"), NULL, NULL); break; - case wxT('>'): + case wxT('>'): OutputString(stream, wxT(">"), NULL, NULL); break; - case wxT('&'): + case wxT('&'): OutputString(stream, wxT("&"), NULL, NULL); break; default: break; @@ -628,11 +628,11 @@ static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent, case wxXML_TEXT_NODE: OutputStringEnt(stream, node->GetContent(), convMem, convFile); break; - + case wxXML_ELEMENT_NODE: OutputString(stream, wxT("<"), NULL, NULL); OutputString(stream, node->GetName(), NULL, NULL); - + prop = node->GetProperties(); while (prop) { @@ -642,7 +642,7 @@ static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent, // FIXME - what if prop contains '"'? prop = prop->GetNext(); } - + if (node->GetChildren()) { OutputString(stream, wxT(">"), NULL, NULL); @@ -665,13 +665,13 @@ static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent, else OutputString(stream, wxT("/>"), NULL, NULL); break; - + case wxXML_COMMENT_NODE: OutputString(stream, wxT(""), NULL, NULL); break; - + default: wxFAIL_MSG(wxT("unsupported node type")); } @@ -681,9 +681,9 @@ bool wxXmlDocument::Save(wxOutputStream& stream) const { if ( !IsOk() ) return FALSE; - + wxString s; - + wxMBConv *convMem = NULL, *convFile = NULL; #if wxUSE_UNICODE convFile = new wxCSConv(GetFileEncoding()); @@ -694,18 +694,18 @@ bool wxXmlDocument::Save(wxOutputStream& stream) const convMem = new wxCSConv(GetEncoding()); } #endif - + s.Printf(wxT("\n"), GetVersion().c_str(), GetFileEncoding().c_str()); OutputString(stream, s, NULL, NULL); - + OutputNode(stream, GetRoot(), 0, convMem, convFile); OutputString(stream, wxT("\n"), NULL, NULL); - + if ( convFile ) delete convFile; if ( convMem ) delete convMem; - + return TRUE; } -- 2.45.2