git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3219
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
// macros for handling spin events
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
// macros for handling spin events
#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
+#endif
+#ifndef EVT_SPIN_DOWN
#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
+#endif
+#ifndef EVT_SPIN
#define EVT_SPIN(id, func) { wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
#define EVT_SPIN(id, func) { wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
wxTextFileType_None, // incomplete (the last line of the file only)
wxTextFileType_Unix, // line is terminated with 'LF' = 0xA = 10 = '\n'
wxTextFileType_Dos, // 'CR' 'LF'
wxTextFileType_None, // incomplete (the last line of the file only)
wxTextFileType_Unix, // line is terminated with 'LF' = 0xA = 10 = '\n'
wxTextFileType_Dos, // 'CR' 'LF'
- wxTextFileType_Mac // 'CR' = 0xD = 13 = '\r'
+ wxTextFileType_Mac, // 'CR' = 0xD = 13 = '\r'
+ wxTextFileType_Os2 // 'CR' 'LF'
};
WX_DEFINE_ARRAY(wxTextFileType, ArrayFileType);
};
WX_DEFINE_ARRAY(wxTextFileType, ArrayFileType);
class WXDLLEXPORT wxFrame;
// FIXME should use wxStricmp() instead
class WXDLLEXPORT wxFrame;
// FIXME should use wxStricmp() instead
+#if defined(__GNUWIN32__)
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
-static void _PNG_stream_reader( png_structp png_ptr, png_bytep data, png_size_t length )
+#if defined(__VISAGECPP__)
+#define LINKAGEMODE _Optlink
+#else
+#define LINKAGEMODE
+#endif
+
+static void LINKAGEMODE _PNG_stream_reader( png_structp png_ptr, png_bytep data, png_size_t length )
{
((wxInputStream*) png_get_io_ptr( png_ptr )) -> Read(data, length);
}
{
((wxInputStream*) png_get_io_ptr( png_ptr )) -> Read(data, length);
}
-static void _PNG_stream_writer( png_structp png_ptr, png_bytep data, png_size_t length )
+static void LINKAGEMODE _PNG_stream_writer( png_structp png_ptr, png_bytep data, png_size_t length )
{
((wxOutputStream*) png_get_io_ptr( png_ptr )) -> Write(data, length);
}
{
((wxOutputStream*) png_get_io_ptr( png_ptr )) -> Write(data, length);
}
{
// VZ: as this function uses setjmp() the only fool proof error handling
// method is to use goto (setjmp is not really C++ dtors friendly...)
{
// VZ: as this function uses setjmp() the only fool proof error handling
// method is to use goto (setjmp is not really C++ dtors friendly...)
unsigned char **lines;
unsigned int i;
png_infop info_ptr = (png_infop) NULL;
unsigned char **lines;
unsigned int i;
png_infop info_ptr = (png_infop) NULL;
png_structp png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING,
(voidp) NULL,
(png_error_ptr) NULL,
(png_error_ptr) NULL );
if (!png_ptr)
goto error_nolines;
png_structp png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING,
(voidp) NULL,
(png_error_ptr) NULL,
(png_error_ptr) NULL );
if (!png_ptr)
goto error_nolines;
info_ptr = png_create_info_struct( png_ptr );
if (!info_ptr)
goto error_nolines;
info_ptr = png_create_info_struct( png_ptr );
if (!info_ptr)
goto error_nolines;
if (setjmp(png_ptr->jmpbuf))
goto error_nolines;
if (setjmp(png_ptr->jmpbuf))
goto error_nolines;
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
goto error_nolines;
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
goto error_nolines;
png_set_read_fn( png_ptr, &stream, _PNG_stream_reader);
png_set_read_fn( png_ptr, &stream, _PNG_stream_reader);
png_uint_32 width,height;
int bit_depth,color_type,interlace_type;
png_uint_32 width,height;
int bit_depth,color_type,interlace_type;
png_read_info( png_ptr, info_ptr );
png_get_IHDR( png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, (int*) NULL, (int*) NULL );
png_read_info( png_ptr, info_ptr );
png_get_IHDR( png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, (int*) NULL, (int*) NULL );
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_expand( png_ptr );
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_expand( png_ptr );
png_set_strip_16( png_ptr );
png_set_packing( png_ptr );
if (png_get_valid( png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_expand( png_ptr );
png_set_filler( png_ptr, 0xff, PNG_FILLER_AFTER );
png_set_strip_16( png_ptr );
png_set_packing( png_ptr );
if (png_get_valid( png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_expand( png_ptr );
png_set_filler( png_ptr, 0xff, PNG_FILLER_AFTER );
image->Create( width, height );
image->Create( width, height );
if (!image->Ok())
goto error_nolines;
if (!image->Ok())
goto error_nolines;
lines = (unsigned char **)malloc( height * sizeof(unsigned char *) );
if (lines == NULL)
goto error_nolines;
lines = (unsigned char **)malloc( height * sizeof(unsigned char *) );
if (lines == NULL)
goto error_nolines;
for (i = 0; i < height; i++)
{
if ((lines[i] = (unsigned char *)malloc(width * (sizeof(unsigned char) * 4))) == NULL)
for (i = 0; i < height; i++)
{
if ((lines[i] = (unsigned char *)malloc(width * (sizeof(unsigned char) * 4))) == NULL)
// loaded successfully!
{
int transp = 0;
// loaded successfully!
{
int transp = 0;
for ( unsigned int j = 0; j < height; j++ )
free( lines[j] );
free( lines );
for ( unsigned int j = 0; j < height; j++ )
free( lines[j] );
free( lines );
if (transp)
{
image->SetMaskColour( 255, 0, 255 );
if (transp)
{
image->SetMaskColour( 255, 0, 255 );
image->SetMask( FALSE );
}
}
image->SetMask( FALSE );
}
}
return TRUE;
error_nolines:
lines = NULL; // called from before it was set
error:
wxLogError(_("Couldn't load a PNG image - probably file is corrupted."));
return TRUE;
error_nolines:
lines = NULL; // called from before it was set
error:
wxLogError(_("Couldn't load a PNG image - probably file is corrupted."));
if ( image->Ok() )
{
image->Destroy();
}
if ( image->Ok() )
{
image->Destroy();
}
if ( lines )
{
free( lines );
}
if ( lines )
{
free( lines );
}
if ( png_ptr )
{
if ( info_ptr )
if ( png_ptr )
{
if ( info_ptr )
png_infop info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
png_destroy_write_struct( &png_ptr, (png_infopp)NULL );
return FALSE;
}
png_infop info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
png_destroy_write_struct( &png_ptr, (png_infopp)NULL );
return FALSE;
}
if (setjmp(png_ptr->jmpbuf))
{
png_destroy_write_struct( &png_ptr, (png_infopp)NULL );
return FALSE;
}
if (setjmp(png_ptr->jmpbuf))
{
png_destroy_write_struct( &png_ptr, (png_infopp)NULL );
return FALSE;
}
png_set_write_fn( png_ptr, &stream, _PNG_stream_writer, NULL);
png_set_write_fn( png_ptr, &stream, _PNG_stream_writer, NULL);
png_set_IHDR( png_ptr, info_ptr, image->GetWidth(), image->GetHeight(), 8,
PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_set_IHDR( png_ptr, info_ptr, image->GetWidth(), image->GetHeight(), 8,
PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_color_8 sig_bit;
sig_bit.red = 8;
sig_bit.green = 8;
png_color_8 sig_bit;
sig_bit.red = 8;
sig_bit.green = 8;
png_write_info( png_ptr, info_ptr );
png_set_shift( png_ptr, &sig_bit );
png_set_packing( png_ptr );
png_write_info( png_ptr, info_ptr );
png_set_shift( png_ptr, &sig_bit );
png_set_packing( png_ptr );
unsigned char *data = (unsigned char *)malloc( image->GetWidth()*4 );
if (!data)
{
png_destroy_write_struct( &png_ptr, (png_infopp)NULL );
return FALSE;
}
unsigned char *data = (unsigned char *)malloc( image->GetWidth()*4 );
if (!data)
{
png_destroy_write_struct( &png_ptr, (png_infopp)NULL );
return FALSE;
}
for (int y = 0; y < image->GetHeight(); y++)
{
unsigned char *ptr = image->GetData() + (y * image->GetWidth() * 3);
for (int y = 0; y < image->GetHeight(); y++)
{
unsigned char *ptr = image->GetData() + (y * image->GetWidth() * 3);
png_bytep row_ptr = data;
png_write_rows( png_ptr, &row_ptr, 1 );
}
png_bytep row_ptr = data;
png_write_rows( png_ptr, &row_ptr, 1 );
}
free(data);
png_write_end( png_ptr, info_ptr );
png_destroy_write_struct( &png_ptr, (png_infopp)&info_ptr );
free(data);
png_write_end( png_ptr, info_ptr );
png_destroy_write_struct( &png_ptr, (png_infopp)&info_ptr );
wxTextFileType_Unix;
#elif defined(__WXMAC__)
wxTextFileType_Mac;
wxTextFileType_Unix;
#elif defined(__WXMAC__)
wxTextFileType_Mac;
+#elif defined(__WXPM__)
+ wxTextFileType_Os2;
#else
wxTextFileType_None;
#error "wxTextFile: unsupported platform."
#else
wxTextFileType_None;
#error "wxTextFile: unsupported platform."
#endif
wxStartTime = 1000*tp.tv_sec + tp.tv_usec/1000;
#elif (defined(__SC__) || defined(__SGI__) || defined(___BSDI__) || defined(__ALPHA__) || \
#endif
wxStartTime = 1000*tp.tv_sec + tp.tv_usec/1000;
#elif (defined(__SC__) || defined(__SGI__) || defined(___BSDI__) || defined(__ALPHA__) || \
- defined(__MINGW32__) || defined(__MWERKS__) || defined(__FreeBSD__) )
+ defined(__MINGW32__) || defined(__MWERKS__) || defined(__FreeBSD__) )
time_t t0;
struct tm *tp;
time(&t0);
time_t t0;
struct tm *tp;
time(&t0);
#ifndef __VMS__
bool wxGetLocalTime(long *timeZone, int *dstObserved)
{
#ifndef __VMS__
bool wxGetLocalTime(long *timeZone, int *dstObserved)
{
-#if defined(__MINGW32__)
+#if defined(__MINGW32__)
time_t t0;
struct tm *tp;
time(&t0);
time_t t0;
struct tm *tp;
time(&t0);
*dstObserved = tp->tm_isdst;
#else
*dstObserved = tp->tm_isdst;
#else
-#if (((defined(__SYSV__) && !defined(__HPUX__)) || defined(__MSDOS__) || defined(__WXMSW__)) \
+#if (((defined(__SYSV__) && !defined(__HPUX__)) || defined(__MSDOS__) || defined(__WXMSW__) || defined(__WXPM__)) \
&& !defined(__GNUWIN32__) && !defined(__MWERKS__) )
&& !defined(__GNUWIN32__) && !defined(__MWERKS__) )
-#if defined(__BORLANDC__)
+# if defined(__BORLANDC__)
/* Borland uses underscores */
*timeZone = _timezone;
*dstObserved = _daylight;
/* Borland uses underscores */
*timeZone = _timezone;
*dstObserved = _daylight;
-#elif defined(__SALFORDC__)
+# elif defined(__SALFORDC__)
*timeZone = _timezone;
*dstObserved = daylight;
*timeZone = _timezone;
*dstObserved = daylight;
+# elif defined(__VISAGECPP__)
+ *timeZone = _timezone;
+ *dstObserved = daylight;
+# else
*timeZone = timezone;
*dstObserved = daylight;
*timeZone = timezone;
*dstObserved = daylight;
#elif defined(__xlC__) || defined(__AIX__) || defined(__SVR4__) || defined(__SYSV__) || defined(__MWERKS__) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) // || defined(__AIXV3__)
#elif defined(__xlC__) || defined(__AIX__) || defined(__SVR4__) || defined(__SYSV__) || defined(__MWERKS__) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) // || defined(__AIXV3__)
-#ifndef __MWERKS__ // shouldn't this be one scope below ?
+# ifndef __MWERKS__ // shouldn't this be one scope below ?
-#endif
-#if defined(__SYSV__) || (defined(__GNUWIN32__) && !defined(__MINGW32))
+# endif
+# if defined(__SYSV__) || (defined(__GNUWIN32__) && !defined(__MINGW32))
struct timezone tz;
gettimeofday(&tp, &tz);
*timeZone = 60*(tz.tz_minuteswest);
*dstObserved = tz.tz_dsttime;
struct timezone tz;
gettimeofday(&tp, &tz);
*timeZone = 60*(tz.tz_minuteswest);
*dstObserved = tz.tz_dsttime;
time_t t0;
struct tm *tp;
time(&t0);
tp = localtime(&t0);
time_t t0;
struct tm *tp;
time(&t0);
tp = localtime(&t0);
*timeZone = tp->tm_gmtoff; // ???
*timeZone = tp->tm_gmtoff; // ???
*dstObserved = tp->tm_isdst;
#endif
#elif defined(__WXSTUBS__)
*dstObserved = tp->tm_isdst;
#endif
#elif defined(__WXSTUBS__)
// Modified by:
// Created: 28/06/98
// RCS-ID: $Id$
// Modified by:
// Created: 28/06/98
// RCS-ID: $Id$
-// Copyright: (c) Guilhem Lavaux
+// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
c = m_input->GetC();
if (!m_input) return (wxChar) 0;
c = m_input->GetC();
if (!m_input) return (wxChar) 0;
c != _T('\r') &&
c != _T('\t') &&
c != _T(' '))
c != _T('\r') &&
c != _T('\t') &&
c != _T(' '))
// this shouldn't happen
return (wxChar) 0;
}
// this shouldn't happen
return (wxChar) 0;
}
void wxTextInputStream::SkipIfEndOfLine( wxChar c )
{
if (c == _T('\n'))
void wxTextInputStream::SkipIfEndOfLine( wxChar c )
{
if (c == _T('\n'))
if (c == _T('\r'))
{
// eat on both Mac and DOS
if (c == _T('\r'))
{
// eat on both Mac and DOS
if (!m_input) return;
if (c2 == _T('\n'))
if (!m_input) return;
if (c2 == _T('\n'))
/* I only implemented a simple integer parser */
int sign;
wxInt32 i;
/* I only implemented a simple integer parser */
int sign;
wxInt32 i;
int c = NextNonWhiteSpace();
if (!m_input) return 0;
i = 0;
int c = NextNonWhiteSpace();
if (!m_input) return 0;
i = 0;
- if (! (c == _T('-') || c == _T('+') || isdigit(c)) )
+ if (! (c == _T('-') || c == _T('+') || isdigit(c)) )
{
m_input->Ungetch(c);
return 0;
}
{
m_input->Ungetch(c);
return 0;
}
{
sign = -1;
c = m_input->GetC();
{
sign = -1;
c = m_input->GetC();
- } else
- if (c == _T('+'))
+ } else
+ if (c == _T('+'))
{
sign = 1;
c = m_input->GetC();
{
sign = 1;
c = m_input->GetC();
{
i = i*10 + (c - (int)_T('0'));
c = m_input->GetC();
{
i = i*10 + (c - (int)_T('0'));
c = m_input->GetC();
if (!m_input) return 0.0;
f = 0.0;
if (!m_input) return 0.0;
f = 0.0;
- if (! (c == _T('.') || c == _T('-') || c == _T('+') || isdigit(c)) )
+ if (! (c == _T('.') || c == _T('-') || c == _T('+') || isdigit(c)) )
{
m_input->Ungetch(c);
return 0.0;
}
{
m_input->Ungetch(c);
return 0.0;
}
{
sign = -1;
c = m_input->GetC();
{
sign = -1;
c = m_input->GetC();
- } else
- if (c == _T('+'))
+ } else
+ if (c == _T('+'))
{
sign = 1;
c = m_input->GetC();
{
sign = 1;
c = m_input->GetC();
{
f = f*10 + (c - _T('0'));
c = m_input->GetC();
}
{
f = f*10 + (c - _T('0'));
c = m_input->GetC();
}
{
double f_multiplicator = (double) 0.1;
c = m_input->GetC();
{
double f_multiplicator = (double) 0.1;
c = m_input->GetC();
{
f += (c-_T('0'))*f_multiplicator;
f_multiplicator /= 10;
c = m_input->GetC();
}
{
f += (c-_T('0'))*f_multiplicator;
f_multiplicator /= 10;
c = m_input->GetC();
}
{
double f_multiplicator = 0.0;
int i, e;
c = m_input->GetC();
{
double f_multiplicator = 0.0;
int i, e;
c = m_input->GetC();
{
case _T('-'): f_multiplicator = 0.1; break;
case _T('+'): f_multiplicator = 10.0; break;
{
case _T('-'): f_multiplicator = 0.1; break;
case _T('+'): f_multiplicator = 10.0; break;
for (i=0;i<e;i++)
f *= f_multiplicator;
for (i=0;i<e;i++)
f *= f_multiplicator;
else
SkipIfEndOfLine( c );
}
else
SkipIfEndOfLine( c );
}
{
c = m_input->GetC();
if (!m_input) break;
{
c = m_input->GetC();
if (!m_input) break;
if (c == _T('\r'))
{
// eat on both Mac and DOS
if (c == _T('\r'))
{
// eat on both Mac and DOS
wxChar c2 = m_input->GetC();
if (!m_input) break;
wxChar c2 = m_input->GetC();
if (!m_input) break;
wxTextInputStream& wxTextInputStream::operator>>(wxString& line)
{
line = ReadString();
wxTextInputStream& wxTextInputStream::operator>>(wxString& line)
{
line = ReadString();
c = (wxChar) 0;
return *this;
}
c = (wxChar) 0;
return *this;
}
if (c1 == _T('\r'))
{
c = _T('\n');
wxChar c2 = m_input->GetC();
if (!m_input) return *this;
if (c1 == _T('\r'))
{
c = _T('\n');
wxChar c2 = m_input->GetC();
if (!m_input) return *this;
if (c2 != _T('\n'))
{
// we are on a Mac
if (c2 != _T('\n'))
{
// we are on a Mac
{
wxString str;
str.Printf(_T("%u"), i);
{
wxString str;
str.Printf(_T("%u"), i);
{
wxString str;
str.Printf(_T("%u"), i);
{
wxString str;
str.Printf(_T("%u"), i);
{
wxString str;
str.Printf(_T("%u"), i);
{
wxString str;
str.Printf(_T("%u"), i);
#elif defined(__WXMAC__)
c = _T('\r');
m_output->Write( (const void*)(&c), sizeof(wxChar) );
#elif defined(__WXMAC__)
c = _T('\r');
m_output->Write( (const void*)(&c), sizeof(wxChar) );
+#elif defined(__OS2__)
+ c = _T('\r');
+ m_output->Write( (const void*)(&c), sizeof(wxChar) );
+ c = _T('\n');
+ m_output->Write( (const void*)(&c), sizeof(wxChar) );
#else
#error "wxTextOutputStream: unsupported platform."
#endif
#else
#error "wxTextOutputStream: unsupported platform."
#endif
#endif
#endif /* __WXMSW__ */
#endif
#endif /* __WXMSW__ */
+#ifdef __WXPM__
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+#endif
wxChar *
copystring (const wxChar *s)
wxChar *
copystring (const wxChar *s)