* Copyright (C) 1991-2001 SciTech Software, Inc.
* All rights reserved.
*
-* ======================================================================
-* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
-* | |
-* |This copyrighted computer code is a proprietary trade secret of |
-* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
-* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
-* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
-* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
-* |written authorization from SciTech to possess or use this code, you |
-* |may be subject to civil and/or criminal penalties. |
-* | |
-* |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|
-* ======================================================================
+* ========================================================================
+*
+* 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
DECLARE_EVENT_TABLE();
protected:
- wxHtmlAppletWindow *m_parent;
+ //wxHtmlAppletWindow *m_parent;
// Special handler for background erase messages
void OnEraseBackground(wxEraseEvent&);
--- /dev/null
+/****************************************************************************
+*
+* 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
+
--- /dev/null
+/****************************************************************************
+*
+* 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
+
--- /dev/null
+/****************************************************************************
+*
+* 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
--- /dev/null
+/****************************************************************************
+*
+* 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
+
--- /dev/null
+/****************************************************************************
+*
+* 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
+
--- /dev/null
+/****************************************************************************
+*
+* 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
+
* Copyright (C) 1991-2001 SciTech Software, Inc.
* All rights reserved.
*
-* ======================================================================
-* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
-* | |
-* |This copyrighted computer code is a proprietary trade secret of |
-* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
-* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
-* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
-* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
-* |written authorization from SciTech to possess or use this code, you |
-* |may be subject to civil and/or criminal penalties. |
-* | |
-* |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|
-* ======================================================================
+* ========================================================================
+*
+* 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
DECLARE_CLASS(wxHtmlAppletWindow);
DECLARE_EVENT_TABLE();
+ bool m_mutexLock;
wxIncludePrep *incPreprocessor; // deleted by list it is added too in constructor
protected:
wxAppletList m_AppletList;
// Event handlers to load a new page
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
*
* 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
-* may not use this file except in compliance with the License. You may
-* obtain a copy of the License at http://www.wxwindows.org/licence.htm
+* 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.
*
-* 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++
menuFile->Append(Minimal_Quit, "E&xit");
menuNav->Append(Minimal_Back, "Go &back");
menuNav->Append(Minimal_Forward, "Go &forward");
-
+
// Now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, "&File");
menuBar->Append(menuNav, "&Navigate");
-
+
// ... and attach this menu bar to the frame
SetMenuBar(menuBar);
CreateStatusBar(2);
- // Create the HTML window
+ // Create the HTML window
html = new wxHtmlAppletWindow(this);
html->SetRelatedFrame(this, "wxApplet Demo: '%s'");
html->SetRelatedStatusBar(1);
*
* 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
-* may not use this file except in compliance with the License. You may
-* obtain a copy of the License at http://www.wxwindows.org/licence.htm
+* 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.
*
-* 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++
Minimal_About,
Minimal_Back,
Minimal_Forward,
-
+
// Controls start here (the numbers are, of course, arbitrary)
Minimal_Text = 1000,
};
*
* 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
-* may not use this file except in compliance with the License. You may
-* obtain a copy of the License at http://www.wxwindows.org/licence.htm
+* 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.
*
-* 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++
m_ListBox->Select(n);
m_TextCtrl->SetValue(GetStringSelection());
}
-
+
void ComboBox::Deselect(int n)
{
m_ListBox->Deselect(n);
void ComboBox::Insert(const wxString& item, int pos)
{
m_ListBox->Insert(item,pos);
-}
+}
void ComboBox::Insert(const wxString& item, int pos, void *clientData)
{
m_ListBox->SetFirstItem(n);
m_TextCtrl->SetValue(GetStringSelection());
}
-
+
void ComboBox::SetFirstItem(const wxString &s)
{
m_ListBox->SetFirstItem(s);
m_TextCtrl->SetValue(GetStringSelection());
}
-
+
void ComboBox::Append(const wxString &item)
{
m_ListBox->Append(item);
m_TextCtrl->SetValue(GetStringSelection());
}
-void ComboBox::Clear()
+void ComboBox::Clear()
{
m_ListBox->Clear();
m_TextCtrl->SetValue(GetStringSelection());
}
-
+
void ComboBox::Delete(int n)
{
m_ListBox->Delete(n);
*
* 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
-* may not use this file except in compliance with the License. You may
-* obtain a copy of the License at http://www.wxwindows.org/licence.htm
+* 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.
*
-* 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++
public:
// Constructor
ComboBox(wxWindow *parent, int,int);
-
+
// Returns the id of the listbox: listBoxId.
int GetListBoxId();
-
+
// Inserts: Used to insert items into the listbox
void Insert(const wxString& item, int pos);
void Insert(const wxString& item, int pos, void *clientData);
void Insert(const wxString& item, int pos, wxClientData *clientData);
void InsertItems(int nItems, const wxString *items, int pos);
void InsertItems(const wxArrayString& items, int pos);
-
+
// Sets: Used to set items in the combo box
void Set(int n, const wxString* items, void **clientData );
void Set(const wxArrayString& items, void **clientData);
int FindString(const wxString &s);
-
+
// Selections: Used to get/de/select items in the listbox
void Select(int n);
void Deselect(int n);
- int GetSelection();
+ int GetSelection();
wxString GetStringSelection();
bool SetStringSelection(const wxString& s, bool select);
-
+
// Set the specified item at the first visible item or scroll to max
// range.
void SetFirstItem(int n);
void SetFirstItem(const wxString& s);
-
+
// Append items to the listbox
void Append(const wxString& item);
void Append(const wxString& item, void *clientData);
void Append(const wxString& item, wxClientData *clientData);
-
+
// Deleting items from the list box
- void Clear();
+ void Clear();
void Delete(int n);
-
+
// OnChange event function (called from SDD dialog box code, see: dialog.h) Mimic
- // msw combobox behavior: Click on listbox item it shows in textbox.
+ // msw combobox behavior: Click on listbox item it shows in textbox.
void OnChange(wxCommandEvent &event);
};
* Copyright (C) 1991-2001 SciTech Software, Inc.
* All rights reserved.
*
-* ======================================================================
-* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
-* | |
-* |This copyrighted computer code is a proprietary trade secret of |
-* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
-* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
-* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
-* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
-* |written authorization from SciTech to possess or use this code, you |
-* |may be subject to civil and/or criminal penalties. |
-* | |
-* |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|
-* ======================================================================
+* ========================================================================
+*
+* 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
// Implement the dynamic class so it can be constructed dynamically
IMPLEMENT_DYNAMIC_CLASS(MonitorApplet, wxApplet);
-
+
// Event handler table.
BEGIN_EVENT_TABLE(MonitorApplet, wxApplet)
EVT_LISTBOX(ID_LISTBOX_MFTR, MonitorApplet::OnChange)
// Include database of known monitors. Normally this would come from a
// real database on disk, but for this simple example we hard code all
// the values into a table.
-#include "monitors.c"
-
+#include "monitors.c"
+
/*------------------------- Implementation --------------------------------*/
/****************************************************************************
via the virtual Create member function.
****************************************************************************/
MonitorApplet::MonitorApplet()
-{
+{
m_Mfr = NULL;
m_Model = NULL;
m_Data = NULL;
memset(&m_Data->m_Monitor,0,sizeof(m_Data->m_Monitor));
parent->RegisterCookie(MONITOR_COOKIE_NAME,m_Data);
}
-
+
// Create all the controls and initialise them
MonitorDialogFunc(this,true,true);
if ((m_Mfr = new ComboBox(this , ID_LISTBOX_MFTR, ID_TEXTCTRL_MFTR)) == NULL)
}
return ret;
}
-
+
/****************************************************************************
REMARKS:
Destructor for the MonitorApplet class.
Handles user navigation away from the applet via an HTML link
****************************************************************************/
void MonitorApplet::OnLinkClicked(
- const wxHtmlLinkInfo&)
+ const wxHtmlLinkInfo&)
{
SaveCurrentState();
}
-
+
/****************************************************************************
REMARKS:
Handles user navigation away from the applet via the history forward command
{
SaveCurrentState();
}
-
+
/****************************************************************************
REMARKS:
Handles user navigation away from the applet via the history back command
{
SaveCurrentState();
}
-
+
/****************************************************************************
REMARKS:
Handles inter applet communication messages
****************************************************************************/
-void MonitorApplet::OnMessage(
+void MonitorApplet::OnMessage(
wxEvent& msg)
{
msg.Skip(true);
ReadModelList(true);
}
else if (evt.GetId() == m_Model->GetListBoxId()) {
- m_Model->OnChange(evt);
+ m_Model->OnChange(evt);
}
}
Updates the manufacturer list for the dialog box from the database.
****************************************************************************/
void MonitorApplet::ReadMfrList()
-{
+{
char buf[80] = "";
int i,selected = 0;
MonitorEntry *m;
****************************************************************************/
void MonitorApplet::ReadModelList(
bool selectCurrent)
-{
+{
int i,selected = 0;
MonitorEntry *m;
wxString mfrStr;
-
+
mfrStr = m_Mfr->GetStringSelection();
m_Model->Clear();
for (m = m_Monitors,i = 0; m->m_Mfr[0] != 0; m++) {
/****************************************************************************
*
+* wxWindows HTML Applet Package
+*
* Copyright (C) 1991-2001 SciTech Software, Inc.
* All rights reserved.
*
-* ======================================================================
-* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
-* | |
-* |This copyrighted computer code is a proprietary trade secret of |
-* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
-* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
-* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
-* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
-* |written authorization from SciTech to possess or use this code, you |
-* |may be subject to civil and/or criminal penalties. |
-* | |
-* |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|
-* ======================================================================
+* ========================================================================
+*
+* 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
MonitorEntry m_Monitor;
};
-// Name used to track the monitor data cookie
-#define MONITOR_COOKIE_NAME "MonitorData"
-
+// Name used to track the monitor data cookie
+#define MONITOR_COOKIE_NAME "MonitorData"
+
/****************************************************************************
REMARKS:
Defines our wxMonitor applet class
private:
DECLARE_DYNAMIC_CLASS(MonitorApplet);
DECLARE_EVENT_TABLE();
-
+
protected:
- ComboBox *m_Mfr;
+ ComboBox *m_Mfr;
ComboBox *m_Model;
- MonitorData *m_Data;
+ MonitorData *m_Data;
static MonitorEntry m_Monitors[];
-
+
// Flush the current state to a cookie
void SaveCurrentState();
-
+
public:
// Constructor (called during dynamic creation)
MonitorApplet();
wxHtmlAppletWindow *parent,
const wxSize& size,
long style);
-
+
// Virtual destructor
virtual ~MonitorApplet();
// Handle HTML navigation to a new URL
- virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
-
+ virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
+
// Handle HTML navigation forward command in applet
virtual void OnHistoryForward();
-
+
// Handle HTML navigation back command in applet
virtual void OnHistoryBack();
-
+
// Handle messages from the wxAppletManager and other applets
virtual void OnMessage(wxEvent& msg);
void ReadMfrList();
void ReadModelList(bool selectCurrent);
- // Event handlers
+ // Event handlers
void OnChange(wxCommandEvent &event);
};
-
+
#endif // __WX_MONITORAPPLET_H
* Copyright (C) 1991-2001 SciTech Software, Inc.
* All rights reserved.
*
-* ======================================================================
-* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
-* | |
-* |This copyrighted computer code is a proprietary trade secret of |
-* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
-* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
-* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
-* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
-* |written authorization from SciTech to possess or use this code, you |
-* |may be subject to civil and/or criminal penalties. |
-* | |
-* |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|
-* ======================================================================
+* ========================================================================
+*
+* 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
****************************************************************************/
wxApplet::~wxApplet()
{
- m_parent->RemoveApplet(this);
+ ((wxHtmlAppletWindow *) m_parent)->RemoveApplet(this);
}
/****************************************************************************
* Copyright (C) 1991-2001 SciTech Software, Inc.
* All rights reserved.
*
-* ======================================================================
-* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
-* | |
-* |This copyrighted computer code is a proprietary trade secret of |
-* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
-* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
-* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
-* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
-* |written authorization from SciTech to possess or use this code, you |
-* |may be subject to civil and/or criminal penalties. |
-* | |
-* |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|
-* ======================================================================
+* ========================================================================
+*
+* 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
const wxString& name)
: wxHtmlWindow(parent,id,pos,size,style,name)
{
- //setup client navbars
+ // Init our locks
+ UnLock();
+
+ // setup client navbars
if (navBar) {
m_NavBar = navBar;
m_NavBackId = navBackId;
m_NavBar = NULL;
}
- //Add HTML preprocessors
+ // Add HTML preprocessors
// deleting preprocessors is done by the code within the window
incPreprocessor = new wxIncludePrep(); // #include preprocessor
this->AddProcessor(incPreprocessor);
this->AddProcessor(echoPreprocessor);
this->AddProcessor(ifPreprocessor);
-
-
}
/****************************************************************************
}
}
- // Grab the directory from the string for use in the include preprocessor
- // make sure we get either type of / or \.
- int ch = link.Find('\\', true);
- if (ch == -1) ch = link.Find('/', true);
- if (ch != -1) {
- wxFileSystem fs;
- wxString tmp = link.Mid(0, ch+1);
- fs.ChangePathTo(incPreprocessor->GetDirectory(), true);
- fs.ChangePathTo(tmp, true);
- incPreprocessor->ChangeDirectory(fs.GetPath());
- }
+ // Make a copy of the current path the translate for <!-- include files from what will be the new path
+ // we cannot just grab this value from the base class since it is not correct until after LoadPage is
+ // called. And we need the incPreprocessor to know the right path before LoadPage.
+ wxFileSystem fs;
+ fs.ChangePathTo(m_FS->GetPath(), true);
+ fs.ChangePathTo(link);
+ incPreprocessor->ChangeDirectory(fs.GetPath());
// Inform all the applets that the new page is being loaded
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
(node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href));
bool stat = wxHtmlWindow::LoadPage(href);
+
+
// Enable/Dis the navbar tools
if (m_NavBar) {
m_NavBar->EnableTool(m_NavForwardId,HistoryCanForward());
void wxHtmlAppletWindow::OnLoadPage(
wxLoadPageEvent &event)
{
- if (event.GetHtmlWindow() == this){
- if (LoadPage(event.GetHRef())){
- wxPageLoadedEvent evt;
+ // 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 (LoadPage(event.GetHRef())){
+ // wxPageLoadedEvent evt;
+ // NOTE: This is reserved for later use as we might need to send
+ // page loaded events to applets.
+ }
}
+ UnLock();
}
}
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:
name - name of the last applet that changed the data in this object
--- /dev/null
+/****************************************************************************
+*
+* 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)
--- /dev/null
+/****************************************************************************
+*
+* 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)
--- /dev/null
+/****************************************************************************
+*
+* 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)
+
--- /dev/null
+/****************************************************************************
+*
+* 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)
+
--- /dev/null
+/****************************************************************************
+*
+* 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)
--- /dev/null
+/****************************************************************************
+*
+* 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;
+}
+
#include "wx/log.h"
#include "wx/app.h"
#include "wx/filefn.h"
+#include "wx/filesys.h"
#include "wx/wfstream.h"
#include "wx/intl.h"
#include "wx/module.h"
bool wxImage::LoadFile( const wxString& filename, long type )
{
#if wxUSE_STREAMS
- if (wxFileExists(filename))
- {
- wxFileInputStream stream(filename);
- wxBufferedInputStream bstream( stream );
- return LoadFile(bstream, type);
- }
- else
- {
- wxLogError( _("Can't load image from file '%s': file does not exist."), filename.c_str() );
-
+ // We want to use wxFileSystem for virtual FS compatibility
+ wxFileSystem fsys;
+ wxFSFile *file = fsys.OpenFile(filename);
+ if (!file) {
+ wxLogError(_("Can't open file '%s'"), filename);
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
return FALSE;
#endif // wxUSE_STREAMS
bool wxImage::LoadFile( const wxString& filename, const wxString& mimetype )
{
#if wxUSE_STREAMS
- if (wxFileExists(filename))
- {
- wxFileInputStream stream(filename);
- wxBufferedInputStream bstream( stream );
- return LoadFile(bstream, mimetype);
- }
- else
- {
- wxLogError( _("Can't load image from file '%s': file does not exist."), filename.c_str() );
-
+ // We want to use wxFileSystem for virtual FS compatibility
+ wxFileSystem fsys;
+ wxFSFile *file = fsys.OpenFile(filename);
+ if (!file) {
+ wxLogError(_("Can't open file '%s'"), filename);
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
return FALSE;
#endif // wxUSE_STREAMS
-/*******************************************************************************
- * *
- * MODULE : DIB.CC *
- * *
- * DESCRIPTION : Routines for dealing with Device Independent Bitmaps. *
- * *
- * FUNCTIONS : *
- * *
- * wxReadDIB() - Reads a DIB *
- * *
- * WriteDIB() - Writes a global handle in CF_DIB format*
- * to a file. *
- * *
- * wxPaletteSize() - Calculates the palette size in bytes *
- * of given DIB *
- * *
- * DibNumColors() - Determines the number of colors in DIB *
- * *
- * 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 *
- * *
- *******************************************************************************/
+/////////////////////////////////////////////////////////////////////////////
+// Name: dib.cpp
+// Purpose: Routines for dealing with Device Independent Bitmaps.
+// Author:
+// Modified by: Jason Quijano 06/06/2001
+// Created: 01/02/97
+// RCS-ID: $Id$
+// Copyright: (c) Julian Smart
+/////////////////////////////////////////////////////////////////////////////
+// FUNCTIONS :
+// wxReadDIB() - Reads a DIB
+// WriteDIB() - Writes a global handle in CF_DIB format to a file.
+// wxPaletteSize() - Calculates the palette size in bytes of given DIB *
+// DibNumColors() - Determines the number of colors in DIB
+// 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".
#include "wx/wxprec.h"
#endif
#include "wx/msw/dib.h"
+#include "wx/filesys.h"
#ifdef __GNUWIN32_OLD__
#include "wx/msw/gnuwin32/extra.h"
#endif
#ifndef SEEK_CUR
-/* flags for _lseek */
+// flags for _lseek
#define SEEK_CUR 1
#define SEEK_END 2
#define SEEK_SET 0
#endif
-#define MAXREAD 32768 /* Number of bytes to be read during */
- /* each read operation. */
+// Number of bytes to be read during each read operation.
+#define MAXREAD 32768
-/* Header signatutes for various resources */
-#define BFT_ICON 0x4349 /* 'IC' */
-#define BFT_BITMAP 0x4d42 /* 'BM' */
-#define BFT_CURSOR 0x5450 /* 'PT(' */
+// Header signatutes for various resources
+#define BFT_ICON 0x4349 // 'IC'
+#define BFT_BITMAP 0x4d42 // 'BM'
+#define BFT_CURSOR 0x5450 // 'PT('
-/* macro to determine if resource is a DIB */
-#define ISDIB(bft) ((bft) == BFT_BITMAP)
+// macro to determine if resource is a DIB
+#define ISDIB(bft) ((bft) == BFT_BITMAP)
-/* Macro to align given value to the closest DWORD (unsigned long ) */
-#define ALIGNULONG(i) ((i+3)/4*4)
+// Macro to align given value to the closest DWORD (unsigned long )
+#define ALIGNULONG(i) ((i+3)/4*4)
-/* Macro to determine to round off the given value to the closest byte */
-#define WIDTHBYTES(i) ((i+31)/32*4)
+// Macro to determine to round off the given value to the closest byte
+#define WIDTHBYTES(i) ((i+31)/32*4)
-#define PALVERSION 0x300
-#define MAXPALETTE 256 /* max. # supported palette entries */
+#define PALVERSION 0x300
+#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 BOOL WriteDIB (LPTSTR szFile,HANDLE hdib);
-WORD wxPaletteSize (VOID FAR * pv); // This is non-static as some apps use it externally
-static WORD DibNumColors (VOID FAR * pv);
-// HANDLE DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal);
+static BOOL WriteDIB (LPTSTR szFile,HANDLE hdib);
+WORD wxPaletteSize (VOID FAR * pv); // This is non-static as some apps use it externally
+static WORD DibNumColors (VOID FAR * pv);
+// HANDLE DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal);
static BOOL PASCAL MakeBitmapAndPalette(HDC,HANDLE,HPALETTE *,HBITMAP *);
-/****************************************************************************
- * *
- * FUNCTION : WriteDIB(LPSTR szFile,HANDLE hdib) *
- * *
- * PURPOSE : Write a global handle in CF_DIB format to a file. *
- * *
- * RETURNS : TRUE - if successful. *
- * FALSE - otherwise *
- * *
- ****************************************************************************/
-
-static BOOL WriteDIB(LPTSTR 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
+// ----------------------------------------------------------------------------
+static BOOL WriteDIB(
+ LPTSTR szFile,
+ HANDLE hdib )
{
- BITMAPFILEHEADER hdr;
- LPBITMAPINFOHEADER lpbi;
- int fh;
- OFSTRUCT of;
-
- if (!hdib)
- return FALSE;
+ BITMAPFILEHEADER hdr;
+ LPBITMAPINFOHEADER lpbi;
+ int fh;
+ OFSTRUCT of;
- fh = OpenFile(wxConvertWX2MB(szFile), &of, OF_CREATE | OF_READWRITE);
- if (fh == -1)
- return FALSE;
+ if (!hdib)
+ return FALSE;
+ fh = OpenFile(wxConvertWX2MB(szFile), &of, OF_CREATE | OF_READWRITE);
+ if (fh == -1)
+ return FALSE;
#ifdef __WINDOWS_386__
- lpbi = (LPBITMAPINFOHEADER) MK_FP32(GlobalLock(hdib));
+ lpbi = (LPBITMAPINFOHEADER) MK_FP32(GlobalLock(hdib));
#else
- lpbi = (LPBITMAPINFOHEADER) GlobalLock(hdib);
+ lpbi = (LPBITMAPINFOHEADER) GlobalLock(hdib);
#endif
- /* Fill in the fields of the file header */
- hdr.bfType = BFT_BITMAP;
- hdr.bfSize = GlobalSize(hdib) + sizeof(BITMAPFILEHEADER);
- hdr.bfReserved1 = 0;
- hdr.bfReserved2 = 0;
- hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + lpbi->biSize +
- wxPaletteSize(lpbi);
+ // Fill in the fields of the file header
+ hdr.bfType = BFT_BITMAP;
+ hdr.bfSize = GlobalSize(hdib) + sizeof(BITMAPFILEHEADER);
+ hdr.bfReserved1 = 0;
+ hdr.bfReserved2 = 0;
+ hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + lpbi->biSize + wxPaletteSize(lpbi);
- /* Write the file header */
- _lwrite(fh, (LPSTR) &hdr, sizeof(BITMAPFILEHEADER));
+ // Write the file header
+ _lwrite(fh, (LPSTR) &hdr, sizeof(BITMAPFILEHEADER));
- /* Write the DIB header and the bits */
- lwrite(fh, (LPSTR) lpbi, GlobalSize(hdib));
+ //Write the DIB header and the bits
+ lwrite(fh, (LPSTR) lpbi, GlobalSize(hdib));
- GlobalUnlock(hdib);
- _lclose(fh);
- return TRUE;
+ GlobalUnlock(hdib);
+ _lclose(fh);
+ return TRUE;
}
-/****************************************************************************
- * *
- * 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 *
- * multiplied by 3 to give the palette size, otherwise the *
- * number of colors is multiplied by 4. *
- * *
- * RETURNS : Palette size in number of bytes. *
- * *
- ****************************************************************************/
-
-WORD 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
+// multiplied by 3 to give the palette size, otherwise the
+// number of colors is multiplied by 4.
+// RETURNS : Palette size in number of bytes.
+// ----------------------------------------------------------------------------
+WORD wxPaletteSize(
+ VOID FAR * pv )
{
- LPBITMAPINFOHEADER lpbi;
- WORD NumColors;
+ LPBITMAPINFOHEADER lpbi;
+ WORD NumColors;
- lpbi = (LPBITMAPINFOHEADER) pv;
- NumColors = DibNumColors(lpbi);
+ lpbi = (LPBITMAPINFOHEADER) pv;
+ NumColors = DibNumColors(lpbi);
- if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
- return (WORD)(NumColors * sizeof(RGBTRIPLE));
- else
- return (WORD)(NumColors * sizeof(RGBQUAD));
+ if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
+ return (WORD)(NumColors * sizeof(RGBTRIPLE));
+ else
+ return (WORD)(NumColors * sizeof(RGBQUAD));
}
-/****************************************************************************
- * *
- * FUNCTION : DibNumColors(VOID FAR * pv) *
- * *
- * PURPOSE : Determines the number of colors in the DIB by looking at *
- * the BitCount filed in the info block. *
- * *
- * RETURNS : The number of colors in the DIB. *
- * *
- ****************************************************************************/
-
-static WORD 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.
+// RETURNS : The number of colors in the DIB.
+// ----------------------------------------------------------------------------
+static WORD DibNumColors(
+ VOID FAR *pv )
{
- int bits;
- BITMAPINFOHEADER *lpbi;
- BITMAPCOREHEADER *lpbc;
-
- lpbi = ((BITMAPINFOHEADER*) pv);
- lpbc = ((BITMAPCOREHEADER*) pv);
-
- /* With the BITMAPINFO format headers, the size of the palette
- * is in biClrUsed, whereas in the BITMAPCORE - style headers, it
- * is dependent on the bits per pixel ( = 2 raised to the power of
- * bits/pixel).
- */
- if (lpbi->biSize != sizeof(BITMAPCOREHEADER)) {
- if (lpbi->biClrUsed != 0)
- return (WORD) lpbi->biClrUsed;
- bits = lpbi->biBitCount;
- }
- else
- bits = lpbc->bcBitCount;
-
- switch (bits) {
- case 1:
- return 2;
- case 4:
- return 16;
- case 8:
- return 256;
- default:
- /* A 24 bitcount DIB has no color table */
- return 0;
- }
+ int bits;
+ BITMAPINFOHEADER *lpbi;
+ BITMAPCOREHEADER *lpbc;
+ lpbi = ((BITMAPINFOHEADER*) pv);
+ lpbc = ((BITMAPCOREHEADER*) pv);
+
+ // With the BITMAPINFO format headers, the size of the palette
+ // is in biClrUsed, whereas in the BITMAPCORE - style headers, it
+ // is dependent on the bits per pixel ( = 2 raised to the power of
+ // bits/pixel).
+
+ if (lpbi->biSize != sizeof(BITMAPCOREHEADER)) {
+ if (lpbi->biClrUsed != 0)
+ return (WORD) lpbi->biClrUsed;
+ bits = lpbi->biBitCount;
+ }
+ else
+ bits = lpbc->bcBitCount;
+
+ switch (bits) {
+ case 1:
+ return 2;
+ case 4:
+ return 16;
+ case 8:
+ return 256;
+ default:
+ // A 24 bitcount DIB has no color table
+ return 0;
+ }
}
-/****************************************************************************
- * *
- * FUNCTION : DibFromBitmap() *
- * *
- * PURPOSE : Will create a global memory block in DIB format that *
- * represents the Device-dependent bitmap (DDB) passed in. *
- * *
- * RETURNS : A handle to the DIB *
- * *
- ****************************************************************************/
-
+// ----------------------------------------------------------------------------
+// FUNCTION : DibFromBitmap()
+// PURPOSE : Will create a global memory block in DIB format that
+// represents the Device-dependent bitmap (DDB) passed in.
+// RETURNS : A handle to the DIB
+// ----------------------------------------------------------------------------
#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;
- BITMAPINFOHEADER bi;
- BITMAPINFOHEADER FAR *lpbi;
- DWORD dwLen;
- HANDLE hdib;
- HANDLE h;
- HDC hdc;
-
- if (!hbm)
- return NULL;
-
- if (hpal == NULL)
- hpal = GetStockObject(DEFAULT_PALETTE);
-
- GetObject(hbm, sizeof (bm), (LPSTR) &bm);
-
- if (biBits == 0)
- biBits = bm.bmPlanes * bm.bmBitsPixel;
-
- bi.biSize = sizeof(BITMAPINFOHEADER);
- bi.biWidth = bm.bmWidth;
- bi.biHeight = bm.bmHeight;
- bi.biPlanes = 1;
- bi.biBitCount = biBits;
- bi.biCompression = biStyle;
- bi.biSizeImage = 0;
- bi.biXPelsPerMeter = 0;
- bi.biYPelsPerMeter = 0;
- bi.biClrUsed = 0;
- bi.biClrImportant = 0;
-
- dwLen = bi.biSize + wxPaletteSize(&bi);
-
- hdc = GetDC((HWND) NULL);
- hpal = SelectPalette(hdc, hpal, FALSE);
- RealizePalette(hdc);
-
- hdib = GlobalAlloc(GHND, dwLen);
-
- if (!hdib) {
- SelectPalette(hdc, hpal, FALSE);
- ReleaseDC(NULL, hdc);
- return NULL;
- }
+ BITMAP bm;
+ BITMAPINFOHEADER bi;
+ BITMAPINFOHEADER FAR *lpbi;
+ DWORD dwLen;
+ HANDLE hdib;
+ HANDLE h;
+ HDC hdc;
+
+ if (!hbm)
+ return NULL;
+ if (hpal == NULL)
+ hpal = GetStockObject(DEFAULT_PALETTE);
+
+ GetObject(hbm, sizeof (bm), (LPSTR) &bm);
+
+ if (biBits == 0)
+ biBits = bm.bmPlanes * bm.bmBitsPixel;
+
+ bi.biSize = sizeof(BITMAPINFOHEADER);
+ bi.biWidth = bm.bmWidth;
+ bi.biHeight = bm.bmHeight;
+ bi.biPlanes = 1;
+ bi.biBitCount = biBits;
+ bi.biCompression = biStyle;
+ bi.biSizeImage = 0;
+ bi.biXPelsPerMeter = 0;
+ bi.biYPelsPerMeter = 0;
+ bi.biClrUsed = 0;
+ bi.biClrImportant = 0;
+
+ dwLen = bi.biSize + wxPaletteSize(&bi);
+
+ hdc = GetDC((HWND) NULL);
+ hpal = SelectPalette(hdc, hpal, FALSE);
+ RealizePalette(hdc);
+
+ hdib = GlobalAlloc(GHND, dwLen);
+
+ if (!hdib) {
+ SelectPalette(hdc, hpal, FALSE);
+ ReleaseDC(NULL, hdc);
+ return NULL;
+ }
#ifdef __WINDOWS_386__
- lpbi = (BITMAPINFOHEADER FAR *) MK_FP32(GlobalLock(hdib));
+ lpbi = (BITMAPINFOHEADER FAR *) MK_FP32(GlobalLock(hdib));
#else
- lpbi = (BITMAPINFOHEADER FAR *) GlobalLock(hdib);
+ lpbi = (BITMAPINFOHEADER FAR *) GlobalLock(hdib);
#endif
- *lpbi = bi;
+ *lpbi = bi;
- /* call GetDIBits with a NULL lpBits param, so it will calculate the
- * biSizeImage field for us
- */
- GetDIBits(hdc, hbm, 0, (WORD) bi.biHeight,
- NULL, (LPBITMAPINFO) lpbi, DIB_RGB_COLORS);
+ // call GetDIBits with a NULL lpBits param, so it will calculate the
+ // biSizeImage field for us
+ GetDIBits(hdc, hbm, 0, (WORD) bi.biHeight, NULL, (LPBITMAPINFO) lpbi, DIB_RGB_COLORS);
+ bi = *lpbi;
+ GlobalUnlock(hdib);
- bi = *lpbi;
- GlobalUnlock(hdib);
+ // If the driver did not fill in the biSizeImage field, make one up
+ if (bi.biSizeImage == 0) {
+ bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight;
+ if (biStyle != BI_RGB)
+ bi.biSizeImage = (bi.biSizeImage * 3) / 2;
+ }
+
+ // realloc the buffer big enough to hold all the bits
+ dwLen = bi.biSize + wxPaletteSize(&bi) + bi.biSizeImage;
+ if (h = GlobalReAlloc(hdib, dwLen, 0))
+ hdib = h;
+ else {
+ GlobalFree(hdib);
+ hdib = NULL;
+ SelectPalette(hdc, hpal, FALSE);
+ ReleaseDC(NULL, hdc);
+ return hdib;
+ }
+
+ // call GetDIBits with a NON-NULL lpBits param, and actualy get the
+ // bits this time
- /* If the driver did not fill in the biSizeImage field, make one up */
- if (bi.biSizeImage == 0) {
- bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight;
-
- if (biStyle != BI_RGB)
- bi.biSizeImage = (bi.biSizeImage * 3) / 2;
- }
-
- /* realloc the buffer big enough to hold all the bits */
- dwLen = bi.biSize + wxPaletteSize(&bi) + bi.biSizeImage;
- if (h = GlobalReAlloc(hdib, dwLen, 0))
- hdib = h;
- else {
- GlobalFree(hdib);
- hdib = NULL;
-
- SelectPalette(hdc, hpal, FALSE);
- ReleaseDC(NULL, hdc);
- return hdib;
- }
-
- /* call GetDIBits with a NON-NULL lpBits param, and actualy get the
- * bits this time
- */
#ifdef __WINDOWS_386__
lpbi = (BITMAPINFOHEADER FAR *) MK_FP32(GlobalLock(hdib));
#else
lpbi = (BITMAPINFOHEADER FAR *) GlobalLock(hdib);
#endif
- if (GetDIBits(hdc,
- hbm,
- 0,
- (WORD) bi.biHeight,
- (LPSTR) lpbi + (WORD) lpbi->biSize + wxPaletteSize(lpbi),
- (LPBITMAPINFO) lpbi, DIB_RGB_COLORS) == 0) {
- GlobalUnlock(hdib);
- hdib = NULL;
- SelectPalette(hdc, hpal, FALSE);
- ReleaseDC((HWND) NULL, hdc);
- return NULL;
- }
+ if (GetDIBits(hdc,
+ hbm,
+ 0,
+ (WORD) bi.biHeight,
+ (LPSTR) lpbi + (WORD) lpbi->biSize + wxPaletteSize(lpbi),
+ (LPBITMAPINFO) lpbi, DIB_RGB_COLORS) == 0) {
+ GlobalUnlock(hdib);
+ hdib = NULL;
+ SelectPalette(hdc, hpal, FALSE);
+ ReleaseDC((HWND) NULL, hdc);
+ return NULL;
+ }
bi = *lpbi;
GlobalUnlock(hdib);
-
SelectPalette(hdc, hpal, FALSE);
ReleaseDC(NULL, hdc);
return hdib;
}
#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)
-{
- DWORD ulT = ul;
-#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__) || defined(__WXWINE__)
- BYTE *hp = (BYTE *) pv;
-#else
- BYTE huge *hp = (BYTE huge *) pv;
-#endif
- while (ul > (DWORD) MAXREAD) {
- if (_lread(fh, (LPSTR) hp, (WORD) MAXREAD) != MAXREAD)
- 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)
+//************* PRIVATE ROUTINES TO WRITE MORE THAN 64K ******************
+// ----------------------------------------------------------------------------
+// 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__)
- BYTE *hp = (BYTE *) pv;
+ BYTE *hp = (BYTE *) pv;
#else
- BYTE huge *hp = (BYTE huge *) pv;
+ BYTE huge *hp = (BYTE huge *) pv;
#endif
- while (ul > MAXREAD) {
- if (_lwrite(fh, (LPSTR) hp, (WORD) MAXREAD) != MAXREAD)
- return 0;
- ul -= MAXREAD;
- hp += MAXREAD;
- }
- if (_lwrite(fh, (LPSTR) hp, (WXUINT) ul) != (WXUINT) ul)
- return 0;
- return ulT;
+ while (ul > MAXREAD) {
+ if (_lwrite(fh, (LPSTR) hp, (WORD) MAXREAD) != MAXREAD)
+ return 0;
+ ul -= MAXREAD;
+ hp += MAXREAD;
+ }
+ if (_lwrite(fh, (LPSTR) hp, (WXUINT) ul) != (WXUINT) ul)
+ return 0;
+ return ulT;
}
-/****************************************************************************
- *
- * FUNCTION : ReadDIB(hWnd)
- *
- * PURPOSE : Reads a DIB from a file, obtains a handle to its
- * BITMAPINFO struct. and loads the DIB. Once the DIB
- * is loaded, the function also creates a bitmap and
- * palette out of the DIB for a device-dependent form.
- *
- * RETURNS : TRUE - DIB loaded and bitmap/palette created
- * The DIBINIT structure pointed to by pInfo is
- * filled with the appropriate handles.
- * FALSE - otherwise
- *
- ****************************************************************************/
-BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
+// ----------------------------------------------------------------------------
+// FUNCTION : ReadDIB(hWnd)
+// PURPOSE : Reads a DIB from a file, obtains a handle to its
+// BITMAPINFO struct. and loads the DIB. Once the DIB
+// is loaded, the function also creates a bitmap and
+// palette out of the DIB for a device-dependent form.
+// RETURNS : TRUE - DIB loaded and bitmap/palette created
+// The DIBINIT structure pointed to by pInfo is
+// filled with the appropriate handles.
+// FALSE - otherwise
+// ----------------------------------------------------------------------------
+BOOL wxReadDIB(
+ LPTSTR lpFileName,
+ HBITMAP *bitmap,
+ HPALETTE *palette)
{
- int fh;
LPBITMAPINFOHEADER lpbi;
- OFSTRUCT of;
- BITMAPFILEHEADER bf;
- WORD nNumColors;
+ BITMAPFILEHEADER bf;
+ WORD nNumColors;
BOOL result = FALSE;
WORD offBits;
HDC hDC;
BOOL bCoreHead = FALSE;
HANDLE hDIB = 0;
- /* Open the file and get a handle to it's BITMAPINFO */
-
- fh = OpenFile (wxConvertWX2MB(lpFileName), &of, OF_READ);
- if (fh == -1) {
+ // JQ: We want to use wxFileSystem here in stead of Openfile so
+ // that we can use other FS types like a zip files.
+ wxFileSystem fsys;
+ wxFSFile *file = fsys.OpenFile(lpFileName);
+ wxInputStream *dibs = file->GetStream();
+ if (!dibs) {
wxLogError(_("Can't open file '%s'"), lpFileName);
return (0);
- }
+ }
- hDIB = GlobalAlloc(GHND, (DWORD)(sizeof(BITMAPINFOHEADER) +
- 256 * sizeof(RGBQUAD)));
+ hDIB = GlobalAlloc(GHND, (DWORD)(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)));
if (!hDIB)
return(0);
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
#endif
- /* read the BITMAPFILEHEADER */
- if (sizeof (bf) != _lread (fh, (LPSTR)&bf, sizeof (bf)))
+ // JQ: read from the wxInputStream dibs instead of fh so
+ // that we can use other FS types like zip files.
+ dibs->Read((LPSTR)&bf,sizeof(bf));
+ if (sizeof(bf) != dibs->LastRead())
goto ErrExit;
- if (bf.bfType != 0x4d42) /* 'BM' */
+ if (bf.bfType != 0x4d42) // 'BM'
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;
- if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
- {
+ if (lpbi->biSize == sizeof(BITMAPCOREHEADER)){
lpbi->biSize = sizeof(BITMAPINFOHEADER);
lpbi->biBitCount = ((LPBITMAPCOREHEADER)lpbi)->bcBitCount;
lpbi->biPlanes = ((LPBITMAPCOREHEADER)lpbi)->bcPlanes;
lpbi->biHeight = ((LPBITMAPCOREHEADER)lpbi)->bcHeight;
lpbi->biWidth = ((LPBITMAPCOREHEADER)lpbi)->bcWidth;
bCoreHead = TRUE;
- }
- else
- {
- // get to the start of the header and read INFOHEADER
- _llseek(fh,sizeof(BITMAPFILEHEADER),SEEK_SET);
- if (sizeof(BITMAPINFOHEADER) != _lread (fh, (LPSTR)lpbi, sizeof(BITMAPINFOHEADER)))
+ }
+ else {
+
+ // JQ: Get to the start of the header and read INFOHEADER
+ // using dibs wxInputStream
+ dibs->SeekI(sizeof(BITMAPFILEHEADER),wxFromStart);
+ if (dibs->LastError() != wxSTREAM_NO_ERROR)
+ 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;
- if ( nNumColors == 0 )
- {
- /* no color table for 24-bit, default size otherwise */
+ if ( nNumColors == 0 ) {
+ // no color table for 24-bit, default size otherwise
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)
lpbi->biClrUsed = nNumColors;
- if (lpbi->biSizeImage == 0)
- {
+ if (lpbi->biSizeImage == 0){
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);
- hDIB = GlobalReAlloc(hDIB, lpbi->biSize +
- nNumColors * sizeof(RGBQUAD) +
- lpbi->biSizeImage, 0);
- if (!hDIB) /* can't resize buffer for loading */
+ hDIB = GlobalReAlloc(hDIB, lpbi->biSize + nNumColors * sizeof(RGBQUAD) +
+ lpbi->biSizeImage, 0);
+
+ // can't resize buffer for loading
+ if (!hDIB)
goto ErrExit2;
#ifdef __WINDOWS_386__
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
#endif
- /* read the color table */
+ // read the color table
if (!bCoreHead)
- _lread(fh, (LPSTR)(lpbi) + lpbi->biSize, nNumColors * sizeof(RGBQUAD));
- else
- {
+ dibs->Read((LPSTR)lpbi + lpbi->biSize, nNumColors * sizeof(RGBQUAD));
+ else {
signed int i;
RGBQUAD FAR *pQuad;
RGBTRIPLE FAR *pTriple;
-
- _lread(fh, (LPSTR)(lpbi) + lpbi->biSize, nNumColors * sizeof(RGBTRIPLE));
-
+ dibs->Read((LPSTR)lpbi + lpbi->biSize, nNumColors * sizeof(RGBTRIPLE));
pQuad = (RGBQUAD FAR *)((LPSTR)lpbi + lpbi->biSize);
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].rgbBlue = pTriple[i].rgbtBlue;
pQuad[i].rgbGreen = pTriple[i].rgbtGreen;
pQuad[i].rgbReserved = 0;
+ }
}
- }
- /* 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));
if (bf.bfOffBits != 0L)
- {
- _llseek(fh,bf.bfOffBits,SEEK_SET);
- }
+ dibs->SeekI(bf.bfOffBits, wxFromStart);
- if (lpbi->biSizeImage == lread(fh, (LPSTR)lpbi + offBits, lpbi->biSizeImage))
+ dibs->Read((LPSTR)lpbi + offBits,lpbi->biSizeImage);
+ if (lpbi->biSizeImage == dibs->LastRead())
{
GlobalUnlock(hDIB);
-
hDC = GetDC(NULL);
- if (!MakeBitmapAndPalette(hDC, hDIB, palette,
- bitmap))
+ if (!MakeBitmapAndPalette(hDC, hDIB, palette, bitmap))
{
ReleaseDC(NULL,hDC);
goto ErrExit2;
ErrExit2:
GlobalFree(hDIB);
}
-
- _lclose(fh);
return(result);
}
-/****************************************************************************
- *
- * FUNCTION : MakeBitmapAndPalette
- *
- * PURPOSE : Given a DIB, creates a bitmap and corresponding palette
- * to be used for a device-dependent representation of
- * of the image.
- *
- * RETURNS : TRUE --> success. phPal and phBitmap are filled with
- * appropriate handles. Caller is responsible
- * for freeing objects.
- * FALSE --> unable to create objects. both pointer are
- * not valid
- *
- ****************************************************************************/
-static BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB,
- HPALETTE * phPal, HBITMAP * phBitmap)
+// ----------------------------------------------------------------------------
+// FUNCTION : MakeBitmapAndPalette
+// PURPOSE : Given a DIB, creates a bitmap and corresponding palette
+// to be used for a device-dependent representation of
+// of the image.
+// RETURNS : TRUE --> success. phPal and phBitmap are filled with
+// appropriate handles. Caller is responsible for freeing objects.
+// FALSE --> unable to create objects. both pointer are not valid
+// ----------------------------------------------------------------------------
+static BOOL PASCAL MakeBitmapAndPalette(
+ HDC hDC,
+ HANDLE hDIB,
+ HPALETTE * phPal,
+ HBITMAP * phBitmap)
{
LPBITMAPINFOHEADER lpInfo;
BOOL result = FALSE;
}
GlobalUnlock (hDIB); // glt
-
return(result);
}
-/****************************************************************************
- * *
- * FUNCTION : wxMakeDIBPalette(lpInfo) *
- * *
- * PURPOSE : Given a BITMAPINFOHEADER, create a palette based on
- * the color table.
- *
- * *
- * RETURNS : non-zero - handle of a corresponding palette
- * zero - unable to create palette
- * *
- ****************************************************************************/
-HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo)
+// ----------------------------------------------------------------------------
+// FUNCTION : wxMakeDIBPalette(lpInfo)
+// PURPOSE : Given a BITMAPINFOHEADER, create a palette based on
+// the color table.
+// RETURNS : non-zero - handle of a corresponding palette
+// zero - unable to create palette
+// ----------------------------------------------------------------------------
+HPALETTE wxMakeDIBPalette(
+ LPBITMAPINFOHEADER lpInfo )
{
#ifdef __WXWINE__
- return (FALSE);
+ return (FALSE);
#else
LPLOGPALETTE npPal;
RGBQUAD far *lpRGB;
HPALETTE hLogPal;
WORD i;
- /* since biClrUsed field was filled during the loading of the DIB,
- ** we know it contains the number of colors in the color table.
- */
+ // since biClrUsed field was filled during the loading of the DIB,
+ // we know it contains the number of colors in the color table.
if (lpInfo->biClrUsed)
{
/*
npPal->palVersion = 0x300;
npPal->palNumEntries = (WORD)lpInfo->biClrUsed;
- /* get pointer to the color table */
+ // get pointer to the color table
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++)
{
npPal->palPalEntry[i].peRed = lpRGB->rgbRed;
hLogPal = CreatePalette((LPLOGPALETTE)npPal);
// LocalFree((HANDLE)npPal);
free(npPal);
-
return(hLogPal);
}
- /* 24-bit DIB with no color table. return default palette. Another
- ** option would be to create a 256 color "rainbow" palette to provide
- ** some good color choices.
- */
+ // 24-bit DIB with no color table. return default palette. Another
+ // option would be to create a 256 color "rainbow" palette to provide
+ // some good color choices.
else
return((HPALETTE) GetStockObject(DEFAULT_PALETTE));
#endif
-
}
-bool wxLoadIntoBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette **pal)
+// ----------------------------------------------------------------------------
+// FUNCTION :
+// PURPOSE :
+// RETURNS :
+// ----------------------------------------------------------------------------
+bool wxLoadIntoBitmap(
+ wxChar *filename,
+ wxBitmap *bitmap,
+ wxPalette **pal)
{
- HBITMAP hBitmap;
- HPALETTE hPalette;
-
- bool success = (wxReadDIB(filename, &hBitmap, &hPalette) != 0);
+ HBITMAP hBitmap;
+ HPALETTE hPalette;
- if (!success)
- {
- DeleteObject(hPalette);
- return FALSE;
- }
+ bool success = (wxReadDIB(filename, &hBitmap, &hPalette) != 0);
+ if (!success)
+ {
+ DeleteObject(hPalette);
+ return FALSE;
+ }
- if (hPalette)
- {
- if (pal)
+ if (hPalette)
{
- *pal = new wxPalette;
- (*pal)->SetHPALETTE((WXHPALETTE) hPalette);
+ if (pal)
+ {
+ *pal = new wxPalette;
+ (*pal)->SetHPALETTE((WXHPALETTE) hPalette);
+ }
+ else
+ DeleteObject(hPalette);
}
- else
- DeleteObject(hPalette);
- }
- else if (pal)
- *pal = NULL;
+ else if (pal)
+ *pal = NULL;
- if (hBitmap)
- {
- BITMAP bm;
- GetObject(hBitmap, sizeof(bm), (LPSTR)&bm);
+ if (hBitmap)
+ {
+ BITMAP bm;
+ GetObject(hBitmap, sizeof(bm), (LPSTR)&bm);
- bitmap->SetHBITMAP((WXHBITMAP) hBitmap);
- bitmap->SetWidth(bm.bmWidth);
- bitmap->SetHeight(bm.bmHeight);
- bitmap->SetDepth(bm.bmPlanes * bm.bmBitsPixel);
+ bitmap->SetHBITMAP((WXHBITMAP) hBitmap);
+ bitmap->SetWidth(bm.bmWidth);
+ bitmap->SetHeight(bm.bmHeight);
+ bitmap->SetDepth(bm.bmPlanes * bm.bmBitsPixel);
#if WXWIN_COMPATIBILITY_2
- bitmap->SetOk(TRUE);
+ bitmap->SetOk(TRUE);
#endif // WXWIN_COMPATIBILITY_2
- return TRUE;
- }
- else return FALSE;
+ return TRUE;
+ }
+ else return FALSE;
}
-wxBitmap *wxLoadBitmap(wxChar *filename, wxPalette **pal)
+// ----------------------------------------------------------------------------
+// FUNCTION :
+// PURPOSE :
+// RETURNS :
+// ----------------------------------------------------------------------------
+wxBitmap *wxLoadBitmap(
+ wxChar *filename,
+ wxPalette **pal)
{
- wxBitmap *bitmap = new wxBitmap;
- if (wxLoadIntoBitmap(filename, bitmap, pal))
- return bitmap;
- else
- {
- delete bitmap;
- return NULL;
- }
+ wxBitmap *bitmap = new wxBitmap;
+ if (wxLoadIntoBitmap(filename, bitmap, pal))
+ return bitmap;
+ else
+ {
+ delete bitmap;
+ return NULL;
+ }
}
//---------------------------------------------------------------------
+// FUNCTION : InitBitmapInfoHeader
+// PURPOSE : Does a "standard" initialization of a BITMAPINFOHEADER,
+// given the Width, Height, and Bits per Pixel for the DIB.
//
-// Function: InitBitmapInfoHeader
-//
-// 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
+// to the specified values. biSizeImage is computed, the
+// biCompression field is set to "no compression," and all
+// other fields are 0.
//
-// By standard, I mean that all the relevant fields are set
-// to the specified values. biSizeImage is computed, the
-// biCompression field is set to "no compression," and all
-// other fields are 0.
+// Note that DIBs only allow BitsPixel values of 1, 4, 8, or
+// 24. This routine makes sure that one of these values is
+// used (whichever is most appropriate for the specified
+// nBPP).
//
-// Note that DIBs only allow BitsPixel values of 1, 4, 8, or
-// 24. This routine makes sure that one of these values is
-// used (whichever is most appropriate for the specified
-// nBPP).
-//
-// Parms: lpBmInfoHdr == Far pointer to a BITMAPINFOHEADER structure
+// PARMS : lpBmInfoHdr == Far pointer to a BITMAPINFOHEADER structure
// 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).
-// dwHeight == Height of DIB (not in Win 3.0 & 3.1, high
+// dwHeight == Height of DIB (not in Win 3.0 & 3.1, high
// word MUST be 0).
-// nBPP == Bits per Pixel for the DIB.
+// nBPP == Bits per Pixel for the DIB.
//
// History: Date Reason
// 11/07/91 Created
//
//---------------------------------------------------------------------
-
-static void InitBitmapInfoHeader (LPBITMAPINFOHEADER lpBmInfoHdr,
- DWORD dwWidth,
- DWORD dwHeight,
- int nBPP)
+static void InitBitmapInfoHeader (
+ LPBITMAPINFOHEADER lpBmInfoHdr,
+ DWORD dwWidth,
+ DWORD dwHeight,
+ int nBPP )
{
// _fmemset (lpBmInfoHdr, 0, sizeof (BITMAPINFOHEADER));
memset (lpBmInfoHdr, 0, sizeof (BITMAPINFOHEADER));
lpBmInfoHdr->biSizeImage = WIDTHBYTES (dwWidth * nBPP) * dwHeight;
}
-
-
-
+// ----------------------------------------------------------------------------
+// FUNCTION :
+// PURPOSE :
+// RETURNS :
+// ----------------------------------------------------------------------------
LPSTR wxFindDIBBits (LPSTR lpbi)
{
return (lpbi + *(LPDWORD)lpbi + wxPaletteSize (lpbi));
}
//---------------------------------------------------------------------
-//
// Function: BitmapToDIB
//
// Purpose: Given a device dependent bitmap and a palette, returns
// 6/01/91 Created
//
//---------------------------------------------------------------------
-
-HANDLE wxBitmapToDIB (HBITMAP hBitmap, HPALETTE hPal)
+HANDLE wxBitmapToDIB (
+ HBITMAP hBitmap,
+ HPALETTE hPal)
{
- BITMAP Bitmap;
- BITMAPINFOHEADER bmInfoHdr;
- LPBITMAPINFOHEADER lpbmInfoHdr;
- LPSTR lpBits;
- HDC hMemDC;
- HANDLE hDIB;
- HPALETTE hOldPal = NULL;
-
- // Do some setup -- make sure the Bitmap passed in is valid,
- // get info on the bitmap (like its height, width, etc.),
- // then setup a BITMAPINFOHEADER.
+ BITMAP Bitmap;
+ BITMAPINFOHEADER bmInfoHdr;
+ LPBITMAPINFOHEADER lpbmInfoHdr;
+ LPSTR lpBits;
+ HDC hMemDC;
+ HANDLE hDIB;
+ HPALETTE hOldPal = NULL;
+
+ // Do some setup -- make sure the Bitmap passed in is valid,
+ // get info on the bitmap (like its height, width, etc.),
+ // then setup a BITMAPINFOHEADER.
if (!hBitmap)
return NULL;
Bitmap.bmPlanes * Bitmap.bmBitsPixel);
- // Now allocate memory for the DIB. Then, set the BITMAPINFOHEADER
- // into this memory, and find out where the bitmap bits go.
+ // Now allocate memory for the DIB. Then, set the BITMAPINFOHEADER
+ // into this memory, and find out where the bitmap bits go.
- hDIB = GlobalAlloc (GHND, sizeof (BITMAPINFOHEADER) +
- wxPaletteSize ((LPSTR) &bmInfoHdr) + bmInfoHdr.biSizeImage);
+ hDIB = GlobalAlloc (GHND, sizeof (BITMAPINFOHEADER) +
+ wxPaletteSize ((LPSTR) &bmInfoHdr) + bmInfoHdr.biSizeImage);
- if (!hDIB)
- return NULL;
+ if (!hDIB)
+ return NULL;
#ifdef __WINDOWS_386__
- lpbmInfoHdr = (LPBITMAPINFOHEADER) MK_FP32(GlobalLock (hDIB));
+ lpbmInfoHdr = (LPBITMAPINFOHEADER) MK_FP32(GlobalLock (hDIB));
#else
- lpbmInfoHdr = (LPBITMAPINFOHEADER) GlobalLock (hDIB);
+ lpbmInfoHdr = (LPBITMAPINFOHEADER) GlobalLock (hDIB);
#endif
- *lpbmInfoHdr = bmInfoHdr;
- lpBits = wxFindDIBBits ((LPSTR) lpbmInfoHdr);
-
-
- // Now, we need a DC to hold our bitmap. If the app passed us
- // a palette, it should be selected into the DC.
+ *lpbmInfoHdr = bmInfoHdr;
+ lpBits = wxFindDIBBits ((LPSTR) lpbmInfoHdr);
- hMemDC = GetDC (NULL);
+ // Now, we need a DC to hold our bitmap. If the app passed us
+ // a palette, it should be selected into the DC.
+ hMemDC = GetDC (NULL);
- if (hPal)
- {
- hOldPal = SelectPalette (hMemDC, hPal, FALSE);
- RealizePalette (hMemDC);
- }
-
-
-
- // 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,
- // and bitmap bits of our global memory block.
+ if (hPal)
+ {
+ hOldPal = SelectPalette (hMemDC, hPal, FALSE);
+ RealizePalette (hMemDC);
+ }
- if (!GetDIBits (hMemDC,
+ // 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,
+ // and bitmap bits of our global memory block.
+ if (!GetDIBits (hMemDC,
hBitmap,
0,
Bitmap.bmHeight,
lpBits,
(LPBITMAPINFO) lpbmInfoHdr,
DIB_RGB_COLORS))
- {
- GlobalUnlock (hDIB);
- GlobalFree (hDIB);
- hDIB = NULL;
- }
- else
- GlobalUnlock (hDIB);
-
-
- // Finally, clean up and return.
+ {
+ GlobalUnlock (hDIB);
+ GlobalFree (hDIB);
+ hDIB = NULL;
+ }
+ else
+ GlobalUnlock (hDIB);
+ // Finally, clean up and return.
if (hOldPal)
- SelectPalette (hMemDC, hOldPal, FALSE);
+ SelectPalette (hMemDC, hOldPal, FALSE);
ReleaseDC (NULL, hMemDC);
-
return hDIB;
}
-bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap)
+// ----------------------------------------------------------------------------
+// FUNCTION :
+// PURPOSE :
+// RETURNS :
+// ----------------------------------------------------------------------------
+bool wxSaveBitmap(
+ wxChar *filename,
+ wxBitmap *bitmap,
+ wxPalette *colourmap)
{
- HPALETTE hPalette = 0;
- if (colourmap)
- hPalette = (HPALETTE) colourmap->GetHPALETTE();
-
- HANDLE dibHandle = wxBitmapToDIB((HBITMAP) bitmap->GetHBITMAP(), hPalette);
- if (dibHandle)
- {
- bool success = (WriteDIB(filename, dibHandle) != 0);
- GlobalFree(dibHandle);
- return success;
- }
- else return FALSE;
+ HPALETTE hPalette = 0;
+ if (colourmap)
+ hPalette = (HPALETTE) colourmap->GetHPALETTE();
+
+ HANDLE dibHandle = wxBitmapToDIB((HBITMAP) bitmap->GetHBITMAP(), hPalette);
+ if (dibHandle)
+ {
+ bool success = (WriteDIB(filename, dibHandle) != 0);
+ GlobalFree(dibHandle);
+ return success;
+ }
+ else return FALSE;
}