From 3d05544e4e71e7ff10984dae5a9b8a07d92f42a6 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 9 Jan 1999 20:18:06 +0000 Subject: [PATCH] More SC++ fixes; HelpGen starting to compile with VC++; image sample now compiles/runs with VC++ git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1357 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- distrib/msw/zipdist.bat | 2 +- docs/msw/todo.txt | 6 ++ include/wx/image.h | 14 ++- samples/image/image.cpp | 36 +++++-- samples/image/image.rc | 3 + samples/image/makefile.nt | 64 ++++++++++++ src/common/image.cpp | 166 +++++++++++++++++------------- src/common/mimetype.cpp | 7 +- src/common/resourc2.cpp | 8 +- src/common/resource.cpp | 2 +- src/makesc.env | 9 +- src/msw/app.cpp | 4 +- src/msw/checklst.cpp | 4 +- src/msw/dummy.cpp | 5 +- src/msw/dummydll.cpp | 6 +- src/msw/makefile.sc | 19 ++-- src/msw/regconf.cpp | 7 ++ src/msw/registry.cpp | 7 +- src/msw/taskbar.cpp | 3 +- src/ntwxwin.mak | 2 +- utils/HelpGen/include/srcparser.h | 2 - utils/HelpGen/include/wxstlac.h | 5 +- utils/HelpGen/include/wxstllst.h | 4 + utils/HelpGen/include/wxstlvec.h | 4 + utils/HelpGen/src/HelpGen.cpp | 7 +- utils/HelpGen/src/HelpGen.rc | 3 + utils/HelpGen/src/makefile.nt | 66 ++++++++++++ 27 files changed, 344 insertions(+), 121 deletions(-) create mode 100644 samples/image/image.rc create mode 100644 samples/image/makefile.nt create mode 100644 utils/HelpGen/src/HelpGen.rc create mode 100644 utils/HelpGen/src/makefile.nt diff --git a/distrib/msw/zipdist.bat b/distrib/msw/zipdist.bat index 0e1dde4dab..420220df5a 100755 --- a/distrib/msw/zipdist.bat +++ b/distrib/msw/zipdist.bat @@ -36,7 +36,7 @@ zip32 -@ %dest\wx200cw.zip < %src\distrib\msw\cw.rsp zip32 -@ %dest\ogl3.zip < %src\utils\ogl\distrib\ogl.rsp rem Tex2RTF -zip32 -@ %dest\tex2rtf.zip < %src\distrib\msw\tex2rtf.rsp +zip32 -@ %dest\tex2rtf2.zip < %src\distrib\msw\tex2rtf.rsp copy %src\docs\changes.txt %dest copy %src\docs\msw\install.txt %dest\install_msw.txt diff --git a/docs/msw/todo.txt b/docs/msw/todo.txt index 6e19165510..5cdfc5d148 100644 --- a/docs/msw/todo.txt +++ b/docs/msw/todo.txt @@ -41,6 +41,12 @@ image, using Borland Image Editor. WIN16 doesn't have a function for specifying which image to use, so the larger one gets used erroneously. +Add headers to VC++ project files. + +Test GLCanvas. + +Distribution naming? + LOW PRIORITY (MEDIUM TERM) -------------------------- diff --git a/include/wx/image.h b/include/wx/image.h index ef5b924c1b..f411b6eab1 100644 --- a/include/wx/image.h +++ b/include/wx/image.h @@ -18,6 +18,7 @@ #include "wx/object.h" #include "wx/string.h" #include "wx/gdicmn.h" +#include "wx/stream.h" //----------------------------------------------------------------------------- // classes @@ -43,8 +44,8 @@ class WXDLLEXPORT wxImageHandler: public wxObject public: wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; } - virtual bool LoadFile( wxImage *image, const wxString& name ); - virtual bool SaveFile( wxImage *image, const wxString& name ); + virtual bool LoadFile( wxImage *image, wxInputStream& stream ); + virtual bool SaveFile( wxImage *image, wxOutputStream& stream ); inline void SetName(const wxString& name) { m_name = name; } inline void SetExtension(const wxString& ext) { m_extension = ext; } @@ -78,8 +79,8 @@ public: m_type = wxBITMAP_TYPE_PNG; }; - virtual bool LoadFile( wxImage *image, const wxString& name ); - virtual bool SaveFile( wxImage *image, const wxString& name ); + virtual bool LoadFile( wxImage *image, wxInputStream& stream ); + virtual bool SaveFile( wxImage *image, wxOutputStream& stream ); }; #endif @@ -100,7 +101,7 @@ public: m_type = wxBITMAP_TYPE_BMP; }; - virtual bool LoadFile( wxImage *image, const wxString& name ); + virtual bool LoadFile( wxImage *image, wxInputStream& stream ); }; //----------------------------------------------------------------------------- @@ -118,6 +119,7 @@ public: wxImage(); wxImage( int width, int height ); wxImage( const wxString& name, long type = wxBITMAP_TYPE_PNG ); + wxImage( wxInputStream& stream, long type = wxBITMAP_TYPE_PNG ); wxImage( const wxImage& image ); wxImage( const wxImage* image ); @@ -138,7 +140,9 @@ public: unsigned char GetBlue( int x, int y ); virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG ); + virtual bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_PNG ); virtual bool SaveFile( const wxString& name, int type ); + virtual bool SaveFile( wxOutputStream& stream, int type ); bool Ok() const; int GetWidth() const; diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 1c64b7aedc..3546f1f1e6 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -7,7 +7,17 @@ * */ +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP #include "wx/wx.h" +#endif + #include "wx/image.h" // derived classes @@ -77,6 +87,8 @@ END_EVENT_TABLE() MyCanvas::MyCanvas( wxWindow *parent, const wxWindowID id, const wxPoint &pos, const wxSize &size ) : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER ) { + SetBackgroundColour(* wxWHITE); + wxBitmap bitmap( 100, 100 ); wxMemoryDC dc; @@ -85,14 +97,20 @@ MyCanvas::MyCanvas( wxWindow *parent, const wxWindowID id, const wxPoint &pos, c dc.SetPen( *wxWHITE_PEN ); dc.DrawRectangle( 0, 0, 100, 100 ); dc.SelectObject( wxNullBitmap ); - + + wxString dir(""); + +#ifdef __WXGTK__ + dir = wxString("../"); +#endif + wxImage image( bitmap ); - image.SaveFile( "../test.png", wxBITMAP_TYPE_PNG ); + image.SaveFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG ); - image.LoadFile( "../horse.png", wxBITMAP_TYPE_PNG ); + image.LoadFile( dir + wxString("horse.png"), wxBITMAP_TYPE_PNG ); my_horse = new wxBitmap( image.ConvertToBitmap() ); - image.LoadFile( "../test.png", wxBITMAP_TYPE_PNG ); + image.LoadFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG ); my_square = new wxBitmap( image.ConvertToBitmap() ); } @@ -140,8 +158,7 @@ MyFrame::MyFrame(void) : wxMenuBar *menu_bar = new wxMenuBar(); menu_bar->Append(file_menu, "File"); - menu_bar->Show( TRUE ); - + SetMenuBar( menu_bar ); CreateStatusBar(2); @@ -166,7 +183,8 @@ void MyFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) { int w,h; GetClientSize( &w, &h ); - m_canvas->SetSize( w, h ); + if (m_canvas) + m_canvas->SetSize( w, h ); } //----------------------------------------------------------------------------- @@ -188,7 +206,3 @@ bool MyApp::OnInit(void) return TRUE; } - - - - diff --git a/samples/image/image.rc b/samples/image/image.rc new file mode 100644 index 0000000000..626b82f58a --- /dev/null +++ b/samples/image/image.rc @@ -0,0 +1,3 @@ +/* mondrian ICON "mondrian.ico" */ +#include "wx/msw/wx.rc" + diff --git a/samples/image/makefile.nt b/samples/image/makefile.nt new file mode 100644 index 0000000000..c2b083308f --- /dev/null +++ b/samples/image/makefile.nt @@ -0,0 +1,64 @@ +# +# File: makefile.nt +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds image example (MS VC++). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +# Set WXDIR for your system +WXDIR = $(WXWIN) + +WXUSINGDLL=0 + +!include $(WXDIR)\src\ntwxwin.mak + +THISDIR = $(WXDIR)\samples\image +PROGRAM=image + +OBJECTS = $(PROGRAM).obj + +$(PROGRAM): $(PROGRAM).exe + +all: wx $(PROGRAM).exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.nt FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.nt clean + cd $(THISDIR) + +$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(PROGRAM).res + $(link) @<< +-out:$(PROGRAM).exe +$(LINKFLAGS) +$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res +$(LIBS) +<< + + +$(PROGRAM).obj: $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc + $(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc + + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.sbr + -erase *.pdb diff --git a/src/common/image.cpp b/src/common/image.cpp index 3138c68f0b..858a80a0cc 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -26,6 +26,7 @@ #include "../png/png.h" #endif #include "wx/filefn.h" +#include "wx/wfstream.h" #ifdef __WXMSW__ #include @@ -91,6 +92,11 @@ wxImage::wxImage( const wxString& name, long type ) LoadFile( name, type ); } +wxImage::wxImage( wxInputStream& stream, long type ) +{ + LoadFile( stream, type ); +} + wxImage::wxImage( const wxImage& image ) { Ref(image); @@ -296,15 +302,23 @@ int wxImage::GetHeight() const bool wxImage::LoadFile( const wxString& filename, long type ) { - UnRef(); - - if (!wxFileExists(filename)) + if (wxFileExists(filename)) { + wxFileInputStream stream(filename); + return LoadFile(stream, type); + } + + else { wxLogWarning( "Image file does not exist." ); return FALSE; } +} +bool wxImage::LoadFile( wxInputStream& stream, long type ) +{ + UnRef(); + m_refData = new wxImageRefData; wxImageHandler *handler = FindHandler(type); @@ -316,10 +330,20 @@ bool wxImage::LoadFile( const wxString& filename, long type ) return FALSE; } - return handler->LoadFile( this, filename ); + return handler->LoadFile( this, stream ); } bool wxImage::SaveFile( const wxString& filename, int type ) +{ + wxFileOutputStream stream(filename); + + if ( stream.LastError() == wxStream_NOERROR ) + return SaveFile(stream, type); + else + return FALSE; +} + +bool wxImage::SaveFile( wxOutputStream& stream, int type ) { wxCHECK_MSG( Ok(), FALSE, "invalid image" ); @@ -332,7 +356,7 @@ bool wxImage::SaveFile( const wxString& filename, int type ) return FALSE; } - return handler->SaveFile( this, filename ); + return handler->SaveFile( this, stream ); } void wxImage::AddHandler( wxImageHandler *handler ) @@ -424,12 +448,12 @@ void wxImage::CleanUpHandlers() IMPLEMENT_DYNAMIC_CLASS(wxImageHandler,wxObject) #endif -bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), const wxString& WXUNUSED(name) ) +bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), wxInputStream& WXUNUSED(stream) ) { return FALSE; } -bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), const wxString& WXUNUSED(name) ) +bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream) ) { return FALSE; } @@ -443,9 +467,27 @@ bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), const wxString& WXUNUSE #if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxPNGHandler,wxImageHandler) #endif + + +static void _PNG_stream_reader( png_structp png_ptr, png_bytep data, png_size_t length ) +{ + ((wxInputStream*) png_get_io_ptr( png_ptr )) -> Read(data, length); +} -bool wxPNGHandler::LoadFile( wxImage *image, const wxString& name ) +static void _PNG_stream_writer( png_structp png_ptr, png_bytep data, png_size_t length ) { + ((wxOutputStream*) png_get_io_ptr( png_ptr )) -> Write(data, length); +} + +bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream ) +{ +// png_structp png_ptr; + // png_infop info_ptr; + // unsigned char *ptr, **lines, *ptr2; + // int transp,bit_depth,color_type,interlace_type; + //png_uint_32 width, height; + //unsigned int i; + image->Destroy(); png_structp png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING, @@ -469,10 +511,8 @@ bool wxPNGHandler::LoadFile( wxImage *image, const wxString& name ) { png_destroy_read_struct( &png_ptr, &info_ptr, (png_infopp) NULL ); return FALSE; - } - - FILE *f = fopen( name, "rb" ); - png_init_io( png_ptr, f ); + } + png_set_read_fn( png_ptr, &stream, _PNG_stream_reader); png_uint_32 width,height; int bit_depth,color_type,interlace_type; @@ -591,35 +631,30 @@ bool wxPNGHandler::LoadFile( wxImage *image, const wxString& name ) } -bool wxPNGHandler::SaveFile( wxImage *image, const wxString& name ) +bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream ) { - FILE *f = fopen( name, "wb" ); - if (!f) return FALSE; - - png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, - (voidp) NULL, (png_error_ptr) NULL, (png_error_ptr) NULL); + { + png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) { - fclose( f ); - return FALSE; + return FALSE; } png_infop info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { - fclose(f); - png_destroy_write_struct( &png_ptr, (png_infopp) NULL ); - return FALSE; + png_destroy_write_struct( &png_ptr, (png_infopp)NULL ); + return FALSE; } if (setjmp(png_ptr->jmpbuf)) { - fclose( f ); - png_destroy_write_struct( &png_ptr, (png_infopp) NULL ); - return FALSE; + png_destroy_write_struct( &png_ptr, (png_infopp)NULL ); + return FALSE; } - png_init_io( png_ptr, f ); + 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); @@ -637,9 +672,8 @@ bool wxPNGHandler::SaveFile( wxImage *image, const wxString& name ) unsigned char *data = (unsigned char *)malloc( image->GetWidth()*4 ); if (!data) { - fclose( f ); - png_destroy_write_struct( &png_ptr, (png_infopp) NULL ); - return FALSE; + png_destroy_write_struct( &png_ptr, (png_infopp)NULL ); + return FALSE; } for (int y = 0; y < image->GetHeight(); y++) @@ -667,11 +701,9 @@ bool wxPNGHandler::SaveFile( wxImage *image, const wxString& name ) free(data); png_write_end( png_ptr, info_ptr ); - png_destroy_write_struct( &png_ptr, (png_infopp) NULL ); - - fclose(f); - - return TRUE; + png_destroy_write_struct( &png_ptr, (png_infopp)NULL ); + } + return TRUE; } #endif @@ -686,9 +718,8 @@ bool wxPNGHandler::SaveFile( wxImage *image, const wxString& name ) IMPLEMENT_DYNAMIC_CLASS(wxBMPHandler,wxImageHandler) #endif -bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) +bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) { - FILE *file; unsigned char *data, *ptr; int done, i, bpp, planes, comp, ncolors, line, column, linesize, linepos, rshift = 0, gshift = 0, bshift = 0; @@ -696,6 +727,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) short int word; long int dbuf[4], dword, rmask = 0, gmask = 0, bmask = 0, offset, size; + off_t start_offset = stream.TellI(); signed char bbuf[4]; struct _cmap { @@ -714,56 +746,48 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) image->Destroy(); - file = fopen(name, "r"); - if (!file) - return NULL; - done = 0; /* * Reading the bmp header */ - fread(&bbuf, 1, 2, file); + stream.Read(&bbuf, 2); - fread(dbuf, 4, 4, file); + stream.Read(dbuf, 4 * 4); size = dbuf[0]; offset = dbuf[2]; - fread(dbuf, 4, 2, file); + stream.Read(dbuf, 4 * 2); int width = (int)dbuf[0]; int height = (int)dbuf[1]; if (width > 32767) { wxLogError( "Image width > 32767 pixels for file\n" ); - fclose(file); return FALSE; } if (height > 32767) { wxLogError( "Image height > 32767 pixels for file\n" ); - fclose(file); return FALSE; } - fread(&word, 2, 1, file); + stream.Read(&word, 2); planes = (int)word; - fread(&word, 2, 1, file); + stream.Read(&word, 2); bpp = (int)word; if (bpp != 1 && bpp != 4 && bpp != 8 && bpp && 16 && bpp != 24 && bpp != 32) { wxLogError( "unknown bitdepth in file\n" ); - fclose(file); return FALSE; } - fread(dbuf, 4, 4, file); + stream.Read(dbuf, 4 * 4); comp = (int)dbuf[0]; if (comp != BI_RGB && comp != BI_RLE4 && comp != BI_RLE8 && comp != BI_BITFIELDS) { wxLogError( "unknown encoding in Windows BMP file\n" ); - fclose(file); return FALSE; } - fread(dbuf, 4, 2, file); + stream.Read(dbuf, 4 * 2); ncolors = (int)dbuf[0]; if (ncolors == 0) ncolors = 1 << bpp; @@ -771,7 +795,6 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) if (((comp == BI_RLE4) && (bpp != 4)) || ((comp == BI_RLE8) && (bpp != 8)) || ((comp == BI_BITFIELDS) && (bpp != 16 && bpp != 32))) { wxLogError( "encoding of BMP doesn't match bitdepth\n" ); - fclose(file); return FALSE; } if (bpp < 16) @@ -781,7 +804,6 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) if (!cmap) { wxLogError( "Cannot allocate RAM for color map in BMP file\n" ); - fclose(file); return FALSE; } } @@ -793,7 +815,6 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) if (!ptr) { wxLogError( "Cannot allocate RAM for RGB data in file\n" ); - fclose(file); if (cmap) free(cmap); return FALSE; @@ -806,7 +827,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) { for (i = 0; i < ncolors; i++) { - fread(bbuf, 1, 4, file); + stream.Read(bbuf, 4); cmap[i].b = bbuf[0]; cmap[i].g = bbuf[1]; cmap[i].r = bbuf[2]; @@ -818,7 +839,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) { int bit = 0; - fread(dbuf, 4, 3, file); + stream.Read(dbuf, 4 * 3); bmask = dbuf[0]; gmask = dbuf[1]; rmask = dbuf[2]; @@ -856,7 +877,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) /* * Reading the image data */ - fseek(file, offset, SEEK_SET); + stream.SeekI(start_offset + offset); data = ptr; /* set the whole image to the background color */ @@ -889,7 +910,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) int index; linepos++; - aByte = getc(file); + aByte = stream.GetC(); if (bpp == 1) { int bit = 0; @@ -935,7 +956,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) unsigned char first; first = aByte; - aByte = getc(file); + aByte = stream.GetC(); if (first == 0) { if (aByte == 0) @@ -949,10 +970,10 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) } else if (aByte == 2) { - aByte = getc(file); + aByte = stream.GetC(); column += aByte; linepos = column * bpp / 8; - aByte = getc(file); + aByte = stream.GetC(); line += aByte; } else @@ -962,14 +983,14 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) for (i = 0; i < absolute; i++) { linepos++; - aByte = getc(file); + aByte = stream.GetC(); ptr[poffset] = cmap[aByte].r; ptr[poffset + 1] = cmap[aByte].g; ptr[poffset + 2] = cmap[aByte].b; column++; } if (absolute & 0x01) - aByte = getc(file); + aByte = stream.GetC(); } } else @@ -996,7 +1017,8 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) } else if (bpp == 24) { - linepos += fread(&bbuf, 1, 3, file); + stream.Read(&bbuf, 3); + linepos += 3; ptr[poffset] = (unsigned char)bbuf[2]; ptr[poffset + 1] = (unsigned char)bbuf[1]; ptr[poffset + 2] = (unsigned char)bbuf[0]; @@ -1006,7 +1028,8 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) { unsigned char temp; - linepos += fread(&word, 2, 1, file); + stream.Read(&word, 2); + linepos += 2; temp = (word & rmask) >> rshift; ptr[poffset] = temp; temp = (word & gmask) >> gshift; @@ -1019,7 +1042,8 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) { unsigned char temp; - linepos += fread(&dword, 4, 1, file); + stream.Read(&dword, 4); + linepos += 4; temp = (dword & rmask) >> rshift; ptr[poffset] = temp; temp = (dword & gmask) >> gshift; @@ -1031,10 +1055,9 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) } while ((linepos < linesize) && (comp != 1) && (comp != 2)) { - int temp = fread(&aByte, 1, 1, file); - - linepos += temp; - if (!temp) + stream.Read(&aByte, 1); + linepos += 1; + if (stream.LastError() != wxStream_NOERROR) break; } } @@ -1042,7 +1065,6 @@ bool wxBMPHandler::LoadFile( wxImage *image, const wxString& name ) image->SetMask( FALSE ); - fclose(file); return TRUE; } diff --git a/src/common/mimetype.cpp b/src/common/mimetype.cpp index 9a1e1b4fba..9194145321 100644 --- a/src/common/mimetype.cpp +++ b/src/common/mimetype.cpp @@ -34,6 +34,9 @@ #include "wx/icon.h" #endif //WX_PRECOMP +// Doesn't compile in WIN16 mode +#ifndef __WIN16__ + #include "wx/log.h" #include "wx/intl.h" #include "wx/dynarray.h" @@ -1210,5 +1213,5 @@ void wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName) #endif // OS type -/* vi: set cin tw=80 ts=4 sw=4: */ - +#endif + // __WIN16__ diff --git a/src/common/resourc2.cpp b/src/common/resourc2.cpp index e08516d3b1..4bee887ddb 100644 --- a/src/common/resourc2.cpp +++ b/src/common/resourc2.cpp @@ -76,7 +76,7 @@ #include "wx/settings.h" -#if (defined(__BORLANDC__) && defined(__WIN16__)) +#if ((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__)) // Forward (private) declarations bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db); @@ -704,7 +704,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table wxItemResource *item = table->FindResource(resource); if (item) { - if (!item->GetType() || strcmp(item->GetType(), "wxBitmap") != 0) + if ((item->GetType() == "") || (item->GetType() != "wxBitmap")) { wxLogWarning(_("%s not a bitmap resource specification."), (const char*) resource); return wxNullBitmap; @@ -859,7 +859,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) wxItemResource *item = table->FindResource(resource); if (item) { - if ((item->GetType() == "") || strcmp(item->GetType(), "wxIcon") != 0) + if ((item->GetType() == "") || (item->GetType() != "wxIcon")) { wxLogWarning(_("%s not an icon resource specification."), (const char*) resource); return wxNullIcon; @@ -1482,7 +1482,7 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, wxItemResource *resource = table->FindResource((const char *)resourceName); // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX)) - if (!resource || !resource->GetType() || + if (!resource || (resource->GetType() == "") || ! ((strcmp(resource->GetType(), "wxDialog") == 0) || (strcmp(resource->GetType(), "wxPanel") == 0))) return FALSE; diff --git a/src/common/resource.cpp b/src/common/resource.cpp index abead5b084..436565d0ed 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -1431,7 +1431,7 @@ wxFont wxResourceInterpretFontSpec(wxExpr *expr) // Separate file for the remainder of this, for BC++/Win16 -#if !(defined(__BORLANDC__) && defined(__WIN16__)) +#if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__)) /* * (Re)allocate buffer for reading in from resource file */ diff --git a/src/makesc.env b/src/makesc.env index 2237f97a55..064e1cbf02 100644 --- a/src/makesc.env +++ b/src/makesc.env @@ -16,17 +16,18 @@ CC=sc RC=rc # WIN16 settings -#CFLAGS = -Jm -ml -W -D__WXMSW__ -D__WXDEBUG__ -D__WINDOWS__ -D__WIN16__ $(EXTRACPPFLAGS) -#LDFLAGS = -ml -W +#CFLAGS = -Jm -ml -W -D__WXMSW__ -D__SC__ -D__WXDEBUG__ -D__WINDOWS__ -D__WIN16__ $(EXTRACPPFLAGS) #LINKER = link -#LIBS=$(WXLIB) $(EXTRALIBS) libw.lib commdlg.lib ddeml.lib shell.lib +#LDFLAGS = -ml -W -L$(LINKER).exe $(EXTRALDFLAGS) +#LIBS=$(WXLIB) $(EXTRALIBS) libw.lib commdlg.lib ddeml.lib shell.lib # $(LIB)\ctl3dv2.lib #DEFFILE=sc16.def # WIN32 settings CFLAGS = -o -mn -W -D__NT__ -DWIN32 -D__WIN32__ -D__WINDOWS__ -D__WXMSW__ -D__SC__ -D__WXDEBUG__ $(EXTRACPPFLAGS) -LDFLAGS = -Llink386.exe $(EXTRALDFLAGS) LINKER = link386 +LDFLAGS = -L$(LINKER).exe $(EXTRALDFLAGS) LIBS=$(WXLIB) $(EXTRALIBS) ctl3d32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib kernel32.lib winmm.lib +DEFFILE=sc32.def .$(SRCSUFF).obj: *$(CC) -c $(CFLAGS) -I$(INCLUDE) $(OPTIONS) $< -o$@ diff --git a/src/msw/app.cpp b/src/msw/app.cpp index e795e42453..9301d3f76d 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -33,6 +33,7 @@ #include "wx/dc.h" #include "wx/dialog.h" #include "wx/msgdlg.h" + #include "wx/intl.h" #endif #include "wx/msw/private.h" @@ -248,7 +249,8 @@ bool wxApp::Initialize() // This is to foil optimizations in Visual C++ that // throw out dummy.obj. -#if (_MSC_VER >= 800) && !defined(WXMAKINGDLL) +// #if (_MSC_VER >= 800) && !defined(WXMAKINGDLL) +#if defined(_MSC_VER) && defined(__WIN16__) && !defined(WXMAKINGDLL) extern char wxDummyChar; if (wxDummyChar) wxDummyChar++; #endif diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index b4848d08c2..9ab8c3ceb7 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -22,8 +22,6 @@ #if wxUSE_OWNER_DRAWN -#include - #include "wx/object.h" #include "wx/colour.h" #include "wx/font.h" @@ -35,6 +33,8 @@ #include "wx/dcmemory.h" #include "wx/msw/checklst.h" +#include + // ============================================================================ // implementation // ============================================================================ diff --git a/src/msw/dummy.cpp b/src/msw/dummy.cpp index 50f5c99001..e03022c6f5 100644 --- a/src/msw/dummy.cpp +++ b/src/msw/dummy.cpp @@ -39,8 +39,11 @@ #pragma hdrstop #endif -// Foils optimizations in Visual C++ (see also wx_main.cc) +// 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; +#endif #if defined(WXUSINGDLL) diff --git a/src/msw/dummydll.cpp b/src/msw/dummydll.cpp index 16f1b40d8c..94d3a94a5f 100644 --- a/src/msw/dummydll.cpp +++ b/src/msw/dummydll.cpp @@ -17,5 +17,9 @@ #include "wx/wxprec.h" -// Foils optimizations in Visual C++ (see also wx_main.cc) +// 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; +#endif + diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc index 3bb6b74e3e..42b89ee629 100644 --- a/src/msw/makefile.sc +++ b/src/msw/makefile.sc @@ -77,6 +77,7 @@ COMMONOBJS = \ $(COMMDIR)\object.obj \ $(COMMDIR)\prntbase.obj \ $(COMMDIR)\resource.obj \ + $(COMMDIR)\resourc2.obj \ $(COMMDIR)\tbarbase.obj \ $(COMMDIR)\tbarsmpl.obj \ $(COMMDIR)\textfile.obj \ @@ -88,14 +89,6 @@ COMMONOBJS = \ $(COMMDIR)\hash.obj \ $(COMMDIR)\list.obj \ $(COMMDIR)\string.obj \ - $(COMMDIR)\socket.obj \ - $(COMMDIR)\sckaddr.obj \ - $(COMMDIR)\sckfile.obj \ - $(COMMDIR)\sckipc.obj \ - $(COMMDIR)\sckstrm.obj \ - $(COMMDIR)\url.obj \ - $(COMMDIR)\http.obj \ - $(COMMDIR)\protocol.obj \ $(COMMDIR)\time.obj \ $(COMMDIR)\tokenzr.obj \ $(COMMDIR)\wxexpr.obj \ @@ -111,6 +104,16 @@ COMMONOBJS = \ $(COMMDIR)\variant.obj \ $(COMMDIR)\wincmn.obj +# Don't compile for WIN16 +# $(COMMDIR)\socket.obj \ +# $(COMMDIR)\sckaddr.obj \ +# $(COMMDIR)\sckfile.obj \ +# $(COMMDIR)\sckipc.obj \ +# $(COMMDIR)\sckstrm.obj \ +# $(COMMDIR)\url.obj \ +# $(COMMDIR)\http.obj \ +# $(COMMDIR)\protocol.obj \ + # Don't compile # $(COMMDIR)\db.obj \ # $(COMMDIR)\dbtable.obj \ diff --git a/src/msw/regconf.cpp b/src/msw/regconf.cpp index 3a1a84eb3b..2fe6d9da58 100644 --- a/src/msw/regconf.cpp +++ b/src/msw/regconf.cpp @@ -28,6 +28,9 @@ #include #include #include + +#ifndef __WIN16__ + #include #include @@ -471,3 +474,7 @@ bool wxRegConfig::DeleteAll() return bOk; } + +#endif + // __WIN16__ + diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index bb51ed0337..5d44fc5a73 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -27,9 +27,10 @@ #include "wx/string.h" #include "wx/intl.h" #include "wx/log.h" - #include "wx/config.h" // for wxExpandEnvVars +#ifndef __WIN16__ + // Windows headers /* #define STRICT @@ -799,3 +800,7 @@ void RemoveTrailingSeparator(wxString& str) if ( !str.IsEmpty() && str.Last() == REG_SEPARATOR ) str.Truncate(str.Len() - 1); } + +#endif + // __WIN16__ + diff --git a/src/msw/taskbar.cpp b/src/msw/taskbar.cpp index 334be2636e..68c7ac60aa 100644 --- a/src/msw/taskbar.cpp +++ b/src/msw/taskbar.cpp @@ -21,8 +21,6 @@ #pragma hdrstop #endif -#include - #ifndef WX_PRECOMP #include "wx/defs.h" #include "wx/window.h" @@ -32,6 +30,7 @@ #ifdef __WIN95__ +#include #include #include #include diff --git a/src/ntwxwin.mak b/src/ntwxwin.mak index 6ab7fc5ff8..18ec6b8f64 100644 --- a/src/ntwxwin.mak +++ b/src/ntwxwin.mak @@ -100,7 +100,7 @@ EXTRADLLFLAGS=$(EXTRADLLFLAGS) /DNOMAIN !endif INC=-I$(WXINC) -I$(WXDIR)/src/png -I$(WXDIR)/src/zlib $(EXTRAINC) -LIBS = $(EXTRALIBS) $(WXLIB) $(WINLIBS) +LIBS = $(EXTRALIBS) $(WXLIB) $(WINLIBS) $(WXDIR)\lib\winpng.lib $(WXDIR)\lib\zlib.lib !ifndef FINAL FINAL=0 diff --git a/utils/HelpGen/include/srcparser.h b/utils/HelpGen/include/srcparser.h index 6d0a550d36..d6dba4650f 100644 --- a/utils/HelpGen/include/srcparser.h +++ b/utils/HelpGen/include/srcparser.h @@ -15,7 +15,6 @@ #define __SRCPARSER_G__ #if defined( wxUSE_TEMPLATE_STL ) - #include #ifdef WIN32 @@ -28,7 +27,6 @@ #endif #else - #include "wx/string.h" #include "wxstlvec.h" diff --git a/utils/HelpGen/include/wxstlac.h b/utils/HelpGen/include/wxstlac.h index 62b4ba485f..9f69f1f26d 100644 --- a/utils/HelpGen/include/wxstlac.h +++ b/utils/HelpGen/include/wxstlac.h @@ -12,13 +12,16 @@ #ifndef __WXSTLAC_G__ #define __WXSTLAC_G__ +#ifdef new +#undef new +#endif + #include #include #include #include #include - // the below macro used internally (see actual interface after this macro) // arguments: diff --git a/utils/HelpGen/include/wxstllst.h b/utils/HelpGen/include/wxstllst.h index 76fd0108e1..5a1d1bc469 100644 --- a/utils/HelpGen/include/wxstllst.h +++ b/utils/HelpGen/include/wxstllst.h @@ -12,6 +12,10 @@ #ifndef __WXSTLLST_G__ #define __WXSTLLST_G__ +#ifdef new +#undef new +#endif + #include #include #include diff --git a/utils/HelpGen/include/wxstlvec.h b/utils/HelpGen/include/wxstlvec.h index ddfbead071..6658b07559 100644 --- a/utils/HelpGen/include/wxstlvec.h +++ b/utils/HelpGen/include/wxstlvec.h @@ -12,6 +12,10 @@ #ifndef __WXSTLVEC_G__ #define __WXSTLVEC_G__ +#ifdef new +#undef new +#endif + #include #include // imports memmove() #include diff --git a/utils/HelpGen/src/HelpGen.cpp b/utils/HelpGen/src/HelpGen.cpp index d4bb767050..c8908f0732 100644 --- a/utils/HelpGen/src/HelpGen.cpp +++ b/utils/HelpGen/src/HelpGen.cpp @@ -40,10 +40,11 @@ #ifndef WX_PRECOMP #include #include - #include #include #endif // WX_PRECOMP +#include + // C++ parsing classes #include "cjparser.h" @@ -69,6 +70,10 @@ static wxString GetAllComments(const spContext& ctx); // get the string with current time (returns pointer to static buffer) // timeFormat is used for the call of strftime(3) +#ifdef GetCurrentTime +#undef GetCurrentTime +#endif + static const char *GetCurrentTime(const char *timeFormat); // ----------------------------------------------------------------------------- diff --git a/utils/HelpGen/src/HelpGen.rc b/utils/HelpGen/src/HelpGen.rc new file mode 100644 index 0000000000..626b82f58a --- /dev/null +++ b/utils/HelpGen/src/HelpGen.rc @@ -0,0 +1,3 @@ +/* mondrian ICON "mondrian.ico" */ +#include "wx/msw/wx.rc" + diff --git a/utils/HelpGen/src/makefile.nt b/utils/HelpGen/src/makefile.nt new file mode 100644 index 0000000000..d1f107585e --- /dev/null +++ b/utils/HelpGen/src/makefile.nt @@ -0,0 +1,66 @@ +# +# File: makefile.nt +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds minimal example (MS VC++). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +# Set WXDIR for your system +WXDIR = $(WXWIN) + +WXUSINGDLL=0 + +!include $(WXDIR)\src\ntwxwin.mak + +THISDIR = $(WXDIR)\utils\HelpGen\src +PROGRAM=HelpGen +EXTRAINC=-I..\include + +OBJECTS = $(PROGRAM).obj cjparser.obj ifcontext.obj markup.obj\ + scriptbinder.obj srcparser.obj sourcepainter.obj + +$(PROGRAM): $(PROGRAM).exe + +all: wx $(PROGRAM).exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.nt FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.nt clean + cd $(THISDIR) + +$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(PROGRAM).res + $(link) @<< +-out:$(PROGRAM).exe +$(LINKFLAGS) +$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res +$(LIBS) +<< + + +$(PROGRAM).obj: $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc + $(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc + + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.sbr + -erase *.pdb -- 2.45.2