From dbda9e86f0e5ec1184bc16d135bb7205bc99236e Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 9 Feb 1999 16:00:23 +0000 Subject: [PATCH] Added more makefiles; fixed some samples for Cygwin git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1654 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- distrib/msw/msw.rsp | 8 + docs/motif/install.txt | 6 + docs/msw/install.txt | 31 +- include/wx/date.h | 9 + include/wx/defs.h | 7 +- include/wx/motif/window.h | 1 + include/wx/msw/setup0.h | 2 +- include/wx/msw/window.h | 8 +- include/wx/string.h | 10 +- include/wx/stubs/window.h | 1 + include/wx/valgen.h | 2 +- samples/db/makefile.g95 | 16 + samples/dnd/makefile.unx | 17 + samples/forty/makefile.b32 | 16 + samples/image/makefile.b32 | 16 + samples/image/makefile.g95 | 16 + samples/mdi/makefile.sl | 18 + samples/mfc/makefile.g95 | 16 + samples/minimal/makefile.sc | 36 + samples/minimal/makefile.sl | 18 + samples/minimal/makefile.wat | 15 + samples/png/makefile.b32 | 16 + samples/png/makefile.g95 | 16 + samples/regtest/makefile.b32 | 16 + samples/splitter/makefile.dos | 17 + samples/validate/makefile.unx | 17 + samples/wxsocket/client.g95 | 16 + samples/wxsocket/makefile.dos | 19 + samples/wxsocket/server.g95 | 16 + src/common/image.cpp | 1730 +++++++++---------- src/common/string.cpp | 4 + src/makeb32.env | 4 +- src/makebcc.env | 8 +- src/makeg95.env | 20 +- src/makelib.b32 | 37 + src/makelib.bcc | 37 + src/makelib.g95 | 23 + src/makelib.wat | 26 + src/makeprog.b32 | 11 +- src/makeprog.bcc | 7 +- src/makeprog.g95 | 23 + src/makeprog.wat | 4 +- src/makewat.env | 2 +- src/msw/clipbrd.cpp | 1 + src/msw/dialog.cpp | 1 + src/msw/makefile.g95 | 15 +- src/msw/makefile.twn | 1 + src/msw/window.cpp | 73 +- utils/dialoged/src/makefile.b32 | 5 +- utils/dialoged/src/makefile.g95 | 64 +- utils/glcanvas/samples/cube/makefile.b32 | 18 + utils/glcanvas/samples/cube/makefile.bcc | 21 + utils/glcanvas/samples/cube/makefile.g95 | 43 +- utils/glcanvas/samples/cube/makefile.wat | 17 + utils/glcanvas/samples/isosurf/makefile.b32 | 22 + utils/glcanvas/samples/isosurf/makefile.bcc | 25 + utils/glcanvas/samples/isosurf/makefile.g95 | 20 + utils/glcanvas/samples/isosurf/makefile.wat | 20 + utils/glcanvas/samples/penguin/makefile.b32 | 18 + utils/glcanvas/samples/penguin/makefile.bcc | 21 + utils/glcanvas/samples/penguin/makefile.g95 | 18 + utils/glcanvas/samples/penguin/makefile.wat | 17 + utils/glcanvas/win/makefile.b32 | 17 + utils/glcanvas/win/makefile.bcc | 19 + utils/glcanvas/win/makefile.g95 | 16 + utils/glcanvas/win/makefile.wat | 16 + utils/ogl/samples/ogledit/Makefile | 1 + utils/ogl/samples/ogledit/Makefile.in | 29 + utils/ogl/samples/ogledit/makefile.b32 | 88 +- utils/ogl/samples/ogledit/makefile.bcc | 80 +- utils/ogl/samples/ogledit/makefile.g95 | 18 + utils/ogl/samples/studio/makefile.b32 | 19 + utils/ogl/samples/studio/makefile.bcc | 22 + utils/ogl/samples/studio/makefile.g95 | 19 + utils/ogl/src/basic.cpp | 4 +- utils/ogl/src/drawn.cpp | 16 +- utils/ogl/src/makefile.b32 | 98 +- utils/ogl/src/makefile.bcc | 94 +- utils/ogl/src/makefile.g95 | 17 + utils/tex2rtf/src/makefile.g95 | 63 +- utils/tex2rtf/src/texutils.cpp | 23 +- utils/wxtree/src/makefile.b32 | 10 +- utils/wxtree/src/makefile.bcc | 90 +- utils/wxtree/src/makefile.g95 | 52 +- 84 files changed, 1994 insertions(+), 1575 deletions(-) create mode 100644 samples/db/makefile.g95 create mode 100644 samples/dnd/makefile.unx create mode 100644 samples/forty/makefile.b32 create mode 100644 samples/image/makefile.b32 create mode 100644 samples/image/makefile.g95 create mode 100644 samples/mdi/makefile.sl create mode 100644 samples/mfc/makefile.g95 create mode 100644 samples/minimal/makefile.sc create mode 100644 samples/minimal/makefile.sl create mode 100644 samples/minimal/makefile.wat create mode 100644 samples/png/makefile.b32 create mode 100644 samples/png/makefile.g95 create mode 100644 samples/regtest/makefile.b32 create mode 100644 samples/splitter/makefile.dos create mode 100644 samples/validate/makefile.unx create mode 100644 samples/wxsocket/client.g95 create mode 100644 samples/wxsocket/makefile.dos create mode 100644 samples/wxsocket/server.g95 create mode 100644 src/makelib.b32 create mode 100644 src/makelib.bcc create mode 100644 src/makelib.g95 create mode 100644 src/makelib.wat create mode 100644 src/makeprog.g95 create mode 100644 utils/glcanvas/samples/cube/makefile.b32 create mode 100644 utils/glcanvas/samples/cube/makefile.bcc create mode 100644 utils/glcanvas/samples/cube/makefile.wat create mode 100644 utils/glcanvas/samples/isosurf/makefile.b32 create mode 100644 utils/glcanvas/samples/isosurf/makefile.bcc create mode 100644 utils/glcanvas/samples/isosurf/makefile.g95 create mode 100644 utils/glcanvas/samples/isosurf/makefile.wat create mode 100644 utils/glcanvas/samples/penguin/makefile.b32 create mode 100644 utils/glcanvas/samples/penguin/makefile.bcc create mode 100644 utils/glcanvas/samples/penguin/makefile.g95 create mode 100644 utils/glcanvas/samples/penguin/makefile.wat create mode 100644 utils/glcanvas/win/makefile.b32 create mode 100644 utils/glcanvas/win/makefile.bcc create mode 100644 utils/glcanvas/win/makefile.g95 create mode 100644 utils/glcanvas/win/makefile.wat create mode 100644 utils/ogl/samples/ogledit/Makefile create mode 100644 utils/ogl/samples/ogledit/Makefile.in create mode 100644 utils/ogl/samples/ogledit/makefile.g95 create mode 100644 utils/ogl/samples/studio/makefile.b32 create mode 100644 utils/ogl/samples/studio/makefile.bcc create mode 100644 utils/ogl/samples/studio/makefile.g95 create mode 100644 utils/ogl/src/makefile.g95 diff --git a/distrib/msw/msw.rsp b/distrib/msw/msw.rsp index 5c91e57c39..710bf7ef3a 100644 --- a/distrib/msw/msw.rsp +++ b/distrib/msw/msw.rsp @@ -10,22 +10,30 @@ tools/gettext/msgunfmt.exe src/makeb32.env src/makeprog.b32 +src/makelib.b32 src/makebcc.env src/makeprog.bcc +src/makelib.bcc src/makemsc.env src/makeprog.msc +src/makelib.msc src/makewat.env src/makeprog.wat +src/makelib.wat src/makesc.env src/makevc.env src/makeprog.vc src/makelib.vc src/makeg95.env +src/makeprog.g95 +src/makelib.g95 src/makesl.env src/makeprog.sl +src/makelib.sl src/salford.lnk src/maketwin.env src/makeprog.twn +src/makelib.twn src/makefile.bcc src/makefile.dos src/makefile.vc diff --git a/docs/motif/install.txt b/docs/motif/install.txt index 2c78c9aaf6..1279481f77 100644 --- a/docs/motif/install.txt +++ b/docs/motif/install.txt @@ -1,6 +1,12 @@ wxWindows 2.0 for Motif installation ------------------------------------ +IMPORTANT NOTE: If you experience problems installing, please +re-read this instructions and other related files (todo.txt, +bugs.txt etc.) carefully before mailing wxwin-users or +the author. Preferably, try to fix the problem first and +then send a patch to the author. + - Prerequisites: Motif 1.2 or above, or Lesstif (not yet tested). Motif 2.0 and above may also be suitable. diff --git a/docs/msw/install.txt b/docs/msw/install.txt index ee25d87c26..a8e5447ff5 100644 --- a/docs/msw/install.txt +++ b/docs/msw/install.txt @@ -2,6 +2,12 @@ Installing wxWindows 2.0 ------------------------ +IMPORTANT NOTE: If you experience problems installing, please +re-read this instructions and other related files (todo.txt, +bugs.txt etc.) carefully before mailing wxwin-users or +the author. Preferably, try to fix the problem first and +then send a patch to the author. + Unarchiving ----------- @@ -22,8 +28,7 @@ wx200vc.zip MS VC++ 5.0 project files wx200cw.zip Metrowerks CodeWarrior project files Unarchive the required files plus any optional documentation -files into a suitable directory such as c:\wx. Alter your -WXWIN environment variable to point to this directory. +files into a suitable directory such as c:\wx. Other add-on packages are available from the wxWindows Web site, such as: @@ -32,13 +37,21 @@ Other add-on packages are available from the wxWindows Web site, such as: - tex2rtf3.zip. Tex2RTF: create Windows Help, HTML, and Word RTF files from the same document source. +General installation notes +-------------------------- + +Alter your WXWIN environment variable to point to this directory. +For Cygwin or Mingw32 compilation, make sure WXWIN contains only +forward slashes. + +If installing from the CVS server, copy include/wx/msw/setup0.h to +include/wx/msw/setup.h. + Compilation ----------- -At present, wxWindows compiles with VC++ 4.0/5.0/6.0, -BC++ 4.5/5.0, Cygwin b19/b20, and Mingw32. It may compile -with 16-bit compilers (BC++ and VC++ 1.5) but this hasn't -been tested lately. +The following sections explain how to compile wxWindows with each supported +compiler. Visual C++ 4.0/5.0/6.0 compilation ---------------------------------- @@ -77,6 +90,9 @@ Note (1): if you wish to use templates, please edit include\wx\msw\setup.h and set wxUSE_DEBUG_NEW_ALWAYS to 0. Without this, the redefinition of 'new' will cause problems in the headers. Alternatively, #undef new before including template headers. +You will also need to set wxUSE_IOSTREAMH to 0 if you will be +using templates, to avoid the non-template stream files being included +within wxWindows. Note (2): libraries and applications generated with makefiles and project files are unlikely to be compatible, so use one method or @@ -232,6 +248,9 @@ Here are the steps required: - Mingw32 may not support winsock.h, so comment out socket-related files in src/msw/makefile.g95. +- Set your WXWIN variable to where wxWindows is installed. + For Cygwin/Mingw32, use forward slashes in the path, not backslashes. + - Use the makefile.g95 files for compiling wxWindows and samples, e.g.: > cd c:\wx\src\msw diff --git a/include/wx/date.h b/include/wx/date.h index 49936f064d..fae4f9ec50 100644 --- a/include/wx/date.h +++ b/include/wx/date.h @@ -21,6 +21,15 @@ #include "wx/string.h" #if wxUSE_TIMEDATE +// These lines necessary to stop VC++ 6 being confused about namespaces +class WXDLLEXPORT wxDate; +bool WXDLLEXPORT operator<(const wxDate &dt1, const wxDate &dt2); +bool WXDLLEXPORT operator<(const wxDate &dt1, const wxDate &dt2); +bool WXDLLEXPORT operator <= (const wxDate &dt1, const wxDate &dt2); +bool WXDLLEXPORT operator > (const wxDate &dt1, const wxDate &dt2); +bool WXDLLEXPORT operator >= (const wxDate &dt1, const wxDate &dt2); +bool WXDLLEXPORT operator == (const wxDate &dt1, const wxDate &dt2); +bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2); enum wxdate_format_type {wxMDY, wxDAY, wxMONTH, wxFULL, wxEUROPEAN}; diff --git a/include/wx/defs.h b/include/wx/defs.h index 25e148dd55..63f75b9e60 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -160,11 +160,8 @@ #elif defined(__WATCOMC__) // typedef unsigned int bool; - #if __WATCOMC__<1100 - typedef enum _tagbool { - false, - true - } bool ; + #if (__WATCOMC__ < 1100) + typedef unsigned int bool; #endif #elif defined(__SUNCC__) diff --git a/include/wx/motif/window.h b/include/wx/motif/window.h index 24c5ca9135..b8bd87a279 100644 --- a/include/wx/motif/window.h +++ b/include/wx/motif/window.h @@ -27,6 +27,7 @@ #include "wx/list.h" #include "wx/region.h" #include "wx/accel.h" +#include "wx/intl.h" #define wxKEY_SHIFT 1 #define wxKEY_CTRL 2 diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index 4e12fe21ae..52dfe26d6b 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -132,7 +132,7 @@ #ifndef __MWERKS__ #define wxUSE_IOSTREAMH 1 #else -#define wxUSE_IOSTREAMH 0 +#define wxUSE_IOSTREAMH 1 #endif // VC++ 4.2 and above allows and // but you can't mix them. Set to 1 for , diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 7d72620bd1..2efdb4dcd4 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -27,6 +27,7 @@ #include "wx/list.h" #include "wx/region.h" #include "wx/msw/accel.h" +#include "wx/intl.h" #define wxKEY_SHIFT 1 #define wxKEY_CTRL 2 @@ -621,9 +622,10 @@ public: virtual void MSWOnMouseEnter(int x, int y, WXUINT flags); virtual void MSWOnMouseLeave(int x, int y, WXUINT flags); - virtual void MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); - virtual void MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); - virtual void MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); + // These return TRUE if an event handler was found, FALSE otherwise (not processed) + virtual bool MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); + virtual bool MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); + virtual bool MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); virtual bool MSWOnActivate(int flag, bool minimized, WXHWND activate); virtual long MSWOnMDIActivate(long flag, WXHWND activate, WXHWND deactivate); diff --git a/include/wx/string.h b/include/wx/string.h index e997410380..593b80c603 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -70,7 +70,7 @@ const unsigned int wxSTRING_MAXLEN = UINT_MAX - 100; //--------------------------------------------------------------------------- // checks whether the passed in pointer is NULL and if the string is empty -inline bool WXDLLEXPORT IsEmpty(const char *p) { return !p || !*p; } +inline bool WXDLLEXPORT IsEmpty(const char *p) { return (!p || !*p); } // safe version of strlen() (returns 0 if passed NULL pointer) inline size_t WXDLLEXPORT Strlen(const char *psz) @@ -144,8 +144,8 @@ struct WXDLLEXPORT wxStringData char* data() const { return (char*)(this + 1); } // empty string has a special ref count so it's never deleted - bool IsEmpty() const { return nRefs == -1; } - bool IsShared() const { return nRefs > 1; } + bool IsEmpty() const { return (nRefs == -1); } + bool IsShared() const { return (nRefs > 1); } // lock/unlock void Lock() { if ( !IsEmpty() ) nRefs++; } @@ -153,8 +153,8 @@ struct WXDLLEXPORT wxStringData // if we had taken control over string memory (GetWriteBuf), it's // intentionally put in invalid state - void Validate(bool b) { nRefs = b ? 1 : 0; } - bool IsValid() const { return nRefs != 0; } + void Validate(bool b) { nRefs = (b ? 1 : 0); } + bool IsValid() const { return (nRefs != 0); } }; // --------------------------------------------------------------------------- diff --git a/include/wx/stubs/window.h b/include/wx/stubs/window.h index aae03f8a6f..b94c1afe41 100644 --- a/include/wx/stubs/window.h +++ b/include/wx/stubs/window.h @@ -27,6 +27,7 @@ #include "wx/list.h" #include "wx/region.h" #include "wx/accel.h" +#include "wx/intl.h" #define wxKEY_SHIFT 1 #define wxKEY_CTRL 2 diff --git a/include/wx/valgen.h b/include/wx/valgen.h index 88e9b88bb0..8a43952b60 100644 --- a/include/wx/valgen.h +++ b/include/wx/valgen.h @@ -38,7 +38,7 @@ public: // Called when the value in the window must be validated. // This function can pop up an error message. - virtual bool Validate(wxWindow *parent) {return true;} + virtual bool Validate(wxWindow *parent) {return TRUE;} // Called to transfer data to the window virtual bool TransferToWindow(void); diff --git a/samples/db/makefile.g95 b/samples/db/makefile.g95 new file mode 100644 index 0000000000..c5239232ba --- /dev/null +++ b/samples/db/makefile.g95 @@ -0,0 +1,16 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../.. + +TARGET=dbtest +OBJECTS = $(TARGET).o listdb.o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/samples/dnd/makefile.unx b/samples/dnd/makefile.unx new file mode 100644 index 0000000000..ffbb3975d5 --- /dev/null +++ b/samples/dnd/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for dnd example (UNIX). + +PROGRAM=dnd + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/forty/makefile.b32 b/samples/forty/makefile.b32 new file mode 100644 index 0000000000..5586d65abe --- /dev/null +++ b/samples/forty/makefile.b32 @@ -0,0 +1,16 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=forty +OBJECTS = $(TARGET).obj canvas.obj card.obj game.obj pile.obj playerdg.obj scoredg.obj scorefil.obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/samples/image/makefile.b32 b/samples/image/makefile.b32 new file mode 100644 index 0000000000..d98ac5a4da --- /dev/null +++ b/samples/image/makefile.b32 @@ -0,0 +1,16 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=image +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/samples/image/makefile.g95 b/samples/image/makefile.g95 new file mode 100644 index 0000000000..1587d6af5f --- /dev/null +++ b/samples/image/makefile.g95 @@ -0,0 +1,16 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../.. + +TARGET=image +OBJECTS = $(TARGET).o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/samples/mdi/makefile.sl b/samples/mdi/makefile.sl new file mode 100644 index 0000000000..0309cff0a8 --- /dev/null +++ b/samples/mdi/makefile.sl @@ -0,0 +1,18 @@ +# +# File: makefile.sl +# Author: Julian Smart +# Created: 1998 +# +# Makefile : Builds a wxWindows sample for Salford C++, WIN32 + +PROGRAM = mdi +OBJECTS = $(PROGRAM).obj + +include ..\..\src\makeprog.sl + +all: wx $(TARGET) + +wx: + cd $(WXDIR)\src\msw ^ mk32 -f makefile.sl all + cd $(WXDIR)\samples\mdi + diff --git a/samples/mfc/makefile.g95 b/samples/mfc/makefile.g95 new file mode 100644 index 0000000000..7da52292d8 --- /dev/null +++ b/samples/mfc/makefile.g95 @@ -0,0 +1,16 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../.. + +TARGET=mfctest +OBJECTS = $(TARGET).o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/samples/minimal/makefile.sc b/samples/minimal/makefile.sc new file mode 100644 index 0000000000..c55f65c7d7 --- /dev/null +++ b/samples/minimal/makefile.sc @@ -0,0 +1,36 @@ +# Symantec C++ makefile + +WXDIR = $(WXWIN) +WXLIB = $(WXDIR)\lib\wx.lib +INCDIR = $(WXDIR)\include +INCLUDE=$(INCDIR) +TARGET=minimal + +include $(WXDIR)\src\makesc.env + +minimal.exe: minimal.obj $(DEFFILE) minimal.res + *$(CC) $(LDFLAGS) -o$@ $** $(LIBS) + *$(RC) -k minimal.res + +sc32.def: + echo EXETYPE NT > sc32.def + echo SUBSYSTEM WINDOWS >> sc32.def + +sc16.def: + echo NAME $(TARGET) > sc16.def + echo EXETYPE WINDOWS >> sc16.def + echo STUB 'WINSTUB.EXE' >> sc16.def + echo CODE PRELOAD MOVEABLE DISCARDABLE >> sc16.def + echo DATA PRELOAD MOVEABLE MULTIPLE >> sc16.def + echo HEAPSIZE 1024 >> sc16.def + echo STACKSIZE 8192 >> sc16.def + +clean: + -del *.obj + -del *.exe + -del *.res + -del *.map + -del *.rws + -del sc32.def + -del sc16.def + diff --git a/samples/minimal/makefile.sl b/samples/minimal/makefile.sl new file mode 100644 index 0000000000..7dd9a0b6a6 --- /dev/null +++ b/samples/minimal/makefile.sl @@ -0,0 +1,18 @@ +# +# File: makefile.sl +# Author: Julian Smart +# Created: 1998 +# +# Makefile : Builds a wxWindows sample for Salford C++, WIN32 + +PROGRAM = minimal +OBJECTS = $(PROGRAM).obj + +include ..\..\src\makeprog.sl + +all: wx $(TARGET) + +wx: + cd $(WXDIR)\src\msw ^ mk32 -f makefile.sl all + cd $(WXDIR)\samples\minimal + diff --git a/samples/minimal/makefile.wat b/samples/minimal/makefile.wat new file mode 100644 index 0000000000..2b200ba7ec --- /dev/null +++ b/samples/minimal/makefile.wat @@ -0,0 +1,15 @@ +# +# Makefile for WATCOM +# +# Created by Julian Smart, January 1999 +# +# + +WXDIR = $(%WXWIN) + +PROGRAM = minimal +OBJECTS = $(PROGRAM).obj + +!include $(WXDIR)\src\makeprog.wat + + diff --git a/samples/png/makefile.b32 b/samples/png/makefile.b32 new file mode 100644 index 0000000000..cd1a01aa66 --- /dev/null +++ b/samples/png/makefile.b32 @@ -0,0 +1,16 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=pngdemo +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/samples/png/makefile.g95 b/samples/png/makefile.g95 new file mode 100644 index 0000000000..d183132ec8 --- /dev/null +++ b/samples/png/makefile.g95 @@ -0,0 +1,16 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../.. + +TARGET=pngdemo +OBJECTS = $(TARGET).o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/samples/regtest/makefile.b32 b/samples/regtest/makefile.b32 new file mode 100644 index 0000000000..f3ac07cbf8 --- /dev/null +++ b/samples/regtest/makefile.b32 @@ -0,0 +1,16 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=regtest +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/samples/splitter/makefile.dos b/samples/splitter/makefile.dos new file mode 100644 index 0000000000..13e3a4ce8e --- /dev/null +++ b/samples/splitter/makefile.dos @@ -0,0 +1,17 @@ +# +# File: makefile.dos +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Makefile : Builds 16-bit sample, VC++ 1.5 +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +WXDIR = $(WXWIN) + +TARGET=test +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.msc + diff --git a/samples/validate/makefile.unx b/samples/validate/makefile.unx new file mode 100644 index 0000000000..fd12e5ba03 --- /dev/null +++ b/samples/validate/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for validate example (UNIX). + +PROGRAM=validate + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/wxsocket/client.g95 b/samples/wxsocket/client.g95 new file mode 100644 index 0000000000..260c61cfd6 --- /dev/null +++ b/samples/wxsocket/client.g95 @@ -0,0 +1,16 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../.. + +TARGET=client +OBJECTS = $(TARGET).o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/samples/wxsocket/makefile.dos b/samples/wxsocket/makefile.dos new file mode 100644 index 0000000000..2a42833b60 --- /dev/null +++ b/samples/wxsocket/makefile.dos @@ -0,0 +1,19 @@ +# +# File: makefile.dos +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Makefile : Builds 16-bit sample, VC++ 1.5 +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +WXDIR = $(WXWIN) + +TARGET=client +OBJECTS = $(TARGET).obj + +# TODO: server + +!include $(WXDIR)\src\makeprog.msc + diff --git a/samples/wxsocket/server.g95 b/samples/wxsocket/server.g95 new file mode 100644 index 0000000000..48e622cc59 --- /dev/null +++ b/samples/wxsocket/server.g95 @@ -0,0 +1,16 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../.. + +TARGET=server +OBJECTS = $(TARGET).o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/src/common/image.cpp b/src/common/image.cpp index 1f0cc7de58..0b4956dad2 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -51,17 +51,17 @@ extern "C" { class wxImageRefData: public wxObjectRefData { - + public: - wxImageRefData(void); - ~wxImageRefData(void); - - int m_width; - int m_height; - unsigned char *m_data; - bool m_hasMask; - unsigned char m_maskRed,m_maskGreen,m_maskBlue; - bool m_ok; + wxImageRefData(void); + ~wxImageRefData(void); + + int m_width; + int m_height; + unsigned char *m_data; + bool m_hasMask; + unsigned char m_maskRed,m_maskGreen,m_maskBlue; + bool m_ok; }; wxImageRefData::wxImageRefData(void) @@ -125,12 +125,12 @@ wxImage::wxImage( const wxImage* image ) void wxImage::Create( int width, int height ) { m_refData = new wxImageRefData(); - + M_IMGDATA->m_data = (unsigned char *) malloc( width*height*3 ); if (M_IMGDATA->m_data) { for (int l = 0; l < width*height*3; l++) M_IMGDATA->m_data[l] = 0; - + M_IMGDATA->m_width = width; M_IMGDATA->m_height = height; M_IMGDATA->m_ok = TRUE; @@ -149,53 +149,53 @@ void wxImage::Destroy() wxImage wxImage::Scale( int width, int height ) { wxImage image; - + wxCHECK_MSG( Ok(), image, "invlaid image" ); - + wxCHECK_MSG( (width > 0) && (height > 0), image, "invalid image size" ); - + image.Create( width, height ); - + char unsigned *data = image.GetData(); - + wxCHECK_MSG( data, image, "unable to create image" ); - + if (M_IMGDATA->m_hasMask) image.SetMaskColour( M_IMGDATA->m_maskRed, M_IMGDATA->m_maskGreen, M_IMGDATA->m_maskBlue ); - + long old_height = M_IMGDATA->m_height; long old_width = M_IMGDATA->m_width; - + char unsigned *source_data = M_IMGDATA->m_data; char unsigned *target_data = data; - + for (long j = 0; j < height; j++) { long y_offset = (j * old_height / height) * old_width; - + for (long i = 0; i < width; i++) { - memcpy( target_data, - source_data + 3*(y_offset + ((i * old_width )/ width)), - 3 ); + memcpy( target_data, + source_data + 3*(y_offset + ((i * old_width )/ width)), + 3 ); target_data += 3; } } - + return image; } void wxImage::SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b ) { wxCHECK_RET( Ok(), "invalid image" ); - + int w = M_IMGDATA->m_width; int h = M_IMGDATA->m_height; - + wxCHECK_RET( (x>=0) && (y>=0) && (xm_data[ pos ] = r; M_IMGDATA->m_data[ pos+1 ] = g; M_IMGDATA->m_data[ pos+2 ] = b; @@ -204,42 +204,42 @@ void wxImage::SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned c unsigned char wxImage::GetRed( int x, int y ) { wxCHECK_MSG( Ok(), 0, "invalid image" ); - + int w = M_IMGDATA->m_width; int h = M_IMGDATA->m_height; - + wxCHECK_MSG( (x>=0) && (y>=0) && (xm_data[pos]; } unsigned char wxImage::GetGreen( int x, int y ) { wxCHECK_MSG( Ok(), 0, "invalid image" ); - + int w = M_IMGDATA->m_width; int h = M_IMGDATA->m_height; - + wxCHECK_MSG( (x>=0) && (y>=0) && (xm_data[pos+1]; } unsigned char wxImage::GetBlue( int x, int y ) { wxCHECK_MSG( Ok(), 0, "invalid image" ); - + int w = M_IMGDATA->m_width; int h = M_IMGDATA->m_height; - + wxCHECK_MSG( (x>=0) && (y>=0) && (xm_data[pos+2]; } @@ -251,7 +251,7 @@ bool wxImage::Ok() const char unsigned *wxImage::GetData() const { wxCHECK_MSG( Ok(), (char unsigned *)NULL, "invalid image" ); - + return M_IMGDATA->m_data; } @@ -263,7 +263,7 @@ void wxImage::SetData( char unsigned *WXUNUSED(data) ) void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b ) { wxCHECK_RET( Ok(), "invalid image" ); - + M_IMGDATA->m_maskRed = r; M_IMGDATA->m_maskGreen = g; M_IMGDATA->m_maskBlue = b; @@ -273,49 +273,49 @@ void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b ) unsigned char wxImage::GetMaskRed() const { wxCHECK_MSG( Ok(), 0, "invalid image" ); - + return M_IMGDATA->m_maskRed; } unsigned char wxImage::GetMaskGreen() const { wxCHECK_MSG( Ok(), 0, "invalid image" ); - + return M_IMGDATA->m_maskGreen; } unsigned char wxImage::GetMaskBlue() const { wxCHECK_MSG( Ok(), 0, "invalid image" ); - + return M_IMGDATA->m_maskBlue; } void wxImage::SetMask( bool mask ) { wxCHECK_RET( Ok(), "invalid image" ); - + M_IMGDATA->m_hasMask = mask; } bool wxImage::HasMask() const { wxCHECK_MSG( Ok(), FALSE, "invalid image" ); - + return M_IMGDATA->m_hasMask; } int wxImage::GetWidth() const { wxCHECK_MSG( Ok(), 0, "invalid image" ); - + return M_IMGDATA->m_width; } int wxImage::GetHeight() const { wxCHECK_MSG( Ok(), 0, "invalid image" ); - + return M_IMGDATA->m_height; } @@ -327,14 +327,14 @@ bool wxImage::LoadFile( const wxString& filename, long type ) wxFileInputStream stream(filename); return LoadFile(stream, type); } - + else { wxLogError( "Can't load image from file '%s': file does not exist.", filename.c_str() ); - + return FALSE; } #else // !wxUSE_STREAMS - return FALSE; + return FALSE; #endif // wxUSE_STREAMS } @@ -342,7 +342,7 @@ bool wxImage::SaveFile( const wxString& filename, int type ) { #if wxUSE_STREAMS wxFileOutputStream stream(filename); - + if ( stream.LastError() == wxStream_NOERROR ) return SaveFile(stream, type); else @@ -354,34 +354,34 @@ bool wxImage::SaveFile( const wxString& filename, int type ) bool wxImage::LoadFile( wxInputStream& stream, long type ) { UnRef(); - + m_refData = new wxImageRefData; - + wxImageHandler *handler = FindHandler(type); - + if (handler == NULL) { wxLogWarning( "No image handler for type %d defined.", type ); - + return FALSE; } - + return handler->LoadFile( this, stream ); } bool wxImage::SaveFile( wxOutputStream& stream, int type ) { wxCHECK_MSG( Ok(), FALSE, "invalid image" ); - + wxImageHandler *handler = FindHandler(type); - + if (handler == NULL) { - wxLogWarning( "No image handler for type %d defined.", type ); - - return FALSE; + wxLogWarning( "No image handler for type %d defined.", type ); + + return FALSE; } - + return handler->SaveFile( this, stream ); } #endif // wxUSE_STREAMS @@ -390,7 +390,7 @@ void wxImage::AddHandler( wxImageHandler *handler ) { // make sure that the memory will be freed at the program end sm_handlers.DeleteContents(TRUE); - + sm_handlers.Append( handler ); } @@ -398,7 +398,7 @@ void wxImage::InsertHandler( wxImageHandler *handler ) { // make sure that the memory will be freed at the program end sm_handlers.DeleteContents(TRUE); - + sm_handlers.Insert( handler ); } @@ -421,7 +421,7 @@ wxImageHandler *wxImage::FindHandler( const wxString& name ) { wxImageHandler *handler = (wxImageHandler*)node->Data(); if (handler->GetName().Cmp(name) == 0) return handler; - + node = node->Next(); } return (wxImageHandler *)NULL; @@ -435,7 +435,7 @@ wxImageHandler *wxImage::FindHandler( const wxString& extension, long bitmapType wxImageHandler *handler = (wxImageHandler*)node->Data(); if ( (handler->GetExtension().Cmp(extension) == 0) && (bitmapType == -1 || handler->GetType() == bitmapType) ) - return handler; + return handler; node = node->Next(); } return (wxImageHandler*)NULL; @@ -508,12 +508,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNGHandler,wxImageHandler) #if wxUSE_STREAMS 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); + ((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 ) { - ((wxOutputStream*) png_get_io_ptr( png_ptr )) -> Write(data, length); + ((wxOutputStream*) png_get_io_ptr( png_ptr )) -> Write(data, length); } bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream ) @@ -526,50 +526,50 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream ) 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 ); + (voidp) NULL, + (png_error_ptr) NULL, + (png_error_ptr) NULL ); if (!png_ptr) goto error; - + info_ptr = png_create_info_struct( png_ptr ); if (!info_ptr) goto error; - + if (setjmp(png_ptr->jmpbuf)) goto error; - + if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) goto error; - + 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; - + lines = (unsigned char **)malloc( height * sizeof(unsigned char *) ); if (lines == NULL) goto error; - + for (i = 0; i < height; i++) { if ((lines[i] = (unsigned char *)malloc(width * (sizeof(unsigned char) * 4))) == NULL) @@ -579,7 +579,7 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream ) goto error; } } - + // loaded successfully! { int transp = 0; @@ -640,11 +640,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 ); @@ -654,22 +654,22 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream ) image->SetMask( FALSE ); } } - + return TRUE; - + 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 ) @@ -686,83 +686,83 @@ error: bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream ) { - { - png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_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; - sig_bit.blue = 8; - sig_bit.alpha = 8; - png_set_sBIT( png_ptr, info_ptr, &sig_bit ); - 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); - for (int x = 0; x < image->GetWidth(); x++) + png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png_ptr) { - data[(x << 2) + 0] = *ptr++; - data[(x << 2) + 1] = *ptr++; - data[(x << 2) + 2] = *ptr++; - if ((data[(x << 2) + 0] == image->GetMaskRed()) && - (data[(x << 2) + 1] == image->GetMaskGreen()) && - (data[(x << 2) + 2] == image->GetMaskBlue())) - { - data[(x << 2) + 3] = 0; - } - else + 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; + sig_bit.blue = 8; + sig_bit.alpha = 8; + png_set_sBIT( png_ptr, info_ptr, &sig_bit ); + 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); + for (int x = 0; x < image->GetWidth(); x++) { - data[(x << 2) + 3] = 255; + data[(x << 2) + 0] = *ptr++; + data[(x << 2) + 1] = *ptr++; + data[(x << 2) + 2] = *ptr++; + if ((data[(x << 2) + 0] == image->GetMaskRed()) && + (data[(x << 2) + 1] == image->GetMaskGreen()) && + (data[(x << 2) + 2] == image->GetMaskBlue())) + { + data[(x << 2) + 3] = 0; + } + else + { + data[(x << 2) + 3] = 255; + } } + 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 ); - } - return TRUE; + return TRUE; } #endif // wxUSE_STREAMS #endif - // wxUSE_LIBPNG +// wxUSE_LIBPNG //----------------------------------------------------------------------------- @@ -781,9 +781,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxJPEGHandler,wxImageHandler) //------------- JPEG Data Source Manager typedef struct { - struct jpeg_source_mgr pub; /* public fields */ - - JOCTET* buffer; /* start of buffer */ + struct jpeg_source_mgr pub; /* public fields */ + + JOCTET* buffer; /* start of buffer */ } my_source_mgr; typedef my_source_mgr * my_src_ptr; @@ -794,45 +794,45 @@ METHODDEF(void) my_init_source ( j_decompress_ptr cinfo ) METHODDEF(boolean) my_fill_input_buffer ( j_decompress_ptr cinfo ) { - return TRUE; + return TRUE; } METHODDEF(void) my_skip_input_data ( j_decompress_ptr cinfo, long num_bytes ) { - my_src_ptr src = (my_src_ptr) cinfo->src; - - src->pub.next_input_byte += (size_t) num_bytes; - src->pub.bytes_in_buffer -= (size_t) num_bytes; + my_src_ptr src = (my_src_ptr) cinfo->src; + + src->pub.next_input_byte += (size_t) num_bytes; + src->pub.bytes_in_buffer -= (size_t) num_bytes; } METHODDEF(void) my_term_source ( j_decompress_ptr cinfo ) { - my_src_ptr src = (my_src_ptr) cinfo->src; - - free (src->buffer); + my_src_ptr src = (my_src_ptr) cinfo->src; + + free (src->buffer); } void jpeg_wxio_src( j_decompress_ptr cinfo, wxInputStream& infile ) { - my_src_ptr src; - - if (cinfo->src == NULL) { /* first time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - sizeof(my_source_mgr)); + my_src_ptr src; + + if (cinfo->src == NULL) { /* first time for this JPEG object? */ + cinfo->src = (struct jpeg_source_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + sizeof(my_source_mgr)); + src = (my_src_ptr) cinfo->src; + } src = (my_src_ptr) cinfo->src; - } - src = (my_src_ptr) cinfo->src; - src->pub.bytes_in_buffer = infile.StreamSize(); /* forces fill_input_buffer on first read */ - src->buffer = (JOCTET *) malloc (infile.StreamSize()); - src->pub.next_input_byte = src->buffer; /* until buffer loaded */ - infile.Read(src->buffer, infile.StreamSize()); - - src->pub.init_source = my_init_source; - src->pub.fill_input_buffer = my_fill_input_buffer; - src->pub.skip_input_data = my_skip_input_data; - src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->pub.term_source = my_term_source; + src->pub.bytes_in_buffer = infile.StreamSize(); /* forces fill_input_buffer on first read */ + src->buffer = (JOCTET *) malloc (infile.StreamSize()); + src->pub.next_input_byte = src->buffer; /* until buffer loaded */ + infile.Read(src->buffer, infile.StreamSize()); + + src->pub.init_source = my_init_source; + src->pub.fill_input_buffer = my_fill_input_buffer; + src->pub.skip_input_data = my_skip_input_data; + src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ + src->pub.term_source = my_term_source; } @@ -844,7 +844,7 @@ bool wxJPEGHandler::LoadFile( wxImage *image, wxInputStream& stream ) JSAMPARRAY tempbuf; unsigned char *ptr; unsigned stride; - + image->Destroy(); cinfo.err = jpeg_std_error( &jerr ); jpeg_create_decompress( &cinfo ); @@ -852,23 +852,23 @@ bool wxJPEGHandler::LoadFile( wxImage *image, wxInputStream& stream ) jpeg_read_header( &cinfo, TRUE ); cinfo.out_color_space = JCS_RGB; jpeg_start_decompress( &cinfo ); - + image->Create( cinfo.image_width, cinfo.image_height ); if (!image->Ok()) { - jpeg_finish_decompress( &cinfo ); - jpeg_destroy_decompress( &cinfo ); - return FALSE; + jpeg_finish_decompress( &cinfo ); + jpeg_destroy_decompress( &cinfo ); + return FALSE; } image->SetMask( FALSE ); ptr = image->GetData(); stride = cinfo.output_width * 3; tempbuf = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, stride, 1 ); - + ((j_common_ptr) &cinfo, JPOOL_IMAGE, stride, 1 ); + while ( cinfo.output_scanline < cinfo.output_height ) { - jpeg_read_scanlines( &cinfo, tempbuf, 1 ); - memcpy( ptr, tempbuf[0], stride ); - ptr += stride; + jpeg_read_scanlines( &cinfo, tempbuf, 1 ); + memcpy( ptr, tempbuf[0], stride ); + ptr += stride; } jpeg_finish_decompress( &cinfo ); jpeg_destroy_decompress( &cinfo ); @@ -880,10 +880,10 @@ bool wxJPEGHandler::LoadFile( wxImage *image, wxInputStream& stream ) typedef struct { - struct jpeg_destination_mgr pub; - - wxOutputStream *stream; - JOCTET * buffer; + struct jpeg_destination_mgr pub; + + wxOutputStream *stream; + JOCTET * buffer; } my_destination_mgr; typedef my_destination_mgr * my_dest_ptr; @@ -892,89 +892,89 @@ typedef my_destination_mgr * my_dest_ptr; METHODDEF(void) init_destination (j_compress_ptr cinfo) { - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - /* Allocate the output buffer --- it will be released when done with image */ - dest->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - OUTPUT_BUF_SIZE * sizeof(JOCTET)); - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + /* Allocate the output buffer --- it will be released when done with image */ + dest->buffer = (JOCTET *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + OUTPUT_BUF_SIZE * sizeof(JOCTET)); + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; } METHODDEF(boolean) empty_output_buffer (j_compress_ptr cinfo) { - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - dest->stream->Write(dest->buffer, OUTPUT_BUF_SIZE); - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; - return TRUE; + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + dest->stream->Write(dest->buffer, OUTPUT_BUF_SIZE); + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; + return TRUE; } METHODDEF(void) term_destination (j_compress_ptr cinfo) { - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; - /* Write any data remaining in the buffer */ - if (datacount > 0) - dest->stream->Write(dest->buffer, datacount); + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; + /* Write any data remaining in the buffer */ + if (datacount > 0) + dest->stream->Write(dest->buffer, datacount); } GLOBAL(void) jpeg_wxio_dest (j_compress_ptr cinfo, wxOutputStream& outfile) { - my_dest_ptr dest; - - if (cinfo->dest == NULL) { /* first time for this JPEG object? */ - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - sizeof(my_destination_mgr)); - } - - dest = (my_dest_ptr) cinfo->dest; - dest->pub.init_destination = init_destination; - dest->pub.empty_output_buffer = empty_output_buffer; - dest->pub.term_destination = term_destination; - dest->stream = &outfile; + my_dest_ptr dest; + + if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + cinfo->dest = (struct jpeg_destination_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + sizeof(my_destination_mgr)); + } + + dest = (my_dest_ptr) cinfo->dest; + dest->pub.init_destination = init_destination; + dest->pub.empty_output_buffer = empty_output_buffer; + dest->pub.term_destination = term_destination; + dest->stream = &outfile; } bool wxJPEGHandler::SaveFile( wxImage *image, wxOutputStream& stream ) { - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - JSAMPLE *image_buffer; - int stride; /* physical row width in image buffer */ - - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - jpeg_wxio_dest(&cinfo, stream); - - cinfo.image_width = image->GetWidth(); - cinfo.image_height = image->GetHeight(); - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - jpeg_set_defaults(&cinfo); - jpeg_start_compress(&cinfo, TRUE); - - stride = cinfo.image_width * 3; /* JSAMPLEs per row in image_buffer */ - image_buffer = image->GetData(); - while (cinfo.next_scanline < cinfo.image_height) { - row_pointer[0] = &image_buffer[cinfo.next_scanline * stride]; - jpeg_write_scanlines( &cinfo, row_pointer, 1 ); - } - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - - return TRUE; + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ + JSAMPLE *image_buffer; + int stride; /* physical row width in image buffer */ + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + jpeg_wxio_dest(&cinfo, stream); + + cinfo.image_width = image->GetWidth(); + cinfo.image_height = image->GetHeight(); + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + jpeg_set_defaults(&cinfo); + jpeg_start_compress(&cinfo, TRUE); + + stride = cinfo.image_width * 3; /* JSAMPLEs per row in image_buffer */ + image_buffer = image->GetData(); + while (cinfo.next_scanline < cinfo.image_height) { + row_pointer[0] = &image_buffer[cinfo.next_scanline * stride]; + jpeg_write_scanlines( &cinfo, row_pointer, 1 ); + } + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); + + return TRUE; } #endif // wxUSE_STREAMS #endif - // wxUSE_LIBJPEG +// wxUSE_LIBJPEG @@ -989,352 +989,352 @@ IMPLEMENT_DYNAMIC_CLASS(wxBMPHandler,wxImageHandler) #if wxUSE_STREAMS bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) { - unsigned char *data, *ptr; - int done, i, bpp, planes, comp, ncolors, line, column, - linesize, linepos, rshift = 0, gshift = 0, bshift = 0; - unsigned char aByte; - 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 - { + unsigned char *data, *ptr; + int done, i, bpp, planes, comp, ncolors, line, column, + linesize, linepos, rshift = 0, gshift = 0, bshift = 0; + unsigned char aByte; + 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 + { unsigned char r, g, b; - } - *cmap = NULL; + } + *cmap = NULL; #ifndef BI_RGB #define BI_RGB 0 #define BI_RLE8 1 #define BI_RLE4 2 #endif - + #ifndef BI_BITFIELDS #define BI_BITFIELDS 3 #endif - - image->Destroy(); - - done = 0; - /* + + image->Destroy(); + + done = 0; + /* * Reading the bmp header */ - - stream.Read(&bbuf, 2); - - stream.Read(dbuf, 4 * 4); - - size = dbuf[0]; - offset = dbuf[2]; - - stream.Read(dbuf, 4 * 2); - int width = (int)dbuf[0]; - int height = (int)dbuf[1]; - if (width > 32767) - { + + stream.Read(&bbuf, 2); + + stream.Read(dbuf, 4 * 4); + + size = dbuf[0]; + offset = dbuf[2]; + + 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" ); return FALSE; - } - if (height > 32767) - { + } + if (height > 32767) + { wxLogError( "Image height > 32767 pixels for file\n" ); return FALSE; - } - stream.Read(&word, 2); - planes = (int)word; - stream.Read(&word, 2); - bpp = (int)word; - if (bpp != 1 && bpp != 4 && bpp != 8 && bpp && 16 && bpp != 24 && bpp != 32) - { + } + stream.Read(&word, 2); + planes = (int)word; + 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" ); return FALSE; - } - stream.Read(dbuf, 4 * 4); - comp = (int)dbuf[0]; - if (comp != BI_RGB && comp != BI_RLE4 && comp != BI_RLE8 && comp != BI_BITFIELDS) - { + } + 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" ); return FALSE; - } - stream.Read(dbuf, 4 * 2); - ncolors = (int)dbuf[0]; - if (ncolors == 0) - ncolors = 1 << bpp; - /* some more sanity checks */ - if (((comp == BI_RLE4) && (bpp != 4)) || ((comp == BI_RLE8) && (bpp != 8)) || ((comp == BI_BITFIELDS) && (bpp != 16 && bpp != 32))) - { + } + stream.Read(dbuf, 4 * 2); + ncolors = (int)dbuf[0]; + if (ncolors == 0) + ncolors = 1 << bpp; + /* some more sanity checks */ + 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" ); return FALSE; - } - if (bpp < 16) - { + } + if (bpp < 16) + { cmap = (struct _cmap *)malloc(sizeof(struct _cmap) * ncolors); - + if (!cmap) - { - wxLogError( "Cannot allocate RAM for color map in BMP file\n" ); - return FALSE; - } - } - else - cmap = NULL; - - image->Create( width, height ); - ptr = image->GetData(); - if (!ptr) - { + { + wxLogError( "Cannot allocate RAM for color map in BMP file\n" ); + return FALSE; + } + } + else + cmap = NULL; + + image->Create( width, height ); + ptr = image->GetData(); + if (!ptr) + { wxLogError( "Cannot allocate RAM for RGB data in file\n" ); if (cmap) - free(cmap); + free(cmap); return FALSE; - } - - /* + } + + /* * Reading the palette, if it exists. */ - if (bpp < 16 && ncolors != 0) - { + if (bpp < 16 && ncolors != 0) + { for (i = 0; i < ncolors; i++) - { - stream.Read(bbuf, 4); - cmap[i].b = bbuf[0]; - cmap[i].g = bbuf[1]; - cmap[i].r = bbuf[2]; - } - } - else if (bpp == 16 || bpp == 32) - { + { + stream.Read(bbuf, 4); + cmap[i].b = bbuf[0]; + cmap[i].g = bbuf[1]; + cmap[i].r = bbuf[2]; + } + } + else if (bpp == 16 || bpp == 32) + { if (comp == BI_BITFIELDS) - { - int bit = 0; - - stream.Read(dbuf, 4 * 3); - bmask = dbuf[0]; - gmask = dbuf[1]; - rmask = dbuf[2]; - /* find shift amount.. ugly, but i can't think of a better way */ - for (bit = 0; bit < bpp; bit++) - { - if (bmask & (1 << bit)) - bshift = bit; - if (gmask & (1 << bit)) - gshift = bit; - if (rmask & (1 << bit)) - rshift = bit; - } - } + { + int bit = 0; + + stream.Read(dbuf, 4 * 3); + bmask = dbuf[0]; + gmask = dbuf[1]; + rmask = dbuf[2]; + /* find shift amount.. ugly, but i can't think of a better way */ + for (bit = 0; bit < bpp; bit++) + { + if (bmask & (1 << bit)) + bshift = bit; + if (gmask & (1 << bit)) + gshift = bit; + if (rmask & (1 << bit)) + rshift = bit; + } + } else if (bpp == 16) - { - rmask = 0x7C00; - gmask = 0x03E0; - bmask = 0x001F; - rshift = 10; - gshift = 5; - bshift = 0; - } + { + rmask = 0x7C00; + gmask = 0x03E0; + bmask = 0x001F; + rshift = 10; + gshift = 5; + bshift = 0; + } else if (bpp == 32) - { - rmask = 0x00FF0000; - gmask = 0x0000FF00; - bmask = 0x000000FF; - rshift = 16; - gshift = 8; - bshift = 0; - } - } - - /* + { + rmask = 0x00FF0000; + gmask = 0x0000FF00; + bmask = 0x000000FF; + rshift = 16; + gshift = 8; + bshift = 0; + } + } + + /* * Reading the image data */ - stream.SeekI(start_offset + offset); - data = ptr; - - /* set the whole image to the background color */ - if (bpp < 16 && (comp == BI_RLE4 || comp == BI_RLE8)) - { + stream.SeekI(start_offset + offset); + data = ptr; + + /* set the whole image to the background color */ + if (bpp < 16 && (comp == BI_RLE4 || comp == BI_RLE8)) + { for (i = 0; i < width * height; i++) - { - *ptr++ = cmap[0].r; - *ptr++ = cmap[0].g; - *ptr++ = cmap[0].b; - } + { + *ptr++ = cmap[0].r; + *ptr++ = cmap[0].g; + *ptr++ = cmap[0].b; + } ptr = data; - } - line = 0; - column = 0; + } + line = 0; + column = 0; #define poffset (line * width * 3 + column * 3) - - /* + + /* * BMPs are stored upside down... hmmmmmmmmmm.... */ - - linesize = ((width * bpp + 31) / 32) * 4; - for (line = (height - 1); line >= 0; line--) - { + + linesize = ((width * bpp + 31) / 32) * 4; + for (line = (height - 1); line >= 0; line--) + { linepos = 0; for (column = 0; column < width;) - { - if (bpp < 16) - { - int index; - - linepos++; - aByte = stream.GetC(); - if (bpp == 1) + { + if (bpp < 16) + { + int index; + + linepos++; + aByte = stream.GetC(); + if (bpp == 1) + { + int bit = 0; + + for (bit = 0; bit < 8; bit++) { - int bit = 0; - - for (bit = 0; bit < 8; bit++) - { - index = ((aByte & (0x80 >> bit)) ? 1 : 0); + index = ((aByte & (0x80 >> bit)) ? 1 : 0); + ptr[poffset] = cmap[index].r; + ptr[poffset + 1] = cmap[index].g; + ptr[poffset + 2] = cmap[index].b; + column++; + } + } + else if (bpp == 4) + { + if (comp == BI_RLE4) + { + wxLogError( "can't deal with 4bit encoded yet.\n"); + image->Destroy(); + free(cmap); + return FALSE; + } + else + { + int nibble = 0; + + for (nibble = 0; nibble < 2; nibble++) + { + index = ((aByte & (0xF0 >> nibble * 4)) >> (!nibble * 4)); + if (index >= 16) + index = 15; ptr[poffset] = cmap[index].r; ptr[poffset + 1] = cmap[index].g; ptr[poffset + 2] = cmap[index].b; column++; - } + } } - else if (bpp == 4) + } + else if (bpp == 8) + { + if (comp == BI_RLE8) { - if (comp == BI_RLE4) - { - wxLogError( "can't deal with 4bit encoded yet.\n"); - image->Destroy(); - free(cmap); - return FALSE; - } - else - { - int nibble = 0; - - for (nibble = 0; nibble < 2; nibble++) - { - index = ((aByte & (0xF0 >> nibble * 4)) >> (!nibble * 4)); - if (index >= 16) - index = 15; - ptr[poffset] = cmap[index].r; - ptr[poffset + 1] = cmap[index].g; - ptr[poffset + 2] = cmap[index].b; - column++; - } - } + unsigned char first; + + first = aByte; + aByte = stream.GetC(); + if (first == 0) + { + if (aByte == 0) + { + /* column = width; */ + } + else if (aByte == 1) + { + column = width; + line = -1; + } + else if (aByte == 2) + { + aByte = stream.GetC(); + column += aByte; + linepos = column * bpp / 8; + aByte = stream.GetC(); + line += aByte; + } + else + { + int absolute = aByte; + + for (i = 0; i < absolute; i++) + { + linepos++; + 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 = stream.GetC(); + } + } + else + { + for (i = 0; i < first; i++) + { + ptr[poffset] = cmap[aByte].r; + ptr[poffset + 1] = cmap[aByte].g; + ptr[poffset + 2] = cmap[aByte].b; + column++; + linepos++; + } + } } - else if (bpp == 8) + else { - if (comp == BI_RLE8) - { - unsigned char first; - - first = aByte; - aByte = stream.GetC(); - if (first == 0) - { - if (aByte == 0) - { -/* column = width; */ - } - else if (aByte == 1) - { - column = width; - line = -1; - } - else if (aByte == 2) - { - aByte = stream.GetC(); - column += aByte; - linepos = column * bpp / 8; - aByte = stream.GetC(); - line += aByte; - } - else - { - int absolute = aByte; - - for (i = 0; i < absolute; i++) - { - linepos++; - 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 = stream.GetC(); - } - } - else - { - for (i = 0; i < first; i++) - { - ptr[poffset] = cmap[aByte].r; - ptr[poffset + 1] = cmap[aByte].g; - ptr[poffset + 2] = cmap[aByte].b; - column++; - linepos++; - } - } - } - else - { - ptr[poffset] = cmap[aByte].r; - ptr[poffset + 1] = cmap[aByte].g; - ptr[poffset + 2] = cmap[aByte].b; - column++; - linepos += size; - } + ptr[poffset] = cmap[aByte].r; + ptr[poffset + 1] = cmap[aByte].g; + ptr[poffset + 2] = cmap[aByte].b; + column++; + linepos += size; } + } } - else if (bpp == 24) + else if (bpp == 24) { - 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]; - column++; + 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]; + column++; } - else if (bpp == 16) + else if (bpp == 16) { - unsigned char temp; - - stream.Read(&word, 2); - linepos += 2; - temp = (word & rmask) >> rshift; - ptr[poffset] = temp; - temp = (word & gmask) >> gshift; - ptr[poffset + 1] = temp; - temp = (word & bmask) >> gshift; - ptr[poffset + 2] = temp; - column++; + unsigned char temp; + + stream.Read(&word, 2); + linepos += 2; + temp = (word & rmask) >> rshift; + ptr[poffset] = temp; + temp = (word & gmask) >> gshift; + ptr[poffset + 1] = temp; + temp = (word & bmask) >> gshift; + ptr[poffset + 2] = temp; + column++; } - else + else { - unsigned char temp; - - stream.Read(&dword, 4); - linepos += 4; - temp = (dword & rmask) >> rshift; - ptr[poffset] = temp; - temp = (dword & gmask) >> gshift; - ptr[poffset + 1] = temp; - temp = (dword & bmask) >> bshift; - ptr[poffset + 2] = temp; - column++; + unsigned char temp; + + stream.Read(&dword, 4); + linepos += 4; + temp = (dword & rmask) >> rshift; + ptr[poffset] = temp; + temp = (dword & gmask) >> gshift; + ptr[poffset + 1] = temp; + temp = (dword & bmask) >> bshift; + ptr[poffset + 2] = temp; + column++; } } - while ((linepos < linesize) && (comp != 1) && (comp != 2)) + while ((linepos < linesize) && (comp != 1) && (comp != 2)) { - stream.Read(&aByte, 1); - linepos += 1; - if (stream.LastError() != wxStream_NOERROR) - break; + stream.Read(&aByte, 1); + linepos += 1; + if (stream.LastError() != wxStream_NOERROR) + break; } } - if (cmap) free(cmap); - - image->SetMask( FALSE ); - - return TRUE; + if (cmap) free(cmap); + + image->SetMask( FALSE ); + + return TRUE; } #endif // wxUSE_STREAMS @@ -1342,14 +1342,14 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) wxBitmap wxImage::ConvertToBitmap() const { -// sizeLimit is the MS upper limit for the DIB size + // sizeLimit is the MS upper limit for the DIB size int sizeLimit = 1024*768*3; - -// width and height of the device-dependent bitmap + + // width and height of the device-dependent bitmap int width = GetWidth(); int bmpHeight = GetHeight(); - -// calc the number of bytes per scanline and padding + + // calc the number of bytes per scanline and padding int bytePerLine = width*3; int sizeDWORD = sizeof( DWORD ); div_t lineBoundary = div( bytePerLine, sizeDWORD ); @@ -1359,7 +1359,7 @@ wxBitmap wxImage::ConvertToBitmap() const padding = sizeDWORD - lineBoundary.rem; bytePerLine += padding; } -// calc the number of DIBs and heights of DIBs + // calc the number of DIBs and heights of DIBs int numDIB = 1; int hRemain = 0; int height = sizeLimit/bytePerLine; @@ -1369,37 +1369,37 @@ wxBitmap wxImage::ConvertToBitmap() const { div_t result = div( bmpHeight, height ); numDIB = result.quot; - hRemain = result.rem; - if( hRemain >0 ) numDIB++; + hRemain = result.rem; + if( hRemain >0 ) numDIB++; } - -// set bitmap parameters + + // set bitmap parameters wxBitmap bitmap; wxCHECK_MSG( Ok(), bitmap, "invalid image" ); bitmap.SetWidth( width ); bitmap.SetHeight( bmpHeight ); bitmap.SetDepth( wxDisplayDepth() ); - -// create a DIB header + + // create a DIB header int headersize = sizeof(BITMAPINFOHEADER); LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize ); wxCHECK_MSG( lpDIBh, bitmap, "could not allocate memory for DIB header" ); -// Fill in the DIB header + // Fill in the DIB header lpDIBh->bmiHeader.biSize = headersize; lpDIBh->bmiHeader.biWidth = (DWORD)width; lpDIBh->bmiHeader.biHeight = (DWORD)(-height); lpDIBh->bmiHeader.biSizeImage = bytePerLine*height; -// the general formula for biSizeImage: -// ( ( ( ((DWORD)width*24) +31 ) & ~31 ) >> 3 ) * height; + // the general formula for biSizeImage: + // ( ( ( ((DWORD)width*24) +31 ) & ~31 ) >> 3 ) * height; lpDIBh->bmiHeader.biPlanes = 1; lpDIBh->bmiHeader.biBitCount = 24; lpDIBh->bmiHeader.biCompression = BI_RGB; lpDIBh->bmiHeader.biClrUsed = 0; -// These seem not really needed for our purpose here. + // These seem not really needed for our purpose here. lpDIBh->bmiHeader.biClrImportant = 0; lpDIBh->bmiHeader.biXPelsPerMeter = 0; lpDIBh->bmiHeader.biYPelsPerMeter = 0; -// memory for DIB data + // memory for DIB data unsigned char *lpBits; lpBits = (unsigned char *)malloc( lpDIBh->bmiHeader.biSizeImage ); if( !lpBits ) @@ -1408,33 +1408,33 @@ wxBitmap wxImage::ConvertToBitmap() const free( lpDIBh ); return bitmap; } - -// create and set the device-dependent bitmap + + // create and set the device-dependent bitmap HDC hdc = ::GetDC(NULL); HDC memdc = ::CreateCompatibleDC( hdc ); HBITMAP hbitmap; hbitmap = ::CreateCompatibleBitmap( hdc, width, bmpHeight ); ::SelectObject( memdc, hbitmap); - -// copy image data into DIB data and then into DDB (in a loop) + + // copy image data into DIB data and then into DDB (in a loop) unsigned char *data = GetData(); int i, j, n; int origin = 0; unsigned char *ptdata = data; unsigned char *ptbits; - + for( n=0; n 1 && n == numDIB-1 && hRemain > 0 ) - { - // redefine height and size of the (possibly) last smaller DIB - // memory is not reallocated - height = hRemain; + if( numDIB > 1 && n == numDIB-1 && hRemain > 0 ) + { + // redefine height and size of the (possibly) last smaller DIB + // memory is not reallocated + height = hRemain; lpDIBh->bmiHeader.biHeight = (DWORD)(-height); lpDIBh->bmiHeader.biSizeImage = bytePerLine*height; - } + } ptbits = lpBits; - + for( j=0; jbmiHeader), CBM_INIT, lpBits, lpDIBh, DIB_RGB_COLORS ); -// The above line is equivalent to the following two lines. -// hbitmap = ::CreateCompatibleBitmap( hdc, width, height ); -// ::SetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS); -// or the following lines -// hbitmap = ::CreateCompatibleBitmap( hdc, width, height ); -// HDC memdc = ::CreateCompatibleDC( hdc ); -// ::SelectObject( memdc, hbitmap); -// ::SetDIBitsToDevice( memdc, 0, 0, width, height, -// 0, 0, 0, height, (void *)lpBits, lpDIBh, DIB_RGB_COLORS); -// ::SelectObject( memdc, 0 ); -// ::DeleteDC( memdc ); + 0, 0, width, height, lpBits, lpDIBh, DIB_RGB_COLORS, SRCCOPY); + origin += height; + // if numDIB = 1, lines below can also be used + // hbitmap = CreateDIBitmap( hdc, &(lpDIBh->bmiHeader), CBM_INIT, lpBits, lpDIBh, DIB_RGB_COLORS ); + // The above line is equivalent to the following two lines. + // hbitmap = ::CreateCompatibleBitmap( hdc, width, height ); + // ::SetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS); + // or the following lines + // hbitmap = ::CreateCompatibleBitmap( hdc, width, height ); + // HDC memdc = ::CreateCompatibleDC( hdc ); + // ::SelectObject( memdc, hbitmap); + // ::SetDIBitsToDevice( memdc, 0, 0, width, height, + // 0, 0, 0, height, (void *)lpBits, lpDIBh, DIB_RGB_COLORS); + // ::SelectObject( memdc, 0 ); + // ::DeleteDC( memdc ); } bitmap.SetHBITMAP( (WXHBITMAP) hbitmap ); - -// similarly, created an mono-bitmap for the possible mask + + // similarly, created an mono-bitmap for the possible mask if( HasMask() ) { hbitmap = ::CreateBitmap( (WORD)width, (WORD)bmpHeight, 1, 1, NULL ); @@ -1484,16 +1484,16 @@ wxBitmap wxImage::ConvertToBitmap() const { if( numDIB > 1 && n == numDIB - 1 && hRemain > 0 ) { - // redefine height and size of the (possibly) last smaller DIB - // memory is not reallocated - height = hRemain; + // redefine height and size of the (possibly) last smaller DIB + // memory is not reallocated + height = hRemain; lpDIBh->bmiHeader.biHeight = (DWORD)(-height); lpDIBh->bmiHeader.biSizeImage = bytePerLine*height; - } + } ptbits = lpBits; for( int j=0; jSetMaskBitmap( (WXHBITMAP) hbitmap ); bitmap.SetMask( mask ); -// It will be deleted when the wxBitmap object is deleted (as of 01/1999) -/* The following can also be used but is slow to run + // It will be deleted when the wxBitmap object is deleted (as of 01/1999) + /* The following can also be used but is slow to run wxColour colour( GetMaskRed(), GetMaskGreen(), GetMaskBlue()); wxMask *mask = new wxMask( bitmap, colour ); bitmap.SetMask( mask ); -*/ + */ } - -// free allocated resources + + // free allocated resources ::SelectObject( memdc, 0 ); ::DeleteDC( memdc ); ::ReleaseDC(NULL, hdc); free(lpDIBh); free(lpBits); - -// check the wxBitmap object + + // check the wxBitmap object if( bitmap.GetHBITMAP() ) bitmap.SetOk( TRUE ); else bitmap.SetOk( FALSE ); - + return bitmap; } wxImage::wxImage( const wxBitmap &bitmap ) { -// check the bitmap + // check the bitmap if( !bitmap.Ok() ) { wxFAIL_MSG( "invalid bitmap" ); return; } - -// create an wxImage object + + // create an wxImage object int width = bitmap.GetWidth(); int height = bitmap.GetHeight(); Create( width, height ); @@ -1561,8 +1561,8 @@ wxImage::wxImage( const wxBitmap &bitmap ) wxFAIL_MSG( "could not allocate data for image" ); return; } - -// calc the number of bytes per scanline and padding in the DIB + + // calc the number of bytes per scanline and padding in the DIB int bytePerLine = width*3; int sizeDWORD = sizeof( DWORD ); div_t lineBoundary = div( bytePerLine, sizeDWORD ); @@ -1572,8 +1572,8 @@ wxImage::wxImage( const wxBitmap &bitmap ) padding = sizeDWORD - lineBoundary.rem; bytePerLine += padding; } - -// create a DIB header + + // create a DIB header int headersize = sizeof(BITMAPINFOHEADER); LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize ); if( !lpDIBh ) @@ -1582,7 +1582,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) free( data ); return; } -// Fill in the DIB header + // Fill in the DIB header lpDIBh->bmiHeader.biSize = headersize; lpDIBh->bmiHeader.biWidth = width; lpDIBh->bmiHeader.biHeight = -height; @@ -1591,11 +1591,11 @@ wxImage::wxImage( const wxBitmap &bitmap ) lpDIBh->bmiHeader.biBitCount = 24; lpDIBh->bmiHeader.biCompression = BI_RGB; lpDIBh->bmiHeader.biClrUsed = 0; -// These seem not really needed for our purpose here. + // These seem not really needed for our purpose here. lpDIBh->bmiHeader.biClrImportant = 0; lpDIBh->bmiHeader.biXPelsPerMeter = 0; lpDIBh->bmiHeader.biYPelsPerMeter = 0; -// memory for DIB data + // memory for DIB data unsigned char *lpBits; lpBits = (unsigned char *) malloc( lpDIBh->bmiHeader.biSizeImage ); if( !lpBits ) @@ -1606,13 +1606,13 @@ wxImage::wxImage( const wxBitmap &bitmap ) return; } -// copy data from the device-dependent bitmap to the DIB + // copy data from the device-dependent bitmap to the DIB HDC hdc = ::GetDC(NULL); HBITMAP hbitmap; hbitmap = (HBITMAP) bitmap.GetHBITMAP(); ::GetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS ); - -// copy DIB data into the wxImage object + + // copy DIB data into the wxImage object int i, j; unsigned char *ptdata = data; unsigned char *ptbits = lpBits; @@ -1624,21 +1624,21 @@ wxImage::wxImage( const wxBitmap &bitmap ) *(ptdata++) = *(ptbits+1); *(ptdata++) = *(ptbits ); ptbits += 3; - } + } ptbits += padding; } - -// similarly, set data according to the possible mask bitmap + + // similarly, set data according to the possible mask bitmap if( bitmap.GetMask() && bitmap.GetMask()->GetMaskBitmap() ) { hbitmap = (HBITMAP) bitmap.GetMask()->GetMaskBitmap(); - // memory DC created, color set, data copied, and memory DC deleted + // memory DC created, color set, data copied, and memory DC deleted HDC memdc = ::CreateCompatibleDC( hdc ); ::SetTextColor( memdc, RGB( 0, 0, 0 ) ); ::SetBkColor( memdc, RGB( 255, 255, 255 ) ); ::GetDIBits( memdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS ); ::DeleteDC( memdc ); -// background color set to RGB(16,16,16) in consistent with wxGTK + // background color set to RGB(16,16,16) in consistent with wxGTK unsigned char r=16, g=16, b=16; ptdata = data; ptbits = lpBits; @@ -1647,13 +1647,13 @@ wxImage::wxImage( const wxBitmap &bitmap ) for( j=0; j> 3)+8) * height ); - + mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height ); - + wxMask *mask = new wxMask(); mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 ); - + bitmap.SetMask( mask ); } - + // Retrieve depth - + GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); int bpp = visual->depth; - + bitmap.SetDepth( bpp ); - + if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; if (bpp < 8) bpp = 8; - + // Render - + enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR }; byte_order b_o = RGB; - + if (bpp >= 24) { GdkVisual *visual = gdk_visual_get_system(); @@ -1740,13 +1740,13 @@ wxBitmap wxImage::ConvertToBitmap() const else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB; else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR; } - + int r_mask = GetMaskRed(); int g_mask = GetMaskGreen(); int b_mask = GetMaskBlue(); - + unsigned char* data = GetData(); - + int index = 0; for (int y = 0; y < height; y++) { @@ -1758,7 +1758,7 @@ wxBitmap wxImage::ConvertToBitmap() const index++; int b = data[index]; index++; - + if (HasMask()) { if ((r == r_mask) && (b == b_mask) && (g == g_mask)) @@ -1766,7 +1766,7 @@ wxBitmap wxImage::ConvertToBitmap() const else gdk_image_put_pixel( mask_image, x, y, 0 ); } - + if (HasMask()) { if ((r == r_mask) && (b == b_mask) && (g == g_mask)) @@ -1774,10 +1774,10 @@ wxBitmap wxImage::ConvertToBitmap() const else gdk_image_put_pixel( mask_image, x, y, 0 ); } - + switch (bpp) { - case 8: + case 8: { int pixel = -1; if (wxTheApp->m_colorCube) @@ -1789,7 +1789,7 @@ wxBitmap wxImage::ConvertToBitmap() const GdkColormap *cmap = gtk_widget_get_default_colormap(); GdkColor *colors = cmap->colors; int max = 3 * (65536); - + for (int i = 0; i < cmap->size; i++) { int rdiff = (r << 8) - colors[i].red; @@ -1799,104 +1799,104 @@ wxBitmap wxImage::ConvertToBitmap() const if (sum < max) { pixel = i; max = sum; } } } - + gdk_image_put_pixel( data_image, x, y, pixel ); - + break; } - case 15: + case 15: { guint32 pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3); gdk_image_put_pixel( data_image, x, y, pixel ); break; } - case 16: + case 16: { guint32 pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); gdk_image_put_pixel( data_image, x, y, pixel ); break; } - case 32: - case 24: + case 32: + case 24: { guint32 pixel = 0; switch (b_o) { - case RGB: pixel = (r << 16) | (g << 8) | b; break; - case RBG: pixel = (r << 16) | (b << 8) | g; break; - case BRG: pixel = (b << 16) | (r << 8) | g; break; - case BGR: pixel = (b << 16) | (g << 8) | r; break; - case GRB: pixel = (g << 16) | (r << 8) | b; break; - case GBR: pixel = (g << 16) | (b << 8) | r; break; + case RGB: pixel = (r << 16) | (g << 8) | b; break; + case RBG: pixel = (r << 16) | (b << 8) | g; break; + case BRG: pixel = (b << 16) | (r << 8) | g; break; + case BGR: pixel = (b << 16) | (g << 8) | r; break; + case GRB: pixel = (g << 16) | (r << 8) | b; break; + case GBR: pixel = (g << 16) | (b << 8) | r; break; } gdk_image_put_pixel( data_image, x, y, pixel ); } - default: break; + default: break; } } // for } // for - + // Blit picture - + GdkGC *data_gc = gdk_gc_new( bitmap.GetPixmap() ); - + gdk_draw_image( bitmap.GetPixmap(), data_gc, data_image, 0, 0, 0, 0, width, height ); - + gdk_image_destroy( data_image ); gdk_gc_unref( data_gc ); - + // Blit mask - + if (HasMask()) { GdkGC *mask_gc = gdk_gc_new( bitmap.GetMask()->GetBitmap() ); - + gdk_draw_image( bitmap.GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height ); - + gdk_image_destroy( mask_image ); gdk_gc_unref( mask_gc ); } - + return bitmap; } wxImage::wxImage( const wxBitmap &bitmap ) { wxCHECK_RET( bitmap.Ok(), "invalid bitmap" ); - + GdkImage *gdk_image = gdk_image_get( bitmap.GetPixmap(), - 0, 0, - bitmap.GetWidth(), bitmap.GetHeight() ); - + 0, 0, + bitmap.GetWidth(), bitmap.GetHeight() ); + wxCHECK_RET( gdk_image, "couldn't create image" ); - + Create( bitmap.GetWidth(), bitmap.GetHeight() ); char unsigned *data = GetData(); - + if (!data) { gdk_image_destroy( gdk_image ); wxFAIL_MSG( "couldn't create image" ); return; } - + GdkImage *gdk_image_mask = (GdkImage*) NULL; if (bitmap.GetMask()) { gdk_image_mask = gdk_image_get( bitmap.GetMask()->GetBitmap(), - 0, 0, - bitmap.GetWidth(), bitmap.GetHeight() ); - + 0, 0, + bitmap.GetWidth(), bitmap.GetHeight() ); + SetMaskColour( 16, 16, 16 ); // anything unlikely and dividable } - + GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); int bpp = visual->depth; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; - + GdkColormap *cmap = gtk_widget_get_default_colormap(); - + long pos = 0; for (int j = 0; j < bitmap.GetHeight(); j++) { @@ -1924,7 +1924,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) data[pos+1] = (pixel >> 8) & 0xff; data[pos+2] = pixel & 0xff; } - + if (gdk_image_mask) { int mask_pixel = gdk_image_get_pixel( gdk_image_mask, i, j ); @@ -1933,13 +1933,13 @@ wxImage::wxImage( const wxBitmap &bitmap ) data[pos] = 16; data[pos+1] = 16; data[pos+2] = 16; - } + } } - + pos += 3; } } - + gdk_image_destroy( gdk_image ); if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); } @@ -1955,44 +1955,44 @@ wxImage::wxImage( const wxBitmap &bitmap ) wxBitmap wxImage::ConvertToBitmap() const { wxBitmap bitmap; - + wxCHECK_MSG( Ok(), bitmap, "invalid image" ); - + int width = GetWidth(); int height = GetHeight(); - + bitmap.SetHeight( height ); bitmap.SetWidth( width ); - + Display *dpy = (Display*) wxGetDisplay(); Visual* vis = DefaultVisual( dpy, DefaultScreen( dpy ) ); int bpp = DefaultDepth( dpy, DefaultScreen( dpy ) ); - + // Create image XImage *data_image = XCreateImage( dpy, vis, bpp, ZPixmap, 0, 0, width, height, 32, 0 ); data_image->data = new char[ data_image->bytes_per_line * data_image->height ]; - + bitmap.Create( width, height, bpp ); - -/* + + /* // Create mask - - GdkImage *mask_image = (GdkImage*) NULL; - - if (HasMask()) - { + + GdkImage *mask_image = (GdkImage*) NULL; + + if (HasMask()) + { unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); - - mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height ); - - wxMask *mask = new wxMask(); - mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 ); - - bitmap.SetMask( mask ); - } -*/ - + + mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height ); + + wxMask *mask = new wxMask(); + mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 ); + + bitmap.SetMask( mask ); + } + */ + // Retrieve depth info XVisualInfo vinfo_template; @@ -2010,17 +2010,17 @@ wxBitmap wxImage::ConvertToBitmap() const printf("no visual.\n" ); return wxNullBitmap; } - + XFree( vi ); - + if ((bpp == 16) && (vi->red_mask != 0xf800)) bpp = 15; if (bpp < 8) bpp = 8; - + // Render - + enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR }; byte_order b_o = RGB; - + if (bpp >= 24) { if ((vi->red_mask > vi->green_mask) && (vi->green_mask > vi->blue_mask)) b_o = RGB; @@ -2030,172 +2030,172 @@ wxBitmap wxImage::ConvertToBitmap() const else if ((vi->green_mask > vi->red_mask) && (vi->red_mask > vi->blue_mask)) b_o = GRB; else if ((vi->green_mask > vi->blue_mask) && (vi->blue_mask > vi->red_mask)) b_o = GBR; } - -/* + + /* int r_mask = GetMaskRed(); int g_mask = GetMaskGreen(); int b_mask = GetMaskBlue(); -*/ - + */ + XColor colors[256]; if (bpp == 8) { - Colormap cmap = (Colormap) wxTheApp->GetMainColormap( dpy ); - + Colormap cmap = (Colormap) wxTheApp->GetMainColormap( dpy ); + for (int i = 0; i < 256; i++) colors[i].pixel = i; - XQueryColors( dpy, cmap, colors, 256 ); + XQueryColors( dpy, cmap, colors, 256 ); } - + unsigned char* data = GetData(); - + int index = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int r = data[index]; - index++; + index++; int g = data[index]; - index++; + index++; int b = data[index]; - index++; - -/* - if (HasMask()) - { - if ((r == r_mask) && (b == b_mask) && (g == g_mask)) - gdk_image_put_pixel( mask_image, x, y, 1 ); - else - gdk_image_put_pixel( mask_image, x, y, 0 ); - } -*/ - - switch (bpp) - { - case 8: - { + index++; + + /* + if (HasMask()) + { + if ((r == r_mask) && (b == b_mask) && (g == g_mask)) + gdk_image_put_pixel( mask_image, x, y, 1 ); + else + gdk_image_put_pixel( mask_image, x, y, 0 ); + } + */ + + switch (bpp) + { + case 8: + { int pixel = -1; -/* - if (wxTheApp->m_colorCube) - { - pixel = wxTheApp->m_colorCube - [ ((r & 0xf8) << 7) + ((g & 0xf8) << 2) + ((b & 0xf8) >> 3) ]; + /* + if (wxTheApp->m_colorCube) + { + pixel = wxTheApp->m_colorCube + [ ((r & 0xf8) << 7) + ((g & 0xf8) << 2) + ((b & 0xf8) >> 3) ]; } else - { -*/ - int max = 3 * (65536); - for (int i = 0; i < 256; i++) - { - int rdiff = (r << 8) - colors[i].red; - int gdiff = (g << 8) - colors[i].green; - int bdiff = (b << 8) - colors[i].blue; - int sum = abs (rdiff) + abs (gdiff) + abs (bdiff); - if (sum < max) { pixel = i; max = sum; } - } -/* - } -*/ - XPutPixel( data_image, x, y, pixel ); - break; - } - case 15: - { - int pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3); - XPutPixel( data_image, x, y, pixel ); - break; - } - case 16: - { - int pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); - XPutPixel( data_image, x, y, pixel ); - break; - } - case 32: - case 24: - { - int pixel = 0; - switch (b_o) - { - case RGB: pixel = (r << 16) | (g << 8) | b; break; - case RBG: pixel = (r << 16) | (b << 8) | g; break; - case BRG: pixel = (b << 16) | (r << 8) | g; break; - case BGR: pixel = (b << 16) | (g << 8) | r; break; - case GRB: pixel = (g << 16) | (r << 8) | b; break; - case GBR: pixel = (g << 16) | (b << 8) | r; break; - } - XPutPixel( data_image, x, y, pixel ); - } - default: break; - } + { + */ + int max = 3 * (65536); + for (int i = 0; i < 256; i++) + { + int rdiff = (r << 8) - colors[i].red; + int gdiff = (g << 8) - colors[i].green; + int bdiff = (b << 8) - colors[i].blue; + int sum = abs (rdiff) + abs (gdiff) + abs (bdiff); + if (sum < max) { pixel = i; max = sum; } + } + /* + } + */ + XPutPixel( data_image, x, y, pixel ); + break; + } + case 15: + { + int pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3); + XPutPixel( data_image, x, y, pixel ); + break; + } + case 16: + { + int pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); + XPutPixel( data_image, x, y, pixel ); + break; + } + case 32: + case 24: + { + int pixel = 0; + switch (b_o) + { + case RGB: pixel = (r << 16) | (g << 8) | b; break; + case RBG: pixel = (r << 16) | (b << 8) | g; break; + case BRG: pixel = (b << 16) | (r << 8) | g; break; + case BGR: pixel = (b << 16) | (g << 8) | r; break; + case GRB: pixel = (g << 16) | (r << 8) | b; break; + case GBR: pixel = (g << 16) | (b << 8) | r; break; + } + XPutPixel( data_image, x, y, pixel ); + } + default: break; + } } // for } // for - + // Blit picture - + XGCValues gcvalues; gcvalues.foreground = BlackPixel( dpy, DefaultScreen( dpy ) ); GC gc = XCreateGC( dpy, RootWindow ( dpy, DefaultScreen(dpy) ), GCForeground, &gcvalues ); XPutImage( dpy, (Drawable)bitmap.GetPixmap(), gc, data_image, 0, 0, 0, 0, width, height ); - + XDestroyImage( data_image ); XFreeGC( dpy, gc ); - -/* + + /* // Blit mask - - if (HasMask()) - { - GdkGC *mask_gc = gdk_gc_new( bitmap.GetMask()->GetBitmap() ); - + + if (HasMask()) + { + GdkGC *mask_gc = gdk_gc_new( bitmap.GetMask()->GetBitmap() ); + gdk_draw_image( bitmap.GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height ); - - gdk_image_destroy( mask_image ); - gdk_gc_unref( mask_gc ); - } -*/ - + + gdk_image_destroy( mask_image ); + gdk_gc_unref( mask_gc ); + } + */ + return bitmap; } wxImage::wxImage( const wxBitmap &bitmap ) { wxCHECK_RET( bitmap.Ok(), "invalid bitmap" ); - + Display *dpy = (Display*) wxGetDisplay(); Visual* vis = DefaultVisual( dpy, DefaultScreen( dpy ) ); int bpp = DefaultDepth( dpy, DefaultScreen( dpy ) ); XImage *ximage = XGetImage( dpy, - (Drawable)bitmap.GetPixmap(), - 0, 0, - bitmap.GetWidth(), bitmap.GetHeight(), - AllPlanes, ZPixmap ); - + (Drawable)bitmap.GetPixmap(), + 0, 0, + bitmap.GetWidth(), bitmap.GetHeight(), + AllPlanes, ZPixmap ); + wxCHECK_RET( ximage, "couldn't create image" ); - + Create( bitmap.GetWidth(), bitmap.GetHeight() ); char unsigned *data = GetData(); - + if (!data) { XDestroyImage( ximage ); wxFAIL_MSG( "couldn't create image" ); return; } - -/* + + /* GdkImage *gdk_image_mask = (GdkImage*) NULL; if (bitmap.GetMask()) { - gdk_image_mask = gdk_image_get( bitmap.GetMask()->GetBitmap(), - 0, 0, - bitmap.GetWidth(), bitmap.GetHeight() ); - - SetMaskColour( 16, 16, 16 ); // anything unlikely and dividable - } -*/ - + gdk_image_mask = gdk_image_get( bitmap.GetMask()->GetBitmap(), + 0, 0, + bitmap.GetWidth(), bitmap.GetHeight() ); + + SetMaskColour( 16, 16, 16 ); // anything unlikely and dividable + } + */ + // Retrieve depth info XVisualInfo vinfo_template; @@ -2213,26 +2213,26 @@ wxImage::wxImage( const wxBitmap &bitmap ) printf("no visual.\n" ); return; } - + if ((bpp == 16) && (vi->red_mask != 0xf800)) bpp = 15; XFree( vi ); - + XColor colors[256]; if (bpp == 8) { - Colormap cmap = (Colormap)wxTheApp->GetMainColormap( dpy ); - + Colormap cmap = (Colormap)wxTheApp->GetMainColormap( dpy ); + for (int i = 0; i < 256; i++) colors[i].pixel = i; - XQueryColors( dpy, cmap, colors, 256 ); + XQueryColors( dpy, cmap, colors, 256 ); } - + long pos = 0; for (int j = 0; j < bitmap.GetHeight(); j++) { for (int i = 0; i < bitmap.GetWidth(); i++) { - int pixel = XGetPixel( ximage, i, j ); + int pixel = XGetPixel( ximage, i, j ); if (bpp <= 8) { data[pos] = colors[pixel].red >> 8; @@ -2254,27 +2254,27 @@ wxImage::wxImage( const wxBitmap &bitmap ) data[pos+1] = (pixel >> 8) & 0xff; data[pos+2] = pixel & 0xff; } - -/* + + /* if (gdk_image_mask) { - int mask_pixel = gdk_image_get_pixel( gdk_image_mask, i, j ); - if (mask_pixel == 0) - { - data[pos] = 16; - data[pos+1] = 16; - data[pos+2] = 16; - } + int mask_pixel = gdk_image_get_pixel( gdk_image_mask, i, j ); + if (mask_pixel == 0) + { + data[pos] = 16; + data[pos+1] = 16; + data[pos+2] = 16; } -*/ - + } + */ + pos += 3; } } - + XDestroyImage( ximage ); -/* + /* if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); -*/ + */ } #endif diff --git a/src/common/string.cpp b/src/common/string.cpp index 10f765aff9..3ba5ee9ab5 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -110,6 +110,10 @@ extern const char WXDLLEXPORT *g_szNul = &g_strEmpty.dummy; #warning "Using sprintf() because no snprintf()-like function defined" #elif defined(__MWERKS__) #warning "Using sprintf() because no snprintf()-like function defined" +#elif defined(__WATCOMC__) + // No warning +#elif defined(__BORLANDC__) + // No warning #elif defined(__SUNCC__) // nothing -- I don't know about "#warning" for Sun's CC #else diff --git a/src/makeb32.env b/src/makeb32.env index 8e318d0536..ab253615c5 100644 --- a/src/makeb32.env +++ b/src/makeb32.env @@ -50,10 +50,10 @@ WXLIB= $(WXLIBDIR)\wx32.lib !if "$(WXBUILDDLL)" == "1" DLL_FLAGS= $(DLL_FLAGS) -D_RTLDLL -LINK_FLAGS= /Tpd /ap /c +LINK_FLAGS= /Tpd /ap /c $(EXTRALINKFLAGS) !endif -CPPFLAGS=$(DLL_FLAGS) @$(CFG) +CPPFLAGS=$(DLL_FLAGS) $(EXTRACPPFLAGS) @$(CFG) DUMMY=dummy diff --git a/src/makebcc.env b/src/makebcc.env index 1bbebd6249..302872beb5 100644 --- a/src/makebcc.env +++ b/src/makebcc.env @@ -11,18 +11,16 @@ FINAL=0 !endif !if "$(FINAL)" == "0" -LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib +LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib $(EXTRALINKFLAGS) OPT = -Od DEBUG_FLAGS= -v -D__WXDEBUG__ !else -LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib +LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib $(EXTRALINKFLAGS) OPT = -O2 DEBUG_FLAGS = !endif -CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) - -CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) +CPPFLAGS=$(DEBUG_FLAGS) $(OPT) $(EXTRACPPFLAGS) @$(CFG) WXLIB= $(WXLIBDIR)\wx.lib SRCSUFF = cpp diff --git a/src/makeg95.env b/src/makeg95.env index 25281c2375..0fb9dfacee 100644 --- a/src/makeg95.env +++ b/src/makeg95.env @@ -121,11 +121,11 @@ WXSRC=$(WXDIR)/src/msw WXINC=$(WXDIR)/include WXBASESRC=$(WXDIR)/src/common WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx.$(LIBSUFF) -INC = -I$(WXINC) -I$(WXDIR)/src/png -I$(WXDIR)/include/wx/msw/gnuwin32 -I$(WXDIR)/src/zlib $(EXTRAINC)$(COMPPATHS) +INC = -I$(WXINC) -I$(WXDIR)/src/png -I$(WXDIR)/include/wx/msw/gnuwin32 -I$(WXDIR)/src/zlib $(EXTRAINC) $(COMPPATHS) RCLFLAGS=-cpp "cpp -lang-c++ -DWIN32 -D_WIN32 -DRCL_INVOKED -I$(WXWIN)\include" #LIBS = -lctl3d32 $(WXLIB) $(WINLIBS) $(COMPLIBS) -LIBS = $(WXLIB) $(WINLIBS) $(COMPLIBS) +LIBS = $(WXLIB) $(WINLIBS) $(COMPLIBS) $(EXTRALIBS) WINFLAGS=-D_X86_=1 -DWIN32 -D_WIN32 $(WINVERSION) @@ -135,13 +135,13 @@ XLIB=$(LIBS) LDLIBS = $(LIBS) # Directory for object files (don't change) -OBJDIR = objects$(GUISUFFIX) +# OBJDIR = objects$(GUISUFFIX) # You shouldn't need to change these... -CPPFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) -CFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) +CPPFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRACPPFLAGS) +CFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRACFLAGS) WINDOWSLDFLAGS=-Wl,--subsystem,windows -mwindows -LDFLAGS = $(WINDOWSLDFLAGS) -L$(WXDIR)/lib +LDFLAGS = $(WINDOWSLDFLAGS) -L$(WXDIR)/lib $(EXTRALDFLAGS) .SUFFIXES: .rc .$(RESSUFF) .$(RSCSUFF) .cpp .c @@ -150,11 +150,11 @@ LDFLAGS = $(WINDOWSLDFLAGS) -L$(WXDIR)/lib # CPLUS_INCLUDE_PATH=/usr/H-i386-cygwin32/i386-cygwin32/include:/usr/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2-961023/include:$(WXDIR)/include/common:$(WXDIR)/include/msw:$(WXDIR)/contrib/fafa:$(WXDIR)/contrib/itsybits; \ # export CPLUS_INCLUDE_PATH RCINCLUDE; \ -.rc.$(RESSUFF): $< $(WXDIR)/include/msw/wx.rc - $(RC) $(RESFLAGS1) $< $(RESFLAGS2) $*.$(RESSUFF) $(RCLFLAGS) +#.rc.$(RESSUFF): $< $(WXDIR)/include/msw/wx.rc +# $(RC) $(RESFLAGS1) $< $(RESFLAGS2) $*.$(RESSUFF) $(RCLFLAGS) -.$(RESSUFF).$(RSCSUFF): $< - $(CVTRES) $< $*.$(RSCSUFF) +#.$(RESSUFF).$(RSCSUFF): $< +# $(CVTRES) $< $*.$(RSCSUFF) .$(SRCSUFF).$(OBJSUFF): $(CC) -c $(CPPFLAGS) -o $@ $*.$(SRCSUFF) diff --git a/src/makelib.b32 b/src/makelib.b32 new file mode 100644 index 0000000000..cf2732bfd3 --- /dev/null +++ b/src/makelib.b32 @@ -0,0 +1,37 @@ +# +# File: makelib.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Include file for libraries. Set LIBTARGET and OBJECTS +# before including this file. + +# WXWIN and BCCDIR are set by parent make + +WXDIR = $(WXWIN) + +!include $(WXDIR)\src\makeb32.env + +$(LIBTARGET): $(OBJECTS) + erase $(LIBTARGET) + tlib $(LIBTARGET) /P512 @&&! +-+$(OBJECTS:.obj =.obj -+) +! + +.$(SRCSUFF).obj: + bcc32 $(CPPFLAGS) -c {$< } + +.c.obj: + bcc32 $(CPPFLAGS) -P- -c {$< } + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.rws + -erase $(LIBTARGET) + + diff --git a/src/makelib.bcc b/src/makelib.bcc new file mode 100644 index 0000000000..73705fb5be --- /dev/null +++ b/src/makelib.bcc @@ -0,0 +1,37 @@ +# +# File: makelib.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Include file for libraries. Set LIBTARGET and OBJECTS +# before including this file. + +# WXWIN and BCCDIR are set by parent make + +WXDIR = $(WXWIN) + +!include $(WXDIR)\src\makebcc.env + +$(LIBTARGET): $(OBJECTS) + erase $(LIBTARGET) + tlib $(LIBTARGET) /P1024 @&&! +-+$(OBJECTS:.obj =.obj -+) +! + +.$(SRCSUFF).obj: + bcc $(CPPFLAGS) -c {$< } + +.c.obj: + bcc $(CPPFLAGS) -P- -c {$< } + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.rws + -erase $(LIBTARGET) + + diff --git a/src/makelib.g95 b/src/makelib.g95 new file mode 100644 index 0000000000..de3e8c583c --- /dev/null +++ b/src/makelib.g95 @@ -0,0 +1,23 @@ +# +# File: makelib.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Include file for Cygwin/Mingw32 libraries + +WXDIR = $(WXWIN) + +# All common UNIX compiler flags and options are now in +# this central makefile. +include $(WXDIR)/src/makeg95.env + +all: $(LIBTARGET) $(EXTRATARGETS) + +$(LIBTARGET): $(OBJECTS) + ar $(AROPTIONS) $@ $(OBJECTS) + $(RANLIB) $@ + +clean: + rm -f $(OBJECTS) $(LIBTARGET) core *.rsc *.res diff --git a/src/makelib.wat b/src/makelib.wat new file mode 100644 index 0000000000..74cc16dc7b --- /dev/null +++ b/src/makelib.wat @@ -0,0 +1,26 @@ +WXDIR = $(%WXWIN) + +!include $(WXDIR)\src\makewat.env + +WXLIB = $(WXDIR)\lib +LNK = tmp.lbc + +all: $(LIBTARGET) + +$(LIBTARGET) : $(OBJECTS) + %create tmp.lbc + @for %i in ( $(OBJECTS) ) do @%append tmp.lbc +%i + wlib /b /c /n /p=512 $^@ @tmp.lbc + +clean: .SYMBOLIC + -erase *.obj + -erase *.bak + -erase *.err + -erase *.pch + -erase *.lib + -erase *.lbc + -erase *.res + -erase *.exe + -erase *.lbc + -erase $(LIBTARGET) + diff --git a/src/makeprog.b32 b/src/makeprog.b32 index 325dd50e77..3f81e49cbc 100644 --- a/src/makeprog.b32 +++ b/src/makeprog.b32 @@ -13,18 +13,21 @@ WXDIR = $(WXWIN) !include $(WXDIR)\src\makeb32.env -LIBS=$(WXLIB) cw32mt import32 ole2w32 +LIBS=$(WXLIB) $(EXTRALIBS) cw32mt import32 ole2w32 !if "$(FINAL)" == "0" -LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib $(EXTRALINKFLAGS) OPT = -Od DEBUG_FLAGS= -v !else -LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib $(EXTRALINKFLAGS) OPT = -Od DEBUG_FLAGS = !endif -CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) + +CPPFLAGS=$(DEBUG_FLAGS) $(EXTRACPPFLAGS) $(OPT) @$(CFG) + +all: $(TARGET).exe $(EXTRATARGETS) $(TARGET).exe: $(OBJECTS) $(TARGET).res tlink32 $(LINKFLAGS) @&&! diff --git a/src/makeprog.bcc b/src/makeprog.bcc index e8f20a2b00..3be08ebda1 100644 --- a/src/makeprog.bcc +++ b/src/makeprog.bcc @@ -4,9 +4,9 @@ !include $(WXDIR)\src\makebcc.env WXLIB = $(WXDIR)\lib\wx.lib -LIBS=$(WXLIB) mathwl cwl import ole2w16 +LIBS=$(WXLIB) $(EXTRALIBS) mathwl cwl import ole2w16 -all: $(TARGET).exe +all: $(TARGET).exe $(EXTRATARGETS) $(TARGET).exe: $(WXLIB) $(OBJECTS) $(TARGET).def $(TARGET).res tlink $(LINKFLAGS) @&&! @@ -21,6 +21,9 @@ $(TARGET).def .$(SRCSUFF).obj: bcc $(CPPFLAGS) -c {$< } +.c.obj: + bcc $(CPPFLAGS) -P- -c {$< } + $(TARGET).res : $(TARGET).rc $(WXDIR)\include\wx\msw\wx.rc brc -r /i$(BCCDIR)\include /i$(WXDIR)\include $(TARGET) diff --git a/src/makeprog.g95 b/src/makeprog.g95 new file mode 100644 index 0000000000..391881439c --- /dev/null +++ b/src/makeprog.g95 @@ -0,0 +1,23 @@ +# +# File: makeprog.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Include file for Cygwin/Mingw32 samples + +WXDIR = $(WXWIN) + +include $(WXDIR)/src/makeg95.env + +all: $(TARGET)$(GUISUFFIX)$(EXESUFF) $(TARGET)_resources.$(OBJSUFF) $(EXTRATARGETS) + +$(TARGET)$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(TARGET)_resources.$(OBJSUFF) $(WXLIB) + $(CC) $(LDFLAGS) -o $(TARGET)$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(TARGET)_resources.$(OBJSUFF) $(LDLIBS) + +$(TARGET)_resources.o: $(TARGET).rc + $(RESCOMP) $(RCINPUTSWITCH) $(TARGET).rc $(RCOUTPUTSWITCH) $(TARGET)_resources.o $(RESFLAGS) + +clean: + rm -f $(OBJECTS) $(TARGET)_resources.o $(TARGET).exe core *.rsc *.res diff --git a/src/makeprog.wat b/src/makeprog.wat index 7814ef4947..431ecc5d3f 100644 --- a/src/makeprog.wat +++ b/src/makeprog.wat @@ -5,7 +5,7 @@ WXDIR = $(%WXWIN) WXLIB = $(WXDIR)\lib LNK = $(PROGRAM).lnk -all: $(PROGRAM).exe +all: $(PROGRAM).exe $(EXTRATARGETS) $(PROGRAM).exe : $(OBJECTS) $(PROGRAM).res $(LNK) $(WXLIB)\wx.lib wlink @$(LNK) @@ -20,7 +20,7 @@ $(LNK) : makefile.wat @%append $(LNK) system $(LINKOPTION) @%append $(LNK) $(STACK) @%append $(LNK) name $(PROGRAM).exe - @%append $(LNK) file $(WXLIB)\wx.lib + @for %i in ($(LIBS)) do @%append $(LNK) file %i @for %i in ($(EXTRALIBS)) do @%append $(LNK) file %i @for %i in ($(OBJECTS)) do @%append $(LNK) file %i # @%append $(LNK) $(MINDATA) diff --git a/src/makewat.env b/src/makewat.env index 64abaf4388..6435eb28b3 100644 --- a/src/makewat.env +++ b/src/makewat.env @@ -51,7 +51,7 @@ WATLIBDIR = $(WATCOMDIR)\lib386\nt MINDATA = MAXDATA = STACK = option stack=64k -EXTRALIBS = $(WXDIR)\lib\zlib.lib $(WXDIR)\lib\png.lib $(WXDIR)\lib\xpm.lib & +LIBS = $(WXDIR)\lib\wx.lib $(WXDIR)\lib\zlib.lib $(WXDIR)\lib\png.lib $(WXDIR)\lib\xpm.lib & $(WATLIBDIR)\comctl32.lib $(WATLIBDIR)\comdlg32.lib & $(WATLIBDIR)\ole32.lib $(WATLIBDIR)\oleaut32.lib & $(WATLIBDIR)\uuid.lib # $(WATLIBDIR)\odbc32.lib diff --git a/src/msw/clipbrd.cpp b/src/msw/clipbrd.cpp index f15f9d8fc8..9fb76f0b08 100644 --- a/src/msw/clipbrd.cpp +++ b/src/msw/clipbrd.cpp @@ -47,6 +47,7 @@ #include "wx/metafile.h" #endif +#include "wx/log.h" #include "wx/clipbrd.h" #include diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index d64bf0d7e7..d5f4085fa6 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -29,6 +29,7 @@ #endif #include "wx/msw/private.h" +#include "wx/log.h" #if wxUSE_COMMON_DIALOGS #include diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95 index 455592f62c..c078f9370c 100644 --- a/src/msw/makefile.g95 +++ b/src/msw/makefile.g95 @@ -51,11 +51,6 @@ XPMDIR=../xpm OLEDIR=ole MSWDIR=. -GENERICOBJDIR=../generic/$(OBJDIR) -COMMOBJDIR=../common/$(OBJDIR) -OLEOBJDIR=ole/$(OBJDIR) -MSWDIR=$(OBJDIR) - DOCDIR = $(WXDIR)\docs GENERICOBJS= \ @@ -95,6 +90,7 @@ COMMONOBJS = \ $(COMMDIR)/helpbase.$(OBJSUFF) \ $(COMMDIR)/image.$(OBJSUFF) \ $(COMMDIR)/intl.$(OBJSUFF) \ + $(COMMDIR)/ipcbase.$(OBJSUFF) \ $(COMMDIR)/layout.$(OBJSUFF) \ $(COMMDIR)/log.$(OBJSUFF) \ $(COMMDIR)/memory.$(OBJSUFF) \ @@ -263,15 +259,6 @@ $(WXLIB): $(OBJECTS) $(EXTRAOBJS) ar $(AROPTIONS) $@ $(EXTRAOBJS) $(OBJECTS) $(RANLIB) $@ -#$(MSWOBJDIR): -# mkdir $(OBJDIR) - -#$(COMMOBJDIR): -# mkdir $(COMMDIR)/$(OBJDIR) - -#$(GENERICOBJDIR): -# mkdir $(GENDIR)/$(OBJDIR) - $(OBJECTS): $(WXINC)/wx/defs.h $(WXINC)/wx/object.h $(WXINC)/wx/setup.h $(COMMDIR)/y_tab.$(OBJSUFF): $(COMMDIR)/y_tab.c $(COMMDIR)/lex_yy.c diff --git a/src/msw/makefile.twn b/src/msw/makefile.twn index 503c878f4f..dab7599437 100644 --- a/src/msw/makefile.twn +++ b/src/msw/makefile.twn @@ -92,6 +92,7 @@ COMMONOBJS = \ $(COMMDIR)/helpbase.$(OBJSUFF) \ $(COMMDIR)/image.$(OBJSUFF) \ $(COMMDIR)/intl.$(OBJSUFF) \ + $(COMMDIR)/ipcbase.$(OBJSUFF) \ $(COMMDIR)/layout.$(OBJSUFF) \ $(COMMDIR)/log.$(OBJSUFF) \ $(COMMDIR)/memory.$(OBJSUFF) \ diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 569dec2dd6..9dcf9a86a1 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -50,6 +50,8 @@ #include "wx/menuitem.h" #include "wx/log.h" #include "wx/tooltip.h" +#include "wx/intl.h" +#include "wx/log.h" #include "wx/msw/private.h" @@ -1223,10 +1225,19 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) } case WM_KEYDOWN: - MSWOnKeyDown((WORD) wParam, lParam); - // we consider these message "not interesting" + { + // If this has been processed by an event handler, + // return 0 now (we've handled it). + if (MSWOnKeyDown((WORD) wParam, lParam)) + { + return 0; + } + + // we consider these message "not interesting" to OnChar if ( wParam == VK_SHIFT || wParam == VK_CONTROL ) + { return Default(); + } // Avoid duplicate messages to OnChar for these special keys switch ( wParam ) @@ -1240,27 +1251,36 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) case VK_RIGHT: case VK_DOWN: case VK_UP: - if ( ::GetKeyState(VK_CONTROL) & 0x100 ) - MSWOnChar((WORD)wParam, lParam); +/* +// if ( ::GetKeyState(VK_CONTROL) & 0x100 ) // Don't understand purpose of this test + if (!MSWOnChar((WORD)wParam, lParam)) + return Default(); break; - +*/ default: - MSWOnChar((WORD)wParam, lParam); + if (!MSWOnChar((WORD)wParam, lParam)) + { + return Default(); + } +/* if ( ::GetKeyState(VK_CONTROL) & 0x100 ) return Default(); +*/ break; } break; - + } case WM_KEYUP: { - MSWOnKeyUp((WORD) wParam, lParam); + if (!MSWOnKeyUp((WORD) wParam, lParam)) + return Default(); break; } case WM_CHAR: // Always an ASCII character { - MSWOnChar((WORD)wParam, lParam, TRUE); + if (!MSWOnChar((WORD)wParam, lParam, TRUE)) + return Default(); break; } @@ -2456,7 +2476,7 @@ void wxWindow::MSWOnMouseLeave(int x, int y, WXUINT flags) GetEventHandler()->ProcessEvent(event); } -void wxWindow::MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) +bool wxWindow::MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) { int id; bool tempControlDown = FALSE; @@ -2518,12 +2538,16 @@ void wxWindow::MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) event.m_x = pt.x; event.m_y = pt.y; - if (!GetEventHandler()->ProcessEvent(event)) - Default(); + if (GetEventHandler()->ProcessEvent(event)) + return TRUE; + else + return FALSE; } + else + return FALSE; } -void wxWindow::MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII) +bool wxWindow::MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII) { int id; @@ -2552,12 +2576,19 @@ void wxWindow::MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII) event.m_x = pt.x; event.m_y = pt.y; - if (!GetEventHandler()->ProcessEvent(event)) - Default(); + if (GetEventHandler()->ProcessEvent(event)) + { + return TRUE; + } + else return FALSE; + } + else + { + return FALSE; } } -void wxWindow::MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII) +bool wxWindow::MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII) { int id; @@ -2586,9 +2617,13 @@ void wxWindow::MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII) event.m_x = pt.x; event.m_y = pt.y; - if (!GetEventHandler()->ProcessEvent(event)) - Default(); + if (GetEventHandler()->ProcessEvent(event)) + return TRUE; + else + return FALSE; } + else + return FALSE; } void wxWindow::MSWOnJoyDown(int joystick, int x, int y, WXUINT flags) @@ -3666,7 +3701,7 @@ void wxWindow::OnChar(wxKeyEvent& event) if ( id == -1 ) id= m_lastWParam; - if ( !event.ControlDown() ) + if ( !event.ControlDown() ) // Why this test? (void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam); } diff --git a/utils/dialoged/src/makefile.b32 b/utils/dialoged/src/makefile.b32 index 1479b6f97f..39c14b5720 100644 --- a/utils/dialoged/src/makefile.b32 +++ b/utils/dialoged/src/makefile.b32 @@ -14,7 +14,8 @@ WXDIR = $(WXWIN) TARGET=dialoged -OBJECTS = dialoged.obj reseditr.obj dlghndlr.obj reswrite.obj winprop.obj edtree.obj edlist.obj symbtable.obj winstyle.obj +OBJECTS = dialoged.obj reseditr.obj dlghndlr.obj reswrite.obj winprop.obj\ + edtree.obj edlist.obj symbtabl.obj winstyle.obj -!include $(WXDIR)\src\makeb32.env +!include $(WXDIR)\src\makeprog.b32 diff --git a/utils/dialoged/src/makefile.g95 b/utils/dialoged/src/makefile.g95 index b886f57feb..7bf29275c3 100644 --- a/utils/dialoged/src/makefile.g95 +++ b/utils/dialoged/src/makefile.g95 @@ -1,61 +1,17 @@ # -# File: makefile.g95 -# Author: Julian Smart -# Created: 1996 -# Updated: +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 # -# "%W% %G%" -# -# Makefile for Dialog Editor (GNU-WIN32) +# Makefile for wxWindows Dialog Editor (Cygwin/Mingw32). WXDIR = ../../.. -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/makeg95.env - -OBJECTS = $(OBJDIR)/dialoged.$(OBJSUFF) $(OBJDIR)/reseditr.$(OBJSUFF)\ - $(OBJDIR)/dlghndlr.$(OBJSUFF) $(OBJDIR)/reswrite.$(OBJSUFF) $(OBJDIR)/winprop.$(OBJSUFF)\ - $(OBJDIR)/edlist.$(OBJSUFF) $(OBJDIR)/edtree.$(OBJSUFF) $(OBJDIR)/winstyle.$(OBJSUFF) $(OBJDIR)/symbtabl.$(OBJSUFF)\ - $(OBJDIR)/dialoged_resources.$(OBJSUFF) - -all: $(OBJDIR) dialoged$(GUISUFFIX)$(EXESUFF) - -$(OBJDIR): - mkdir $(OBJDIR) - -dialoged$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB) - $(CC) $(LDFLAGS) -o dialoged$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(XVIEW_LINK) $(LDLIBS) - -$(OBJDIR)/dialoged.$(OBJSUFF): dialoged.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ dialoged.$(SRCSUFF) - -$(OBJDIR)/winprop.$(OBJSUFF): winprop.h reseditr.h winprop.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ winprop.$(SRCSUFF) - -$(OBJDIR)/reswrite.$(OBJSUFF): winprop.h reseditr.h reswrite.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ reswrite.$(SRCSUFF) - -$(OBJDIR)/reseditr.$(OBJSUFF): winprop.h reseditr.h reseditr.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ reseditr.$(SRCSUFF) - -$(OBJDIR)/dlghndlr.$(OBJSUFF): winprop.h reseditr.h dlghndlr.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ dlghndlr.$(SRCSUFF) - -$(OBJDIR)/edlist.$(OBJSUFF): winprop.h edlist.h edlist.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ edlist.$(SRCSUFF) - -$(OBJDIR)/edtree.$(OBJSUFF): winprop.h edtree.h edtree.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ edtree.$(SRCSUFF) - -$(OBJDIR)/winstyle.$(OBJSUFF): winstyle.h winstyle.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ winstyle.$(SRCSUFF) - -$(OBJDIR)/symbtabl.$(OBJSUFF): symbtabl.h symbtabl.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ symbtabl.$(SRCSUFF) +TARGET=dialoged +OBJECTS = $(TARGET).o reseditr.o dlghndlr.o reswrite.o\ + winprop.o edtree.o edlist.o symbtabl.o winstyle.o -$(OBJDIR)/dialoged_resources.o: dialoged.rc - $(RESCOMP) -i dialoged.rc -o $(OBJDIR)/dialoged_resources.o $(RESFLAGS) +include $(WXDIR)/src/makeprog.g95 -clean: - rm -f $(OBJECTS) dialoged$(GUISUFFIX).exe core *.rsc *.res diff --git a/utils/glcanvas/samples/cube/makefile.b32 b/utils/glcanvas/samples/cube/makefile.b32 new file mode 100644 index 0000000000..d247005826 --- /dev/null +++ b/utils/glcanvas/samples/cube/makefile.b32 @@ -0,0 +1,18 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=cube +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/utils/glcanvas/samples/cube/makefile.bcc b/utils/glcanvas/samples/cube/makefile.bcc new file mode 100644 index 0000000000..750206f1f0 --- /dev/null +++ b/utils/glcanvas/samples/cube/makefile.bcc @@ -0,0 +1,21 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Builds a BC++ 16-bit sample + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +WXDIR = $(WXWIN) + +TARGET=cube +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.bcc + diff --git a/utils/glcanvas/samples/cube/makefile.g95 b/utils/glcanvas/samples/cube/makefile.g95 index 88d34c180f..7d4119e5db 100644 --- a/utils/glcanvas/samples/cube/makefile.g95 +++ b/utils/glcanvas/samples/cube/makefile.g95 @@ -1,37 +1,18 @@ # -# File: makefile.unx -# Author: Julian Smart -# Created: 1993 -# Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 # -# "%W% %G%" -# -# Makefile for cube example (UNIX). - -WXDIR = ../.. - -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/makeg95.env - -OBJECTS = $(OBJDIR)/cube.$(OBJSUFF) - -all: $(OBJDIR) cube$(GUISUFFIX)$(EXESUFF) - -wx: - -$(OBJDIR): - mkdir $(OBJDIR) +# Makefile for wxWindows sample (Cygwin/Mingw32). -cube$(GUISUFFIX)$(EXESUFF): $(OBJDIR)/cube.$(OBJSUFF) cube.res $(WXLIB) - $(CC) $(LDFLAGS) -o cube$(GUISUFFIX)$(EXESUFF) $(OBJDIR)/cube.$(OBJSUFF) $(LDLIBS) - $(RSRC) cube.$(RESSUFF) cube.exe +WXDIR = ../../../.. -$(OBJDIR)/cube.$(OBJSUFF): cube.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ cube.$(SRCSUFF) +TARGET=cube +EXTRACPPFLAGS=-I../../win +EXTRALIBS=-lglcanvas -lopengl32 -lglu32 +OBJECTS = $(TARGET).o -cube.res: cube.rc +include $(WXDIR)/src/makeprog.g95 -clean: - rm -f $(OBJECTS) cube$(GUISUFFIX).exe core *.rsc *.res diff --git a/utils/glcanvas/samples/cube/makefile.wat b/utils/glcanvas/samples/cube/makefile.wat new file mode 100644 index 0000000000..448db542b5 --- /dev/null +++ b/utils/glcanvas/samples/cube/makefile.wat @@ -0,0 +1,17 @@ +# +# Makefile for WATCOM +# +# Created by Julian Smart, January 1999 +# +# + +WXDIR = $(%WXWIN) + +PROGRAM = cube +OBJECTS = $(PROGRAM).obj +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win + +!include $(WXDIR)\src\makeprog.wat + + diff --git a/utils/glcanvas/samples/isosurf/makefile.b32 b/utils/glcanvas/samples/isosurf/makefile.b32 new file mode 100644 index 0000000000..27bd57a6e6 --- /dev/null +++ b/utils/glcanvas/samples/isosurf/makefile.b32 @@ -0,0 +1,22 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=isosurf +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win +OBJECTS = $(TARGET).obj +EXTRATARGETS=isosurf.dat + +!include $(WXDIR)\src\makeprog.b32 + +isosurf.dat: isosurf.dat.gz + gzip -c -d isosurf.dat.gz > isosurf.dat + diff --git a/utils/glcanvas/samples/isosurf/makefile.bcc b/utils/glcanvas/samples/isosurf/makefile.bcc new file mode 100644 index 0000000000..778a628406 --- /dev/null +++ b/utils/glcanvas/samples/isosurf/makefile.bcc @@ -0,0 +1,25 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Builds a BC++ 16-bit sample + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +WXDIR = $(WXWIN) + +TARGET=isosurf +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win +OBJECTS = $(TARGET).obj +EXTRATARGETS=isosurf.dat + +!include $(WXDIR)\src\makeprog.bcc + +isosurf.dat: isosurf.dat.gz + gzip -c -d isosurf.dat.gz > isosurf.dat + diff --git a/utils/glcanvas/samples/isosurf/makefile.g95 b/utils/glcanvas/samples/isosurf/makefile.g95 new file mode 100644 index 0000000000..81b138d0ec --- /dev/null +++ b/utils/glcanvas/samples/isosurf/makefile.g95 @@ -0,0 +1,20 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../../../.. + +TARGET=isosurf +EXTRACPPFLAGS=-I../../win +EXTRALIBS=-lglcanvas -lopengl32 -lglu32 +OBJECTS = $(TARGET).o + +include $(WXDIR)/src/makeprog.g95 + +isosurf.dat: isosurf.dat.gz + gzip -c -d isosurf.dat.gz > isosurf.dat diff --git a/utils/glcanvas/samples/isosurf/makefile.wat b/utils/glcanvas/samples/isosurf/makefile.wat new file mode 100644 index 0000000000..424761f965 --- /dev/null +++ b/utils/glcanvas/samples/isosurf/makefile.wat @@ -0,0 +1,20 @@ +# +# Makefile for WATCOM +# +# Created by Julian Smart, January 1999 +# +# + +WXDIR = $(%WXWIN) + +PROGRAM = isosurf +OBJECTS = $(PROGRAM).obj +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win +EXTRATARGETS=isosurf.dat + +!include $(WXDIR)\src\makeprog.wat + +isosurf.dat: isosurf.dat.gz + gzip -c -d isosurf.dat.gz > isosurf.dat + diff --git a/utils/glcanvas/samples/penguin/makefile.b32 b/utils/glcanvas/samples/penguin/makefile.b32 new file mode 100644 index 0000000000..a8dbbec2ab --- /dev/null +++ b/utils/glcanvas/samples/penguin/makefile.b32 @@ -0,0 +1,18 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=penguin +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win +OBJECTS = $(TARGET).obj lw.obj trackball.obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/utils/glcanvas/samples/penguin/makefile.bcc b/utils/glcanvas/samples/penguin/makefile.bcc new file mode 100644 index 0000000000..750206f1f0 --- /dev/null +++ b/utils/glcanvas/samples/penguin/makefile.bcc @@ -0,0 +1,21 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Builds a BC++ 16-bit sample + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +WXDIR = $(WXWIN) + +TARGET=cube +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.bcc + diff --git a/utils/glcanvas/samples/penguin/makefile.g95 b/utils/glcanvas/samples/penguin/makefile.g95 new file mode 100644 index 0000000000..6002514c36 --- /dev/null +++ b/utils/glcanvas/samples/penguin/makefile.g95 @@ -0,0 +1,18 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../../../.. + +TARGET=penguin +EXTRACPPFLAGS=-I../../win +EXTRALIBS=-lglcanvas -lopengl32 -lglu32 +OBJECTS = $(TARGET).o lw.o trackball.o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/utils/glcanvas/samples/penguin/makefile.wat b/utils/glcanvas/samples/penguin/makefile.wat new file mode 100644 index 0000000000..448db542b5 --- /dev/null +++ b/utils/glcanvas/samples/penguin/makefile.wat @@ -0,0 +1,17 @@ +# +# Makefile for WATCOM +# +# Created by Julian Smart, January 1999 +# +# + +WXDIR = $(%WXWIN) + +PROGRAM = cube +OBJECTS = $(PROGRAM).obj +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win + +!include $(WXDIR)\src\makeprog.wat + + diff --git a/utils/glcanvas/win/makefile.b32 b/utils/glcanvas/win/makefile.b32 new file mode 100644 index 0000000000..97783fb2d7 --- /dev/null +++ b/utils/glcanvas/win/makefile.b32 @@ -0,0 +1,17 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds wxGLCanvas library for 32-bit BC++ + +WXDIR = $(WXWIN) + +LIBTARGET=$(WXDIR)\lib\glcanvas.lib + +OBJECTS = glcanvas.obj + +!include $(WXDIR)\src\makelib.b32 + diff --git a/utils/glcanvas/win/makefile.bcc b/utils/glcanvas/win/makefile.bcc new file mode 100644 index 0000000000..705fc065bc --- /dev/null +++ b/utils/glcanvas/win/makefile.bcc @@ -0,0 +1,19 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Builds a BC++ 16-bit sample + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +WXDIR = $(WXWIN) + +TARGET=minimal +OBJECTS=$(TARGET).obj + +!include $(WXDIR)\src\makeprog.bcc + diff --git a/utils/glcanvas/win/makefile.g95 b/utils/glcanvas/win/makefile.g95 new file mode 100644 index 0000000000..98be5a9d86 --- /dev/null +++ b/utils/glcanvas/win/makefile.g95 @@ -0,0 +1,16 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows wxGLCanvas library Cygwin/Mingw32). + +WXDIR = ../../.. + +LIBTARGET=$(WXDIR)/lib/libglcanvas.a +OBJECTS = glcanvas.o + +include $(WXDIR)/src/makelib.g95 + diff --git a/utils/glcanvas/win/makefile.wat b/utils/glcanvas/win/makefile.wat new file mode 100644 index 0000000000..7b533107ee --- /dev/null +++ b/utils/glcanvas/win/makefile.wat @@ -0,0 +1,16 @@ +#!/binb/wmake.exe +# +# File: makefile.wat +# Author: Julian Smart +# Created: 1999 +# +# Makefile : Builds wxGLCanvas library for Watcom C++, WIN32 + +WXDIR = $(%WXWIN) + +OBJECTS=glcanvas.obj +LIBTARGET=$(WXDIR)\lib\glcanvas.lib + +!include $(WXDIR)\src\makelib.wat + + diff --git a/utils/ogl/samples/ogledit/Makefile b/utils/ogl/samples/ogledit/Makefile new file mode 100644 index 0000000000..d492ad28c4 --- /dev/null +++ b/utils/ogl/samples/ogledit/Makefile @@ -0,0 +1 @@ +include ../../../../install/unix/setup/general/makedirs diff --git a/utils/ogl/samples/ogledit/Makefile.in b/utils/ogl/samples/ogledit/Makefile.in new file mode 100644 index 0000000000..84755f1b63 --- /dev/null +++ b/utils/ogl/samples/ogledit/Makefile.in @@ -0,0 +1,29 @@ +# WXXT base directory +WXBASEDIR=@WXBASEDIR@ + +# set the OS type for compilation +OS=@OS@ +# compile a binary only +RULE=bin + +# define exexutable name +BIN_TARGET=ogledit +# define library sources +BIN_SRC=\ + ogledit.cpp\ + doc.cpp\ + view.cpp\ + palette.cpp + +#define library objects +BIN_OBJ=\ + $(BIN_CPP_SRC:.cpp=.o) + +# additional things needed to link +BIN_LINK=-lwx_ogl_gtk + +# additional things needed to compile +ADD_COMPILE=-I../../src + +# include the definitions now +include ../../../../../template.mak diff --git a/utils/ogl/samples/ogledit/makefile.b32 b/utils/ogl/samples/ogledit/makefile.b32 index fda48cda63..7ee48625c2 100644 --- a/utils/ogl/samples/ogledit/makefile.b32 +++ b/utils/ogl/samples/ogledit/makefile.b32 @@ -1,88 +1,18 @@ # -# File: makefile.bcc +# File: makefile.b32 # Author: Julian Smart -# Created: 1996 +# Created: 1999 # Updated: -# Copyright: (c) 1996 +# Copyright: # -# "%W% %G%" -# -# Makefile : Builds OGL example for BC++, 32-bit. - -!if "$(BCCDIR)" == "" -!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4 -!endif - -!if "$(WXWIN)" == "" -!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx -!endif - -!ifndef FINAL -FINAL=0 -!endif +# Makefile : Builds sample for 32-bit BC++ WXDIR = $(WXWIN) -!include $(WXDIR)\src\makeb32.env - -THISDIR = $(WXDIR)\utils\ogl\samples\ogledit - -OGLDIR = ..\.. # $(WXDIR)\utils\ogl # Command line too long! -OGLINC = $(OGLDIR)\src -OGLLIB = $(WXDIR)\lib\ogl.lib - -WXLIB = $(WXDIR)\lib\wx32.lib -LIBS=$(WXLIB) $(OGLLIB) cw32 import32 ole2w32 -INC=/I$(OGLINC) -CFG=$(WXDIR)\src\wxwin32.cfg - -!if "$(FINAL)" == "0" -LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib -OPT = -Od -DEBUG_FLAGS= -v -DDEBUG=$(DEBUG) -!else -LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib -OPT = -O2 -DEBUG_FLAGS = -DDEBUG=$(DEBUG) -!endif - -CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) - -OBJECTS = ogledit.obj doc.obj view.obj palette.obj - -all: ogl ogledit.exe - -ogl: - cd $(OGLDIR)\src - make -f makefile.b32 - cd $(THISDIR) - -ogledit.exe: $(WXLIB) $(OBJECTS) ogledit.def ogledit.res - tlink32 $(LINKFLAGS) @&&! -c0w32.obj $(OBJECTS) -ogledit -nul -$(LIBS) -ogledit.def -ogledit.res -! - -.$(SRCSUFF).obj: - bcc32 $(CPPFLAGS) $(INC) -c {$< } - -ogledit.obj: ogledit.$(SRCSUFF) - -doc.obj: doc.$(SRCSUFF) - -view.obj: view.$(SRCSUFF) -palette.obj: palette.$(SRCSUFF) +TARGET=ogledit +EXTRALIBS=$(WXDIR)\lib\ogl.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src +OBJECTS = $(TARGET).obj doc.obj view.obj palette.obj -ogledit.res : ogledit.rc $(WXDIR)\include\msw\wx.rc - brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa ogledit +!include $(WXDIR)\src\makeprog.b32 -clean: - -erase *.obj - -erase *.exe - -erase *.res - -erase *.map - -erase *.rws diff --git a/utils/ogl/samples/ogledit/makefile.bcc b/utils/ogl/samples/ogledit/makefile.bcc index 0b94f0ab24..171d966ebd 100644 --- a/utils/ogl/samples/ogledit/makefile.bcc +++ b/utils/ogl/samples/ogledit/makefile.bcc @@ -1,87 +1,21 @@ # # File: makefile.bcc # Author: Julian Smart -# Created: 1996 +# Created: 1998 # Updated: -# Copyright: (c) 1996 # -# "%W% %G%" -# -# Makefile : Builds OGL example for BC++, 16-bit. - -!if "$(BCCDIR)" == "" -!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4 -!endif +# Builds a BC++ 16-bit sample !if "$(WXWIN)" == "" !error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx !endif -!ifndef FINAL -FINAL=0 -!endif - WXDIR = $(WXWIN) -!include $(WXDIR)\src\makebcc.env - -THISDIR = $(WXDIR)\utils\ogl\samples\ogledit - -OGLDIR = $(WXDIR)\utils\ogl -OGLINC = $(OGLDIR)\src -OGLLIB = $(OGLDIR)\lib\ogl.lib - -WXLIB = $(WXDIR)\lib\wx.lib -LIBS=$(WXLIB) $(OGLLIB) mathwl cwl import -INC=/I$(OGLINC) -CFG=$(WXDIR)\src\wxwin.cfg - -!if "$(FINAL)" == "0" -LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib -OPT = -Od -DEBUG_FLAGS= -v -!else -LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib -OPT = -O2 -DEBUG_FLAGS = -!endif -CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) - -OBJECTS = ogledit.obj doc.obj view.obj palette.obj - -all: ogl ogledit.exe - -ogl: - cd $(OGLDIR)\src - make -f makefile.bcc - cd $(THISDIR) - -ogledit.exe: $(WXLIB) $(OBJECTS) ogledit.def ogledit.res - tlink $(LINKFLAGS) @&&! -c0wl.obj $(OBJECTS) -ogledit -nul -$(LIBS) -ogledit.def -! - rc -30 -K ogledit.res - -.$(SRCSUFF).obj: - bcc $(CPPFLAGS) $(INC) -c {$< } - -ogledit.obj: ogledit.$(SRCSUFF) - -doc.obj: doc.$(SRCSUFF) - -view.obj: view.$(SRCSUFF) -palette.obj: palette.$(SRCSUFF) +TARGET=ogledit +EXTRALIBS=$(WXDIR)\lib\ogl.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src +OBJECTS = $(TARGET).obj doc.obj view.obj palette.obj -ogledit.res : ogledit.rc $(WXDIR)\include\wx\msw\wx.rc - rc -r /i$(BCCDIR)\include /i$(WXDIR)\include ogledit +!include $(WXDIR)\src\makeprog.b32 -clean: - -erase *.obj - -erase *.exe - -erase *.res - -erase *.map - -erase *.rws diff --git a/utils/ogl/samples/ogledit/makefile.g95 b/utils/ogl/samples/ogledit/makefile.g95 new file mode 100644 index 0000000000..633e5b88e4 --- /dev/null +++ b/utils/ogl/samples/ogledit/makefile.g95 @@ -0,0 +1,18 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../../../.. + +TARGET=ogledit +EXTRACPPFLAGS=-I../../src +EXTRALIBS=-logl +OBJECTS = $(TARGET).o doc.o view.o palette.o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/utils/ogl/samples/studio/makefile.b32 b/utils/ogl/samples/studio/makefile.b32 new file mode 100644 index 0000000000..292366caa1 --- /dev/null +++ b/utils/ogl/samples/studio/makefile.b32 @@ -0,0 +1,19 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=studio +EXTRALIBS=$(WXDIR)\lib\ogl.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src +OBJECTS = $(TARGET).obj doc.obj shapes.obj symbols.obj view.obj cspalette.obj\ + mainfrm.obj project.obj dialogs.obj csprint.obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/utils/ogl/samples/studio/makefile.bcc b/utils/ogl/samples/studio/makefile.bcc new file mode 100644 index 0000000000..11f514391a --- /dev/null +++ b/utils/ogl/samples/studio/makefile.bcc @@ -0,0 +1,22 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Builds a BC++ 16-bit sample + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +WXDIR = $(WXWIN) + +TARGET=studio +EXTRALIBS=$(WXDIR)\lib\ogl.lib +EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src +OBJECTS = $(TARGET).obj doc.obj shapes.obj symbols.obj view.obj cspalette.obj\ + mainfrm.obj project.obj dialogs.obj csprint.obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/utils/ogl/samples/studio/makefile.g95 b/utils/ogl/samples/studio/makefile.g95 new file mode 100644 index 0000000000..2da54a18a9 --- /dev/null +++ b/utils/ogl/samples/studio/makefile.g95 @@ -0,0 +1,19 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../../../.. + +TARGET=studio +EXTRACPPFLAGS=-I../../src +EXTRALIBS=-logl +OBJECTS = $(TARGET).o doc.o shapes.o symbols.o view.o cspalette.o\ + mainfrm.o project.o dialogs.o csprint.o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/utils/ogl/src/basic.cpp b/utils/ogl/src/basic.cpp index 2ca8ddaee5..19426d340e 100644 --- a/utils/ogl/src/basic.cpp +++ b/utils/ogl/src/basic.cpp @@ -2007,7 +2007,7 @@ void wxShape::ReadAttributes(wxExpr *clause) if (brush_string == "") brush_string = "WHITE"; - if (pen_string[0] == '#') + if (pen_string.GetChar(0) == '#') { wxColour col(oglHexToColour(pen_string.After('#'))); m_pen = wxThePenList->FindOrCreatePen(col, pen_width, pen_style); @@ -2018,7 +2018,7 @@ void wxShape::ReadAttributes(wxExpr *clause) if (!m_pen) m_pen = wxBLACK_PEN; - if (brush_string[0] == '#') + if (brush_string.GetChar(0) == '#') { wxColour col(oglHexToColour(brush_string.After('#'))); m_brush = wxTheBrushList->FindOrCreateBrush(col, brush_style); diff --git a/utils/ogl/src/drawn.cpp b/utils/ogl/src/drawn.cpp index e473681512..7a41a3eb17 100644 --- a/utils/ogl/src/drawn.cpp +++ b/utils/ogl/src/drawn.cpp @@ -1158,16 +1158,16 @@ void wxOpPolyDraw::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) wxString hexString = expr->Nth(2)->StringValue(); while (i < m_noPoints) { - buf1[0] = hexString[bufPtr]; - buf1[1] = hexString[bufPtr + 1]; - buf1[2] = hexString[bufPtr + 2]; - buf1[3] = hexString[bufPtr + 3]; + buf1[0] = hexString[(size_t)bufPtr]; + buf1[1] = hexString[(size_t)(bufPtr + 1)]; + buf1[2] = hexString[(size_t)(bufPtr + 2)]; + buf1[3] = hexString[(size_t)(bufPtr + 3)]; buf1[4] = 0; - buf2[0] = hexString[bufPtr + 4]; - buf2[1] = hexString[bufPtr + 5]; - buf2[2] = hexString[bufPtr + 6]; - buf2[3] = hexString[bufPtr + 7]; + buf2[0] = hexString[(size_t)(bufPtr + 4)]; + buf2[1] = hexString[(size_t)(bufPtr + 5)]; + buf2[2] = hexString[(size_t)(bufPtr + 6)]; + buf2[3] = hexString[(size_t)(bufPtr + 7)]; buf2[4] = 0; bufPtr += 8; diff --git a/utils/ogl/src/makefile.b32 b/utils/ogl/src/makefile.b32 index c9acc471b1..0b5356ac42 100644 --- a/utils/ogl/src/makefile.b32 +++ b/utils/ogl/src/makefile.b32 @@ -1,106 +1,18 @@ # # File: makefile.b32 # Author: Julian Smart -# Created: 1996 +# Created: 1999 # Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh +# Copyright: # -# "%W% %G%" -# -# Makefile : Builds OGL for BC++, 32-bit. - -!if "$(BCCDIR)" == "" -!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4 -!endif - -!if "$(WXWIN)" == "" -!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx -!endif +# Makefile : Builds OGL library for 32-bit BC++ -# Change WXDIR to wherever wxWindows is found WXDIR = $(WXWIN) -!include $(WXDIR)\src\makeb32.env - -WXLIB = $(WXDIR)\lib\wx32.lib -WXINC = $(WXDIR)\include -CFG=$(WXWIN)\src\wxwin32.cfg - -OGLDIR = $(WXDIR)\utils\ogl -OGLLIB = $(WXDIR)\lib\ogl.lib -DOCDIR = $(OGLDIR)\docs - -INC=/DPROLOGIO=1 # /I$(WXDIR)\include\base /I$(WXDIR)\include\msw - -LIBS=$(WXLIB) $(OGLLIB) mathwl cwl import mathwl - -!ifndef FINAL -FINAL=0 -!endif - -!if "$(FINAL)" == "0" -LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib -OPT = -Od -DEBUG_FLAGS= -v -DDEBUG=$(DEBUG) -!else -LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib -OPT = -O2 -DEBUG_FLAGS = -DDEBUG=$(DEBUG) -!endif -CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) -CFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) +LIBTARGET=$(WXDIR)\lib\ogl.lib OBJECTS = basic.obj basic2.obj canvas.obj ogldiag.obj lines.obj misc.obj divided.obj constrnt.obj\ composit.obj drawn.obj bmpshape.obj mfutils.obj -all: $(OGLLIB) - -.$(SRCSUFF).obj: - bcc32 $(CPPFLAGS) $(INC) -c {$< } - -$(OGLLIB): $(OBJECTS) - erase $(OGLLIB) - tlib /P128 @&&! -$(OGLLIB) & -+$(OBJECTS:.obj =.obj +) -! - -# Making documents -docs: hlp -hlp: $(DOCDIR)/ogl.hlp -hlp32: $(DOCDIR)/hlp32/ogl.hlp -rtf: $(DOCDIR)/ogl.rtf - -$(DOCDIR)/ogl.hlp: $(DOCDIR)/ogl.rtf $(DOCDIR)/ogl.hpj - cd $(DOCDIR) - -erase ogl.ph - hc ogl - cd $(THISDIR) - -$(DOCDIR)/hlp32/ogl.hlp: $(DOCDIR)/hlp32/ogl.rtf $(DOCDIR)/hlp32/ogl.hpj - cd $(DOCDIR)/hlp32 - -erase ogl.ph - start /w hcw /c /e ogl.hpj - cd $(THISDIR) - -$(DOCDIR)/ogl.rtf: $(DOCDIR)/classes.tex $(DOCDIR)/intro.tex $(DOCDIR)/ogl.tex - cd $(DOCDIR) - start /w tex2rtf $(DOCDIR)/ogl.tex $(DOCDIR)/ogl.rtf -twice -winhelp - cd $(THISDIR) - -$(DOCDIR)/hlp32/ogl.rtf: $(DOCDIR)/classes.tex $(DOCDIR)/intro.tex $(DOCDIR)/ogl.tex - cd $(DOCDIR) - start /w tex2rtf $(DOCDIR)/ogl.tex $(DOCDIR)/hlp32/ogl.rtf -twice -winhelp -macros $(DOCDIR)/t2rtf32.ini - cd $(THISDIR) - -wordrtf: - cd $(DOCDIR) - -wx /W tex2rtf $(DOCDIR)/ogl.tex $(DOCDIR)/ogl.rtf -twice -rtf - cd $(THISDIR) - -clean: - -erase *.obj - -erase *.exe - -erase *.res - -erase ..\lib\*.lib $(OGLLIB) +!include $(WXDIR)\src\makelib.b32 diff --git a/utils/ogl/src/makefile.bcc b/utils/ogl/src/makefile.bcc index 92a3d67369..94177e6b17 100644 --- a/utils/ogl/src/makefile.bcc +++ b/utils/ogl/src/makefile.bcc @@ -1,105 +1,21 @@ # # File: makefile.bcc # Author: Julian Smart -# Created: 1996 +# Created: 1998 # Updated: -# Copyright: (c) 1996 # -# "%W% %G%" -# -# Makefile : Builds OGL for BC++, 16-bit. - -!if "$(BCCDIR)" == "" -!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4 -!endif +# Builds OGL library for BC++, 16-bit !if "$(WXWIN)" == "" !error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx !endif -# Change WXDIR to wherever wxWindows is found WXDIR = $(WXWIN) -!include $(WXDIR)\src\makebcc.env - -WXLIB = $(WXDIR)\lib\wx.lib -WXINC = $(WXDIR)\include -CFG=$(WXWIN)\src\wxwin.cfg - -OGLDIR = $(WXDIR)\utils\ogl -OGLLIB = $(OGLDIR)\lib\ogl.lib -DOCDIR = $(OGLDIR)\docs -INC=/DPROLOGIO=1 # /I$(WXDIR)\include\base /I$(WXDIR)\include\msw - -LIBS=$(WXLIB) $(OGLLIB) mathwl cwl import mathwl - -!ifndef FINAL -FINAL=0 -!endif - -!if "$(FINAL)" == "0" -LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib -OPT = -Od -DEBUG_FLAGS= -v -!else -LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib -OPT = -O2 -DEBUG_FLAGS= -!endif -CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) -CFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) +LIBTARGET=$(WXDIR)\lib\ogl.lib OBJECTS = basic.obj basic2.obj canvas.obj ogldiag.obj lines.obj misc.obj divided.obj constrnt.obj\ - composit.obj drawn.obj bitmap.obj mfutils.obj - -all: $(OGLLIB) - -.$(SRCSUFF).obj: - bcc $(CPPFLAGS) $(INC) -c {$< } - -$(OGLLIB): $(OBJECTS) - erase $(OGLLIB) - tlib /P128 @&&! -$(OGLLIB) & -+$(OBJECTS:.obj =.obj +) -! - -# Making documents -docs: hlp -hlp: $(DOCDIR)/ogl.hlp -hlp32: $(DOCDIR)/hlp32/ogl.hlp -rtf: $(DOCDIR)/ogl.rtf - -$(DOCDIR)/ogl.hlp: $(DOCDIR)/ogl.rtf $(DOCDIR)/ogl.hpj - cd $(DOCDIR) - -erase ogl.ph - hc ogl - cd $(THISDIR) - -$(DOCDIR)/hlp32/ogl.hlp: $(DOCDIR)/hlp32/ogl.rtf $(DOCDIR)/hlp32/ogl.hpj - cd $(DOCDIR)/hlp32 - -erase ogl.ph - start /w hcw /c /e ogl.hpj - cd $(THISDIR) - -$(DOCDIR)/ogl.rtf: $(DOCDIR)/classes.tex $(DOCDIR)/intro.tex $(DOCDIR)/ogl.tex - cd $(DOCDIR) - start /w tex2rtf $(DOCDIR)/ogl.tex $(DOCDIR)/ogl.rtf -twice -winhelp - cd $(THISDIR) - -$(DOCDIR)/hlp32/ogl.rtf: $(DOCDIR)/classes.tex $(DOCDIR)/intro.tex $(DOCDIR)/ogl.tex - cd $(DOCDIR) - start /w tex2rtf $(DOCDIR)/ogl.tex $(DOCDIR)/hlp32/ogl.rtf -twice -winhelp -macros $(DOCDIR)/t2rtf32.ini - cd $(THISDIR) - -wordrtf: - cd $(DOCDIR) - -wx /W tex2rtf $(DOCDIR)/ogl.tex $(DOCDIR)/ogl.rtf -twice -rtf - cd $(THISDIR) + composit.obj drawn.obj bmpshape.obj mfutils.obj -clean: - -erase *.obj - -erase *.exe - -erase *.res - -erase ..\lib\*.lib +!include $(WXDIR)\src\makelib.bcc diff --git a/utils/ogl/src/makefile.g95 b/utils/ogl/src/makefile.g95 new file mode 100644 index 0000000000..12a93aeac7 --- /dev/null +++ b/utils/ogl/src/makefile.g95 @@ -0,0 +1,17 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows OGL library Cygwin/Mingw32). + +WXDIR = ../../.. + +LIBTARGET=$(WXDIR)/lib/libogl.a +OBJECTS = basic.o basic2.o canvas.o ogldiag.o lines.o misc.o divided.o constrnt.o\ + composit.o drawn.o bmpshape.o mfutils.o + +include $(WXDIR)/src/makelib.g95 + diff --git a/utils/tex2rtf/src/makefile.g95 b/utils/tex2rtf/src/makefile.g95 index d5a033d7c4..513c166910 100644 --- a/utils/tex2rtf/src/makefile.g95 +++ b/utils/tex2rtf/src/makefile.g95 @@ -1,61 +1,16 @@ # -# File: makefile.g95 -# Author: Julian Smart -# Created: 1996 -# Updated: +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 # -# "%W% %G%" -# -# Makefile for Tex2RTF (GNU-WIN32) +# Makefile for wxWindows sample (Cygwin/Mingw32). WXDIR = ../../.. -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/makeg95.env - -OBJECTS = $(OBJDIR)/tex2rtf.$(OBJSUFF) $(OBJDIR)/texutils.$(OBJSUFF) $(OBJDIR)/tex2any.$(OBJSUFF)\ - $(OBJDIR)/htmlutil.$(OBJSUFF) $(OBJDIR)/rtfutils.$(OBJSUFF) $(OBJDIR)/xlputils.$(OBJSUFF)\ - $(OBJDIR)/table.$(OBJSUFF) $(OBJDIR)/readshg.$(OBJSUFF)\ - $(OBJDIR)/tex2rtf_resources.$(OBJSUFF) - -all: $(OBJDIR) tex2rtf$(GUISUFFIX)$(EXESUFF) - -INC = $(COMPPATHS) -I$(WXDIR)/include/msw -I$(WXDIR)/include/base -I../../wxhelp/src -CPPFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) -DDEBUG='$(DEBUG)' $(DEBUGFLAGS) $(WARN) $(OPT) - -$(OBJDIR): - mkdir $(OBJDIR) - -tex2rtf$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB) - $(CC) $(LDFLAGS) -o tex2rtf$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS) - -$(OBJDIR)/tex2rtf.$(OBJSUFF): tex2rtf.$(SRCSUFF) tex2rtf.h tex2any.h - $(CC) -c $(CPPFLAGS) -o $@ tex2rtf.$(SRCSUFF) - -$(OBJDIR)/texutils.$(OBJSUFF): texutils.$(SRCSUFF) tex2rtf.h tex2any.h - $(CC) -c $(CPPFLAGS) -o $@ texutils.$(SRCSUFF) - -$(OBJDIR)/tex2any.$(OBJSUFF): tex2any.$(SRCSUFF) tex2any.h - $(CC) -c $(CPPFLAGS) -o $@ tex2any.$(SRCSUFF) - -$(OBJDIR)/htmlutil.$(OBJSUFF): htmlutil.$(SRCSUFF) tex2any.h - $(CC) -c $(CPPFLAGS) -o $@ htmlutil.$(SRCSUFF) - -$(OBJDIR)/rtfutils.$(OBJSUFF): rtfutils.$(SRCSUFF) tex2any.h - $(CC) -c $(CPPFLAGS) -o $@ rtfutils.$(SRCSUFF) - -$(OBJDIR)/xlputils.$(OBJSUFF): xlputils.$(SRCSUFF) tex2any.h - $(CC) -c $(CPPFLAGS) -o $@ xlputils.$(SRCSUFF) - -$(OBJDIR)/table.$(OBJSUFF): table.$(SRCSUFF) tex2any.h - $(CC) -c $(CPPFLAGS) -o $@ table.$(SRCSUFF) - -$(OBJDIR)/readshg.$(OBJSUFF): readshg.$(SRCSUFF) readshg.h - $(CC) -c $(CPPFLAGS) -o $@ readshg.$(SRCSUFF) +TARGET=tex2rtf +OBJECTS = $(TARGET).o texutils.o tex2any.o htmlutil.o rtfutils.o xlputils.o table.o readshg.o -$(OBJDIR)/tex2rtf_resources.o: tex2rtf.rc - $(RESCOMP) -i tex2rtf.rc -o $(OBJDIR)/tex2rtf_resources.o $(RESFLAGS) +include $(WXDIR)/src/makeprog.g95 -clean: - rm -f $(OBJECTS) tex2rtf$(GUISUFFIX).exe core *.rsc *.res diff --git a/utils/tex2rtf/src/texutils.cpp b/utils/tex2rtf/src/texutils.cpp index ea888383fe..b3b64661b8 100644 --- a/utils/tex2rtf/src/texutils.cpp +++ b/utils/tex2rtf/src/texutils.cpp @@ -402,11 +402,11 @@ void WriteTexReferences(char *filename) void ReadTexReferences(char *filename) { -#if !wxUSE_IOSTREAMH && __WXMSW__ + if (!wxFileExists(filename)) + return; + ifstream istr(filename, ios::in); -#else - ifstream istr(filename, ios::nocreate | ios::in); -#endif + if (istr.bad()) return; char label[100]; @@ -569,12 +569,11 @@ void BibReadValue(istream& istr, char *buffer, bool ignoreBraces = TRUE, bool ReadBib(char *filename) { + if (!wxFileExists(filename)) + return FALSE; + char buf[300]; -#if !wxUSE_IOSTREAMH && __WXMSW__ ifstream istr(filename, ios::in); -#else - ifstream istr(filename, ios::nocreate | ios::in); -#endif if (istr.bad()) return FALSE; BibLine = 1; @@ -1291,11 +1290,11 @@ char *RegisterSetting(char *settingName, char *settingValue, bool interactive) bool ReadCustomMacros(char *filename) { -#if !wxUSE_IOSTREAMH && __WXMSW__ + if (!wxFileExists(filename)) + return FALSE; + ifstream istr(filename, ios::in); -#else - ifstream istr(filename, ios::nocreate | ios::in); -#endif + if (istr.bad()) return FALSE; CustomMacroList.Clear(); diff --git a/utils/wxtree/src/makefile.b32 b/utils/wxtree/src/makefile.b32 index 6f257ba8de..fe9d9fb3e3 100644 --- a/utils/wxtree/src/makefile.b32 +++ b/utils/wxtree/src/makefile.b32 @@ -1,18 +1,16 @@ # # File: makefile.b32 -# Author: Patrick Halke -# Created: 1995 +# Author: Julian Smart +# Created: 1999 # Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh # -# "%W% %G%" # -# Makefile : Builds 32bit wxtree library for 32-bit BC++ +# Makefile : Builds wxTree sample for 32-bit BC++ WXDIR = $(WXWIN) TARGET=test -OBJECTS=$(TARGET) +OBJECTS=$(TARGET).obj wxtree.obj !include $(WXDIR)\src\makeprog.b32 diff --git a/utils/wxtree/src/makefile.bcc b/utils/wxtree/src/makefile.bcc index df91939532..69a61d94eb 100644 --- a/utils/wxtree/src/makefile.bcc +++ b/utils/wxtree/src/makefile.bcc @@ -1,96 +1,16 @@ # # File: makefile.bcc # Author: Julian Smart -# Created: 1993 +# Created: 1999 # Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh # -# "%W% %G%" # -# Makefile : Builds tree library and example (DOS). +# Makefile : Builds wxTree sample for 16-bit BC++ -!if "$(BCCDIR)" == "" -!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4 -!endif - -!if "$(WXWIN)" == "" -!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx -!endif - -# Change WXDIR to wherever wxWindows is found WXDIR = $(WXWIN) -!include $(WXDIR)\src\makebcc.env - -WXLIB = $(WXDIR)\lib\wx.lib -WXINC = $(WXDIR)\include -CFG=$(WXWIN)\src\wxwin.cfg - -TREEDIR = $(WXDIR)\utils\wxtree -TREELIB = $(TREEDIR)\lib\wxtree.lib - -WXHELPDIR = $(WXDIR)\utils\wxhelp -TEX2RTFDIR = $(WXDIR)\utils\tex2rtf -DOCDIR = $(WXHELPDIR)\docs - -# Default is to output RTF for WinHelp -!ifndef WINHELP -WINHELP=-winhelp -!endif - -INC=/I$(WXDIR)\include\base /I$(WXDIR)\include\msw - -LIBS=$(WXLIB) $(TREELIB) mathwl cwl import mathwl - -!ifndef FINAL -FINAL=0 -!endif - -!if "$(FINAL)" == "0" -LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib -OPT = -Od -DEBUG_FLAGS= -v -!else -LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib -OPT = -O2 -DEBUG_FLAGS= -!endif -CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) -CFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) - -HEADERS = wxtree.h -SOURCES = wxtree.$(SRCSUFF) -OBJECTS = wxtree.obj - -all: $(TREELIB) - -.$(SRCSUFF).obj: - bcc $(CPPFLAGS) $(INC) -c {$< } - -$(TREELIB): $(OBJECTS) - erase $(TREELIB) - tlib /P128 @&&! -$(TREELIB) & -+$(OBJECTS:.obj =.obj +) -! - -test.obj: test.$(SRCSUFF) - -test.res : test.rc $(WXDIR)\include\msw\wx.rc - rc /i$(BCCDIR)\include /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa -r test -test.exe: test.obj test.def test.res $(TREELIB) - tlink $(LINKFLAGS) @&&! -c0wl.obj test.obj -test -nul -$(LIBS) -test.def -! - rc -K test.res +TARGET=test +OBJECTS=$(TARGET).obj wxtree.obj -clean: - -erase *.obj - -erase *.exe - -erase *.res - -erase ..\lib\*.lib +!include $(WXDIR)\src\makeprog.bcc diff --git a/utils/wxtree/src/makefile.g95 b/utils/wxtree/src/makefile.g95 index a7b7f866c1..38c05afa70 100644 --- a/utils/wxtree/src/makefile.g95 +++ b/utils/wxtree/src/makefile.g95 @@ -1,48 +1,16 @@ # -# File: makefile.g95 -# Author: Julian Smart -# Created: 1996 +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 # -# "%W% %G%" -# -# Makefile : Builds wxTree library and example under GNU-WIN32 -# -WXDIR = ../../.. -include $(WXDIR)/src/makeg95.env - -PROPDIR = $(WXDIR)/utils/wxtree -TREELIB = $(PROPDIR)/lib/$(LIBPREFIX)wxtree.$(LIBSUFF) -THISDIR = $(PROPDIR)/src - -OBJECTS = $(OBJDIR)/wxtree.$(OBJSUFF) -TESTOBJECTS = $(OBJDIR)/test.$(OBJSUFF) $(OBJDIR)/test_resources.$(OBJSUFF) - -LDFLAGS = -Wl,--subsystem,windows -mwindows -L$(WXDIR)/lib -L../lib -LDLIBS=-lwxtree $(LIBS) +# Makefile for wxWindows sample (Cygwin/Mingw32). -all: $(OBJDIR) $(TREELIB) - -test: $(OBJDIR) test.exe - -$(OBJDIR): - mkdir $(OBJDIR) - -$(TREELIB): $(OBJECTS) - rm -f $@ - ar $(AROPTIONS) $@ $(OBJECTS) - $(RANLIB) $@ - -$(OBJDIR)/test.$(OBJSUFF): test.h test.$(SRCSUFF) $(TREELIB) - $(CC) -c $(CPPFLAGS) -o $@ test.$(SRCSUFF) - -test.exe: $(TESTOBJECTS) - $(CC) $(LDFLAGS) -o test$(GUISUFFIX)$(EXESUFF) $(TESTOBJECTS) $(LDLIBS) +WXDIR = ../../.. -$(OBJDIR)/wxtree.$(OBJSUFF): wxtree.h wxtree.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ wxtree.$(SRCSUFF) +TARGET=test +OBJECTS = $(TARGET).o wxtree.o -$(OBJDIR)/test_resources.o: test.rc - $(RESCOMP) -i test.rc -o $(OBJDIR)/test_resources.o $(RESFLAGS) +include $(WXDIR)/src/makeprog.g95 -clean: - rm -f *.$(OBJSUFF) $(TREELIB) objects/test.o *.exe *.res *.map *.rsc -- 2.45.2