typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
// macros for handling spin events
+#ifndef EVT_SPIN_UP
#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 },
-
+#endif
+#ifndef EVT_SPIN
#define EVT_SPIN(id, func) { wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
+#endif
#endif // wxUSE_SPINBTN
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);
class WXDLLEXPORT wxFrame;
// FIXME should use wxStricmp() instead
-#ifdef __GNUWIN32__
+#if defined(__GNUWIN32__)
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
#if wxUSE_STREAMS
-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);
}
-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);
}
{
// 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;
-
+
image->Destroy();
-
+
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;
-
+
if (setjmp(png_ptr->jmpbuf))
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_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 );
-
+
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 );
-
+
image->Create( width, height );
-
+
if (!image->Ok())
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)
goto error;
}
}
-
+
// loaded successfully!
{
int transp = 0;
}
}
}
-
+
for ( unsigned int j = 0; j < height; j++ )
free( lines[j] );
free( lines );
-
+
if (transp)
{
image->SetMaskColour( 255, 0, 255 );
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."));
-
+
if ( image->Ok() )
{
image->Destroy();
}
-
+
if ( lines )
{
free( lines );
}
-
+
if ( png_ptr )
{
if ( info_ptr )
{
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;
}
-
+
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_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 );
-
+
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);
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 );
return TRUE;
}
-#endif
+#endif
// wxUSE_STREAMS
-#endif
+#endif
// wxUSE_LIBPNG
wxTextFileType_Unix;
#elif defined(__WXMAC__)
wxTextFileType_Mac;
+#elif defined(__WXPM__)
+ wxTextFileType_Os2;
#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__) || \
- defined(__MINGW32__) || defined(__MWERKS__) || defined(__FreeBSD__) )
+ defined(__MINGW32__) || defined(__MWERKS__) || defined(__FreeBSD__) )
time_t t0;
struct tm *tp;
time(&t0);
#ifndef __VMS__
bool wxGetLocalTime(long *timeZone, int *dstObserved)
{
-#if defined(__MINGW32__)
+#if defined(__MINGW32__)
time_t t0;
struct tm *tp;
time(&t0);
*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__) )
-#if defined(__BORLANDC__)
+# if defined(__BORLANDC__)
/* Borland uses underscores */
*timeZone = _timezone;
*dstObserved = _daylight;
-#elif defined(__SALFORDC__)
+# elif defined(__SALFORDC__)
*timeZone = _timezone;
*dstObserved = daylight;
-#else
+# elif defined(__VISAGECPP__)
+ *timeZone = _timezone;
+ *dstObserved = daylight;
+# else
*timeZone = timezone;
*dstObserved = daylight;
-#endif
+# endif
#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 ?
struct timeval tp;
-#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;
-#else
+# else
time_t t0;
struct tm *tp;
time(&t0);
tp = localtime(&t0);
-#ifndef __MWERKS__
+# ifndef __MWERKS__
*timeZone = tp->tm_gmtoff; // ???
-#else
+# else
*timeZone = 0 ;
-#endif
+# endif
*dstObserved = tp->tm_isdst;
#endif
#elif defined(__WXSTUBS__)
// Modified by:
// Created: 28/06/98
// RCS-ID: $Id$
-// Copyright: (c) Guilhem Lavaux
+// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
c = m_input->GetC();
if (!m_input) return (wxChar) 0;
- if (c != _T('\n') &&
+ if (c != _T('\n') &&
c != _T('\r') &&
c != _T('\t') &&
c != _T(' '))
return c;
}
}
-
+
// this shouldn't happen
return (wxChar) 0;
}
void wxTextInputStream::SkipIfEndOfLine( wxChar c )
{
if (c == _T('\n'))
- {
+ {
// eat on UNIX
return;
}
-
+
if (c == _T('\r'))
{
// eat on both Mac and DOS
if (!m_input) return;
if (c2 == _T('\n'))
- {
+ {
// eat on DOS
return;
}
/* I only implemented a simple integer parser */
int sign;
wxInt32 i;
-
+
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;
}
- if (c == _T('-'))
+ if (c == _T('-'))
{
sign = -1;
c = m_input->GetC();
- } else
- if (c == _T('+'))
+ } else
+ if (c == _T('+'))
{
sign = 1;
c = m_input->GetC();
- } else
+ } else
{
sign = 1;
}
- while (isdigit(c))
+ while (isdigit(c))
{
i = i*10 + (c - (int)_T('0'));
c = m_input->GetC();
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;
}
- if (c == _T('-'))
+ if (c == _T('-'))
{
sign = -1;
c = m_input->GetC();
- } else
- if (c == _T('+'))
+ } else
+ if (c == _T('+'))
{
sign = 1;
c = m_input->GetC();
- }
- else
+ }
+ else
{
sign = 1;
}
- while (isdigit(c))
+ while (isdigit(c))
{
f = f*10 + (c - _T('0'));
c = m_input->GetC();
}
- if (c == _T('.'))
+ if (c == _T('.'))
{
double f_multiplicator = (double) 0.1;
c = m_input->GetC();
- while (isdigit(c))
+ while (isdigit(c))
{
f += (c-_T('0'))*f_multiplicator;
f_multiplicator /= 10;
c = m_input->GetC();
}
- if (c == _T('e'))
+ if (c == _T('e'))
{
double f_multiplicator = 0.0;
int i, e;
c = m_input->GetC();
- switch (c)
+ switch (c)
{
case _T('-'): f_multiplicator = 0.1; break;
case _T('+'): f_multiplicator = 10.0; break;
for (i=0;i<e;i++)
f *= f_multiplicator;
- }
+ }
else
SkipIfEndOfLine( c );
}
wxChar c;
wxString line;
- for (;;)
+ for (;;)
{
c = m_input->GetC();
if (!m_input) break;
if (c == _T('\r'))
{
// eat on both Mac and DOS
-
+
wxChar c2 = m_input->GetC();
if (!m_input) break;
-
+
if (c2 == _T('\n'))
- {
+ {
// eat on DOS
break;
}
line += c;
}
-
+
return line;
}
-
+
wxTextInputStream& wxTextInputStream::operator>>(wxString& line)
{
line = ReadString();
c = (wxChar) 0;
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
{
c = c1;
}
-
+
return *this;
}
{
wxString str;
str.Printf(_T("%u"), i);
-
+
WriteString(str);
}
{
wxString str;
str.Printf(_T("%u"), i);
-
+
WriteString(str);
}
{
wxString str;
str.Printf(_T("%u"), i);
-
+
WriteString(str);
}
#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
#endif
#endif /* __WXMSW__ */
+#ifdef __WXPM__
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+#endif
wxChar *
copystring (const wxChar *s)