_MSC_VER => __VISUALC__ change

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1580 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-02-03 16:48:12 +00:00
parent b7f4714a25
commit 3f4a0c5be3
42 changed files with 1621 additions and 1736 deletions

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c)
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DEFS_H_ #ifndef _WX_DEFS_H_
@@ -21,27 +21,54 @@
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/version.h" #include "wx/version.h"
// Helps SGI compilation, apparently // ----------------------------------------------------------------------------
#if defined(__SGI__) // compiler and OS identification
#if defined(__GNUG__) // ----------------------------------------------------------------------------
#define __need_wchar_t
#else
/* Note I use the term __SGI_CC__ for both cc and CC, its not a good idea to
* mix gcc and cc/CC, the name mangling is different */
#define __SGI_CC__
#endif
#endif
#if defined(sun) || defined(__SUN__) // OS
# if !defined(__GNUG__) #if defined(__HPUX__) || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi ) || defined(__unix__)
# ifndef __SUNCC__ #ifndef __UNIX__
# define __SUNCC__ #define __UNIX__
# endif #endif // Unix
# endif
#endif // Helps SGI compilation, apparently
#ifdef __SGI__
#ifdef __GNUG__
#define __need_wchar_t
#else // !gcc
// Note I use the term __SGI_CC__ for both cc and CC, its not a good
// idea to mix gcc and cc/CC, the name mangling is different
#define __SGI_CC__
#endif // gcc/!gcc
#endif // SGI
#if defined(sun) || defined(__SUN__)
#ifndef __GNUG__
#ifndef __SUNCC__
#define __SUNCC__
#endif // Sun CC
#endif
#endif // Sun
#else // Windows
#ifndef __WINDOWS__
#define __WINDOWS__
#endif // Windows
// define another standard symbol for Microsoft Visual C++: the standard one
// (_MSC_VER) is also defined by Metrowerks compiler
#if defined(_MSC_VER) && !defined(__MWERKS__)
#define __VISUALC__
#elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__)
#define __BORLANDC__
#elif defined(__WATCOMC__)
//#define __WATCOMC__
#elif defined(__SC__)
#define __SYMANTECC__
#endif // compiler
#endif // OS
// suppress some Visual C++ warnings // suppress some Visual C++ warnings
#ifdef _MSC_VER #ifdef __VISUALC__
# pragma warning(disable:4244) // cobversion from double to float # pragma warning(disable:4244) // cobversion from double to float
# pragma warning(disable:4100) // unreferenced formal parameter # pragma warning(disable:4100) // unreferenced formal parameter
#endif #endif
@@ -124,9 +151,9 @@
typedef unsigned int bool; typedef unsigned int bool;
#elif defined(__SALFORDC__) #elif defined(__SALFORDC__)
typedef unsigned int bool; typedef unsigned int bool;
#elif defined(_MSC_VER) && (_MSC_VER <= 1000) #elif defined(__VISUALC__) && (__VISUALC__ <= 1000)
typedef unsigned int bool; typedef unsigned int bool;
#elif defined(_MSC_VER) && (_MSC_VER == 1020) #elif defined(__VISUALC__) && (__VISUALC__ == 1020)
#define bool unsigned int #define bool unsigned int
#elif defined(__BORLANDC__) && (__BORLANDC__ < 0x500) #elif defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
typedef unsigned int bool; typedef unsigned int bool;
@@ -144,7 +171,7 @@
#endif // Sun CC #endif // Sun CC
#endif #endif
#if ( defined(_MSC_VER) && (_MSC_VER <= 800) ) || defined(__GNUWIN32__) || (defined(__BORLANDC__) && defined(__WIN16__)) || defined(__SC__) || defined(__SALFORDC__) #if ( defined(__VISUALC__) && (__VISUALC__ <= 800) ) || defined(__GNUWIN32__) || (defined(__BORLANDC__) && defined(__WIN16__)) || defined(__SC__) || defined(__SALFORDC__)
// Not a good idea, because later system files (e.g. windows.h) // Not a good idea, because later system files (e.g. windows.h)
// may try to define it. Use wxByte instead. // may try to define it. Use wxByte instead.
// #define byte unsigned char // #define byte unsigned char
@@ -281,30 +308,6 @@ enum ErrCode
WXDLLEXPORT_DATA(extern const bool) wxTrue; WXDLLEXPORT_DATA(extern const bool) wxTrue;
WXDLLEXPORT_DATA(extern const bool) wxFalse; WXDLLEXPORT_DATA(extern const bool) wxFalse;
// ----------------------------------------------------------------------------
// compiler and OS identification
// ----------------------------------------------------------------------------
// OS
#if defined(__HPUX__) || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi ) || defined(__unix__)
#ifndef __UNIX__
#define __UNIX__
#endif
#endif
#ifndef __UNIX__ // Windows
#if defined(_MSC_VER)
#define __VISUALC__
#elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__)
#define __BORLANDC__
#elif defined(__WATCOMC__)
//#define __WATCOMC__
#elif defined(__SC__)
#define __SYMANTECC__
#endif // compiler
#endif // OS
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// compiler specific settings // compiler specific settings
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -315,25 +318,18 @@ WXDLLEXPORT_DATA(extern const bool) wxFalse;
#pragma warning(disable: 4514) // unreferenced inline func has been removed #pragma warning(disable: 4514) // unreferenced inline func has been removed
/* /*
you might be tempted to disable this one also: triggered by CHECK and FAIL you might be tempted to disable this one also: triggered by CHECK and FAIL
macros in debug.h, but it's, overall, is a rather useful one, so I leave it macros in debug.h, but it's, overall, a rather useful one, so I leave it and
and will try to find some way to disable this warning just for CHECK/FAIL. will try to find some way to disable this warning just for CHECK/FAIL. Anyone?
Anyone?
*/ */
#pragma warning(disable: 4127) // conditional expression is constant #pragma warning(disable: 4127) // conditional expression is constant
#endif // VC++ #endif // VC++
#if _MSC_VER > 1010 #if defined(__MWERKS__)
#undef try #undef try
#undef except #undef except
#undef finally #undef finally
#define except(x) catch(...) #define except(x) catch(...)
#elif defined(__MWERKS__) #endif // Metrowerks
#undef try
#undef except
#undef finally
#define except(x) catch(...)
#endif
// where should i put this? we need to make sure of this as it breaks // where should i put this? we need to make sure of this as it breaks
// the <iostream> code. // the <iostream> code.
@@ -402,20 +398,20 @@ typedef void (*wxFunction) (wxObject&, wxEvent&);
/* /*
* Frame/dialog style flags * Frame/dialog style flags
*/ */
#define wxSTAY_ON_TOP 0x8000 #define wxSTAY_ON_TOP 0x8000
#define wxICONIZE 0x4000 #define wxICONIZE 0x4000
#define wxMINIMIZE wxICONIZE #define wxMINIMIZE wxICONIZE
#define wxMAXIMIZE 0x2000 #define wxMAXIMIZE 0x2000
#define wxTHICK_FRAME 0x1000 #define wxTHICK_FRAME 0x1000
#define wxSYSTEM_MENU 0x0800 #define wxSYSTEM_MENU 0x0800
#define wxMINIMIZE_BOX 0x0400 #define wxMINIMIZE_BOX 0x0400
#define wxMAXIMIZE_BOX 0x0200 #define wxMAXIMIZE_BOX 0x0200
#define wxTINY_CAPTION_HORIZ 0x0100 #define wxTINY_CAPTION_HORIZ 0x0100
#define wxTINY_CAPTION_VERT 0x0080 #define wxTINY_CAPTION_VERT 0x0080
#define wxRESIZE_BOX wxMAXIMIZE_BOX #define wxRESIZE_BOX wxMAXIMIZE_BOX
#define wxRESIZE_BORDER 0x0040 #define wxRESIZE_BORDER 0x0040
#define wxDIALOG_MODAL 0x0020 #define wxDIALOG_MODAL 0x0020
#define wxDIALOG_MODELESS 0x0000 #define wxDIALOG_MODELESS 0x0000
#define wxDEFAULT_FRAME_STYLE (wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN) #define wxDEFAULT_FRAME_STYLE (wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN)
@@ -423,7 +419,7 @@ typedef void (*wxFunction) (wxObject&, wxEvent&);
#define wxDEFAULT_FRAME wxDEFAULT_FRAME_STYLE #define wxDEFAULT_FRAME wxDEFAULT_FRAME_STYLE
#endif #endif
#define wxDEFAULT_DIALOG_STYLE (wxSYSTEM_MENU|wxCAPTION|wxTHICK_FRAME) #define wxDEFAULT_DIALOG_STYLE (wxSYSTEM_MENU|wxCAPTION|wxTHICK_FRAME)
/* /*
* Subwindow style flags * Subwindow style flags
@@ -671,7 +667,7 @@ enum {
wxCROSS_HATCH, wxCROSS_HATCH,
wxHORIZONTAL_HATCH, wxHORIZONTAL_HATCH,
wxVERTICAL_HATCH, wxVERTICAL_HATCH,
#define IS_HATCH(s) ((s)>=wxBDIAGONAL_HATCH && (s)<=wxVERTICAL_HATCH) #define IS_HATCH(s) ((s)>=wxBDIAGONAL_HATCH && (s)<=wxVERTICAL_HATCH)
wxJOIN_BEVEL = 120, wxJOIN_BEVEL = 120,
wxJOIN_MITER, wxJOIN_MITER,
@@ -684,7 +680,7 @@ enum {
// Logical ops // Logical ops
typedef enum typedef enum
{ {
wxCLEAR, // 0 wxCLEAR, // 0
wxXOR, // src XOR dst wxXOR, // src XOR dst
@@ -715,10 +711,10 @@ typedef enum
#define wxWINDING_RULE 2 #define wxWINDING_RULE 2
// ToolPanel in wxFrame // ToolPanel in wxFrame
#define wxTOOL_TOP 1 #define wxTOOL_TOP 1
#define wxTOOL_BOTTOM 2 #define wxTOOL_BOTTOM 2
#define wxTOOL_LEFT 3 #define wxTOOL_LEFT 3
#define wxTOOL_RIGHT 4 #define wxTOOL_RIGHT 4
// Dialog specifiers/return values // Dialog specifiers/return values
@@ -784,13 +780,13 @@ enum wxDataFormat
/* Virtual keycodes */ /* Virtual keycodes */
enum wxKeyCode enum wxKeyCode
{ {
WXK_BACK = 8, WXK_BACK = 8,
WXK_TAB = 9, WXK_TAB = 9,
WXK_RETURN = 13, WXK_RETURN = 13,
WXK_ESCAPE = 27, WXK_ESCAPE = 27,
WXK_SPACE = 32, WXK_SPACE = 32,
WXK_DELETE = 127, WXK_DELETE = 127,
WXK_START = 300, WXK_START = 300,
@@ -866,25 +862,25 @@ enum wxKeyCode
/* OS mnemonics -- Identify the running OS (useful for Windows) /* OS mnemonics -- Identify the running OS (useful for Windows)
* [Not all platforms are currently available or supported] */ * [Not all platforms are currently available or supported] */
enum enum
{ {
wxUNKNOWN_PLATFORM, wxUNKNOWN_PLATFORM,
wxCURSES, /* Text-only CURSES */ wxCURSES, // Text-only CURSES
wxXVIEW_X, /* Sun's XView OpenLOOK toolkit */ wxXVIEW_X, // Sun's XView OpenLOOK toolkit
wxMOTIF_X, /* OSF Motif 1.x.x */ wxMOTIF_X, // OSF Motif 1.x.x
wxCOSE_X, /* OSF Common Desktop Environment */ wxCOSE_X, // OSF Common Desktop Environment
wxNEXTSTEP, /* NeXTStep */ wxNEXTSTEP, // NeXTStep
wxMACINTOSH, /* Apple System 7 */ wxMACINTOSH, // Apple System 7
wxGTK, /* GTK */ wxGTK, // GTK
wxQT, /* Qt */ wxQT, // Qt
wxGEOS, /* GEOS */ wxGEOS, // GEOS
wxOS2_PM, /* OS/2 Workplace */ wxOS2_PM, // OS/2 Workplace
wxWINDOWS, /* Windows or WfW */ wxWINDOWS, // Windows or WfW
wxPENWINDOWS, /* Windows for Pen Computing */ wxPENWINDOWS, // Windows for Pen Computing
wxWINDOWS_NT, /* Windows NT */ wxWINDOWS_NT, // Windows NT
wxWIN32S, /* Windows 32S API */ wxWIN32S, // Windows 32S API
wxWIN95, /* Windows 95 */ wxWIN95, // Windows 95
wxWIN386 /* Watcom 32-bit supervisor modus */ wxWIN386 // Watcom 32-bit supervisor modus
}; };
/* Printing */ /* Printing */

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c)
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DOCH__ #ifndef _WX_DOCH__
@@ -44,7 +44,7 @@ class WXDLLEXPORT wxConfigBase;
#else #else
# include <istream> # include <istream>
# include <ostream> # include <ostream>
# ifdef _MSC_VER # ifdef __VISUALC__
using namespace std; using namespace std;
# endif # endif
#endif #endif

View File

@@ -29,16 +29,12 @@
typedef long off_t; typedef long off_t;
#endif #endif
#ifdef _MSC_VER #if defined(__VISUALC__) || defined(__MWERKS__)
#define off_t _off_t typedef _off_t off_t;
#endif #elif defined(__BORLANDC__) && defined(__WIN16__)
typedef long off_t;
#if defined(__BORLANDC__) && defined(__WIN16__) #elif defined(__SC__)
typedef long off_t; typedef long off_t;
#endif
#if defined(__SC__)
typedef long off_t;
#endif #endif
const off_t wxInvalidOffset = (off_t)-1; const off_t wxInvalidOffset = (off_t)-1;

20
include/wx/ioswrap.h Normal file
View File

@@ -0,0 +1,20 @@
///////////////////////////////////////////////////////////////////////////////
// Name: ioswrap.h
// Purpose: includes the correct iostream headers for current compiler
// Author: Vadim Zeitlin
// Modified by:
// Created: 03.02.99
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#if wxUSE_IOSTREAMH
// N.B. BC++ doesn't have istream.h, ostream.h
# include <iostream.h>
#else
# include <iostream>
# if defined(__VISUALC__) || defined(__MWERKS__)
using namespace std;
# endif
#endif

View File

@@ -57,13 +57,13 @@ class WXDLLEXPORT wxLogFrame;
class WXDLLEXPORT wxFrame; class WXDLLEXPORT wxFrame;
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
// N.B. BC++ doesn't have istream.h, ostream.h // N.B. BC++ doesn't have istream.h, ostream.h
# include <iostream.h> # include <iostream.h>
#else #else
# include <ostream> # include <ostream>
# ifdef _MSC_VER # if defined(__VISUALC__) || defined(__MWERKS__)
using namespace std; using namespace std;
# endif # endif
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -6,7 +6,7 @@
// Created: 29/01/98 // Created: 29/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart // Copyright: (c) 1998 Julian Smart
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MEMORYH__ #ifndef _WX_MEMORYH__
@@ -29,13 +29,13 @@
#include <stddef.h> #include <stddef.h>
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
// N.B. BC++ doesn't have istream.h, ostream.h // N.B. BC++ doesn't have istream.h, ostream.h
# include <iostream.h> # include <iostream.h>
#else #else
# include <ostream> # include <ostream>
# ifdef _MSC_VER # if defined(__VISUALC__) || defined(__MWERKS__)
using namespace std; using namespace std;
# endif # endif
#endif #endif
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
@@ -49,15 +49,15 @@ void wxDebugFree(void * buf, bool isVect = FALSE);
// Undefine temporarily (new is #defined in object.h) because we want to // Undefine temporarily (new is #defined in object.h) because we want to
// declare some new operators. // declare some new operators.
#ifdef new #ifdef new
#undef new #undef new
#endif #endif
#if defined(__SUNCC__) #if defined(__SUNCC__)
#define wxUSE_ARRAY_MEMORY_OPERATORS 0 #define wxUSE_ARRAY_MEMORY_OPERATORS 0
#elif !( defined (_MSC_VER) && (_MSC_VER <= 1020) ) || defined( __MWERKS__) #elif !( defined (__VISUALC__) && (__VISUALC__ <= 1020) ) || defined( __MWERKS__)
#define wxUSE_ARRAY_MEMORY_OPERATORS 1 #define wxUSE_ARRAY_MEMORY_OPERATORS 1
#else #else
#define wxUSE_ARRAY_MEMORY_OPERATORS 0 #define wxUSE_ARRAY_MEMORY_OPERATORS 0
#endif #endif
// Added JACS 25/11/98: needed for some compilers // Added JACS 25/11/98: needed for some compilers
@@ -76,9 +76,9 @@ void operator delete[] (void * buf);
#endif #endif
// VC++ 6.0 // VC++ 6.0
#if _MSC_VER >= 1200 #if defined(__VISUALC__) && (__VISUALC__ >= 1200)
void operator delete(void *buf, char*, int); void operator delete(void *buf, char*, int);
void operator delete[](void *buf, char*, int); void operator delete[](void *buf, char*, int);
#endif #endif
#endif #endif

View File

@@ -19,12 +19,14 @@
#ifndef _MSW_MSVCRT_H_ #ifndef _MSW_MSVCRT_H_
#define _MSW_MSVCRT_H_ #define _MSW_MSVCRT_H_
// use debug CRT functions for memory leak detections in VC++ if we're not // use debug CRT functions for memory leak detections in VC++ 5.0+ in debug
// using wxWindows own methods // builds
#if defined(__WXDEBUG__) && defined(_MSC_VER) && !wxUSE_GLOBAL_MEMORY_OPERATORS && !defined(__NO_VC_CRTDBG__) #undef wxUSE_VC_CRTDBG
#define wxUSE_VC_CRTDBG #if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ >= 1000)
#else // it doesn't combine well with wxWin own memory debugging methods
#undef wxUSE_VC_CRTDBG #if !wxUSE_GLOBAL_MEMORY_OPERATORS && !defined(__NO_VC_CRTDBG__)
#define wxUSE_VC_CRTDBG
#endif
#endif #endif
#ifdef wxUSE_VC_CRTDBG #ifdef wxUSE_VC_CRTDBG
@@ -46,4 +48,5 @@
#define wxCrtSetDbgFlag(flag) #define wxCrtSetDbgFlag(flag)
#endif // wxUSE_VC_CRTDBG #endif // wxUSE_VC_CRTDBG
#endif // _MSW_MSVCRT_H_ #endif // _MSW_MSVCRT_H_

View File

@@ -2,7 +2,7 @@
// Name: oleutils.h // Name: oleutils.h
// Purpose: OLE helper routines, OLE debugging support &c // Purpose: OLE helper routines, OLE debugging support &c
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 19.02.1998 // Created: 19.02.1998
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
@@ -44,7 +44,7 @@ bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount);
// ============================================================================ // ============================================================================
/* /*
The most dumb implementation of IUnknown methods. We don't support The most dumb implementation of IUnknown methods. We don't support
aggregation nor containment, but for 99% of cases this simple aggregation nor containment, but for 99% of cases this simple
implementation is quite enough. implementation is quite enough.
@@ -121,11 +121,10 @@ bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount);
// Debugging support // Debugging support
// ============================================================================ // ============================================================================
#if defined(__WXDEBUG__) && defined(_MSC_VER) && (_MSC_VER > 1000) // VZ: I don't know it's not done for compilers other than VC++ but I leave it
// ---------------------------------------------------------------------------- // as is. Please note, though, that tracing OLE interface calls may be
// // incredibly useful when debugging OLE programs.
// ---------------------------------------------------------------------------- #if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ >= 1000)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// All OLE specific log functions have DebugTrace level (as LogTrace) // All OLE specific log functions have DebugTrace level (as LogTrace)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -143,4 +142,5 @@ void wxLogRelease(const char *szInterface, ULONG cRef);
#define wxLogRelease(szInterface, cRef) #define wxLogRelease(szInterface, cRef)
#endif //WXDEBUG #endif //WXDEBUG
#endif //_WX_OLEUTILS_H #endif //_WX_OLEUTILS_H

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OBJECTH__ #ifndef _WX_OBJECTH__
@@ -40,13 +40,13 @@ class WXDLLEXPORT wxHashTable;
class WXDLLEXPORT wxObject_Serialize; class WXDLLEXPORT wxObject_Serialize;
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
// N.B. BC++ doesn't have istream.h, ostream.h // N.B. BC++ doesn't have istream.h, ostream.h
# include <iostream.h> # include <iostream.h>
#else #else
# include <ostream> # include <ostream>
# ifdef _MSC_VER # if defined(__VISUALC__) || defined(__MWERKS__)
using namespace std; using namespace std;
# endif # endif
#endif #endif
/* /*
@@ -61,7 +61,7 @@ class WXDLLEXPORT wxClassInfo
wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn fn); wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn fn);
wxObject *CreateObject(void); wxObject *CreateObject(void);
inline char *GetClassName(void) const { return m_className; } inline char *GetClassName(void) const { return m_className; }
inline char *GetBaseClassName1(void) const { return m_baseClassName1; } inline char *GetBaseClassName1(void) const { return m_baseClassName1; }
inline char *GetBaseClassName2(void) const { return m_baseClassName2; } inline char *GetBaseClassName2(void) const { return m_baseClassName2; }
@@ -87,7 +87,7 @@ public:
char* m_baseClassName2; char* m_baseClassName2;
int m_objectSize; int m_objectSize;
wxObjectConstructorFn m_objectConstructor; wxObjectConstructorFn m_objectConstructor;
// Pointers to base wxClassInfos: set in InitializeClasses // Pointers to base wxClassInfos: set in InitializeClasses
// called from wx_main.cc // called from wx_main.cc
wxClassInfo* m_baseInfo1; wxClassInfo* m_baseInfo1;
@@ -198,13 +198,12 @@ class WXDLLEXPORT wxObject
void operator delete (void * buf); void operator delete (void * buf);
// VC++ 6.0 // VC++ 6.0
#if _MSC_VER >= 1200 #if defined(__VISUALC__) && (__VISUALC__ >= 1200)
void operator delete(void *buf, char*, int); void operator delete(void *buf, char*, int);
#endif #endif
// Cause problems for VC++ // Causes problems for VC++
// #ifndef _MSC_VER #if wxUSE_ARRAY_MEMORY_OPERATORS && !defined(__VISUALC__)
#if !defined(_MSC_VER) && wxUSE_ARRAY_MEMORY_OPERATORS
void * operator new[] (size_t size, char * fileName = NULL, int lineNum = 0); void * operator new[] (size_t size, char * fileName = NULL, int lineNum = 0);
void operator delete[] (void * buf); void operator delete[] (void * buf);
#endif #endif
@@ -216,7 +215,7 @@ class WXDLLEXPORT wxObject
#endif #endif
*/ */
#endif #endif // Debug & memory tracing
#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT #if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT
virtual void Dump(ostream& str); virtual void Dump(ostream& str);

