OS/2 updates

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3219 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster 1999-07-30 21:47:13 +00:00
parent b7a34956cb
commit 717b9bf234
8 changed files with 114 additions and 88 deletions

View File

@ -107,10 +107,15 @@ public:
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

View File

@ -41,7 +41,8 @@ enum wxTextFileType
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);

View File

@ -41,7 +41,7 @@ class WXDLLEXPORT wxProcess;
class WXDLLEXPORT wxFrame;
// FIXME should use wxStricmp() instead
#ifdef __GNUWIN32__
#if defined(__GNUWIN32__)
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif

View File

@ -59,12 +59,18 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNGHandler,wxImageHandler)
#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);
}
@ -73,56 +79,56 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream )
{
// 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)
@ -132,7 +138,7 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream )
goto error;
}
}
// loaded successfully!
{
int transp = 0;
@ -193,11 +199,11 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream )
}
}
}
for ( unsigned int j = 0; j < height; j++ )
free( lines[j] );
free( lines );
if (transp)
{
image->SetMaskColour( 255, 0, 255 );
@ -207,24 +213,24 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream )
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 )
@ -247,26 +253,26 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream )
{
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;
@ -276,14 +282,14 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream )
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);
@ -306,7 +312,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream )
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 );
@ -314,9 +320,9 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream )
return TRUE;
}
#endif
#endif
// wxUSE_STREAMS
#endif
#endif
// wxUSE_LIBPNG

View File

@ -53,6 +53,8 @@ const wxTextFileType wxTextFile::typeDefault =
wxTextFileType_Unix;
#elif defined(__WXMAC__)
wxTextFileType_Mac;
#elif defined(__WXPM__)
wxTextFileType_Os2;
#else
wxTextFileType_None;
#error "wxTextFile: unsupported platform."

View File

@ -83,7 +83,7 @@ void wxStartTimer(void)
#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);
@ -136,7 +136,7 @@ long wxGetElapsedTime(bool resetTimer)
#ifndef __VMS__
bool wxGetLocalTime(long *timeZone, int *dstObserved)
{
#if defined(__MINGW32__)
#if defined(__MINGW32__)
time_t t0;
struct tm *tp;
time(&t0);
@ -157,38 +157,41 @@ bool wxGetLocalTime(long *timeZone, int *dstObserved)
*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__)

View File

@ -5,7 +5,7 @@
// Modified by:
// Created: 28/06/98
// RCS-ID: $Id$
// Copyright: (c) Guilhem Lavaux
// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
@ -55,7 +55,7 @@ wxChar wxTextInputStream::NextNonWhiteSpace()
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(' '))
@ -63,7 +63,7 @@ wxChar wxTextInputStream::NextNonWhiteSpace()
return c;
}
}
// this shouldn't happen
return (wxChar) 0;
}
@ -71,11 +71,11 @@ wxChar wxTextInputStream::NextNonWhiteSpace()
void wxTextInputStream::SkipIfEndOfLine( wxChar c )
{
if (c == _T('\n'))
{
{
// eat on UNIX
return;
}
if (c == _T('\r'))
{
// eat on both Mac and DOS
@ -84,7 +84,7 @@ void wxTextInputStream::SkipIfEndOfLine( wxChar c )
if (!m_input) return;
if (c2 == _T('\n'))
{
{
// eat on DOS
return;
}
@ -106,32 +106,32 @@ wxUint32 wxTextInputStream::Read32()
/* 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();
@ -164,54 +164,54 @@ double wxTextInputStream::ReadDouble()
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;
@ -221,7 +221,7 @@ double wxTextInputStream::ReadDouble()
for (i=0;i<e;i++)
f *= f_multiplicator;
}
}
else
SkipIfEndOfLine( c );
}
@ -240,7 +240,7 @@ wxString wxTextInputStream::ReadString()
wxChar c;
wxString line;
for (;;)
for (;;)
{
c = m_input->GetC();
if (!m_input) break;
@ -254,12 +254,12 @@ wxString wxTextInputStream::ReadString()
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;
}
@ -273,10 +273,10 @@ wxString wxTextInputStream::ReadString()
line += c;
}
return line;
}
wxTextInputStream& wxTextInputStream::operator>>(wxString& line)
{
line = ReadString();
@ -291,13 +291,13 @@ wxTextInputStream& wxTextInputStream::operator>>(wxChar& c)
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
@ -308,7 +308,7 @@ wxTextInputStream& wxTextInputStream::operator>>(wxChar& c)
{
c = c1;
}
return *this;
}
@ -361,7 +361,7 @@ void wxTextOutputStream::Write32(wxUint32 i)
{
wxString str;
str.Printf(_T("%u"), i);
WriteString(str);
}
@ -369,7 +369,7 @@ void wxTextOutputStream::Write16(wxUint16 i)
{
wxString str;
str.Printf(_T("%u"), i);
WriteString(str);
}
@ -377,7 +377,7 @@ void wxTextOutputStream::Write8(wxUint8 i)
{
wxString str;
str.Printf(_T("%u"), i);
WriteString(str);
}
@ -407,6 +407,11 @@ void wxTextOutputStream::WriteString(const wxString& string)
#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

View File

@ -177,6 +177,10 @@ extern "C"
#endif
#endif /* __WXMSW__ */
#ifdef __WXPM__
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
wxChar *
copystring (const wxChar *s)