Commited latest SciTech changes into CVS. This includes updates to the
applet code (with changes copyright headers) as well as updates to the wxImage and dib.cpp modules to use virtual file systems so that we can load these objects from ZIP files correctly. The dib.cpp module was also extensively cleaned up (although the DIB writing code does not presently use file streams as we couldn't figure out if it was possible to write to a ZIP file stream). The code has been tested and functions correctly for both regular files and ZIP files. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10551 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -5,23 +5,19 @@
|
|||||||
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* ======================================================================
|
* ========================================================================
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
*
|
||||||
* | |
|
* The contents of this file are subject to the wxWindows License
|
||||||
* |This copyrighted computer code is a proprietary trade secret of |
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
* http://www.wxwindows.org/licence3.txt
|
||||||
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
*
|
||||||
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
* Software distributed under the License is distributed on an
|
||||||
* |written authorization from SciTech to possess or use this code, you |
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* |may be subject to civil and/or criminal penalties. |
|
* implied. See the License for the specific language governing
|
||||||
* | |
|
* rights and limitations under the License.
|
||||||
* |If you received this code in error or you would like to report |
|
*
|
||||||
* |improper use, please immediately contact SciTech Software, Inc. at |
|
* ========================================================================
|
||||||
* |530-894-8400. |
|
|
||||||
* | |
|
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
|
||||||
* ======================================================================
|
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
* Environment: Any
|
* Environment: Any
|
||||||
@@ -51,7 +47,7 @@ private:
|
|||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxHtmlAppletWindow *m_parent;
|
//wxHtmlAppletWindow *m_parent;
|
||||||
|
|
||||||
// Special handler for background erase messages
|
// Special handler for background erase messages
|
||||||
void OnEraseBackground(wxEraseEvent&);
|
void OnEraseBackground(wxEraseEvent&);
|
||||||
|
95
contrib/include/wx/applet/echovar.h
Normal file
95
contrib/include/wx/applet/echovar.h
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Header file for wxEchoVariable Class, Dynamically constructed
|
||||||
|
* objects representing variables in SSI #echo directive
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __WX_ECHOVAR_H
|
||||||
|
#define __WX_ECHOVAR_H
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
wxEchoVariable class Definition
|
||||||
|
****************************************************************************/
|
||||||
|
class wxEchoVariable : public wxObject {
|
||||||
|
private:
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxEchoVariable);
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxEchoVariable() : wxObject() {}
|
||||||
|
~wxEchoVariable() {}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
RETURNS:
|
||||||
|
The boolean 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
|
||||||
|
****************************************************************************/
|
||||||
|
virtual wxString GetValue(const char *parms = NULL) const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
// static function to retrieve any variable avaliable
|
||||||
|
static wxString GetValue(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 _BEV_parm = wxString(parms);
|
||||||
|
|
||||||
|
#define END_ECHO_VARIABLE(name, returnval) \
|
||||||
|
return returnval; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define STRING_ECHO_VARIABLE(name, string) \
|
||||||
|
BEGIN_ECHO_VARIABLE(##name##); \
|
||||||
|
END_ECHO_VARIABLE(##name##, wxString(##string##))
|
||||||
|
|
||||||
|
#endif // __WX_ECHOVAR_H
|
||||||
|
|
95
contrib/include/wx/applet/ifelsevar.h
Normal file
95
contrib/include/wx/applet/ifelsevar.h
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Header file for wxIfElseVariable Class, Dynamically constructed
|
||||||
|
* objects representing variables in SSI #if, #else and #endif directives
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __WX_IFELSEVAR_H
|
||||||
|
#define __WX_IFELSEVAR_H
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
This class is used to create variables for the HTML preprocessor #if, #else,
|
||||||
|
and #endif directives.
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxIfElsePrep
|
||||||
|
****************************************************************************/
|
||||||
|
class wxIfElseVariable : public wxObject {
|
||||||
|
private:
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxIfElseVariable);
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxIfElseVariable() : wxObject() {}
|
||||||
|
~wxIfElseVariable() {}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
RETURNS:
|
||||||
|
The boolean value of the variable
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE
|
||||||
|
****************************************************************************/
|
||||||
|
virtual bool GetValue() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
// static function to retrieve any variable avaliable
|
||||||
|
static bool GetValue(const wxString &cls);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*--------------------------------- 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 {
|
||||||
|
|
||||||
|
#define END_IFELSE_VARIABLE(name, returnval) \
|
||||||
|
return returnval; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define IFELSE_VARIABLE(name, state) \
|
||||||
|
BEGIN_IFELSE_VARIABLE(##name##); \
|
||||||
|
END_IFELSE_VARIABLE(##name##, bool (state))
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __WX_IFELSEVAR_H
|
||||||
|
|
109
contrib/include/wx/applet/loadpage.h
Normal file
109
contrib/include/wx/applet/loadpage.h
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Header file for the wxLoadPage Event class
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __WX_LOAD_PAGE_H
|
||||||
|
#define __WX_LOAD_PAGE_H
|
||||||
|
|
||||||
|
#include "wx/html/htmlwin.h"
|
||||||
|
|
||||||
|
// Forward declaration
|
||||||
|
class wxHtmlAppletWindow;
|
||||||
|
|
||||||
|
// If we are compiling this code into a library that links against
|
||||||
|
// the DLL, we need to remove all the __declspec(dllimports) that
|
||||||
|
// would declare our classes below incorrectly.
|
||||||
|
|
||||||
|
#ifndef WXMAKINGDLL
|
||||||
|
#undef WXDLLEXPORT
|
||||||
|
#define WXDLLEXPORT
|
||||||
|
#endif
|
||||||
|
// Declare our local load page event type
|
||||||
|
BEGIN_DECLARE_EVENT_TYPES()
|
||||||
|
DECLARE_EVENT_TYPE(wxEVT_LOAD_PAGE, wxEVT_USER_FIRST+1)
|
||||||
|
DECLARE_EVENT_TYPE(wxEVT_PAGE_LOADED, wxEVT_USER_FIRST+2)
|
||||||
|
END_DECLARE_EVENT_TYPES()
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Defines the class for load page events.
|
||||||
|
****************************************************************************/
|
||||||
|
class wxLoadPageEvent : public wxEvent {
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxLoadPageEvent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxString m_hRef;
|
||||||
|
wxHtmlAppletWindow *m_htmlWindow;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
wxLoadPageEvent(const wxString &hRef = "",wxHtmlAppletWindow *htmlWindow = NULL);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~wxLoadPageEvent() {}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Define the macro to create our event type
|
||||||
|
typedef void (wxEvtHandler::*wxLoadPageEventFunction)(wxLoadPageEvent&);
|
||||||
|
#define EVT_LOAD_PAGE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_LOAD_PAGE, -1, -1, (wxObjectEventFunction)(wxEventFunction)(wxLoadPageEventFunction) & fn, (wxObject *) NULL ),
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Defines the class for pageloaded events.
|
||||||
|
****************************************************************************/
|
||||||
|
class wxPageLoadedEvent : public wxEvent {
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxPageLoadedEvent);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
wxPageLoadedEvent();
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~wxPageLoadedEvent() {}
|
||||||
|
|
||||||
|
// Copy constructor for the object
|
||||||
|
void CopyObject(wxObject& obj) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Define the macro to create our event type
|
||||||
|
typedef void (wxEvtHandler::*wxPageLoadedEventFunction)(wxPageLoadedEvent&);
|
||||||
|
#define EVT_PAGE_LOADED(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PAGE_LOADED, -1, -1, (wxObjectEventFunction)(wxEventFunction)(wxPageLoadedEventFunction) & fn, (wxObject *) NULL ),
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __WX_LOAD_PAGE_H
|
59
contrib/include/wx/applet/prepecho.h
Normal file
59
contrib/include/wx/applet/prepecho.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Header file for the Preprocessor of the #echo directive
|
||||||
|
* in wxHTML.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __WX_PREPECHO_H
|
||||||
|
#define __WX_PREPECHO_H
|
||||||
|
|
||||||
|
#include "wx/html/htmlproc.h"
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Echo Preprocessor class Definition
|
||||||
|
****************************************************************************/
|
||||||
|
class wxEchoPrep : public wxHtmlProcessor {
|
||||||
|
private:
|
||||||
|
//DECLARE_DYNAMIC_CLASS(wxEchoPrep);
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxEchoPrep() : wxHtmlProcessor() {}
|
||||||
|
~wxEchoPrep() {}
|
||||||
|
|
||||||
|
// Process input text and return processed result
|
||||||
|
wxString Process(const wxString& text) const;
|
||||||
|
|
||||||
|
// Return priority value of this processor. The higher, the sooner
|
||||||
|
// is the processor applied to the text.
|
||||||
|
int GetPriority() const { return wxHTML_PRIORITY_SYSTEM-2; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __WX_PREPECHO_H
|
||||||
|
|
59
contrib/include/wx/applet/prepifelse.h
Normal file
59
contrib/include/wx/applet/prepifelse.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Header file for the Preprocessor of the #if SSI directive
|
||||||
|
* in wxHTML.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __WX_PREPIFELSE_H
|
||||||
|
#define __WX_PREPIFELSE_H
|
||||||
|
|
||||||
|
#include "wx/html/htmlproc.h"
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
If Else Preprocessor class Definition
|
||||||
|
****************************************************************************/
|
||||||
|
class wxIfElsePrep : public wxHtmlProcessor {
|
||||||
|
private:
|
||||||
|
//DECLARE_DYNAMIC_CLASS(wxIfElsePrep);
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxIfElsePrep() : wxHtmlProcessor() {}
|
||||||
|
~wxIfElsePrep() {}
|
||||||
|
|
||||||
|
// Process input text and return processed result
|
||||||
|
wxString Process(const wxString& text) const;
|
||||||
|
|
||||||
|
// Return priority value of this processor. The higher, the sooner
|
||||||
|
// is the processor applied to the text.
|
||||||
|
int GetPriority() const { return wxHTML_PRIORITY_SYSTEM-2; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __WX_PREPECHO_H
|
||||||
|
|
63
contrib/include/wx/applet/prepinclude.h
Normal file
63
contrib/include/wx/applet/prepinclude.h
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Header file for the Preprocessor of the #include directive
|
||||||
|
* in wxHTML.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __WX_PREPINCLUDE_H
|
||||||
|
#define __WX_PREPINCLUDE_H
|
||||||
|
|
||||||
|
#include "wx/html/htmlproc.h"
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
wxIncludePrep class Definition
|
||||||
|
****************************************************************************/
|
||||||
|
class wxIncludePrep : public wxHtmlProcessor {
|
||||||
|
private:
|
||||||
|
//DECLARE_DYNAMIC_CLASS(wxIncludePrep);
|
||||||
|
wxString DOC_ROOT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxIncludePrep() : wxHtmlProcessor() {DOC_ROOT = wxString("");}
|
||||||
|
~wxIncludePrep() {}
|
||||||
|
|
||||||
|
// Process input text and return processed result
|
||||||
|
wxString Process(const wxString& text) const;
|
||||||
|
|
||||||
|
// Return priority value of this processor. The higher, the sooner
|
||||||
|
// is the processor applied to the text.
|
||||||
|
int GetPriority() const { return wxHTML_PRIORITY_SYSTEM; }
|
||||||
|
|
||||||
|
void ChangeDirectory(const wxString &dir);
|
||||||
|
wxString GetDirectory() { return DOC_ROOT; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __WX_PREPINCLUDE_H
|
||||||
|
|
@@ -5,23 +5,19 @@
|
|||||||
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* ======================================================================
|
* ========================================================================
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
*
|
||||||
* | |
|
* The contents of this file are subject to the wxWindows License
|
||||||
* |This copyrighted computer code is a proprietary trade secret of |
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
* http://www.wxwindows.org/licence3.txt
|
||||||
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
*
|
||||||
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
* Software distributed under the License is distributed on an
|
||||||
* |written authorization from SciTech to possess or use this code, you |
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* |may be subject to civil and/or criminal penalties. |
|
* implied. See the License for the specific language governing
|
||||||
* | |
|
* rights and limitations under the License.
|
||||||
* |If you received this code in error or you would like to report |
|
*
|
||||||
* |improper use, please immediately contact SciTech Software, Inc. at |
|
* ========================================================================
|
||||||
* |530-894-8400. |
|
|
||||||
* | |
|
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
|
||||||
* ======================================================================
|
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
* Environment: Any
|
* Environment: Any
|
||||||
@@ -85,6 +81,7 @@ private:
|
|||||||
DECLARE_CLASS(wxHtmlAppletWindow);
|
DECLARE_CLASS(wxHtmlAppletWindow);
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
|
bool m_mutexLock;
|
||||||
wxIncludePrep *incPreprocessor; // deleted by list it is added too in constructor
|
wxIncludePrep *incPreprocessor; // deleted by list it is added too in constructor
|
||||||
protected:
|
protected:
|
||||||
wxAppletList m_AppletList;
|
wxAppletList m_AppletList;
|
||||||
@@ -152,6 +149,16 @@ public:
|
|||||||
// Event handlers to load a new page
|
// Event handlers to load a new page
|
||||||
void OnPageLoaded(wxPageLoadedEvent &event);
|
void OnPageLoaded(wxPageLoadedEvent &event);
|
||||||
|
|
||||||
|
// LoadPage mutex locks
|
||||||
|
void Lock() { m_mutexLock = true;};
|
||||||
|
void UnLock() { m_mutexLock = false;};
|
||||||
|
|
||||||
|
// Returns TRUE if the mutex is locked, FALSE otherwise.
|
||||||
|
bool IsLocked() { return m_mutexLock;};
|
||||||
|
|
||||||
|
// Tries to lock the mutex. If it can't, returns immediately with false.
|
||||||
|
bool TryLock();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __WX_APPLET_WINDOW_H
|
#endif // __WX_APPLET_WINDOW_H
|
||||||
|
@@ -2,22 +2,21 @@
|
|||||||
*
|
*
|
||||||
* wxWindows HTML Applet Package
|
* wxWindows HTML Applet Package
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the wxWindows licence; you
|
* The contents of this file are subject to the wxWindows License
|
||||||
* may not use this file except in compliance with the License. You may
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* obtain a copy of the License at http://www.wxwindows.org/licence.htm
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
*
|
*
|
||||||
* Software distributed under the License is distributed on an
|
* Software distributed under the License is distributed on an
|
||||||
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* implied. See the License for the specific language governing
|
* implied. See the License for the specific language governing
|
||||||
* rights and limitations under the License.
|
* rights and limitations under the License.
|
||||||
*
|
*
|
||||||
* The Original Code is Copyright (C) 2001 SciTech Software, Inc.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is SciTech Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
|
@@ -2,22 +2,21 @@
|
|||||||
*
|
*
|
||||||
* wxWindows HTML Applet Package
|
* wxWindows HTML Applet Package
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the wxWindows licence; you
|
* The contents of this file are subject to the wxWindows License
|
||||||
* may not use this file except in compliance with the License. You may
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* obtain a copy of the License at http://www.wxwindows.org/licence.htm
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
*
|
*
|
||||||
* Software distributed under the License is distributed on an
|
* Software distributed under the License is distributed on an
|
||||||
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* implied. See the License for the specific language governing
|
* implied. See the License for the specific language governing
|
||||||
* rights and limitations under the License.
|
* rights and limitations under the License.
|
||||||
*
|
*
|
||||||
* The Original Code is Copyright (C) 2001 SciTech Software, Inc.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is SciTech Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
|
@@ -2,22 +2,21 @@
|
|||||||
*
|
*
|
||||||
* wxWindows HTML Applet Package
|
* wxWindows HTML Applet Package
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the wxWindows licence; you
|
* The contents of this file are subject to the wxWindows License
|
||||||
* may not use this file except in compliance with the License. You may
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* obtain a copy of the License at http://www.wxwindows.org/licence.htm
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
*
|
*
|
||||||
* Software distributed under the License is distributed on an
|
* Software distributed under the License is distributed on an
|
||||||
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* implied. See the License for the specific language governing
|
* implied. See the License for the specific language governing
|
||||||
* rights and limitations under the License.
|
* rights and limitations under the License.
|
||||||
*
|
*
|
||||||
* The Original Code is Copyright (C) 2001 SciTech Software, Inc.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is SciTech Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
|
@@ -2,22 +2,21 @@
|
|||||||
*
|
*
|
||||||
* wxWindows HTML Applet Package
|
* wxWindows HTML Applet Package
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the wxWindows licence; you
|
* The contents of this file are subject to the wxWindows License
|
||||||
* may not use this file except in compliance with the License. You may
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* obtain a copy of the License at http://www.wxwindows.org/licence.htm
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
*
|
*
|
||||||
* Software distributed under the License is distributed on an
|
* Software distributed under the License is distributed on an
|
||||||
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* implied. See the License for the specific language governing
|
* implied. See the License for the specific language governing
|
||||||
* rights and limitations under the License.
|
* rights and limitations under the License.
|
||||||
*
|
*
|
||||||
* The Original Code is Copyright (C) 2001 SciTech Software, Inc.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is SciTech Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
|
@@ -5,23 +5,19 @@
|
|||||||
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* ======================================================================
|
* ========================================================================
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
*
|
||||||
* | |
|
* The contents of this file are subject to the wxWindows License
|
||||||
* |This copyrighted computer code is a proprietary trade secret of |
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
* http://www.wxwindows.org/licence3.txt
|
||||||
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
*
|
||||||
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
* Software distributed under the License is distributed on an
|
||||||
* |written authorization from SciTech to possess or use this code, you |
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* |may be subject to civil and/or criminal penalties. |
|
* implied. See the License for the specific language governing
|
||||||
* | |
|
* rights and limitations under the License.
|
||||||
* |If you received this code in error or you would like to report |
|
*
|
||||||
* |improper use, please immediately contact SciTech Software, Inc. at |
|
* ========================================================================
|
||||||
* |530-894-8400. |
|
|
||||||
* | |
|
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
|
||||||
* ======================================================================
|
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
* Environment: Any
|
* Environment: Any
|
||||||
|
@@ -1,25 +1,23 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* ======================================================================
|
* ========================================================================
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
*
|
||||||
* | |
|
* The contents of this file are subject to the wxWindows License
|
||||||
* |This copyrighted computer code is a proprietary trade secret of |
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
* http://www.wxwindows.org/licence3.txt
|
||||||
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
*
|
||||||
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
* Software distributed under the License is distributed on an
|
||||||
* |written authorization from SciTech to possess or use this code, you |
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* |may be subject to civil and/or criminal penalties. |
|
* implied. See the License for the specific language governing
|
||||||
* | |
|
* rights and limitations under the License.
|
||||||
* |If you received this code in error or you would like to report |
|
*
|
||||||
* |improper use, please immediately contact SciTech Software, Inc. at |
|
* ========================================================================
|
||||||
* |530-894-8400. |
|
|
||||||
* | |
|
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
|
||||||
* ======================================================================
|
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
* Environment: Any
|
* Environment: Any
|
||||||
|
@@ -5,23 +5,19 @@
|
|||||||
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* ======================================================================
|
* ========================================================================
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
*
|
||||||
* | |
|
* The contents of this file are subject to the wxWindows License
|
||||||
* |This copyrighted computer code is a proprietary trade secret of |
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
* http://www.wxwindows.org/licence3.txt
|
||||||
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
*
|
||||||
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
* Software distributed under the License is distributed on an
|
||||||
* |written authorization from SciTech to possess or use this code, you |
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* |may be subject to civil and/or criminal penalties. |
|
* implied. See the License for the specific language governing
|
||||||
* | |
|
* rights and limitations under the License.
|
||||||
* |If you received this code in error or you would like to report |
|
*
|
||||||
* |improper use, please immediately contact SciTech Software, Inc. at |
|
* ========================================================================
|
||||||
* |530-894-8400. |
|
|
||||||
* | |
|
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
|
||||||
* ======================================================================
|
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
* Environment: Any
|
* Environment: Any
|
||||||
@@ -72,7 +68,7 @@ Destructor for the wxApplet class.
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
wxApplet::~wxApplet()
|
wxApplet::~wxApplet()
|
||||||
{
|
{
|
||||||
m_parent->RemoveApplet(this);
|
((wxHtmlAppletWindow *) m_parent)->RemoveApplet(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@@ -5,23 +5,19 @@
|
|||||||
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* ======================================================================
|
* ========================================================================
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
*
|
||||||
* | |
|
* The contents of this file are subject to the wxWindows License
|
||||||
* |This copyrighted computer code is a proprietary trade secret of |
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
* http://www.wxwindows.org/licence3.txt
|
||||||
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
*
|
||||||
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
* Software distributed under the License is distributed on an
|
||||||
* |written authorization from SciTech to possess or use this code, you |
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* |may be subject to civil and/or criminal penalties. |
|
* implied. See the License for the specific language governing
|
||||||
* | |
|
* rights and limitations under the License.
|
||||||
* |If you received this code in error or you would like to report |
|
*
|
||||||
* |improper use, please immediately contact SciTech Software, Inc. at |
|
* ========================================================================
|
||||||
* |530-894-8400. |
|
|
||||||
* | |
|
|
||||||
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
|
||||||
* ======================================================================
|
|
||||||
*
|
*
|
||||||
* Language: ANSI C++
|
* Language: ANSI C++
|
||||||
* Environment: Any
|
* Environment: Any
|
||||||
@@ -82,6 +78,9 @@ wxHtmlAppletWindow::wxHtmlAppletWindow(
|
|||||||
const wxString& name)
|
const wxString& name)
|
||||||
: wxHtmlWindow(parent,id,pos,size,style,name)
|
: wxHtmlWindow(parent,id,pos,size,style,name)
|
||||||
{
|
{
|
||||||
|
// Init our locks
|
||||||
|
UnLock();
|
||||||
|
|
||||||
// setup client navbars
|
// setup client navbars
|
||||||
if (navBar) {
|
if (navBar) {
|
||||||
m_NavBar = navBar;
|
m_NavBar = navBar;
|
||||||
@@ -102,8 +101,6 @@ wxHtmlAppletWindow::wxHtmlAppletWindow(
|
|||||||
this->AddProcessor(incPreprocessor);
|
this->AddProcessor(incPreprocessor);
|
||||||
this->AddProcessor(echoPreprocessor);
|
this->AddProcessor(echoPreprocessor);
|
||||||
this->AddProcessor(ifPreprocessor);
|
this->AddProcessor(ifPreprocessor);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -240,23 +237,21 @@ bool wxHtmlAppletWindow::LoadPage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the directory from the string for use in the include preprocessor
|
// Make a copy of the current path the translate for <!-- include files from what will be the new path
|
||||||
// make sure we get either type of / or \.
|
// we cannot just grab this value from the base class since it is not correct until after LoadPage is
|
||||||
int ch = link.Find('\\', true);
|
// called. And we need the incPreprocessor to know the right path before LoadPage.
|
||||||
if (ch == -1) ch = link.Find('/', true);
|
|
||||||
if (ch != -1) {
|
|
||||||
wxFileSystem fs;
|
wxFileSystem fs;
|
||||||
wxString tmp = link.Mid(0, ch+1);
|
fs.ChangePathTo(m_FS->GetPath(), true);
|
||||||
fs.ChangePathTo(incPreprocessor->GetDirectory(), true);
|
fs.ChangePathTo(link);
|
||||||
fs.ChangePathTo(tmp, true);
|
|
||||||
incPreprocessor->ChangeDirectory(fs.GetPath());
|
incPreprocessor->ChangeDirectory(fs.GetPath());
|
||||||
}
|
|
||||||
|
|
||||||
// Inform all the applets that the new page is being loaded
|
// Inform all the applets that the new page is being loaded
|
||||||
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
|
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
|
||||||
(node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href));
|
(node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href));
|
||||||
bool stat = wxHtmlWindow::LoadPage(href);
|
bool stat = wxHtmlWindow::LoadPage(href);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Enable/Dis the navbar tools
|
// Enable/Dis the navbar tools
|
||||||
if (m_NavBar) {
|
if (m_NavBar) {
|
||||||
m_NavBar->EnableTool(m_NavForwardId,HistoryCanForward());
|
m_NavBar->EnableTool(m_NavForwardId,HistoryCanForward());
|
||||||
@@ -431,11 +426,21 @@ need to change the page for the current window to a new window.
|
|||||||
void wxHtmlAppletWindow::OnLoadPage(
|
void wxHtmlAppletWindow::OnLoadPage(
|
||||||
wxLoadPageEvent &event)
|
wxLoadPageEvent &event)
|
||||||
{
|
{
|
||||||
|
// Test the mutex lock. We have to do this here because wxHTML constantly
|
||||||
|
// calls wxYield which processes the message queue. This in turns means
|
||||||
|
// that we may end up processing a new 'loadPage' event while the new
|
||||||
|
// page is still loading! We need to avoid this so we use a simple
|
||||||
|
// lock to avoid loading a page while presently loading another page.
|
||||||
|
if (TryLock()) {
|
||||||
if (event.GetHtmlWindow() == this){
|
if (event.GetHtmlWindow() == this){
|
||||||
if (LoadPage(event.GetHRef())){
|
if (LoadPage(event.GetHRef())){
|
||||||
wxPageLoadedEvent evt;
|
// wxPageLoadedEvent evt;
|
||||||
|
// NOTE: This is reserved for later use as we might need to send
|
||||||
|
// page loaded events to applets.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UnLock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -452,6 +457,23 @@ void wxHtmlAppletWindow::OnPageLoaded(
|
|||||||
Enable(true);
|
Enable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
none
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This function tries to lock the mutex. If it can't, returns
|
||||||
|
immediately with false.
|
||||||
|
***************************************************************************/
|
||||||
|
bool wxHtmlAppletWindow::TryLock()
|
||||||
|
{
|
||||||
|
if (!m_mutexLock) {
|
||||||
|
m_mutexLock = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
PARAMETERS:
|
PARAMETERS:
|
||||||
name - name of the last applet that changed the data in this object
|
name - name of the last applet that changed the data in this object
|
||||||
|
180
contrib/src/applet/echovar.cpp
Normal file
180
contrib/src/applet/echovar.cpp
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Implementation of wxEchoVariable Class, Dynamically constructed
|
||||||
|
* objects representing variables in SSI #echo directive
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// For compilers that support precompilation
|
||||||
|
#include "wx/wxprec.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);
|
||||||
|
|
||||||
|
/*----------------------------- Implementation ----------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
cls - The String name of the class
|
||||||
|
parms - an optional parameter string to pass off to the child class
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
The string value of the variable
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
To grab a value from any class which is derived from this one simple use this
|
||||||
|
static function and the name of the derived class to get the value.
|
||||||
|
This static function is the only function implemented in this base class
|
||||||
|
basically this is provided for an easier method of grabbing a variable. We
|
||||||
|
keep all the dynamic object handling in this class to avoid confusing the source
|
||||||
|
where these are used.
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxEchoPrep
|
||||||
|
****************************************************************************/
|
||||||
|
static wxString wxEchoVariable::GetValue(
|
||||||
|
const wxString &cls,
|
||||||
|
const char *parms)
|
||||||
|
{
|
||||||
|
wxObject * tmpclass;
|
||||||
|
|
||||||
|
tmpclass = wxCreateDynamicObject(wxString("wxEchoVariable") + cls);
|
||||||
|
if (!tmpclass) {
|
||||||
|
#ifdef CHECKED
|
||||||
|
wxMessageBox(wxString("wxHTML #echo error: Class not found (") + cls + wxString(")."),"Error",wxICON_ERROR);
|
||||||
|
#endif
|
||||||
|
return wxString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
wxEchoVariable * ev = wxDynamicCast(tmpclass, wxEchoVariable);
|
||||||
|
|
||||||
|
if (!ev) {
|
||||||
|
#ifdef CHECKED
|
||||||
|
wxMessageBox(wxString("wxHTML #echo error: Class is not a valid echo variable (") + cls + wxString(")."),"Error",wxICON_ERROR);
|
||||||
|
#endif
|
||||||
|
return wxString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ev->GetValue(parms);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------ Macro Documentation ---------------------------*/
|
||||||
|
|
||||||
|
// Here we declare some fake functions to get doc-jet to properly document the macros
|
||||||
|
|
||||||
|
#undef ECHO_PARM
|
||||||
|
/****************************************************************************
|
||||||
|
RETURNS:
|
||||||
|
The value of the parameter string from the HTML parm= field
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This is a macro to retrieve the parameter string passed in the parm= field.
|
||||||
|
Use this macro to get the correct variable within a BEGIN_ECHO_VARIABLE and
|
||||||
|
END_ECHO_VARIABLE block.
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxEchoVariable, wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE
|
||||||
|
****************************************************************************/
|
||||||
|
wxString ECHO_PARM();
|
||||||
|
|
||||||
|
|
||||||
|
#undef BEGIN_ECHO_VARIABLE
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
name - The name of the variable to create
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This macro is used to create variables for use by the #echo directive
|
||||||
|
the HTML preprocessor.
|
||||||
|
To create a new variable include the code necessary to get the value of the
|
||||||
|
variable between a block of BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros.
|
||||||
|
Use the ECHO_PARM macro to grab the optional parameter string passed from the
|
||||||
|
'parm=' field in the html file.
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
BEGIN_ECHO_VARIABLE(UserName)
|
||||||
|
// Get username from nucleus
|
||||||
|
wxString tmp = GA_GetUserName();
|
||||||
|
END_ECHO_VARIABLE(UserName, tmp)
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxEchoVariable, wxEchoPrep, END_ECHO_VARIABLE, ECHO_PARM, STRING_ECHO_VARIABLE
|
||||||
|
****************************************************************************/
|
||||||
|
void BEGIN_ECHO_VARIABLE(
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
#undef END_ECHO_VARIABLE
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
name - The name of the variable to end
|
||||||
|
returnval - The value which should be sent back as the value of the variable
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This macro is used to create variables for use by the #echo directive
|
||||||
|
the HTML preprocessor.
|
||||||
|
To create a new variable include the code necessary to get the value of the
|
||||||
|
variable between a block of BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros.
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
BEGIN_ECHO_VARIABLE(UserName)
|
||||||
|
// Get username from nucleus
|
||||||
|
wxString tmp = GA_GetUserName();
|
||||||
|
END_ECHO_VARIABLE(UserName, tmp)
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxEchoVariable, wxEchoPrep, BEGIN_ECHO_VARIABLE, ECHO_PARM, STRING_ECHO_VARIABLE
|
||||||
|
****************************************************************************/
|
||||||
|
void END_ECHO_VARIABLE(
|
||||||
|
const char *name,
|
||||||
|
wxString returnval);
|
||||||
|
|
||||||
|
#undef STRING_ECHO_VARIABLE
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
name - The name of the variable
|
||||||
|
returnval - String to return as the value of the variable
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This macro is used to create constant string variables for use by the #echo
|
||||||
|
directive in the HTML preprocessor.
|
||||||
|
This MACRO creates a variable that simply returns the given string and is
|
||||||
|
not modifiable.
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxEchoVariable, wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE
|
||||||
|
****************************************************************************/
|
||||||
|
void STRING_ECHO_VARIABLE(
|
||||||
|
const char *name,
|
||||||
|
wxString string);
|
||||||
|
|
||||||
|
// hack to make this file link
|
||||||
|
FORCE_LINK_ME(echovar)
|
159
contrib/src/applet/ifelsevar.cpp
Normal file
159
contrib/src/applet/ifelsevar.cpp
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Implementation of wxIfElseVariable Class, Dynamically constructed
|
||||||
|
* objects representing variables in SSI #if, #else, and #endif directives
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// For compilers that support precompilation
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
#include "wx/html/forcelnk.h"
|
||||||
|
|
||||||
|
// Include private headers
|
||||||
|
#include "wx/applet/ifelsevar.h"
|
||||||
|
|
||||||
|
/*---------------------------- Global variables ---------------------------*/
|
||||||
|
|
||||||
|
// Implement the dynamic class so it can be constructed dynamically
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxIfElseVariable, wxObject);
|
||||||
|
|
||||||
|
/*----------------------------- Implementation ----------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
cls - The String name of the class
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
The boolean value of the variable
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
To grab a value from any class which is derived from this one simple use this
|
||||||
|
static function and the name of the derived class to get the value.
|
||||||
|
This static function is the only function implemented in this base class
|
||||||
|
basically this is provided for an easier method of grabbing a variable. We
|
||||||
|
keep all the dynamic object handling in this class to avoid confusing the source
|
||||||
|
where these are used.
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxIfElsePrep
|
||||||
|
****************************************************************************/
|
||||||
|
static bool wxIfElseVariable::GetValue(
|
||||||
|
const wxString &cls)
|
||||||
|
{
|
||||||
|
wxObject * tmpclass;
|
||||||
|
|
||||||
|
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("");
|
||||||
|
}
|
||||||
|
|
||||||
|
wxIfElseVariable * ev = wxDynamicCast(tmpclass, wxIfElseVariable);
|
||||||
|
|
||||||
|
if (!ev) {
|
||||||
|
#ifdef CHECKED
|
||||||
|
wxMessageBox(wxString("wxHTML #if error: Class is not a valid ifelse variable (") + cls + wxString(")."),"Error",wxICON_ERROR);
|
||||||
|
#endif
|
||||||
|
return wxString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ev->GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------ Macro Documentation ---------------------------*/
|
||||||
|
|
||||||
|
// Here we declare some fake functions to get doc-jet to properly document the macros
|
||||||
|
|
||||||
|
#undef BEGIN_IFELSE_VARIABLE
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
name - The name of the variable to create
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This macro is used to create variables for use by the #if, #else and #endif
|
||||||
|
blocks in the HTML preprocessor.
|
||||||
|
To create a new variable include the code necessary to get the value of the
|
||||||
|
variable between a block of BEGIN_IFELSE_VARIABLE and END_IFELSE_VARIABLE macros.
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
BEGIN_IFELSE_VARIABLE(UserName)
|
||||||
|
// Get username from nucleus
|
||||||
|
bool tmp = GA_HasRegistered();
|
||||||
|
END_IFELSE_VARIABLE(UserName, tmp)
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxIfElseVariable, wxIfElsePrep, END_IFELSE_VARIABLE, IFELSE_VARIABLE
|
||||||
|
****************************************************************************/
|
||||||
|
void BEGIN_IFELSE_VARIABLE(
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
#undef END_IFELSE_VARIABLE
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
name - The name of the variable to end
|
||||||
|
returnval - The boolean value which is the value of the variable
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This macro is used to create variables for use by the #if, #else and #endif
|
||||||
|
blocks in the HTML preprocessor.
|
||||||
|
To create a new variable include the code necessary to get the value of the
|
||||||
|
variable between a block of BEGIN_IFELSE_VARIABLE and END_IFELSE_VARIABLE macros.
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
BEGIN_IFELSE_VARIABLE(UserName)
|
||||||
|
// Get username from nucleus
|
||||||
|
bool tmp = GA_HasRegistered();
|
||||||
|
END_IFELSE_VARIABLE(UserName, tmp)
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxIfElseVariable, wxIfElsePrep, BEGIN_IFELSE_VARIABLE, IFELSE_VARIABLE
|
||||||
|
****************************************************************************/
|
||||||
|
void END_IFELSE_VARIABLE(
|
||||||
|
const char *name,
|
||||||
|
bool returnval);
|
||||||
|
|
||||||
|
#undef IFELSE_VARIABLE
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
name - The name of the variable
|
||||||
|
state - value of the variable
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This macro is used to create constant boolean variables for use by the
|
||||||
|
#if, #else and #endif blocks in the HTML preprocessor.
|
||||||
|
This MACRO creates a variable that simply returns the given state and is
|
||||||
|
not modifiable.
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxIfElseVariable, wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE
|
||||||
|
****************************************************************************/
|
||||||
|
void IFELSE_VARIABLE(
|
||||||
|
const char *name,
|
||||||
|
bool state);
|
||||||
|
|
||||||
|
|
||||||
|
FORCE_LINK_ME(ifelsevar)
|
98
contrib/src/applet/loadpage.cpp
Normal file
98
contrib/src/applet/loadpage.cpp
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Loadpage event class implementation
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// For compilers that support precompilation
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
#include "wx/html/forcelnk.h"
|
||||||
|
|
||||||
|
// Include private headers
|
||||||
|
#include "wx/applet/loadpage.h"
|
||||||
|
|
||||||
|
/*------------------------- Implementation --------------------------------*/
|
||||||
|
|
||||||
|
// Implement the class functions for wxLoadPageEvent
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxLoadPageEvent, wxEvent)
|
||||||
|
|
||||||
|
// Implement the class functions for wxPageLoadedEvent
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxPageLoadedEvent, wxEvent)
|
||||||
|
|
||||||
|
// Define our custom event ID for load page
|
||||||
|
DEFINE_EVENT_TYPE(wxEVT_LOAD_PAGE);
|
||||||
|
|
||||||
|
// Define our custom event ID for page loaded
|
||||||
|
DEFINE_EVENT_TYPE(wxEVT_PAGE_LOADED);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Constructor for the wxLoadPageEvent class
|
||||||
|
****************************************************************************/
|
||||||
|
wxLoadPageEvent::wxLoadPageEvent(
|
||||||
|
const wxString &hRef,
|
||||||
|
wxHtmlAppletWindow *htmlWindow)
|
||||||
|
: m_hRef(hRef), m_htmlWindow(htmlWindow)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
****************************************************************************/
|
||||||
|
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)
|
||||||
|
|
128
contrib/src/applet/prepecho.cpp
Normal file
128
contrib/src/applet/prepecho.cpp
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: This file is the implementation of the Preprocessor object
|
||||||
|
* for parsing the <!--#echo directive
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// 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 ---------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------- Implementation ----------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
text - HTML to process for echo directives
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
The string containing the processed HTML
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This function replaces #echo directives with a variable retrieved from the
|
||||||
|
class given in the HTML directive. These classes are created by making a sub
|
||||||
|
class of wxEchoVariable. Dynamic class construction is used at run time
|
||||||
|
internally to create an instance of this class and access the value of the
|
||||||
|
variable.
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxEchoVariable
|
||||||
|
****************************************************************************/
|
||||||
|
wxString wxEchoPrep::Process(
|
||||||
|
const wxString& text) const
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char ft[] = "<!--#echo ";
|
||||||
|
|
||||||
|
// make a copy so we can replace text as we go without affecting the original
|
||||||
|
wxString output = text;
|
||||||
|
|
||||||
|
while ((i = (output.Lower()).Find(ft)) != -1) {
|
||||||
|
// Loop until every #echo directive is found
|
||||||
|
|
||||||
|
int n, c, end;
|
||||||
|
wxString cname, parms;
|
||||||
|
wxString tag;
|
||||||
|
|
||||||
|
// grab the tag and remove it from the file
|
||||||
|
end = (output.Mid(i)).Find("-->");
|
||||||
|
if (end == -1) {
|
||||||
|
#ifdef CHECKED
|
||||||
|
wxMessageBox("wxHTML #echo error: Premature end of file while parsing #echo.","Error",wxICON_ERROR);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
end += 3;
|
||||||
|
tag = output.Mid(i, end);
|
||||||
|
output.Remove(i, end);
|
||||||
|
|
||||||
|
n = (tag.Lower()).Find(" parm=");
|
||||||
|
c = tag.Find("-->");
|
||||||
|
if (n == -1) {
|
||||||
|
n = c;
|
||||||
|
// find the classname
|
||||||
|
c = (tag.Mid(10, n-10)).Find(" ");
|
||||||
|
if (c == -1) n -= 10;
|
||||||
|
else n = c;
|
||||||
|
cname = tag.Mid(10, n);
|
||||||
|
|
||||||
|
// grab the value from the class, put it in tag since the data is no longer needed
|
||||||
|
tag = wxEchoVariable::GetValue(cname, NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Find the parms
|
||||||
|
parms = tag.Mid(n+6, c-n-6);
|
||||||
|
// Clip off any quotation marks if they exist. (don't die if there arn't any)
|
||||||
|
c = parms.Find("\"");
|
||||||
|
if (c != -1) parms = parms.Mid(c+1);
|
||||||
|
c = parms.Find("\"");
|
||||||
|
if (c != -1) parms = parms.Mid(0, c);
|
||||||
|
// find the classname
|
||||||
|
c = (tag.Mid(10, n-10)).Find(" ");
|
||||||
|
if (c == -1) n -= 10;
|
||||||
|
else n = c;
|
||||||
|
cname = tag.Mid(10, n);
|
||||||
|
|
||||||
|
// grab the value from the class, put it in tag since the data is no longer needed
|
||||||
|
tag = wxEchoVariable::GetValue(cname, parms.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
output = (output.Mid(0,i) + tag + output.Mid(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_LINK(echovar)
|
||||||
|
|
171
contrib/src/applet/prepifelse.cpp
Normal file
171
contrib/src/applet/prepifelse.cpp
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: This file is the implementation of the Preprocessor object
|
||||||
|
* for parsing the <!--#if directive
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// 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"
|
||||||
|
|
||||||
|
/*---------------------------- Global variables ---------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------- Implementation ----------------------------*/
|
||||||
|
|
||||||
|
/* {SECRET} */
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
None of the Reverse Find functions in wxWindows appear to work in a way that
|
||||||
|
can be used by our code. This includes the libstr rfind implementations which
|
||||||
|
do not correctly pass the given return value.
|
||||||
|
****************************************************************************/
|
||||||
|
int ReverseFind(
|
||||||
|
const wxString &tstr,
|
||||||
|
const wxString &str)
|
||||||
|
{
|
||||||
|
wxASSERT( str.GetStringData()->IsValid() );
|
||||||
|
|
||||||
|
// TODO could be made much quicker than that
|
||||||
|
int p = tstr.Len()-str.Len()-1;
|
||||||
|
while ( p >= 0 ) {
|
||||||
|
if ( wxStrncmp(tstr.c_str() + p, str.c_str(), str.Len()) == 0 )
|
||||||
|
return p;
|
||||||
|
p--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
text - HTML to process for if/else blocks
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
The string containing the processed HTML
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This function replaces #if, #else, and #endif directives with the text
|
||||||
|
contained within the blocks, dependant on the value of the given boolean
|
||||||
|
variable. The variable is created by making a sub class of wxIfElseVariable.
|
||||||
|
Dynamic class construction is used at run time internally to create an instance
|
||||||
|
of this class and access the value of the variable.
|
||||||
|
|
||||||
|
SEE ALSO:
|
||||||
|
wxIfElseVariable
|
||||||
|
****************************************************************************/
|
||||||
|
wxString wxIfElsePrep::Process(
|
||||||
|
const wxString& text) const
|
||||||
|
{
|
||||||
|
int b;
|
||||||
|
char ft[] = "<!--#if ";
|
||||||
|
|
||||||
|
// make a copy so we can replace text as we go without affecting the original
|
||||||
|
wxString output = text;
|
||||||
|
while ((b = ReverseFind(output.Lower(), ft)) != -1) {
|
||||||
|
// Loop until every #echo directive is found
|
||||||
|
// We search from the end of the string so that #if statements will properly recurse
|
||||||
|
// and we avoid the hassle of matching statements with the correct <!--#endif-->
|
||||||
|
int end, c, n;
|
||||||
|
wxString usecode, code;
|
||||||
|
wxString cname;
|
||||||
|
wxString tag;
|
||||||
|
bool value;
|
||||||
|
|
||||||
|
code = wxString("");
|
||||||
|
|
||||||
|
// grab the tag and get the name of the variable
|
||||||
|
end = (output.Mid(b)).Find("-->");
|
||||||
|
if (end == -1) {
|
||||||
|
#ifdef CHECKED
|
||||||
|
wxMessageBox("wxHTML #if error: Premature end of file while parsing #if.","Error",wxICON_ERROR);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
end += 3;
|
||||||
|
tag = output.Mid(b, end);
|
||||||
|
output.Remove(b, end);
|
||||||
|
|
||||||
|
c = tag.Find("-->");
|
||||||
|
n = c;
|
||||||
|
|
||||||
|
// find the classname
|
||||||
|
c = (tag.Mid(8, n-8)).Find(" ");
|
||||||
|
if (c == -1) n -= 8;
|
||||||
|
else n = c;
|
||||||
|
cname = tag.Mid(8, n);
|
||||||
|
|
||||||
|
cname.Trim(false);
|
||||||
|
c = cname.Find("\"");
|
||||||
|
if (c != -1) cname = cname.Mid(c+1);
|
||||||
|
c = cname.Find("\"");
|
||||||
|
if (c != -1) cname = cname.Mid(0, c);
|
||||||
|
|
||||||
|
// Grab the value from the variable class identified by cname
|
||||||
|
value = wxIfElseVariable::GetValue(cname);
|
||||||
|
|
||||||
|
// Find the end of the tag (<!--#endif-->) and copy it all into the variable code
|
||||||
|
end = ((output.Mid(b)).Lower()).Find("<!--#endif-->");
|
||||||
|
if (end == -1) {
|
||||||
|
#ifdef CHECKED
|
||||||
|
wxMessageBox("wxHTML #if error: Premature end of file while searching for matching #endif.","Error",wxICON_ERROR);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = output.Mid(b, end);
|
||||||
|
output.Remove(b, end+13); // remove the entire #if block from original document
|
||||||
|
|
||||||
|
// Find out if there is an else statement
|
||||||
|
end = (code.Lower()).Find("<!--#else-->");
|
||||||
|
if (end != -1) {
|
||||||
|
if (!value) {
|
||||||
|
// Use the else statement
|
||||||
|
usecode = code.Mid(end+12);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Use statement before #else
|
||||||
|
usecode = code.Mid(0, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (value) {
|
||||||
|
// There is no #else statement
|
||||||
|
usecode = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usecode != wxString(""))
|
||||||
|
output = (output.Mid(0,b) + usecode + output.Mid(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_LINK(ifelsevar)
|
146
contrib/src/applet/prepinclude.cpp
Normal file
146
contrib/src/applet/prepinclude.cpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows License
|
||||||
|
* Version 3.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.wxwindows.org/licence3.txt
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: This file is the implementation of the Preprocessor object
|
||||||
|
* for parsing the <!--#include
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// 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"
|
||||||
|
|
||||||
|
#define RECURSE_LIMIT 50
|
||||||
|
/*---------------------------- Global variables ---------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------- Implementation ----------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
text - HTML to process for include directives
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
The string containing the processed HTML
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This is the only implemented method of the Preprocessor class. It is a constant
|
||||||
|
function that parses a string. Basically we load the string search for include
|
||||||
|
statements then replace them with the correct file. Wash rinse and repeat until
|
||||||
|
all recursive cases are handled.
|
||||||
|
****************************************************************************/
|
||||||
|
wxString wxIncludePrep::Process(
|
||||||
|
const wxString& text) const
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char ft[] = "<!--#include virtual=";
|
||||||
|
|
||||||
|
wxFileSystem *fs = new wxFileSystem;
|
||||||
|
fs->ChangePathTo(DOC_ROOT, true);
|
||||||
|
|
||||||
|
int openedcount = 0;
|
||||||
|
|
||||||
|
// make a copy so we can replace text as we go without affecting the original
|
||||||
|
wxString output = text;
|
||||||
|
while ((i = (output.Lower()).Find(ft)) != -1) {
|
||||||
|
// This loop makes more recursion unnecessary since each iteration adds
|
||||||
|
// the new include files to output.
|
||||||
|
int n, c;
|
||||||
|
wxString fname;
|
||||||
|
|
||||||
|
n = (output.Mid(i+21)).Find("-->");
|
||||||
|
|
||||||
|
if (n == -1) {
|
||||||
|
#ifdef CHECKED
|
||||||
|
wxMessageBox("wxHTML #include error: Could not read filename. Premature end of file.","Error",wxICON_ERROR);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fname = output.Mid(i+21, n);
|
||||||
|
|
||||||
|
// Clip off any quotation marks if they exist. (don't die if there arn't any)
|
||||||
|
c = fname.Find("\"");
|
||||||
|
if (c != -1) fname = fname.Mid(c+1);
|
||||||
|
c = fname.Find("\"");
|
||||||
|
if (c != -1) fname = fname.Mid(0, c);
|
||||||
|
|
||||||
|
// remove the #include tag
|
||||||
|
output.Remove(i, n+21+3);
|
||||||
|
|
||||||
|
wxFSFile * file = fs->OpenFile(fname);
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
#ifdef CHECKED
|
||||||
|
wxMessageBox(wxString("wxHTML #include error: File not Found ") + fname + wxString("."),"Error",wxICON_ERROR);
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString tmp;
|
||||||
|
|
||||||
|
|
||||||
|
do {
|
||||||
|
char tmp2[257];
|
||||||
|
(file->GetStream())->Read(tmp2, 256);
|
||||||
|
c = (file->GetStream())->LastRead();
|
||||||
|
tmp2[c] = 0;
|
||||||
|
tmp += wxString(tmp2);
|
||||||
|
} while (c == 256);
|
||||||
|
|
||||||
|
output = (output.Mid(0,i) + tmp + output.Mid(i));
|
||||||
|
|
||||||
|
#ifdef CHECKED
|
||||||
|
if (openedcount > RECURSE_LIMIT) {
|
||||||
|
wxMessageBox(wxString("wxHTML #include error: More than RECURSE_LIMIT files have been #included you may have a file that is directly or indirectly including itself, causing an endless loop"), "Error" ,wxICON_ERROR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
openedcount++;
|
||||||
|
delete file;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete fs;
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
dir - Default directory to get included HTML files from
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This function sets the directory to get included HTML files from. The default
|
||||||
|
value is the current directory. Directorys may be given as a relative path.
|
||||||
|
****************************************************************************/
|
||||||
|
void wxIncludePrep::ChangeDirectory(
|
||||||
|
const wxString &dir)
|
||||||
|
{
|
||||||
|
|
||||||
|
DOC_ROOT = dir;
|
||||||
|
}
|
||||||
|
|
@@ -28,6 +28,7 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/filefn.h"
|
#include "wx/filefn.h"
|
||||||
|
#include "wx/filesys.h"
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
@@ -762,18 +763,19 @@ bool wxImage::HasOption(const wxString& name) const
|
|||||||
bool wxImage::LoadFile( const wxString& filename, long type )
|
bool wxImage::LoadFile( const wxString& filename, long type )
|
||||||
{
|
{
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
if (wxFileExists(filename))
|
// We want to use wxFileSystem for virtual FS compatibility
|
||||||
{
|
wxFileSystem fsys;
|
||||||
wxFileInputStream stream(filename);
|
wxFSFile *file = fsys.OpenFile(filename);
|
||||||
wxBufferedInputStream bstream( stream );
|
if (!file) {
|
||||||
return LoadFile(bstream, type);
|
wxLogError(_("Can't open file '%s'"), filename);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxLogError( _("Can't load image from file '%s': file does not exist."), filename.c_str() );
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
wxInputStream *stream = file->GetStream();
|
||||||
|
if (!stream) {
|
||||||
|
wxLogError(_("Can't open stream for file '%s'"), filename);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return LoadFile(*stream, type);
|
||||||
#else // !wxUSE_STREAMS
|
#else // !wxUSE_STREAMS
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
@@ -782,18 +784,19 @@ bool wxImage::LoadFile( const wxString& filename, long type )
|
|||||||
bool wxImage::LoadFile( const wxString& filename, const wxString& mimetype )
|
bool wxImage::LoadFile( const wxString& filename, const wxString& mimetype )
|
||||||
{
|
{
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
if (wxFileExists(filename))
|
// We want to use wxFileSystem for virtual FS compatibility
|
||||||
{
|
wxFileSystem fsys;
|
||||||
wxFileInputStream stream(filename);
|
wxFSFile *file = fsys.OpenFile(filename);
|
||||||
wxBufferedInputStream bstream( stream );
|
if (!file) {
|
||||||
return LoadFile(bstream, mimetype);
|
wxLogError(_("Can't open file '%s'"), filename);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxLogError( _("Can't load image from file '%s': file does not exist."), filename.c_str() );
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
wxInputStream *stream = file->GetStream();
|
||||||
|
if (!stream) {
|
||||||
|
wxLogError(_("Can't open stream for file '%s'"), filename);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return LoadFile(*stream, mimetype);
|
||||||
#else // !wxUSE_STREAMS
|
#else // !wxUSE_STREAMS
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
|
523
src/msw/dib.cpp
523
src/msw/dib.cpp
@@ -1,29 +1,21 @@
|
|||||||
/*******************************************************************************
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
* *
|
// Name: dib.cpp
|
||||||
* MODULE : DIB.CC *
|
// Purpose: Routines for dealing with Device Independent Bitmaps.
|
||||||
* *
|
// Author:
|
||||||
* DESCRIPTION : Routines for dealing with Device Independent Bitmaps. *
|
// Modified by: Jason Quijano 06/06/2001
|
||||||
* *
|
// Created: 01/02/97
|
||||||
* FUNCTIONS : *
|
// RCS-ID: $Id$
|
||||||
* *
|
// Copyright: (c) Julian Smart
|
||||||
* wxReadDIB() - Reads a DIB *
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
* *
|
// FUNCTIONS :
|
||||||
* WriteDIB() - Writes a global handle in CF_DIB format*
|
// wxReadDIB() - Reads a DIB
|
||||||
* to a file. *
|
// WriteDIB() - Writes a global handle in CF_DIB format to a file.
|
||||||
* *
|
// wxPaletteSize() - Calculates the palette size in bytes of given DIB *
|
||||||
* wxPaletteSize() - Calculates the palette size in bytes *
|
// DibNumColors() - Determines the number of colors in DIB
|
||||||
* of given DIB *
|
// DibFromBitmap() - Creates a DIB repr. the DDB passed in.
|
||||||
* *
|
// lread() - Private routine to read more than 64k
|
||||||
* DibNumColors() - Determines the number of colors in DIB *
|
// lwrite() - Private routine to write more than 64k
|
||||||
* *
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
* DibFromBitmap() - Creates a DIB repr. the DDB passed in. *
|
|
||||||
* *
|
|
||||||
* *
|
|
||||||
* lread() - Private routine to read more than 64k *
|
|
||||||
* *
|
|
||||||
* lwrite() - Private routine to write more than 64k *
|
|
||||||
* *
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
@@ -47,39 +39,39 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/dib.h"
|
#include "wx/msw/dib.h"
|
||||||
|
#include "wx/filesys.h"
|
||||||
|
|
||||||
#ifdef __GNUWIN32_OLD__
|
#ifdef __GNUWIN32_OLD__
|
||||||
#include "wx/msw/gnuwin32/extra.h"
|
#include "wx/msw/gnuwin32/extra.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SEEK_CUR
|
#ifndef SEEK_CUR
|
||||||
/* flags for _lseek */
|
// flags for _lseek
|
||||||
#define SEEK_CUR 1
|
#define SEEK_CUR 1
|
||||||
#define SEEK_END 2
|
#define SEEK_END 2
|
||||||
#define SEEK_SET 0
|
#define SEEK_SET 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAXREAD 32768 /* Number of bytes to be read during */
|
// Number of bytes to be read during each read operation.
|
||||||
/* each read operation. */
|
#define MAXREAD 32768
|
||||||
|
|
||||||
/* Header signatutes for various resources */
|
// Header signatutes for various resources
|
||||||
#define BFT_ICON 0x4349 /* 'IC' */
|
#define BFT_ICON 0x4349 // 'IC'
|
||||||
#define BFT_BITMAP 0x4d42 /* 'BM' */
|
#define BFT_BITMAP 0x4d42 // 'BM'
|
||||||
#define BFT_CURSOR 0x5450 /* 'PT(' */
|
#define BFT_CURSOR 0x5450 // 'PT('
|
||||||
|
|
||||||
/* macro to determine if resource is a DIB */
|
// macro to determine if resource is a DIB
|
||||||
#define ISDIB(bft) ((bft) == BFT_BITMAP)
|
#define ISDIB(bft) ((bft) == BFT_BITMAP)
|
||||||
|
|
||||||
/* Macro to align given value to the closest DWORD (unsigned long ) */
|
// Macro to align given value to the closest DWORD (unsigned long )
|
||||||
#define ALIGNULONG(i) ((i+3)/4*4)
|
#define ALIGNULONG(i) ((i+3)/4*4)
|
||||||
|
|
||||||
/* Macro to determine to round off the given value to the closest byte */
|
// Macro to determine to round off the given value to the closest byte
|
||||||
#define WIDTHBYTES(i) ((i+31)/32*4)
|
#define WIDTHBYTES(i) ((i+31)/32*4)
|
||||||
|
|
||||||
#define PALVERSION 0x300
|
#define PALVERSION 0x300
|
||||||
#define MAXPALETTE 256 /* max. # supported palette entries */
|
#define MAXPALETTE 256 // max. # supported palette entries
|
||||||
|
|
||||||
static DWORD PASCAL lread(int fh, VOID FAR *pv, DWORD ul);
|
|
||||||
static DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul);
|
static DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul);
|
||||||
|
|
||||||
static BOOL WriteDIB (LPTSTR szFile,HANDLE hdib);
|
static BOOL WriteDIB (LPTSTR szFile,HANDLE hdib);
|
||||||
@@ -88,18 +80,14 @@ static WORD DibNumColors (VOID FAR * pv);
|
|||||||
// HANDLE DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal);
|
// HANDLE DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal);
|
||||||
static BOOL PASCAL MakeBitmapAndPalette(HDC,HANDLE,HPALETTE *,HBITMAP *);
|
static BOOL PASCAL MakeBitmapAndPalette(HDC,HANDLE,HPALETTE *,HBITMAP *);
|
||||||
|
|
||||||
/****************************************************************************
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
// FUNCTION : WriteDIB(LPSTR szFile,HANDLE hdib)
|
||||||
* FUNCTION : WriteDIB(LPSTR szFile,HANDLE hdib) *
|
// PURPOSE : Write a global handle in CF_DIB format to a file.
|
||||||
* *
|
// RETURNS : TRUE - if successful. FALSE - otherwise
|
||||||
* PURPOSE : Write a global handle in CF_DIB format to a file. *
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
static BOOL WriteDIB(
|
||||||
* RETURNS : TRUE - if successful. *
|
LPTSTR szFile,
|
||||||
* FALSE - otherwise *
|
HANDLE hdib )
|
||||||
* *
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static BOOL WriteDIB(LPTSTR szFile, HANDLE hdib)
|
|
||||||
{
|
{
|
||||||
BITMAPFILEHEADER hdr;
|
BITMAPFILEHEADER hdr;
|
||||||
LPBITMAPINFOHEADER lpbi;
|
LPBITMAPINFOHEADER lpbi;
|
||||||
@@ -108,7 +96,6 @@ static BOOL WriteDIB(LPTSTR szFile, HANDLE hdib)
|
|||||||
|
|
||||||
if (!hdib)
|
if (!hdib)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
fh = OpenFile(wxConvertWX2MB(szFile), &of, OF_CREATE | OF_READWRITE);
|
fh = OpenFile(wxConvertWX2MB(szFile), &of, OF_CREATE | OF_READWRITE);
|
||||||
if (fh == -1)
|
if (fh == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -118,18 +105,17 @@ static BOOL WriteDIB(LPTSTR szFile, HANDLE hdib)
|
|||||||
#else
|
#else
|
||||||
lpbi = (LPBITMAPINFOHEADER) GlobalLock(hdib);
|
lpbi = (LPBITMAPINFOHEADER) GlobalLock(hdib);
|
||||||
#endif
|
#endif
|
||||||
/* Fill in the fields of the file header */
|
// Fill in the fields of the file header
|
||||||
hdr.bfType = BFT_BITMAP;
|
hdr.bfType = BFT_BITMAP;
|
||||||
hdr.bfSize = GlobalSize(hdib) + sizeof(BITMAPFILEHEADER);
|
hdr.bfSize = GlobalSize(hdib) + sizeof(BITMAPFILEHEADER);
|
||||||
hdr.bfReserved1 = 0;
|
hdr.bfReserved1 = 0;
|
||||||
hdr.bfReserved2 = 0;
|
hdr.bfReserved2 = 0;
|
||||||
hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + lpbi->biSize +
|
hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + lpbi->biSize + wxPaletteSize(lpbi);
|
||||||
wxPaletteSize(lpbi);
|
|
||||||
|
|
||||||
/* Write the file header */
|
// Write the file header
|
||||||
_lwrite(fh, (LPSTR) &hdr, sizeof(BITMAPFILEHEADER));
|
_lwrite(fh, (LPSTR) &hdr, sizeof(BITMAPFILEHEADER));
|
||||||
|
|
||||||
/* Write the DIB header and the bits */
|
//Write the DIB header and the bits
|
||||||
lwrite(fh, (LPSTR) lpbi, GlobalSize(hdib));
|
lwrite(fh, (LPSTR) lpbi, GlobalSize(hdib));
|
||||||
|
|
||||||
GlobalUnlock(hdib);
|
GlobalUnlock(hdib);
|
||||||
@@ -137,20 +123,16 @@ static BOOL WriteDIB(LPTSTR szFile, HANDLE hdib)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
// FUNCTION : wxPaletteSize(VOID FAR * pv)
|
||||||
* FUNCTION : wxPaletteSize(VOID FAR * pv) *
|
// PURPOSE : Calculates the palette size in bytes. If the info. block
|
||||||
* *
|
// is of the BITMAPCOREHEADER type, the number of colors is
|
||||||
* PURPOSE : Calculates the palette size in bytes. If the info. block *
|
// multiplied by 3 to give the palette size, otherwise the
|
||||||
* is of the BITMAPCOREHEADER type, the number of colors is *
|
// number of colors is multiplied by 4.
|
||||||
* multiplied by 3 to give the palette size, otherwise the *
|
// RETURNS : Palette size in number of bytes.
|
||||||
* number of colors is multiplied by 4. *
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
WORD wxPaletteSize(
|
||||||
* RETURNS : Palette size in number of bytes. *
|
VOID FAR * pv )
|
||||||
* *
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
WORD wxPaletteSize(VOID FAR * pv)
|
|
||||||
{
|
{
|
||||||
LPBITMAPINFOHEADER lpbi;
|
LPBITMAPINFOHEADER lpbi;
|
||||||
WORD NumColors;
|
WORD NumColors;
|
||||||
@@ -164,31 +146,26 @@ WORD wxPaletteSize(VOID FAR * pv)
|
|||||||
return (WORD)(NumColors * sizeof(RGBQUAD));
|
return (WORD)(NumColors * sizeof(RGBQUAD));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
// FUNCTION : DibNumColors(VOID FAR * pv)
|
||||||
* FUNCTION : DibNumColors(VOID FAR * pv) *
|
// PURPOSE : Determines the number of colors in the DIB by looking at
|
||||||
* *
|
// the BitCount filed in the info block.
|
||||||
* PURPOSE : Determines the number of colors in the DIB by looking at *
|
// RETURNS : The number of colors in the DIB.
|
||||||
* the BitCount filed in the info block. *
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
static WORD DibNumColors(
|
||||||
* RETURNS : The number of colors in the DIB. *
|
VOID FAR *pv )
|
||||||
* *
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static WORD DibNumColors(VOID FAR *pv)
|
|
||||||
{
|
{
|
||||||
int bits;
|
int bits;
|
||||||
BITMAPINFOHEADER *lpbi;
|
BITMAPINFOHEADER *lpbi;
|
||||||
BITMAPCOREHEADER *lpbc;
|
BITMAPCOREHEADER *lpbc;
|
||||||
|
|
||||||
lpbi = ((BITMAPINFOHEADER*) pv);
|
lpbi = ((BITMAPINFOHEADER*) pv);
|
||||||
lpbc = ((BITMAPCOREHEADER*) pv);
|
lpbc = ((BITMAPCOREHEADER*) pv);
|
||||||
|
|
||||||
/* With the BITMAPINFO format headers, the size of the palette
|
// With the BITMAPINFO format headers, the size of the palette
|
||||||
* is in biClrUsed, whereas in the BITMAPCORE - style headers, it
|
// is in biClrUsed, whereas in the BITMAPCORE - style headers, it
|
||||||
* is dependent on the bits per pixel ( = 2 raised to the power of
|
// is dependent on the bits per pixel ( = 2 raised to the power of
|
||||||
* bits/pixel).
|
// bits/pixel).
|
||||||
*/
|
|
||||||
if (lpbi->biSize != sizeof(BITMAPCOREHEADER)) {
|
if (lpbi->biSize != sizeof(BITMAPCOREHEADER)) {
|
||||||
if (lpbi->biClrUsed != 0)
|
if (lpbi->biClrUsed != 0)
|
||||||
return (WORD) lpbi->biClrUsed;
|
return (WORD) lpbi->biClrUsed;
|
||||||
@@ -205,24 +182,23 @@ static WORD DibNumColors(VOID FAR *pv)
|
|||||||
case 8:
|
case 8:
|
||||||
return 256;
|
return 256;
|
||||||
default:
|
default:
|
||||||
/* A 24 bitcount DIB has no color table */
|
// A 24 bitcount DIB has no color table
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
// FUNCTION : DibFromBitmap()
|
||||||
* FUNCTION : DibFromBitmap() *
|
// PURPOSE : Will create a global memory block in DIB format that
|
||||||
* *
|
// represents the Device-dependent bitmap (DDB) passed in.
|
||||||
* PURPOSE : Will create a global memory block in DIB format that *
|
// RETURNS : A handle to the DIB
|
||||||
* represents the Device-dependent bitmap (DDB) passed in. *
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
|
||||||
* RETURNS : A handle to the DIB *
|
|
||||||
* *
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#if NOTHING
|
#if NOTHING
|
||||||
static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal)
|
static HANDLE DibFromBitmap(
|
||||||
|
HBITMAP hbm,
|
||||||
|
DWORD biStyle,
|
||||||
|
WORD biBits,
|
||||||
|
HPALETTE hpal)
|
||||||
{
|
{
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
BITMAPINFOHEADER bi;
|
BITMAPINFOHEADER bi;
|
||||||
@@ -234,7 +210,6 @@ static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hp
|
|||||||
|
|
||||||
if (!hbm)
|
if (!hbm)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (hpal == NULL)
|
if (hpal == NULL)
|
||||||
hpal = GetStockObject(DEFAULT_PALETTE);
|
hpal = GetStockObject(DEFAULT_PALETTE);
|
||||||
|
|
||||||
@@ -277,39 +252,34 @@ static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hp
|
|||||||
|
|
||||||
*lpbi = bi;
|
*lpbi = bi;
|
||||||
|
|
||||||
/* call GetDIBits with a NULL lpBits param, so it will calculate the
|
// call GetDIBits with a NULL lpBits param, so it will calculate the
|
||||||
* biSizeImage field for us
|
// biSizeImage field for us
|
||||||
*/
|
GetDIBits(hdc, hbm, 0, (WORD) bi.biHeight, NULL, (LPBITMAPINFO) lpbi, DIB_RGB_COLORS);
|
||||||
GetDIBits(hdc, hbm, 0, (WORD) bi.biHeight,
|
|
||||||
NULL, (LPBITMAPINFO) lpbi, DIB_RGB_COLORS);
|
|
||||||
|
|
||||||
bi = *lpbi;
|
bi = *lpbi;
|
||||||
GlobalUnlock(hdib);
|
GlobalUnlock(hdib);
|
||||||
|
|
||||||
/* If the driver did not fill in the biSizeImage field, make one up */
|
// If the driver did not fill in the biSizeImage field, make one up
|
||||||
if (bi.biSizeImage == 0) {
|
if (bi.biSizeImage == 0) {
|
||||||
bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight;
|
bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight;
|
||||||
|
|
||||||
if (biStyle != BI_RGB)
|
if (biStyle != BI_RGB)
|
||||||
bi.biSizeImage = (bi.biSizeImage * 3) / 2;
|
bi.biSizeImage = (bi.biSizeImage * 3) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* realloc the buffer big enough to hold all the bits */
|
// realloc the buffer big enough to hold all the bits
|
||||||
dwLen = bi.biSize + wxPaletteSize(&bi) + bi.biSizeImage;
|
dwLen = bi.biSize + wxPaletteSize(&bi) + bi.biSizeImage;
|
||||||
if (h = GlobalReAlloc(hdib, dwLen, 0))
|
if (h = GlobalReAlloc(hdib, dwLen, 0))
|
||||||
hdib = h;
|
hdib = h;
|
||||||
else {
|
else {
|
||||||
GlobalFree(hdib);
|
GlobalFree(hdib);
|
||||||
hdib = NULL;
|
hdib = NULL;
|
||||||
|
|
||||||
SelectPalette(hdc, hpal, FALSE);
|
SelectPalette(hdc, hpal, FALSE);
|
||||||
ReleaseDC(NULL, hdc);
|
ReleaseDC(NULL, hdc);
|
||||||
return hdib;
|
return hdib;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call GetDIBits with a NON-NULL lpBits param, and actualy get the
|
// call GetDIBits with a NON-NULL lpBits param, and actualy get the
|
||||||
* bits this time
|
// bits this time
|
||||||
*/
|
|
||||||
#ifdef __WINDOWS_386__
|
#ifdef __WINDOWS_386__
|
||||||
lpbi = (BITMAPINFOHEADER FAR *) MK_FP32(GlobalLock(hdib));
|
lpbi = (BITMAPINFOHEADER FAR *) MK_FP32(GlobalLock(hdib));
|
||||||
#else
|
#else
|
||||||
@@ -331,56 +301,23 @@ static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hp
|
|||||||
|
|
||||||
bi = *lpbi;
|
bi = *lpbi;
|
||||||
GlobalUnlock(hdib);
|
GlobalUnlock(hdib);
|
||||||
|
|
||||||
SelectPalette(hdc, hpal, FALSE);
|
SelectPalette(hdc, hpal, FALSE);
|
||||||
ReleaseDC(NULL, hdc);
|
ReleaseDC(NULL, hdc);
|
||||||
return hdib;
|
return hdib;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************* PRIVATE ROUTINES TO READ/WRITE MORE THAN 64K ***************/
|
|
||||||
/****************************************************************************
|
|
||||||
* *
|
|
||||||
* FUNCTION : lread(int fh, VOID FAR *pv, DWORD ul) *
|
|
||||||
* *
|
|
||||||
* PURPOSE : Reads data in steps of 32k till all the data has been read.*
|
|
||||||
* *
|
|
||||||
* RETURNS : 0 - If read did not proceed correctly. *
|
|
||||||
* number of bytes read otherwise. *
|
|
||||||
* *
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static DWORD PASCAL lread(int fh, void far *pv, DWORD ul)
|
//************* PRIVATE ROUTINES TO WRITE MORE THAN 64K ******************
|
||||||
{
|
// ----------------------------------------------------------------------------
|
||||||
DWORD ulT = ul;
|
// FUNCTION : lwrite(int fh, VOID FAR *pv, DWORD ul)
|
||||||
#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__) || defined(__WXWINE__)
|
// PURPOSE : Writes data in steps of 32k till all the data is written.
|
||||||
BYTE *hp = (BYTE *) pv;
|
// RETURNS : 0 - If write did not proceed correctly. number of bytes written otherwise.
|
||||||
#else
|
// ----------------------------------------------------------------------------
|
||||||
BYTE huge *hp = (BYTE huge *) pv;
|
static DWORD PASCAL lwrite(
|
||||||
#endif
|
int fh,
|
||||||
while (ul > (DWORD) MAXREAD) {
|
VOID FAR *pv,
|
||||||
if (_lread(fh, (LPSTR) hp, (WORD) MAXREAD) != MAXREAD)
|
DWORD ul)
|
||||||
return 0;
|
|
||||||
ul -= MAXREAD;
|
|
||||||
hp += MAXREAD;
|
|
||||||
}
|
|
||||||
if (_lread(fh, (LPSTR) hp, (WXUINT) ul) != (WXUINT) ul)
|
|
||||||
return 0;
|
|
||||||
return ulT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* *
|
|
||||||
* FUNCTION : lwrite(int fh, VOID FAR *pv, DWORD ul) *
|
|
||||||
* *
|
|
||||||
* PURPOSE : Writes data in steps of 32k till all the data is written. *
|
|
||||||
* *
|
|
||||||
* RETURNS : 0 - If write did not proceed correctly. *
|
|
||||||
* number of bytes written otherwise. *
|
|
||||||
* *
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul)
|
|
||||||
{
|
{
|
||||||
DWORD ulT = ul;
|
DWORD ulT = ul;
|
||||||
#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__) || defined(__WXWINE__)
|
#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__) || defined(__WXWINE__)
|
||||||
@@ -399,26 +336,23 @@ static DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul)
|
|||||||
return ulT;
|
return ulT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
// ----------------------------------------------------------------------------
|
||||||
*
|
// FUNCTION : ReadDIB(hWnd)
|
||||||
* FUNCTION : ReadDIB(hWnd)
|
// PURPOSE : Reads a DIB from a file, obtains a handle to its
|
||||||
*
|
// BITMAPINFO struct. and loads the DIB. Once the DIB
|
||||||
* PURPOSE : Reads a DIB from a file, obtains a handle to its
|
// is loaded, the function also creates a bitmap and
|
||||||
* BITMAPINFO struct. and loads the DIB. Once the DIB
|
// palette out of the DIB for a device-dependent form.
|
||||||
* is loaded, the function also creates a bitmap and
|
// RETURNS : TRUE - DIB loaded and bitmap/palette created
|
||||||
* palette out of the DIB for a device-dependent form.
|
// The DIBINIT structure pointed to by pInfo is
|
||||||
*
|
// filled with the appropriate handles.
|
||||||
* RETURNS : TRUE - DIB loaded and bitmap/palette created
|
// FALSE - otherwise
|
||||||
* The DIBINIT structure pointed to by pInfo is
|
// ----------------------------------------------------------------------------
|
||||||
* filled with the appropriate handles.
|
BOOL wxReadDIB(
|
||||||
* FALSE - otherwise
|
LPTSTR lpFileName,
|
||||||
*
|
HBITMAP *bitmap,
|
||||||
****************************************************************************/
|
HPALETTE *palette)
|
||||||
BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
|
|
||||||
{
|
{
|
||||||
int fh;
|
|
||||||
LPBITMAPINFOHEADER lpbi;
|
LPBITMAPINFOHEADER lpbi;
|
||||||
OFSTRUCT of;
|
|
||||||
BITMAPFILEHEADER bf;
|
BITMAPFILEHEADER bf;
|
||||||
WORD nNumColors;
|
WORD nNumColors;
|
||||||
BOOL result = FALSE;
|
BOOL result = FALSE;
|
||||||
@@ -427,16 +361,17 @@ BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
|
|||||||
BOOL bCoreHead = FALSE;
|
BOOL bCoreHead = FALSE;
|
||||||
HANDLE hDIB = 0;
|
HANDLE hDIB = 0;
|
||||||
|
|
||||||
/* Open the file and get a handle to it's BITMAPINFO */
|
// JQ: We want to use wxFileSystem here in stead of Openfile so
|
||||||
|
// that we can use other FS types like a zip files.
|
||||||
fh = OpenFile (wxConvertWX2MB(lpFileName), &of, OF_READ);
|
wxFileSystem fsys;
|
||||||
if (fh == -1) {
|
wxFSFile *file = fsys.OpenFile(lpFileName);
|
||||||
|
wxInputStream *dibs = file->GetStream();
|
||||||
|
if (!dibs) {
|
||||||
wxLogError(_("Can't open file '%s'"), lpFileName);
|
wxLogError(_("Can't open file '%s'"), lpFileName);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
hDIB = GlobalAlloc(GHND, (DWORD)(sizeof(BITMAPINFOHEADER) +
|
hDIB = GlobalAlloc(GHND, (DWORD)(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)));
|
||||||
256 * sizeof(RGBQUAD)));
|
|
||||||
if (!hDIB)
|
if (!hDIB)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
@@ -446,18 +381,22 @@ BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
|
|||||||
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
|
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* read the BITMAPFILEHEADER */
|
// JQ: read from the wxInputStream dibs instead of fh so
|
||||||
if (sizeof (bf) != _lread (fh, (LPSTR)&bf, sizeof (bf)))
|
// that we can use other FS types like zip files.
|
||||||
|
dibs->Read((LPSTR)&bf,sizeof(bf));
|
||||||
|
if (sizeof(bf) != dibs->LastRead())
|
||||||
goto ErrExit;
|
goto ErrExit;
|
||||||
|
|
||||||
if (bf.bfType != 0x4d42) /* 'BM' */
|
if (bf.bfType != 0x4d42) // 'BM'
|
||||||
goto ErrExit;
|
goto ErrExit;
|
||||||
|
|
||||||
if (sizeof(BITMAPCOREHEADER) != _lread (fh, (LPSTR)lpbi, sizeof(BITMAPCOREHEADER)))
|
// JQ: read from the wxInputStream dibs instead of fh so
|
||||||
|
// that we can use other FS types like zip files.
|
||||||
|
dibs->Read((LPSTR)lpbi,sizeof(BITMAPCOREHEADER));
|
||||||
|
if (sizeof(BITMAPCOREHEADER) != dibs->LastRead())
|
||||||
goto ErrExit;
|
goto ErrExit;
|
||||||
|
|
||||||
if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
|
if (lpbi->biSize == sizeof(BITMAPCOREHEADER)){
|
||||||
{
|
|
||||||
lpbi->biSize = sizeof(BITMAPINFOHEADER);
|
lpbi->biSize = sizeof(BITMAPINFOHEADER);
|
||||||
lpbi->biBitCount = ((LPBITMAPCOREHEADER)lpbi)->bcBitCount;
|
lpbi->biBitCount = ((LPBITMAPCOREHEADER)lpbi)->bcBitCount;
|
||||||
lpbi->biPlanes = ((LPBITMAPCOREHEADER)lpbi)->bcPlanes;
|
lpbi->biPlanes = ((LPBITMAPCOREHEADER)lpbi)->bcPlanes;
|
||||||
@@ -465,38 +404,46 @@ BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
|
|||||||
lpbi->biWidth = ((LPBITMAPCOREHEADER)lpbi)->bcWidth;
|
lpbi->biWidth = ((LPBITMAPCOREHEADER)lpbi)->bcWidth;
|
||||||
bCoreHead = TRUE;
|
bCoreHead = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// get to the start of the header and read INFOHEADER
|
// JQ: Get to the start of the header and read INFOHEADER
|
||||||
_llseek(fh,sizeof(BITMAPFILEHEADER),SEEK_SET);
|
// using dibs wxInputStream
|
||||||
if (sizeof(BITMAPINFOHEADER) != _lread (fh, (LPSTR)lpbi, sizeof(BITMAPINFOHEADER)))
|
dibs->SeekI(sizeof(BITMAPFILEHEADER),wxFromStart);
|
||||||
|
if (dibs->LastError() != wxSTREAM_NO_ERROR)
|
||||||
goto ErrExit;
|
goto ErrExit;
|
||||||
|
|
||||||
|
// JQ: read from the wxInputStream dibs instead of fh so
|
||||||
|
// that we can use other FS types like zip files.
|
||||||
|
// Can I do error checking with this?
|
||||||
|
dibs->Read((LPSTR)lpbi,sizeof(BITMAPINFOHEADER));
|
||||||
|
if (sizeof(BITMAPINFOHEADER) != dibs->LastRead())
|
||||||
|
goto ErrExit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nNumColors = (WORD)lpbi->biClrUsed;
|
nNumColors = (WORD)lpbi->biClrUsed;
|
||||||
if ( nNumColors == 0 )
|
if ( nNumColors == 0 ) {
|
||||||
{
|
// no color table for 24-bit, default size otherwise
|
||||||
/* no color table for 24-bit, default size otherwise */
|
|
||||||
if (lpbi->biBitCount != 24)
|
if (lpbi->biBitCount != 24)
|
||||||
nNumColors = 1 << lpbi->biBitCount; /* standard size table */
|
nNumColors = 1 << lpbi->biBitCount; // standard size table
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fill in some default values if they are zero */
|
// fill in some default values if they are zero
|
||||||
if (lpbi->biClrUsed == 0)
|
if (lpbi->biClrUsed == 0)
|
||||||
lpbi->biClrUsed = nNumColors;
|
lpbi->biClrUsed = nNumColors;
|
||||||
|
|
||||||
if (lpbi->biSizeImage == 0)
|
if (lpbi->biSizeImage == 0){
|
||||||
{
|
|
||||||
lpbi->biSizeImage = ((((lpbi->biWidth * (DWORD)lpbi->biBitCount) + 31) & ~31) >> 3)
|
lpbi->biSizeImage = ((((lpbi->biWidth * (DWORD)lpbi->biBitCount) + 31) & ~31) >> 3)
|
||||||
* lpbi->biHeight;
|
* lpbi->biHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get a proper-sized buffer for header, color table and bits */
|
// get a proper-sized buffer for header, color table and bits
|
||||||
GlobalUnlock(hDIB);
|
GlobalUnlock(hDIB);
|
||||||
hDIB = GlobalReAlloc(hDIB, lpbi->biSize +
|
hDIB = GlobalReAlloc(hDIB, lpbi->biSize + nNumColors * sizeof(RGBQUAD) +
|
||||||
nNumColors * sizeof(RGBQUAD) +
|
|
||||||
lpbi->biSizeImage, 0);
|
lpbi->biSizeImage, 0);
|
||||||
if (!hDIB) /* can't resize buffer for loading */
|
|
||||||
|
// can't resize buffer for loading
|
||||||
|
if (!hDIB)
|
||||||
goto ErrExit2;
|
goto ErrExit2;
|
||||||
|
|
||||||
#ifdef __WINDOWS_386__
|
#ifdef __WINDOWS_386__
|
||||||
@@ -505,21 +452,17 @@ BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
|
|||||||
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
|
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* read the color table */
|
// read the color table
|
||||||
if (!bCoreHead)
|
if (!bCoreHead)
|
||||||
_lread(fh, (LPSTR)(lpbi) + lpbi->biSize, nNumColors * sizeof(RGBQUAD));
|
dibs->Read((LPSTR)lpbi + lpbi->biSize, nNumColors * sizeof(RGBQUAD));
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
signed int i;
|
signed int i;
|
||||||
RGBQUAD FAR *pQuad;
|
RGBQUAD FAR *pQuad;
|
||||||
RGBTRIPLE FAR *pTriple;
|
RGBTRIPLE FAR *pTriple;
|
||||||
|
dibs->Read((LPSTR)lpbi + lpbi->biSize, nNumColors * sizeof(RGBTRIPLE));
|
||||||
_lread(fh, (LPSTR)(lpbi) + lpbi->biSize, nNumColors * sizeof(RGBTRIPLE));
|
|
||||||
|
|
||||||
pQuad = (RGBQUAD FAR *)((LPSTR)lpbi + lpbi->biSize);
|
pQuad = (RGBQUAD FAR *)((LPSTR)lpbi + lpbi->biSize);
|
||||||
pTriple = (RGBTRIPLE FAR *) pQuad;
|
pTriple = (RGBTRIPLE FAR *) pQuad;
|
||||||
for (i = nNumColors - 1; i >= 0; i--)
|
for (i = nNumColors - 1; i >= 0; i--){
|
||||||
{
|
|
||||||
pQuad[i].rgbRed = pTriple[i].rgbtRed;
|
pQuad[i].rgbRed = pTriple[i].rgbtRed;
|
||||||
pQuad[i].rgbBlue = pTriple[i].rgbtBlue;
|
pQuad[i].rgbBlue = pTriple[i].rgbtBlue;
|
||||||
pQuad[i].rgbGreen = pTriple[i].rgbtGreen;
|
pQuad[i].rgbGreen = pTriple[i].rgbtGreen;
|
||||||
@@ -527,21 +470,18 @@ BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* offset to the bits from start of DIB header */
|
// offset to the bits from start of DIB header
|
||||||
offBits = (WORD)(lpbi->biSize + nNumColors * sizeof(RGBQUAD));
|
offBits = (WORD)(lpbi->biSize + nNumColors * sizeof(RGBQUAD));
|
||||||
|
|
||||||
if (bf.bfOffBits != 0L)
|
if (bf.bfOffBits != 0L)
|
||||||
{
|
dibs->SeekI(bf.bfOffBits, wxFromStart);
|
||||||
_llseek(fh,bf.bfOffBits,SEEK_SET);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lpbi->biSizeImage == lread(fh, (LPSTR)lpbi + offBits, lpbi->biSizeImage))
|
dibs->Read((LPSTR)lpbi + offBits,lpbi->biSizeImage);
|
||||||
|
if (lpbi->biSizeImage == dibs->LastRead())
|
||||||
{
|
{
|
||||||
GlobalUnlock(hDIB);
|
GlobalUnlock(hDIB);
|
||||||
|
|
||||||
hDC = GetDC(NULL);
|
hDC = GetDC(NULL);
|
||||||
if (!MakeBitmapAndPalette(hDC, hDIB, palette,
|
if (!MakeBitmapAndPalette(hDC, hDIB, palette, bitmap))
|
||||||
bitmap))
|
|
||||||
{
|
{
|
||||||
ReleaseDC(NULL,hDC);
|
ReleaseDC(NULL,hDC);
|
||||||
goto ErrExit2;
|
goto ErrExit2;
|
||||||
@@ -560,28 +500,23 @@ ErrExit:
|
|||||||
ErrExit2:
|
ErrExit2:
|
||||||
GlobalFree(hDIB);
|
GlobalFree(hDIB);
|
||||||
}
|
}
|
||||||
|
|
||||||
_lclose(fh);
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
// ----------------------------------------------------------------------------
|
||||||
*
|
// FUNCTION : MakeBitmapAndPalette
|
||||||
* FUNCTION : MakeBitmapAndPalette
|
// PURPOSE : Given a DIB, creates a bitmap and corresponding palette
|
||||||
*
|
// to be used for a device-dependent representation of
|
||||||
* PURPOSE : Given a DIB, creates a bitmap and corresponding palette
|
// of the image.
|
||||||
* to be used for a device-dependent representation of
|
// RETURNS : TRUE --> success. phPal and phBitmap are filled with
|
||||||
* of the image.
|
// appropriate handles. Caller is responsible for freeing objects.
|
||||||
*
|
// FALSE --> unable to create objects. both pointer are not valid
|
||||||
* RETURNS : TRUE --> success. phPal and phBitmap are filled with
|
// ----------------------------------------------------------------------------
|
||||||
* appropriate handles. Caller is responsible
|
static BOOL PASCAL MakeBitmapAndPalette(
|
||||||
* for freeing objects.
|
HDC hDC,
|
||||||
* FALSE --> unable to create objects. both pointer are
|
HANDLE hDIB,
|
||||||
* not valid
|
HPALETTE * phPal,
|
||||||
*
|
HBITMAP * phBitmap)
|
||||||
****************************************************************************/
|
|
||||||
static BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB,
|
|
||||||
HPALETTE * phPal, HBITMAP * phBitmap)
|
|
||||||
{
|
{
|
||||||
LPBITMAPINFOHEADER lpInfo;
|
LPBITMAPINFOHEADER lpInfo;
|
||||||
BOOL result = FALSE;
|
BOOL result = FALSE;
|
||||||
@@ -621,23 +556,18 @@ static BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlobalUnlock (hDIB); // glt
|
GlobalUnlock (hDIB); // glt
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
// FUNCTION : wxMakeDIBPalette(lpInfo)
|
||||||
* FUNCTION : wxMakeDIBPalette(lpInfo) *
|
// PURPOSE : Given a BITMAPINFOHEADER, create a palette based on
|
||||||
* *
|
// the color table.
|
||||||
* PURPOSE : Given a BITMAPINFOHEADER, create a palette based on
|
// RETURNS : non-zero - handle of a corresponding palette
|
||||||
* the color table.
|
// zero - unable to create palette
|
||||||
*
|
// ----------------------------------------------------------------------------
|
||||||
* *
|
HPALETTE wxMakeDIBPalette(
|
||||||
* RETURNS : non-zero - handle of a corresponding palette
|
LPBITMAPINFOHEADER lpInfo )
|
||||||
* zero - unable to create palette
|
|
||||||
* *
|
|
||||||
****************************************************************************/
|
|
||||||
HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo)
|
|
||||||
{
|
{
|
||||||
#ifdef __WXWINE__
|
#ifdef __WXWINE__
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
@@ -647,9 +577,8 @@ HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo)
|
|||||||
HPALETTE hLogPal;
|
HPALETTE hLogPal;
|
||||||
WORD i;
|
WORD i;
|
||||||
|
|
||||||
/* since biClrUsed field was filled during the loading of the DIB,
|
// since biClrUsed field was filled during the loading of the DIB,
|
||||||
** we know it contains the number of colors in the color table.
|
// we know it contains the number of colors in the color table.
|
||||||
*/
|
|
||||||
if (lpInfo->biClrUsed)
|
if (lpInfo->biClrUsed)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -664,10 +593,10 @@ HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo)
|
|||||||
npPal->palVersion = 0x300;
|
npPal->palVersion = 0x300;
|
||||||
npPal->palNumEntries = (WORD)lpInfo->biClrUsed;
|
npPal->palNumEntries = (WORD)lpInfo->biClrUsed;
|
||||||
|
|
||||||
/* get pointer to the color table */
|
// get pointer to the color table
|
||||||
lpRGB = (RGBQUAD FAR *)((LPSTR)lpInfo + lpInfo->biSize);
|
lpRGB = (RGBQUAD FAR *)((LPSTR)lpInfo + lpInfo->biSize);
|
||||||
|
|
||||||
/* copy colors from the color table to the LogPalette structure */
|
// copy colors from the color table to the LogPalette structure
|
||||||
for (i = 0; (DWORD)i < lpInfo->biClrUsed; i++, lpRGB++)
|
for (i = 0; (DWORD)i < lpInfo->biClrUsed; i++, lpRGB++)
|
||||||
{
|
{
|
||||||
npPal->palPalEntry[i].peRed = lpRGB->rgbRed;
|
npPal->palPalEntry[i].peRed = lpRGB->rgbRed;
|
||||||
@@ -679,27 +608,31 @@ HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo)
|
|||||||
hLogPal = CreatePalette((LPLOGPALETTE)npPal);
|
hLogPal = CreatePalette((LPLOGPALETTE)npPal);
|
||||||
// LocalFree((HANDLE)npPal);
|
// LocalFree((HANDLE)npPal);
|
||||||
free(npPal);
|
free(npPal);
|
||||||
|
|
||||||
return(hLogPal);
|
return(hLogPal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 24-bit DIB with no color table. return default palette. Another
|
// 24-bit DIB with no color table. return default palette. Another
|
||||||
** option would be to create a 256 color "rainbow" palette to provide
|
// option would be to create a 256 color "rainbow" palette to provide
|
||||||
** some good color choices.
|
// some good color choices.
|
||||||
*/
|
|
||||||
else
|
else
|
||||||
return((HPALETTE) GetStockObject(DEFAULT_PALETTE));
|
return((HPALETTE) GetStockObject(DEFAULT_PALETTE));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxLoadIntoBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette **pal)
|
// ----------------------------------------------------------------------------
|
||||||
|
// FUNCTION :
|
||||||
|
// PURPOSE :
|
||||||
|
// RETURNS :
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
bool wxLoadIntoBitmap(
|
||||||
|
wxChar *filename,
|
||||||
|
wxBitmap *bitmap,
|
||||||
|
wxPalette **pal)
|
||||||
{
|
{
|
||||||
HBITMAP hBitmap;
|
HBITMAP hBitmap;
|
||||||
HPALETTE hPalette;
|
HPALETTE hPalette;
|
||||||
|
|
||||||
bool success = (wxReadDIB(filename, &hBitmap, &hPalette) != 0);
|
bool success = (wxReadDIB(filename, &hBitmap, &hPalette) != 0);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
DeleteObject(hPalette);
|
DeleteObject(hPalette);
|
||||||
@@ -736,7 +669,14 @@ bool wxLoadIntoBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette **pal)
|
|||||||
else return FALSE;
|
else return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap *wxLoadBitmap(wxChar *filename, wxPalette **pal)
|
// ----------------------------------------------------------------------------
|
||||||
|
// FUNCTION :
|
||||||
|
// PURPOSE :
|
||||||
|
// RETURNS :
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
wxBitmap *wxLoadBitmap(
|
||||||
|
wxChar *filename,
|
||||||
|
wxPalette **pal)
|
||||||
{
|
{
|
||||||
wxBitmap *bitmap = new wxBitmap;
|
wxBitmap *bitmap = new wxBitmap;
|
||||||
if (wxLoadIntoBitmap(filename, bitmap, pal))
|
if (wxLoadIntoBitmap(filename, bitmap, pal))
|
||||||
@@ -749,12 +689,9 @@ wxBitmap *wxLoadBitmap(wxChar *filename, wxPalette **pal)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
//
|
// FUNCTION : InitBitmapInfoHeader
|
||||||
// Function: InitBitmapInfoHeader
|
// PURPOSE : Does a "standard" initialization of a BITMAPINFOHEADER,
|
||||||
//
|
// given the Width, Height, and Bits per Pixel for the DIB.
|
||||||
// Purpose: Does a "standard" initialization of a BITMAPINFOHEADER,
|
|
||||||
// given the Width, Height, and Bits per Pixel for the
|
|
||||||
// DIB.
|
|
||||||
//
|
//
|
||||||
// By standard, I mean that all the relevant fields are set
|
// By standard, I mean that all the relevant fields are set
|
||||||
// to the specified values. biSizeImage is computed, the
|
// to the specified values. biSizeImage is computed, the
|
||||||
@@ -766,7 +703,7 @@ wxBitmap *wxLoadBitmap(wxChar *filename, wxPalette **pal)
|
|||||||
// used (whichever is most appropriate for the specified
|
// used (whichever is most appropriate for the specified
|
||||||
// nBPP).
|
// nBPP).
|
||||||
//
|
//
|
||||||
// Parms: lpBmInfoHdr == Far pointer to a BITMAPINFOHEADER structure
|
// PARMS : lpBmInfoHdr == Far pointer to a BITMAPINFOHEADER structure
|
||||||
// to be filled in.
|
// to be filled in.
|
||||||
// dwWidth == Width of DIB (not in Win 3.0 & 3.1, high
|
// dwWidth == Width of DIB (not in Win 3.0 & 3.1, high
|
||||||
// word MUST be 0).
|
// word MUST be 0).
|
||||||
@@ -778,8 +715,8 @@ wxBitmap *wxLoadBitmap(wxChar *filename, wxPalette **pal)
|
|||||||
// 11/07/91 Created
|
// 11/07/91 Created
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
static void InitBitmapInfoHeader (
|
||||||
static void InitBitmapInfoHeader (LPBITMAPINFOHEADER lpBmInfoHdr,
|
LPBITMAPINFOHEADER lpBmInfoHdr,
|
||||||
DWORD dwWidth,
|
DWORD dwWidth,
|
||||||
DWORD dwHeight,
|
DWORD dwHeight,
|
||||||
int nBPP )
|
int nBPP )
|
||||||
@@ -809,16 +746,17 @@ static void InitBitmapInfoHeader (LPBITMAPINFOHEADER lpBmInfoHdr,
|
|||||||
lpBmInfoHdr->biSizeImage = WIDTHBYTES (dwWidth * nBPP) * dwHeight;
|
lpBmInfoHdr->biSizeImage = WIDTHBYTES (dwWidth * nBPP) * dwHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// FUNCTION :
|
||||||
|
// PURPOSE :
|
||||||
|
// RETURNS :
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
LPSTR wxFindDIBBits (LPSTR lpbi)
|
LPSTR wxFindDIBBits (LPSTR lpbi)
|
||||||
{
|
{
|
||||||
return (lpbi + *(LPDWORD)lpbi + wxPaletteSize (lpbi));
|
return (lpbi + *(LPDWORD)lpbi + wxPaletteSize (lpbi));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
//
|
|
||||||
// Function: BitmapToDIB
|
// Function: BitmapToDIB
|
||||||
//
|
//
|
||||||
// Purpose: Given a device dependent bitmap and a palette, returns
|
// Purpose: Given a device dependent bitmap and a palette, returns
|
||||||
@@ -836,8 +774,9 @@ LPSTR wxFindDIBBits (LPSTR lpbi)
|
|||||||
// 6/01/91 Created
|
// 6/01/91 Created
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
HANDLE wxBitmapToDIB (
|
||||||
HANDLE wxBitmapToDIB (HBITMAP hBitmap, HPALETTE hPal)
|
HBITMAP hBitmap,
|
||||||
|
HPALETTE hPal)
|
||||||
{
|
{
|
||||||
BITMAP Bitmap;
|
BITMAP Bitmap;
|
||||||
BITMAPINFOHEADER bmInfoHdr;
|
BITMAPINFOHEADER bmInfoHdr;
|
||||||
@@ -881,10 +820,8 @@ HANDLE wxBitmapToDIB (HBITMAP hBitmap, HPALETTE hPal)
|
|||||||
*lpbmInfoHdr = bmInfoHdr;
|
*lpbmInfoHdr = bmInfoHdr;
|
||||||
lpBits = wxFindDIBBits ((LPSTR) lpbmInfoHdr);
|
lpBits = wxFindDIBBits ((LPSTR) lpbmInfoHdr);
|
||||||
|
|
||||||
|
|
||||||
// Now, we need a DC to hold our bitmap. If the app passed us
|
// Now, we need a DC to hold our bitmap. If the app passed us
|
||||||
// a palette, it should be selected into the DC.
|
// a palette, it should be selected into the DC.
|
||||||
|
|
||||||
hMemDC = GetDC (NULL);
|
hMemDC = GetDC (NULL);
|
||||||
|
|
||||||
if (hPal)
|
if (hPal)
|
||||||
@@ -893,12 +830,9 @@ HANDLE wxBitmapToDIB (HBITMAP hBitmap, HPALETTE hPal)
|
|||||||
RealizePalette (hMemDC);
|
RealizePalette (hMemDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// We're finally ready to get the DIB. Call the driver and let
|
// We're finally ready to get the DIB. Call the driver and let
|
||||||
// it party on our bitmap. It will fill in the color table,
|
// it party on our bitmap. It will fill in the color table,
|
||||||
// and bitmap bits of our global memory block.
|
// and bitmap bits of our global memory block.
|
||||||
|
|
||||||
if (!GetDIBits (hMemDC,
|
if (!GetDIBits (hMemDC,
|
||||||
hBitmap,
|
hBitmap,
|
||||||
0,
|
0,
|
||||||
@@ -914,18 +848,23 @@ HANDLE wxBitmapToDIB (HBITMAP hBitmap, HPALETTE hPal)
|
|||||||
else
|
else
|
||||||
GlobalUnlock (hDIB);
|
GlobalUnlock (hDIB);
|
||||||
|
|
||||||
|
|
||||||
// Finally, clean up and return.
|
// Finally, clean up and return.
|
||||||
|
|
||||||
if (hOldPal)
|
if (hOldPal)
|
||||||
SelectPalette (hMemDC, hOldPal, FALSE);
|
SelectPalette (hMemDC, hOldPal, FALSE);
|
||||||
|
|
||||||
ReleaseDC (NULL, hMemDC);
|
ReleaseDC (NULL, hMemDC);
|
||||||
|
|
||||||
return hDIB;
|
return hDIB;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap)
|
// ----------------------------------------------------------------------------
|
||||||
|
// FUNCTION :
|
||||||
|
// PURPOSE :
|
||||||
|
// RETURNS :
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
bool wxSaveBitmap(
|
||||||
|
wxChar *filename,
|
||||||
|
wxBitmap *bitmap,
|
||||||
|
wxPalette *colourmap)
|
||||||
{
|
{
|
||||||
HPALETTE hPalette = 0;
|
HPALETTE hPalette = 0;
|
||||||
if (colourmap)
|
if (colourmap)
|
||||||
|
Reference in New Issue
Block a user