View File

@@ -16,15 +16,10 @@
#pragma interface "string.h" #pragma interface "string.h"
#endif #endif
/* Dependencies (should be included before this header):
* string.h
* stdio.h
* stdarg.h
* limits.h
*/
#ifdef __WXMAC__ #ifdef __WXMAC__
#include <ctype.h> #include <ctype.h>
#endif #endif
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
@@ -32,11 +27,12 @@
#include <stdlib.h> #include <stdlib.h>
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/defs.h" // Robert Roebling #include "wx/defs.h"
#ifdef WXSTRING_IS_WXOBJECT #ifdef WXSTRING_IS_WXOBJECT
#include "wx/object.h" #include "wx/object.h"
#endif #endif
#endif #endif // !PCH
#include "wx/debug.h" #include "wx/debug.h"
@@ -83,7 +79,7 @@ inline size_t WXDLLEXPORT Strlen(const char *psz)
// portable strcasecmp/_stricmp // portable strcasecmp/_stricmp
inline int WXDLLEXPORT Stricmp(const char *psz1, const char *psz2) inline int WXDLLEXPORT Stricmp(const char *psz1, const char *psz2)
{ {
#if defined(_MSC_VER) #if defined(__VISUALC__) || defined(__MWERKS__)
return _stricmp(psz1, psz2); return _stricmp(psz1, psz2);
#elif defined(__SC__) #elif defined(__SC__)
return _stricmp(psz1, psz2); return _stricmp(psz1, psz2);
@@ -645,7 +641,7 @@ public:
size_t find(const wxString& str, size_t nStart = 0) const; size_t find(const wxString& str, size_t nStart = 0) const;
// VC++ 1.5 can't cope with this syntax. // VC++ 1.5 can't cope with this syntax.
#if !(defined(_MSC_VER) && !defined(__WIN32__)) #if !defined(__VISUALC__) || defined(__WIN32__)
// find first n characters of sz // find first n characters of sz
size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const; size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const;
#endif #endif
@@ -661,7 +657,7 @@ public:
size_t rfind(const wxString& str, size_t nStart = npos) const; size_t rfind(const wxString& str, size_t nStart = npos) const;
// VC++ 1.5 can't cope with this syntax. // VC++ 1.5 can't cope with this syntax.
#if ! (defined(_MSC_VER) && !defined(__WIN32__)) #if !defined(__VISUALC__) || defined(__WIN32__)
// as find, but from the end // as find, but from the end
size_t rfind(const char* sz, size_t nStart = npos, size_t rfind(const char* sz, size_t nStart = npos,
size_t n = npos) const; size_t n = npos) const;
@@ -854,19 +850,7 @@ wxString WXDLLEXPORT operator+(const char *psz, const wxString& string);
#ifdef wxSTD_STRING_COMPATIBILITY #ifdef wxSTD_STRING_COMPATIBILITY
// forward declare iostream #include "wx/ioswrap.h"
// Known not to work with wxUSE_IOSTREAMH set to 0, so
// replacing with includes (on advice of ungod@pasdex.com.au)
// class WXDLLEXPORT istream;
#if wxUSE_IOSTREAMH
// N.B. BC++ doesn't have istream.h, ostream.h
#include <iostream.h>
#else
#include <istream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif
WXDLLEXPORT istream& operator>>(istream& is, wxString& str); WXDLLEXPORT istream& operator>>(istream& is, wxString& str);

View File

@@ -6,7 +6,7 @@
// Created: 29/01/98 // Created: 29/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart // Copyright: (c) 1998 Julian Smart
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UTILSH__ #ifndef _WX_UTILSH__
@@ -23,14 +23,7 @@
#include "wx/filefn.h" #include "wx/filefn.h"
#include "wx/process.h" #include "wx/process.h"
#if wxUSE_IOSTREAMH #include "wx/ioswrap.h"
#include <iostream.h>
#else
#include <iostream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif
#ifdef __X__ #ifdef __X__
#ifndef __VMS__ #ifndef __VMS__

View File

@@ -6,7 +6,7 @@
// Created: 10/09/98 // Created: 10/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c)
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_VARIANT_H_ #ifndef _WX_VARIANT_H_
@@ -22,18 +22,11 @@
#include "wx/list.h" #include "wx/list.h"
#if wxUSE_TIMEDATE #if wxUSE_TIMEDATE
#include "wx/time.h" #include "wx/time.h"
#include "wx/date.h" #include "wx/date.h"
#endif #endif // time/date
#if wxUSE_IOSTREAMH #include "wx/ioswrap.h"
#include <iostream.h>
#else
#include <iostream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif
/* /*
* wxVariantData stores the actual data in a wxVariant object, * wxVariantData stores the actual data in a wxVariant object,

View File

@@ -22,11 +22,11 @@
#endif #endif
// only do Unicode for Windows (VC++), for now // only do Unicode for Windows (VC++), for now
#if defined(_MSC_VER) && defined(__WIN32__) #if defined(__VISUALC__) && defined(__WIN32__)
#include <tchar.h> #include <tchar.h>
typedef _TCHAR wxChar; typedef _TCHAR wxChar;
typedef _TSCHAR wxSChar; typedef _TSCHAR wxSChar;
typedef _TUCHAR wxUChar; typedef _TUCHAR wxUChar;
// ctype.h functions // ctype.h functions
@@ -120,11 +120,11 @@ typedef _TUCHAR wxUChar;
#error "Please define your compiler's Unicode conventions in wxChar.h" #error "Please define your compiler's Unicode conventions in wxChar.h"
#endif #endif
typedef char wxChar; typedef char wxChar;
typedef signed char wxSChar; typedef signed char wxSChar;
typedef unsigned char wxUChar; typedef unsigned char wxUChar;
#define _T(x) x #define _T(x) x
// ctype.h functions // ctype.h functions
#define wxIsalnum isalnum #define wxIsalnum isalnum
@@ -212,7 +212,7 @@ inline bool WXDLLEXPORT wxIsEmpty(const wxChar *p) { return !p || !*p; }
/// safe version of strlen() (returns 0 if passed NULL pointer) /// safe version of strlen() (returns 0 if passed NULL pointer)
inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz) inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz)
#if defined(_MSC_VER) #if defined(__VISUALC__)
{ return psz ? _tcslen(psz) : 0; } { return psz ? _tcslen(psz) : 0; }
#else #else
{ return psz ? strlen(psz) : 0; } { return psz ? strlen(psz) : 0; }
@@ -220,7 +220,7 @@ inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz)
/// portable strcasecmp/_stricmp /// portable strcasecmp/_stricmp
inline int WXDLLEXPORT wxStricmp(const wxChar *, const wxChar *) inline int WXDLLEXPORT wxStricmp(const wxChar *, const wxChar *)
#if defined(_MSC_VER) #if defined(__VISUALC__)
{ return _tcsicmp(psz1, psz2); } { return _tcsicmp(psz1, psz2); }
#elif defined(__BORLANDC__) #elif defined(__BORLANDC__)
{ return stricmp(psz1, psz2); } { return stricmp(psz1, psz2); }
@@ -239,7 +239,7 @@ inline int WXDLLEXPORT wxStricmp(const wxChar *, const wxChar *)
return c1 - c2; return c1 - c2;
*/ */
#error "Please define string case-insensitive compare for your OS/compiler" #error "Please define string case-insensitive compare for your OS/compiler"
#endif // OS/compiler #endif // OS/compiler

View File

@@ -21,14 +21,7 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/string.h" #include "wx/string.h"
#if wxUSE_IOSTREAMH #include "wx/ioswrap.h"
#include <iostream.h>
#else
#include <iostream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif
#include "wx/list.h" #include "wx/list.h"
#include "wx/hash.h" #include "wx/hash.h"

View File

@@ -6,19 +6,19 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c)
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// check if to use precompiled headers // check if to use precompiled headers
#if (defined(__BORLANDC__) || defined(_MSC_VER) || defined(__WATCOMC__)) && defined(__WXMSW__) #if (defined(__BORLANDC__) || defined(__VISUALC__) || defined(__WATCOMC__)) && defined(__WXMSW__)
#if !NOPCH #if !NOPCH
#define WX_PRECOMP #define WX_PRECOMP
#endif #endif
#endif #endif
// For some reason, this must be defined for common dialogs to work. // For some reason, this must be defined for common dialogs to work.
#ifdef __WATCOMC__ #ifdef __WATCOMC__
#define INCLUDE_COMMDLG_H 1 #define INCLUDE_COMMDLG_H 1
#endif #endif
// include the wx definitions // include the wx definitions

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -51,15 +51,12 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "wx/ioswrap.h"
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <iostream.h> #include <fstream.h>
#include <fstream.h>
#else #else
#include <iostream> #include <fstream>
#include <fstream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif #endif
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY

View File

@@ -15,7 +15,7 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "file.h" #pragma implementation "file.h"
#endif #endif
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
@@ -23,7 +23,7 @@
#include "wx/defs.h" #include "wx/defs.h"
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
// standard // standard
@@ -55,37 +55,34 @@
#include <windows.h> // for GetTempFileName #include <windows.h> // for GetTempFileName
#elif (defined(__UNIX__) || defined(__GNUWIN32__)) #elif (defined(__UNIX__) || defined(__GNUWIN32__))
#include <unistd.h> #include <unistd.h>
#ifdef __GNUWIN32__ #ifdef __GNUWIN32__
#include <windows.h> #include <windows.h>
#endif #endif
#elif (defined(__WXSTUBS__)) #elif (defined(__WXSTUBS__))
// Have to ifdef this for different environments // Have to ifdef this for different environments
#include <io.h> #include <io.h>
#elif (defined(__WXMAC__)) #elif (defined(__WXMAC__))
int access( const char *path, int mode ) { return 0 ; } int access( const char *path, int mode ) { return 0 ; }
char* mktemp( char * path ) { return path ;} char* mktemp( char * path ) { return path ;}
#include <unistd.h> #include <unistd.h>
#include <unix.h> #include <unix.h>
#define W_OK 2 #define W_OK 2
#define R_OK 4 #define R_OK 4
#else #else
#error "Please specify the header with file functions declarations." #error "Please specify the header with file functions declarations."
#endif //Win/UNIX #endif //Win/UNIX
#include <stdio.h> // SEEK_xxx constants #include <stdio.h> // SEEK_xxx constants
#include <fcntl.h> // O_RDONLY &c #include <fcntl.h> // O_RDONLY &c
#ifndef __MWERKS__ #ifndef __MWERKS__
#include <sys/types.h> // needed for stat #include <sys/types.h> // needed for stat
#include <sys/stat.h> // stat #include <sys/stat.h> // stat
#endif #endif
// Microsoft compiler loves underscores, feed them to it // Microsoft compiler loves underscores, feed them to it
#ifdef _MSC_VER #ifdef __VISUALC__
#ifndef __MWERKS__
// functions // functions
#define open _open #define open _open
#define close _close #define close _close
@@ -100,7 +97,7 @@
#define stat _stat #define stat _stat
// constants // constants
#define O_RDONLY _O_RDONLY #define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY #define O_WRONLY _O_WRONLY
#define O_RDWR _O_RDWR #define O_RDWR _O_RDWR
@@ -110,16 +107,11 @@
#define S_IFDIR _S_IFDIR #define S_IFDIR _S_IFDIR
#define S_IFREG _S_IFREG #define S_IFREG _S_IFREG
#endif
#define W_OK 2
#define R_OK 4
#else #else
#define tell(fd) lseek(fd, 0, SEEK_CUR) #define tell(fd) lseek(fd, 0, SEEK_CUR)
#endif //_MSC_VER #endif // VC++
#ifdef __BORLANDC__ #if defined(__BORLANDC__) || defined(_MSC_VER)
#define W_OK 2 #define W_OK 2
#define R_OK 4 #define R_OK 4
#endif #endif
@@ -129,9 +121,8 @@
#define O_BINARY (0) #define O_BINARY (0)
#endif //__UNIX__ #endif //__UNIX__
#ifdef __SALFORDC__ #ifdef __SALFORDC__
#include <unix.h> #include <unix.h>
#endif #endif
// wxWindows // wxWindows
@@ -141,13 +132,13 @@
#include <wx/log.h> #include <wx/log.h>
#ifndef MAX_PATH #ifndef MAX_PATH
#define MAX_PATH 512 #define MAX_PATH 512
#endif #endif
#ifdef __WXMAC__ #ifdef __WXMAC__
char gwxMacFileName[ MAX_PATH ] ; char gwxMacFileName[ MAX_PATH ] ;
char gwxMacFileName2[ MAX_PATH ] ; char gwxMacFileName2[ MAX_PATH ] ;
char gwxMacFileName3[ MAX_PATH ] ; char gwxMacFileName3[ MAX_PATH ] ;
#endif #endif
// ============================================================================ // ============================================================================
@@ -213,7 +204,7 @@ bool wxFile::Create(const char *szFileName, bool bOverwrite, int accessMode)
// if bOverwrite we create a new file or truncate the existing one, // if bOverwrite we create a new file or truncate the existing one,
// otherwise we only create the new file and fail if it already exists // otherwise we only create the new file and fail if it already exists
#ifdef __SALFORDC__ #ifdef __SALFORDC__
int fd = open(szFileName, O_WRONLY | O_CREAT | int fd = open(szFileName, O_WRONLY | O_CREAT |
(bOverwrite ? O_TRUNC : O_EXCL)); (bOverwrite ? O_TRUNC : O_EXCL));
#else #else
int fd = open(szFileName, O_WRONLY | O_CREAT | int fd = open(szFileName, O_WRONLY | O_CREAT |
@@ -330,7 +321,7 @@ size_t wxFile::Write(const void *pBuf, size_t nCount)
bool wxFile::Flush() bool wxFile::Flush()
{ {
if ( IsOpened() ) { if ( IsOpened() ) {
#if (defined(_MSC_VER) && !defined(__MWERKS__)) || wxHAVE_FSYNC #if defined(__VISUALC__) || wxHAVE_FSYNC
if ( fsync(m_fd) == -1 ) if ( fsync(m_fd) == -1 )
{ {
wxLogSysError(_("can't flush file descriptor %d"), m_fd); wxLogSysError(_("can't flush file descriptor %d"), m_fd);
@@ -399,9 +390,9 @@ off_t wxFile::Length() const
{ {
wxASSERT( IsOpened() ); wxASSERT( IsOpened() );
#if defined( _MSC_VER ) && !defined( __MWERKS__ ) #ifdef __VISUALC__
int iRc = _filelength(m_fd); int iRc = _filelength(m_fd);
#else #else // !VC++
int iRc = tell(m_fd); int iRc = tell(m_fd);
if ( iRc != -1 ) { if ( iRc != -1 ) {
// @ have to use const_cast :-( // @ have to use const_cast :-(
@@ -416,8 +407,7 @@ off_t wxFile::Length() const
iRc = iLen; iRc = iLen;
} }
#endif // VC++
#endif //_MSC_VER
if ( iRc == -1 ) { if ( iRc == -1 ) {
wxLogSysError(_("can't find length of file on file descriptor %d"), m_fd); wxLogSysError(_("can't find length of file on file descriptor %d"), m_fd);

File diff suppressed because it is too large Load Diff

View File

@@ -986,7 +986,7 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg)
// make life easier for people using VC++ IDE: clicking on the message will // make life easier for people using VC++ IDE: clicking on the message will
// take us immediately to the place of the failed assert // take us immediately to the place of the failed assert
#ifdef _MSC_VER #ifdef __VISUALC__
sprintf(szBuf, _("%s(%d): assert failed"), szFile, nLine); sprintf(szBuf, _("%s(%d): assert failed"), szFile, nLine);
#else // !VC++ #else // !VC++
// make the error message more clear for all the others // make the error message more clear for all the others

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -38,15 +38,12 @@
#include <wx/log.h> #include <wx/log.h>
#include <stdlib.h> #include <stdlib.h>
#include "wx/ioswrap.h"
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <iostream.h> #include <fstream.h>
#include <fstream.h>
#else #else
#include <iostream> #include <fstream>
#include <fstream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif #endif
#if !defined(__WATCOMC__) && !defined(__VMS__) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) #if !defined(__WATCOMC__) && !defined(__VMS__) && !defined( __MWERKS__ ) && !defined(__SALFORDC__)
@@ -78,8 +75,8 @@
// wxDebugContext wxTheDebugContext; // wxDebugContext wxTheDebugContext;
/* /*
Redefine new and delete so that we can pick up situations where: Redefine new and delete so that we can pick up situations where:
- we overwrite or underwrite areas of malloc'd memory. - we overwrite or underwrite areas of malloc'd memory.
- we use uninitialise variables - we use uninitialise variables
Only do this in debug mode. Only do this in debug mode.
We change new to get enough memory to allocate a struct, followed We change new to get enough memory to allocate a struct, followed
@@ -116,7 +113,7 @@ void wxMemStruct::ErrorMsg (const char * mesg)
wxLogDebug("wxWindows memory checking error: %s", mesg); wxLogDebug("wxWindows memory checking error: %s", mesg);
PrintNode (); PrintNode ();
// << m_fileName << ' ' << m_lineNum << endl; // << m_fileName << ' ' << m_lineNum << endl;
} }
/* /*
@@ -126,7 +123,7 @@ void wxMemStruct::ErrorMsg ()
{ {
wxLogDebug("wxWindows over/underwrite memory error:"); wxLogDebug("wxWindows over/underwrite memory error:");
PrintNode (); PrintNode ();
// cerr << m_fileName << ' ' << m_lineNum << endl; // cerr << m_fileName << ' ' << m_lineNum << endl;
} }
@@ -141,9 +138,9 @@ void wxMemStruct::ErrorMsg ()
int wxMemStruct::AssertList () int wxMemStruct::AssertList ()
{ {
if (wxDebugContext::GetHead () != 0 && ! (wxDebugContext::GetHead ())->AssertIt () || if (wxDebugContext::GetHead () != 0 && ! (wxDebugContext::GetHead ())->AssertIt () ||
wxDebugContext::GetTail () != 0 && ! wxDebugContext::GetTail ()->AssertIt ()) { wxDebugContext::GetTail () != 0 && ! wxDebugContext::GetTail ()->AssertIt ()) {
ErrorMsg ("Head or tail pointers trashed"); ErrorMsg ("Head or tail pointers trashed");
return 0; return 0;
} }
return 1; return 1;
} }
@@ -163,8 +160,8 @@ int wxMemStruct::AssertList ()
int wxMemStruct::AssertIt () int wxMemStruct::AssertIt ()
{ {
return (m_id == MemStructId && return (m_id == MemStructId &&
(m_prev == 0 || m_prev->m_id == MemStructId) && (m_prev == 0 || m_prev->m_id == MemStructId) &&
(m_next == 0 || m_next->m_id == MemStructId)); (m_next == 0 || m_next->m_id == MemStructId));
} }
@@ -175,19 +172,19 @@ int wxMemStruct::AssertIt ()
int wxMemStruct::Append () int wxMemStruct::Append ()
{ {
if (! AssertList ()) if (! AssertList ())
return 0; return 0;
if (wxDebugContext::GetHead () == 0) { if (wxDebugContext::GetHead () == 0) {
if (wxDebugContext::GetTail () != 0) { if (wxDebugContext::GetTail () != 0) {
ErrorMsg ("Null list should have a null tail pointer"); ErrorMsg ("Null list should have a null tail pointer");
return 0; return 0;
} }
(void) wxDebugContext::SetHead (this); (void) wxDebugContext::SetHead (this);
(void) wxDebugContext::SetTail (this); (void) wxDebugContext::SetTail (this);
} else { } else {
wxDebugContext::GetTail ()->m_next = this; wxDebugContext::GetTail ()->m_next = this;
this->m_prev = wxDebugContext::GetTail (); this->m_prev = wxDebugContext::GetTail ();
(void) wxDebugContext::SetTail (this); (void) wxDebugContext::SetTail (this);
} }
return 1; return 1;
} }
@@ -201,51 +198,51 @@ int wxMemStruct::Append ()
int wxMemStruct::Unlink () int wxMemStruct::Unlink ()
{ {
if (! AssertList ()) if (! AssertList ())
return 0; return 0;
if (wxDebugContext::GetHead () == 0 || wxDebugContext::GetTail () == 0) { if (wxDebugContext::GetHead () == 0 || wxDebugContext::GetTail () == 0) {
ErrorMsg ("Trying to remove node from empty list"); ErrorMsg ("Trying to remove node from empty list");
return 0; return 0;
} }
// Handle the part of the list before this node. // Handle the part of the list before this node.
if (m_prev == 0) { if (m_prev == 0) {
if (this != wxDebugContext::GetHead ()) { if (this != wxDebugContext::GetHead ()) {
ErrorMsg ("No previous node for non-head node"); ErrorMsg ("No previous node for non-head node");
return 0; return 0;
} }
(void) wxDebugContext::SetHead (m_next); (void) wxDebugContext::SetHead (m_next);
} else { } else {
if (! m_prev->AssertIt ()) { if (! m_prev->AssertIt ()) {
ErrorMsg ("Trashed previous pointer"); ErrorMsg ("Trashed previous pointer");
return 0; return 0;
} }
if (m_prev->m_next != this) { if (m_prev->m_next != this) {
ErrorMsg ("List is inconsistent"); ErrorMsg ("List is inconsistent");
return 0; return 0;
} }
m_prev->m_next = m_next; m_prev->m_next = m_next;
} }
// Handle the part of the list after this node. // Handle the part of the list after this node.
if (m_next == 0) { if (m_next == 0) {
if (this != wxDebugContext::GetTail ()) { if (this != wxDebugContext::GetTail ()) {
ErrorMsg ("No next node for non-tail node"); ErrorMsg ("No next node for non-tail node");
return 0; return 0;
} }
(void) wxDebugContext::SetTail (m_prev); (void) wxDebugContext::SetTail (m_prev);
} else { } else {
if (! m_next->AssertIt ()) { if (! m_next->AssertIt ()) {
ErrorMsg ("Trashed next pointer"); ErrorMsg ("Trashed next pointer");
return 0; return 0;
} }
if (m_next->m_prev != this) { if (m_next->m_prev != this) {
ErrorMsg ("List is inconsistent"); ErrorMsg ("List is inconsistent");
return 0; return 0;
} }
m_next->m_prev = m_prev; m_next->m_prev = m_prev;
} }
return 1; return 1;
@@ -262,22 +259,22 @@ int wxMemStruct::CheckBlock ()
int nFailures = 0; int nFailures = 0;
if (m_firstMarker != MemStartCheck) { if (m_firstMarker != MemStartCheck) {
nFailures++; nFailures++;
ErrorMsg (); ErrorMsg ();
} }
char * pointer = wxDebugContext::MidMarkerPos ((char *) this); char * pointer = wxDebugContext::MidMarkerPos ((char *) this);
if (* (wxMarkerType *) pointer != MemMidCheck) { if (* (wxMarkerType *) pointer != MemMidCheck) {
nFailures++; nFailures++;
ErrorMsg (); ErrorMsg ();
} }
pointer = wxDebugContext::EndMarkerPos ((char *) this, RequestSize ()); pointer = wxDebugContext::EndMarkerPos ((char *) this, RequestSize ());
if (* (wxMarkerType *) pointer != MemEndCheck) { if (* (wxMarkerType *) pointer != MemEndCheck) {
nFailures++; nFailures++;
ErrorMsg (); ErrorMsg ();
} }
return nFailures; return nFailures;
} }
@@ -288,12 +285,12 @@ int wxMemStruct::CheckBlock ()
int wxMemStruct::CheckAllPrevious () int wxMemStruct::CheckAllPrevious ()
{ {
int nFailures = 0; int nFailures = 0;
for (wxMemStruct * st = this->m_prev; st != 0; st = st->m_prev) { for (wxMemStruct * st = this->m_prev; st != 0; st = st->m_prev) {
if (st->AssertIt ()) if (st->AssertIt ())
nFailures += st->CheckBlock (); nFailures += st->CheckBlock ();
else else
return -1; return -1;
} }
return nFailures; return nFailures;
@@ -366,7 +363,7 @@ void wxMemStruct::PrintNode ()
void wxMemStruct::Dump () void wxMemStruct::Dump ()
{ {
if (!ValidateNode()) return; if (!ValidateNode()) return;
if (m_isObject) if (m_isObject)
{ {
wxObject *obj = (wxObject *)m_actualData; wxObject *obj = (wxObject *)m_actualData;
@@ -416,15 +413,15 @@ int wxMemStruct::ValidateNode ()
{ {
char * startPointer = (char *) this; char * startPointer = (char *) this;
if (!AssertIt ()) { if (!AssertIt ()) {
if (IsDeleted ()) if (IsDeleted ())
ErrorMsg ("Object already deleted"); ErrorMsg ("Object already deleted");
else { else {
// Can't use the error routines as we have no recognisable object. // Can't use the error routines as we have no recognisable object.
#ifndef __WXGTK__ #ifndef __WXGTK__
wxLogDebug("Can't verify memory struct - all bets are off!"); wxLogDebug("Can't verify memory struct - all bets are off!");
#endif #endif
} }
return 0; return 0;
} }
/* /*
@@ -438,20 +435,20 @@ int wxMemStruct::ValidateNode ()
if (* (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) != MemMidCheck) if (* (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) != MemMidCheck)
ErrorMsg (); ErrorMsg ();
if (* (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer, if (* (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer,
RequestSize ()) != RequestSize ()) !=
MemEndCheck) MemEndCheck)
ErrorMsg (); ErrorMsg ();
// Back to before the extra buffer and check that // Back to before the extra buffer and check that
// we can still read what we originally wrote. // we can still read what we originally wrote.
if (Marker () != MemStartCheck || if (Marker () != MemStartCheck ||
* (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) * (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer)
!= MemMidCheck || != MemMidCheck ||
* (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer, * (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer,
RequestSize ()) != MemEndCheck) RequestSize ()) != MemEndCheck)
{ {
ErrorMsg (); ErrorMsg ();
return 0; return 0;
} }
return 1; return 1;
@@ -588,7 +585,7 @@ char * wxDebugContext::EndMarkerPos (const char * buf, const size_t size)
char * wxDebugContext::StartPos (const char * caller) char * wxDebugContext::StartPos (const char * caller)
{ {
return ((char *) (caller - wxDebugContext::PaddedSize (sizeof(wxMarkerType)) - return ((char *) (caller - wxDebugContext::PaddedSize (sizeof(wxMarkerType)) -
wxDebugContext::PaddedSize (sizeof (wxMemStruct)))); wxDebugContext::PaddedSize (sizeof (wxMemStruct))));
} }
/* /*
@@ -620,7 +617,7 @@ size_t wxDebugContext::PaddedSize (const size_t size)
size_t wxDebugContext::TotSize (const size_t reqSize) size_t wxDebugContext::TotSize (const size_t reqSize)
{ {
return (PaddedSize (sizeof (wxMemStruct)) + PaddedSize (reqSize) + return (PaddedSize (sizeof (wxMemStruct)) + PaddedSize (reqSize) +
2 * sizeof(wxMarkerType)); 2 * sizeof(wxMarkerType));
} }
@@ -631,7 +628,7 @@ void wxDebugContext::TraverseList (PmSFV func, wxMemStruct *from)
{ {
if (!from) if (!from)
from = wxDebugContext::GetHead (); from = wxDebugContext::GetHead ();
for (wxMemStruct * st = from; st != 0; st = st->m_next) for (wxMemStruct * st = from; st != 0; st = st->m_next)
{ {
void* data = st->GetActualData(); void* data = st->GetActualData();
@@ -683,7 +680,7 @@ bool wxDebugContext::Dump(void)
} }
} }
TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL)); TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL));
wxLogDebug( "" ); wxLogDebug( "" );
wxLogDebug( "" ); wxLogDebug( "" );
@@ -739,10 +736,10 @@ bool wxDebugContext::PrintStatistics(bool detailed)
wxLogDebug( "----- Memory statistics -----" ); wxLogDebug( "----- Memory statistics -----" );
} }
} }
bool currentMode = GetDebugMode(); bool currentMode = GetDebugMode();
SetDebugMode(FALSE); SetDebugMode(FALSE);
long noNonObjectNodes = 0; long noNonObjectNodes = 0;
long noObjectNodes = 0; long noObjectNodes = 0;
long totalSize = 0; long totalSize = 0;
@@ -753,7 +750,7 @@ bool wxDebugContext::PrintStatistics(bool detailed)
if (!from) if (!from)
from = wxDebugContext::GetHead (); from = wxDebugContext::GetHead ();
wxMemStruct *st; wxMemStruct *st;
for (st = from; st != 0; st = st->m_next) for (st = from; st != 0; st = st->m_next)
{ {
void* data = st->GetActualData(); void* data = st->GetActualData();
@@ -803,7 +800,7 @@ bool wxDebugContext::PrintStatistics(bool detailed)
} }
wxLogDebug(""); wxLogDebug("");
} }
SetDebugMode(currentMode); SetDebugMode(currentMode);
wxLogDebug("Number of object items: %ld", noObjectNodes); wxLogDebug("Number of object items: %ld", noObjectNodes);
@@ -816,7 +813,7 @@ bool wxDebugContext::PrintStatistics(bool detailed)
#else #else
return FALSE; return FALSE;
#endif #endif
} }
bool wxDebugContext::PrintClasses(void) bool wxDebugContext::PrintClasses(void)
{ {
@@ -874,7 +871,7 @@ bool wxDebugContext::PrintClasses(void)
wxLogDebug(""); wxLogDebug("");
wxLogDebug(""); wxLogDebug("");
return TRUE; return TRUE;
} }
void wxDebugContext::SetCheckpoint(bool all) void wxDebugContext::SetCheckpoint(bool all)
{ {
@@ -888,7 +885,7 @@ void wxDebugContext::SetCheckpoint(bool all)
int wxDebugContext::Check(bool checkAll) int wxDebugContext::Check(bool checkAll)
{ {
int nFailures = 0; int nFailures = 0;
wxMemStruct *from = (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL ); wxMemStruct *from = (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL );
if (!from || checkAll) if (!from || checkAll)
from = wxDebugContext::GetHead (); from = wxDebugContext::GetHead ();
@@ -942,7 +939,7 @@ int wxDebugContext::CountObjectsLeft(bool sinceCheckpoint)
#endif #endif
// Seems OK all of a sudden. Maybe to do with linking with multithreaded library? // Seems OK all of a sudden. Maybe to do with linking with multithreaded library?
#if 0 // def _MSC_VER #if 0 // def __VISUALC__
#define NO_DEBUG_ALLOCATION #define NO_DEBUG_ALLOCATION
#endif #endif
@@ -1001,7 +998,7 @@ void operator delete (void * buf)
} }
// VC++ 6.0 // VC++ 6.0
#if _MSC_VER >= 1200 #if defined(__VISUALC__) && (__VISUALC__ >= 1200)
void operator delete(void* pData, char* /* fileName */, int /* lineNum */) void operator delete(void* pData, char* /* fileName */, int /* lineNum */)
{ {
// ::operator delete(pData); // ::operator delete(pData);
@@ -1039,12 +1036,12 @@ void * wxDebugAlloc(size_t size, char * fileName, int lineNum, bool isObject, bo
{ {
return (void *)malloc(size); return (void *)malloc(size);
} }
int totSize = wxDebugContext::TotSize (size); int totSize = wxDebugContext::TotSize (size);
char * buf = (char *) malloc(totSize); char * buf = (char *) malloc(totSize);
if (!buf) { if (!buf) {
wxLogDebug("Call to malloc (%ld) failed.", (long)size); wxLogDebug("Call to malloc (%ld) failed.", (long)size);
return 0; return 0;
} }
wxMemStruct * st = (wxMemStruct *)buf; wxMemStruct * st = (wxMemStruct *)buf;
st->m_firstMarker = MemStartCheck; st->m_firstMarker = MemStartCheck;
@@ -1058,15 +1055,15 @@ void * wxDebugAlloc(size_t size, char * fileName, int lineNum, bool isObject, bo
// Errors from Append() shouldn't really happen - but just in case! // Errors from Append() shouldn't really happen - but just in case!
if (st->Append () == 0) { if (st->Append () == 0) {
st->ErrorMsg ("Trying to append new node"); st->ErrorMsg ("Trying to append new node");
} }
if (wxDebugContext::GetCheckPrevious ()) { if (wxDebugContext::GetCheckPrevious ()) {
if (st->CheckAllPrevious () < 0) { if (st->CheckAllPrevious () < 0) {
st->ErrorMsg ("Checking previous nodes"); st->ErrorMsg ("Checking previous nodes");
} }
} }
// Set up the extra markers at the middle and end. // Set up the extra markers at the middle and end.
char * ptr = wxDebugContext::MidMarkerPos (buf); char * ptr = wxDebugContext::MidMarkerPos (buf);
* (wxMarkerType *) ptr = MemMidCheck; * (wxMarkerType *) ptr = MemMidCheck;
@@ -1086,7 +1083,7 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) )
{ {
if (!buf) if (!buf)
return; return;
// If not in debugging allocation mode, do the normal thing // If not in debugging allocation mode, do the normal thing
// so we don't leave any trace of ourselves in the node list. // so we don't leave any trace of ourselves in the node list.
if (!wxDebugContext::GetDebugMode()) if (!wxDebugContext::GetDebugMode())
@@ -1101,7 +1098,7 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) )
wxMemStruct * st = (wxMemStruct *) wxDebugContext::StructPos (startPointer); wxMemStruct * st = (wxMemStruct *) wxDebugContext::StructPos (startPointer);
if (! st->ValidateNode ()) if (! st->ValidateNode ())
return; return;
// If this is the current checkpoint, we need to // If this is the current checkpoint, we need to
// move the checkpoint back so it points to a valid // move the checkpoint back so it points to a valid
@@ -1113,12 +1110,12 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) )
{ {
st->ErrorMsg ("Unlinking deleted node"); st->ErrorMsg ("Unlinking deleted node");
} }
// Now put in the fill char into the id slot and the caller requested // Now put in the fill char into the id slot and the caller requested
// memory locations. // memory locations.
st->SetDeleted (); st->SetDeleted ();
(void) memset (wxDebugContext::CallerMemPos (startPointer), MemFillChar, (void) memset (wxDebugContext::CallerMemPos (startPointer), MemFillChar,
st->RequestSize ()); st->RequestSize ());
// Don't allow delayed freeing of memory in this version // Don't allow delayed freeing of memory in this version
// if (!wxDebugContext::GetDelayFree()) // if (!wxDebugContext::GetDelayFree())
@@ -1160,7 +1157,7 @@ void wxTraceLevel(int level, const char *fmt ...)
{ {
if (wxDebugContext::GetLevel() < level) if (wxDebugContext::GetLevel() < level)
return; return;
va_list ap; va_list ap;
static char buffer[512]; static char buffer[512];

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -40,15 +40,8 @@
#endif #endif
#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT #if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT
// for wxObject::Dump // for wxObject::Dump
#if wxUSE_IOSTREAMH #include "wx/ioswrap.h"
# include <iostream.h>
#else
# include <iostream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif
#endif #endif
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
@@ -121,7 +114,7 @@ void wxObject::operator delete (void * buf)
} }
// VC++ 6.0 // VC++ 6.0
#if _MSC_VER >= 1200 #if defined(__VISUALC__) && (__VISUALC__ >= 1200)
void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum */) void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum */)
{ {
::operator delete(pData); ::operator delete(pData);
@@ -129,7 +122,7 @@ void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum
#endif #endif
// Cause problems for VC++ - crashes // Cause problems for VC++ - crashes
#if !defined(_MSC_VER) && wxUSE_ARRAY_MEMORY_OPERATORS #if !defined(__VISUALC__) && wxUSE_ARRAY_MEMORY_OPERATORS
void * wxObject::operator new[] (size_t size, char * fileName, int lineNum) void * wxObject::operator new[] (size_t size, char * fileName, int lineNum)
{ {
return wxDebugAlloc(size, fileName, lineNum, TRUE, TRUE); return wxDebugAlloc(size, fileName, lineNum, TRUE, TRUE);

View File

@@ -2,12 +2,12 @@
// Name: odbc.cpp // Name: odbc.cpp
// Purpose: ODBC implementation // Purpose: ODBC implementation
// Author: Julian Smart, Olaf Klein (oklein@smallo.ruhr.de), // Author: Julian Smart, Olaf Klein (oklein@smallo.ruhr.de),
// Patrick Halke (patrick@zaphod.ruhr.de) // Patrick Halke (patrick@zaphod.ruhr.de)
// Modified by: // Modified by:
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -25,7 +25,7 @@
#if wxUSE_ODBC #if wxUSE_ODBC
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(disable:4706) // assignment within conditional expression #pragma warning(disable:4706) // assignment within conditional expression
#endif // VC++ #endif // VC++
@@ -1831,7 +1831,7 @@ bool wxQueryField::IsDirty(void) {
return dirty; return dirty;
} }
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression #pragma warning(default:4706) // assignment within conditional expression
#endif // VC++ #endif // VC++

View File

@@ -22,7 +22,7 @@
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(disable:4706) // assignment within conditional expression #pragma warning(disable:4706) // assignment within conditional expression
#endif // VC++ #endif // VC++
@@ -1568,7 +1568,7 @@ wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemReso
return table->CreateItem((wxWindow *)this, resource, parentResource); return table->CreateItem((wxWindow *)this, resource, parentResource);
} }
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression #pragma warning(default:4706) // assignment within conditional expression
#endif // VC++ #endif // VC++

View File

@@ -22,7 +22,7 @@
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(disable:4706) // assignment within conditional expression #pragma warning(disable:4706) // assignment within conditional expression
#endif // VC++ #endif // VC++
@@ -2916,7 +2916,7 @@ wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemReso
return table->CreateItem((wxWindow *)this, resource, parentResource); return table->CreateItem((wxWindow *)this, resource, parentResource);
} }
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression #pragma warning(default:4706) // assignment within conditional expression
#endif // VC++ #endif // VC++

View File

@@ -97,7 +97,7 @@ void wxMacProcessEvents() ;
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#ifdef _MSC_VER #ifdef __VISUALC__
#include <io.h> #include <io.h>
#endif #endif
@@ -157,7 +157,7 @@ void wxMacProcessEvents() ;
// implementations (such as PC-NFS) will require you to include this // implementations (such as PC-NFS) will require you to include this
// or a similar routine (see appendix in WinSock doc or help file). // or a similar routine (see appendix in WinSock doc or help file).
#if defined( NEED_WSAFDIsSet ) || defined( _MSC_VER ) #if defined( NEED_WSAFDIsSet ) || defined( __VISUALC__ )
int PASCAL FAR __WSAFDIsSet(SOCKET fd, fd_set FAR *set) int PASCAL FAR __WSAFDIsSet(SOCKET fd, fd_set FAR *set)
{ {
int i = set->fd_count; int i = set->fd_count;
@@ -440,9 +440,9 @@ wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, size_t nbytes)
SockMsg msg; SockMsg msg;
// warning about 'cast truncates constant value' // warning about 'cast truncates constant value'
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(disable: 4310) #pragma warning(disable: 4310)
#endif // _MSC_VER #endif // __VISUALC__
msg.sig[0] = (char) 0xad; msg.sig[0] = (char) 0xad;
msg.sig[1] = (char) 0xde; msg.sig[1] = (char) 0xde;
@@ -468,9 +468,9 @@ wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, size_t nbytes)
return *this; return *this;
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(default: 4310) #pragma warning(default: 4310)
#endif // _MSC_VER #endif // __VISUALC__
} }
wxSocketBase& wxSocketBase::Unread(const char *buffer, size_t nbytes) wxSocketBase& wxSocketBase::Unread(const char *buffer, size_t nbytes)

View File

@@ -90,7 +90,7 @@ extern const char WXDLLEXPORT *g_szNul = &g_strEmpty.dummy;
// function: for Unix this is done with configure, for Windows we test the // function: for Unix this is done with configure, for Windows we test the
// compiler explicitly. // compiler explicitly.
#ifdef __WXMSW__ #ifdef __WXMSW__
#ifdef _MSC_VER #ifdef __VISUALC__
#define wxVsprintf _vsnprintf #define wxVsprintf _vsnprintf
#endif #endif
#else // !Windows #else // !Windows
@@ -107,7 +107,7 @@ extern const char WXDLLEXPORT *g_szNul = &g_strEmpty.dummy;
#ifndef __SC__ #ifndef __SC__
#pragma message("Using sprintf() because no snprintf()-like function defined") #pragma message("Using sprintf() because no snprintf()-like function defined")
#endif #endif
#endif #endif // no vsnprintf
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global functions // global functions
@@ -119,46 +119,18 @@ extern const char WXDLLEXPORT *g_szNul = &g_strEmpty.dummy;
// iostream ones. // iostream ones.
// //
// ATTN: you can _not_ use both of these in the same program! // ATTN: you can _not_ use both of these in the same program!
#if wxUSE_IOSTREAMH
#include <iostream.h>
#define NAMESPACE
#else
#include <iostream>
# ifdef _MSC_VER
using namespace std;
# endif
// for msvc (bcc50+ also) you don't need these NAMESPACE defines,
// using namespace std; takes care of that.
#define NAMESPACE std::
#endif
#ifdef __WXMSW__ istream& operator>>(istream& is, wxString& WXUNUSED(str))
#ifdef _MSC_VER
#define wxVsprintf _vsnprintf
#endif
#else
#if defined ( HAVE_VSNPRINTF )
#define wxVsprintf vsnprintf
#endif
#endif
#ifndef wxVsprintf
// vsprintf() is ANSI so we can always use it, but it's unsafe!
#define wxVsprintf(buffer,len,format,argptr) vsprintf(buffer,format, argptr)
#pragma message("Using sprintf() because no snprintf()-like function defined")
#endif
NAMESPACE istream& operator>>(NAMESPACE istream& is, wxString& WXUNUSED(str))
{ {
#if 0 #if 0
int w = is.width(0); int w = is.width(0);
if ( is.ipfx(0) ) { if ( is.ipfx(0) ) {
NAMESPACE streambuf *sb = is.rdbuf(); streambuf *sb = is.rdbuf();
str.erase(); str.erase();
while ( true ) { while ( true ) {
int ch = sb->sbumpc (); int ch = sb->sbumpc ();
if ( ch == EOF ) { if ( ch == EOF ) {
is.setstate(NAMESPACE ios::eofbit); is.setstate(ios::eofbit);
break; break;
} }
else if ( isspace(ch) ) { else if ( isspace(ch) ) {
@@ -174,7 +146,7 @@ NAMESPACE istream& operator>>(NAMESPACE istream& is, wxString& WXUNUSED(str))
is.isfx(); is.isfx();
if ( str.length() == 0 ) if ( str.length() == 0 )
is.setstate(NAMESPACE ios::failbit); is.setstate(ios::failbit);
#endif #endif
return is; return is;
} }
@@ -1142,12 +1114,12 @@ size_t wxString::find(const wxString& str, size_t nStart) const
} }
// VC++ 1.5 can't cope with the default argument in the header. // VC++ 1.5 can't cope with the default argument in the header.
#if ! (defined(_MSC_VER) && !defined(__WIN32__)) #if !defined(__VISUALC__) || defined(__WIN32__)
size_t wxString::find(const char* sz, size_t nStart, size_t n) const size_t wxString::find(const char* sz, size_t nStart, size_t n) const
{ {
return find(wxString(sz, n == npos ? 0 : n), nStart); return find(wxString(sz, n == npos ? 0 : n), nStart);
} }
#endif #endif // VC++ 1.5
// Gives a duplicate symbol (presumably a case-insensitivity problem) // Gives a duplicate symbol (presumably a case-insensitivity problem)
#if !defined(__BORLANDC__) #if !defined(__BORLANDC__)
@@ -1178,7 +1150,7 @@ size_t wxString::rfind(const wxString& str, size_t nStart) const
} }
// VC++ 1.5 can't cope with the default argument in the header. // VC++ 1.5 can't cope with the default argument in the header.
#if ! (defined(_MSC_VER) && !defined(__WIN32__)) #if !defined(__VISUALC__) || defined(__WIN32__)
size_t wxString::rfind(const char* sz, size_t nStart, size_t n) const size_t wxString::rfind(const char* sz, size_t nStart, size_t n) const
{ {
return rfind(wxString(sz, n == npos ? 0 : n), nStart); return rfind(wxString(sz, n == npos ? 0 : n), nStart);
@@ -1192,7 +1164,7 @@ size_t wxString::rfind(char ch, size_t nStart) const
return p == NULL ? npos : p - c_str(); return p == NULL ? npos : p - c_str();
} }
#endif #endif // VC++ 1.5
wxString wxString::substr(size_t nStart, size_t nLen) const wxString wxString::substr(size_t nStart, size_t nLen) const
{ {

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -32,17 +32,14 @@ seconds since January 1, 1901, GMT.
#include "wx/time.h" #include "wx/time.h"
#include "wx/date.h" #include "wx/date.h"
#include "wx/utils.h" #include "wx/utils.h"
#include <wx/intl.h> #include "wx/intl.h"
#include "wx/ioswrap.h"
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <iostream.h> #include <iomanip.h>
#include <iomanip.h>
#else #else
#include <iostream> #include <iomanip>
#include <iomanip>
# ifdef _MSC_VER
using namespace std;
# endif
#endif #endif
#include <string.h> #include <string.h>
@@ -60,8 +57,8 @@ static int DST_OBSERVED; /* flags U.S. daylight saving time observed */
static bool wxTimeInitialized = FALSE; static bool wxTimeInitialized = FALSE;
wxTime::tFormat wxTime::Format = wxTime::wx12h; wxTime::tFormat wxTime::Format = wxTime::wx12h;
wxTime::tPrecision wxTime::Precision = wxTime::wxStdMinSec; wxTime::tPrecision wxTime::Precision = wxTime::wxStdMinSec;
static const unsigned long seconds_in_day = 24*60*60L; static const unsigned long seconds_in_day = 24*60*60L;
static const wxDate refDate(1,1,1901); static const wxDate refDate(1,1,1901);
@@ -69,19 +66,19 @@ static const wxDate refDate(1,1,1901);
wxTime wxTime::GetLocalTime(const wxDate& date, hourTy h, minuteTy m, secondTy s) wxTime wxTime::GetLocalTime(const wxDate& date, hourTy h, minuteTy m, secondTy s)
/* /*
Return a local wxTime for the specified Standard Time date, hour, minute, Return a local wxTime for the specified Standard Time date, hour, minute,
and second. and second.
*/ */
{ {
if (!wxTimeInitialized) if (!wxTimeInitialized)
{ {
wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
wxTimeInitialized = TRUE; wxTimeInitialized = TRUE;
} }
/* /*
if (!date.IsBetween(refDate,maxDate)) if (!date.IsBetween(refDate,maxDate))
setError(NIHCL_DATERANGE,DEFAULT, setError(NIHCL_DATERANGE,DEFAULT,
date.dayOfMonth(),date.nameOfMonth(),date.year()); date.dayOfMonth(),date.nameOfMonth(),date.year());
*/ */
// The following line causes an error in GCC 2.1 // The following line causes an error in GCC 2.1
// long daysBetween = date-refDate; // long daysBetween = date-refDate;
@@ -95,13 +92,13 @@ wxTime wxTime::GetLocalTime(const wxDate& date, hourTy h, minuteTy m, secondTy s
wxTime::wxTime() wxTime::wxTime()
/* /*
Construct a wxTime for this instant. Construct a wxTime for this instant.
*/ */
{ {
if (!wxTimeInitialized) if (!wxTimeInitialized)
{ {
wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
wxTimeInitialized = TRUE; wxTimeInitialized = TRUE;
} }
sec = wxGetCurrentTime(); sec = wxGetCurrentTime();
#ifdef __SALFORDC__ #ifdef __SALFORDC__
@@ -113,14 +110,14 @@ wxTime::wxTime()
wxTime::wxTime(hourTy h, minuteTy m, secondTy s, bool dst) wxTime::wxTime(hourTy h, minuteTy m, secondTy s, bool dst)
/* /*
Construct a wxTime for today at the specified (local) hour, minute, and Construct a wxTime for today at the specified (local) hour, minute, and
second. second.
*/ */
{ {
if (!wxTimeInitialized) if (!wxTimeInitialized)
{ {
wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
wxTimeInitialized = TRUE; wxTimeInitialized = TRUE;
} }
sec = wxTime(wxDate(),h,m,s,dst).sec; sec = wxTime(wxDate(),h,m,s,dst).sec;
@@ -136,7 +133,7 @@ wxTime::wxTime(const wxDate& date, hourTy h, minuteTy m, secondTy s, bool dst)
if (!wxTimeInitialized) if (!wxTimeInitialized)
{ {
wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
wxTimeInitialized = TRUE; wxTimeInitialized = TRUE;
} }
sec = GetLocalTime(date,h,m,s).sec-3600; sec = GetLocalTime(date,h,m,s).sec-3600;
if (IsDST()) if (IsDST())
@@ -149,8 +146,8 @@ wxTime::wxTime(const wxDate& date, hourTy h, minuteTy m, secondTy s, bool dst)
sec += 3600; sec += 3600;
/* /*
if (IsDST()) setError(NIHCL_BADTIME,DEFAULT, if (IsDST()) setError(NIHCL_BADTIME,DEFAULT,
date.dayOfMonth(),date.nameOfMonth(),date.year(), date.dayOfMonth(),date.nameOfMonth(),date.year(),
h,m,s,(dst?_("DST"):"")); h,m,s,(dst?_("DST"):""));
*/ */
} }
sec += TIME_ZONE; // adjust to GMT sec += TIME_ZONE; // adjust to GMT
@@ -159,11 +156,11 @@ wxTime::wxTime(const wxDate& date, hourTy h, minuteTy m, secondTy s, bool dst)
#ifndef __SALFORDC__ #ifndef __SALFORDC__
wxTime::operator wxDate() const wxTime::operator wxDate() const
/* /*
Convert a wxTime to a local wxDate Convert a wxTime to a local wxDate
*/ */
{ {
// return wxDate((int)(GetLocalTime().sec/seconds_in_day)); 4.2 cc bug // return wxDate((int)(GetLocalTime().sec/seconds_in_day)); 4.2 cc bug
long daycount = (long)(GetLocalTime().sec/seconds_in_day); long daycount = (long)(GetLocalTime().sec/seconds_in_day);
wxDate date(1,1,1901); wxDate date(1,1,1901);
date += daycount; date += daycount;
@@ -178,11 +175,11 @@ bool wxTime::IsBetween(const wxTime& a, const wxTime& b) const
hourTy wxTime::GetHour() const hourTy wxTime::GetHour() const
/* /*
Return the hour of this wxTime in local time; i.e., adjust for Return the hour of this wxTime in local time; i.e., adjust for
time zone and Daylight Savings Time. time zone and Daylight Savings Time.
*/ */
{ {
return GetLocalTime().GetHourGMT(); return GetLocalTime().GetHourGMT();
} }
hourTy wxTime::GetHourGMT() const hourTy wxTime::GetHourGMT() const
@@ -190,12 +187,12 @@ hourTy wxTime::GetHourGMT() const
Return the hour of this Time in GMT. Return the hour of this Time in GMT.
*/ */
{ {
return (hourTy)((sec % 86400) / 3600); return (hourTy)((sec % 86400) / 3600);
} }
wxTime wxTime::GetBeginDST(unsigned year) wxTime wxTime::GetBeginDST(unsigned year)
/* /*
Return the local Standard Time at which Daylight Savings Time Return the local Standard Time at which Daylight Savings Time
begins in the specified year. begins in the specified year.
*/ */
{ {
@@ -203,8 +200,8 @@ wxTime wxTime::GetBeginDST(unsigned year)
wxTime DSTtime(GetLocalTime(wxDate(3,31,year).Previous(1)+7,2)); wxTime DSTtime(GetLocalTime(wxDate(3,31,year).Previous(1)+7,2));
if (year<=1986) { if (year<=1986) {
// Previous Sunday // Previous Sunday
DSTtime = GetLocalTime(wxDate(4,30,year).Previous(1),2); DSTtime = GetLocalTime(wxDate(4,30,year).Previous(1),2);
if (year==1974) DSTtime = GetLocalTime(wxDate(1,6,1974),2); if (year==1974) DSTtime = GetLocalTime(wxDate(1,6,1974),2);
if (year==1975) DSTtime = GetLocalTime(wxDate(2,23,1975),2); if (year==1975) DSTtime = GetLocalTime(wxDate(2,23,1975),2);
} }
return DSTtime; return DSTtime;
@@ -216,8 +213,8 @@ wxTime wxTime::GetEndDST(unsigned year)
ends in the specified year. ends in the specified year.
*/ */
{ {
wxTime STDtime(GetLocalTime(wxDate(10,31,year).Previous(1),2-1)); wxTime STDtime(GetLocalTime(wxDate(10,31,year).Previous(1),2-1));
return STDtime; return STDtime;
} }
bool wxTime::IsDST() const bool wxTime::IsDST() const
@@ -229,12 +226,12 @@ bool wxTime::IsDST() const
long daycount = (long)(sec/seconds_in_day); long daycount = (long)(sec/seconds_in_day);
// At this point, daycount is the number of days from 1/1/1901. // At this point, daycount is the number of days from 1/1/1901.
// Need to convert to julian date (which starts at 1/1/4713 B.C.) // Need to convert to julian date (which starts at 1/1/4713 B.C.)
wxDate date(1,1,1901); wxDate date(1,1,1901);
date += daycount; date += daycount;
unsigned year = date.GetYear(); unsigned year = date.GetYear();
if (DST_OBSERVED) if (DST_OBSERVED)
{ {
if (*this >= GetBeginDST(year)) if (*this >= GetBeginDST(year))
if (*this < GetEndDST(year)) return TRUE; if (*this < GetEndDST(year)) return TRUE;
@@ -247,7 +244,7 @@ wxTime wxTime::GetLocalTime() const
Adjusts this GM Time for local time zone and Daylight Savings Time. Adjusts this GM Time for local time zone and Daylight Savings Time.
*/ */
{ {
wxTime local_time(sec-TIME_ZONE); wxTime local_time(sec-TIME_ZONE);
if (local_time.IsDST()) local_time.sec += 3600; if (local_time.IsDST()) local_time.sec += 3600;
return local_time; return local_time;
} }
@@ -255,7 +252,7 @@ wxTime wxTime::GetLocalTime() const
minuteTy wxTime::GetMinute() const minuteTy wxTime::GetMinute() const
/* /*
Return the minute of this wxTime in local time; i.e., adjust Return the minute of this wxTime in local time; i.e., adjust
for time zone and Daylight Savings Time. for time zone and Daylight Savings Time.
*/ */
{ {
return GetLocalTime().GetMinuteGMT(); return GetLocalTime().GetMinuteGMT();
@@ -266,7 +263,7 @@ minuteTy wxTime::GetMinuteGMT() const
Return the minute of this wxTime in GMT. Return the minute of this wxTime in GMT.
*/ */
{ {
return (minuteTy)(((sec % 86400) % 3600) / 60); return (minuteTy)(((sec % 86400) % 3600) / 60);
} }
secondTy wxTime::GetSecond() const secondTy wxTime::GetSecond() const
@@ -274,7 +271,7 @@ secondTy wxTime::GetSecond() const
Return the second of this wxTime. Return the second of this wxTime.
*/ */
{ {
return (secondTy)(((sec % 86400) % 3600) % 60); return (secondTy)(((sec % 86400) % 3600) % 60);
} }
secondTy wxTime::GetSecondGMT() const secondTy wxTime::GetSecondGMT() const
@@ -318,7 +315,7 @@ wxTime wxTime::Max(const wxTime& t) const
wxTime wxTime::Min(const wxTime& t) const wxTime wxTime::Min(const wxTime& t) const
{ {
if (t > *this) return *this; if (t > *this) return *this;
return t; return t;
} }
#ifndef __SALFORDC__ #ifndef __SALFORDC__
@@ -329,46 +326,46 @@ wxTime::operator char *(void)
#endif #endif
void wxTime::SetFormat(const wxTime::tFormat lFormat, void wxTime::SetFormat(const wxTime::tFormat lFormat,
const wxTime::tPrecision lPrecision) { const wxTime::tPrecision lPrecision) {
wxTime::Format = lFormat; wxTime::Format = lFormat;
wxTime::Precision = lPrecision; wxTime::Precision = lPrecision;
} }
char *wxTime::FormatTime() const { char *wxTime::FormatTime() const {
static char timeBuf[30]; static char timeBuf[30];
unsigned hh(GetHour()); unsigned hh(GetHour());
switch (Format) { switch (Format) {
case wx12h: case wx12h:
hh -= 12; hh -= 12;
break; break;
case wx24h: case wx24h:
break; break;
} }
switch (Precision) { switch (Precision) {
case wxStdMinSec: case wxStdMinSec:
sprintf(timeBuf,"%2d:%02d:%02d",hh,GetMinute(),GetSecond()); sprintf(timeBuf,"%2d:%02d:%02d",hh,GetMinute(),GetSecond());
break; break;
case wxStdMin: case wxStdMin:
sprintf(timeBuf,"%2d:%02d",hh,GetMinute()); sprintf(timeBuf,"%2d:%02d",hh,GetMinute());
break; break;
} }
if (Format == wx12h) if (Format == wx12h)
if (GetHour() <= 12) if (GetHour() <= 12)
strcat(timeBuf,_("am")); strcat(timeBuf,_("am"));
else else
strcat(timeBuf,_("pm")); strcat(timeBuf,_("pm"));
return timeBuf; return timeBuf;
} }
/* /*
int wxTime::compare(const Object& ob) const int wxTime::compare(const Object& ob) const
{ {
assertArgSpecies(ob,classDesc,"compare"); assertArgSpecies(ob,classDesc,"compare");
register clockTy t = castdown(ob).sec; register clockTy t = castdown(ob).sec;
if (sec < t) return -1; if (sec < t) return -1;
if (sec > t) return 1; if (sec > t) return 1;
@@ -392,16 +389,16 @@ void wxTime::printOn(ostream& strm) const
wxDate(*this).printOn(strm); wxDate(*this).printOn(strm);
strm << ' ' << ((hh <= 12) ? hh : hh-12) << ':' strm << ' ' << ((hh <= 12) ? hh : hh-12) << ':'
<< setfill('0') << setw(2) << GetMinute() << ':' << setfill('0') << setw(2) << GetMinute() << ':'
<< setfill('0') << setw(2) << GetSecond() << ' '; << setfill('0') << setw(2) << GetSecond() << ' ';
if (hh < 12) strm << _("am"); if (hh < 12) strm << _("am");
else strm << _("pm"); else strm << _("pm");
} }
wxTime::wxTime(OIOin& strm) wxTime::wxTime(OIOin& strm)
: BASE(strm) : BASE(strm)
{ {
unsigned long usec; unsigned long usec;
strm >> sec >> usec; strm >> sec >> usec;
} }
void wxTime::storer(OIOout& strm) const void wxTime::storer(OIOout& strm) const
@@ -412,16 +409,16 @@ void wxTime::storer(OIOout& strm) const
wxTime::wxTime(OIOifd& fd) wxTime::wxTime(OIOifd& fd)
: BASE(fd) : BASE(fd)
{ {
unsigned long usec; unsigned long usec;
fd >> sec >> usec; fd >> sec >> usec;
} }
void wxTime::storer(OIOofd& fd) const void wxTime::storer(OIOofd& fd) const
{ {
BASE::storer(fd); BASE::storer(fd);
fd << sec << 0l; fd << sec << 0l;
} }
*/ */

View File

@@ -6,7 +6,7 @@
// Created: 29/01/98 // Created: 29/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart // Copyright: (c) 1998 Julian Smart
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -30,15 +30,12 @@
#include "wx/textdlg.h" #include "wx/textdlg.h"
#endif #endif
#include "wx/ioswrap.h"
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <iostream.h> #include <fstream.h>
#include <fstream.h>
#else #else
#include <iostream> #include <fstream>
#include <fstream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif #endif
#include <ctype.h> #include <ctype.h>
@@ -46,9 +43,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if !defined(__WATCOMC__) #if !defined(__WATCOMC__)
#if !(defined(_MSC_VER) && (_MSC_VER > 800)) #if !(defined(_MSC_VER) && (_MSC_VER > 800))
#include <errno.h> #include <errno.h>
#endif #endif
#endif #endif
#include <time.h> #include <time.h>
#ifndef __MWERKS__ #ifndef __MWERKS__
@@ -92,14 +89,14 @@ int strncasecmp(const char *str_1, const char *str_2, size_t maxchar)
{ {
register char c1, c2; register char c1, c2;
while( maxchar--) while( maxchar--)
{ {
c1 = tolower(*str_1++); c1 = tolower(*str_1++);
c2 = tolower(*str_2++); c2 = tolower(*str_2++);
if ( !c1 || c1!=c2 ) if ( !c1 || c1!=c2 )
return c1 - c2; return c1 - c2;
} ; } ;
return 0 ; return 0 ;
@@ -163,14 +160,6 @@ int strncasecmp(const char *str_1, const char *str_2, size_t maxchar)
#endif #endif
#endif #endif
#ifdef _MSC_VER
#pragma warning (disable : 4245)
#endif
#ifdef _MSC_VER
#pragma warning (default : 4245)
#endif
#else #else
// This declaration is missing in SunOS! // This declaration is missing in SunOS!
// (Yes, I know it is NOT ANSI-C but its in BSD libc) // (Yes, I know it is NOT ANSI-C but its in BSD libc)
@@ -181,7 +170,7 @@ extern "C"
int strncasecmp (const char *, const char *, size_t); int strncasecmp (const char *, const char *, size_t);
} }
#endif #endif
#endif /* __WXMSW__ */ #endif /* __WXMSW__ */
char * char *
@@ -191,7 +180,7 @@ copystring (const char *s)
size_t len = strlen (s) + 1; size_t len = strlen (s) + 1;
char *news = new char[len]; char *news = new char[len];
memcpy (news, s, len); // Should be the fastest memcpy (news, s, len); // Should be the fastest
return news; return news;
} }
@@ -199,7 +188,7 @@ copystring (const char *s)
// Id generation // Id generation
static long wxCurrentId = 100; static long wxCurrentId = 100;
long long
wxNewId (void) wxNewId (void)
{ {
return wxCurrentId++; return wxCurrentId++;
@@ -208,21 +197,21 @@ wxNewId (void)
long long
wxGetCurrentId(void) { return wxCurrentId; } wxGetCurrentId(void) { return wxCurrentId; }
void void
wxRegisterId (long id) wxRegisterId (long id)
{ {
if (id >= wxCurrentId) if (id >= wxCurrentId)
wxCurrentId = id + 1; wxCurrentId = id + 1;
} }
void void
StringToFloat (char *s, float *number) StringToFloat (char *s, float *number)
{ {
if (s && *s && number) if (s && *s && number)
*number = (float) strtod (s, (char **) NULL); *number = (float) strtod (s, (char **) NULL);
} }
void void
StringToDouble (char *s, double *number) StringToDouble (char *s, double *number)
{ {
if (s && *s && number) if (s && *s && number)
@@ -248,14 +237,14 @@ DoubleToString (double number, const char *fmt)
return buf; return buf;
} }
void void
StringToInt (char *s, int *number) StringToInt (char *s, int *number)
{ {
if (s && *s && number) if (s && *s && number)
*number = (int) strtol (s, (char **) NULL, 10); *number = (int) strtol (s, (char **) NULL, 10);
} }
void void
StringToLong (char *s, long *number) StringToLong (char *s, long *number)
{ {
if (s && *s && number) if (s && *s && number)
@@ -288,7 +277,7 @@ static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A'
int wxHexToDec(const wxString& buf) int wxHexToDec(const wxString& buf)
{ {
int firstDigit, secondDigit; int firstDigit, secondDigit;
if (buf.GetChar(0) >= 'A') if (buf.GetChar(0) >= 'A')
firstDigit = buf.GetChar(0) - 'A' + 10; firstDigit = buf.GetChar(0) - 'A' + 10;
else else
@@ -298,7 +287,7 @@ int wxHexToDec(const wxString& buf)
secondDigit = buf.GetChar(1) - 'A' + 10; secondDigit = buf.GetChar(1) - 'A' + 10;
else else
secondDigit = buf.GetChar(1) - '0'; secondDigit = buf.GetChar(1) - '0';
return firstDigit * 16 + secondDigit; return firstDigit * 16 + secondDigit;
} }
@@ -321,7 +310,7 @@ wxString wxDecToHex(int dec)
} }
// Match a string INDEPENDENT OF CASE // Match a string INDEPENDENT OF CASE
bool bool
StringMatch (char *str1, char *str2, bool subString, bool exact) StringMatch (char *str1, char *str2, bool subString, bool exact)
{ {
if (str1 == NULL || str2 == NULL) if (str1 == NULL || str2 == NULL)
@@ -338,15 +327,15 @@ StringMatch (char *str1, char *str2, bool subString, bool exact)
// Search for str1 in str2 // Search for str1 in str2
// Slow .... but acceptable for short strings // Slow .... but acceptable for short strings
for (i = 0; i <= len2 - len1; i++) for (i = 0; i <= len2 - len1; i++)
{ {
if (strncasecmp (str1, str2 + i, len1) == 0) if (strncasecmp (str1, str2 + i, len1) == 0)
return TRUE; return TRUE;
} }
} }
else if (exact) else if (exact)
{ {
if (strcasecmp (str1, str2) == 0) if (strcasecmp (str1, str2) == 0)
return TRUE; return TRUE;
} }
else else
{ {
@@ -354,7 +343,7 @@ StringMatch (char *str1, char *str2, bool subString, bool exact)
int len2 = strlen (str2); int len2 = strlen (str2);
if (strncasecmp (str1, str2, wxMin (len1, len2)) == 0) if (strncasecmp (str1, str2, wxMin (len1, len2)) == 0)
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@@ -365,7 +354,7 @@ StringMatch (char *str1, char *str2, bool subString, bool exact)
wxString wxNow( void ) wxString wxNow( void )
{ {
time_t now = time((time_t *) NULL); time_t now = time((time_t *) NULL);
char *date = ctime(&now); char *date = ctime(&now);
date[24] = '\0'; date[24] = '\0';
return wxString(date); return wxString(date);
} }
@@ -400,31 +389,31 @@ char *wxStripMenuCodes (char *in, char *out)
{ {
if (!in) if (!in)
return (char *) NULL; return (char *) NULL;
if (!out) if (!out)
out = copystring(in); out = copystring(in);
char *tmpOut = out; char *tmpOut = out;
while (*in) while (*in)
{ {
if (*in == '&') if (*in == '&')
{ {
// Check && -> &, &x -> x // Check && -> &, &x -> x
if (*++in == '&') if (*++in == '&')
*out++ = *in++; *out++ = *in++;
} }
else if (*in == '\t') else if (*in == '\t')
{ {
// Remove all stuff after \t in X mode, and let the stuff as is // Remove all stuff after \t in X mode, and let the stuff as is
// in Windows mode. // in Windows mode.
// Accelerators are handled in wx_item.cc for Motif, and are not // Accelerators are handled in wx_item.cc for Motif, and are not
// YET supported in XView // YET supported in XView
break; break;
} }
else else
*out++ = *in++; *out++ = *in++;
} // while } // while
*out = '\0'; *out = '\0';
@@ -463,12 +452,12 @@ wxFindWindowByLabel (const wxString& title, wxWindow * parent)
else else
{ {
for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ()) for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ())
{ {
wxWindow *win = (wxWindow *) node->Data (); wxWindow *win = (wxWindow *) node->Data ();
wxWindow *retwin = wxFindWindowByLabel1 (title, win); wxWindow *retwin = wxFindWindowByLabel1 (title, win);
if (retwin) if (retwin)
return retwin; return retwin;
} // for() } // for()
} }
return (wxWindow *) NULL; return (wxWindow *) NULL;
@@ -481,22 +470,22 @@ wxFindWindowByLabel1 (const wxString& title, wxWindow * parent)
if (parent) if (parent)
{ {
if (parent->GetLabel() == title) if (parent->GetLabel() == title)
return parent; return parent;
} }
if (parent) if (parent)
{ {
for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ()) for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
{ {
wxWindow *win = (wxWindow *) node->Data (); wxWindow *win = (wxWindow *) node->Data ();
wxWindow *retwin = wxFindWindowByLabel1 (title, win); wxWindow *retwin = wxFindWindowByLabel1 (title, win);
if (retwin) if (retwin)
return retwin; return retwin;
} // for() } // for()
} }
return (wxWindow *) NULL; // Not found return (wxWindow *) NULL; // Not found
} }
@@ -518,12 +507,12 @@ wxFindWindowByName (const wxString& title, wxWindow * parent)
else else
{ {
for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ()) for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ())
{ {
wxWindow *win = (wxWindow *) node->Data (); wxWindow *win = (wxWindow *) node->Data ();
wxWindow *retwin = wxFindWindowByName1 (title, win); wxWindow *retwin = wxFindWindowByName1 (title, win);
if (retwin) if (retwin)
return retwin; return retwin;
} // for() } // for()
} }
// Failed? Try by label instead. // Failed? Try by label instead.
@@ -536,28 +525,28 @@ wxFindWindowByName1 (const wxString& title, wxWindow * parent)
{ {
if (parent) if (parent)
{ {
if ( parent->GetName() == title ) if ( parent->GetName() == title )
return parent; return parent;
} }
if (parent) if (parent)
{ {
for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ()) for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
{ {
wxWindow *win = (wxWindow *) node->Data (); wxWindow *win = (wxWindow *) node->Data ();
wxWindow *retwin = wxFindWindowByName1 (title, win); wxWindow *retwin = wxFindWindowByName1 (title, win);
if (retwin) if (retwin)
return retwin; return retwin;
} // for() } // for()
} }
return (wxWindow *) NULL; // Not found return (wxWindow *) NULL; // Not found
} }
// Returns menu item id or -1 if none. // Returns menu item id or -1 if none.
int int
wxFindMenuItemId (wxFrame * frame, const wxString& menuString, const wxString& itemString) wxFindMenuItemId (wxFrame * frame, const wxString& menuString, const wxString& itemString)
{ {
wxMenuBar *menuBar = frame->GetMenuBar (); wxMenuBar *menuBar = frame->GetMenuBar ();
@@ -572,12 +561,12 @@ On Fri, 21 Jul 1995, Paul Craven wrote:
> Is there a way to find the path of running program's executable? I can get > Is there a way to find the path of running program's executable? I can get
> my home directory, and the current directory, but I don't know how to get the > my home directory, and the current directory, but I don't know how to get the
> executable directory. > executable directory.
> >
The code below (warty as it is), does what you want on most Unix, The code below (warty as it is), does what you want on most Unix,
DOS, and Mac platforms (it's from the ALS Prolog main). DOS, and Mac platforms (it's from the ALS Prolog main).
|| Ken Bowen Applied Logic Systems, Inc. PO Box 180, || Ken Bowen Applied Logic Systems, Inc. PO Box 180,
||==== Voice: +1 (617)965-9191 Newton Centre, ||==== Voice: +1 (617)965-9191 Newton Centre,
|| FAX: +1 (617)965-1636 MA 02159 USA || FAX: +1 (617)965-1636 MA 02159 USA
Email: ken@als.com WWW: http://www.als.com Email: ken@als.com WWW: http://www.als.com
@@ -590,8 +579,8 @@ DOS, and Mac platforms (it's from the ALS Prolog main).
/*--------------------------------------------------------------------* /*--------------------------------------------------------------------*
| whereami is given a filename f in the form: whereami(argv[0]) | whereami is given a filename f in the form: whereami(argv[0])
| It returns the directory in which the executable file (containing | It returns the directory in which the executable file (containing
| this code [main.c] ) may be found. A dot will be returned to indicate | this code [main.c] ) may be found. A dot will be returned to indicate
| the current directory. | the current directory.
*--------------------------------------------------------------------*/ *--------------------------------------------------------------------*/
@@ -599,7 +588,7 @@ static void
whereami(name) whereami(name)
char *name; char *name;
{ {
register char *cutoff = NULL; /* stifle -Wall */ register char *cutoff = NULL; /* stifle -Wall */
register char *s; register char *s;
register char *t; register char *t;
int cc; int cc;
@@ -612,117 +601,117 @@ whereami(name)
if (access(name, R_OK) == 0) { if (access(name, R_OK) == 0) {
/*-------------------------------------------------------------* /*-------------------------------------------------------------*
* The file was accessible without any other work. But the current * The file was accessible without any other work. But the current
* working directory might change on us, so if it was accessible * working directory might change on us, so if it was accessible
* through the cwd, then we should get it for later accesses. * through the cwd, then we should get it for later accesses.
*-------------------------------------------------------------*/ *-------------------------------------------------------------*/
t = imagedir; t = imagedir;
if (!absolute_pathname(name)) { if (!absolute_pathname(name)) {
#if defined(DOS) || defined(__WIN32__) #if defined(DOS) || defined(__WIN32__)
int drive; int drive;
char *newrbuf; char *newrbuf;
newrbuf = imagedir; newrbuf = imagedir;
#ifndef __DJGPP__ #ifndef __DJGPP__
if (*(name + 1) == ':') { if (*(name + 1) == ':') {
if (*name >= 'a' && *name <= 'z') if (*name >= 'a' && *name <= 'z')
drive = (int) (*name - 'a' + 1); drive = (int) (*name - 'a' + 1);
else else
drive = (int) (*name - 'A' + 1); drive = (int) (*name - 'A' + 1);
*newrbuf++ = *name; *newrbuf++ = *name;
*newrbuf++ = *(name + 1); *newrbuf++ = *(name + 1);
*newrbuf++ = DIR_SEPARATOR; *newrbuf++ = DIR_SEPARATOR;
} }
else { else {
drive = 0; drive = 0;
*newrbuf++ = DIR_SEPARATOR; *newrbuf++ = DIR_SEPARATOR;
} }
if (getcwd(newrbuf, drive) == 0) { /* } */ if (getcwd(newrbuf, drive) == 0) { /* } */
#else #else
if (getcwd(newrbuf, 1024) == 0) { /* } */ if (getcwd(newrbuf, 1024) == 0) { /* } */
#endif #endif
#else /* DOS */ #else /* DOS */
#ifdef HAVE_GETWD #ifdef HAVE_GETWD
if (getwd(imagedir) == 0) { /* } */ if (getwd(imagedir) == 0) { /* } */
#else /* !HAVE_GETWD */ #else /* !HAVE_GETWD */
if (getcwd(imagedir, 1024) == 0) { if (getcwd(imagedir, 1024) == 0) {
#endif /* !HAVE_GETWD */ #endif /* !HAVE_GETWD */
#endif /* DOS */ #endif /* DOS */
fatal_error(FE_GETCWD, 0); fatal_error(FE_GETCWD, 0);
} }
for (; *t; t++) /* Set t to end of buffer */ for (; *t; t++) /* Set t to end of buffer */
; ;
if (*(t - 1) == DIR_SEPARATOR) /* leave slash if already if (*(t - 1) == DIR_SEPARATOR) /* leave slash if already
* last char * last char
*/ */
cutoff = t - 1; cutoff = t - 1;
else { else {
cutoff = t; /* otherwise put one in */ cutoff = t; /* otherwise put one in */
*t++ = DIR_SEPARATOR; *t++ = DIR_SEPARATOR;
} }
} }
#if (!defined(__MAC__) && !defined(__DJGPP__) && !defined(__GO32__) && !defined(__WIN32__)) #if (!defined(__MAC__) && !defined(__DJGPP__) && !defined(__GO32__) && !defined(__WIN32__))
else else
(*t++ = DIR_SEPARATOR); (*t++ = DIR_SEPARATOR);
#endif #endif
/*-------------------------------------------------------------* /*-------------------------------------------------------------*
* Copy the rest of the string and set the cutoff if it was not * Copy the rest of the string and set the cutoff if it was not
* already set. If the first character of name is a slash, cutoff * already set. If the first character of name is a slash, cutoff
* is not presently set but will be on the first iteration of the * is not presently set but will be on the first iteration of the
* loop below. * loop below.
*-------------------------------------------------------------*/ *-------------------------------------------------------------*/
for ((*name == DIR_SEPARATOR ? (s = name+1) : (s = name));;) { for ((*name == DIR_SEPARATOR ? (s = name+1) : (s = name));;) {
if (*s == DIR_SEPARATOR) if (*s == DIR_SEPARATOR)
cutoff = t; cutoff = t;
if (!(*t++ = *s++)) if (!(*t++ = *s++))
break; break;
} }
} }
else { else {
/*-------------------------------------------------------------* /*-------------------------------------------------------------*
* Get the path list from the environment. If the path list is * Get the path list from the environment. If the path list is
* inaccessible for any reason, leave with fatal error. * inaccessible for any reason, leave with fatal error.
*-------------------------------------------------------------*/ *-------------------------------------------------------------*/
#ifdef __MAC__ #ifdef __MAC__
if ((s = getenv("Commands")) == (char *) 0) if ((s = getenv("Commands")) == (char *) 0)
#else #else
if ((s = getenv("PATH")) == (char *) 0) if ((s = getenv("PATH")) == (char *) 0)
#endif #endif
fatal_error(FE_PATH, 0); fatal_error(FE_PATH, 0);
/* /*
* Copy path list into ebuf and set the source pointer to the * Copy path list into ebuf and set the source pointer to the
* beginning of this buffer. * beginning of this buffer.
*/ */
strcpy(ebuf, s); strcpy(ebuf, s);
s = ebuf; s = ebuf;
for (;;) { for (;;) {
t = imagedir; t = imagedir;
while (*s && *s != PATH_SEPARATOR) while (*s && *s != PATH_SEPARATOR)
*t++ = *s++; *t++ = *s++;
if (t > imagedir && *(t - 1) == DIR_SEPARATOR) if (t > imagedir && *(t - 1) == DIR_SEPARATOR)
; /* do nothing -- slash already is in place */ ; /* do nothing -- slash already is in place */
else else
*t++ = DIR_SEPARATOR; /* put in the slash */ *t++ = DIR_SEPARATOR; /* put in the slash */
cutoff = t - 1; /* set cutoff */ cutoff = t - 1; /* set cutoff */
strcpy(t, name); strcpy(t, name);
if (access(imagedir, R_OK) == 0) if (access(imagedir, R_OK) == 0)
break; break;
if (*s) if (*s)
s++; /* advance source pointer */ s++; /* advance source pointer */
else else
fatal_error(FE_INFND, 0); fatal_error(FE_INFND, 0);
} }
} }
@@ -735,26 +724,26 @@ whereami(name)
#ifdef HAVE_SYMLINK #ifdef HAVE_SYMLINK
while ((cc = readlink(imagedir, ebuf, 512)) != -1) { while ((cc = readlink(imagedir, ebuf, 512)) != -1) {
ebuf[cc] = 0; ebuf[cc] = 0;
s = ebuf; s = ebuf;
if (*s == DIR_SEPARATOR) { if (*s == DIR_SEPARATOR) {
t = imagedir; t = imagedir;
} }
else { else {
t = cutoff + 1; t = cutoff + 1;
} }
for (;;) { for (;;) {
if (*s == DIR_SEPARATOR) if (*s == DIR_SEPARATOR)
cutoff = t; /* mark the last slash seen */ cutoff = t; /* mark the last slash seen */
if (!(*t++ = *s++)) /* copy the character */ if (!(*t++ = *s++)) /* copy the character */
break; break;
} }
} }
#endif /* HAVE_SYMLINK */ #endif /* HAVE_SYMLINK */
strcpy(imagename, cutoff + 1); /* keep the image name */ strcpy(imagename, cutoff + 1); /* keep the image name */
*(cutoff + 1) = 0; /* chop off the filename part */ *(cutoff + 1) = 0; /* chop off the filename part */
} }
#endif #endif
@@ -801,14 +790,14 @@ wxString wxGetTextFromUser(const wxString& message, const wxString& caption,
} }
#ifdef __MWERKS__ #ifdef __MWERKS__
char *strdup(const char *s) char *strdup(const char *s)
{ {
return strcpy( (char*) malloc( strlen( s ) + 1 ) , s ) ; return strcpy( (char*) malloc( strlen( s ) + 1 ) , s ) ;
} }
int isascii( int c ) int isascii( int c )
{ {
return ( c >= 0 && c < 128 ) ; return ( c >= 0 && c < 128 ) ;
} }
#endif #endif

View File

@@ -6,7 +6,7 @@
// Created: 10/09/98 // Created: 10/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c)
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -17,16 +17,13 @@
#include "wx/wxprec.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
# include <fstream.h> # include <fstream.h>
#else #else
# include <fstream> # include <fstream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif #endif
#include "wx/stream.h" #include "wx/stream.h"

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -21,12 +21,9 @@
#endif #endif
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <fstream.h> #include <fstream.h>
#else #else
#include <fstream> #include <fstream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif #endif
#include <stdarg.h> #include <stdarg.h>

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -67,8 +67,8 @@ IMPLEMENT_CLASS(wxXLPHelpController, wxHelpControllerBase)
#endif #endif
// suppress annoying warning "'this' used in base member init list" (so what?) // suppress annoying warning "'this' used in base member init list" (so what?)
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(disable: 4355) #pragma warning(disable: 4355)
#endif // Visual C++ #endif // Visual C++
wxXLPHelpController::wxXLPHelpController(void) wxXLPHelpController::wxXLPHelpController(void)
@@ -78,8 +78,8 @@ wxXLPHelpController::wxXLPHelpController(void)
helpRunning = FALSE; helpConnection = NULL; helpRunning = FALSE; helpConnection = NULL;
} }
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(default: 4355) #pragma warning(default: 4355)
#endif // Visual C++ #endif // Visual C++
wxXLPHelpController::~wxXLPHelpController(void) wxXLPHelpController::~wxXLPHelpController(void)
@@ -118,21 +118,21 @@ bool wxXLPHelpController::LoadFile(const wxString& file)
bool wxXLPHelpController::DisplayContents(void) bool wxXLPHelpController::DisplayContents(void)
{ {
if (!helpRunning) if (!helpRunning)
{ {
if (!Run()) if (!Run())
return FALSE; return FALSE;
} }
if (helpConnection) if (helpConnection)
return helpConnection->Execute("s -1"); return helpConnection->Execute("s -1");
else else
return FALSE; return FALSE;
} }
bool wxXLPHelpController::DisplaySection(int section) bool wxXLPHelpController::DisplaySection(int section)
{ {
if (!helpRunning) if (!helpRunning)
{ {
if (!Run()) if (!Run())
return FALSE; return FALSE;
} }
@@ -146,7 +146,7 @@ bool wxXLPHelpController::DisplaySection(int section)
bool wxXLPHelpController::DisplayBlock(long block) bool wxXLPHelpController::DisplayBlock(long block)
{ {
if (!helpRunning) if (!helpRunning)
{ {
if (!Run()) if (!Run())
return FALSE; return FALSE;
} }
@@ -160,7 +160,7 @@ bool wxXLPHelpController::DisplayBlock(long block)
bool wxXLPHelpController::KeywordSearch(const wxString& k) bool wxXLPHelpController::KeywordSearch(const wxString& k)
{ {
if (!helpRunning) if (!helpRunning)
{ {
if (!Run()) if (!Run())
return FALSE; return FALSE;
} }

View File

@@ -227,7 +227,7 @@ bool wxApp::Initialize()
// This is to foil optimizations in Visual C++ that throw out dummy.obj. // This is to foil optimizations in Visual C++ that throw out dummy.obj.
// PLEASE DO NOT ALTER THIS. // PLEASE DO NOT ALTER THIS.
#if defined(_MSC_VER) && !defined(WXMAKINGDLL) #if defined(__VISUALC__) && !defined(WXMAKINGDLL)
extern char wxDummyChar; extern char wxDummyChar;
if (wxDummyChar) wxDummyChar++; if (wxDummyChar) wxDummyChar++;
#endif #endif
@@ -545,7 +545,7 @@ void wxApp::CleanUp()
#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL)) #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
// temporarily disable this warning // temporarily disable this warning
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(disable: 4715) // not all control paths return a value #pragma warning(disable: 4715) // not all control paths return a value
#endif // Visual C++ #endif // Visual C++
@@ -565,10 +565,10 @@ int wxEntry(WXHINSTANCE hInstance,
// FIXME other compilers must support Win32 SEH (structured exception // FIXME other compilers must support Win32 SEH (structured exception
// handling) too, just find the appropriate keyword in their docs! // handling) too, just find the appropriate keyword in their docs!
// Please note that it's _not_ the same as C++ exceptions! // Please note that it's _not_ the same as C++ exceptions!
#if !defined(__WXDEBUG__) && defined(_MSC_VER) && !defined(__MWERKS__) #if !defined(__WXDEBUG__) && defined(__VISUALC__)
#define CATCH_PROGRAM_EXCEPTIONS #define CATCH_PROGRAM_EXCEPTIONS
__try { __try {
#else #else
#undef CATCH_PROGRAM_EXCEPTIONS #undef CATCH_PROGRAM_EXCEPTIONS
#endif #endif
@@ -656,7 +656,7 @@ int wxEntry(WXHINSTANCE hInstance,
} }
// restore warning state // restore warning state
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(default: 4715) // not all control paths return a value #pragma warning(default: 4715) // not all control paths return a value
#endif // Visual C++ #endif // Visual C++
@@ -1123,6 +1123,6 @@ HINSTANCE wxGetInstance()
// For some reason, with MSVC++ 1.5, WinMain isn't linked in properly // For some reason, with MSVC++ 1.5, WinMain isn't linked in properly
// if in a separate file. So include it here to ensure it's linked. // if in a separate file. So include it here to ensure it's linked.
#if (defined(_MSC_VER) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__TWIN32__)) #if (defined(__VISUALC__) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__TWIN32__))
#include "main.cpp" #include "main.cpp"
#endif #endif

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Microsoft, Julian Smart and Markus Holzem // Copyright: (c) Microsoft, Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -29,13 +29,14 @@
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
#include <stdio.h> #include <stdio.h>
#include <wx/msw/dibutils.h>
#include "wx/msw/dibutils.h"
#if defined(__WIN32__) #if defined(__WIN32__)
#if !defined(__MWERKS__) && !defined(__SALFORDC__) #if !defined(__MWERKS__) && !defined(__SALFORDC__)
#include <memory.h> // for _fmemcpy() #include <memory.h> // for _fmemcpy()
#endif #endif
#define _huge #define _huge
#ifndef hmemcpy #ifndef hmemcpy
#define hmemcpy memcpy #define hmemcpy memcpy
#endif #endif
@@ -81,7 +82,7 @@ void ClearSystemPalette(void)
for(Counter = 0; Counter < 256; Counter++) for(Counter = 0; Counter < 256; Counter++)
{ {
Palette.aEntries[Counter].peRed = 0; Palette.aEntries[Counter].peRed = 0;
Palette.aEntries[Counter].peGreen = 0; Palette.aEntries[Counter].peGreen = 0;
Palette.aEntries[Counter].peBlue = 0; Palette.aEntries[Counter].peBlue = 0;
Palette.aEntries[Counter].peFlags = PC_NOCOLLAPSE; Palette.aEntries[Counter].peFlags = PC_NOCOLLAPSE;
} }
@@ -92,8 +93,8 @@ void ClearSystemPalette(void)
if (ScreenPalette) if (ScreenPalette)
{ {
ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE); ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE);
nMapped = RealizePalette(ScreenDC); nMapped = RealizePalette(ScreenDC);
ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE); ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE);
bOK = DeleteObject(ScreenPalette); bOK = DeleteObject(ScreenPalette);
} }
@@ -114,14 +115,14 @@ void ClearSystemPalette(void)
int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi) int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi)
{ {
HFILE fh; HFILE fh;
OFSTRUCT of; OFSTRUCT of;
fh = OpenFile(szFile, &of, OF_WRITE | OF_CREATE); fh = OpenFile(szFile, &of, OF_WRITE | OF_CREATE);
if (!fh) { if (!fh) {
// printf("la regamos0"); // printf("la regamos0");
return 0; return 0;
} }
long size = DibSize(lpbi); long size = DibSize(lpbi);
@@ -133,19 +134,19 @@ int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi)
bmf.bfReserved1 = 0; bmf.bfReserved1 = 0;
bmf.bfReserved2 = 0; bmf.bfReserved2 = 0;
bmf.bfOffBits = sizeof(bmf) + (char far*)(DibPtr(lpbi)) - (char far*)lpbi; bmf.bfOffBits = sizeof(bmf) + (char far*)(DibPtr(lpbi)) - (char far*)lpbi;
#if defined( __WATCOMC__) || defined(_MSC_VER) || defined(__SC__) || defined(__SALFORDC__) #if defined( __WATCOMC__) || defined(__VISUALC__) || defined(__SC__) || defined(__SALFORDC__)
if (_hwrite(fh, (LPCSTR)(&bmf), sizeof(bmf))<0 || if (_hwrite(fh, (LPCSTR)(&bmf), sizeof(bmf))<0 ||
_hwrite(fh, (LPCSTR)lpbi, size)<0) { _hwrite(fh, (LPCSTR)lpbi, size)<0) {
_lclose(fh); _lclose(fh);
// printf("la regamos1"); // printf("la regamos1");
return 0; return 0;
} }
#else #else
if (_hwrite(fh, (LPBYTE)(&bmf), sizeof(bmf))<0 || if (_hwrite(fh, (LPBYTE)(&bmf), sizeof(bmf))<0 ||
_hwrite(fh, (LPBYTE)lpbi, size)<0) { _hwrite(fh, (LPBYTE)lpbi, size)<0) {
_lclose(fh); _lclose(fh);
// printf("la regamos1"); // printf("la regamos1");
return 0; return 0;
} }
#endif #endif
@@ -155,50 +156,50 @@ int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi)
PDIB DibOpenFile(LPSTR szFile) PDIB DibOpenFile(LPSTR szFile)
{ {
HFILE fh; HFILE fh;
DWORD dwLen; DWORD dwLen;
DWORD dwBits; DWORD dwBits;
PDIB pdib; PDIB pdib;
LPVOID p; LPVOID p;
OFSTRUCT of; OFSTRUCT of;
#if defined(WIN32) || defined(_WIN32) #if defined(WIN32) || defined(_WIN32)
#define GetCurrentInstance() GetModuleHandle(NULL) #define GetCurrentInstance() GetModuleHandle(NULL)
#else #else
#define GetCurrentInstance() (HINSTANCE)SELECTOROF((LPVOID)&of) #define GetCurrentInstance() (HINSTANCE)SELECTOROF((LPVOID)&of)
#endif #endif
fh = OpenFile(szFile, &of, OF_READ); fh = OpenFile(szFile, &of, OF_READ);
if (fh == -1) if (fh == -1)
{ {
HRSRC h; HRSRC h;
// TODO: Unicode version // TODO: Unicode version
#ifdef __WIN16__ #ifdef __WIN16__
h = FindResource(GetCurrentInstance(), szFile, RT_BITMAP); h = FindResource(GetCurrentInstance(), szFile, RT_BITMAP);
#else #else
h = FindResourceA(GetCurrentInstance(), szFile, RT_BITMAP); h = FindResourceA(GetCurrentInstance(), szFile, RT_BITMAP);
#endif #endif
#if defined(__WIN32__) #if defined(__WIN32__)
//!!! can we call GlobalFree() on this? is it the right format. //!!! can we call GlobalFree() on this? is it the right format.
//!!! can we write to this resource? //!!! can we write to this resource?
if (h) if (h)
return (PDIB)LockResource(LoadResource(GetCurrentInstance(), h)); return (PDIB)LockResource(LoadResource(GetCurrentInstance(), h));
#else #else
if (h) if (h)
fh = AccessResource(GetCurrentInstance(), h); fh = AccessResource(GetCurrentInstance(), h);
#endif #endif
} }
if (fh == -1) if (fh == -1)
return NULL; return NULL;
pdib = DibReadBitmapInfo(fh); pdib = DibReadBitmapInfo(fh);
if (!pdib) if (!pdib)
return NULL; return NULL;
/* How much memory do we need to hold the DIB */ /* How much memory do we need to hold the DIB */
@@ -207,11 +208,11 @@ PDIB DibOpenFile(LPSTR szFile)
/* Can we get more memory? */ /* Can we get more memory? */
p = GlobalReAllocPtr(pdib,dwLen,0); p = GlobalReAllocPtr(pdib,dwLen,0);
if (!p) if (!p)
{ {
GlobalFreePtr(pdib); GlobalFreePtr(pdib);
pdib = NULL; pdib = NULL;
} }
else else
@@ -221,8 +222,8 @@ PDIB DibOpenFile(LPSTR szFile)
if (pdib) if (pdib)
{ {
/* read in the bits */ /* read in the bits */
_hread(fh, (LPBYTE)pdib + (UINT)pdib->biSize + DibPaletteSize(pdib), dwBits); _hread(fh, (LPBYTE)pdib + (UINT)pdib->biSize + DibPaletteSize(pdib), dwBits);
} }
_lclose(fh); _lclose(fh);
@@ -468,7 +469,7 @@ PDIB DibCreate(int bits, int dx, int dy)
*pdw++ = 0x00000000; // 0000 black *pdw++ = 0x00000000; // 0000 black
*pdw++ = 0x00800000; // 0001 dark red *pdw++ = 0x00800000; // 0001 dark red
*pdw++ = 0x00008000; // 0010 dark green *pdw++ = 0x00008000; // 0010 dark green
*pdw++ = 0x00808000; // 0011 mustard *pdw++ = 0x00808000; // 0011 mustard
*pdw++ = 0x00000080; // 0100 dark blue *pdw++ = 0x00000080; // 0100 dark blue
*pdw++ = 0x00800080; // 0101 purple *pdw++ = 0x00800080; // 0101 purple
*pdw++ = 0x00008080; // 0110 dark turquoise *pdw++ = 0x00008080; // 0110 dark turquoise
@@ -476,7 +477,7 @@ PDIB DibCreate(int bits, int dx, int dy)
*pdw++ = 0x00808080; // 0111 dark gray *pdw++ = 0x00808080; // 0111 dark gray
*pdw++ = 0x00FF0000; // 1001 red *pdw++ = 0x00FF0000; // 1001 red
*pdw++ = 0x0000FF00; // 1010 green *pdw++ = 0x0000FF00; // 1010 green
*pdw++ = 0x00FFFF00; // 1011 yellow *pdw++ = 0x00FFFF00; // 1011 yellow
*pdw++ = 0x000000FF; // 1100 blue *pdw++ = 0x000000FF; // 1100 blue
*pdw++ = 0x00FF00FF; // 1101 pink (magenta) *pdw++ = 0x00FF00FF; // 1101 pink (magenta)
*pdw++ = 0x0000FFFF; // 1110 cyan *pdw++ = 0x0000FFFF; // 1110 cyan
@@ -583,69 +584,69 @@ static void hmemmove(BYTE _huge *d, BYTE _huge *s, LONG len)
BOOL DibMapToPalette(PDIB pdib, HPALETTE hpal) BOOL DibMapToPalette(PDIB pdib, HPALETTE hpal)
{ {
LPBITMAPINFOHEADER lpbi; LPBITMAPINFOHEADER lpbi;
PALETTEENTRY pe; PALETTEENTRY pe;
int n; int n;
int nDibColors; int nDibColors;
int nPalColors=0; int nPalColors=0;
BYTE FAR * lpBits; BYTE FAR * lpBits;
RGBQUAD FAR * lpRgb; RGBQUAD FAR * lpRgb;
BYTE xlat[256]; BYTE xlat[256];
DWORD SizeImage; DWORD SizeImage;
if (!hpal || !pdib) if (!hpal || !pdib)
return FALSE; return FALSE;
lpbi = (LPBITMAPINFOHEADER)pdib; lpbi = (LPBITMAPINFOHEADER)pdib;
lpRgb = DibColors(pdib); lpRgb = DibColors(pdib);
GetObject(hpal,sizeof(int),(LPSTR)&nPalColors); GetObject(hpal,sizeof(int),(LPSTR)&nPalColors);
nDibColors = DibNumColors(pdib); nDibColors = DibNumColors(pdib);
if ((SizeImage = lpbi->biSizeImage) == 0) if ((SizeImage = lpbi->biSizeImage) == 0)
SizeImage = DibSizeImage(lpbi); SizeImage = DibSizeImage(lpbi);
// //
// build a xlat table. from the current DIB colors to the given // build a xlat table. from the current DIB colors to the given
// palette. // palette.
// //
for (n=0; n<nDibColors; n++) for (n=0; n<nDibColors; n++)
xlat[n] = (BYTE)GetNearestPaletteIndex(hpal,RGB(lpRgb[n].rgbRed,lpRgb[n].rgbGreen,lpRgb[n].rgbBlue)); xlat[n] = (BYTE)GetNearestPaletteIndex(hpal,RGB(lpRgb[n].rgbRed,lpRgb[n].rgbGreen,lpRgb[n].rgbBlue));
lpBits = (LPBYTE)DibPtr(lpbi); lpBits = (LPBYTE)DibPtr(lpbi);
lpbi->biClrUsed = nPalColors; lpbi->biClrUsed = nPalColors;
// //
// re-size the DIB // re-size the DIB
// //
if (nPalColors > nDibColors) if (nPalColors > nDibColors)
{ {
GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0); GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0);
hmemmove((BYTE _huge *)DibPtr(lpbi), (BYTE _huge *)lpBits, SizeImage); hmemmove((BYTE _huge *)DibPtr(lpbi), (BYTE _huge *)lpBits, SizeImage);
lpBits = (LPBYTE)DibPtr(lpbi); lpBits = (LPBYTE)DibPtr(lpbi);
} }
else if (nPalColors < nDibColors) else if (nPalColors < nDibColors)
{ {
hmemcpy(DibPtr(lpbi), lpBits, SizeImage); hmemcpy(DibPtr(lpbi), lpBits, SizeImage);
GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0); GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0);
lpBits = (LPBYTE)DibPtr(lpbi); lpBits = (LPBYTE)DibPtr(lpbi);
} }
// //
// translate the DIB bits // translate the DIB bits
// //
switch (lpbi->biCompression) switch (lpbi->biCompression)
{ {
case BI_RLE8: case BI_RLE8:
xlatRle8(lpBits, SizeImage, xlat); xlatRle8(lpBits, SizeImage, xlat);
break; break;
case BI_RLE4: case BI_RLE4:
xlatRle4(lpBits, SizeImage, xlat); xlatRle4(lpBits, SizeImage, xlat);
break; break;
case BI_RGB: case BI_RGB:
if (lpbi->biBitCount == 8) if (lpbi->biBitCount == 8)
xlatClut8(lpBits, SizeImage, xlat); xlatClut8(lpBits, SizeImage, xlat);
else else
xlatClut4(lpBits, SizeImage, xlat); xlatClut4(lpBits, SizeImage, xlat);
@@ -660,12 +661,12 @@ BOOL DibMapToPalette(PDIB pdib, HPALETTE hpal)
GetPaletteEntries(hpal,n,1,&pe); GetPaletteEntries(hpal,n,1,&pe);
lpRgb[n].rgbRed = pe.peRed; lpRgb[n].rgbRed = pe.peRed;
lpRgb[n].rgbGreen = pe.peGreen; lpRgb[n].rgbGreen = pe.peGreen;
lpRgb[n].rgbBlue = pe.peBlue; lpRgb[n].rgbBlue = pe.peBlue;
lpRgb[n].rgbReserved = (BYTE)0; lpRgb[n].rgbReserved = (BYTE)0;
} }
return TRUE; return TRUE;
} }
@@ -676,21 +677,21 @@ HPALETTE MakePalette(const BITMAPINFO FAR* Info, UINT flags)
WORD nColors = Info->bmiHeader.biClrUsed; WORD nColors = Info->bmiHeader.biClrUsed;
if (nColors) { if (nColors) {
LOGPALETTE* logPal = (LOGPALETTE*) LOGPALETTE* logPal = (LOGPALETTE*)
new BYTE[sizeof(LOGPALETTE) + (nColors-1)*sizeof(PALETTEENTRY)]; new BYTE[sizeof(LOGPALETTE) + (nColors-1)*sizeof(PALETTEENTRY)];
logPal->palVersion = 0x300; // Windows 3.0 version logPal->palVersion = 0x300; // Windows 3.0 version
logPal->palNumEntries = nColors; logPal->palNumEntries = nColors;
for (short n = 0; n < nColors; n++) { for (short n = 0; n < nColors; n++) {
logPal->palPalEntry[n].peRed = rgb[n].rgbRed; logPal->palPalEntry[n].peRed = rgb[n].rgbRed;
logPal->palPalEntry[n].peGreen = rgb[n].rgbGreen; logPal->palPalEntry[n].peGreen = rgb[n].rgbGreen;
logPal->palPalEntry[n].peBlue = rgb[n].rgbBlue; logPal->palPalEntry[n].peBlue = rgb[n].rgbBlue;
logPal->palPalEntry[n].peFlags = (BYTE)flags; logPal->palPalEntry[n].peFlags = (BYTE)flags;
} }
hPalette = ::CreatePalette(logPal); hPalette = ::CreatePalette(logPal);
delete logPal; delete logPal;
} else } else
hPalette = 0; hPalette = 0;
return hPalette; return hPalette;
} }

View File

@@ -1,9 +1,9 @@
/* /*
* File: dummy.cc * File: dummy.cc
* Purpose: See below * Purpose: See below
* Author: Julian Smart * Author: Julian Smart
* Created: 1993 * Created: 1993
* Updated: * Updated:
* Copyright: (c) 1993, AIAI, University of Edinburgh * Copyright: (c) 1993, AIAI, University of Edinburgh
*/ */
@@ -40,7 +40,7 @@
// Foils optimizations in Visual C++ (see also app.cpp). Without it, // Foils optimizations in Visual C++ (see also app.cpp). Without it,
// dummy.obj isn't linked and we get a linker error. // dummy.obj isn't linked and we get a linker error.
#if defined(_MSC_VER) #if defined(__VISUALC__)
char wxDummyChar = 0; char wxDummyChar = 0;
#endif #endif
@@ -51,7 +51,7 @@
#if !defined(APIENTRY) #if !defined(APIENTRY)
#define APIENTRY FAR PASCAL #define APIENTRY FAR PASCAL
#endif #endif
int int
#ifdef __WATCOMC__ #ifdef __WATCOMC__
PASCAL PASCAL

View File

@@ -1,13 +1,13 @@
/* /*
* File: dummydll.cc * File: dummydll.cc
* Purpose: * Purpose:
* Author: Julian Smart * Author: Julian Smart
* Created: 1993 * Created: 1993
* Updated: * Updated:
* Copyright: (c) 1993, AIAI, University of Edinburgh * Copyright: (c) 1993, AIAI, University of Edinburgh
*/ */
/* static const char sccsid[] = "@(#)dummydll.cc 1.2 5/9/94"; */ /* static const char sccsid[] = "@(#)dummydll.cc 1.2 5/9/94"; */
/* /*
* A dummy file to include wx.h. If precompiling wx.h, I * A dummy file to include wx.h. If precompiling wx.h, I
@@ -19,7 +19,7 @@
// Foils optimizations in Visual C++ (see also app.cpp). Without it, // Foils optimizations in Visual C++ (see also app.cpp). Without it,
// dummy.obj isn't linked and we get a linker error. // dummy.obj isn't linked and we get a linker error.
#if defined(_MSC_VER) && defined(__WIN16__) #if defined(__VISUALC__) && defined(__WIN16__)
char wxDummyChar=0; char wxDummyChar=0;
#endif #endif

View File

@@ -2,7 +2,7 @@
// Name: msw/ole/dataobj.cpp // Name: msw/ole/dataobj.cpp
// Purpose: implementation of wx[I]DataObject class // Purpose: implementation of wx[I]DataObject class
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 10.05.98 // Created: 10.05.98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
@@ -313,7 +313,7 @@ STDMETHODIMP wxIDataObject::EnumFormatEtc(DWORD dwDirection,
return E_NOTIMPL; return E_NOTIMPL;
} }
wxIEnumFORMATETC *pEnum = wxIEnumFORMATETC *pEnum =
new wxIEnumFORMATETC(m_pDataObject->GetPreferredFormat()); new wxIEnumFORMATETC(m_pDataObject->GetPreferredFormat());
pEnum->AddRef(); pEnum->AddRef();
*ppenumFormatEtc = pEnum; *ppenumFormatEtc = pEnum;
@@ -359,7 +359,7 @@ const char *wxDataObject::GetFormatName(wxDataFormat format)
{ {
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
// case 'xxx' is not a valid value for switch of enum 'wxDataFormat' // case 'xxx' is not a valid value for switch of enum 'wxDataFormat'
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(disable:4063) #pragma warning(disable:4063)
#endif // VC++ #endif // VC++
@@ -386,7 +386,7 @@ const char *wxDataObject::GetFormatName(wxDataFormat format)
return s_szBuf; return s_szBuf;
} }
#ifdef _MSC_VER #ifdef __VISUALC__
#pragma warning(default:4063) #pragma warning(default:4063)
#endif // VC++ #endif // VC++

View File

@@ -2,7 +2,7 @@
// Name: ole/oleutils.cpp // Name: ole/oleutils.cpp
// Purpose: implementation of OLE helper functions // Purpose: implementation of OLE helper functions
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 19.02.98 // Created: 19.02.98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
@@ -37,8 +37,8 @@
#include <wx/msw/ole/uuid.h> #include <wx/msw/ole/uuid.h>
#include <wx/msw/ole/oleutils.h> #include <wx/msw/ole/oleutils.h>
#if defined(_MSC_VER) && (_MSC_VER > 1000) #if defined(__VISUALC__) && (__VISUALC__ > 1000)
#include <docobj.h> #include <docobj.h>
#endif #endif
// ============================================================================ // ============================================================================
@@ -62,7 +62,7 @@ bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount)
// Debug support // Debug support
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if defined(__WXDEBUG__) && defined(_MSC_VER) && (_MSC_VER > 1000) #if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ > 1000)
const char *GetIidName(REFIID riid) const char *GetIidName(REFIID riid)
{ {
// an association between symbolic name and numeric value of an IID // an association between symbolic name and numeric value of an IID

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -26,12 +26,9 @@
#include <string.h> #include <string.h>
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <fstream.h> # include <fstream.h>
#else #else
#include <fstream> # include <fstream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif #endif
#include <windows.h> #include <windows.h>
@@ -70,7 +67,7 @@ ima_png_error(png_struct *png_ptr, char *message)
{ {
// wxMessageBox(message, "PNG error"); // wxMessageBox(message, "PNG error");
longjmp(png_ptr->jmpbuf, 1); longjmp(png_ptr->jmpbuf, 1);
} }
@@ -80,15 +77,15 @@ wxPalette *wxCopyPalette(const wxPalette *cmap);
wxPNGReader::wxPNGReader(void) wxPNGReader::wxPNGReader(void)
{ {
filetype = 0; filetype = 0;
RawImage = NULL; // Image data RawImage = NULL; // Image data
Width = 0; Height = 0; // Dimensions Width = 0; Height = 0; // Dimensions
Depth = 0; // (bits x pixel) Depth = 0; // (bits x pixel)
ColorType = 0; // Bit 1 = Palette used ColorType = 0; // Bit 1 = Palette used
// Bit 2 = Color used // Bit 2 = Color used
// Bit 3 = Alpha used // Bit 3 = Alpha used
EfeWidth = 0; // Efective Width EfeWidth = 0; // Efective Width
lpbi = NULL; lpbi = NULL;
bgindex = -1; bgindex = -1;
@@ -100,15 +97,15 @@ wxPNGReader::wxPNGReader ( char* ImageFileName )
{ {
imageOK = FALSE; imageOK = FALSE;
filetype = 0; filetype = 0;
RawImage = NULL; // Image data RawImage = NULL; // Image data
Width = 0; Height = 0; // Dimensions Width = 0; Height = 0; // Dimensions
Depth = 0; // (bits x pixel) Depth = 0; // (bits x pixel)
ColorType = 0; // Bit 1 = Palette used ColorType = 0; // Bit 1 = Palette used
// Bit 2 = Color used // Bit 2 = Color used
// Bit 3 = Alpha used // Bit 3 = Alpha used
EfeWidth = 0; // Efective Width EfeWidth = 0; // Efective Width
lpbi = NULL; lpbi = NULL;
bgindex = -1; bgindex = -1;
@@ -125,17 +122,17 @@ wxPNGReader::Create(int width, int height, int depth, int colortype)
if (lpbi) { if (lpbi) {
#ifdef __WIN16__ #ifdef __WIN16__
GlobalFreePtr((unsigned int) lpbi); GlobalFreePtr((unsigned int) lpbi);
#else #else
GlobalFreePtr(lpbi); GlobalFreePtr(lpbi);
#endif #endif
// delete Palette; // delete Palette;
} }
RawImage = 0; RawImage = 0;
Palette = 0; Palette = 0;
if (lpbi = DibCreate(Depth, Width, Height)) { if (lpbi = DibCreate(Depth, Width, Height)) {
RawImage = (ImagePointerType)DibPtr(lpbi); RawImage = (ImagePointerType)DibPtr(lpbi);
EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4; EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
imageOK = TRUE; imageOK = TRUE;
} }
} }
@@ -144,11 +141,11 @@ wxPNGReader::~wxPNGReader ( )
{ {
if (lpbi) { if (lpbi) {
#ifdef __WIN16__ #ifdef __WIN16__
GlobalFreePtr((unsigned int) lpbi); GlobalFreePtr((unsigned int) lpbi);
#else #else
GlobalFreePtr(lpbi); GlobalFreePtr(lpbi);
#endif #endif
delete Palette; delete Palette;
} }
} }
@@ -167,17 +164,17 @@ bool wxPNGReader::GetRGB(int x, int y, byte* r, byte* g, byte* b)
if (!Inside(x, y)) return FALSE; if (!Inside(x, y)) return FALSE;
if (Palette) { if (Palette) {
return Palette->GetRGB(GetIndex(x, y), r, g, b); return Palette->GetRGB(GetIndex(x, y), r, g, b);
/* PALETTEENTRY entry; /* PALETTEENTRY entry;
::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry); ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry);
*r = entry.peRed; *r = entry.peRed;
*g = entry.peGreen; *g = entry.peGreen;
*b = entry.peBlue; */ *b = entry.peBlue; */
} else { } else {
ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
*b = ImagePointer[0]; *b = ImagePointer[0];
*g = ImagePointer[1]; *g = ImagePointer[1];
*r = ImagePointer[2]; *r = ImagePointer[2];
} }
return TRUE; return TRUE;
} }
@@ -199,14 +196,14 @@ bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b)
if (ColorType & COLORTYPE_PALETTE) if (ColorType & COLORTYPE_PALETTE)
{ {
if (!Palette) return FALSE; if (!Palette) return FALSE;
SetIndex(x, y, Palette->GetPixel(r, g, b)); SetIndex(x, y, Palette->GetPixel(r, g, b));
} else { } else {
ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
ImagePointer[0] = b; ImagePointer[0] = b;
ImagePointer[1] = g; ImagePointer[1] = g;
ImagePointer[2] = r; ImagePointer[2] = r;
} }
return TRUE; return TRUE;
@@ -215,7 +212,7 @@ bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b)
bool wxPNGReader::SetPalette(wxPalette* colourmap) bool wxPNGReader::SetPalette(wxPalette* colourmap)
{ {
if (!colourmap) if (!colourmap)
return FALSE; return FALSE;
ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
Palette = colourmap; Palette = colourmap;
return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0); return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
@@ -226,7 +223,7 @@ wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
{ {
Palette = new wxPalette(); Palette = new wxPalette();
if (!Palette) if (!Palette)
return FALSE; return FALSE;
if (!g) g = r; if (!g) g = r;
if (!b) b = g; if (!b) b = g;
@@ -240,15 +237,15 @@ wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
{ {
Palette = new wxPalette(); Palette = new wxPalette();
if (!Palette) if (!Palette)
return FALSE; return FALSE;
byte r[256], g[256], b[256]; byte r[256], g[256], b[256];
for(int i=0; i<n; i++) for(int i=0; i<n; i++)
{ {
r[i] = rgb_struct[i].red; r[i] = rgb_struct[i].red;
g[i] = rgb_struct[i].green; g[i] = rgb_struct[i].green;
b[i] = rgb_struct[i].blue; b[i] = rgb_struct[i].blue;
} }
// Added by JACS copying from Andrew Davison's additions // Added by JACS copying from Andrew Davison's additions
// to GIF-reading code // to GIF-reading code
@@ -281,10 +278,10 @@ wxBitmap* wxPNGReader::GetBitmap(void)
bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap) bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap)
{ {
HDC dc = ::CreateCompatibleDC(NULL); HDC dc = ::CreateCompatibleDC(NULL);
if (dc) if (dc)
{ {
// tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it // tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it
// is a memory dc that must have a bitmap selected into it) // is a memory dc that must have a bitmap selected into it)
HDC dc2 = GetDC(NULL); HDC dc2 = GetDC(NULL);
@@ -295,11 +292,11 @@ bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap)
if ( Palette ) if ( Palette )
{ {
HPALETTE oldPal = ::SelectPalette(dc, (HPALETTE) Palette->GetHPALETTE(), FALSE); HPALETTE oldPal = ::SelectPalette(dc, (HPALETTE) Palette->GetHPALETTE(), FALSE);
::RealizePalette(dc); ::RealizePalette(dc);
} }
HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi, HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi,
CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS); CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS);
::SelectPalette(dc, NULL, TRUE); ::SelectPalette(dc, NULL, TRUE);
::SelectObject(dc, oldBitmap); ::SelectObject(dc, oldBitmap);
@@ -323,16 +320,16 @@ bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap)
wxMask *mask = CreateMask(); wxMask *mask = CreateMask();
bitmap->SetMask(mask); bitmap->SetMask(mask);
} }
return TRUE; return TRUE;
} }
else else
{ {
return FALSE; return FALSE;
} }
} }
else else
{ {
return FALSE; return FALSE;
} }
} }
@@ -341,13 +338,13 @@ wxPalette *wxCopyPalette(const wxPalette *cmap)
// To get number of entries... // To get number of entries...
WORD count = 0; WORD count = 0;
::GetObject((HPALETTE) cmap->GetHPALETTE(), sizeof(WORD), &count); ::GetObject((HPALETTE) cmap->GetHPALETTE(), sizeof(WORD), &count);
LOGPALETTE* logPal = (LOGPALETTE*) LOGPALETTE* logPal = (LOGPALETTE*)
new BYTE[sizeof(LOGPALETTE) + count*sizeof(PALETTEENTRY)]; new BYTE[sizeof(LOGPALETTE) + count*sizeof(PALETTEENTRY)];
logPal->palVersion = 0x300; logPal->palVersion = 0x300;
logPal->palNumEntries = count; logPal->palNumEntries = count;
::GetPaletteEntries((HPALETTE) cmap->GetHPALETTE(), 0, count, logPal->palPalEntry); ::GetPaletteEntries((HPALETTE) cmap->GetHPALETTE(), 0, count, logPal->palPalEntry);
HPALETTE hPalette = ::CreatePalette(logPal); HPALETTE hPalette = ::CreatePalette(logPal);
delete[] logPal; delete[] logPal;
@@ -360,7 +357,7 @@ wxMask *wxPNGReader::CreateMask(void)
{ {
HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL); HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL);
HDC dc = ::CreateCompatibleDC(NULL); HDC dc = ::CreateCompatibleDC(NULL);
HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap); HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap);
int bgIndex = GetBGIndex(); int bgIndex = GetBGIndex();
@@ -377,7 +374,7 @@ wxMask *wxPNGReader::CreateMask(void)
else else
::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255)); ::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255));
} }
} }
::SelectObject(dc, oldBitmap); ::SelectObject(dc, oldBitmap);
wxMask *mask = new wxMask; wxMask *mask = new wxMask;
@@ -390,138 +387,138 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
int number_passes; int number_passes;
if (ImageFileName) if (ImageFileName)
strcpy(filename, ImageFileName); strcpy(filename, ImageFileName);
FILE *fp; FILE *fp;
png_struct *png_ptr; png_struct *png_ptr;
png_info *info_ptr; png_info *info_ptr;
wxPNGReaderIter iter(this); wxPNGReaderIter iter(this);
/* open the file */ /* open the file */
fp = fopen(filename, "rb"); fp = fopen(filename, "rb");
if (!fp) if (!fp)
return FALSE; return FALSE;
/* allocate the necessary structures */ /* allocate the necessary structures */
png_ptr = new (png_struct); png_ptr = new (png_struct);
if (!png_ptr) if (!png_ptr)
{ {
fclose(fp); fclose(fp);
return FALSE; return FALSE;
} }
info_ptr = new (png_info); info_ptr = new (png_info);
if (!info_ptr) if (!info_ptr)
{ {
fclose(fp); fclose(fp);
delete(png_ptr); delete(png_ptr);
return FALSE; return FALSE;
} }
/* set error handling */ /* set error handling */
if (setjmp(png_ptr->jmpbuf)) if (setjmp(png_ptr->jmpbuf))
{ {
png_read_destroy(png_ptr, info_ptr, (png_info *)0); png_read_destroy(png_ptr, info_ptr, (png_info *)0);
fclose(fp); fclose(fp);
delete(png_ptr); delete(png_ptr);
delete(info_ptr); delete(info_ptr);
/* If we get here, we had a problem reading the file */ /* If we get here, we had a problem reading the file */
return FALSE; return FALSE;
} }
//png_set_error(ima_png_error, NULL); //png_set_error(ima_png_error, NULL);
/* initialize the structures, info first for error handling */ /* initialize the structures, info first for error handling */
png_info_init(info_ptr); png_info_init(info_ptr);
png_read_init(png_ptr); png_read_init(png_ptr);
/* set up the input control */ /* set up the input control */
png_init_io(png_ptr, fp); png_init_io(png_ptr, fp);
/* read the file information */ /* read the file information */
png_read_info(png_ptr, info_ptr); png_read_info(png_ptr, info_ptr);
/* allocate the memory to hold the image using the fields /* allocate the memory to hold the image using the fields
of png_info. */ of png_info. */
png_color_16 my_background={ 0, 31, 127, 255, 0 }; png_color_16 my_background={ 0, 31, 127, 255, 0 };
if (info_ptr->valid & PNG_INFO_bKGD) if (info_ptr->valid & PNG_INFO_bKGD)
{ {
png_set_background(png_ptr, &(info_ptr->background), png_set_background(png_ptr, &(info_ptr->background),
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
if ( info_ptr->num_palette > 0 ) if ( info_ptr->num_palette > 0 )
bgindex = info_ptr->background.index; bgindex = info_ptr->background.index;
} }
else { else {
png_set_background(png_ptr, &my_background, png_set_background(png_ptr, &my_background,
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
// Added by JACS: guesswork! // Added by JACS: guesswork!
if ( info_ptr->num_trans != 0 ) if ( info_ptr->num_trans != 0 )
bgindex = info_ptr->num_trans - 1 ; bgindex = info_ptr->num_trans - 1 ;
} }
/* tell libpng to strip 16 bit depth files down to 8 bits */ /* tell libpng to strip 16 bit depth files down to 8 bits */
if (info_ptr->bit_depth == 16) if (info_ptr->bit_depth == 16)
png_set_strip_16(png_ptr); png_set_strip_16(png_ptr);
int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24; int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24;
Create(info_ptr->width, info_ptr->height, pixel_depth, Create(info_ptr->width, info_ptr->height, pixel_depth,
info_ptr->color_type); info_ptr->color_type);
if (info_ptr->num_palette>0) if (info_ptr->num_palette>0)
{ {
SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette); SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette);
} }
int row_stride = info_ptr->width * ((pixel_depth+7)>>3); int row_stride = info_ptr->width * ((pixel_depth+7)>>3);
// printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride); // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride);
// printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth); // printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth);
byte *row_pointers = new byte[row_stride]; byte *row_pointers = new byte[row_stride];
/* turn on interlace handling */ /* turn on interlace handling */
if (info_ptr->interlace_type) if (info_ptr->interlace_type)
number_passes = png_set_interlace_handling(png_ptr); number_passes = png_set_interlace_handling(png_ptr);
else else
number_passes = 1; number_passes = 1;
// printf("NP = %d ", number_passes); // printf("NP = %d ", number_passes);
for (int pass=0; pass< number_passes; pass++) { for (int pass=0; pass< number_passes; pass++) {
iter.upset(); iter.upset();
int y=0; int y=0;
do { do {
// (unsigned char *)iter.GetRow(); // (unsigned char *)iter.GetRow();
if (info_ptr->interlace_type) { if (info_ptr->interlace_type) {
if (pass>0) if (pass>0)
iter.GetRow(row_pointers, row_stride); iter.GetRow(row_pointers, row_stride);
png_read_row(png_ptr, row_pointers, NULL); png_read_row(png_ptr, row_pointers, NULL);
} }
else else
png_read_row(png_ptr, row_pointers, NULL); png_read_row(png_ptr, row_pointers, NULL);
iter.SetRow(row_pointers, row_stride); iter.SetRow(row_pointers, row_stride);
y++; y++;
} while(iter.PrevRow()); } while(iter.PrevRow());
// printf("Y=%d ",y); // printf("Y=%d ",y);
} }
delete[] row_pointers; delete[] row_pointers;
/* read the rest of the file, getting any additional chunks /* read the rest of the file, getting any additional chunks
in info_ptr */ in info_ptr */
png_read_end(png_ptr, info_ptr); png_read_end(png_ptr, info_ptr);
/* clean up after the read, and free any memory allocated */ /* clean up after the read, and free any memory allocated */
png_read_destroy(png_ptr, info_ptr, (png_info *)0); png_read_destroy(png_ptr, info_ptr, (png_info *)0);
/* free the structures */ /* free the structures */
delete(png_ptr); delete(png_ptr);
delete(info_ptr); delete(info_ptr);
/* close the file */ /* close the file */
fclose(fp); fclose(fp);
/* that's it */ /* that's it */
return TRUE; return TRUE;
} }
@@ -530,91 +527,91 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
bool wxPNGReader::SaveFile(char * ImageFileName) bool wxPNGReader::SaveFile(char * ImageFileName)
{ {
if (ImageFileName) if (ImageFileName)
strcpy(filename, ImageFileName); strcpy(filename, ImageFileName);
wxPNGReaderIter iter(this); wxPNGReaderIter iter(this);
FILE *fp; FILE *fp;
png_struct *png_ptr; png_struct *png_ptr;
png_info *info_ptr; png_info *info_ptr;
/* open the file */ /* open the file */
fp = fopen(filename, "wb"); fp = fopen(filename, "wb");
if (!fp) if (!fp)
return FALSE; return FALSE;
/* allocate the necessary structures */ /* allocate the necessary structures */
png_ptr = new (png_struct); png_ptr = new (png_struct);
if (!png_ptr) if (!png_ptr)
{ {
fclose(fp); fclose(fp);
return FALSE; return FALSE;
} }
info_ptr = new (png_info); info_ptr = new (png_info);
if (!info_ptr) if (!info_ptr)
{ {
fclose(fp); fclose(fp);
delete(png_ptr); delete(png_ptr);
return FALSE; return FALSE;
} }
/* set error handling */ /* set error handling */
if (setjmp(png_ptr->jmpbuf)) if (setjmp(png_ptr->jmpbuf))
{ {
png_write_destroy(png_ptr); png_write_destroy(png_ptr);
fclose(fp); fclose(fp);
delete(png_ptr); delete(png_ptr);
delete(info_ptr); delete(info_ptr);
/* If we get here, we had a problem reading the file */ /* If we get here, we had a problem reading the file */
return FALSE; return FALSE;
} }
//png_set_error(ima_png_error, NULL); //png_set_error(ima_png_error, NULL);
// printf("writig pg %s ", filename); // printf("writig pg %s ", filename);
/* initialize the structures */ /* initialize the structures */
png_info_init(info_ptr); png_info_init(info_ptr);
png_write_init(png_ptr); png_write_init(png_ptr);
int row_stride = GetWidth() * ((GetDepth()+7)>>3); int row_stride = GetWidth() * ((GetDepth()+7)>>3);
/* set up the output control */ /* set up the output control */
png_init_io(png_ptr, fp); png_init_io(png_ptr, fp);
/* set the file information here */ /* set the file information here */
info_ptr->width = GetWidth(); info_ptr->width = GetWidth();
info_ptr->height = GetHeight(); info_ptr->height = GetHeight();
info_ptr->pixel_depth = GetDepth(); info_ptr->pixel_depth = GetDepth();
info_ptr->channels = (GetDepth()>8) ? 3: 1; info_ptr->channels = (GetDepth()>8) ? 3: 1;
info_ptr->bit_depth = GetDepth()/info_ptr->channels; info_ptr->bit_depth = GetDepth()/info_ptr->channels;
info_ptr->color_type = GetColorType(); info_ptr->color_type = GetColorType();
info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0; info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0;
info_ptr->valid = 0; info_ptr->valid = 0;
info_ptr->rowbytes = row_stride; info_ptr->rowbytes = row_stride;
// printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels); // printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels);
/* set the palette if there is one */ /* set the palette if there is one */
if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette()) if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette())
{ {
// printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); // printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
info_ptr->valid |= PNG_INFO_PLTE; info_ptr->valid |= PNG_INFO_PLTE;
info_ptr->palette = new png_color[256]; info_ptr->palette = new png_color[256];
info_ptr->num_palette = 256; info_ptr->num_palette = 256;
for (int i=0; i<256; i++) for (int i=0; i<256; i++)
GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue); GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
} }
// printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); // printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
/* optional significant bit chunk */ /* optional significant bit chunk */
// info_ptr->valid |= PNG_INFO_sBIT; // info_ptr->valid |= PNG_INFO_sBIT;
// info_ptr->sig_bit = true_bit_depth; // info_ptr->sig_bit = true_bit_depth;
/* optional gamma chunk */ /* optional gamma chunk */
// info_ptr->valid |= PNG_INFO_gAMA; // info_ptr->valid |= PNG_INFO_gAMA;
// info_ptr->gamma = gamma; // info_ptr->gamma = gamma;
/* other optional chunks */ /* other optional chunks */
/* write the file information */ /* write the file information */
png_write_info(png_ptr, info_ptr); png_write_info(png_ptr, info_ptr);
@@ -622,14 +619,14 @@ bool wxPNGReader::SaveFile(char * ImageFileName)
/* set up the transformations you want. Note that these are /* set up the transformations you want. Note that these are
all optional. Only call them if you want them */ all optional. Only call them if you want them */
/* shift the pixels up to a legal bit depth and fill in /* shift the pixels up to a legal bit depth and fill in
as appropriate to correctly scale the image */ as appropriate to correctly scale the image */
// png_set_shift(png_ptr, &(info_ptr->sig_bit)); // png_set_shift(png_ptr, &(info_ptr->sig_bit));
/* pack pixels into bytes */ /* pack pixels into bytes */
// png_set_packing(png_ptr); // png_set_packing(png_ptr);
/* flip bgr pixels to rgb */ /* flip bgr pixels to rgb */
// png_set_bgr(png_ptr); // png_set_bgr(png_ptr);
/* swap bytes of 16 bit files to most significant bit first */ /* swap bytes of 16 bit files to most significant bit first */
@@ -640,35 +637,35 @@ bool wxPNGReader::SaveFile(char * ImageFileName)
/* If you are only writing one row at a time, this works */ /* If you are only writing one row at a time, this works */
byte *row_pointers = new byte[row_stride]; byte *row_pointers = new byte[row_stride];
iter.upset(); iter.upset();
do { do {
// (unsigned char *)iter.GetRow(); // (unsigned char *)iter.GetRow();
iter.GetRow(row_pointers, row_stride); iter.GetRow(row_pointers, row_stride);
png_write_row(png_ptr, row_pointers); png_write_row(png_ptr, row_pointers);
} while(iter.PrevRow()); } while(iter.PrevRow());
delete[] row_pointers; delete[] row_pointers;
/* write the rest of the file */ /* write the rest of the file */
png_write_end(png_ptr, info_ptr); png_write_end(png_ptr, info_ptr);
/* clean up after the write, and free any memory allocated */ /* clean up after the write, and free any memory allocated */
png_write_destroy(png_ptr); png_write_destroy(png_ptr);
/* if you malloced the palette, free it here */ /* if you malloced the palette, free it here */
if (info_ptr->palette) if (info_ptr->palette)
delete[] (info_ptr->palette); delete[] (info_ptr->palette);
/* free the structures */ /* free the structures */
delete(png_ptr); delete(png_ptr);
delete(info_ptr); delete(info_ptr);
/* close the file */ /* close the file */
fclose(fp); fclose(fp);
/* that's it */ /* that's it */
return TRUE; return TRUE;
} }
static int Power(int x, int y) static int Power(int x, int y)
@@ -693,7 +690,7 @@ static void DecToHex(int dec, char *buf)
buf[1] = hexArray[secondDigit]; buf[1] = hexArray[secondDigit];
buf[2] = 0; buf[2] = 0;
} }
bool wxPNGReader::SaveXPM(char *filename, char *name) bool wxPNGReader::SaveXPM(char *filename, char *name)
{ {

View File

@@ -39,12 +39,9 @@
#include <stdlib.h> #include <stdlib.h>
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <fstream.h> # include <fstream.h>
#else #else
#include <fstream> # include <fstream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif #endif
#include <sys/types.h> #include <sys/types.h>

View File

@@ -68,41 +68,26 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifndef __WATCOMC__ #ifndef __WATCOMC__
#if !(defined(_MSC_VER) && (_MSC_VER > 800)) #if !(defined(_MSC_VER) && (_MSC_VER > 800))
#include <errno.h> #include <errno.h>
#endif #endif
#endif #endif
#include <stdarg.h> #include <stdarg.h>
//// BEGIN for console support: VC++ only //// BEGIN for console support: VC++ only
#if defined(__WXDEBUG__) && !defined(__WIN16__) && defined(_MSC_VER) && !defined(__NO_VC_CRTDBG__) #include "wx/msw/msvcrt.h"
#define wxUSE_VC_CRTDBG
#else
#undef wxUSE_VC_CRTDBG
#endif
#ifdef wxUSE_VC_CRTDBG #include <fcntl.h>
// VC++ uses this macro as debug/release mode indicator
#ifndef _DEBUG
#define _DEBUG
#endif
#include <fcntl.h> #include "wx/ioswrap.h"
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
// N.B. BC++ doesn't have istream.h, ostream.h // N.B. BC++ doesn't have istream.h, ostream.h
# include <iostream.h>
# include <io.h> # include <io.h>
# include <fstream.h> # include <fstream.h>
#else #else
# include <istream>
# include <ostream>
# include <fstream> # include <fstream>
# ifdef _MSC_VER
using namespace std;
# endif
#endif #endif
/* Need to undef new if including crtdbg.h */ /* Need to undef new if including crtdbg.h */
@@ -118,8 +103,6 @@
# define new new(__FILE__,__LINE__) # define new new(__FILE__,__LINE__)
# endif # endif
#endif
/// END for console support /// END for console support
// In the WIN.INI file // In the WIN.INI file
@@ -766,14 +749,14 @@ bool wxDirExists(const wxString& dir)
#endif #endif
#if defined(__WIN32__) #if defined(__WIN32__)
HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo); HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo);
if (h==INVALID_HANDLE_VALUE) if (h==INVALID_HANDLE_VALUE)
return FALSE; return FALSE;
else { else {
FindClose(h); FindClose(h);
return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY); return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
} }
#else #else
// In Borland findfirst has a different argument // In Borland findfirst has a different argument
// ordering from _dos_findfirst. But _dos_findfirst // ordering from _dos_findfirst. But _dos_findfirst
@@ -806,13 +789,13 @@ bool wxIsWild( const wxString& pattern )
wxString tmp = pattern; wxString tmp = pattern;
char *pat = WXSTRINGCAST(tmp); char *pat = WXSTRINGCAST(tmp);
while (*pat) { while (*pat) {
switch (*pat++) { switch (*pat++) {
case '?': case '*': case '[': case '{': case '?': case '*': case '[': case '{':
return TRUE; return TRUE;
case '\\': case '\\':
if (!*pat++) if (!*pat++)
return FALSE; return FALSE;
} }
} }
return FALSE; return FALSE;
}; };
@@ -832,124 +815,124 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special )
// dot_special means '.' only matches '.' // dot_special means '.' only matches '.'
if (dot_special && *str == '.' && *pattern != *str) if (dot_special && *str == '.' && *pattern != *str)
return FALSE; return FALSE;
while ((*pattern != '\0') && (!done) while ((*pattern != '\0') && (!done)
&& (((*str=='\0')&&((*pattern==OB)||(*pattern=='*')))||(*str!='\0'))) { && (((*str=='\0')&&((*pattern==OB)||(*pattern=='*')))||(*str!='\0'))) {
switch (*pattern) { switch (*pattern) {
case '\\': case '\\':
pattern++; pattern++;
if (*pattern != '\0') if (*pattern != '\0')
pattern++; pattern++;
break; break;
case '*': case '*':
pattern++; pattern++;
ret_code = FALSE; ret_code = FALSE;
while ((*str!='\0') while ((*str!='\0')
&& (!(ret_code=wxMatchWild(pattern, str++, FALSE)))) && (!(ret_code=wxMatchWild(pattern, str++, FALSE))))
/*loop*/; /*loop*/;
if (ret_code) { if (ret_code) {
while (*str != '\0') while (*str != '\0')
str++; str++;
while (*pattern != '\0') while (*pattern != '\0')
pattern++; pattern++;
} }
break; break;
case '[': case '[':
pattern++; pattern++;
repeat: repeat:
if ((*pattern == '\0') || (*pattern == ']')) { if ((*pattern == '\0') || (*pattern == ']')) {
done = TRUE; done = TRUE;
break; break;
} }
if (*pattern == '\\') { if (*pattern == '\\') {
pattern++; pattern++;
if (*pattern == '\0') { if (*pattern == '\0') {
done = TRUE; done = TRUE;
break; break;
} }
} }
if (*(pattern + 1) == '-') { if (*(pattern + 1) == '-') {
c = *pattern; c = *pattern;
pattern += 2; pattern += 2;
if (*pattern == ']') { if (*pattern == ']') {
done = TRUE; done = TRUE;
break; break;
} }
if (*pattern == '\\') { if (*pattern == '\\') {
pattern++; pattern++;
if (*pattern == '\0') { if (*pattern == '\0') {
done = TRUE; done = TRUE;
break; break;
} }
} }
if ((*str < c) || (*str > *pattern)) { if ((*str < c) || (*str > *pattern)) {
pattern++; pattern++;
goto repeat; goto repeat;
} }
} else if (*pattern != *str) { } else if (*pattern != *str) {
pattern++; pattern++;
goto repeat; goto repeat;
} }
pattern++; pattern++;
while ((*pattern != ']') && (*pattern != '\0')) { while ((*pattern != ']') && (*pattern != '\0')) {
if ((*pattern == '\\') && (*(pattern + 1) != '\0')) if ((*pattern == '\\') && (*(pattern + 1) != '\0'))
pattern++; pattern++;
pattern++; pattern++;
} }
if (*pattern != '\0') { if (*pattern != '\0') {
pattern++, str++; pattern++, str++;
} }
break; break;
case '?': case '?':
pattern++; pattern++;
str++; str++;
break; break;
case OB: case OB:
pattern++; pattern++;
while ((*pattern != CB) && (*pattern != '\0')) { while ((*pattern != CB) && (*pattern != '\0')) {
cp = str; cp = str;
ok = TRUE; ok = TRUE;
while (ok && (*cp != '\0') && (*pattern != '\0') while (ok && (*cp != '\0') && (*pattern != '\0')
&& (*pattern != ',') && (*pattern != CB)) { && (*pattern != ',') && (*pattern != CB)) {
if (*pattern == '\\') if (*pattern == '\\')
pattern++; pattern++;
ok = (*pattern++ == *cp++); ok = (*pattern++ == *cp++);
} }
if (*pattern == '\0') { if (*pattern == '\0') {
ok = FALSE; ok = FALSE;
done = TRUE; done = TRUE;
break; break;
} else if (ok) { } else if (ok) {
str = cp; str = cp;
while ((*pattern != CB) && (*pattern != '\0')) { while ((*pattern != CB) && (*pattern != '\0')) {
if (*++pattern == '\\') { if (*++pattern == '\\') {
if (*++pattern == CB) if (*++pattern == CB)
pattern++; pattern++;
} }
} }
} else { } else {
while (*pattern!=CB && *pattern!=',' && *pattern!='\0') { while (*pattern!=CB && *pattern!=',' && *pattern!='\0') {
if (*++pattern == '\\') { if (*++pattern == '\\') {
if (*++pattern == CB || *pattern == ',') if (*++pattern == CB || *pattern == ',')
pattern++; pattern++;
} }
} }
} }
if (*pattern != '\0') if (*pattern != '\0')
pattern++; pattern++;
} }
break; break;
default: default:
if (*str == *pattern) { if (*str == *pattern) {
str++, pattern++; str++, pattern++;
} else { } else {
done = TRUE; done = TRUE;
} }
} }
} }
while (*pattern == '*') while (*pattern == '*')
pattern++; pattern++;
return ((*str == '\0') && (*pattern == '\0')); return ((*str == '\0') && (*pattern == '\0'));
}; };
@@ -1089,14 +1072,14 @@ void OutputDebugStringW95(const char* lpOutputString, ...)
#endif #endif
#ifdef wxUSE_VC_CRTDBG #ifdef 0
// maximum mumber of lines the output console should have // maximum mumber of lines the output console should have
static const WORD MAX_CONSOLE_LINES = 500; static const WORD MAX_CONSOLE_LINES = 500;
BOOL WINAPI MyConsoleHandler( DWORD dwCtrlType ) { // control signal type BOOL WINAPI MyConsoleHandler( DWORD dwCtrlType ) { // control signal type
FreeConsole(); FreeConsole();
return TRUE; return TRUE;
} }
void wxRedirectIOToConsole() void wxRedirectIOToConsole()
@@ -1110,10 +1093,10 @@ void wxRedirectIOToConsole()
AllocConsole(); AllocConsole();
// set the screen buffer to be big enough to let us scroll text // set the screen buffer to be big enough to let us scroll text
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
&coninfo); &coninfo);
coninfo.dwSize.Y = MAX_CONSOLE_LINES; coninfo.dwSize.Y = MAX_CONSOLE_LINES;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),
coninfo.dwSize); coninfo.dwSize);
// redirect unbuffered STDOUT to the console // redirect unbuffered STDOUT to the console
@@ -1139,13 +1122,12 @@ void wxRedirectIOToConsole()
fp = _fdopen( hConHandle, "w" ); fp = _fdopen( hConHandle, "w" );
*stderr = *fp; *stderr = *fp;
setvbuf( stderr, NULL, _IONBF, 0 ); setvbuf( stderr, NULL, _IONBF, 0 );
// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog
// point to console as well // point to console as well
ios::sync_with_stdio(); ios::sync_with_stdio();
SetConsoleCtrlHandler(MyConsoleHandler, TRUE); SetConsoleCtrlHandler(MyConsoleHandler, TRUE);
} }
#else #else
// Not supported // Not supported

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -59,9 +59,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifndef __WATCOMC__ #ifndef __WATCOMC__
#if !(defined(_MSC_VER) && (_MSC_VER > 800)) #if !(defined(_MSC_VER) && (_MSC_VER > 800))
#include <errno.h> #include <errno.h>
#endif #endif
#endif #endif
#include <stdarg.h> #include <stdarg.h>