// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c)
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DEFS_H_
#include "wx/setup.h"
#include "wx/version.h"
-// Helps SGI compilation, apparently
-#if defined(__SGI__)
-#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
+// ----------------------------------------------------------------------------
+// compiler and OS identification
+// ----------------------------------------------------------------------------
-#if defined(sun) || defined(__SUN__)
-# if !defined(__GNUG__)
-# ifndef __SUNCC__
-# define __SUNCC__
-# endif
-# endif
-#endif
+// OS
+#if defined(__HPUX__) || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi ) || defined(__unix__)
+ #ifndef __UNIX__
+ #define __UNIX__
+ #endif // Unix
+
+ // 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
-#ifdef _MSC_VER
+#ifdef __VISUALC__
# pragma warning(disable:4244) // cobversion from double to float
# pragma warning(disable:4100) // unreferenced formal parameter
#endif
typedef unsigned int bool;
#elif defined(__SALFORDC__)
typedef unsigned int bool;
-#elif defined(_MSC_VER) && (_MSC_VER <= 1000)
+#elif defined(__VISUALC__) && (__VISUALC__ <= 1000)
typedef unsigned int bool;
-#elif defined(_MSC_VER) && (_MSC_VER == 1020)
+#elif defined(__VISUALC__) && (__VISUALC__ == 1020)
#define bool unsigned int
#elif defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
typedef unsigned int bool;
#endif // Sun CC
#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)
// may try to define it. Use wxByte instead.
// #define byte unsigned char
WXDLLEXPORT_DATA(extern const bool) wxTrue;
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
// ----------------------------------------------------------------------------
#pragma warning(disable: 4514) // unreferenced inline func has been removed
/*
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
- and will try to find some way to disable this warning just for CHECK/FAIL.
- Anyone?
+ macros in debug.h, but it's, overall, a rather useful one, so I leave it and
+ will try to find some way to disable this warning just for CHECK/FAIL. Anyone?
*/
#pragma warning(disable: 4127) // conditional expression is constant
-
#endif // VC++
-#if _MSC_VER > 1010
-#undef try
-#undef except
-#undef finally
-#define except(x) catch(...)
-#elif defined(__MWERKS__)
-#undef try
-#undef except
-#undef finally
-#define except(x) catch(...)
-#endif
+#if defined(__MWERKS__)
+ #undef try
+ #undef except
+ #undef finally
+ #define except(x) catch(...)
+#endif // Metrowerks
// where should i put this? we need to make sure of this as it breaks
// the <iostream> code.
/*
* Frame/dialog style flags
*/
-#define wxSTAY_ON_TOP 0x8000
-#define wxICONIZE 0x4000
-#define wxMINIMIZE wxICONIZE
-#define wxMAXIMIZE 0x2000
-#define wxTHICK_FRAME 0x1000
-#define wxSYSTEM_MENU 0x0800
-#define wxMINIMIZE_BOX 0x0400
-#define wxMAXIMIZE_BOX 0x0200
-#define wxTINY_CAPTION_HORIZ 0x0100
-#define wxTINY_CAPTION_VERT 0x0080
-#define wxRESIZE_BOX wxMAXIMIZE_BOX
-#define wxRESIZE_BORDER 0x0040
-#define wxDIALOG_MODAL 0x0020
-#define wxDIALOG_MODELESS 0x0000
+#define wxSTAY_ON_TOP 0x8000
+#define wxICONIZE 0x4000
+#define wxMINIMIZE wxICONIZE
+#define wxMAXIMIZE 0x2000
+#define wxTHICK_FRAME 0x1000
+#define wxSYSTEM_MENU 0x0800
+#define wxMINIMIZE_BOX 0x0400
+#define wxMAXIMIZE_BOX 0x0200
+#define wxTINY_CAPTION_HORIZ 0x0100
+#define wxTINY_CAPTION_VERT 0x0080
+#define wxRESIZE_BOX wxMAXIMIZE_BOX
+#define wxRESIZE_BORDER 0x0040
+#define wxDIALOG_MODAL 0x0020
+#define wxDIALOG_MODELESS 0x0000
#define wxDEFAULT_FRAME_STYLE (wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN)
#define wxDEFAULT_FRAME wxDEFAULT_FRAME_STYLE
#endif
-#define wxDEFAULT_DIALOG_STYLE (wxSYSTEM_MENU|wxCAPTION|wxTHICK_FRAME)
+#define wxDEFAULT_DIALOG_STYLE (wxSYSTEM_MENU|wxCAPTION|wxTHICK_FRAME)
/*
* Subwindow style flags
wxCROSS_HATCH,
wxHORIZONTAL_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_MITER,
// Logical ops
-typedef enum
+typedef enum
{
wxCLEAR, // 0
wxXOR, // src XOR dst
#define wxWINDING_RULE 2
// ToolPanel in wxFrame
-#define wxTOOL_TOP 1
-#define wxTOOL_BOTTOM 2
-#define wxTOOL_LEFT 3
-#define wxTOOL_RIGHT 4
+#define wxTOOL_TOP 1
+#define wxTOOL_BOTTOM 2
+#define wxTOOL_LEFT 3
+#define wxTOOL_RIGHT 4
// Dialog specifiers/return values
/* Virtual keycodes */
-enum wxKeyCode
+enum wxKeyCode
{
WXK_BACK = 8,
WXK_TAB = 9,
- WXK_RETURN = 13,
- WXK_ESCAPE = 27,
- WXK_SPACE = 32,
+ WXK_RETURN = 13,
+ WXK_ESCAPE = 27,
+ WXK_SPACE = 32,
WXK_DELETE = 127,
WXK_START = 300,
/* OS mnemonics -- Identify the running OS (useful for Windows)
* [Not all platforms are currently available or supported] */
-enum
+enum
{
wxUNKNOWN_PLATFORM,
- wxCURSES, /* Text-only CURSES */
- wxXVIEW_X, /* Sun's XView OpenLOOK toolkit */
- wxMOTIF_X, /* OSF Motif 1.x.x */
- wxCOSE_X, /* OSF Common Desktop Environment */
- wxNEXTSTEP, /* NeXTStep */
- wxMACINTOSH, /* Apple System 7 */
- wxGTK, /* GTK */
- wxQT, /* Qt */
- wxGEOS, /* GEOS */
- wxOS2_PM, /* OS/2 Workplace */
- wxWINDOWS, /* Windows or WfW */
- wxPENWINDOWS, /* Windows for Pen Computing */
- wxWINDOWS_NT, /* Windows NT */
- wxWIN32S, /* Windows 32S API */
- wxWIN95, /* Windows 95 */
- wxWIN386 /* Watcom 32-bit supervisor modus */
+ wxCURSES, // Text-only CURSES
+ wxXVIEW_X, // Sun's XView OpenLOOK toolkit
+ wxMOTIF_X, // OSF Motif 1.x.x
+ wxCOSE_X, // OSF Common Desktop Environment
+ wxNEXTSTEP, // NeXTStep
+ wxMACINTOSH, // Apple System 7
+ wxGTK, // GTK
+ wxQT, // Qt
+ wxGEOS, // GEOS
+ wxOS2_PM, // OS/2 Workplace
+ wxWINDOWS, // Windows or WfW
+ wxPENWINDOWS, // Windows for Pen Computing
+ wxWINDOWS_NT, // Windows NT
+ wxWIN32S, // Windows 32S API
+ wxWIN95, // Windows 95
+ wxWIN386 // Watcom 32-bit supervisor modus
};
/* Printing */
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c)
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DOCH__
#else
# include <istream>
# include <ostream>
-# ifdef _MSC_VER
+# ifdef __VISUALC__
using namespace std;
# endif
#endif
typedef long off_t;
#endif
-#ifdef _MSC_VER
- #define off_t _off_t
-#endif
-
-#if defined(__BORLANDC__) && defined(__WIN16__)
-typedef long off_t;
-#endif
-
-#if defined(__SC__)
-typedef long off_t;
+#if defined(__VISUALC__) || defined(__MWERKS__)
+ typedef _off_t off_t;
+#elif defined(__BORLANDC__) && defined(__WIN16__)
+ typedef long off_t;
+#elif defined(__SC__)
+ typedef long off_t;
#endif
const off_t wxInvalidOffset = (off_t)-1;
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// 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
class WXDLLEXPORT wxFrame;
#if wxUSE_IOSTREAMH
-// N.B. BC++ doesn't have istream.h, ostream.h
-# include <iostream.h>
+ // N.B. BC++ doesn't have istream.h, ostream.h
+# include <iostream.h>
#else
-# include <ostream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+# include <ostream>
+# if defined(__VISUALC__) || defined(__MWERKS__)
+ using namespace std;
+# endif
#endif
// ----------------------------------------------------------------------------
// Created: 29/01/98
// RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MEMORYH__
#include <stddef.h>
#if wxUSE_IOSTREAMH
-// N.B. BC++ doesn't have istream.h, ostream.h
-# include <iostream.h>
+ // N.B. BC++ doesn't have istream.h, ostream.h
+# include <iostream.h>
#else
-# include <ostream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+# include <ostream>
+# if defined(__VISUALC__) || defined(__MWERKS__)
+ using namespace std;
+# endif
#endif
#ifdef __WXDEBUG__
// Undefine temporarily (new is #defined in object.h) because we want to
// declare some new operators.
#ifdef new
-#undef new
+ #undef new
#endif
#if defined(__SUNCC__)
-#define wxUSE_ARRAY_MEMORY_OPERATORS 0
-#elif !( defined (_MSC_VER) && (_MSC_VER <= 1020) ) || defined( __MWERKS__)
-#define wxUSE_ARRAY_MEMORY_OPERATORS 1
+ #define wxUSE_ARRAY_MEMORY_OPERATORS 0
+#elif !( defined (__VISUALC__) && (__VISUALC__ <= 1020) ) || defined( __MWERKS__)
+ #define wxUSE_ARRAY_MEMORY_OPERATORS 1
#else
-#define wxUSE_ARRAY_MEMORY_OPERATORS 0
+ #define wxUSE_ARRAY_MEMORY_OPERATORS 0
#endif
// Added JACS 25/11/98: needed for some compilers
#endif
// VC++ 6.0
-#if _MSC_VER >= 1200
-void operator delete(void *buf, char*, int);
-void operator delete[](void *buf, char*, int);
+#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
+ void operator delete(void *buf, char*, int);
+ void operator delete[](void *buf, char*, int);
#endif
#endif
#ifndef _MSW_MSVCRT_H_
#define _MSW_MSVCRT_H_
-// use debug CRT functions for memory leak detections in VC++ if we're not
-// using wxWindows own methods
-#if defined(__WXDEBUG__) && defined(_MSC_VER) && !wxUSE_GLOBAL_MEMORY_OPERATORS && !defined(__NO_VC_CRTDBG__)
- #define wxUSE_VC_CRTDBG
-#else
- #undef wxUSE_VC_CRTDBG
+// use debug CRT functions for memory leak detections in VC++ 5.0+ in debug
+// builds
+#undef wxUSE_VC_CRTDBG
+#if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ >= 1000)
+ // it doesn't combine well with wxWin own memory debugging methods
+ #if !wxUSE_GLOBAL_MEMORY_OPERATORS && !defined(__NO_VC_CRTDBG__)
+ #define wxUSE_VC_CRTDBG
+ #endif
#endif
#ifdef wxUSE_VC_CRTDBG
#define wxCrtSetDbgFlag(flag)
#endif // wxUSE_VC_CRTDBG
-#endif // _MSW_MSVCRT_H_
\ No newline at end of file
+#endif // _MSW_MSVCRT_H_
+
// Name: oleutils.h
// Purpose: OLE helper routines, OLE debugging support &c
// Author: Vadim Zeitlin
-// Modified by:
+// Modified by:
// Created: 19.02.1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// ============================================================================
/*
- 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
implementation is quite enough.
// 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)
// ----------------------------------------------------------------------------
#define wxLogRelease(szInterface, cRef)
#endif //WXDEBUG
-#endif //_WX_OLEUTILS_H
\ No newline at end of file
+#endif //_WX_OLEUTILS_H
+
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OBJECTH__
class WXDLLEXPORT wxObject_Serialize;
#if wxUSE_IOSTREAMH
-// N.B. BC++ doesn't have istream.h, ostream.h
-# include <iostream.h>
+ // N.B. BC++ doesn't have istream.h, ostream.h
+# include <iostream.h>
#else
-# include <ostream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+# include <ostream>
+# if defined(__VISUALC__) || defined(__MWERKS__)
+ using namespace std;
+# endif
#endif
/*
wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn fn);
wxObject *CreateObject(void);
-
+
inline char *GetClassName(void) const { return m_className; }
inline char *GetBaseClassName1(void) const { return m_baseClassName1; }
inline char *GetBaseClassName2(void) const { return m_baseClassName2; }
char* m_baseClassName2;
int m_objectSize;
wxObjectConstructorFn m_objectConstructor;
-
+
// Pointers to base wxClassInfos: set in InitializeClasses
// called from wx_main.cc
wxClassInfo* m_baseInfo1;
void operator delete (void * buf);
// VC++ 6.0
-#if _MSC_VER >= 1200
+#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
void operator delete(void *buf, char*, int);
#endif
- // Cause problems for VC++
-// #ifndef _MSC_VER
-#if !defined(_MSC_VER) && wxUSE_ARRAY_MEMORY_OPERATORS
+ // Causes problems for VC++
+#if wxUSE_ARRAY_MEMORY_OPERATORS && !defined(__VISUALC__)
void * operator new[] (size_t size, char * fileName = NULL, int lineNum = 0);
void operator delete[] (void * buf);
#endif
#endif
*/
-#endif
+#endif // Debug & memory tracing
#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT
virtual void Dump(ostream& str);
#pragma interface "string.h"
#endif
-/* Dependencies (should be included before this header):
- * string.h
- * stdio.h
- * stdarg.h
- * limits.h
- */
#ifdef __WXMAC__
-#include <ctype.h>
+ #include <ctype.h>
#endif
+
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#ifndef WX_PRECOMP
- #include "wx/defs.h" // Robert Roebling
+ #include "wx/defs.h"
+
#ifdef WXSTRING_IS_WXOBJECT
#include "wx/object.h"
#endif
-#endif
+#endif // !PCH
#include "wx/debug.h"
// portable strcasecmp/_stricmp
inline int WXDLLEXPORT Stricmp(const char *psz1, const char *psz2)
{
-#if defined(_MSC_VER)
+#if defined(__VISUALC__) || defined(__MWERKS__)
return _stricmp(psz1, psz2);
#elif defined(__SC__)
return _stricmp(psz1, psz2);
size_t find(const wxString& str, size_t nStart = 0) const;
// 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
size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const;
#endif
size_t rfind(const wxString& str, size_t nStart = npos) const;
// 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
size_t rfind(const char* sz, size_t nStart = npos,
size_t n = npos) const;
#ifdef wxSTD_STRING_COMPATIBILITY
-// forward declare iostream
-// 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
+#include "wx/ioswrap.h"
WXDLLEXPORT istream& operator>>(istream& is, wxString& str);
// Created: 29/01/98
// RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UTILSH__
#include "wx/filefn.h"
#include "wx/process.h"
-#if wxUSE_IOSTREAMH
-#include <iostream.h>
-#else
-#include <iostream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
-#endif
+#include "wx/ioswrap.h"
#ifdef __X__
#ifndef __VMS__
// Created: 10/09/98
// RCS-ID: $Id$
// Copyright: (c)
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_VARIANT_H_
#include "wx/list.h"
#if wxUSE_TIMEDATE
-#include "wx/time.h"
-#include "wx/date.h"
-#endif
+ #include "wx/time.h"
+ #include "wx/date.h"
+#endif // time/date
-#if wxUSE_IOSTREAMH
-#include <iostream.h>
-#else
-#include <iostream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
-#endif
+#include "wx/ioswrap.h"
/*
* wxVariantData stores the actual data in a wxVariant object,
#endif
// only do Unicode for Windows (VC++), for now
-#if defined(_MSC_VER) && defined(__WIN32__)
+#if defined(__VISUALC__) && defined(__WIN32__)
#include <tchar.h>
typedef _TCHAR wxChar;
-typedef _TSCHAR wxSChar;
+typedef _TSCHAR wxSChar;
typedef _TUCHAR wxUChar;
// ctype.h functions
#error "Please define your compiler's Unicode conventions in wxChar.h"
#endif
-typedef char wxChar;
-typedef signed char wxSChar;
-typedef unsigned char wxUChar;
+typedef char wxChar;
+typedef signed char wxSChar;
+typedef unsigned char wxUChar;
-#define _T(x) x
+#define _T(x) x
// ctype.h functions
#define wxIsalnum isalnum
/// safe version of strlen() (returns 0 if passed NULL pointer)
inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz)
-#if defined(_MSC_VER)
+#if defined(__VISUALC__)
{ return psz ? _tcslen(psz) : 0; }
#else
{ return psz ? strlen(psz) : 0; }
/// portable strcasecmp/_stricmp
inline int WXDLLEXPORT wxStricmp(const wxChar *, const wxChar *)
-#if defined(_MSC_VER)
+#if defined(__VISUALC__)
{ return _tcsicmp(psz1, psz2); }
#elif defined(__BORLANDC__)
{ return stricmp(psz1, psz2); }
return c1 - c2;
*/
-
+
#error "Please define string case-insensitive compare for your OS/compiler"
#endif // OS/compiler
#include "wx/defs.h"
#include "wx/string.h"
-#if wxUSE_IOSTREAMH
-#include <iostream.h>
-#else
-#include <iostream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
-#endif
+#include "wx/ioswrap.h"
#include "wx/list.h"
#include "wx/hash.h"
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c)
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// check if to use precompiled headers
-#if (defined(__BORLANDC__) || defined(_MSC_VER) || defined(__WATCOMC__)) && defined(__WXMSW__)
-#if !NOPCH
-#define WX_PRECOMP
-#endif
+#if (defined(__BORLANDC__) || defined(__VISUALC__) || defined(__WATCOMC__)) && defined(__WXMSW__)
+ #if !NOPCH
+ #define WX_PRECOMP
+ #endif
#endif
// For some reason, this must be defined for common dialogs to work.
#ifdef __WATCOMC__
-#define INCLUDE_COMMDLG_H 1
+#define INCLUDE_COMMDLG_H 1
#endif
// include the wx definitions
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <stdio.h>
#include <string.h>
+#include "wx/ioswrap.h"
+
#if wxUSE_IOSTREAMH
-#include <iostream.h>
-#include <fstream.h>
+ #include <fstream.h>
#else
-#include <iostream>
-#include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+ #include <fstream>
#endif
#if !USE_SHARED_LIBRARY
// ----------------------------------------------------------------------------
#ifdef __GNUG__
-#pragma implementation "file.h"
+ #pragma implementation "file.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/defs.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
// standard
#include <windows.h> // for GetTempFileName
#elif (defined(__UNIX__) || defined(__GNUWIN32__))
- #include <unistd.h>
-#ifdef __GNUWIN32__
- #include <windows.h>
-#endif
+ #include <unistd.h>
+ #ifdef __GNUWIN32__
+ #include <windows.h>
+ #endif
#elif (defined(__WXSTUBS__))
- // Have to ifdef this for different environments
- #include <io.h>
+ // Have to ifdef this for different environments
+ #include <io.h>
#elif (defined(__WXMAC__))
- int access( const char *path, int mode ) { return 0 ; }
- char* mktemp( char * path ) { return path ;}
- #include <unistd.h>
- #include <unix.h>
- #define W_OK 2
- #define R_OK 4
+ int access( const char *path, int mode ) { return 0 ; }
+ char* mktemp( char * path ) { return path ;}
+ #include <unistd.h>
+ #include <unix.h>
+ #define W_OK 2
+ #define R_OK 4
#else
- #error "Please specify the header with file functions declarations."
+ #error "Please specify the header with file functions declarations."
#endif //Win/UNIX
#include <stdio.h> // SEEK_xxx constants
#include <fcntl.h> // O_RDONLY &c
#ifndef __MWERKS__
-#include <sys/types.h> // needed for stat
-#include <sys/stat.h> // stat
+ #include <sys/types.h> // needed for stat
+ #include <sys/stat.h> // stat
#endif
// Microsoft compiler loves underscores, feed them to it
-#ifdef _MSC_VER
-
- #ifndef __MWERKS__
-
+#ifdef __VISUALC__
// functions
#define open _open
#define close _close
#define stat _stat
// constants
-
+
#define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY
#define O_RDWR _O_RDWR
#define S_IFDIR _S_IFDIR
#define S_IFREG _S_IFREG
-
- #endif
-
- #define W_OK 2
- #define R_OK 4
#else
#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 R_OK 4
#endif
#define O_BINARY (0)
#endif //__UNIX__
-
#ifdef __SALFORDC__
-#include <unix.h>
+ #include <unix.h>
#endif
// wxWindows
#include <wx/log.h>
#ifndef MAX_PATH
-#define MAX_PATH 512
+ #define MAX_PATH 512
#endif
#ifdef __WXMAC__
-char gwxMacFileName[ MAX_PATH ] ;
-char gwxMacFileName2[ MAX_PATH ] ;
-char gwxMacFileName3[ MAX_PATH ] ;
+ char gwxMacFileName[ MAX_PATH ] ;
+ char gwxMacFileName2[ MAX_PATH ] ;
+ char gwxMacFileName3[ MAX_PATH ] ;
#endif
// ============================================================================
// 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
#ifdef __SALFORDC__
- int fd = open(szFileName, O_WRONLY | O_CREAT |
+ int fd = open(szFileName, O_WRONLY | O_CREAT |
(bOverwrite ? O_TRUNC : O_EXCL));
#else
int fd = open(szFileName, O_WRONLY | O_CREAT |
bool wxFile::Flush()
{
if ( IsOpened() ) {
- #if (defined(_MSC_VER) && !defined(__MWERKS__)) || wxHAVE_FSYNC
+ #if defined(__VISUALC__) || wxHAVE_FSYNC
if ( fsync(m_fd) == -1 )
{
wxLogSysError(_("can't flush file descriptor %d"), m_fd);
{
wxASSERT( IsOpened() );
- #if defined( _MSC_VER ) && !defined( __MWERKS__ )
+ #ifdef __VISUALC__
int iRc = _filelength(m_fd);
- #else
+ #else // !VC++
int iRc = tell(m_fd);
if ( iRc != -1 ) {
// @ have to use const_cast :-(
iRc = iLen;
}
-
- #endif //_MSC_VER
+ #endif // VC++
if ( iRc == -1 ) {
wxLogSysError(_("can't find length of file on file descriptor %d"), m_fd);
// Created: 29/01/98
// RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <wx/intl.h>
// there are just too many of those...
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(disable:4706) // assignment within conditional expression
#endif // VC++
#include <stdlib.h>
#include <string.h>
#if !defined(__WATCOMC__)
-#if !(defined(_MSC_VER) && (_MSC_VER > 800))
-#include <errno.h>
-#endif
+ #if !(defined(_MSC_VER) && (_MSC_VER > 800))
+ #include <errno.h>
+ #endif
#endif
+
#include <time.h>
+
#ifndef __MWERKS__
#include <sys/types.h>
#include <sys/stat.h>
{
static const char PATH_TOKS[] =
#ifdef __WINDOWS__
- " ;"; // Don't seperate with colon in DOS (used for drive)
+ " ;"; // Don't seperate with colon in DOS (used for drive)
#else
- " :;";
+ " :;";
#endif
char *val = getenv (WXSTRINGCAST envVariable);
char *token = strtok (s, PATH_TOKS);
if (token)
- {
- Add (copystring (token));
- while (token)
- {
- if ((token = strtok ((char *) NULL, PATH_TOKS)) != NULL)
- Add (wxString(token));
- }
- }
+ {
+ Add (copystring (token));
+ while (token)
+ {
+ if ((token = strtok ((char *) NULL, PATH_TOKS)) != NULL)
+ Add (wxString(token));
+ }
+ }
delete[]s;
}
}
if (path_only)
{
if (!Member (wxString(path_only)))
- Add (wxString(path_only));
+ Add (wxString(path_only));
}
}
if (
#if defined(__WINDOWS__) || defined(__VMS__) || defined (__WXMAC__)
// Case INDEPENDENT
- path.CompareTo (path2, wxString::ignoreCase) == 0
+ path.CompareTo (path2, wxString::ignoreCase) == 0
#else
- // Case sensitive File System
- path.CompareTo (path2) == 0
+ // Case sensitive File System
+ path.CompareTo (path2) == 0
#endif
- )
- return TRUE;
+ )
+ return TRUE;
}
return FALSE;
}
#endif
if (wxFileExists (wxBuffer))
{
- return wxString(wxBuffer); // Found!
+ return wxString(wxBuffer); // Found!
}
- } // for()
+ } // for()
- return wxString(""); // Not found
+ return wxString(""); // Not found
}
wxString wxPathList::FindAbsoluteValidPath (const wxString& file)
}
}
-bool
+bool
wxFileExists (const wxString& filename)
{
#ifdef __GNUWIN32__ // (fix a B20 bug)
else
return TRUE;
#elif defined(__WXMAC__)
- struct stat stbuf;
- strcpy( gwxMacFileName , filename ) ;
- wxUnix2MacFilename( gwxMacFileName ) ;
- if (gwxMacFileName && stat ((char *)(const char *)gwxMacFileName, &stbuf) == 0)
- return TRUE;
+ struct stat stbuf;
+ strcpy( gwxMacFileName , filename ) ;
+ wxUnix2MacFilename( gwxMacFileName ) ;
+ if (gwxMacFileName && stat ((char *)(const char *)gwxMacFileName, &stbuf) == 0)
+ return TRUE;
return FALSE ;
#else
}
*/
-bool
+bool
wxIsAbsolutePath (const wxString& filename)
{
if (filename != "")
/* MSDOS */
|| filename[0] == '\\' || (isalpha (filename[0]) && filename[1] == ':')
#endif
- )
- return TRUE;
+ )
+ return TRUE;
}
return FALSE;
}
* IF one exists. Inserts zero into buffer.
*
*/
-
+
void wxStripExtension(char *buffer)
{
int len = strlen(buffer);
p = &path[2];
for (; *p; p++)
{
- if (*p == SEP)
- {
- if (p[1] == '.' && p[2] == '.' && (p[3] == SEP || p[3] == '\0'))
- {
+ if (*p == SEP)
+ {
+ if (p[1] == '.' && p[2] == '.' && (p[3] == SEP || p[3] == '\0'))
+ {
char *q;
- for (q = p - 1; q >= path && *q != SEP; q--);
- if (q[0] == SEP && (q[1] != '.' || q[2] != '.' || q[3] != SEP)
- && (q - 1 <= path || q[-1] != SEP))
- {
- strcpy (q, p + 3);
- if (path[0] == '\0')
- {
- path[0] = SEP;
- path[1] = '\0';
- }
+ for (q = p - 1; q >= path && *q != SEP; q--);
+ if (q[0] == SEP && (q[1] != '.' || q[2] != '.' || q[3] != SEP)
+ && (q - 1 <= path || q[-1] != SEP))
+ {
+ strcpy (q, p + 3);
+ if (path[0] == '\0')
+ {
+ path[0] = SEP;
+ path[1] = '\0';
+ }
#ifdef __WXMSW__
- /* Check that path[2] is NULL! */
- else if (path[1] == ':' && !path[2])
- {
- path[2] = SEP;
- path[3] = '\0';
- }
-#endif
- p = q - 1;
- }
- }
- else if (p[1] == '.' && (p[2] == SEP || p[2] == '\0'))
- strcpy (p, p + 2);
- }
+ /* Check that path[2] is NULL! */
+ else if (path[1] == ':' && !path[2])
+ {
+ path[2] = SEP;
+ path[3] = '\0';
+ }
+#endif
+ p = q - 1;
+ }
+ }
+ else if (p[1] == '.' && (p[2] == SEP || p[2] == '\0'))
+ strcpy (p, p + 2);
+ }
}
}
return path;
char ch = buf[strlen(buf) - 1];
#ifdef __WXMSW__
if (ch != '\\' && ch != '/')
- strcat(buf, "\\");
+ strcat(buf, "\\");
#else
if (ch != '/')
- strcat(buf, "/");
+ strcat(buf, "/");
#endif
strcat(buf, wxBuffer);
return copystring( wxRealPath(buf) );
~user/ => user's home dir
If the environment variable a = "foo" and b = "bar" then:
Unix:
- $a => foo
- $a$b => foobar
- $a.c => foo.c
- xxx$a => xxxfoo
- ${a}! => foo!
- $(b)! => bar!
- \$a => \$a
+ $a => foo
+ $a$b => foobar
+ $a.c => foo.c
+ xxx$a => xxxfoo
+ ${a}! => foo!
+ $(b)! => bar!
+ \$a => \$a
MSDOS:
- $a ==> $a
- $(a) ==> foo
- $(a)$b ==> foo$b
- $(a)$(b)==> foobar
- test.$$ ==> test.$$
+ $a ==> $a
+ $(a) ==> foo
+ $(a)$b ==> foo$b
+ $(a)$(b)==> foobar
+ test.$$ ==> test.$$
*/
/* input name in name, pathname output to buf. */
{
register char *d, *s, *nm;
char lnm[_MAXPATHLEN];
- int q;
+ int q;
// Some compilers don't like this line.
// const char trimchars[] = "\n \t";
#endif
buf[0] = '\0';
if (name == NULL || *name == '\0')
- return buf;
+ return buf;
nm = copystring(name); // Make a scratch copy
char *nm_tmp = nm;
/* Skip leading whitespace and cr */
while (strchr((char *)trimchars, *nm) != NULL)
- nm++;
+ nm++;
/* And strip off trailing whitespace and cr */
s = nm + (q = strlen(nm)) - 1;
while (q-- && strchr((char *)trimchars, *s) != NULL)
- *s = '\0';
+ *s = '\0';
s = nm;
d = lnm;
/* Expand inline environment variables */
while ((*d++ = *s)) {
#ifndef __WXMSW__
- if (*s == '\\') {
- if ((*(d - 1) = *++s)) {
- s++;
- continue;
- } else
- break;
- } else
+ if (*s == '\\') {
+ if ((*(d - 1) = *++s)) {
+ s++;
+ continue;
+ } else
+ break;
+ } else
#endif
#ifdef __WXMSW__
- if (*s++ == '$' && (*s == '{' || *s == ')'))
+ if (*s++ == '$' && (*s == '{' || *s == ')'))
#else
- if (*s++ == '$')
-#endif
- {
- register char *start = d;
- register int braces = (*s == '{' || *s == '(');
- register char *value;
- while ((*d++ = *s))
- if (braces ? (*s == '}' || *s == ')') : !(isalnum(*s) || *s == '_') )
- break;
- else
- s++;
- *--d = 0;
- value = getenv(braces ? start + 1 : start);
- if (value) {
- for ((d = start - 1); (*d++ = *value++););
- d--;
- if (braces && *s)
- s++;
- }
- }
+ if (*s++ == '$')
+#endif
+ {
+ register char *start = d;
+ register int braces = (*s == '{' || *s == '(');
+ register char *value;
+ while ((*d++ = *s))
+ if (braces ? (*s == '}' || *s == ')') : !(isalnum(*s) || *s == '_') )
+ break;
+ else
+ s++;
+ *--d = 0;
+ value = getenv(braces ? start + 1 : start);
+ if (value) {
+ for ((d = start - 1); (*d++ = *value++););
+ d--;
+ if (braces && *s)
+ s++;
+ }
+ }
}
/* Expand ~ and ~user */
s = "";
if (nm[0] == '~' && !q)
{
- /* prefix ~ */
- if (nm[1] == SEP || nm[1] == 0)
- { /* ~/filename */
- if ((s = wxGetUserHome("")) != NULL) {
- if (*++nm)
- nm++;
- }
+ /* prefix ~ */
+ if (nm[1] == SEP || nm[1] == 0)
+ { /* ~/filename */
+ if ((s = wxGetUserHome("")) != NULL) {
+ if (*++nm)
+ nm++;
+ }
} else
- { /* ~user/filename */
- register char *nnm;
- register char *home;
- for (s = nm; *s && *s != SEP; s++);
- int was_sep; /* MATTHEW: Was there a separator, or NULL? */
+ { /* ~user/filename */
+ register char *nnm;
+ register char *home;
+ for (s = nm; *s && *s != SEP; s++);
+ int was_sep; /* MATTHEW: Was there a separator, or NULL? */
was_sep = (*s == SEP);
- nnm = *s ? s + 1 : s;
- *s = 0;
- if ((home = wxGetUserHome(wxString(nm + 1))) == NULL) {
+ nnm = *s ? s + 1 : s;
+ *s = 0;
+ if ((home = wxGetUserHome(wxString(nm + 1))) == NULL) {
if (was_sep) /* replace only if it was there: */
- *s = SEP;
- s = "";
- } else {
- nm = nnm;
- s = home;
- }
- }
+ *s = SEP;
+ s = "";
+ } else {
+ nm = nnm;
+ s = home;
+ }
+ }
}
d = buf;
if (s && *s) { /* MATTHEW: s could be NULL if user '~' didn't exist */
- /* Copy home dir */
- while ('\0' != (*d++ = *s++))
- /* loop */;
- // Handle root home
- if (d - 1 > buf && *(d - 2) != SEP)
- *(d - 1) = SEP;
+ /* Copy home dir */
+ while ('\0' != (*d++ = *s++))
+ /* loop */;
+ // Handle root home
+ if (d - 1 > buf && *(d - 2) != SEP)
+ *(d - 1) = SEP;
}
s = nm;
while ((*d++ = *s++));
{
strcpy(wxBuffer, "~");
if (user != "")
- strcat(wxBuffer, (const char*) user);
+ strcat(wxBuffer, (const char*) user);
#ifdef __WXMSW__
// strcat(wxBuffer, "\\");
#else
tcp = path + strlen (path);
while (--tcp >= path)
- {
- if (*tcp == '/' || *tcp == '\\'
+ {
+ if (*tcp == '/' || *tcp == '\\'
#ifdef __VMS__
|| *tcp == ':' || *tcp == ']')
#else
)
#endif
- return tcp + 1;
- } /* while */
+ return tcp + 1;
+ } /* while */
#ifdef __WXMSW__
if (isalpha (*path) && *(path + 1) == ':')
- return path + 2;
+ return path + 2;
#endif
}
return path;
tcp = path + strlen (path);
while (--tcp >= path)
- {
- if (*tcp == '/' || *tcp == '\\'
+ {
+ if (*tcp == '/' || *tcp == '\\'
#ifdef __VMS__
|| *tcp == ':' || *tcp == ']')
#else
)
#endif
- return wxString(tcp + 1);
- } /* while */
+ return wxString(tcp + 1);
+ } /* while */
#ifdef __WXMSW__
if (isalpha (*path) && *(path + 1) == ':')
- return wxString(path + 2);
+ return wxString(path + 2);
#endif
}
// Yes, this should return the path, not an empty string, otherwise
#ifdef __WXMSW__
// Try Drive specifier
if (isalpha (buf[0]) && buf[1] == ':')
- {
- // A:junk --> A:. (since A:.\junk Not A:\junk)
- buf[2] = '.';
- buf[3] = '\0';
- return buf;
- }
+ {
+ // A:junk --> A:. (since A:.\junk Not A:\junk)
+ buf[2] = '.';
+ buf[3] = '\0';
+ return buf;
+ }
#endif
}
#ifdef __WXMSW__
// Try Drive specifier
if (isalpha (buf[0]) && buf[1] == ':')
- {
- // A:junk --> A:. (since A:.\junk Not A:\junk)
- buf[2] = '.';
- buf[3] = '\0';
- return wxString(buf);
- }
+ {
+ // A:junk --> A:. (since A:.\junk Not A:\junk)
+ buf[2] = '.';
+ buf[3] = '\0';
+ return wxString(buf);
+ }
#endif
}
// Also, convert to lower case, since case is significant in UNIX.
#ifdef __WXMAC__
-void
+void
wxMac2UnixFilename (char *s)
{
- if (s)
- {
- memmove( s+1 , s ,strlen( s ) + 1) ;
- if ( *s == ':' )
- *s = '.' ;
- else
- *s = '/' ;
-
- while (*s)
- {
- if (*s == ':')
- *s = '/';
- else
- *s = wxToLower (*s); // Case INDEPENDENT
- s++;
- }
- }
+ if (s)
+ {
+ memmove( s+1 , s ,strlen( s ) + 1) ;
+ if ( *s == ':' )
+ *s = '.' ;
+ else
+ *s = '/' ;
+
+ while (*s)
+ {
+ if (*s == ':')
+ *s = '/';
+ else
+ *s = wxToLower (*s); // Case INDEPENDENT
+ s++;
+ }
+ }
}
-void
+void
wxUnix2MacFilename (char *s)
{
- if (s)
- {
- if ( *s == '.' )
- {
- // relative path , since it goes on with slash which is translated to a :
- memmove( s , s+1 ,strlen( s ) ) ;
- }
- else if ( *s == '/' )
- {
- // absolute path -> on mac just start with the drive name
- memmove( s , s+1 ,strlen( s ) ) ;
- }
- else
- {
- wxASSERT_MSG( 1 , "unkown path beginning" ) ;
- }
- while (*s)
- {
- if (*s == '/' || *s == '\\')
- *s = ':';
-
- s++ ;
- }
- }
+ if (s)
+ {
+ if ( *s == '.' )
+ {
+ // relative path , since it goes on with slash which is translated to a :
+ memmove( s , s+1 ,strlen( s ) ) ;
+ }
+ else if ( *s == '/' )
+ {
+ // absolute path -> on mac just start with the drive name
+ memmove( s , s+1 ,strlen( s ) ) ;
+ }
+ else
+ {
+ wxASSERT_MSG( 1 , "unkown path beginning" ) ;
+ }
+ while (*s)
+ {
+ if (*s == '/' || *s == '\\')
+ *s = ':';
+
+ s++ ;
+ }
+ }
}
#endif
-void
+void
wxDos2UnixFilename (char *s)
{
if (s)
while (*s)
{
- if (*s == '\\')
- *s = '/';
+ if (*s == '\\')
+ *s = '/';
#ifdef __WXMSW__
- else
- *s = wxToLower (*s); // Case INDEPENDENT
+ else
+ *s = wxToLower (*s); // Case INDEPENDENT
#endif
- s++;
+ s++;
}
}
-void
+void
#ifdef __WXMSW__
wxUnix2DosFilename (char *s)
#else
if (s)
while (*s)
{
- if (*s == '/')
- *s = '\\';
- s++;
+ if (*s == '/')
+ *s = '\\';
+ s++;
}
#endif
}
// Concatenate two files to form third
-bool
+bool
wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& file3)
{
char *outfile = wxGetTempFileName("cat");
FILE *fp3 = (FILE *) NULL;
// Open the inputs and outputs
#ifdef __WXMAC__
- strcpy( gwxMacFileName , file1 ) ;
- wxUnix2MacFilename( gwxMacFileName ) ;
- strcpy( gwxMacFileName2 , file2) ;
- wxUnix2MacFilename( gwxMacFileName2 ) ;
- strcpy( gwxMacFileName3 , outfile) ;
- wxUnix2MacFilename( gwxMacFileName3 ) ;
+ strcpy( gwxMacFileName , file1 ) ;
+ wxUnix2MacFilename( gwxMacFileName ) ;
+ strcpy( gwxMacFileName2 , file2) ;
+ wxUnix2MacFilename( gwxMacFileName2 ) ;
+ strcpy( gwxMacFileName3 , outfile) ;
+ wxUnix2MacFilename( gwxMacFileName3 ) ;
if ((fp1 = fopen (gwxMacFileName, "rb")) == NULL ||
(fp2 = fopen (gwxMacFileName2, "rb")) == NULL ||
#endif
{
if (fp1)
- fclose (fp1);
+ fclose (fp1);
if (fp2)
- fclose (fp2);
+ fclose (fp2);
if (fp3)
- fclose (fp3);
+ fclose (fp3);
return FALSE;
}
}
// Copy files
-bool
+bool
wxCopyFile (const wxString& file1, const wxString& file2)
{
FILE *fd1;
int ch;
#ifdef __WXMAC__
- strcpy( gwxMacFileName , file1 ) ;
- wxUnix2MacFilename( gwxMacFileName ) ;
- strcpy( gwxMacFileName2 , file2) ;
- wxUnix2MacFilename( gwxMacFileName2 ) ;
+ strcpy( gwxMacFileName , file1 ) ;
+ wxUnix2MacFilename( gwxMacFileName ) ;
+ strcpy( gwxMacFileName2 , file2) ;
+ wxUnix2MacFilename( gwxMacFileName2 ) ;
if ((fd1 = fopen (gwxMacFileName, "rb")) == NULL)
return FALSE;
return TRUE;
}
-bool
+bool
wxRenameFile (const wxString& file1, const wxString& file2)
{
#ifdef __WXMAC__
- strcpy( gwxMacFileName , file1 ) ;
- wxUnix2MacFilename( gwxMacFileName ) ;
- strcpy( gwxMacFileName2 , file2) ;
- wxUnix2MacFilename( gwxMacFileName2 ) ;
+ strcpy( gwxMacFileName , file1 ) ;
+ wxUnix2MacFilename( gwxMacFileName ) ;
+ strcpy( gwxMacFileName2 , file2) ;
+ wxUnix2MacFilename( gwxMacFileName2 ) ;
if (0 == rename (gwxMacFileName, gwxMacFileName2))
return TRUE;
bool wxRemoveFile(const wxString& file)
{
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
int flag = remove(WXSTRINGCAST file);
#elif defined( __WXMAC__ )
- strcpy( gwxMacFileName , file ) ;
- wxUnix2MacFilename( gwxMacFileName ) ;
+ strcpy( gwxMacFileName , file ) ;
+ wxUnix2MacFilename( gwxMacFileName ) ;
int flag = unlink(gwxMacFileName);
#else
int flag = unlink(WXSTRINGCAST file);
#if defined(__WXSTUBS__)
return FALSE;
#elif defined(__VMS__)
- return FALSE;
+ return FALSE;
#elif defined( __WXMAC__ )
strcpy( gwxMacFileName , dir ) ;
wxUnix2MacFilename( gwxMacFileName ) ;
#ifdef __VMS__
return FALSE;
#elif defined( __WXMAC__ )
- strcpy( gwxMacFileName , dir ) ;
- wxUnix2MacFilename( gwxMacFileName ) ;
+ strcpy( gwxMacFileName , dir ) ;
+ wxUnix2MacFilename( gwxMacFileName ) ;
return (rmdir(WXSTRINGCAST gwxMacFileName) == 0);
#else
#endif
#if defined(__WIN32__)
- HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo);
-
- if (h==INVALID_HANDLE_VALUE)
- return FALSE;
- else {
- FindClose(h);
- return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
- }
+ HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo);
+
+ if (h==INVALID_HANDLE_VALUE)
+ return FALSE;
+ else {
+ FindClose(h);
+ return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
+ }
#else
// In Borland findfirst has a different argument
// ordering from _dos_findfirst. But _dos_findfirst
{
#ifdef __WINDOWS__
-#ifndef __WIN32__
+#ifndef __WIN32__
char tmp[144];
::GetTempFileName(0, WXSTRINGCAST prefix, 0, tmp);
#else
return buf;
#else
- static short last_temp = 0; // cache last to speed things a bit
+ static short last_temp = 0; // cache last to speed things a bit
// At most 1000 temp files to a process! We use a ring count.
char tmp[100]; // FIXME static buffer
{
sprintf (tmp, "/tmp/%s%d.%03x", WXSTRINGCAST prefix, (int) getpid (), (int) suffix);
if (!wxFileExists( tmp ))
- {
- // Touch the file to create it (reserve name)
- FILE *fd = fopen (tmp, "w");
- if (fd)
- fclose (fd);
- last_temp = suffix;
+ {
+ // Touch the file to create it (reserve name)
+ FILE *fd = fopen (tmp, "w");
+ if (fd)
+ fclose (fd);
+ last_temp = suffix;
if (buf)
- strcpy( buf, tmp);
- else
- buf = copystring( tmp );
- return buf;
- }
+ strcpy( buf, tmp);
+ else
+ buf = copystring( tmp );
+ return buf;
+ }
}
wxLogError( _("wxWindows: error finding temporary file name.\n") );
if (buf) buf[0] = 0;
/* MATTHEW: p is NULL => Local directory */
if (!p)
p = ".";
-
+
if ((wxDirStream=opendir(p))==NULL)
return (char *) NULL;
strcat(buf, nextDir->d_name);
if ((strcmp(nextDir->d_name, ".") == 0) ||
- (strcmp(nextDir->d_name, "..") == 0)) {
- if (wxFindFileFlags && !(wxFindFileFlags & wxDIR))
- continue;
- isdir = TRUE;
+ (strcmp(nextDir->d_name, "..") == 0)) {
+ if (wxFindFileFlags && !(wxFindFileFlags & wxDIR))
+ continue;
+ isdir = TRUE;
} else
- isdir = wxDirExists(buf);
-
+ isdir = wxDirExists(buf);
+
if (!wxFindFileFlags
- || ((wxFindFileFlags & wxDIR) && isdir)
- || ((wxFindFileFlags & wxFILE) && !isdir))
- return buf;
+ || ((wxFindFileFlags & wxDIR) && isdir)
+ || ((wxFindFileFlags & wxFILE) && !isdir))
+ return buf;
}
}
closedir(wxDirStream);
wxString path1(wxFileSpec);
char *p = wxPathOnly(WXSTRINGCAST path1);
if (p && (strlen(p) > 0))
- strcpy(wxBuffer, p);
+ strcpy(wxBuffer, p);
else
- wxBuffer[0] = 0;
+ wxBuffer[0] = 0;
#ifdef __WIN32__
if (wxFileStrucHandle != INVALID_HANDLE_VALUE)
- FindClose(wxFileStrucHandle);
+ FindClose(wxFileStrucHandle);
wxFileStrucHandle = ::FindFirstFile(WXSTRINGCAST spec, &wxFileStruc);
if (wxFileStrucHandle == INVALID_HANDLE_VALUE)
- return NULL;
+ return NULL;
bool isdir = !!(wxFileStruc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
if (isdir && !(flags & wxDIR))
- return wxFindNextFile();
+ return wxFindNextFile();
else if (!isdir && flags && !(flags & wxFILE))
- return wxFindNextFile();
+ return wxFindNextFile();
if (wxBuffer[0] != 0)
- strcat(wxBuffer, "\\");
+ strcat(wxBuffer, "\\");
strcat(wxBuffer, wxFileStruc.cFileName);
return wxBuffer;
#else
if (attrib & _A_SUBDIR) {
if (!(wxFindFileFlags & wxDIR))
- return wxFindNextFile();
+ return wxFindNextFile();
} else if (wxFindFileFlags && !(wxFindFileFlags & wxFILE))
- return wxFindNextFile();
+ return wxFindNextFile();
- if (wxBuffer[0] != 0)
- strcat(wxBuffer, "\\");
+ if (wxBuffer[0] != 0)
+ strcat(wxBuffer, "\\");
#ifdef __BORLANDC__
- strcat(wxBuffer, wxFileStruc.ff_name);
+ strcat(wxBuffer, wxFileStruc.ff_name);
#else
- strcat(wxBuffer, wxFileStruc.name);
+ strcat(wxBuffer, wxFileStruc.name);
#endif
- return wxBuffer;
+ return wxBuffer;
}
else
return NULL;
wxString p2(wxFileSpec);
char *p = wxPathOnly(WXSTRINGCAST p2);
if (p && (strlen(p) > 0))
- strcpy(wxBuffer, p);
+ strcpy(wxBuffer, p);
else
- wxBuffer[0] = 0;
-
+ wxBuffer[0] = 0;
+
try_again:
#ifdef __WIN32__
if (wxFileStrucHandle == INVALID_HANDLE_VALUE)
- return NULL;
+ return NULL;
bool success = (FindNextFile(wxFileStrucHandle, &wxFileStruc) != 0);
if (!success) {
- FindClose(wxFileStrucHandle);
+ FindClose(wxFileStrucHandle);
wxFileStrucHandle = INVALID_HANDLE_VALUE;
- return NULL;
+ return NULL;
}
bool isdir = !!(wxFileStruc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
if (isdir && !(wxFindFileFlags & wxDIR))
goto try_again;
else if (!isdir && wxFindFileFlags && !(wxFindFileFlags & wxFILE))
- goto try_again;
+ goto try_again;
if (wxBuffer[0] != 0)
strcat(wxBuffer, "\\");
strcat(wxBuffer, wxFileStruc.cFileName);
- return wxBuffer;
+ return wxBuffer;
#else
#ifdef __BORLANDC__
if (attrib & _A_SUBDIR) {
if (!(wxFindFileFlags & wxDIR))
- goto try_again;
+ goto try_again;
} else if (wxFindFileFlags && !(wxFindFileFlags & wxFILE))
goto try_again;
- if (wxBuffer[0] != 0)
+ if (wxBuffer[0] != 0)
strcat(wxBuffer, "\\");
#ifdef __BORLANDC__
- strcat(wxBuffer, wxFileStruc.ff_name);
+ strcat(wxBuffer, wxFileStruc.ff_name);
#else
- strcat(wxBuffer, wxFileStruc.name);
+ strcat(wxBuffer, wxFileStruc.name);
#endif
- return wxBuffer;
+ return wxBuffer;
}
else
return NULL;
{
if (!buf)
buf = new char[sz+1];
-#ifdef _MSC_VER
+#ifdef _MSC_VER
if (_getcwd(buf, sz) == NULL) {
#else
if (getcwd(buf, sz) == NULL) {
bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile)
{
// we assume that it's not empty
- wxCHECK_MSG( !IsEmpty(pszFile), FALSE,
+ wxCHECK_MSG( !IsEmpty(pszFile), FALSE,
_("empty file name in wxFindFileInPath"));
// skip path separator in the beginning of the file name if present
wxString tmp = pattern;
char *pat = WXSTRINGCAST(tmp);
while (*pat) {
- switch (*pat++) {
- case '?': case '*': case '[': case '{':
- return TRUE;
- case '\\':
- if (!*pat++)
- return FALSE;
- }
+ switch (*pat++) {
+ case '?': case '*': case '[': case '{':
+ return TRUE;
+ case '\\':
+ if (!*pat++)
+ return FALSE;
+ }
}
return FALSE;
};
// dot_special means '.' only matches '.'
if (dot_special && *str == '.' && *pattern != *str)
- return FALSE;
+ return FALSE;
while ((*pattern != '\0') && (!done)
&& (((*str=='\0')&&((*pattern==OB)||(*pattern=='*')))||(*str!='\0'))) {
- switch (*pattern) {
- case '\\':
- pattern++;
- if (*pattern != '\0')
- pattern++;
- break;
- case '*':
- pattern++;
- ret_code = FALSE;
- while ((*str!='\0')
- && (!(ret_code=wxMatchWild(pattern, str++, FALSE))))
- /*loop*/;
- if (ret_code) {
- while (*str != '\0')
- str++;
- while (*pattern != '\0')
- pattern++;
- }
- break;
- case '[':
- pattern++;
- repeat:
- if ((*pattern == '\0') || (*pattern == ']')) {
- done = TRUE;
- break;
- }
- if (*pattern == '\\') {
- pattern++;
- if (*pattern == '\0') {
- done = TRUE;
- break;
- }
- }
- if (*(pattern + 1) == '-') {
- c = *pattern;
- pattern += 2;
- if (*pattern == ']') {
- done = TRUE;
- break;
- }
- if (*pattern == '\\') {
- pattern++;
- if (*pattern == '\0') {
- done = TRUE;
- break;
- }
- }
- if ((*str < c) || (*str > *pattern)) {
- pattern++;
- goto repeat;
- }
- } else if (*pattern != *str) {
- pattern++;
- goto repeat;
- }
- pattern++;
- while ((*pattern != ']') && (*pattern != '\0')) {
- if ((*pattern == '\\') && (*(pattern + 1) != '\0'))
- pattern++;
- pattern++;
- }
- if (*pattern != '\0') {
- pattern++, str++;
- }
- break;
- case '?':
- pattern++;
- str++;
- break;
- case OB:
- pattern++;
- while ((*pattern != CB) && (*pattern != '\0')) {
- cp = str;
- ok = TRUE;
- while (ok && (*cp != '\0') && (*pattern != '\0')
- && (*pattern != ',') && (*pattern != CB)) {
- if (*pattern == '\\')
- pattern++;
- ok = (*pattern++ == *cp++);
- }
- if (*pattern == '\0') {
- ok = FALSE;
- done = TRUE;
- break;
- } else if (ok) {
- str = cp;
- while ((*pattern != CB) && (*pattern != '\0')) {
- if (*++pattern == '\\') {
- if (*++pattern == CB)
- pattern++;
- }
- }
- } else {
- while (*pattern!=CB && *pattern!=',' && *pattern!='\0') {
- if (*++pattern == '\\') {
+ switch (*pattern) {
+ case '\\':
+ pattern++;
+ if (*pattern != '\0')
+ pattern++;
+ break;
+ case '*':
+ pattern++;
+ ret_code = FALSE;
+ while ((*str!='\0')
+ && (!(ret_code=wxMatchWild(pattern, str++, FALSE))))
+ /*loop*/;
+ if (ret_code) {
+ while (*str != '\0')
+ str++;
+ while (*pattern != '\0')
+ pattern++;
+ }
+ break;
+ case '[':
+ pattern++;
+ repeat:
+ if ((*pattern == '\0') || (*pattern == ']')) {
+ done = TRUE;
+ break;
+ }
+ if (*pattern == '\\') {
+ pattern++;
+ if (*pattern == '\0') {
+ done = TRUE;
+ break;
+ }
+ }
+ if (*(pattern + 1) == '-') {
+ c = *pattern;
+ pattern += 2;
+ if (*pattern == ']') {
+ done = TRUE;
+ break;
+ }
+ if (*pattern == '\\') {
+ pattern++;
+ if (*pattern == '\0') {
+ done = TRUE;
+ break;
+ }
+ }
+ if ((*str < c) || (*str > *pattern)) {
+ pattern++;
+ goto repeat;
+ }
+ } else if (*pattern != *str) {
+ pattern++;
+ goto repeat;
+ }
+ pattern++;
+ while ((*pattern != ']') && (*pattern != '\0')) {
+ if ((*pattern == '\\') && (*(pattern + 1) != '\0'))
+ pattern++;
+ pattern++;
+ }
+ if (*pattern != '\0') {
+ pattern++, str++;
+ }
+ break;
+ case '?':
+ pattern++;
+ str++;
+ break;
+ case OB:
+ pattern++;
+ while ((*pattern != CB) && (*pattern != '\0')) {
+ cp = str;
+ ok = TRUE;
+ while (ok && (*cp != '\0') && (*pattern != '\0')
+ && (*pattern != ',') && (*pattern != CB)) {
+ if (*pattern == '\\')
+ pattern++;
+ ok = (*pattern++ == *cp++);
+ }
+ if (*pattern == '\0') {
+ ok = FALSE;
+ done = TRUE;
+ break;
+ } else if (ok) {
+ str = cp;
+ while ((*pattern != CB) && (*pattern != '\0')) {
+ if (*++pattern == '\\') {
+ if (*++pattern == CB)
+ pattern++;
+ }
+ }
+ } else {
+ while (*pattern!=CB && *pattern!=',' && *pattern!='\0') {
+ if (*++pattern == '\\') {
if (*++pattern == CB || *pattern == ',')
- pattern++;
- }
- }
- }
- if (*pattern != '\0')
- pattern++;
- }
- break;
- default:
- if (*str == *pattern) {
- str++, pattern++;
- } else {
- done = TRUE;
- }
- }
+ pattern++;
+ }
+ }
+ }
+ if (*pattern != '\0')
+ pattern++;
+ }
+ break;
+ default:
+ if (*str == *pattern) {
+ str++, pattern++;
+ } else {
+ done = TRUE;
+ }
+ }
}
while (*pattern == '*')
- pattern++;
+ pattern++;
return ((*str == '\0') && (*pattern == '\0'));
};
#endif
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression
#endif // VC++
// make life easier for people using VC++ IDE: clicking on the message will
// take us immediately to the place of the failed assert
-#ifdef _MSC_VER
+#ifdef __VISUALC__
sprintf(szBuf, _("%s(%d): assert failed"), szFile, nLine);
#else // !VC++
// make the error message more clear for all the others
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <wx/log.h>
#include <stdlib.h>
+#include "wx/ioswrap.h"
+
#if wxUSE_IOSTREAMH
-#include <iostream.h>
-#include <fstream.h>
+ #include <fstream.h>
#else
-#include <iostream>
-#include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+ #include <fstream>
#endif
#if !defined(__WATCOMC__) && !defined(__VMS__) && !defined( __MWERKS__ ) && !defined(__SALFORDC__)
// wxDebugContext wxTheDebugContext;
/*
Redefine new and delete so that we can pick up situations where:
- - we overwrite or underwrite areas of malloc'd memory.
- - we use uninitialise variables
+ - we overwrite or underwrite areas of malloc'd memory.
+ - we use uninitialise variables
Only do this in debug mode.
We change new to get enough memory to allocate a struct, followed
wxLogDebug("wxWindows memory checking error: %s", mesg);
PrintNode ();
-// << m_fileName << ' ' << m_lineNum << endl;
+// << m_fileName << ' ' << m_lineNum << endl;
}
/*
{
wxLogDebug("wxWindows over/underwrite memory error:");
PrintNode ();
-
+
// cerr << m_fileName << ' ' << m_lineNum << endl;
}
int wxMemStruct::AssertList ()
{
if (wxDebugContext::GetHead () != 0 && ! (wxDebugContext::GetHead ())->AssertIt () ||
- wxDebugContext::GetTail () != 0 && ! wxDebugContext::GetTail ()->AssertIt ()) {
- ErrorMsg ("Head or tail pointers trashed");
- return 0;
+ wxDebugContext::GetTail () != 0 && ! wxDebugContext::GetTail ()->AssertIt ()) {
+ ErrorMsg ("Head or tail pointers trashed");
+ return 0;
}
return 1;
}
int wxMemStruct::AssertIt ()
{
return (m_id == MemStructId &&
- (m_prev == 0 || m_prev->m_id == MemStructId) &&
- (m_next == 0 || m_next->m_id == MemStructId));
+ (m_prev == 0 || m_prev->m_id == MemStructId) &&
+ (m_next == 0 || m_next->m_id == MemStructId));
}
int wxMemStruct::Append ()
{
if (! AssertList ())
- return 0;
+ return 0;
if (wxDebugContext::GetHead () == 0) {
- if (wxDebugContext::GetTail () != 0) {
- ErrorMsg ("Null list should have a null tail pointer");
- return 0;
- }
- (void) wxDebugContext::SetHead (this);
- (void) wxDebugContext::SetTail (this);
+ if (wxDebugContext::GetTail () != 0) {
+ ErrorMsg ("Null list should have a null tail pointer");
+ return 0;
+ }
+ (void) wxDebugContext::SetHead (this);
+ (void) wxDebugContext::SetTail (this);
} else {
- wxDebugContext::GetTail ()->m_next = this;
- this->m_prev = wxDebugContext::GetTail ();
- (void) wxDebugContext::SetTail (this);
+ wxDebugContext::GetTail ()->m_next = this;
+ this->m_prev = wxDebugContext::GetTail ();
+ (void) wxDebugContext::SetTail (this);
}
return 1;
}
int wxMemStruct::Unlink ()
{
if (! AssertList ())
- return 0;
+ return 0;
if (wxDebugContext::GetHead () == 0 || wxDebugContext::GetTail () == 0) {
- ErrorMsg ("Trying to remove node from empty list");
- return 0;
+ ErrorMsg ("Trying to remove node from empty list");
+ return 0;
}
// Handle the part of the list before this node.
if (m_prev == 0) {
- if (this != wxDebugContext::GetHead ()) {
- ErrorMsg ("No previous node for non-head node");
- return 0;
- }
- (void) wxDebugContext::SetHead (m_next);
+ if (this != wxDebugContext::GetHead ()) {
+ ErrorMsg ("No previous node for non-head node");
+ return 0;
+ }
+ (void) wxDebugContext::SetHead (m_next);
} else {
- if (! m_prev->AssertIt ()) {
- ErrorMsg ("Trashed previous pointer");
- return 0;
- }
-
- if (m_prev->m_next != this) {
- ErrorMsg ("List is inconsistent");
- return 0;
- }
- m_prev->m_next = m_next;
+ if (! m_prev->AssertIt ()) {
+ ErrorMsg ("Trashed previous pointer");
+ return 0;
+ }
+
+ if (m_prev->m_next != this) {
+ ErrorMsg ("List is inconsistent");
+ return 0;
+ }
+ m_prev->m_next = m_next;
}
// Handle the part of the list after this node.
if (m_next == 0) {
- if (this != wxDebugContext::GetTail ()) {
- ErrorMsg ("No next node for non-tail node");
- return 0;
- }
- (void) wxDebugContext::SetTail (m_prev);
+ if (this != wxDebugContext::GetTail ()) {
+ ErrorMsg ("No next node for non-tail node");
+ return 0;
+ }
+ (void) wxDebugContext::SetTail (m_prev);
} else {
- if (! m_next->AssertIt ()) {
- ErrorMsg ("Trashed next pointer");
- return 0;
- }
-
- if (m_next->m_prev != this) {
- ErrorMsg ("List is inconsistent");
- return 0;
- }
- m_next->m_prev = m_prev;
+ if (! m_next->AssertIt ()) {
+ ErrorMsg ("Trashed next pointer");
+ return 0;
+ }
+
+ if (m_next->m_prev != this) {
+ ErrorMsg ("List is inconsistent");
+ return 0;
+ }
+ m_next->m_prev = m_prev;
}
return 1;
int nFailures = 0;
if (m_firstMarker != MemStartCheck) {
- nFailures++;
- ErrorMsg ();
+ nFailures++;
+ ErrorMsg ();
}
-
+
char * pointer = wxDebugContext::MidMarkerPos ((char *) this);
if (* (wxMarkerType *) pointer != MemMidCheck) {
- nFailures++;
- ErrorMsg ();
+ nFailures++;
+ ErrorMsg ();
}
-
+
pointer = wxDebugContext::EndMarkerPos ((char *) this, RequestSize ());
if (* (wxMarkerType *) pointer != MemEndCheck) {
- nFailures++;
- ErrorMsg ();
+ nFailures++;
+ ErrorMsg ();
}
-
+
return nFailures;
}
int wxMemStruct::CheckAllPrevious ()
{
int nFailures = 0;
-
+
for (wxMemStruct * st = this->m_prev; st != 0; st = st->m_prev) {
- if (st->AssertIt ())
- nFailures += st->CheckBlock ();
- else
- return -1;
+ if (st->AssertIt ())
+ nFailures += st->CheckBlock ();
+ else
+ return -1;
}
return nFailures;
void wxMemStruct::Dump ()
{
if (!ValidateNode()) return;
-
+
if (m_isObject)
{
wxObject *obj = (wxObject *)m_actualData;
{
char * startPointer = (char *) this;
if (!AssertIt ()) {
- if (IsDeleted ())
- ErrorMsg ("Object already deleted");
- else {
- // Can't use the error routines as we have no recognisable object.
+ if (IsDeleted ())
+ ErrorMsg ("Object already deleted");
+ else {
+ // Can't use the error routines as we have no recognisable object.
#ifndef __WXGTK__
- wxLogDebug("Can't verify memory struct - all bets are off!");
+ wxLogDebug("Can't verify memory struct - all bets are off!");
#endif
- }
- return 0;
+ }
+ return 0;
}
/*
if (* (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) != MemMidCheck)
ErrorMsg ();
if (* (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer,
- RequestSize ()) !=
- MemEndCheck)
+ RequestSize ()) !=
+ MemEndCheck)
ErrorMsg ();
// Back to before the extra buffer and check that
// we can still read what we originally wrote.
if (Marker () != MemStartCheck ||
- * (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer)
- != MemMidCheck ||
- * (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer,
- RequestSize ()) != MemEndCheck)
+ * (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer)
+ != MemMidCheck ||
+ * (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer,
+ RequestSize ()) != MemEndCheck)
{
- ErrorMsg ();
- return 0;
+ ErrorMsg ();
+ return 0;
}
return 1;
char * wxDebugContext::StartPos (const char * caller)
{
return ((char *) (caller - wxDebugContext::PaddedSize (sizeof(wxMarkerType)) -
- wxDebugContext::PaddedSize (sizeof (wxMemStruct))));
+ wxDebugContext::PaddedSize (sizeof (wxMemStruct))));
}
/*
size_t wxDebugContext::TotSize (const size_t reqSize)
{
return (PaddedSize (sizeof (wxMemStruct)) + PaddedSize (reqSize) +
- 2 * sizeof(wxMarkerType));
+ 2 * sizeof(wxMarkerType));
}
{
if (!from)
from = wxDebugContext::GetHead ();
-
+
for (wxMemStruct * st = from; st != 0; st = st->m_next)
{
void* data = st->GetActualData();
}
}
TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL));
-
+
wxLogDebug( "" );
wxLogDebug( "" );
wxLogDebug( "----- Memory statistics -----" );
}
}
-
+
bool currentMode = GetDebugMode();
SetDebugMode(FALSE);
-
+
long noNonObjectNodes = 0;
long noObjectNodes = 0;
long totalSize = 0;
if (!from)
from = wxDebugContext::GetHead ();
- wxMemStruct *st;
+ wxMemStruct *st;
for (st = from; st != 0; st = st->m_next)
{
void* data = st->GetActualData();
}
wxLogDebug("");
}
-
+
SetDebugMode(currentMode);
wxLogDebug("Number of object items: %ld", noObjectNodes);
#else
return FALSE;
#endif
-}
+}
bool wxDebugContext::PrintClasses(void)
{
wxLogDebug("");
wxLogDebug("");
return TRUE;
-}
+}
void wxDebugContext::SetCheckpoint(bool all)
{
int wxDebugContext::Check(bool checkAll)
{
int nFailures = 0;
-
+
wxMemStruct *from = (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL );
if (!from || checkAll)
from = wxDebugContext::GetHead ();
#endif
// 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
#endif
}
// VC++ 6.0
-#if _MSC_VER >= 1200
+#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
void operator delete(void* pData, char* /* fileName */, int /* lineNum */)
{
// ::operator delete(pData);
{
return (void *)malloc(size);
}
-
+
int totSize = wxDebugContext::TotSize (size);
char * buf = (char *) malloc(totSize);
if (!buf) {
- wxLogDebug("Call to malloc (%ld) failed.", (long)size);
- return 0;
+ wxLogDebug("Call to malloc (%ld) failed.", (long)size);
+ return 0;
}
wxMemStruct * st = (wxMemStruct *)buf;
st->m_firstMarker = MemStartCheck;
// Errors from Append() shouldn't really happen - but just in case!
if (st->Append () == 0) {
- st->ErrorMsg ("Trying to append new node");
+ st->ErrorMsg ("Trying to append new node");
}
-
+
if (wxDebugContext::GetCheckPrevious ()) {
- if (st->CheckAllPrevious () < 0) {
- st->ErrorMsg ("Checking previous nodes");
- }
+ if (st->CheckAllPrevious () < 0) {
+ st->ErrorMsg ("Checking previous nodes");
+ }
}
-
+
// Set up the extra markers at the middle and end.
char * ptr = wxDebugContext::MidMarkerPos (buf);
* (wxMarkerType *) ptr = MemMidCheck;
{
if (!buf)
return;
-
+
// If not in debugging allocation mode, do the normal thing
// so we don't leave any trace of ourselves in the node list.
if (!wxDebugContext::GetDebugMode())
wxMemStruct * st = (wxMemStruct *) wxDebugContext::StructPos (startPointer);
if (! st->ValidateNode ())
- return;
+ return;
// If this is the current checkpoint, we need to
// move the checkpoint back so it points to a valid
{
st->ErrorMsg ("Unlinking deleted node");
}
-
+
// Now put in the fill char into the id slot and the caller requested
// memory locations.
st->SetDeleted ();
(void) memset (wxDebugContext::CallerMemPos (startPointer), MemFillChar,
- st->RequestSize ());
+ st->RequestSize ());
// Don't allow delayed freeing of memory in this version
// if (!wxDebugContext::GetDelayFree())
{
if (wxDebugContext::GetLevel() < level)
return;
-
+
va_list ap;
static char buffer[512];
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#endif
#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT
- // for wxObject::Dump
-#if wxUSE_IOSTREAMH
-# include <iostream.h>
-#else
-# include <iostream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
-#endif
+ // for wxObject::Dump
+ #include "wx/ioswrap.h"
#endif
#if !USE_SHARED_LIBRARY
}
// VC++ 6.0
-#if _MSC_VER >= 1200
+#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum */)
{
::operator delete(pData);
#endif
// 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)
{
return wxDebugAlloc(size, fileName, lineNum, TRUE, TRUE);
// Name: odbc.cpp
// Purpose: ODBC implementation
// Author: Julian Smart, Olaf Klein (oklein@smallo.ruhr.de),
-// Patrick Halke (patrick@zaphod.ruhr.de)
-// Modified by:
+// Patrick Halke (patrick@zaphod.ruhr.de)
+// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#if wxUSE_ODBC
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(disable:4706) // assignment within conditional expression
#endif // VC++
return dirty;
}
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression
#endif // VC++
#if wxUSE_WX_RESOURCES
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(disable:4706) // assignment within conditional expression
#endif // VC++
return table->CreateItem((wxWindow *)this, resource, parentResource);
}
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression
#endif // VC++
#if wxUSE_WX_RESOURCES
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(disable:4706) // assignment within conditional expression
#endif // VC++
return table->CreateItem((wxWindow *)this, resource, parentResource);
}
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression
#endif // VC++
#include <signal.h>
#include <errno.h>
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#include <io.h>
#endif
// implementations (such as PC-NFS) will require you to include this
// 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 i = set->fd_count;
SockMsg msg;
// warning about 'cast truncates constant value'
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(disable: 4310)
-#endif // _MSC_VER
+#endif // __VISUALC__
msg.sig[0] = (char) 0xad;
msg.sig[1] = (char) 0xde;
return *this;
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(default: 4310)
-#endif // _MSC_VER
+#endif // __VISUALC__
}
wxSocketBase& wxSocketBase::Unread(const char *buffer, size_t nbytes)
// function: for Unix this is done with configure, for Windows we test the
// compiler explicitly.
#ifdef __WXMSW__
- #ifdef _MSC_VER
+ #ifdef __VISUALC__
#define wxVsprintf _vsnprintf
#endif
#else // !Windows
#ifndef __SC__
#pragma message("Using sprintf() because no snprintf()-like function defined")
#endif
-#endif
+#endif // no vsnprintf
// ----------------------------------------------------------------------------
// global functions
// iostream ones.
//
// 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__
- #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))
+istream& operator>>(istream& is, wxString& WXUNUSED(str))
{
#if 0
int w = is.width(0);
if ( is.ipfx(0) ) {
- NAMESPACE streambuf *sb = is.rdbuf();
+ streambuf *sb = is.rdbuf();
str.erase();
while ( true ) {
int ch = sb->sbumpc ();
if ( ch == EOF ) {
- is.setstate(NAMESPACE ios::eofbit);
+ is.setstate(ios::eofbit);
break;
}
else if ( isspace(ch) ) {
is.isfx();
if ( str.length() == 0 )
- is.setstate(NAMESPACE ios::failbit);
+ is.setstate(ios::failbit);
#endif
return is;
}
}
// 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
{
return find(wxString(sz, n == npos ? 0 : n), nStart);
}
-#endif
+#endif // VC++ 1.5
// Gives a duplicate symbol (presumably a case-insensitivity problem)
#if !defined(__BORLANDC__)
}
// 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
{
return rfind(wxString(sz, n == npos ? 0 : n), nStart);
return p == NULL ? npos : p - c_str();
}
-#endif
+#endif // VC++ 1.5
wxString wxString::substr(size_t nStart, size_t nLen) const
{
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include "wx/time.h"
#include "wx/date.h"
#include "wx/utils.h"
-#include <wx/intl.h>
+#include "wx/intl.h"
+
+#include "wx/ioswrap.h"
#if wxUSE_IOSTREAMH
-#include <iostream.h>
-#include <iomanip.h>
+ #include <iomanip.h>
#else
-#include <iostream>
-#include <iomanip>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+ #include <iomanip>
#endif
#include <string.h>
static bool wxTimeInitialized = FALSE;
-wxTime::tFormat wxTime::Format = wxTime::wx12h;
-wxTime::tPrecision wxTime::Precision = wxTime::wxStdMinSec;
+wxTime::tFormat wxTime::Format = wxTime::wx12h;
+wxTime::tPrecision wxTime::Precision = wxTime::wxStdMinSec;
static const unsigned long seconds_in_day = 24*60*60L;
static const wxDate refDate(1,1,1901);
wxTime wxTime::GetLocalTime(const wxDate& date, hourTy h, minuteTy m, secondTy s)
/*
- Return a local wxTime for the specified Standard Time date, hour, minute,
- and second.
+ Return a local wxTime for the specified Standard Time date, hour, minute,
+ and second.
*/
{
if (!wxTimeInitialized)
{
- wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
- wxTimeInitialized = TRUE;
+ wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
+ wxTimeInitialized = TRUE;
}
/*
- if (!date.IsBetween(refDate,maxDate))
- setError(NIHCL_DATERANGE,DEFAULT,
- date.dayOfMonth(),date.nameOfMonth(),date.year());
+ if (!date.IsBetween(refDate,maxDate))
+ setError(NIHCL_DATERANGE,DEFAULT,
+ date.dayOfMonth(),date.nameOfMonth(),date.year());
*/
// The following line causes an error in GCC 2.1
// long daysBetween = date-refDate;
wxTime::wxTime()
/*
- Construct a wxTime for this instant.
+ Construct a wxTime for this instant.
*/
{
if (!wxTimeInitialized)
{
- wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
- wxTimeInitialized = TRUE;
+ wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
+ wxTimeInitialized = TRUE;
}
sec = wxGetCurrentTime();
#ifdef __SALFORDC__
wxTime::wxTime(hourTy h, minuteTy m, secondTy s, bool dst)
/*
- Construct a wxTime for today at the specified (local) hour, minute, and
- second.
+ Construct a wxTime for today at the specified (local) hour, minute, and
+ second.
*/
{
if (!wxTimeInitialized)
{
- wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
- wxTimeInitialized = TRUE;
+ wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
+ wxTimeInitialized = TRUE;
}
sec = wxTime(wxDate(),h,m,s,dst).sec;
if (!wxTimeInitialized)
{
wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED);
- wxTimeInitialized = TRUE;
+ wxTimeInitialized = TRUE;
}
sec = GetLocalTime(date,h,m,s).sec-3600;
if (IsDST())
sec += 3600;
/*
if (IsDST()) setError(NIHCL_BADTIME,DEFAULT,
- date.dayOfMonth(),date.nameOfMonth(),date.year(),
- h,m,s,(dst?_("DST"):""));
+ date.dayOfMonth(),date.nameOfMonth(),date.year(),
+ h,m,s,(dst?_("DST"):""));
*/
}
sec += TIME_ZONE; // adjust to GMT
#ifndef __SALFORDC__
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
- long daycount = (long)(GetLocalTime().sec/seconds_in_day);
+ long daycount = (long)(GetLocalTime().sec/seconds_in_day);
wxDate date(1,1,1901);
date += daycount;
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.
*/
{
- return GetLocalTime().GetHourGMT();
+ return GetLocalTime().GetHourGMT();
}
hourTy wxTime::GetHourGMT() const
Return the hour of this Time in GMT.
*/
{
- return (hourTy)((sec % 86400) / 3600);
+ return (hourTy)((sec % 86400) / 3600);
}
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.
*/
{
wxTime DSTtime(GetLocalTime(wxDate(3,31,year).Previous(1)+7,2));
if (year<=1986) {
// Previous Sunday
- DSTtime = GetLocalTime(wxDate(4,30,year).Previous(1),2);
- if (year==1974) DSTtime = GetLocalTime(wxDate(1,6,1974),2);
+ DSTtime = GetLocalTime(wxDate(4,30,year).Previous(1),2);
+ if (year==1974) DSTtime = GetLocalTime(wxDate(1,6,1974),2);
if (year==1975) DSTtime = GetLocalTime(wxDate(2,23,1975),2);
}
return DSTtime;
ends in the specified year.
*/
{
- wxTime STDtime(GetLocalTime(wxDate(10,31,year).Previous(1),2-1));
- return STDtime;
+ wxTime STDtime(GetLocalTime(wxDate(10,31,year).Previous(1),2-1));
+ return STDtime;
}
bool wxTime::IsDST() const
long daycount = (long)(sec/seconds_in_day);
// 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.)
- wxDate date(1,1,1901);
+ // Need to convert to julian date (which starts at 1/1/4713 B.C.)
+ wxDate date(1,1,1901);
date += daycount;
unsigned year = date.GetYear();
- if (DST_OBSERVED)
+ if (DST_OBSERVED)
{
if (*this >= GetBeginDST(year))
if (*this < GetEndDST(year)) return TRUE;
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;
return local_time;
}
minuteTy wxTime::GetMinute() const
/*
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 the minute of this wxTime in GMT.
*/
{
- return (minuteTy)(((sec % 86400) % 3600) / 60);
+ return (minuteTy)(((sec % 86400) % 3600) / 60);
}
secondTy wxTime::GetSecond() const
Return the second of this wxTime.
*/
{
- return (secondTy)(((sec % 86400) % 3600) % 60);
+ return (secondTy)(((sec % 86400) % 3600) % 60);
}
secondTy wxTime::GetSecondGMT() const
wxTime wxTime::Min(const wxTime& t) const
{
if (t > *this) return *this;
- return t;
+ return t;
}
#ifndef __SALFORDC__
#endif
void wxTime::SetFormat(const wxTime::tFormat lFormat,
- const wxTime::tPrecision lPrecision) {
+ const wxTime::tPrecision lPrecision) {
- wxTime::Format = lFormat;
- wxTime::Precision = lPrecision;
+ wxTime::Format = lFormat;
+ wxTime::Precision = lPrecision;
}
char *wxTime::FormatTime() const {
- static char timeBuf[30];
- unsigned hh(GetHour());
-
- switch (Format) {
- case wx12h:
- hh -= 12;
- break;
- case wx24h:
- break;
- }
-
- switch (Precision) {
- case wxStdMinSec:
- sprintf(timeBuf,"%2d:%02d:%02d",hh,GetMinute(),GetSecond());
- break;
- case wxStdMin:
- sprintf(timeBuf,"%2d:%02d",hh,GetMinute());
- break;
- }
-
- if (Format == wx12h)
- if (GetHour() <= 12)
- strcat(timeBuf,_("am"));
- else
- strcat(timeBuf,_("pm"));
-
- return timeBuf;
+ static char timeBuf[30];
+ unsigned hh(GetHour());
+
+ switch (Format) {
+ case wx12h:
+ hh -= 12;
+ break;
+ case wx24h:
+ break;
+ }
+
+ switch (Precision) {
+ case wxStdMinSec:
+ sprintf(timeBuf,"%2d:%02d:%02d",hh,GetMinute(),GetSecond());
+ break;
+ case wxStdMin:
+ sprintf(timeBuf,"%2d:%02d",hh,GetMinute());
+ break;
+ }
+
+ if (Format == wx12h)
+ if (GetHour() <= 12)
+ strcat(timeBuf,_("am"));
+ else
+ strcat(timeBuf,_("pm"));
+
+ return timeBuf;
}
/*
int wxTime::compare(const Object& ob) const
{
- assertArgSpecies(ob,classDesc,"compare");
+ assertArgSpecies(ob,classDesc,"compare");
register clockTy t = castdown(ob).sec;
if (sec < t) return -1;
if (sec > t) return 1;
wxDate(*this).printOn(strm);
strm << ' ' << ((hh <= 12) ? hh : hh-12) << ':'
<< setfill('0') << setw(2) << GetMinute() << ':'
- << setfill('0') << setw(2) << GetSecond() << ' ';
+ << setfill('0') << setw(2) << GetSecond() << ' ';
if (hh < 12) strm << _("am");
else strm << _("pm");
}
wxTime::wxTime(OIOin& strm)
- : BASE(strm)
+ : BASE(strm)
{
- unsigned long usec;
- strm >> sec >> usec;
+ unsigned long usec;
+ strm >> sec >> usec;
}
void wxTime::storer(OIOout& strm) const
wxTime::wxTime(OIOifd& fd)
- : BASE(fd)
+ : BASE(fd)
{
- unsigned long usec;
- fd >> sec >> usec;
+ unsigned long usec;
+ fd >> sec >> usec;
}
void wxTime::storer(OIOofd& fd) const
{
- BASE::storer(fd);
- fd << sec << 0l;
+ BASE::storer(fd);
+ fd << sec << 0l;
}
*/
// Created: 29/01/98
// RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include "wx/textdlg.h"
#endif
+#include "wx/ioswrap.h"
+
#if wxUSE_IOSTREAMH
-#include <iostream.h>
-#include <fstream.h>
+ #include <fstream.h>
#else
-#include <iostream>
-#include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+ #include <fstream>
#endif
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#if !defined(__WATCOMC__)
-#if !(defined(_MSC_VER) && (_MSC_VER > 800))
-#include <errno.h>
-#endif
+ #if !(defined(_MSC_VER) && (_MSC_VER > 800))
+ #include <errno.h>
+ #endif
#endif
#include <time.h>
#ifndef __MWERKS__
{
register char c1, c2;
- while( maxchar--)
+ while( maxchar--)
{
c1 = tolower(*str_1++);
c2 = tolower(*str_2++);
-
+
if ( !c1 || c1!=c2 )
- return c1 - c2;
-
+ return c1 - c2;
+
} ;
return 0 ;
#endif
#endif
-#ifdef _MSC_VER
-#pragma warning (disable : 4245)
-#endif
-
-#ifdef _MSC_VER
-#pragma warning (default : 4245)
-#endif
-
#else
// This declaration is missing in SunOS!
// (Yes, I know it is NOT ANSI-C but its in BSD libc)
int strncasecmp (const char *, const char *, size_t);
}
#endif
-#endif /* __WXMSW__ */
+#endif /* __WXMSW__ */
char *
size_t len = strlen (s) + 1;
char *news = new char[len];
- memcpy (news, s, len); // Should be the fastest
+ memcpy (news, s, len); // Should be the fastest
return news;
}
// Id generation
static long wxCurrentId = 100;
-long
+long
wxNewId (void)
{
return wxCurrentId++;
long
wxGetCurrentId(void) { return wxCurrentId; }
-void
+void
wxRegisterId (long id)
{
if (id >= wxCurrentId)
wxCurrentId = id + 1;
}
-void
+void
StringToFloat (char *s, float *number)
{
if (s && *s && number)
*number = (float) strtod (s, (char **) NULL);
}
-void
+void
StringToDouble (char *s, double *number)
{
if (s && *s && number)
return buf;
}
-void
+void
StringToInt (char *s, int *number)
{
if (s && *s && number)
*number = (int) strtol (s, (char **) NULL, 10);
}
-void
+void
StringToLong (char *s, long *number)
{
if (s && *s && number)
int wxHexToDec(const wxString& buf)
{
int firstDigit, secondDigit;
-
+
if (buf.GetChar(0) >= 'A')
firstDigit = buf.GetChar(0) - 'A' + 10;
else
secondDigit = buf.GetChar(1) - 'A' + 10;
else
secondDigit = buf.GetChar(1) - '0';
-
+
return firstDigit * 16 + secondDigit;
}
}
// Match a string INDEPENDENT OF CASE
-bool
+bool
StringMatch (char *str1, char *str2, bool subString, bool exact)
{
if (str1 == NULL || str2 == NULL)
// Search for str1 in str2
// Slow .... but acceptable for short strings
for (i = 0; i <= len2 - len1; i++)
- {
- if (strncasecmp (str1, str2 + i, len1) == 0)
- return TRUE;
- }
+ {
+ if (strncasecmp (str1, str2 + i, len1) == 0)
+ return TRUE;
+ }
}
else if (exact)
{
if (strcasecmp (str1, str2) == 0)
- return TRUE;
+ return TRUE;
}
else
{
int len2 = strlen (str2);
if (strncasecmp (str1, str2, wxMin (len1, len2)) == 0)
- return TRUE;
+ return TRUE;
}
return FALSE;
wxString wxNow( void )
{
time_t now = time((time_t *) NULL);
- char *date = ctime(&now);
+ char *date = ctime(&now);
date[24] = '\0';
return wxString(date);
}
{
if (!in)
return (char *) NULL;
-
+
if (!out)
out = copystring(in);
char *tmpOut = out;
-
+
while (*in)
{
if (*in == '&')
- {
- // Check && -> &, &x -> x
- if (*++in == '&')
- *out++ = *in++;
- }
+ {
+ // Check && -> &, &x -> x
+ if (*++in == '&')
+ *out++ = *in++;
+ }
else if (*in == '\t')
- {
+ {
// Remove all stuff after \t in X mode, and let the stuff as is
// in Windows mode.
// Accelerators are handled in wx_item.cc for Motif, and are not
// YET supported in XView
- break;
- }
+ break;
+ }
else
- *out++ = *in++;
- } // while
+ *out++ = *in++;
+ } // while
*out = '\0';
else
{
for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ())
- {
- wxWindow *win = (wxWindow *) node->Data ();
- wxWindow *retwin = wxFindWindowByLabel1 (title, win);
- if (retwin)
- return retwin;
- } // for()
+ {
+ wxWindow *win = (wxWindow *) node->Data ();
+ wxWindow *retwin = wxFindWindowByLabel1 (title, win);
+ if (retwin)
+ return retwin;
+ } // for()
}
return (wxWindow *) NULL;
if (parent)
{
if (parent->GetLabel() == title)
- return parent;
+ return parent;
}
if (parent)
{
for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
- {
- wxWindow *win = (wxWindow *) node->Data ();
- wxWindow *retwin = wxFindWindowByLabel1 (title, win);
- if (retwin)
- return retwin;
- } // for()
+ {
+ wxWindow *win = (wxWindow *) node->Data ();
+ wxWindow *retwin = wxFindWindowByLabel1 (title, win);
+ if (retwin)
+ return retwin;
+ } // for()
}
- return (wxWindow *) NULL; // Not found
+ return (wxWindow *) NULL; // Not found
}
else
{
for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ())
- {
- wxWindow *win = (wxWindow *) node->Data ();
- wxWindow *retwin = wxFindWindowByName1 (title, win);
- if (retwin)
- return retwin;
- } // for()
+ {
+ wxWindow *win = (wxWindow *) node->Data ();
+ wxWindow *retwin = wxFindWindowByName1 (title, win);
+ if (retwin)
+ return retwin;
+ } // for()
}
// Failed? Try by label instead.
{
if (parent)
{
- if ( parent->GetName() == title )
- return parent;
+ if ( parent->GetName() == title )
+ return parent;
}
if (parent)
{
for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
- {
- wxWindow *win = (wxWindow *) node->Data ();
- wxWindow *retwin = wxFindWindowByName1 (title, win);
- if (retwin)
- return retwin;
- } // for()
+ {
+ wxWindow *win = (wxWindow *) node->Data ();
+ wxWindow *retwin = wxFindWindowByName1 (title, win);
+ if (retwin)
+ return retwin;
+ } // for()
}
- return (wxWindow *) NULL; // Not found
+ return (wxWindow *) NULL; // Not found
}
// Returns menu item id or -1 if none.
-int
+int
wxFindMenuItemId (wxFrame * frame, const wxString& menuString, const wxString& itemString)
{
wxMenuBar *menuBar = frame->GetMenuBar ();
> 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
> executable directory.
->
+>
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).
-|| 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,
|| FAX: +1 (617)965-1636 MA 02159 USA
Email: ken@als.com WWW: http://www.als.com
/*--------------------------------------------------------------------*
| whereami is given a filename f in the form: whereami(argv[0])
- | It returns the directory in which the executable file (containing
- | this code [main.c] ) may be found. A dot will be returned to indicate
+ | It returns the directory in which the executable file (containing
+ | this code [main.c] ) may be found. A dot will be returned to indicate
| the current directory.
*--------------------------------------------------------------------*/
whereami(name)
char *name;
{
- register char *cutoff = NULL; /* stifle -Wall */
+ register char *cutoff = NULL; /* stifle -Wall */
register char *s;
register char *t;
int cc;
if (access(name, R_OK) == 0) {
- /*-------------------------------------------------------------*
- * The file was accessible without any other work. But the current
- * working directory might change on us, so if it was accessible
- * through the cwd, then we should get it for later accesses.
- *-------------------------------------------------------------*/
+ /*-------------------------------------------------------------*
+ * The file was accessible without any other work. But the current
+ * working directory might change on us, so if it was accessible
+ * through the cwd, then we should get it for later accesses.
+ *-------------------------------------------------------------*/
- t = imagedir;
- if (!absolute_pathname(name)) {
+ t = imagedir;
+ if (!absolute_pathname(name)) {
#if defined(DOS) || defined(__WIN32__)
- int drive;
- char *newrbuf;
+ int drive;
+ char *newrbuf;
- newrbuf = imagedir;
+ newrbuf = imagedir;
#ifndef __DJGPP__
- if (*(name + 1) == ':') {
- if (*name >= 'a' && *name <= 'z')
- drive = (int) (*name - 'a' + 1);
- else
- drive = (int) (*name - 'A' + 1);
- *newrbuf++ = *name;
- *newrbuf++ = *(name + 1);
- *newrbuf++ = DIR_SEPARATOR;
- }
- else {
- drive = 0;
- *newrbuf++ = DIR_SEPARATOR;
- }
- if (getcwd(newrbuf, drive) == 0) { /* } */
+ if (*(name + 1) == ':') {
+ if (*name >= 'a' && *name <= 'z')
+ drive = (int) (*name - 'a' + 1);
+ else
+ drive = (int) (*name - 'A' + 1);
+ *newrbuf++ = *name;
+ *newrbuf++ = *(name + 1);
+ *newrbuf++ = DIR_SEPARATOR;
+ }
+ else {
+ drive = 0;
+ *newrbuf++ = DIR_SEPARATOR;
+ }
+ if (getcwd(newrbuf, drive) == 0) { /* } */
#else
- if (getcwd(newrbuf, 1024) == 0) { /* } */
+ if (getcwd(newrbuf, 1024) == 0) { /* } */
#endif
#else /* DOS */
#ifdef HAVE_GETWD
- if (getwd(imagedir) == 0) { /* } */
+ if (getwd(imagedir) == 0) { /* } */
#else /* !HAVE_GETWD */
- if (getcwd(imagedir, 1024) == 0) {
+ if (getcwd(imagedir, 1024) == 0) {
#endif /* !HAVE_GETWD */
#endif /* DOS */
- fatal_error(FE_GETCWD, 0);
- }
- for (; *t; t++) /* Set t to end of buffer */
- ;
- if (*(t - 1) == DIR_SEPARATOR) /* leave slash if already
- * last char
- */
- cutoff = t - 1;
- else {
- cutoff = t; /* otherwise put one in */
- *t++ = DIR_SEPARATOR;
- }
- }
+ fatal_error(FE_GETCWD, 0);
+ }
+ for (; *t; t++) /* Set t to end of buffer */
+ ;
+ if (*(t - 1) == DIR_SEPARATOR) /* leave slash if already
+ * last char
+ */
+ cutoff = t - 1;
+ else {
+ cutoff = t; /* otherwise put one in */
+ *t++ = DIR_SEPARATOR;
+ }
+ }
#if (!defined(__MAC__) && !defined(__DJGPP__) && !defined(__GO32__) && !defined(__WIN32__))
- else
- (*t++ = DIR_SEPARATOR);
+ else
+ (*t++ = DIR_SEPARATOR);
#endif
- /*-------------------------------------------------------------*
- * 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
- * is not presently set but will be on the first iteration of the
- * loop below.
- *-------------------------------------------------------------*/
+ /*-------------------------------------------------------------*
+ * 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
+ * is not presently set but will be on the first iteration of the
+ * loop below.
+ *-------------------------------------------------------------*/
- for ((*name == DIR_SEPARATOR ? (s = name+1) : (s = name));;) {
- if (*s == DIR_SEPARATOR)
- cutoff = t;
- if (!(*t++ = *s++))
- break;
- }
+ for ((*name == DIR_SEPARATOR ? (s = name+1) : (s = name));;) {
+ if (*s == DIR_SEPARATOR)
+ cutoff = t;
+ if (!(*t++ = *s++))
+ break;
+ }
}
else {
- /*-------------------------------------------------------------*
- * Get the path list from the environment. If the path list is
- * inaccessible for any reason, leave with fatal error.
- *-------------------------------------------------------------*/
+ /*-------------------------------------------------------------*
+ * Get the path list from the environment. If the path list is
+ * inaccessible for any reason, leave with fatal error.
+ *-------------------------------------------------------------*/
#ifdef __MAC__
- if ((s = getenv("Commands")) == (char *) 0)
+ if ((s = getenv("Commands")) == (char *) 0)
#else
- if ((s = getenv("PATH")) == (char *) 0)
+ if ((s = getenv("PATH")) == (char *) 0)
#endif
- fatal_error(FE_PATH, 0);
-
- /*
- * Copy path list into ebuf and set the source pointer to the
- * beginning of this buffer.
- */
-
- strcpy(ebuf, s);
- s = ebuf;
-
- for (;;) {
- t = imagedir;
- while (*s && *s != PATH_SEPARATOR)
- *t++ = *s++;
- if (t > imagedir && *(t - 1) == DIR_SEPARATOR)
- ; /* do nothing -- slash already is in place */
- else
- *t++ = DIR_SEPARATOR; /* put in the slash */
- cutoff = t - 1; /* set cutoff */
- strcpy(t, name);
- if (access(imagedir, R_OK) == 0)
- break;
-
- if (*s)
- s++; /* advance source pointer */
- else
- fatal_error(FE_INFND, 0);
- }
+ fatal_error(FE_PATH, 0);
+
+ /*
+ * Copy path list into ebuf and set the source pointer to the
+ * beginning of this buffer.
+ */
+
+ strcpy(ebuf, s);
+ s = ebuf;
+
+ for (;;) {
+ t = imagedir;
+ while (*s && *s != PATH_SEPARATOR)
+ *t++ = *s++;
+ if (t > imagedir && *(t - 1) == DIR_SEPARATOR)
+ ; /* do nothing -- slash already is in place */
+ else
+ *t++ = DIR_SEPARATOR; /* put in the slash */
+ cutoff = t - 1; /* set cutoff */
+ strcpy(t, name);
+ if (access(imagedir, R_OK) == 0)
+ break;
+
+ if (*s)
+ s++; /* advance source pointer */
+ else
+ fatal_error(FE_INFND, 0);
+ }
}
#ifdef HAVE_SYMLINK
while ((cc = readlink(imagedir, ebuf, 512)) != -1) {
- ebuf[cc] = 0;
- s = ebuf;
- if (*s == DIR_SEPARATOR) {
- t = imagedir;
- }
- else {
- t = cutoff + 1;
- }
- for (;;) {
- if (*s == DIR_SEPARATOR)
- cutoff = t; /* mark the last slash seen */
- if (!(*t++ = *s++)) /* copy the character */
- break;
- }
+ ebuf[cc] = 0;
+ s = ebuf;
+ if (*s == DIR_SEPARATOR) {
+ t = imagedir;
+ }
+ else {
+ t = cutoff + 1;
+ }
+ for (;;) {
+ if (*s == DIR_SEPARATOR)
+ cutoff = t; /* mark the last slash seen */
+ if (!(*t++ = *s++)) /* copy the character */
+ break;
+ }
}
#endif /* HAVE_SYMLINK */
- strcpy(imagename, cutoff + 1); /* keep the image name */
- *(cutoff + 1) = 0; /* chop off the filename part */
+ strcpy(imagename, cutoff + 1); /* keep the image name */
+ *(cutoff + 1) = 0; /* chop off the filename part */
}
#endif
}
#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
// Created: 10/09/98
// RCS-ID: $Id$
// Copyright: (c)
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#if wxUSE_IOSTREAMH
# include <fstream.h>
#else
# include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
#endif
#include "wx/stream.h"
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#endif
#if wxUSE_IOSTREAMH
-#include <fstream.h>
+ #include <fstream.h>
#else
-#include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+ #include <fstream>
#endif
#include <stdarg.h>
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#endif
// suppress annoying warning "'this' used in base member init list" (so what?)
-#ifdef _MSC_VER
-#pragma warning(disable: 4355)
+#ifdef __VISUALC__
+ #pragma warning(disable: 4355)
#endif // Visual C++
wxXLPHelpController::wxXLPHelpController(void)
helpRunning = FALSE; helpConnection = NULL;
}
-#ifdef _MSC_VER
-#pragma warning(default: 4355)
+#ifdef __VISUALC__
+ #pragma warning(default: 4355)
#endif // Visual C++
wxXLPHelpController::~wxXLPHelpController(void)
bool wxXLPHelpController::DisplayContents(void)
{
- if (!helpRunning)
- {
+ if (!helpRunning)
+ {
if (!Run())
return FALSE;
}
if (helpConnection)
- return helpConnection->Execute("s -1");
+ return helpConnection->Execute("s -1");
else
- return FALSE;
+ return FALSE;
}
bool wxXLPHelpController::DisplaySection(int section)
{
if (!helpRunning)
- {
+ {
if (!Run())
return FALSE;
}
bool wxXLPHelpController::DisplayBlock(long block)
{
if (!helpRunning)
- {
+ {
if (!Run())
return FALSE;
}
bool wxXLPHelpController::KeywordSearch(const wxString& k)
{
if (!helpRunning)
- {
+ {
if (!Run())
return FALSE;
}
// This is to foil optimizations in Visual C++ that throw out dummy.obj.
// PLEASE DO NOT ALTER THIS.
-#if defined(_MSC_VER) && !defined(WXMAKINGDLL)
+#if defined(__VISUALC__) && !defined(WXMAKINGDLL)
extern char wxDummyChar;
if (wxDummyChar) wxDummyChar++;
#endif
#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
// temporarily disable this warning
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(disable: 4715) // not all control paths return a value
#endif // Visual C++
// FIXME other compilers must support Win32 SEH (structured exception
// handling) too, just find the appropriate keyword in their docs!
// 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
- __try {
+ __try {
#else
#undef CATCH_PROGRAM_EXCEPTIONS
#endif
}
// restore warning state
-#ifdef _MSC_VER
+#ifdef __VISUALC__
#pragma warning(default: 4715) // not all control paths return a value
#endif // Visual C++
// 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 (defined(_MSC_VER) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__TWIN32__))
+#if (defined(__VISUALC__) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__TWIN32__))
#include "main.cpp"
#endif
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Microsoft, Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
-#include <wx/msw/dibutils.h>
+
+#include "wx/msw/dibutils.h"
#if defined(__WIN32__)
#if !defined(__MWERKS__) && !defined(__SALFORDC__)
#include <memory.h> // for _fmemcpy()
#endif
- #define _huge
+ #define _huge
#ifndef hmemcpy
#define hmemcpy memcpy
#endif
for(Counter = 0; Counter < 256; Counter++)
{
Palette.aEntries[Counter].peRed = 0;
- Palette.aEntries[Counter].peGreen = 0;
+ Palette.aEntries[Counter].peGreen = 0;
Palette.aEntries[Counter].peBlue = 0;
Palette.aEntries[Counter].peFlags = PC_NOCOLLAPSE;
}
if (ScreenPalette)
{
- ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE);
- nMapped = RealizePalette(ScreenDC);
+ ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE);
+ nMapped = RealizePalette(ScreenDC);
ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE);
bOK = DeleteObject(ScreenPalette);
}
int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi)
{
- HFILE fh;
- OFSTRUCT of;
+ HFILE fh;
+ OFSTRUCT of;
- fh = OpenFile(szFile, &of, OF_WRITE | OF_CREATE);
+ fh = OpenFile(szFile, &of, OF_WRITE | OF_CREATE);
if (!fh) {
-// printf("la regamos0");
- return 0;
+// printf("la regamos0");
+ return 0;
}
long size = DibSize(lpbi);
bmf.bfReserved1 = 0;
bmf.bfReserved2 = 0;
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 ||
- _hwrite(fh, (LPCSTR)lpbi, size)<0) {
- _lclose(fh);
-// printf("la regamos1");
- return 0;
+ _hwrite(fh, (LPCSTR)lpbi, size)<0) {
+ _lclose(fh);
+// printf("la regamos1");
+ return 0;
}
#else
if (_hwrite(fh, (LPBYTE)(&bmf), sizeof(bmf))<0 ||
- _hwrite(fh, (LPBYTE)lpbi, size)<0) {
- _lclose(fh);
-// printf("la regamos1");
- return 0;
+ _hwrite(fh, (LPBYTE)lpbi, size)<0) {
+ _lclose(fh);
+// printf("la regamos1");
+ return 0;
}
#endif
PDIB DibOpenFile(LPSTR szFile)
{
- HFILE fh;
- DWORD dwLen;
- DWORD dwBits;
- PDIB pdib;
- LPVOID p;
- OFSTRUCT of;
+ HFILE fh;
+ DWORD dwLen;
+ DWORD dwBits;
+ PDIB pdib;
+ LPVOID p;
+ OFSTRUCT of;
#if defined(WIN32) || defined(_WIN32)
- #define GetCurrentInstance() GetModuleHandle(NULL)
+ #define GetCurrentInstance() GetModuleHandle(NULL)
#else
- #define GetCurrentInstance() (HINSTANCE)SELECTOROF((LPVOID)&of)
+ #define GetCurrentInstance() (HINSTANCE)SELECTOROF((LPVOID)&of)
#endif
- fh = OpenFile(szFile, &of, OF_READ);
+ fh = OpenFile(szFile, &of, OF_READ);
- if (fh == -1)
- {
- HRSRC h;
+ if (fh == -1)
+ {
+ HRSRC h;
// TODO: Unicode version
#ifdef __WIN16__
- h = FindResource(GetCurrentInstance(), szFile, RT_BITMAP);
+ h = FindResource(GetCurrentInstance(), szFile, RT_BITMAP);
#else
- h = FindResourceA(GetCurrentInstance(), szFile, RT_BITMAP);
+ h = FindResourceA(GetCurrentInstance(), szFile, RT_BITMAP);
#endif
#if defined(__WIN32__)
- //!!! can we call GlobalFree() on this? is it the right format.
- //!!! can we write to this resource?
- if (h)
- return (PDIB)LockResource(LoadResource(GetCurrentInstance(), h));
+ //!!! can we call GlobalFree() on this? is it the right format.
+ //!!! can we write to this resource?
+ if (h)
+ return (PDIB)LockResource(LoadResource(GetCurrentInstance(), h));
#else
- if (h)
- fh = AccessResource(GetCurrentInstance(), h);
+ if (h)
+ fh = AccessResource(GetCurrentInstance(), h);
#endif
- }
+ }
- if (fh == -1)
- return NULL;
+ if (fh == -1)
+ return NULL;
- pdib = DibReadBitmapInfo(fh);
+ pdib = DibReadBitmapInfo(fh);
- if (!pdib)
- return NULL;
+ if (!pdib)
+ return NULL;
/* How much memory do we need to hold the DIB */
/* Can we get more memory? */
- p = GlobalReAllocPtr(pdib,dwLen,0);
+ p = GlobalReAllocPtr(pdib,dwLen,0);
if (!p)
{
- GlobalFreePtr(pdib);
+ GlobalFreePtr(pdib);
pdib = NULL;
}
else
if (pdib)
{
- /* read in the bits */
- _hread(fh, (LPBYTE)pdib + (UINT)pdib->biSize + DibPaletteSize(pdib), dwBits);
+ /* read in the bits */
+ _hread(fh, (LPBYTE)pdib + (UINT)pdib->biSize + DibPaletteSize(pdib), dwBits);
}
_lclose(fh);
*pdw++ = 0x00000000; // 0000 black
*pdw++ = 0x00800000; // 0001 dark red
*pdw++ = 0x00008000; // 0010 dark green
- *pdw++ = 0x00808000; // 0011 mustard
+ *pdw++ = 0x00808000; // 0011 mustard
*pdw++ = 0x00000080; // 0100 dark blue
*pdw++ = 0x00800080; // 0101 purple
*pdw++ = 0x00008080; // 0110 dark turquoise
*pdw++ = 0x00808080; // 0111 dark gray
*pdw++ = 0x00FF0000; // 1001 red
*pdw++ = 0x0000FF00; // 1010 green
- *pdw++ = 0x00FFFF00; // 1011 yellow
+ *pdw++ = 0x00FFFF00; // 1011 yellow
*pdw++ = 0x000000FF; // 1100 blue
*pdw++ = 0x00FF00FF; // 1101 pink (magenta)
*pdw++ = 0x0000FFFF; // 1110 cyan
BOOL DibMapToPalette(PDIB pdib, HPALETTE hpal)
{
- LPBITMAPINFOHEADER lpbi;
- PALETTEENTRY pe;
- int n;
- int nDibColors;
- int nPalColors=0;
- BYTE FAR * lpBits;
- RGBQUAD FAR * lpRgb;
- BYTE xlat[256];
- DWORD SizeImage;
-
- if (!hpal || !pdib)
- return FALSE;
-
- lpbi = (LPBITMAPINFOHEADER)pdib;
- lpRgb = DibColors(pdib);
-
- GetObject(hpal,sizeof(int),(LPSTR)&nPalColors);
- nDibColors = DibNumColors(pdib);
-
- if ((SizeImage = lpbi->biSizeImage) == 0)
- SizeImage = DibSizeImage(lpbi);
-
- //
- // build a xlat table. from the current DIB colors to the given
- // palette.
- //
- for (n=0; n<nDibColors; n++)
- xlat[n] = (BYTE)GetNearestPaletteIndex(hpal,RGB(lpRgb[n].rgbRed,lpRgb[n].rgbGreen,lpRgb[n].rgbBlue));
-
- lpBits = (LPBYTE)DibPtr(lpbi);
- lpbi->biClrUsed = nPalColors;
-
- //
- // re-size the DIB
- //
- if (nPalColors > nDibColors)
- {
- GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0);
- hmemmove((BYTE _huge *)DibPtr(lpbi), (BYTE _huge *)lpBits, SizeImage);
- lpBits = (LPBYTE)DibPtr(lpbi);
- }
- else if (nPalColors < nDibColors)
- {
- hmemcpy(DibPtr(lpbi), lpBits, SizeImage);
- GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0);
- lpBits = (LPBYTE)DibPtr(lpbi);
- }
-
- //
- // translate the DIB bits
- //
- switch (lpbi->biCompression)
- {
- case BI_RLE8:
- xlatRle8(lpBits, SizeImage, xlat);
- break;
-
- case BI_RLE4:
- xlatRle4(lpBits, SizeImage, xlat);
- break;
+ LPBITMAPINFOHEADER lpbi;
+ PALETTEENTRY pe;
+ int n;
+ int nDibColors;
+ int nPalColors=0;
+ BYTE FAR * lpBits;
+ RGBQUAD FAR * lpRgb;
+ BYTE xlat[256];
+ DWORD SizeImage;
+
+ if (!hpal || !pdib)
+ return FALSE;
+
+ lpbi = (LPBITMAPINFOHEADER)pdib;
+ lpRgb = DibColors(pdib);
+
+ GetObject(hpal,sizeof(int),(LPSTR)&nPalColors);
+ nDibColors = DibNumColors(pdib);
+
+ if ((SizeImage = lpbi->biSizeImage) == 0)
+ SizeImage = DibSizeImage(lpbi);
+
+ //
+ // build a xlat table. from the current DIB colors to the given
+ // palette.
+ //
+ for (n=0; n<nDibColors; n++)
+ xlat[n] = (BYTE)GetNearestPaletteIndex(hpal,RGB(lpRgb[n].rgbRed,lpRgb[n].rgbGreen,lpRgb[n].rgbBlue));
+
+ lpBits = (LPBYTE)DibPtr(lpbi);
+ lpbi->biClrUsed = nPalColors;
+
+ //
+ // re-size the DIB
+ //
+ if (nPalColors > nDibColors)
+ {
+ GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0);
+ hmemmove((BYTE _huge *)DibPtr(lpbi), (BYTE _huge *)lpBits, SizeImage);
+ lpBits = (LPBYTE)DibPtr(lpbi);
+ }
+ else if (nPalColors < nDibColors)
+ {
+ hmemcpy(DibPtr(lpbi), lpBits, SizeImage);
+ GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0);
+ lpBits = (LPBYTE)DibPtr(lpbi);
+ }
+
+ //
+ // translate the DIB bits
+ //
+ switch (lpbi->biCompression)
+ {
+ case BI_RLE8:
+ xlatRle8(lpBits, SizeImage, xlat);
+ break;
+
+ case BI_RLE4:
+ xlatRle4(lpBits, SizeImage, xlat);
+ break;
case BI_RGB:
- if (lpbi->biBitCount == 8)
+ if (lpbi->biBitCount == 8)
xlatClut8(lpBits, SizeImage, xlat);
else
xlatClut4(lpBits, SizeImage, xlat);
GetPaletteEntries(hpal,n,1,&pe);
lpRgb[n].rgbRed = pe.peRed;
- lpRgb[n].rgbGreen = pe.peGreen;
- lpRgb[n].rgbBlue = pe.peBlue;
- lpRgb[n].rgbReserved = (BYTE)0;
- }
+ lpRgb[n].rgbGreen = pe.peGreen;
+ lpRgb[n].rgbBlue = pe.peBlue;
+ lpRgb[n].rgbReserved = (BYTE)0;
+ }
- return TRUE;
+ return TRUE;
}
WORD nColors = Info->bmiHeader.biClrUsed;
if (nColors) {
- LOGPALETTE* logPal = (LOGPALETTE*)
- new BYTE[sizeof(LOGPALETTE) + (nColors-1)*sizeof(PALETTEENTRY)];
-
- logPal->palVersion = 0x300; // Windows 3.0 version
- logPal->palNumEntries = nColors;
- for (short n = 0; n < nColors; n++) {
- logPal->palPalEntry[n].peRed = rgb[n].rgbRed;
- logPal->palPalEntry[n].peGreen = rgb[n].rgbGreen;
- logPal->palPalEntry[n].peBlue = rgb[n].rgbBlue;
- logPal->palPalEntry[n].peFlags = (BYTE)flags;
- }
- hPalette = ::CreatePalette(logPal);
- delete logPal;
+ LOGPALETTE* logPal = (LOGPALETTE*)
+ new BYTE[sizeof(LOGPALETTE) + (nColors-1)*sizeof(PALETTEENTRY)];
+
+ logPal->palVersion = 0x300; // Windows 3.0 version
+ logPal->palNumEntries = nColors;
+ for (short n = 0; n < nColors; n++) {
+ logPal->palPalEntry[n].peRed = rgb[n].rgbRed;
+ logPal->palPalEntry[n].peGreen = rgb[n].rgbGreen;
+ logPal->palPalEntry[n].peBlue = rgb[n].rgbBlue;
+ logPal->palPalEntry[n].peFlags = (BYTE)flags;
+ }
+ hPalette = ::CreatePalette(logPal);
+ delete logPal;
} else
- hPalette = 0;
+ hPalette = 0;
return hPalette;
}
/*
- * File: dummy.cc
- * Purpose: See below
- * Author: Julian Smart
- * Created: 1993
- * Updated:
+ * File: dummy.cc
+ * Purpose: See below
+ * Author: Julian Smart
+ * Created: 1993
+ * Updated:
* Copyright: (c) 1993, AIAI, University of Edinburgh
*/
// Foils optimizations in Visual C++ (see also app.cpp). Without it,
// dummy.obj isn't linked and we get a linker error.
-#if defined(_MSC_VER)
+#if defined(__VISUALC__)
char wxDummyChar = 0;
#endif
#if !defined(APIENTRY)
#define APIENTRY FAR PASCAL
#endif
-
+
int
#ifdef __WATCOMC__
PASCAL
/*
- * File: dummydll.cc
- * Purpose:
- * Author: Julian Smart
- * Created: 1993
- * Updated:
+ * File: dummydll.cc
+ * Purpose:
+ * Author: Julian Smart
+ * Created: 1993
+ * Updated:
* 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
// Foils optimizations in Visual C++ (see also app.cpp). Without it,
// dummy.obj isn't linked and we get a linker error.
-#if defined(_MSC_VER) && defined(__WIN16__)
-char wxDummyChar=0;
+#if defined(__VISUALC__) && defined(__WIN16__)
+ char wxDummyChar=0;
#endif
// Name: msw/ole/dataobj.cpp
// Purpose: implementation of wx[I]DataObject class
// Author: Vadim Zeitlin
-// Modified by:
+// Modified by:
// Created: 10.05.98
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
return E_NOTIMPL;
}
- wxIEnumFORMATETC *pEnum =
+ wxIEnumFORMATETC *pEnum =
new wxIEnumFORMATETC(m_pDataObject->GetPreferredFormat());
pEnum->AddRef();
*ppenumFormatEtc = pEnum;
{
#ifdef __WXDEBUG__
// case 'xxx' is not a valid value for switch of enum 'wxDataFormat'
- #ifdef _MSC_VER
+ #ifdef __VISUALC__
#pragma warning(disable:4063)
#endif // VC++
return s_szBuf;
}
- #ifdef _MSC_VER
+ #ifdef __VISUALC__
#pragma warning(default:4063)
#endif // VC++
// Name: ole/oleutils.cpp
// Purpose: implementation of OLE helper functions
// Author: Vadim Zeitlin
-// Modified by:
+// Modified by:
// Created: 19.02.98
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
#include <wx/msw/ole/uuid.h>
#include <wx/msw/ole/oleutils.h>
-#if defined(_MSC_VER) && (_MSC_VER > 1000)
-#include <docobj.h>
+#if defined(__VISUALC__) && (__VISUALC__ > 1000)
+ #include <docobj.h>
#endif
// ============================================================================
// Debug support
// ----------------------------------------------------------------------------
-#if defined(__WXDEBUG__) && defined(_MSC_VER) && (_MSC_VER > 1000)
+#if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ > 1000)
const char *GetIidName(REFIID riid)
{
// an association between symbolic name and numeric value of an IID
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <string.h>
#if wxUSE_IOSTREAMH
-#include <fstream.h>
+# include <fstream.h>
#else
-#include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+# include <fstream>
#endif
#include <windows.h>
{
// wxMessageBox(message, "PNG error");
- longjmp(png_ptr->jmpbuf, 1);
+ longjmp(png_ptr->jmpbuf, 1);
}
wxPNGReader::wxPNGReader(void)
{
filetype = 0;
- RawImage = NULL; // Image data
+ RawImage = NULL; // Image data
- Width = 0; Height = 0; // Dimensions
- Depth = 0; // (bits x pixel)
- ColorType = 0; // Bit 1 = Palette used
- // Bit 2 = Color used
- // Bit 3 = Alpha used
+ Width = 0; Height = 0; // Dimensions
+ Depth = 0; // (bits x pixel)
+ ColorType = 0; // Bit 1 = Palette used
+ // Bit 2 = Color used
+ // Bit 3 = Alpha used
- EfeWidth = 0; // Efective Width
+ EfeWidth = 0; // Efective Width
lpbi = NULL;
bgindex = -1;
{
imageOK = FALSE;
filetype = 0;
- RawImage = NULL; // Image data
+ RawImage = NULL; // Image data
- Width = 0; Height = 0; // Dimensions
- Depth = 0; // (bits x pixel)
- ColorType = 0; // Bit 1 = Palette used
- // Bit 2 = Color used
- // Bit 3 = Alpha used
+ Width = 0; Height = 0; // Dimensions
+ Depth = 0; // (bits x pixel)
+ ColorType = 0; // Bit 1 = Palette used
+ // Bit 2 = Color used
+ // Bit 3 = Alpha used
- EfeWidth = 0; // Efective Width
+ EfeWidth = 0; // Efective Width
lpbi = NULL;
bgindex = -1;
if (lpbi) {
#ifdef __WIN16__
- GlobalFreePtr((unsigned int) lpbi);
+ GlobalFreePtr((unsigned int) lpbi);
#else
- GlobalFreePtr(lpbi);
+ GlobalFreePtr(lpbi);
#endif
-// delete Palette;
+// delete Palette;
}
RawImage = 0;
Palette = 0;
if (lpbi = DibCreate(Depth, Width, Height)) {
- RawImage = (ImagePointerType)DibPtr(lpbi);
- EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
+ RawImage = (ImagePointerType)DibPtr(lpbi);
+ EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
imageOK = TRUE;
}
}
{
if (lpbi) {
#ifdef __WIN16__
- GlobalFreePtr((unsigned int) lpbi);
+ GlobalFreePtr((unsigned int) lpbi);
#else
- GlobalFreePtr(lpbi);
+ GlobalFreePtr(lpbi);
#endif
- delete Palette;
+ delete Palette;
}
}
if (!Inside(x, y)) return FALSE;
if (Palette) {
- return Palette->GetRGB(GetIndex(x, y), r, g, b);
-/* PALETTEENTRY entry;
- ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry);
- *r = entry.peRed;
- *g = entry.peGreen;
- *b = entry.peBlue; */
+ return Palette->GetRGB(GetIndex(x, y), r, g, b);
+/* PALETTEENTRY entry;
+ ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry);
+ *r = entry.peRed;
+ *g = entry.peGreen;
+ *b = entry.peBlue; */
} else {
- ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
- *b = ImagePointer[0];
- *g = ImagePointer[1];
- *r = ImagePointer[2];
+ ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+ *b = ImagePointer[0];
+ *g = ImagePointer[1];
+ *r = ImagePointer[2];
}
return TRUE;
}
if (ColorType & COLORTYPE_PALETTE)
{
- if (!Palette) return FALSE;
- SetIndex(x, y, Palette->GetPixel(r, g, b));
+ if (!Palette) return FALSE;
+ SetIndex(x, y, Palette->GetPixel(r, g, b));
} else {
- ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
- ImagePointer[0] = b;
- ImagePointer[1] = g;
- ImagePointer[2] = r;
+ ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+ ImagePointer[0] = b;
+ ImagePointer[1] = g;
+ ImagePointer[2] = r;
}
return TRUE;
bool wxPNGReader::SetPalette(wxPalette* colourmap)
{
if (!colourmap)
- return FALSE;
+ return FALSE;
ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
Palette = colourmap;
return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
{
Palette = new wxPalette();
if (!Palette)
- return FALSE;
+ return FALSE;
if (!g) g = r;
if (!b) b = g;
{
Palette = new wxPalette();
if (!Palette)
- return FALSE;
+ return FALSE;
byte r[256], g[256], b[256];
for(int i=0; i<n; i++)
{
- r[i] = rgb_struct[i].red;
- g[i] = rgb_struct[i].green;
- b[i] = rgb_struct[i].blue;
+ r[i] = rgb_struct[i].red;
+ g[i] = rgb_struct[i].green;
+ b[i] = rgb_struct[i].blue;
}
// Added by JACS copying from Andrew Davison's additions
// to GIF-reading code
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
// is a memory dc that must have a bitmap selected into it)
HDC dc2 = GetDC(NULL);
if ( Palette )
{
HPALETTE oldPal = ::SelectPalette(dc, (HPALETTE) Palette->GetHPALETTE(), FALSE);
- ::RealizePalette(dc);
+ ::RealizePalette(dc);
}
- HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi,
- CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS);
+ HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi,
+ CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS);
::SelectPalette(dc, NULL, TRUE);
::SelectObject(dc, oldBitmap);
wxMask *mask = CreateMask();
bitmap->SetMask(mask);
}
- return TRUE;
+ return TRUE;
}
else
{
return FALSE;
}
- }
- else
+ }
+ else
{
- return FALSE;
+ return FALSE;
}
}
// To get number of entries...
WORD count = 0;
::GetObject((HPALETTE) cmap->GetHPALETTE(), sizeof(WORD), &count);
-
+
LOGPALETTE* logPal = (LOGPALETTE*)
- new BYTE[sizeof(LOGPALETTE) + count*sizeof(PALETTEENTRY)];
+ new BYTE[sizeof(LOGPALETTE) + count*sizeof(PALETTEENTRY)];
logPal->palVersion = 0x300;
logPal->palNumEntries = count;
::GetPaletteEntries((HPALETTE) cmap->GetHPALETTE(), 0, count, logPal->palPalEntry);
-
+
HPALETTE hPalette = ::CreatePalette(logPal);
delete[] logPal;
{
HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL);
- HDC dc = ::CreateCompatibleDC(NULL);
+ HDC dc = ::CreateCompatibleDC(NULL);
HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap);
int bgIndex = GetBGIndex();
else
::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255));
- }
+ }
}
::SelectObject(dc, oldBitmap);
wxMask *mask = new wxMask;
int number_passes;
if (ImageFileName)
- strcpy(filename, ImageFileName);
+ strcpy(filename, ImageFileName);
- FILE *fp;
- png_struct *png_ptr;
+ FILE *fp;
+ png_struct *png_ptr;
png_info *info_ptr;
- wxPNGReaderIter iter(this);
-
- /* open the file */
- fp = fopen(filename, "rb");
- if (!fp)
- return FALSE;
-
- /* allocate the necessary structures */
- png_ptr = new (png_struct);
- if (!png_ptr)
- {
- fclose(fp);
- return FALSE;
- }
-
- info_ptr = new (png_info);
- if (!info_ptr)
- {
- fclose(fp);
- delete(png_ptr);
- return FALSE;
- }
- /* set error handling */
- if (setjmp(png_ptr->jmpbuf))
- {
- png_read_destroy(png_ptr, info_ptr, (png_info *)0);
- fclose(fp);
- delete(png_ptr);
- delete(info_ptr);
-
- /* If we get here, we had a problem reading the file */
- return FALSE;
- }
+ wxPNGReaderIter iter(this);
+
+ /* open the file */
+ fp = fopen(filename, "rb");
+ if (!fp)
+ return FALSE;
+
+ /* allocate the necessary structures */
+ png_ptr = new (png_struct);
+ if (!png_ptr)
+ {
+ fclose(fp);
+ return FALSE;
+ }
+
+ info_ptr = new (png_info);
+ if (!info_ptr)
+ {
+ fclose(fp);
+ delete(png_ptr);
+ return FALSE;
+ }
+ /* set error handling */
+ if (setjmp(png_ptr->jmpbuf))
+ {
+ png_read_destroy(png_ptr, info_ptr, (png_info *)0);
+ fclose(fp);
+ delete(png_ptr);
+ delete(info_ptr);
+
+ /* If we get here, we had a problem reading the file */
+ return FALSE;
+ }
//png_set_error(ima_png_error, NULL);
- /* initialize the structures, info first for error handling */
- png_info_init(info_ptr);
- png_read_init(png_ptr);
+ /* initialize the structures, info first for error handling */
+ png_info_init(info_ptr);
+ png_read_init(png_ptr);
- /* set up the input control */
- png_init_io(png_ptr, fp);
+ /* set up the input control */
+ png_init_io(png_ptr, fp);
- /* read the file information */
- png_read_info(png_ptr, info_ptr);
+ /* read the file information */
+ png_read_info(png_ptr, info_ptr);
- /* allocate the memory to hold the image using the fields
- of png_info. */
- png_color_16 my_background={ 0, 31, 127, 255, 0 };
+ /* allocate the memory to hold the image using the fields
+ of png_info. */
+ 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_BACKGROUND_GAMMA_FILE, 1, 1.0);
+ png_set_background(png_ptr, &(info_ptr->background),
+ PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
if ( info_ptr->num_palette > 0 )
bgindex = info_ptr->background.index;
}
- else {
- png_set_background(png_ptr, &my_background,
- PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+ else {
+ png_set_background(png_ptr, &my_background,
+ PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
// Added by JACS: guesswork!
if ( info_ptr->num_trans != 0 )
bgindex = info_ptr->num_trans - 1 ;
- }
+ }
- /* tell libpng to strip 16 bit depth files down to 8 bits */
- if (info_ptr->bit_depth == 16)
- png_set_strip_16(png_ptr);
+ /* tell libpng to strip 16 bit depth files down to 8 bits */
+ if (info_ptr->bit_depth == 16)
+ png_set_strip_16(png_ptr);
- int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24;
- Create(info_ptr->width, info_ptr->height, pixel_depth,
- info_ptr->color_type);
+ int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24;
+ Create(info_ptr->width, info_ptr->height, pixel_depth,
+ 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);
+ // 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);
+
+ byte *row_pointers = new byte[row_stride];
+
+ /* turn on interlace handling */
+ if (info_ptr->interlace_type)
+ number_passes = png_set_interlace_handling(png_ptr);
+ else
+ number_passes = 1;
+// printf("NP = %d ", number_passes);
+
+ for (int pass=0; pass< number_passes; pass++) {
+ iter.upset();
+ int y=0;
+ do {
+// (unsigned char *)iter.GetRow();
+ if (info_ptr->interlace_type) {
+ if (pass>0)
+ iter.GetRow(row_pointers, row_stride);
+ png_read_row(png_ptr, row_pointers, NULL);
}
+ else
+ png_read_row(png_ptr, row_pointers, NULL);
+
+ iter.SetRow(row_pointers, row_stride);
+ y++;
+ } while(iter.PrevRow());
+// printf("Y=%d ",y);
+ }
+ delete[] row_pointers;
- 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("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];
-
- /* turn on interlace handling */
- if (info_ptr->interlace_type)
- number_passes = png_set_interlace_handling(png_ptr);
- else
- number_passes = 1;
-// printf("NP = %d ", number_passes);
-
- for (int pass=0; pass< number_passes; pass++) {
- iter.upset();
- int y=0;
- do {
-// (unsigned char *)iter.GetRow();
- if (info_ptr->interlace_type) {
- if (pass>0)
- iter.GetRow(row_pointers, row_stride);
- png_read_row(png_ptr, row_pointers, NULL);
- }
- else
- png_read_row(png_ptr, row_pointers, NULL);
-
- iter.SetRow(row_pointers, row_stride);
- y++;
- } while(iter.PrevRow());
-// printf("Y=%d ",y);
- }
- delete[] row_pointers;
-
- /* read the rest of the file, getting any additional chunks
- in info_ptr */
- png_read_end(png_ptr, info_ptr);
-
- /* clean up after the read, and free any memory allocated */
- png_read_destroy(png_ptr, info_ptr, (png_info *)0);
-
- /* free the structures */
- delete(png_ptr);
- delete(info_ptr);
-
- /* close the file */
- fclose(fp);
-
- /* that's it */
- return TRUE;
+ /* read the rest of the file, getting any additional chunks
+ in info_ptr */
+ png_read_end(png_ptr, info_ptr);
+
+ /* clean up after the read, and free any memory allocated */
+ png_read_destroy(png_ptr, info_ptr, (png_info *)0);
+
+ /* free the structures */
+ delete(png_ptr);
+ delete(info_ptr);
+
+ /* close the file */
+ fclose(fp);
+
+ /* that's it */
+ return TRUE;
}
bool wxPNGReader::SaveFile(char * ImageFileName)
{
if (ImageFileName)
- strcpy(filename, ImageFileName);
+ strcpy(filename, ImageFileName);
wxPNGReaderIter iter(this);
FILE *fp;
png_struct *png_ptr;
- png_info *info_ptr;
+ png_info *info_ptr;
/* open the file */
- fp = fopen(filename, "wb");
- if (!fp)
- return FALSE;
-
- /* allocate the necessary structures */
- png_ptr = new (png_struct);
- if (!png_ptr)
- {
- fclose(fp);
- return FALSE;
- }
-
- info_ptr = new (png_info);
- if (!info_ptr)
- {
- fclose(fp);
- delete(png_ptr);
- return FALSE;
- }
-
- /* set error handling */
- if (setjmp(png_ptr->jmpbuf))
- {
- png_write_destroy(png_ptr);
- fclose(fp);
- delete(png_ptr);
- delete(info_ptr);
-
- /* If we get here, we had a problem reading the file */
- return FALSE;
- }
+ fp = fopen(filename, "wb");
+ if (!fp)
+ return FALSE;
+
+ /* allocate the necessary structures */
+ png_ptr = new (png_struct);
+ if (!png_ptr)
+ {
+ fclose(fp);
+ return FALSE;
+ }
+
+ info_ptr = new (png_info);
+ if (!info_ptr)
+ {
+ fclose(fp);
+ delete(png_ptr);
+ return FALSE;
+ }
+
+ /* set error handling */
+ if (setjmp(png_ptr->jmpbuf))
+ {
+ png_write_destroy(png_ptr);
+ fclose(fp);
+ delete(png_ptr);
+ delete(info_ptr);
+
+ /* If we get here, we had a problem reading the file */
+ return FALSE;
+ }
//png_set_error(ima_png_error, NULL);
-// printf("writig pg %s ", filename);
+// printf("writig pg %s ", filename);
/* initialize the structures */
- png_info_init(info_ptr);
- png_write_init(png_ptr);
-
- int row_stride = GetWidth() * ((GetDepth()+7)>>3);
- /* set up the output control */
+ png_info_init(info_ptr);
+ png_write_init(png_ptr);
+
+ int row_stride = GetWidth() * ((GetDepth()+7)>>3);
+ /* set up the output control */
png_init_io(png_ptr, fp);
- /* set the file information here */
- info_ptr->width = GetWidth();
- info_ptr->height = GetHeight();
- info_ptr->pixel_depth = GetDepth();
- info_ptr->channels = (GetDepth()>8) ? 3: 1;
- info_ptr->bit_depth = GetDepth()/info_ptr->channels;
- info_ptr->color_type = GetColorType();
- info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0;
- info_ptr->valid = 0;
- info_ptr->rowbytes = row_stride;
+ /* set the file information here */
+ info_ptr->width = GetWidth();
+ info_ptr->height = GetHeight();
+ info_ptr->pixel_depth = GetDepth();
+ info_ptr->channels = (GetDepth()>8) ? 3: 1;
+ info_ptr->bit_depth = GetDepth()/info_ptr->channels;
+ info_ptr->color_type = GetColorType();
+ info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0;
+ info_ptr->valid = 0;
+ 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);
- /* set the palette if there is one */
- if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette())
- {
-// printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
- info_ptr->valid |= PNG_INFO_PLTE;
- info_ptr->palette = new png_color[256];
- info_ptr->num_palette = 256;
- 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);
- }
-// printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
+ /* set the palette if there is one */
+ if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette())
+ {
+// printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
+ info_ptr->valid |= PNG_INFO_PLTE;
+ info_ptr->palette = new png_color[256];
+ info_ptr->num_palette = 256;
+ 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);
+ }
+// printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
/* optional significant bit chunk */
// info_ptr->valid |= PNG_INFO_sBIT;
// info_ptr->sig_bit = true_bit_depth;
- /* optional gamma chunk */
+ /* optional gamma chunk */
// info_ptr->valid |= PNG_INFO_gAMA;
// info_ptr->gamma = gamma;
- /* other optional chunks */
+ /* other optional chunks */
/* write the file information */
png_write_info(png_ptr, info_ptr);
/* set up the transformations you want. Note that these are
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 */
// png_set_shift(png_ptr, &(info_ptr->sig_bit));
- /* pack pixels into bytes */
+ /* pack pixels into bytes */
// png_set_packing(png_ptr);
- /* flip bgr pixels to rgb */
+ /* flip bgr pixels to rgb */
// png_set_bgr(png_ptr);
/* swap bytes of 16 bit files to most significant bit first */
/* If you are only writing one row at a time, this works */
- byte *row_pointers = new byte[row_stride];
- iter.upset();
- do {
-// (unsigned char *)iter.GetRow();
- iter.GetRow(row_pointers, row_stride);
- png_write_row(png_ptr, row_pointers);
- } while(iter.PrevRow());
-
+ byte *row_pointers = new byte[row_stride];
+ iter.upset();
+ do {
+// (unsigned char *)iter.GetRow();
+ iter.GetRow(row_pointers, row_stride);
+ png_write_row(png_ptr, row_pointers);
+ } while(iter.PrevRow());
+
delete[] row_pointers;
/* write the rest of the file */
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);
/* if you malloced the palette, free it here */
if (info_ptr->palette)
- delete[] (info_ptr->palette);
+ delete[] (info_ptr->palette);
- /* free the structures */
- delete(png_ptr);
- delete(info_ptr);
+ /* free the structures */
+ delete(png_ptr);
+ delete(info_ptr);
- /* close the file */
- fclose(fp);
+ /* close the file */
+ fclose(fp);
- /* that's it */
- return TRUE;
+ /* that's it */
+ return TRUE;
}
static int Power(int x, int y)
buf[1] = hexArray[secondDigit];
buf[2] = 0;
}
-
+
bool wxPNGReader::SaveXPM(char *filename, char *name)
{
#include <stdlib.h>
#if wxUSE_IOSTREAMH
-#include <fstream.h>
+# include <fstream.h>
#else
-#include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+# include <fstream>
#endif
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#ifndef __WATCOMC__
-#if !(defined(_MSC_VER) && (_MSC_VER > 800))
-#include <errno.h>
-#endif
+ #if !(defined(_MSC_VER) && (_MSC_VER > 800))
+ #include <errno.h>
+ #endif
#endif
#include <stdarg.h>
//// BEGIN for console support: VC++ only
-#if defined(__WXDEBUG__) && !defined(__WIN16__) && defined(_MSC_VER) && !defined(__NO_VC_CRTDBG__)
- #define wxUSE_VC_CRTDBG
-#else
- #undef wxUSE_VC_CRTDBG
-#endif
+#include "wx/msw/msvcrt.h"
-#ifdef wxUSE_VC_CRTDBG
- // VC++ uses this macro as debug/release mode indicator
- #ifndef _DEBUG
- #define _DEBUG
- #endif
+#include <fcntl.h>
- #include <fcntl.h>
+#include "wx/ioswrap.h"
#if wxUSE_IOSTREAMH
// N.B. BC++ doesn't have istream.h, ostream.h
-# include <iostream.h>
# include <io.h>
# include <fstream.h>
-
#else
-# include <istream>
-# include <ostream>
# include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
#endif
/* Need to undef new if including crtdbg.h */
# define new new(__FILE__,__LINE__)
# endif
-#endif
-
/// END for console support
// In the WIN.INI file
#endif
#if defined(__WIN32__)
- HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo);
-
- if (h==INVALID_HANDLE_VALUE)
- return FALSE;
- else {
- FindClose(h);
- return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
- }
+ HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo);
+
+ if (h==INVALID_HANDLE_VALUE)
+ return FALSE;
+ else {
+ FindClose(h);
+ return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
+ }
#else
// In Borland findfirst has a different argument
// ordering from _dos_findfirst. But _dos_findfirst
wxString tmp = pattern;
char *pat = WXSTRINGCAST(tmp);
while (*pat) {
- switch (*pat++) {
- case '?': case '*': case '[': case '{':
- return TRUE;
- case '\\':
- if (!*pat++)
- return FALSE;
- }
+ switch (*pat++) {
+ case '?': case '*': case '[': case '{':
+ return TRUE;
+ case '\\':
+ if (!*pat++)
+ return FALSE;
+ }
}
return FALSE;
};
// dot_special means '.' only matches '.'
if (dot_special && *str == '.' && *pattern != *str)
- return FALSE;
+ return FALSE;
while ((*pattern != '\0') && (!done)
&& (((*str=='\0')&&((*pattern==OB)||(*pattern=='*')))||(*str!='\0'))) {
- switch (*pattern) {
- case '\\':
- pattern++;
- if (*pattern != '\0')
- pattern++;
- break;
- case '*':
- pattern++;
- ret_code = FALSE;
- while ((*str!='\0')
- && (!(ret_code=wxMatchWild(pattern, str++, FALSE))))
- /*loop*/;
- if (ret_code) {
- while (*str != '\0')
- str++;
- while (*pattern != '\0')
- pattern++;
- }
- break;
- case '[':
- pattern++;
- repeat:
- if ((*pattern == '\0') || (*pattern == ']')) {
- done = TRUE;
- break;
- }
- if (*pattern == '\\') {
- pattern++;
- if (*pattern == '\0') {
- done = TRUE;
- break;
- }
- }
- if (*(pattern + 1) == '-') {
- c = *pattern;
- pattern += 2;
- if (*pattern == ']') {
- done = TRUE;
- break;
- }
- if (*pattern == '\\') {
- pattern++;
- if (*pattern == '\0') {
- done = TRUE;
- break;
- }
- }
- if ((*str < c) || (*str > *pattern)) {
- pattern++;
- goto repeat;
- }
- } else if (*pattern != *str) {
- pattern++;
- goto repeat;
- }
- pattern++;
- while ((*pattern != ']') && (*pattern != '\0')) {
- if ((*pattern == '\\') && (*(pattern + 1) != '\0'))
- pattern++;
- pattern++;
- }
- if (*pattern != '\0') {
- pattern++, str++;
- }
- break;
- case '?':
- pattern++;
- str++;
- break;
- case OB:
- pattern++;
- while ((*pattern != CB) && (*pattern != '\0')) {
- cp = str;
- ok = TRUE;
- while (ok && (*cp != '\0') && (*pattern != '\0')
- && (*pattern != ',') && (*pattern != CB)) {
- if (*pattern == '\\')
- pattern++;
- ok = (*pattern++ == *cp++);
- }
- if (*pattern == '\0') {
- ok = FALSE;
- done = TRUE;
- break;
- } else if (ok) {
- str = cp;
- while ((*pattern != CB) && (*pattern != '\0')) {
- if (*++pattern == '\\') {
- if (*++pattern == CB)
- pattern++;
- }
- }
- } else {
- while (*pattern!=CB && *pattern!=',' && *pattern!='\0') {
- if (*++pattern == '\\') {
+ switch (*pattern) {
+ case '\\':
+ pattern++;
+ if (*pattern != '\0')
+ pattern++;
+ break;
+ case '*':
+ pattern++;
+ ret_code = FALSE;
+ while ((*str!='\0')
+ && (!(ret_code=wxMatchWild(pattern, str++, FALSE))))
+ /*loop*/;
+ if (ret_code) {
+ while (*str != '\0')
+ str++;
+ while (*pattern != '\0')
+ pattern++;
+ }
+ break;
+ case '[':
+ pattern++;
+ repeat:
+ if ((*pattern == '\0') || (*pattern == ']')) {
+ done = TRUE;
+ break;
+ }
+ if (*pattern == '\\') {
+ pattern++;
+ if (*pattern == '\0') {
+ done = TRUE;
+ break;
+ }
+ }
+ if (*(pattern + 1) == '-') {
+ c = *pattern;
+ pattern += 2;
+ if (*pattern == ']') {
+ done = TRUE;
+ break;
+ }
+ if (*pattern == '\\') {
+ pattern++;
+ if (*pattern == '\0') {
+ done = TRUE;
+ break;
+ }
+ }
+ if ((*str < c) || (*str > *pattern)) {
+ pattern++;
+ goto repeat;
+ }
+ } else if (*pattern != *str) {
+ pattern++;
+ goto repeat;
+ }
+ pattern++;
+ while ((*pattern != ']') && (*pattern != '\0')) {
+ if ((*pattern == '\\') && (*(pattern + 1) != '\0'))
+ pattern++;
+ pattern++;
+ }
+ if (*pattern != '\0') {
+ pattern++, str++;
+ }
+ break;
+ case '?':
+ pattern++;
+ str++;
+ break;
+ case OB:
+ pattern++;
+ while ((*pattern != CB) && (*pattern != '\0')) {
+ cp = str;
+ ok = TRUE;
+ while (ok && (*cp != '\0') && (*pattern != '\0')
+ && (*pattern != ',') && (*pattern != CB)) {
+ if (*pattern == '\\')
+ pattern++;
+ ok = (*pattern++ == *cp++);
+ }
+ if (*pattern == '\0') {
+ ok = FALSE;
+ done = TRUE;
+ break;
+ } else if (ok) {
+ str = cp;
+ while ((*pattern != CB) && (*pattern != '\0')) {
+ if (*++pattern == '\\') {
+ if (*++pattern == CB)
+ pattern++;
+ }
+ }
+ } else {
+ while (*pattern!=CB && *pattern!=',' && *pattern!='\0') {
+ if (*++pattern == '\\') {
if (*++pattern == CB || *pattern == ',')
- pattern++;
- }
- }
- }
- if (*pattern != '\0')
- pattern++;
- }
- break;
- default:
- if (*str == *pattern) {
- str++, pattern++;
- } else {
- done = TRUE;
- }
- }
+ pattern++;
+ }
+ }
+ }
+ if (*pattern != '\0')
+ pattern++;
+ }
+ break;
+ default:
+ if (*str == *pattern) {
+ str++, pattern++;
+ } else {
+ done = TRUE;
+ }
+ }
}
while (*pattern == '*')
- pattern++;
+ pattern++;
return ((*str == '\0') && (*pattern == '\0'));
};
#endif
-#ifdef wxUSE_VC_CRTDBG
+#ifdef 0
// maximum mumber of lines the output console should have
static const WORD MAX_CONSOLE_LINES = 500;
BOOL WINAPI MyConsoleHandler( DWORD dwCtrlType ) { // control signal type
- FreeConsole();
- return TRUE;
+ FreeConsole();
+ return TRUE;
}
void wxRedirectIOToConsole()
AllocConsole();
// 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.dwSize.Y = MAX_CONSOLE_LINES;
- SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),
+ SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),
coninfo.dwSize);
// redirect unbuffered STDOUT to the console
fp = _fdopen( hConHandle, "w" );
*stderr = *fp;
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
ios::sync_with_stdio();
- SetConsoleCtrlHandler(MyConsoleHandler, TRUE);
-
+ SetConsoleCtrlHandler(MyConsoleHandler, TRUE);
}
#else
// Not supported
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <stdlib.h>
#include <string.h>
#ifndef __WATCOMC__
-#if !(defined(_MSC_VER) && (_MSC_VER > 800))
-#include <errno.h>
-#endif
+ #if !(defined(_MSC_VER) && (_MSC_VER > 800))
+ #include <errno.h>
+ #endif
#endif
#include <stdarg.h>