]> git.saurik.com Git - wxWidgets.git/commitdiff
no message
authorDavid Webster <Dave.Webster@bhmi.com>
Thu, 14 Oct 1999 22:36:24 +0000 (22:36 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Thu, 14 Oct 1999 22:36:24 +0000 (22:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3997 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

31 files changed:
include/wx/colordlg.h
include/wx/os2/app.h
include/wx/os2/dc.h
include/wx/os2/dcmemory.h
include/wx/os2/dcprint.h
include/wx/os2/dcscreen.h
include/wx/os2/dialog.h
include/wx/os2/dirdlg.h
include/wx/os2/filedlg.h
include/wx/os2/frame.h
include/wx/os2/pnghand.h [new file with mode: 0644]
include/wx/os2/pngread.h
include/wx/os2/setup.h
include/wx/os2/setup0.h
src/os2/data.cpp
src/os2/dc.cpp
src/os2/dcclient.cpp
src/os2/dcmemory.cpp
src/os2/dcprint.cpp
src/os2/dcscreen.cpp
src/os2/dialog.cpp
src/os2/dirdlg.cpp
src/os2/filedlg.cpp
src/os2/main.cpp
src/os2/makefile.va
src/os2/notebook.cpp
src/os2/ownerdrw.cpp
src/os2/palette.cpp
src/os2/pen.cpp
src/os2/pnghand.cpp [new file with mode: 0644]
src/os2/pngread.cpp [deleted file]

index 75e6b83f7d853b260de8f918209ff5e26307f2ac..4f322491404907a7ca9e0856390f9a2a2daafc9b 100644 (file)
@@ -12,7 +12,7 @@
 #elif defined(__WXMAC__)
 #include "wx/generic/colrdlgg.h"
 #elif defined(__WXPM__)
-#include "wx/os2/colordlg.h"
+#include "wx/generic/colrdlgg.h"
 #elif defined(__WXSTUBS__)
 #include "wx/generic/colrdlgg.h"
 #endif
index 4b0c4d52a3f9f5e5e9959cc0420bfa65f4e9a0db..d919cdc63a621773f825fdfa17dbdcf24d60113f 100644 (file)
@@ -101,14 +101,6 @@ protected:
     DECLARE_EVENT_TABLE()
 };
 
-#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
-int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine,
-                    int nCmdShow, bool enterLoop = TRUE);
-#else
-int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance);
-#endif
-
-
 #endif
     // _WX_APP_H_
 
index d3181b22096fc9f4b013ae1f9c93116082d8a6fe..ae043b798928898cb3691052af9445b34f8f879b 100644 (file)
 #ifndef _WX_DC_H_
 #define _WX_DC_H_
 
-#ifdef __GNUG__
-#pragma interface "dc.h"
-#endif
+#include "wx/defs.h"
+#include "wx/dc.h"
 
-#include "wx/window.h"
-#include "wx/pen.h"
-#include "wx/brush.h"
-#include "wx/icon.h"
-#include "wx/font.h"
-#include "wx/gdicmn.h"
-
-//-----------------------------------------------------------------------------
-// constants
-//-----------------------------------------------------------------------------
-
-#ifndef MM_TEXT
-#define MM_TEXT               0
-#define MM_ISOTROPIC          1
-#define MM_ANISOTROPIC        2
-#define MM_LOMETRIC           3
-#define MM_HIMETRIC           4
-#define MM_TWIPS              5
-#define MM_POINTS             6
-#define MM_METRIC             7
-#endif
+// ---------------------------------------------------------------------------
+// macros
+// ---------------------------------------------------------------------------
+
+// Logical to device
+// Absolute
+#define XLOG2DEV(x) (x)
+#define YLOG2DEV(y) (y)
+
+// Relative
+#define XLOG2DEVREL(x) (x)
+#define YLOG2DEVREL(y) (y)
+
+// Device to logical
+// Absolute
+#define XDEV2LOG(x) (x)
+
+#define YDEV2LOG(y) (y)
+
+// Relative
+#define XDEV2LOGREL(x) (x)
+#define YDEV2LOGREL(y) (y)
+
+/*
+ * Have the same macros as for XView but not for every operation:
+ * just for calculating window/viewport extent (a better way of scaling).
+ */
+
+// Logical to device
+// Absolute
+#define MS_XLOG2DEV(x) LogicalToDevice(x)
+
+#define MS_YLOG2DEV(y) LogicalToDevice(y)
+
+// Relative
+#define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
+#define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
+
+// Device to logical
+// Absolute
+#define MS_XDEV2LOG(x) DeviceToLogicalX(x)
+
+#define MS_YDEV2LOG(y) DeviceToLogicalY(y)
 
-//-----------------------------------------------------------------------------
-// global variables
-//-----------------------------------------------------------------------------
+// Relative
+#define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
+#define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
 
-extern int wxPageNumber;
+#define YSCALE(y) (yorigin - (y))
 
-//-----------------------------------------------------------------------------
-// wxDC
-//-----------------------------------------------------------------------------
+#define     wx_round(a)    (int)((a)+.5)
 
-class WXDLLEXPORT wxDC: public wxDCBase
+class WXDLLEXPORT wxDC : public wxDCBase
 {
-  DECLARE_ABSTRACT_CLASS(wxDC)
-
-  public:
-
-    wxDC(void);
-    ~wxDC(void);
-
-    virtual void BeginDrawing(void) { };
-    virtual void EndDrawing(void) { };
-
-//-----------------------------------------------------------------------------
-// Pure virtuals from wxDCBase that need defining
-//-----------------------------------------------------------------------------
-    virtual bool   CanDrawBitmap(void) const { return TRUE; };
-    virtual bool   CanGetTextExtent(void) const { return TRUE; };
-    virtual int    GetDepth(void) const;
-    virtual wxSize GetPPI(void) const;
-    virtual void   GetTextExtent( const wxString& string
-                                 ,long*           width
-                                 ,long*           height
-                                 ,long*           descent = NULL
-                                 ,long*           externalLeading = NULL
-                                 ,wxFont*         theFont = NULL
-                                ) const;
-    virtual long   GetCharWidth(void) const;
-    virtual long   GetCharHeight(void) const;
-    virtual void   Clear(void);
-    virtual void   SetFont(const wxFont& font);
-    virtual void   SetPen(const wxPen& pen);
-    virtual void   SetBrush(const wxBrush& brush);
-    virtual void   SetBackground(const wxBrush& brush);
-    virtual void   SetLogicalFunction(int function);
-    virtual void   SetBackgroundMode(int mode);
-    virtual void   SetPalette(const wxPalette& palette);
-    virtual void   SetMapMode(int mode);
-    virtual void   DestroyClippingRegion(void);
-    virtual void   SetUserScale(double x, double y);
-    virtual void   SetLogicalOrigin(long x, long y);
-    virtual void   SetDeviceOrigin(long x, long y);
-    virtual void   SetAxisOrientation(bool xLeftRight, bool yBottomUp);
-
-    virtual void   DoFloodFill( long x
-                               ,long y
-                               ,const wxColour& col
-                               ,int style = wxFLOOD_SURFACE
-                              );
-    virtual bool   DoGetPixel(long x, long y, wxColour *col) const;
-    virtual void   DoDrawPoint(long x, long y);
-    virtual void   DoDrawLine(long x1, long y1, long x2, long y2);
-    virtual void   DoDrawArc(long x1, long y1,
-                             long x2, long y2,
-                             long xc, long yc
-                            );
-    virtual void   DoDrawEllipticArc( long x, long y
-                                     ,long w, long h
-                                     ,double sa, double ea
-                                    );
-    virtual void   DoDrawRectangle(long x, long y, long width, long height);
-    virtual void   DoDrawRoundedRectangle( long x, long y
-                                          ,long width, long height
-                                          ,double radius
-                                         );
-    virtual void   DoDrawEllipse(long x, long y, long width, long height);
-    virtual void   DoCrossHair(long x, long y);
-    virtual void   DoDrawIcon(const wxIcon& icon, long x, long y);
-    virtual void   DoDrawBitmap( const wxBitmap &bmp
-                                ,long x, long y
-                                ,bool useMask = FALSE
-                               );
-    virtual void   DoDrawText(const wxString& text, long x, long y);
-    virtual bool   DoBlit( long xdest, long ydest
-                          ,long width, long height
-                          ,wxDC *source
-                          ,long xsrc, long ysrc
-                          ,int rop = wxCOPY, bool useMask = FALSE
-                         );
-    virtual void   DoGetSize(int *width, int *height) const;
-    virtual void   DoGetSizeMM(int* width, int* height) const;
-    virtual void   DoDrawLines( int n, wxPoint points[]
-                               ,long xoffset, long yoffset
-                              );
-    virtual void   DoDrawPolygon( int n, wxPoint points[]
-                                 ,long xoffset, long yoffset
-                                 ,int fillStyle = wxODDEVEN_RULE
-                                );
-    virtual void   DoSetClippingRegionAsRegion(const wxRegion& region);
-    virtual void   DoSetClippingRegion( long x, long y
-                                       ,long width, long height
-                                      );
-#if wxUSE_SPLINES
-    virtual void DoDrawSpline(wxList *points);
-#endif
+    DECLARE_DYNAMIC_CLASS(wxDC)
 
-    // OS2-specific member variables
-    int               m_windowExtX;
-    int               m_windowExtY;
+public:
+    wxDC();
+    ~wxDC();
+
+    // implement base class pure virtuals
+    // ----------------------------------
+
+    virtual void Clear();
+
+    virtual bool StartDoc(const wxString& message);
+    virtual void EndDoc();
+
+    virtual void StartPage();
+    virtual void EndPage();
+
+    virtual void SetFont(const wxFont& font);
+    virtual void SetPen(const wxPen& pen);
+    virtual void SetBrush(const wxBrush& brush);
+    virtual void SetBackground(const wxBrush& brush);
+    virtual void SetBackgroundMode(int mode);
+    virtual void SetPalette(const wxPalette& palette);
+
+    virtual void DestroyClippingRegion();
+
+    virtual long GetCharHeight() const;
+    virtual long GetCharWidth() const;
+    virtual void GetTextExtent(const wxString& string,
+                               long *x, long *y,
+                               long *descent = NULL,
+                               long *externalLeading = NULL,
+                               wxFont *theFont = NULL) const;
 
-//-----------------------------------------------------------------------------
-// Other virtuals from wxDCBase that are overridden here
-//-----------------------------------------------------------------------------
+    virtual bool CanDrawBitmap() const;
+    virtual bool CanGetTextExtent() const;
+    virtual int GetDepth() const;
+    virtual wxSize GetPPI() const;
 
-    virtual void SetLogicalScale( double x, double y );
+    virtual void SetMapMode(int mode);
+    virtual void SetUserScale(double x, double y);
+    virtual void SetSystemScale(double x, double y);
+    virtual void SetLogicalScale(double x, double y);
+    virtual void SetLogicalOrigin(long x, long y);
+    virtual void SetDeviceOrigin(long x, long y);
+    virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
+    virtual void SetLogicalFunction(int function);
 
-//-----------------------------------------------------------------------------
-// Our own new stuff
-//-----------------------------------------------------------------------------
-    virtual void SetInternalDeviceOrigin( long x, long y );
-    virtual void GetInternalDeviceOrigin( long *x, long *y );
+    // implementation from now on
+    // --------------------------
 
     virtual void SetRop(WXHDC cdc);
     virtual void DoClipping(WXHDC cdc);
@@ -173,36 +134,79 @@ class WXDLLEXPORT wxDC: public wxDCBase
         m_bOwnsDC = bOwnsDC;
     }
 
-private:
-
-#if WXWIN_COMPATIBILITY
-    // function hiding warning supression
-    virtual void   GetTextExtent( const wxString& string
-                                 ,long*           width
-                                 ,long*           height
-                                 ,long*           descent = NULL
-                                 ,long*           externalLeading = NULL
-                                 ,wxFont*         theFont = NULL
-                                 ,bool            use16 = FALSE
-                                ) const
-    { wxDCBase::GetTextExtent(string, width, height, descent, externalLeading, theFont, use16); };
-#endif
-
 protected:
+    virtual void DoFloodFill(long x, long y, const wxColour& col,
+                             int style = wxFLOOD_SURFACE);
+
+    virtual bool DoGetPixel(long x, long y, wxColour *col) const;
+
+    virtual void DoDrawPoint(long x, long y);
+    virtual void DoDrawLine(long x1, long y1, long x2, long y2);
+
+    virtual void DoDrawArc(long x1, long y1,
+                           long x2, long y2,
+                           long xc, long yc);
+    virtual void DoDrawEllipticArc(long x, long y, long w, long h,
+                                   double sa, double ea);
+
+    virtual void DoDrawRectangle(long x, long y, long width, long height);
+    virtual void DoDrawRoundedRectangle(long x, long y,
+                                        long width, long height,
+                                        double radius);
+    virtual void DoDrawEllipse(long x, long y, long width, long height);
+
+    virtual void DoCrossHair(long x, long y);
+
+    virtual void DoDrawIcon(const wxIcon& icon, long x, long y);
+    virtual void DoDrawBitmap(const wxBitmap &bmp, long x, long y,
+                              bool useMask = FALSE);
+
+    virtual void DoDrawText(const wxString& text, long x, long y);
+
+    virtual bool DoBlit(long xdest, long ydest, long width, long height,
+                        wxDC *source, long xsrc, long ysrc,
+                        int rop = wxCOPY, bool useMask = FALSE);
+
+    // this is gnarly - we can't even call this function DoSetClippingRegion()
+    // because of virtual function hiding
+    virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
+    virtual void DoSetClippingRegion(long x, long y,
+                                     long width, long height);
+    virtual void DoGetClippingRegion(long *x, long *y,
+                                     long *width, long *height)
+    {
+        GetClippingBox(x, y, width, height);
+    }
 
-    // ------------------------------------------------------------------------
-    // Some additional data we need
-    // ------------------------------------------------------------------------
+    virtual void DoGetSize(int *width, int *height) const;
+    virtual void DoGetSizeMM(int* width, int* height) const;
+
+    virtual void DoDrawLines(int n, wxPoint points[],
+                             long xoffset, long yoffset);
+    virtual void DoDrawPolygon(int n, wxPoint points[],
+                               long xoffset, long yoffset,
+                               int fillStyle = wxODDEVEN_RULE);
+
+#if wxUSE_SPLINES
+    virtual void DoDrawSpline(wxList *points);
+#endif // wxUSE_SPLINES
+
+    // OS2-specific member variables
+    int               m_windowExtX;
+    int               m_windowExtY;
+
+    // the window associated with this DC (may be NULL)
+    wxWindow         *m_canvas;
 
-    // Owner canvas and selected in bitmap (if bitmap is GDI object selected)
-    wxWindow*         m_canvas;
     wxBitmap          m_selectedBitmap;
 
+    // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
+    bool              m_bOwnsDC:1;
+
     // our HDC and its usage count: we only free it when the usage count drops
     // to 0
     WXHDC             m_hDC;
     int               m_hDCCount;
-    bool              m_bOwnsDC:1;
 
     // Store all old GDI objects when do a SelectObject, so we can select them
     // back in (this unselecting user's objects) so we can safely delete the
@@ -213,6 +217,5 @@ protected:
     WXHFONT           m_oldFont;
     WXHPALETTE        m_oldPalette;
 };
-
 #endif
     // _WX_DC_H_
index f2db0f212c9b556a0329ecefd0e13eb92e48e463..85191f6e45ae4c107043508dfe8215d579ce405b 100644 (file)
 #ifndef _WX_DCMEMORY_H_
 #define _WX_DCMEMORY_H_
 
-#ifdef __GNUG__
-#pragma interface "dcmemory.h"
-#endif
-
 #include "wx/dcclient.h"
 
-class WXDLLEXPORT wxMemoryDC: public wxPaintDC
+class WXDLLEXPORT wxMemoryDC: public wxDC
 {
   DECLARE_DYNAMIC_CLASS(wxMemoryDC)
 
@@ -28,11 +24,7 @@ class WXDLLEXPORT wxMemoryDC: public wxPaintDC
 
     ~wxMemoryDC(void);
     virtual void SelectObject( const wxBitmap& bitmap );
-    void GetSize( int *width, int *height ) const;
-
-  private:
-    friend wxPaintDC;
-    wxBitmap  m_selected;
+    virtual void DoGetSize( int *width, int *height ) const;
 };
 
 #endif
index 9bc20098bc9f1222e26e08a0dc027279a6f3fac8..851b0ace6275f0d1f71631ed6cf8ce0789680591 100644 (file)
 #ifndef _WX_DCPRINT_H_
 #define _WX_DCPRINT_H_
 
-#ifdef __GNUG__
-#pragma interface "dcprint.h"
-#endif
-
 #if wxUSE_PRINTING_ARCHITECTURE
 
 #include "wx/dc.h"
index e04b450f69941e8ce90f5ac3e2da5dfc90f3a923..44b929bc04b7d76cd2dd518b20021cb96a601621 100644 (file)
@@ -1,12 +1,12 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dcscreen.h
 // Purpose:     wxScreenDC class
-// Author:      AUTHOR
+// Author:      David Webster
 // Modified by:
-// Created:     ??/??/98
+// Created:     10/14/99
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
-// Licence:    wxWindows licence
+// Copyright:   (c) David Webster
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #ifndef _WX_DCSCREEN_H_
index d4d91e380e94fb1426ee1519293492ed41346e2b..5bdea1a1d4b084a230f13ecb6e8f286ca5a529be 100644 (file)
@@ -1,21 +1,17 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dialog.h
 // Purpose:     wxDialog class
-// Author:      AUTHOR
+// Author:      David Webster
 // Modified by:
-// Created:     ??/??/98
+// Created:     10/14/99
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
-// Licence:    wxWindows licence
+// Copyright:   (c) David Webster
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #ifndef _WX_DIALOG_H_
 #define _WX_DIALOG_H_
 
-#ifdef __GNUG__
-#pragma interface "dialog.h"
-#endif
-
 #include "wx/panel.h"
 
 WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr;
@@ -69,18 +65,20 @@ public:
 
     ~wxDialog();
 
-// ---------------------------------------------------------------------------
-//  Virtuals
-// ---------------------------------------------------------------------------
-
     virtual bool Destroy();
+
     virtual void DoSetClientSize(int width, int height);
+
     virtual void GetPosition(int *x, int *y) const;
 
     bool Show(bool show);
     bool IsShown() const;
     void Iconize(bool iconize);
 
+#if WXWIN_COMPATIBILITY
+    bool Iconized() const { return IsIconized(); };
+#endif
+
     virtual bool IsIconized() const;
     void         Fit();
 
index 44f96238e2c21a0ce0046e0f1642d0cac1aa141e..677dd03e76ec1c0f6713a06e3906250979576f61 100644 (file)
@@ -1,21 +1,17 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dirdlg.h
 // Purpose:     wxDirDialog class
-// Author:      AUTHOR
+// Author:      David Webster
 // Modified by:
-// Created:     ??/??/98
+// Created:     10/14/99
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
-// Licence:    wxWindows licence
+// Copyright:   (c) David Webster
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #ifndef _WX_DIRDLG_H_
 #define _WX_DIRDLG_H_
 
-#ifdef __GNUG__
-#pragma interface "dirdlg.h"
-#endif
-
 #include "wx/dialog.h"
 
 WXDLLEXPORT_DATA(extern const char*) wxFileSelectorPromptStr;
index 5fc4836b57d86e271a1d64a201c6090cf65484dd..134f26b77a720820176e92a5ec11dfe04a83d6a6 100644 (file)
 #ifndef _WX_FILEDLG_H_
 #define _WX_FILEDLG_H_
 
-#ifdef __GNUG__
-#pragma interface "filedlg.h"
-#endif
-
 #include "wx/dialog.h"
 
 /*
index 042e3504dbcc7f0b83f92100736407d478b28bf6..f6ed0488a03c1503ac43a66301d3dd484fecec99 100644 (file)
 #ifndef _WX_FRAME_H_
 #define _WX_FRAME_H_
 
-#ifdef __GNUG__
-#pragma interface "frame.h"
-#endif
-
 #include "wx/window.h"
 #include "wx/toolbar.h"
 #include "wx/os2/accel.h"
@@ -62,9 +58,6 @@ public:
     virtual void ClientToScreen(int *x, int *y) const;
     virtual void ScreenToClient(int *x, int *y) const;
 
-    void SetClientSize(int width, int height);
-    void GetClientSize(int *width, int *height) const;
-
     void OnSize(wxSizeEvent& event);
     void OnMenuHighlight(wxMenuEvent& event);
     void OnActivate(wxActivateEvent& event);
@@ -74,7 +67,6 @@ public:
     bool Show(bool show);
 
     void DetachMenuBar();
-
     // Set menu bar
     void SetMenuBar(wxMenuBar *menu_bar);
     virtual wxMenuBar *GetMenuBar() const ;
diff --git a/include/wx/os2/pnghand.h b/include/wx/os2/pnghand.h
new file mode 100644 (file)
index 0000000..373ab86
--- /dev/null
@@ -0,0 +1,37 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        pnghand.h
+// Purpose:     PNG bitmap handler
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Microsoft, Julian Smart
+// Licence:    wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma interface "pnghand.h"
+#endif
+
+#ifndef _WX_PNGHAND_H_
+#define _WX_PNGHAND_H_
+
+class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxPNGFileHandler)
+public:
+  inline wxPNGFileHandler(void)
+  {
+       m_name = "PNG bitmap file";
+       m_extension = "bmp";
+       m_type = wxBITMAP_TYPE_PNG;
+  };
+
+  virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
+      int desiredWidth, int desiredHeight);
+  virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
+};
+
+#endif
+  // _WX_PNGHAND_H_
+
index fbc2afdf1f53bbe13ed50d7e2c74ec9beac56a2a..d4cf0361f1d5d2963ea6f765084dd4dc593eb4fd 100644 (file)
@@ -46,7 +46,7 @@ protected:
 
   long EfeWidth;                    // Efective Width
 
-  LPBITMAPINFOHEADER lpbi;
+  BITMAPINFOHEADER2* lpbi;
   int bgindex;
   wxPalette* Palette;
   bool imageOK;
@@ -270,7 +270,7 @@ inline bool wxPNGReaderIter::PrevStep()
   Itx -= Stepx;
   if (Itx >= 0)
      return 1;
-  else {       
+  else {
      Ity -= Stepy;
      if (Ity >= 0 && Ity < ima->Height)
      {
index f1deadd0540d9a440e8e4be792de54db42f23e54..0c84daebefa931af0aabb0bf99f6437dc452dbca 100644 (file)
@@ -1,11 +1,11 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        setup.h
 // Purpose:     Configuration for the library
-// Author:      David Webster
+// Author:      Julian Smart
 // Modified by:
-// Created:     04/02/99
+// Created:     01/02/97
 // RCS-ID:      $Id$
-// Copyright:   (c) David Webster
+// Copyright:   (c) Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 
 #define wxUSE_CARET       1
                                     // Define 1 to use wxCaret class
-#define wxUSE_XPM_IN_MSW  1
+#define wxUSE_XPM_IN_OS2  1
                                     // Define 1 to support the XPM package in wxBitmap.
+#define wxUSE_IMAGE_LOADING_IN_OS2        1
+                                    // Use dynamic DIB loading/saving code in utils/dib under OS2.
+#define wxUSE_RESOURCE_LOADING_IN_OS2     1
+                                    // Use dynamic icon/cursor loading/saving code
+                                    // under OS2.
 #define wxUSE_WX_RESOURCES        1
                                   // Use .wxr resource mechanism (requires PrologIO library)
 
                                   // Set to 0 to disable MDI document/view architecture
 #define wxUSE_PRINTING_ARCHITECTURE  1
                                     // Set to 0 to disable print/preview architecture code
+#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_OS2 1
+                                // Set to 0 to disable PostScript print/preview architecture code
+                                // under OS/2 PM (just use PM printing).
 #define wxUSE_DYNAMIC_CLASSES     1
                                   // If 1, enables provision of run-time type information.
                                   // NOW MANDATORY: don't change.
 
 #define wxUSE_DRAG_AND_DROP 1
 
+#define wxUSE_PORTABLE_FONTS_IN_OS2  0
+                                // Define 1 to use new portable font scheme in Windows
+                                // (used by default under X)
+
+#define wxUSE_GENERIC_DIALOGS_IN_OS2 0
+                                // Define 1 to use generic dialogs in Windows, even though
+                                // they duplicate native common dialog (e.g. wxColourDialog)
 #endif
     // _WX_SETUP_H_
index 1069663d97966aad73b7e340b086d7798323b050..0c84daebefa931af0aabb0bf99f6437dc452dbca 100644 (file)
 
 #define wxUSE_CARET       1
                                     // Define 1 to use wxCaret class
-#define wxUSE_XPM_IN_MSW  1
+#define wxUSE_XPM_IN_OS2  1
                                     // Define 1 to support the XPM package in wxBitmap.
+#define wxUSE_IMAGE_LOADING_IN_OS2        1
+                                    // Use dynamic DIB loading/saving code in utils/dib under OS2.
+#define wxUSE_RESOURCE_LOADING_IN_OS2     1
+                                    // Use dynamic icon/cursor loading/saving code
+                                    // under OS2.
 #define wxUSE_WX_RESOURCES        1
                                   // Use .wxr resource mechanism (requires PrologIO library)
 
                                   // Set to 0 to disable MDI document/view architecture
 #define wxUSE_PRINTING_ARCHITECTURE  1
                                     // Set to 0 to disable print/preview architecture code
+#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_OS2 1
+                                // Set to 0 to disable PostScript print/preview architecture code
+                                // under OS/2 PM (just use PM printing).
 #define wxUSE_DYNAMIC_CLASSES     1
                                   // If 1, enables provision of run-time type information.
                                   // NOW MANDATORY: don't change.
 
 #define wxUSE_DRAG_AND_DROP 1
 
+#define wxUSE_PORTABLE_FONTS_IN_OS2  0
+                                // Define 1 to use new portable font scheme in Windows
+                                // (used by default under X)
+
+#define wxUSE_GENERIC_DIALOGS_IN_OS2 0
+                                // Define 1 to use generic dialogs in Windows, even though
+                                // they duplicate native common dialog (e.g. wxColourDialog)
 #endif
     // _WX_SETUP_H_
index fe49334c2a173b8b21180d8c9d1bca5ef938e0d2..ae00740978947146f7e96f0bc9b4dac436b7a5b0 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "data.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -141,7 +137,6 @@ const wxChar *wxButtonBarNameStr = wxT("buttonbar");
 const wxChar *wxEnhDialogNameStr = wxT("Shell");
 const wxChar *wxToolBarNameStr = wxT("toolbar");
 const wxChar *wxStatusLineNameStr = wxT("status_line");
-const wxChar *wxEmptyString = wxT("");
 const wxChar *wxGetTextFromUserPromptStr = wxT("Input Text");
 const wxChar *wxMessageBoxCaptionStr = wxT("Message");
 const wxChar *wxFileSelectorPromptStr = wxT("Select a file");
@@ -156,631 +151,8 @@ const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
 const wxChar *wxFloatToStringStr = wxT("%.2f");
 const wxChar *wxDoubleToStringStr = wxT("%.2f");
 
-#ifdef __WXMSW__
 const wxChar *wxUserResourceStr = wxT("TEXT");
-#endif
-
-#if wxUSE_SHARED_LIBRARY
-/*
- * For wxWindows to be made into a dynamic library (e.g. Sun),
- * all IMPLEMENT_... macros must be in one place.
- * But normally, the definitions are in the appropriate places.
- */
-
-// Hand-coded IMPLEMENT... macro for wxObject (define static data)
-wxClassInfo wxObject::classwxObject("wxObject", NULL, NULL, sizeof(wxObject), NULL);
-wxClassInfo *wxClassInfo::first = NULL;
-wxClassInfo wxClassInfo::classTable(wxKEY_STRING);
-
-#include "wx/button.h"
-#include "wx/bmpbuttn.h"
-IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
-
-#include "wx/checkbox.h"
-IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
-
-#include "wx/choice.h"
-IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
-
-#if wxUSE_CLIPBOARD
-#include "wx/clipbrd.h"
-IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
-#endif
-
-#if wxUSE_COMBOBOX
-#include "wx/combobox.h"
-IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
-#endif
-
-#include "wx/dc.h"
-#include "wx/dcmemory.h"
-#include "wx/dcclient.h"
-#include "wx/dcscreen.h"
-IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
-IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
-IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
-IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
-
-#if defined(__WXMSW__)
-#include "wx/dcprint.h"
-IMPLEMENT_CLASS(wxPrinterDC, wxDC)
-#endif
-
-#include "wx/dialog.h"
-IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxWindow)
-
-#include "wx/frame.h"
-IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
-
-#include "wx/mdi.h"
-IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
-IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
-IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
-
-#include "wx/cmndata.h"
-IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject)
-
-#include "wx/colordlg.h"
-#include "wx/fontdlg.h"
-
-#if !defined(__WXMSW__) || wxUSE_GENERIC_DIALOGS_IN_MSW
-#include "wx/generic/colordlg.h"
-#include "wx/generic/fontdlg.h"
-IMPLEMENT_DYNAMIC_CLASS(wxGenericColourDialog, wxDialog)
-IMPLEMENT_DYNAMIC_CLASS(wxGenericFontDialog, wxDialog)
-#endif
-
-// X defines wxColourDialog to be wxGenericColourDialog
-#ifndef __X__
-IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
-IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
-#endif
-
-#include "wx/gdicmn.h"
-#include "wx/pen.h"
-#include "wx/brush.h"
-#include "wx/font.h"
-#include "wx/palette.h"
-#include "wx/icon.h"
-#include "wx/cursor.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
-IMPLEMENT_CLASS(wxColourDatabase, wxList)
-IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList)
-IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList)
-IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList)
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList)
-
-/*
-#if (!USE_TYPEDEFS)
-IMPLEMENT_DYNAMIC_CLASS(wxPoint, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxRealPoint, wxObject)
-#endif
-*/
-
-#include "wx/hash.h"
-IMPLEMENT_DYNAMIC_CLASS(wxHashTable, wxObject)
-
-#include "wx/helpbase.h"
-IMPLEMENT_CLASS(wxHelpControllerBase, wxObject)
-
-#if wxUSE_HELP
-
-#ifdef __WXMSW__
-#include "wx/msw/helpwin.h"
-IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
-#endif
-
-// Generic wxHelp controller
-IMPLEMENT_CLASS(wxXLPHelpController, wxHelpControllerBase)
-
-#ifdef __WXMSW__
-IMPLEMENT_CLASS(wxXLPHelpClient, wxDDEClient)
-IMPLEMENT_CLASS(wxXLPHelpConnection, wxDDEConnection)
-#else
-IMPLEMENT_CLASS(wxXLPHelpClient, wxTCPClient)
-IMPLEMENT_CLASS(wxXLPHelpConnection, wxTCPConnection)
-#endif
-
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxString, wxObject)
-
-#include "wx/list.h"
-IMPLEMENT_DYNAMIC_CLASS(wxNode, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxList, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxStringList, wxList)
-
-#if wxUSE_PRINTING_ARCHITECTURE
-#include "wx/print.h"
-IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
-IMPLEMENT_DYNAMIC_CLASS(wxPrinterBase, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxPostScriptPrinter, wxPrinterBase)
-IMPLEMENT_DYNAMIC_CLASS(wxWindowsPrinter, wxPrinterBase)
-IMPLEMENT_ABSTRACT_CLASS(wxPrintout, wxObject)
-IMPLEMENT_CLASS(wxPreviewCanvas, wxWindow)
-IMPLEMENT_CLASS(wxPreviewControlBar, wxWindow)
-IMPLEMENT_CLASS(wxPreviewFrame, wxFrame)
-IMPLEMENT_CLASS(wxPrintPreviewBase, wxObject)
-IMPLEMENT_CLASS(wxPostScriptPrintPreview, wxPrintPreviewBase)
-IMPLEMENT_CLASS(wxWindowsPrintPreview, wxPrintPreviewBase)
-IMPLEMENT_CLASS(wxGenericPrintDialog, wxDialog)
-IMPLEMENT_CLASS(wxGenericPrintSetupDialog, wxDialog)
-#endif
-
-#if wxUSE_POSTSCRIPT
-#include "wx/dcps.h"
-IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC)
-IMPLEMENT_DYNAMIC_CLASS(wxPrintSetupData, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxPageSetupData, wxObject)
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList)
-
-#if wxUSE_WX_RESOURCES
-#include "wx/resource.h"
-IMPLEMENT_DYNAMIC_CLASS(wxItemResource, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable)
-#endif
-
-#include "wx/event.h"
-IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxShowEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxEvent)
-IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent)
-
-#include "wx/utils.h"
-IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxList)
-
-// IMPLEMENT_DYNAMIC_CLASS(wxRect, wxObject)
-
-#include "wx/process.h"
-IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
-
-#if wxUSE_TIMEDATE
-#include "wx/date.h"
-IMPLEMENT_DYNAMIC_CLASS(wxDate, wxObject)
-#endif
-
-#if wxUSE_DOC_VIEW_ARCHITECTURE
-#include "wx/docview.h"
-//IMPLEMENT_ABSTRACT_CLASS(wxDocItem, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxDocument, wxEvtHandler)
-IMPLEMENT_ABSTRACT_CLASS(wxView, wxEvtHandler)
-IMPLEMENT_ABSTRACT_CLASS(wxDocTemplate, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxDocManager, wxEvtHandler)
-IMPLEMENT_CLASS(wxDocChildFrame, wxFrame)
-IMPLEMENT_CLASS(wxDocParentFrame, wxFrame)
-#if wxUSE_PRINTING_ARCHITECTURE
-IMPLEMENT_DYNAMIC_CLASS(wxDocPrintout, wxPrintout)
-#endif
-IMPLEMENT_CLASS(wxCommand, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxCommandProcessor, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxFileHistory, wxObject)
-#endif
-
-#if wxUSE_CONSTRAINTS
-#include "wx/layout.h"
-IMPLEMENT_DYNAMIC_CLASS(wxIndividualLayoutConstraint, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxLayoutConstraints, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxSizer, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxRowColSizer, wxSizer)
-#endif
-
-#if wxUSE_TOOLBAR
-#include "wx/tbarbase.h"
-IMPLEMENT_DYNAMIC_CLASS(wxToolBarTool, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxToolBarBase, wxControl)
-
-#include "wx/tbarsmpl.h"
-IMPLEMENT_DYNAMIC_CLASS(wxToolBarSimple, wxToolBarBase)
-
-#ifdef __WXMSW__
-#include "wx/tbarmsw.h"
-IMPLEMENT_DYNAMIC_CLASS(wxToolBarMSW, wxToolBarBase)
-
-#include "wx/tbar95.h"
-IMPLEMENT_DYNAMIC_CLASS(wxToolBar95, wxToolBarBase)
-#endif
-
-#endif
-
-#if wxUSE_SOCKETS
-
-#include "wx/sckaddr.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxIPV4address, wxSockAddress)
-#ifdef ENABLE_IPV6
-IMPLEMENT_DYNAMIC_CLASS(wxIPV6address, wxSockAddress)
-#endif
-#ifndef __UNIX__
-IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)
-#endif
-
-#include "wx/socket.h"
-
-IMPLEMENT_CLASS(wxSocketBase, wxEvtHandler)
-IMPLEMENT_CLASS(wxSocketClient, wxSocketBase)
-IMPLEMENT_CLASS(wxSocketServer, wxSocketBase)
-IMPLEMENT_CLASS(wxSocketHandler, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxSocketEvent, wxEvent)
-
-#include "wx/url.h"
-
-IMPLEMENT_CLASS(wxProtoInfo, wxObject)
-IMPLEMENT_CLASS(wxURL, wxObject)
-
-#include "wx/protocol/http.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxHTTP, wxProtocol)
-IMPLEMENT_PROTOCOL(wxHTTP, "http", "80", TRUE)
-
-#include "wx/protocol/ftp.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxFTP, wxProtocol)
-IMPLEMENT_PROTOCOL(wxFTP, "ftp", "21", TRUE)
-
-#include "wx/protocol/sckfile.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxFileProto, wxProtocol)
-IMPLEMENT_PROTOCOL(wxFileProto, "file", NULL, FALSE)
-
-#include "wx/sckipc.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxTCPServer, wxServerBase)
-IMPLEMENT_DYNAMIC_CLASS(wxTCPClient, wxClientBase)
-IMPLEMENT_DYNAMIC_CLASS(wxTCPConnection, wxConnectionBase)
-
-#endif
-
-#include "wx/statusbr.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxStatusBar, wxWindow)
-
-BEGIN_EVENT_TABLE(wxStatusBar, wxWindow)
-    EVT_PAINT(wxStatusBar::OnPaint)
-    EVT_SYS_COLOUR_CHANGED(wxStatusBar::OnSysColourChanged)
-END_EVENT_TABLE()
-
-#if wxUSE_TIMEDATE
-#include "wx/time.h"
-IMPLEMENT_DYNAMIC_CLASS(wxTime, wxObject)
-#endif
-
-#if !USE_GNU_WXSTRING
-#include "wx/string.h"
-IMPLEMENT_DYNAMIC_CLASS(wxString, wxObject)
-#endif
-
-#ifdef __WXMOTIF__
-IMPLEMENT_DYNAMIC_CLASS(wxXColormap, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxXFont, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxXCursor, wxObject)
-#endif
-IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
-IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
-IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
-IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
-IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
-IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
-IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
-IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
-
-// This will presumably be implemented on other platforms too
-#ifdef __WXMSW__
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler)
-IMPLEMENT_DYNAMIC_CLASS(wxBMPFileHandler, wxBitmapHandler)
-IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler)
-IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler)
-IMPLEMENT_DYNAMIC_CLASS(wxICOFileHandler, wxBitmapHandler)
-IMPLEMENT_DYNAMIC_CLASS(wxICOResourceHandler, wxBitmapHandler)
-#endif
-
-#include "wx/statbox.h"
-IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
-
-#if wxUSE_IPC
-#include "wx/dde.h"
-IMPLEMENT_CLASS(wxServerBase, wxObject)
-IMPLEMENT_CLASS(wxClientBase, wxObject)
-IMPLEMENT_CLASS(wxConnectionBase, wxObject)
-
-IMPLEMENT_DYNAMIC_CLASS(wxDDEServer, wxServerBase)
-IMPLEMENT_DYNAMIC_CLASS(wxDDEClient, wxClientBase)
-IMPLEMENT_CLASS(wxDDEConnection, wxConnectionBase)
-#endif
-
-IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
-
-#include "wx/listbox.h"
-IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
-
-#include "wx/checklst.h"
-IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
-
-IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
-
-#include "wx/menu.h"
-IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
-IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
-
-#include "wx/stattext.h"
-#include "wx/statbmp.h"
-IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
-
-#if wxUSE_METAFILE
-#include "wx/metafile.h"
-IMPLEMENT_DYNAMIC_CLASS(wxMetaFile, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxMetaFileDC, wxDC)
-#endif
-
-#include "wx/radiobox.h"
-#include "wx/radiobut.h"
-IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
-
-IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
-// IMPLEMENT_DYNAMIC_CLASS(wxBitmapRadioButton, wxRadioButton)
-
-#include "wx/scrolbar.h"
-IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
-
-#if WXWIN_COMPATIBILITY
-BEGIN_EVENT_TABLE(wxScrollBar, wxControl)
-  EVT_SCROLL(wxScrollBar::OnScroll)
-END_EVENT_TABLE()
-#endif
-
-#include "wx/slider.h"
-IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl)
-
-#if WXWIN_COMPATIBILITY
-BEGIN_EVENT_TABLE(wxSlider, wxControl)
-  EVT_SCROLL(wxSlider::OnScroll)
-END_EVENT_TABLE()
-#endif
-
-#include "wx/timer.h"
-IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
-
-#include "wx/textctrl.h"
-IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
-
-#include "wx/window.h"
-IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
-
-#include "wx/scrolwin.h"
-IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxWindow)
-
-#include "wx/panel.h"
-IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow)
-
-#include "wx/msgbxdlg.h"
-#include "wx/textdlg.h"
-#include "wx/filedlg.h"
-#include "wx/dirdlg.h"
-#include "wx/choicdlg.h"
-
-#if !defined(__WXMSW__) || wxUSE_GENERIC_DIALOGS_IN_MSW
-#include "wx/generic/msgdlgg.h"
-IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog)
-#endif
-
-IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog)
-IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
-IMPLEMENT_CLASS(wxFileDialog, wxDialog)
-IMPLEMENT_CLASS(wxDirDialog, wxDialog)
-
-#ifdef __WXMSW__
-IMPLEMENT_CLASS(wxMessageDialog)
-#endif
-
-#if wxUSE_GAUGE
-#ifdef __WXMOTIF__
-#include "../../contrib/xmgauge/gauge.h"
-#endif
-#include "wx_gauge.h"
-IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
-#endif
-
-#include "wx/grid.h"
-IMPLEMENT_DYNAMIC_CLASS(wxGenericGrid, wxPanel)
-
-///// Event tables (also must be in one, statically-linked file for shared libraries)
-
-// This is the base, wxEvtHandler 'bootstrap' code which is expanded manually here
-const wxEventTable *wxEvtHandler::GetEventTable() const { return &wxEvtHandler::sm_eventTable; }
-
-const wxEventTable wxEvtHandler::sm_eventTable =
-    { NULL, &wxEvtHandler::sm_eventTableEntries[0] };
-
-const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = { { 0, 0, 0, NULL } };
-
-BEGIN_EVENT_TABLE(wxFrame, wxWindow)
-    EVT_ACTIVATE(wxFrame::OnActivate)
-    EVT_SIZE(wxFrame::OnSize)
-    EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
-    EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
-    EVT_IDLE(wxFrame::OnIdle)
-    EVT_CLOSE(wxFrame::OnCloseWindow)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxDialog, wxPanel)
-  EVT_BUTTON(wxID_OK, wxDialog::OnOK)
-  EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
-  EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
-  EVT_CHAR_HOOK(wxDialog::OnCharHook)
-  EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
-  EVT_CLOSE(wxDialog::OnCloseWindow)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
-  EVT_CHAR(wxWindow::OnChar)
-  EVT_SIZE(wxWindow::Size)
-  EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
-  EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
-  EVT_INIT_DIALOG(wxWindow::OnInitDialog)
-  EVT_IDLE(wxWindow::OnIdle)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxScrolledWindow, wxWindow)
-  EVT_SCROLL(wxScrolledWindow::OnScroll)
-  EVT_SIZE(wxScrolledWindow::OnSize)
-  EVT_PAINT(wxScrolledWindow::OnPaint)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxPanel, wxWindow)
-  EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
-    EVT_CHAR(wxTextCtrl::OnChar)
-    EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
-END_EVENT_TABLE()
-
-#ifdef __WXMSW__
-BEGIN_EVENT_TABLE(wxMDIParentWindow, wxFrame)
-  EVT_SIZE(wxMDIParentWindow::OnSize)
-  EVT_ACTIVATE(wxMDIParentWindow::OnActivate)
-  EVT_SYS_COLOUR_CHANGED(wxMDIParentWindow::OnSysColourChanged)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
-  EVT_SCROLL(wxMDIClientWindow::OnScroll)
-END_EVENT_TABLE()
-#endif
-
-BEGIN_EVENT_TABLE(wxToolBarBase, wxControl)
-  EVT_SCROLL(wxToolBarBase::OnScroll)
-  EVT_SIZE(wxToolBarBase::OnSize)
-  EVT_IDLE(wxToolBarBase::OnIdle)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxToolBarSimple, wxToolBarBase)
-    EVT_SIZE(wxToolBarSimple::OnSize)
-    EVT_PAINT(wxToolBarSimple::OnPaint)
-    EVT_KILL_FOCUS(wxToolBarSimple::OnKillFocus)
-    EVT_MOUSE_EVENTS(wxToolBarSimple::OnMouseEvent)
-END_EVENT_TABLE()
-
-#ifdef __WXMSW__
-BEGIN_EVENT_TABLE(wxToolBarMSW, wxToolBarBase)
-    EVT_SIZE(wxToolBarMSW::OnSize)
-    EVT_PAINT(wxToolBarMSW::OnPaint)
-    EVT_MOUSE_EVENTS(wxToolBarMSW::OnMouseEvent)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxToolBar95, wxToolBarBase)
-    EVT_SIZE(wxToolBar95::OnSize)
-    EVT_PAINT(wxToolBar95::OnPaint)
-    EVT_KILL_FOCUS(wxToolBar95::OnKillFocus)
-    EVT_MOUSE_EVENTS(wxToolBar95::OnMouseEvent)
-    EVT_SYS_COLOUR_CHANGED(wxToolBar95::OnSysColourChanged)
-END_EVENT_TABLE()
-#endif
-
-BEGIN_EVENT_TABLE(wxGenericGrid, wxPanel)
-    EVT_SIZE(wxGenericGrid::OnSize)
-    EVT_PAINT(wxGenericGrid::OnPaint)
-    EVT_MOUSE_EVENTS(wxGenericGrid::OnMouseEvent)
-    EVT_TEXT(wxGRID_TEXT_CTRL, wxGenericGrid::OnText)
-    EVT_COMMAND_SCROLL(wxGRID_HSCROLL, wxGenericGrid::OnGridScroll)
-    EVT_COMMAND_SCROLL(wxGRID_VSCROLL, wxGenericGrid::OnGridScroll)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxControl, wxWindow)
-  EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground)
-END_EVENT_TABLE()
-
-#if !defined(__WXMSW__) || wxUSE_GENERIC_DIALOGS_IN_MSW
-BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog)
-    EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes)
-    EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo)
-    EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxGenericColourDialog, wxDialog)
-    EVT_BUTTON(wxID_ADD_CUSTOM, wxGenericColourDialog::OnAddCustom)
-    EVT_SLIDER(wxID_RED_SLIDER, wxGenericColourDialog::OnRedSlider)
-    EVT_SLIDER(wxID_GREEN_SLIDER, wxGenericColourDialog::OnGreenSlider)
-    EVT_SLIDER(wxID_BLUE_SLIDER, wxGenericColourDialog::OnBlueSlider)
-    EVT_PAINT(wxGenericColourDialog::OnPaint)
-    EVT_MOUSE_EVENTS(wxGenericColourDialog::OnMouseEvent)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxGenericFontDialog, wxDialog)
-    EVT_CHECKBOX(wxID_FONT_UNDERLINE, wxGenericFontDialog::OnChangeFont)
-    EVT_CHOICE(wxID_FONT_STYLE, wxGenericFontDialog::OnChangeFont)
-    EVT_CHOICE(wxID_FONT_WEIGHT, wxGenericFontDialog::OnChangeFont)
-    EVT_CHOICE(wxID_FONT_FAMILY, wxGenericFontDialog::OnChangeFont)
-    EVT_CHOICE(wxID_FONT_COLOUR, wxGenericFontDialog::OnChangeFont)
-    EVT_CHOICE(wxID_FONT_SIZE, wxGenericFontDialog::OnChangeFont)
-    EVT_PAINT(wxGenericFontDialog::OnPaint)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxGenericPrintDialog, wxDialog)
-    EVT_BUTTON(wxID_OK, wxGenericPrintDialog::OnOK)
-    EVT_BUTTON(wxPRINTID_SETUP, wxGenericPrintDialog::OnSetup)
-    EVT_RADIOBOX(wxPRINTID_RANGE, wxGenericPrintDialog::OnRange)
-END_EVENT_TABLE()
-
-#endif
-
-BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
-    EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog)
-    EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK)
-END_EVENT_TABLE()
-
-#include "wx/prntbase.h"
-
-BEGIN_EVENT_TABLE(wxPrintAbortDialog, wxDialog)
-    EVT_BUTTON(wxID_CANCEL, wxPrintAbortDialog::OnCancel)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxPreviewControlBar, wxWindow)
-    EVT_BUTTON(wxID_PREVIEW_CLOSE,         wxPreviewControlBar::OnClose)
-    EVT_BUTTON(wxID_PREVIEW_PRINT,         wxPreviewControlBar::OnPrint)
-    EVT_BUTTON(wxID_PREVIEW_PREVIOUS,     wxPreviewControlBar::OnPrevious)
-    EVT_BUTTON(wxID_PREVIEW_NEXT,         wxPreviewControlBar::OnNext)
-    EVT_CHOICE(wxID_PREVIEW_ZOOM,         wxPreviewControlBar::OnZoom)
-END_EVENT_TABLE()
-
-#endif
-
 
 const wxSize wxDefaultSize(-1, -1);
 const wxPoint wxDefaultPosition(-1, -1);
+
index 8b435b6b01fcdcdb6230d0e4834b6ea37d1b0c3d..a5787d1f03ab7e34736bf9e830242d12b19b8973 100644 (file)
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dc.cpp
 // Purpose:     wxDC class
-// Author:      AUTHOR
+// Author:      David Webster
 // Modified by:
-// Created:     01/02/97
+// Created:     10/14/99
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
-// Licence:    wxWindows licence
+// Copyright:   (c) David Webster
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "dc.h"
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/window.h"
+    #include "wx/dc.h"
+    #include "wx/utils.h"
+    #include "wx/dialog.h"
+    #include "wx/app.h"
+    #include "wx/bitmap.h"
+    #include "wx/dcmemory.h"
+    #include "wx/log.h"
+    #include "wx/icon.h"
 #endif
 
-#include "wx/dc.h"
+#include "wx/dcprint.h"
+
+#include <string.h>
+#include <math.h>
+
+#include "wx/os2/private.h"
 
 #if !USE_SHARED_LIBRARY
-IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
+    IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
 #endif
 
-//-----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
 // constants
-//-----------------------------------------------------------------------------
-
-#define mm2inches              0.0393700787402
-#define inches2mm              25.4
-#define mm2twips               56.6929133859
-#define twips2mm               0.0176388888889
-#define mm2pt                  2.83464566929
-#define pt2mm                  0.352777777778
-
-//-----------------------------------------------------------------------------
-// wxDCBase
-//-----------------------------------------------------------------------------
-
-long wxDCBase::DeviceToLogicalX(long x) const
-{
-    long new_x = x - m_deviceOriginX;
-    if (new_x > 0)
-        return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
-    else
-        return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
-};
-
-long wxDCBase::DeviceToLogicalY(long y) const
-{
-    long new_y = y - m_deviceOriginY;
-    if (new_y > 0)
-        return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
-    else
-        return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
-};
-
-long wxDCBase::DeviceToLogicalXRel(long x) const
-{
-    if (x > 0)
-        return (long)((double)(x) / m_scaleX + 0.5);
-    else
-        return (long)((double)(x) / m_scaleX - 0.5);
-};
-
-long wxDCBase::DeviceToLogicalYRel(long y) const
-{
-    if (y > 0)
-        return (long)((double)(y) / m_scaleY + 0.5);
-    else
-        return (long)((double)(y) / m_scaleY - 0.5);
-};
-
-long wxDCBase::LogicalToDeviceX(long x) const
-{
-    long new_x = x - m_logicalOriginX;
-    if (new_x > 0)
-        return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
-    else
-    return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
-};
+// ---------------------------------------------------------------------------
 
-long wxDCBase::LogicalToDeviceY(long y) const
-{
-    long new_y = y - m_logicalOriginY;
-    if (new_y > 0)
-        return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
-    else
-        return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
-};
+static const int VIEWPORT_EXTENT = 1000;
 
-long wxDCBase::LogicalToDeviceXRel(long x) const
-{
-    if (x > 0)
-        return (long)((double)(x) * m_scaleX + 0.5);
-    else
-        return (long)((double)(x) * m_scaleX - 0.5);
-};
+static const int MM_POINTS = 9;
+static const int MM_METRIC = 10;
 
-long wxDCBase::LogicalToDeviceYRel(long y) const
-{
-    if (y > 0)
-        return (long)((double)(y) * m_scaleY + 0.5);
-    else
-        return (long)((double)(y) * m_scaleY - 0.5);
-};
+// ===========================================================================
+// implementation
+// ===========================================================================
 
-//-----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
 // wxDC
-//-----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
 
 wxDC::wxDC(void)
 {
@@ -126,64 +72,100 @@ wxDC::~wxDC(void)
     // TODO:
 };
 
-void wxDC::DestroyClippingRegion(void)
-{
-    // TODO:
-};
-
-void wxDC::DoGetSize( int* width, int* height ) const
+// This will select current objects out of the DC,
+// which is what you have to do before deleting the
+// DC.
+void wxDC::SelectOldObjects(WXHDC dc)
 {
-    // TODO:
-};
+    if (dc)
+    {
+        if (m_oldBitmap)
+        {
+//            ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap);
+            if (m_selectedBitmap.Ok())
+            {
+                m_selectedBitmap.SetSelectedInto(NULL);
+            }
+        }
+        m_oldBitmap = 0;
+        if (m_oldPen)
+        {
+//            ::SelectObject((HDC) dc, (HPEN) m_oldPen);
+        }
+        m_oldPen = 0;
+        if (m_oldBrush)
+        {
+//            ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush);
+        }
+        m_oldBrush = 0;
+        if (m_oldFont)
+        {
+//            ::SelectObject((HDC) dc, (HFONT) m_oldFont);
+        }
+        m_oldFont = 0;
+        if (m_oldPalette)
+        {
+//            ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
+        }
+        m_oldPalette = 0;
+    }
 
-void wxDC::DoGetSizeMM( int* width, int* height ) const
-{
-    // TODO:
-};
+    m_brush = wxNullBrush;
+    m_pen = wxNullPen;
+    m_palette = wxNullPalette;
+    m_font = wxNullFont;
+    m_backgroundBrush = wxNullBrush;
+    m_selectedBitmap = wxNullBitmap;
+}
 
-void wxDC::SetMapMode( int mode )
-{
-    // TODO:
-};
+// ---------------------------------------------------------------------------
+// clipping
+// ---------------------------------------------------------------------------
 
-void wxDC::SetUserScale( double x, double y )
+void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
 {
-    m_userScaleX = x;
-    m_userScaleY = y;
-
-    SetMapMode(m_mappingMode);
-};
+   // TODO
+}
 
-void wxDC::SetLogicalScale( double x, double y )
+void wxDC::DoSetClippingRegion( long x, long y
+                               ,long width, long height
+                              )
 {
-    // TODO:
-};
+   // TODO
+}
 
-void wxDC::SetLogicalOrigin( long x, long y )
+void wxDC::DoClipping(WXHDC dc)
 {
-    // TODO:
-};
+    if (m_clipping && dc)
+    {
+//      TODO:
+//      IntersectClipRect((HDC) dc, XLOG2DEV(m_clipX1), YLOG2DEV(m_clipY1),
+//                                  XLOG2DEV(m_clipX2), YLOG2DEV(m_clipY2));
+    }
+}
 
-void wxDC::SetDeviceOrigin( long x, long y )
+void wxDC::DestroyClippingRegion(void)
 {
     // TODO:
 };
 
-void wxDC::SetInternalDeviceOrigin( long x, long y )
-{
-    // TODO:
-};
+// ---------------------------------------------------------------------------
+// query capabilities
+// ---------------------------------------------------------------------------
 
-void wxDC::GetInternalDeviceOrigin( long *x, long *y )
+bool wxDC::CanDrawBitmap() const
 {
-    // TODO:
-};
+    return TRUE;
+}
 
-void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
+bool wxDC::CanGetTextExtent() const
 {
-    // TODO:
-};
+    // What sort of display is it?
+    int technology = 0; // TODO:  ::GetDeviceCaps(GetHdc(), TECHNOLOGY);
 
+    // TODO: return (technology == DT_RASDISPLAY) || (technology == DT_RASPRINTER);
+    return FALSE;
+}
 
 int wxDC::GetDepth() const
 {
@@ -191,104 +173,82 @@ int wxDC::GetDepth() const
    return (1);
 }
 
-wxSize wxDC::GetPPI() const
-{
-   int x = 1;
-   int y = 1;
-   // TODO:
-   return (wxSize(x,y));
-}
-void wxDC::GetTextExtent( const wxString& string
-                         ,long* x
-                         ,long* y
-                         ,long* decent
-                         ,long* externalLeading
-                         ,wxFont* theFont
-                        ) const
-{
-   // TODO:
-}
-
-long wxDC::GetCharWidth() const
-{
-    // TODO
-    return(1);
-}
-
-long wxDC::GetCharHeight() const
-{
-    // TODO
-    return(1);
-}
+// ---------------------------------------------------------------------------
+// drawing
+// ---------------------------------------------------------------------------
 
 void wxDC::Clear()
 {
    // TODO
 }
 
-void wxDC::SetFont(const wxFont& font)
+void wxDC::DoFloodFill( long x
+                       ,long y
+                       ,const wxColour& col
+                       ,int style
+                      )
 {
    // TODO
 }
 
-void wxDC::SetPen(const wxPen& pen)
-{
-   // TODO
-}
-void wxDC::SetBrush(const wxBrush& brush)
+bool wxDC::DoGetPixel(long x, long y, wxColour *col) const
 {
    // TODO
+   return(TRUE);
 }
 
-void wxDC::SetBackground(const wxBrush& brush)
+void wxDC::DoCrossHair(long x, long y)
 {
    // TODO
 }
 
-void wxDC::SetLogicalFunction(int function)
+void wxDC::DoDrawLine(long x1, long y1, long x2, long y2)
 {
    // TODO
 }
 
-void wxDC::SetBackgroundMode(int mode)
+void wxDC::DoDrawArc( long x1, long y1
+                     ,long x2, long y2
+                     ,long xc, long yc
+                    )
 {
    // TODO
 }
 
-void wxDC::SetPalette(const wxPalette& palette)
+void wxDC::DoDrawPoint(long x, long y)
 {
    // TODO
 }
 
-void wxDC::DoFloodFill( long x
-                       ,long y
-                       ,const wxColour& col
-                       ,int style
-                      )
+void wxDC::DoDrawPolygon(int n, wxPoint points[]
+                         ,long xoffset, long yoffset
+                         ,int fillStyle
+                        )
 {
    // TODO
 }
 
-bool wxDC::DoGetPixel(long x, long y, wxColour *col) const
+void wxDC::DoDrawLines( int n, wxPoint points[]
+                       ,long xoffset, long yoffset
+                      )
 {
    // TODO
-   return(TRUE);
 }
 
-void wxDC::DoDrawPoint(long x, long y)
+void wxDC::DoDrawRectangle(long x, long y, long width, long height)
 {
    // TODO
 }
 
-void wxDC::DoDrawLine(long x1, long y1, long x2, long y2)
+void wxDC::DoDrawRoundedRectangle( long x, long y
+                                  ,long width, long height
+                                  ,double radius
+                                 )
 {
    // TODO
 }
 
-void wxDC::DoDrawArc( long x1, long y1
-                     ,long x2, long y2
-                     ,long xc, long yc
-                    )
+void wxDC::DoDrawEllipse(long x, long y, long width, long height)
 {
    // TODO
 }
@@ -304,95 +264,61 @@ void wxDC::DoDrawEllipticArc( long x
    // TODO
 }
 
-void wxDC::DoDrawRectangle(long x, long y, long width, long height)
+void wxDC::DoDrawIcon(const wxIcon& icon, long x, long y)
 {
    // TODO
 }
 
-void wxDC::DoDrawRoundedRectangle( long x, long y
-                                  ,long width, long height
-                                  ,double radius
-                                 )
+void wxDC::DoDrawBitmap( const wxBitmap &bmp
+                        ,long x, long y
+                        ,bool useMask
+                       )
 {
    // TODO
 }
 
-void wxDC::DoDrawEllipse(long x, long y, long width, long height)
-{
-   // TODO
-}
-
-void wxDC::DoCrossHair(long x, long y)
-{
-   // TODO
-}
-
-void wxDC::DoDrawIcon(const wxIcon& icon, long x, long y)
+void wxDC::DoDrawText(const wxString& text, long x, long y)
 {
    // TODO
 }
 
-void wxDC::DoDrawBitmap( const wxBitmap &bmp
-                        ,long x, long y
-                        ,bool useMask
-                       )
-{
-   // TODO
-}
+// ---------------------------------------------------------------------------
+// set GDI objects
+// ---------------------------------------------------------------------------
 
-void wxDC::DoDrawText(const wxString& text, long x, long y)
+void wxDC::SetPalette(const wxPalette& palette)
 {
    // TODO
 }
 
-bool wxDC::DoBlit( long xdest
-                  ,long ydest
-                  ,long width
-                  ,long height
-                  ,wxDC *source
-                  ,long xsrc
-                  ,long ysrc
-                  ,int  rop
-                  ,bool useMask
-                 )
+void wxDC::SetFont(const wxFont& font)
 {
    // TODO
-   return(TRUE);
 }
 
-void wxDC::DoDrawLines( int n, wxPoint points[]
-                       ,long xoffset, long yoffset
-                      )
+void wxDC::SetPen(const wxPen& pen)
 {
    // TODO
 }
-
-void wxDC::DoDrawPolygon(int n, wxPoint points[]
-                         ,long xoffset, long yoffset
-                         ,int fillStyle
-                        )
+void wxDC::SetBrush(const wxBrush& brush)
 {
    // TODO
 }
 
-void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
+void wxDC::SetBackground(const wxBrush& brush)
 {
    // TODO
 }
 
-void wxDC::DoSetClippingRegion( long x, long y
-                               ,long width, long height
-                              )
+void wxDC::SetBackgroundMode(int mode)
 {
    // TODO
 }
 
-#if wxUSE_SPLINES
-void wxDC::DoDrawSpline(wxList *points)
+void wxDC::SetLogicalFunction(int function)
 {
    // TODO
 }
-#endif
 
 void wxDC::SetRop(WXHDC dc)
 {
@@ -426,64 +352,452 @@ void wxDC::SetRop(WXHDC dc)
 //    SetROP2((HDC) dc, c_rop);
 }
 
-void wxDC::DoClipping(WXHDC dc)
+bool wxDC::StartDoc(const wxString& message)
 {
-    if (m_clipping && dc)
+    // We might be previewing, so return TRUE to let it continue.
+    return TRUE;
+}
+
+void wxDC::EndDoc()
+{
+}
+
+void wxDC::StartPage()
+{
+}
+
+void wxDC::EndPage()
+{
+}
+
+// ---------------------------------------------------------------------------
+// text metrics
+// ---------------------------------------------------------------------------
+
+long wxDC::GetCharHeight() const
+{
+    // TODO
+    return(1);
+}
+
+long wxDC::GetCharWidth() const
+{
+    // TODO
+    return(1);
+}
+
+void wxDC::GetTextExtent( const wxString& string
+                         ,long* x
+                         ,long* y
+                         ,long* decent
+                         ,long* externalLeading
+                         ,wxFont* theFont
+                        ) const
+{
+   // TODO:
+}
+
+void wxDC::SetMapMode( int mode )
+{
+    // TODO:
+};
+
+void wxDC::SetUserScale(double x, double y)
+{
+    m_userScaleX = x;
+    m_userScaleY = y;
+
+    SetMapMode(m_mappingMode);
+}
+
+void wxDC::SetAxisOrientation(bool xLeftRight, bool yBottomUp)
+{
+    m_signX = xLeftRight ? 1 : -1;
+    m_signY = yBottomUp ? -1 : 1;
+
+    SetMapMode(m_mappingMode);
+}
+
+void wxDC::SetSystemScale(double x, double y)
+{
+    m_scaleX = x;
+    m_scaleY = y;
+
+    SetMapMode(m_mappingMode);
+}
+
+void wxDC::SetLogicalOrigin( long x, long y )
+{
+    // TODO:
+};
+
+void wxDC::SetDeviceOrigin( long x, long y )
+{
+    // TODO:
+};
+
+// ---------------------------------------------------------------------------
+// coordinates transformations
+// ---------------------------------------------------------------------------
+
+long wxDCBase::DeviceToLogicalX(long x) const
+{
+    long new_x = x - m_deviceOriginX;
+    if (new_x > 0)
+        return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
+    else
+        return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
+};
+
+long wxDCBase::DeviceToLogicalXRel(long x) const
+{
+    if (x > 0)
+        return (long)((double)(x) / m_scaleX + 0.5);
+    else
+        return (long)((double)(x) / m_scaleX - 0.5);
+};
+
+long wxDCBase::DeviceToLogicalY(long y) const
+{
+    long new_y = y - m_deviceOriginY;
+    if (new_y > 0)
+        return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
+    else
+        return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
+};
+
+long wxDCBase::DeviceToLogicalYRel(long y) const
+{
+    if (y > 0)
+        return (long)((double)(y) / m_scaleY + 0.5);
+    else
+        return (long)((double)(y) / m_scaleY - 0.5);
+};
+
+long wxDCBase::LogicalToDeviceX(long x) const
+{
+    long new_x = x - m_logicalOriginX;
+    if (new_x > 0)
+        return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
+    else
+    return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
+};
+
+long wxDCBase::LogicalToDeviceXRel(long x) const
+{
+    if (x > 0)
+        return (long)((double)(x) * m_scaleX + 0.5);
+    else
+        return (long)((double)(x) * m_scaleX - 0.5);
+};
+
+long wxDCBase::LogicalToDeviceY(long y) const
+{
+    long new_y = y - m_logicalOriginY;
+    if (new_y > 0)
+        return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
+    else
+        return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
+};
+
+long wxDCBase::LogicalToDeviceYRel(long y) const
+{
+    if (y > 0)
+        return (long)((double)(y) * m_scaleY + 0.5);
+    else
+        return (long)((double)(y) * m_scaleY - 0.5);
+};
+
+// ---------------------------------------------------------------------------
+// bit blit
+// ---------------------------------------------------------------------------
+
+bool wxDC::DoBlit( long xdest
+                  ,long ydest
+                  ,long width
+                  ,long height
+                  ,wxDC *source
+                  ,long xsrc
+                  ,long ysrc
+                  ,int  rop
+                  ,bool useMask
+                 )
+{
+   // TODO
+   return(TRUE);
+}
+
+void wxDC::DoGetSize( int* width, int* height ) const
+{
+    // TODO:
+};
+
+void wxDC::DoGetSizeMM( int* width, int* height ) const
+{
+    // TODO:
+};
+
+wxSize wxDC::GetPPI() const
+{
+   int x = 1;
+   int y = 1;
+   // TODO:
+   return (wxSize(x,y));
+}
+
+void wxDC::SetLogicalScale( double x, double y )
+{
+    // TODO:
+};
+
+#if WXWIN_COMPATIBILITY
+void wxDC::DoGetTextExtent(const wxString& string, float *x, float *y,
+                         float *descent, float *externalLeading,
+                         wxFont *theFont, bool use16bit) const
+{
+    long x1, y1, descent1, externalLeading1;
+    GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit);
+    *x = x1; *y = y1;
+    if (descent)
+        *descent = descent1;
+    if (externalLeading)
+        *externalLeading = externalLeading1;
+}
+#endif
+
+// ---------------------------------------------------------------------------
+// spline drawing code
+// ---------------------------------------------------------------------------
+
+#if wxUSE_SPLINES
+
+class wxSpline: public wxObject
+{
+public:
+    int type;
+    wxList *points;
+
+    wxSpline(wxList *list);
+    void DeletePoints();
+
+    // Doesn't delete points
+    ~wxSpline();
+};
+
+void wx_draw_open_spline(wxDC *dc, wxSpline *spline);
+
+void wx_quadratic_spline(double a1, double b1, double a2, double b2,
+                         double a3, double b3, double a4, double b4);
+void wx_clear_stack();
+int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3,
+                  double *y3, double *x4, double *y4);
+void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3,
+                    double x4, double y4);
+static bool wx_spline_add_point(double x, double y);
+static void wx_spline_draw_point_array(wxDC *dc);
+wxSpline *wx_make_spline(int x1, int y1, int x2, int y2, int x3, int y3);
+
+void wxDC::DoDrawSpline(wxList *list)
+{
+    wxSpline spline(list);
+
+    wx_draw_open_spline(this, &spline);
+}
+
+wxList wx_spline_point_list;
+
+void wx_draw_open_spline(wxDC *dc, wxSpline *spline)
+{
+    wxPoint *p;
+    double           cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
+    double           x1, y1, x2, y2;
+
+    wxNode *node = spline->points->First();
+    p = (wxPoint *)node->Data();
+
+    x1 = p->x;
+    y1 = p->y;
+
+    node = node->Next();
+    p = (wxPoint *)node->Data();
+
+    x2 = p->x;
+    y2 = p->y;
+    cx1 = (double)((x1 + x2) / 2);
+    cy1 = (double)((y1 + y2) / 2);
+    cx2 = (double)((cx1 + x2) / 2);
+    cy2 = (double)((cy1 + y2) / 2);
+
+    wx_spline_add_point(x1, y1);
+
+    while ((node = node->Next()) != NULL)
     {
-//      TODO:
-//      IntersectClipRect((HDC) dc, XLOG2DEV(m_clipX1), YLOG2DEV(m_clipY1),
-//                                  XLOG2DEV(m_clipX2), YLOG2DEV(m_clipY2));
+        p = (wxPoint *)node->Data();
+        x1 = x2;
+        y1 = y2;
+        x2 = p->x;
+        y2 = p->y;
+        cx4 = (double)(x1 + x2) / 2;
+        cy4 = (double)(y1 + y2) / 2;
+        cx3 = (double)(x1 + cx4) / 2;
+        cy3 = (double)(y1 + cy4) / 2;
+
+        wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
+
+        cx1 = cx4;
+        cy1 = cy4;
+        cx2 = (double)(cx1 + x2) / 2;
+        cy2 = (double)(cy1 + y2) / 2;
     }
+
+    wx_spline_add_point((double)wx_round(cx1), (double)wx_round(cy1));
+    wx_spline_add_point(x2, y2);
+
+    wx_spline_draw_point_array(dc);
+
 }
 
-// This will select current objects out of the DC,
-// which is what you have to do before deleting the
-// DC.
-void wxDC::SelectOldObjects(WXHDC dc)
+/********************* CURVES FOR SPLINES *****************************
+
+  The following spline drawing routine is from
+
+    "An Algorithm for High-Speed Curve Generation"
+    by George Merrill Chaikin,
+    Computer Graphics and Image Processing, 3, Academic Press,
+    1974, 346-349.
+
+      and
+
+        "On Chaikin's Algorithm" by R. F. Riesenfeld,
+        Computer Graphics and Image Processing, 4, Academic Press,
+        1975, 304-310.
+
+***********************************************************************/
+
+#define     half(z1, z2)    ((z1+z2)/2.0)
+#define     THRESHOLD   5
+
+/* iterative version */
+
+void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4,
+                         double b4)
 {
-    if (dc)
-    {
-        if (m_oldBitmap)
-        {
-//            ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap);
-            if (m_selectedBitmap.Ok())
-            {
-                m_selectedBitmap.SetSelectedInto(NULL);
-            }
-        }
-        m_oldBitmap = 0;
-        if (m_oldPen)
-        {
-//            ::SelectObject((HDC) dc, (HPEN) m_oldPen);
-        }
-        m_oldPen = 0;
-        if (m_oldBrush)
-        {
-//            ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush);
-        }
-        m_oldBrush = 0;
-        if (m_oldFont)
-        {
-//            ::SelectObject((HDC) dc, (HFONT) m_oldFont);
-        }
-        m_oldFont = 0;
-        if (m_oldPalette)
-        {
-//            ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
+    register double  xmid, ymid;
+    double           x1, y1, x2, y2, x3, y3, x4, y4;
+
+    wx_clear_stack();
+    wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4);
+
+    while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) {
+        xmid = (double)half(x2, x3);
+        ymid = (double)half(y2, y3);
+        if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD &&
+            fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) {
+            wx_spline_add_point((double)wx_round(x1), (double)wx_round(y1));
+            wx_spline_add_point((double)wx_round(xmid), (double)wx_round(ymid));
+        } else {
+            wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3),
+                (double)half(x3, x4), (double)half(y3, y4), x4, y4);
+            wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2),
+                (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid);
         }
-        m_oldPalette = 0;
     }
+}
 
-    m_brush = wxNullBrush;
-    m_pen = wxNullPen;
-    m_palette = wxNullPalette;
-    m_font = wxNullFont;
-    m_backgroundBrush = wxNullBrush;
-    m_selectedBitmap = wxNullBitmap;
+
+/* utilities used by spline drawing routines */
+
+
+typedef struct wx_spline_stack_struct {
+    double           x1, y1, x2, y2, x3, y3, x4, y4;
+}
+Stack;
+
+#define         SPLINE_STACK_DEPTH             20
+static Stack    wx_spline_stack[SPLINE_STACK_DEPTH];
+static Stack   *wx_stack_top;
+static int      wx_stack_count;
+
+void wx_clear_stack()
+{
+    wx_stack_top = wx_spline_stack;
+    wx_stack_count = 0;
+}
+
+void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
+{
+    wx_stack_top->x1 = x1;
+    wx_stack_top->y1 = y1;
+    wx_stack_top->x2 = x2;
+    wx_stack_top->y2 = y2;
+    wx_stack_top->x3 = x3;
+    wx_stack_top->y3 = y3;
+    wx_stack_top->x4 = x4;
+    wx_stack_top->y4 = y4;
+    wx_stack_top++;
+    wx_stack_count++;
+}
+
+int wx_spline_pop(double *x1, double *y1, double *x2, double *y2,
+                  double *x3, double *y3, double *x4, double *y4)
+{
+    if (wx_stack_count == 0)
+        return (0);
+    wx_stack_top--;
+    wx_stack_count--;
+    *x1 = wx_stack_top->x1;
+    *y1 = wx_stack_top->y1;
+    *x2 = wx_stack_top->x2;
+    *y2 = wx_stack_top->y2;
+    *x3 = wx_stack_top->x3;
+    *y3 = wx_stack_top->y3;
+    *x4 = wx_stack_top->x4;
+    *y4 = wx_stack_top->y4;
+    return (1);
+}
+
+static bool wx_spline_add_point(double x, double y)
+{
+    wxPoint *point = new wxPoint;
+    point->x = (int) x;
+    point->y = (int) y;
+    wx_spline_point_list.Append((wxObject*)point);
+    return TRUE;
+}
+
+static void wx_spline_draw_point_array(wxDC *dc)
+{
+    dc->DrawLines(&wx_spline_point_list, 0, 0);
+    wxNode *node = wx_spline_point_list.First();
+    while (node)
+    {
+        wxPoint *point = (wxPoint *)node->Data();
+        delete point;
+        delete node;
+        node = wx_spline_point_list.First();
+    }
+}
+
+wxSpline::wxSpline(wxList *list)
+{
+    points = list;
+}
+
+wxSpline::~wxSpline()
+{
+}
+
+void wxSpline::DeletePoints()
+{
+    for(wxNode *node = points->First(); node; node = points->First())
+    {
+        wxPoint *point = (wxPoint *)node->Data();
+        delete point;
+        delete node;
+    }
+    delete points;
 }
 
-//
-// Private functions
-//
 
+#endif // wxUSE_SPLINES
 
index c32978beb71a4de56f95bc2726e847e4abed55c4..ee5ad82aef6cef7e280b80b20df56d50b547bf1c 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
-    #pragma implementation "dcclient.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
-#ifdef __BORLANDC__
-    #pragma hdrstop
-#endif
-
 #include "wx/string.h"
 #include "wx/log.h"
 #include "wx/window.h"
index 7cbd330821f76b4c97a124689b631d859e829e03..7f28afd8dd81e6710e6d47c525623077f8b512fa 100644 (file)
@@ -1,35 +1,72 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dcmemory.cpp
 // Purpose:     wxMemoryDC class
-// Author:      AUTHOR
+// Author:      David Webster
 // Modified by:
-// Created:     01/02/97
+// Created:     10/14/99
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
-// Licence:    wxWindows licence
+// Copyright:   (c) David Webster
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "dcmemory.h"
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+#include "wx/utils.h"
 #endif
 
+#include "wx/os2/private.h"
+
 #include "wx/dcmemory.h"
 
-//-----------------------------------------------------------------------------
-// wxMemoryDC
-//-----------------------------------------------------------------------------
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
+#endif
 
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
+/*
+ * Memory DC
+ *
+ */
 
 wxMemoryDC::wxMemoryDC(void)
 {
-  m_ok = FALSE;
-};
+  // TODO:
+/*
+  m_hDC = (WXHDC) ::CreateCompatibleDC((HDC) NULL);
+  m_ok = (m_hDC != 0);
+  m_bOwnsDC = TRUE;
 
-wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
+  SetBrush(*wxWHITE_BRUSH);
+  SetPen(*wxBLACK_PEN);
+
+  // the background mode is only used for text background
+  // and is set in DrawText() to OPAQUE as required, other-
+  // wise always TRANSPARENT, RR
+  ::SetBkMode( GetHdc(), TRANSPARENT );
+*/
+}
+
+wxMemoryDC::wxMemoryDC(wxDC *old_dc)
 {
-  m_ok = FALSE;
-};
+  // TODO:
+/*
+  old_dc->BeginDrawing();
+
+  m_hDC = (WXHDC) ::CreateCompatibleDC((HDC) old_dc->GetHDC());
+  m_ok = (m_hDC != 0);
+
+  old_dc->EndDrawing();
+
+  SetBrush(*wxWHITE_BRUSH);
+  SetPen(*wxBLACK_PEN);
+
+  // the background mode is only used for text background
+  // and is set in DrawText() to OPAQUE as required, other-
+  // wise always TRANSPARENT, RR
+  ::SetBkMode( GetHdc(), TRANSPARENT );
+*/
+}
 
 wxMemoryDC::~wxMemoryDC(void)
 {
@@ -37,28 +74,18 @@ wxMemoryDC::~wxMemoryDC(void)
 
 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
 {
-  m_selected = bitmap;
-  if (m_selected.Ok())
-  {
-  }
-  else
-  {
-    m_ok = FALSE;
-  };
+   // TODO:
 };
 
-void wxMemoryDC::GetSize( int *width, int *height ) const
+void wxMemoryDC::DoGetSize( int *width, int *height ) const
 {
-  if (m_selected.Ok())
+  if (!m_selectedBitmap.Ok())
   {
-    if (width) (*width) = m_selected.GetWidth();
-    if (height) (*height) = m_selected.GetHeight();
+    *width = 0; *height = 0;
+    return;
   }
-  else
-  {
-    if (width) (*width) = 0;
-    if (height) (*height) = 0;
-  };
+  *width = m_selectedBitmap.GetWidth();
+  *height = m_selectedBitmap.GetHeight();
 };
 
 
index aa26aac8710f9d8947fa33ad21d6fefa82c3694c..d6e1ee7922dd4a50d815713038494182dd9b13e9 100644 (file)
@@ -1,20 +1,22 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dcprint.cpp
 // Purpose:     wxPrinterDC class
-// Author:      Julian Smart
+// Author:      David Webster
 // Modified by:
-// Created:     01/02/97
+// Created:     10/14/99
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:    wxWindows licence
+// Copyright:   (c) David Webster
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "dcprint.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
+
+#define INCL_DEV
+#define INCL_GPI
+#define INCL_PM
+#include<os2.h>
+
 #ifndef WX_PRECOMP
 #endif
 
 IMPLEMENT_CLASS(wxPrinterDC, wxDC)
 #endif
 
-#define INCL_DEV
-#define INCL_GPI
-#define INCL_PM
-#include<os2.h>
 
 // This form is deprecated
 wxPrinterDC::wxPrinterDC(const wxString& driver_name, const wxString& device_name, const wxString& file, bool interactive, int orientation)
index e03bbac0c80d8fbfbb86a792919de9e65948729c..58fc9b97cfefabf3d354555a7c6f801d32ef0b22 100644 (file)
@@ -1,18 +1,29 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dcscreen.cpp
 // Purpose:     wxScreenDC class
-// Author:      AUTHOR
+// Author:      David Webster
 // Modified by:
-// Created:     ??/??/98
+// Created:     10/14/99
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
+// Copyright:   (c) David Webster
 // Licence:    wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "dcscreen.h"
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#define INCL_DEV
+#define INCL_GPI
+#define INCL_PM
+#include<os2.h>
+
+#ifndef WX_PRECOMP
+   #include "wx/string.h"
+   #include "wx/window.h"
 #endif
 
+#include "wx/os2/private.h"
+
 #include "wx/dcscreen.h"
 
 #if !USE_SHARED_LIBRARY
index 90afc5040011fd82f00444ef67138ebb1743cd0e..3cd09826e37497b7c505fccff45283139ee2afbf 100644 (file)
@@ -1,12 +1,12 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dialog.cpp
 // Purpose:     wxDialog class
-// Author:      AUTHOR
+// Author:      David Webster
 // Modified by:
-// Created:     ??/??/98
+// Created:     10/14/99
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
-// Licence:    wxWindows licence
+// Copyright:   (c) David Webster
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/os2/private.h"
 #include "wx/log.h"
 
-#if wxUSE_COMMON_DIALOGS
-#include <commdlg.h>
-#endif
-
 #define wxDIALOG_DEFAULT_X 300
 #define wxDIALOG_DEFAULT_Y 300
 
index 095621b978ebe12a862622298ae8d5f1f48db38d..1dd38fa43a2d9701d976b3dc5b42ee35dd3c66ec 100644 (file)
@@ -1,25 +1,35 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dirdlg.cpp
 // Purpose:     wxDirDialog
-// Author:      AUTHOR
+// Author:      David Webster
 // Modified by:
-// Created:     ??/??/98
+// Created:     10/14/99
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
-// Licence:    wxWindows licence
+// Copyright:   (c) David Webster
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "dirdlg.h"
-#endif
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
 
+#ifndef WX_PRECOMP
+#include <stdio.h>
 #include "wx/defs.h"
 #include "wx/utils.h"
 #include "wx/dialog.h"
 #include "wx/dirdlg.h"
+#endif
 
+#include "wx/os2/private.h"
 #include "wx/cmndata.h"
 
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define wxDIALOG_DEFAULT_X 300
+#define wxDIALOG_DEFAULT_Y 300
+
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_CLASS(wxDirDialog, wxDialog)
 #endif
@@ -31,12 +41,12 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
     m_message = message;
     m_dialogStyle = style;
     m_parent = parent;
-       m_path = defaultPath;
+    m_path = defaultPath;
 }
 
 int wxDirDialog::ShowModal()
 {
     // TODO
-       return wxID_CANCEL;
+    return wxID_CANCEL;
 }
 
index 20e3c39cdeb2334fd6a858a907077840c3d040f5..10a80890e08ef3827a7fda6433eb64b21cf7abca 100644 (file)
@@ -9,11 +9,32 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#include "wx/defs.h"
-#include "wx/utils.h"
-#include "wx/dialog.h"
-#include "wx/filedlg.h"
-#include "wx/intl.h"
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+    #include <stdio.h>
+    #include "wx/defs.h"
+    #include "wx/utils.h"
+    #include "wx/msgdlg.h"
+    #include "wx/dialog.h"
+    #include "wx/filedlg.h"
+    #include "wx/intl.h"
+    #include "wx/log.h"
+#endif
+
+#define INCL_PM
+#include <os2.h>
+
+#include "wx/os2/private.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
 
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_CLASS(wxFileDialog, wxDialog)
@@ -61,6 +82,22 @@ wxString wxFileSelector( const char* title
         return wxEmptyString;
 }
 
+# ifndef MAXPATH
+# define MAXPATH   400
+# endif
+
+# ifndef MAXDRIVE
+# define MAXDRIVE  3
+# endif
+
+# ifndef MAXFILE
+# define MAXFILE   9
+# endif
+
+# ifndef MAXEXT
+# define MAXEXT    5
+# endif
+
 wxString wxFileSelectorEx( const char* title
                           ,const char* defaultDir
                           ,const char* defaultFileName
index e6537319a752b2bd8c80320ca3f2a901ce95c5e6..acf359cdad8a0632330cfbea9b64750247e1d478 100644 (file)
@@ -9,7 +9,7 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#include "wx/app.h"
+int wxEntry(int argc, char *argv[]);
 
 int main(int argc, char* argv[])
 {
index b97f8c24444eff31cf8b014973bdc1d99771c05e..18f5dbe173e787f44c7d40830f986e1689bc0fbf 100644 (file)
@@ -299,7 +299,6 @@ OS2OBJS = \
   ..\os2\$D\checklst.obj \
   ..\os2\$D\choice.obj \
   ..\os2\$D\clipbrd.obj \
-  ..\os2\$D\colordlg.obj \
   ..\os2\$D\colour.obj \
   ..\os2\$D\combobox.obj \
   ..\os2\$D\control.obj \
@@ -339,7 +338,7 @@ OS2OBJS = \
   ..\os2\$D\ownerdrw.obj \
   ..\os2\$D\palette.obj \
   ..\os2\$D\pen.obj \
-  ..\os2\$D\pngread.obj \
+  ..\os2\$D\pnghand.obj \
   ..\os2\$D\print.obj \
   ..\os2\$D\radiobox.obj \
   ..\os2\$D\radiobut.obj \
@@ -356,7 +355,6 @@ OS2LIBOBJS = \
   checklst.obj \
   choice.obj \
   clipbrd.obj \
-  colordlg.obj \
   colour.obj \
   combobox.obj \
   control.obj \
@@ -396,7 +394,7 @@ OS2LIBOBJS = \
   ownerdrw.obj \
   palette.obj \
   pen.obj \
-  pngread.obj \
+  pnghand.obj \
   print.obj \
   radiobox.obj \
   radiobut.obj \
@@ -557,7 +555,6 @@ $(OS2LIBOBJS):
   copy ..\os2\$D\checklst.obj
   copy ..\os2\$D\choice.obj
   copy ..\os2\$D\clipbrd.obj
-  copy ..\os2\$D\colordlg.obj
   copy ..\os2\$D\colour.obj
   copy ..\os2\$D\combobox.obj
   copy ..\os2\$D\control.obj
@@ -597,7 +594,7 @@ $(OS2LIBOBJS):
   copy ..\os2\$D\ownerdrw.obj
   copy ..\os2\$D\pallet.obj
   copy ..\os2\$D\pen.obj
-  copy ..\os2\$D\pngread.obj
+  copy ..\os2\$D\pnghand.obj
   copy ..\os2\$D\print.obj
   copy ..\os2\$D\radiobox.obj
   copy ..\os2\$D\radiobut.obj
index 6355b3d9deb9ee8c92cd9dc10d3aea78cda7fc9c..9d105d5ae998c44f8426a5d7cb248082ac453616 100644 (file)
@@ -2,7 +2,7 @@
 // Name:        notebook.cpp
 // Purpose:     implementation of wxNotebook
 // Author:      David Webster
-// Modified by: 
+// Modified by:
 // Created:     10/12/99
 // RCS-ID:      $Id$
 // Copyright:   (c) David Webster
@@ -115,7 +115,7 @@ bool wxNotebook::Create(wxWindow *parent,
       return FALSE;
 
   // colors and font
-  m_backgroundColour = wxColour(GetSysColor(COLOR_BTNFACE));
+// TODO:  m_backgroundColour = wxColour(GetSysColor(COLOR_BTNFACE));
   m_foregroundColour = *wxBLACK ;
 
     // TODO:
@@ -139,7 +139,7 @@ bool wxNotebook::Create(wxWindow *parent,
     tabStyle |= TCS_VERTICAL;
   if (m_windowStyle & wxNB_RIGHT)
     tabStyle |= TCS_VERTICAL|TCS_RIGHT;
-        
+
 
   if ( !MSWCreate(GetId(), GetParent(), WC_TABCONTROL,
                   this, NULL, pos.x, pos.y, size.x, size.y,
@@ -233,7 +233,7 @@ bool wxNotebook::SetPageImage(int nPage, int nImage)
 }
 
 void wxNotebook::SetImageList(wxImageList* imageList)
-{ 
+{
     m_pImageList = imageList;
     // TODO
 }
@@ -309,7 +309,7 @@ bool wxNotebook::InsertPage(int nPage,
     // save the pointer to the page
     m_aPages.Insert(pPage, nPage);
 
-    // some page must be selected: either this one or the first one if there is 
+    // some page must be selected: either this one or the first one if there is
     // still no selection
     if ( bSelect )
         m_nSelection = nPage;
@@ -365,7 +365,7 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event)
         int sel = event.GetOldSelection();
         if ( sel != -1 )
             m_aPages[sel]->Show(FALSE);
-      
+
         sel = event.GetSelection();
         if ( sel != -1 )
         {
@@ -373,7 +373,7 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event)
             pPage->Show(TRUE);
             pPage->SetFocus();
         }
-      
+
         m_nSelection = sel;
   }
     // we want to give others a chance to process this message as well
@@ -440,13 +440,13 @@ bool wxNotebook::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
       return wxControl::MSWOnNotify(idCtrl, lParam, result);
   }
 */
-    event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
+// TODO:    event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
     event.SetOldSelection(m_nSelection);
     event.SetEventObject(this);
     event.SetInt(idCtrl);
 
     bool processed = GetEventHandler()->ProcessEvent(event);
-    *result = !event.IsAllowed();
+// TODO:   *result = !event.IsAllowed();
     return processed;
 }
 
index 458c02a3b213de5e44c0782731fc18ae48851a5c..f7dd9b66215b0e21417ea240543e35c371c83f42 100644 (file)
@@ -2,7 +2,7 @@
 // Name:        msw/ownerdrw.cpp
 // Purpose:     implementation of wxOwnerDrawn class
 // Author:      David Webster
-// Modified by: 
+// Modified by:
 // Created:     10/12/99
 // RCS-ID:      $Id$
 // Copyright:   (c) David Webster
@@ -32,7 +32,7 @@
 
 // ctor
 // ----
-wxOwnerDrawn::wxOwnerDrawn(const wxString& str, 
+wxOwnerDrawn::wxOwnerDrawn(const wxString& str,
                            bool bCheckable, bool bMenuItem)
             : m_strName(str)
 {
@@ -100,6 +100,8 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODSt
   // set the colors
   // --------------
   DWORD colBack, colText;
+// TODO:
+/*
   if ( st & wxODSelected ) {
     colBack = GetSysColor(COLOR_HIGHLIGHT);
     colText = GetSysColor(COLOR_HIGHLIGHTTEXT);
@@ -109,14 +111,14 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODSt
     colBack = m_colBack.Ok() ? ToRGB(m_colBack) : GetSysColor(COLOR_WINDOW);
     colText = m_colText.Ok() ? ToRGB(m_colText) : GetSysColor(COLOR_WINDOWTEXT);
   }
-        
-    dc.SetTextForeground(wxColor(UnRGB(colText)));
-    dc.SetTextBackground(wxColor(UnRGB(colBack)));
+*/
+//    dc.SetTextForeground(wxColor(UnRGB(colText)));
+//    dc.SetTextBackground(wxColor(UnRGB(colBack)));
 
   // select the font and draw the text
   // ---------------------------------
 
-  // determine where to draw and leave space for a check-mark. 
+  // determine where to draw and leave space for a check-mark.
   int x = rc.x + GetMarginWidth();
 
     dc.SetFont(GetFont());
@@ -136,14 +138,10 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODSt
       RECT rect = { 0, 0, GetMarginWidth(), m_nHeight };
 
         // finally copy it to screen DC and clean up
-      BitBlt(hdc, rc.x, rc.y, GetMarginWidth(), m_nHeight, 
+      BitBlt(hdc, rc.x, rc.y, GetMarginWidth(), m_nHeight,
              hdcMem, 0, 0, SRCCOPY);
       DeleteDC(hdcMem);
 */
-#else
-        // #### to do: perhaps using Marlett font (create equiv. font under X)
-//        wxFAIL("not implemented");
-#endif  //O_DRAW_NATIVE_API
     }
   }
   else {
@@ -161,22 +159,22 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODSt
       wxASSERT((nBmpWidth <= rc.GetWidth()) && (nBmpHeight <= rc.GetHeight()));
 
       //MT: blit with mask enabled.
-      dc.Blit(rc.x + (GetMarginWidth() - nBmpWidth) / 2, 
-              rc.y + (m_nHeight - nBmpHeight) /2, 
-              nBmpWidth, nBmpHeight, 
+// TODO:
+/*
+      dc.Blit(rc.x + (GetMarginWidth() - nBmpWidth) / 2,
+              rc.y + (m_nHeight - nBmpHeight) /2,
+              nBmpWidth, nBmpHeight,
               &dcMem, 0, 0, wxCOPY,true);
 
       if ( st & wxODSelected ) {
-// TODO:
-/*
         #ifdef  O_DRAW_NATIVE_API
-          RECT rectBmp = { rc.GetLeft(), rc.GetTop(), 
-                           rc.GetLeft() + GetMarginWidth(), 
+          RECT rectBmp = { rc.GetLeft(), rc.GetTop(),
+                           rc.GetLeft() + GetMarginWidth(),
                            rc.GetTop() + m_nHeight };
           SetBkColor(hdc, colBack);
           DrawEdge(hdc, &rectBmp, EDGE_RAISED, BF_SOFT | BF_RECT);
-*/
       }
+*/
     }
   }
 /*
index 889d289d4b14df9da61eaafb307f5451b1f998b2..0a41e354d1a74c41328d81cb1524995ca924a3e6 100644 (file)
@@ -91,6 +91,7 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
   M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal);
   LocalFree((HANDLE)npPal);
 */
+  return FALSE;
 }
 
 int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
index 3d6fea538d68c4b21f180a9a2886d68bf457d5fc..48da7cb43436b3941cfab29db6dfffc514645961 100644 (file)
@@ -133,7 +133,7 @@ bool wxPen::FreeResource(bool force)
 {
     if (M_PENDATA && (M_PENDATA->m_hPen != 0))
     {
-        DeleteObject((HPEN) M_PENDATA->m_hPen);
+// TODO:        DeleteObject((HPEN) M_PENDATA->m_hPen);
         M_PENDATA->m_hPen = 0;
         return TRUE;
     }
@@ -160,7 +160,7 @@ void wxPen::SetColour(const wxColour& col)
     Unshare();
 
     M_PENDATA->m_colour = col;
-  
+
     RealizeResource();
 }
 
@@ -169,7 +169,7 @@ void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
     Unshare();
 
     M_PENDATA->m_colour.Set(r, g, b);
-  
+
     RealizeResource();
 }
 
@@ -197,7 +197,7 @@ void wxPen::SetStipple(const wxBitmap& Stipple)
 
     M_PENDATA->m_stipple = Stipple;
     M_PENDATA->m_style = wxSTIPPLE;
-  
+
     RealizeResource();
 }
 
@@ -207,7 +207,7 @@ void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
 
     M_PENDATA->m_nbDash = nb_dashes;
     M_PENDATA->m_dash = (wxDash *)Dash;
-  
+
     RealizeResource();
 }
 
@@ -229,22 +229,13 @@ void wxPen::SetCap(int Cap)
     RealizeResource();
 }
 
-void wxPen::SetCap(int Cap)
-{
-    Unshare();
-
-    M_PENDATA->m_cap = Cap;
-
-    RealizeResource();
-}
-
 int wx2os2PenStyle(int wx_style)
 {
     int cstyle;
 // TODO:
 /*
     switch (wx_style)
-    { 
+    {
        case wxDOT:
            cstyle = PS_DOT;
        break;
diff --git a/src/os2/pnghand.cpp b/src/os2/pnghand.cpp
new file mode 100644 (file)
index 0000000..c5c3bad
--- /dev/null
@@ -0,0 +1,785 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        pnghand.cpp
+// Purpose:     Implements a PNG reader class + handler
+// Author:      David Webster
+// Modified by:
+// Created:     10/10/99
+// RCS-ID:      $Id$
+// Copyright:   (c) David Webster
+// Licence:     wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#if wxUSE_IOSTREAMH
+#   include <fstream.h>
+#else
+#   include <fstream>
+#endif
+
+#define INCL_DOS
+#define INCL_PM
+#define INCL_GPI
+#include <os2.h>
+#include "wx/palette.h"
+#include "wx/bitmap.h"
+#include "wx/utils.h"
+#include "wx/os2/pngread.h"
+
+extern "C" {
+#include "../png/png.h"
+}
+
+extern "C" void png_read_init PNGARG((png_structp png_ptr));
+extern "C" void png_write_init PNGARG((png_structp png_ptr));
+
+#ifndef GlobalAllocPtr
+#define     GlobalPtrHandle(lp)         \
+                ((HGLOBAL)GlobalHandle(lp))
+
+#define     GlobalLockPtr(lp)                \
+                ((BOOL)GlobalLock(GlobalPtrHandle(lp)))
+#define     GlobalUnlockPtr(lp)      \
+                GlobalUnlock(GlobalPtrHandle(lp))
+
+#define     GlobalAllocPtr(flags, cb)        \
+                (GlobalLock(GlobalAlloc((flags), (cb))))
+#define     GlobalReAllocPtr(lp, cbNew, flags)       \
+                (GlobalUnlockPtr(lp), GlobalLock(GlobalReAlloc(GlobalPtrHandle(lp) , (cbNew), (flags))))
+#define     GlobalFreePtr(lp)                \
+                (GlobalUnlockPtr(lp), (BOOL)GlobalFree(GlobalPtrHandle(lp)))
+#endif
+
+
+void
+ima_png_error(png_struct *png_ptr, char *message)
+{
+//        wxMessageBox(message, "PNG error");
+
+  longjmp(png_ptr->jmpbuf, 1);
+}
+
+
+// static wxGifReaderIter* iter;
+wxPalette *wxCopyPalette(const wxPalette *cmap);
+
+wxPNGReader::wxPNGReader()
+{
+  filetype = 0;
+  RawImage = NULL;      //  Image data
+
+  Width = 0; Height = 0;       //  Dimensions
+  Depth = 0;           // (bits x pixel)
+  ColorType = 0;        // Bit 1 = Palette used
+                  // Bit 2 = Color used
+                  // Bit 3 = Alpha used
+
+  EfeWidth = 0;         // Efective Width
+
+  lpbi = NULL;
+  bgindex = -1;
+  Palette = 0;
+  imageOK = FALSE;
+}
+
+wxPNGReader::wxPNGReader ( wxChar* ImageFileName )
+{
+  imageOK = FALSE;
+  filetype = 0;
+  RawImage = NULL;      //  Image data
+
+  Width = 0; Height = 0;       //  Dimensions
+  Depth = 0;           // (bits x pixel)
+  ColorType = 0;        // Bit 1 = Palette used
+                  // Bit 2 = Color used
+                  // Bit 3 = Alpha used
+
+  EfeWidth = 0;         // Efective Width
+
+  lpbi = NULL;
+  bgindex = -1;
+  Palette = 0;
+
+  imageOK = ReadFile (ImageFileName);
+}
+
+void
+wxPNGReader::Create(int width, int height, int depth, int colortype)
+{
+  Width = width; Height = height; Depth = depth;
+  ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0);
+
+  if (lpbi)  {
+//   GlobalFreePtr(lpbi);
+//   delete Palette;
+  }
+  RawImage = 0;
+  Palette = 0;
+  lpbi = 0; // TODO: wxDibCreate(Depth, Width, Height);
+  if (lpbi)  {
+    RawImage = 0; //TODO: (ImagePointerType)wxDibPtr(lpbi);
+    EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
+        imageOK = TRUE;
+  }
+}
+
+wxPNGReader::~wxPNGReader ( )
+{
+  if (lpbi)  {
+// TODO:   GlobalFreePtr(lpbi);
+   delete Palette;
+  }
+}
+
+
+int wxPNGReader::GetIndex(int x, int y)
+{
+  if (!Inside(x, y) || (Depth>8)) return -1;
+
+  ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+  int index = (int)(*ImagePointer);
+  return index;
+}
+
+bool wxPNGReader::GetRGB(int x, int y, byte* r, byte* g, byte* b)
+{
+  if (!Inside(x, y)) return FALSE;
+
+  if (Palette) {
+   return Palette->GetRGB(GetIndex(x, y), r, g, b);
+/*   PALETTEENTRY entry;
+   ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry);
+   *r = entry.peRed;
+   *g = entry.peGreen;
+   *b = entry.peBlue;  */
+  } else {
+   ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+   *b = ImagePointer[0];
+   *g = ImagePointer[1];
+   *r = ImagePointer[2];
+  }
+  return TRUE;
+}
+
+
+bool wxPNGReader::SetIndex(int x, int y, int index)
+{
+  if (!Inside(x, y) || (Depth>8)) return FALSE;
+
+  ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+  *ImagePointer = index;
+
+  return TRUE;
+}
+
+bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b)
+{
+  if (!Inside(x, y)) return FALSE;
+
+  if (ColorType & COLORTYPE_PALETTE)
+  {
+   if (!Palette) return FALSE;
+   SetIndex(x, y, Palette->GetPixel(r, g, b));
+
+  } else {
+   ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+   ImagePointer[0] = b;
+   ImagePointer[1] = g;
+   ImagePointer[2] = r;
+  }
+
+  return TRUE;
+}
+
+bool wxPNGReader::SetPalette(wxPalette* colourmap)
+{
+  if (!colourmap)
+   return FALSE;
+  ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
+  Palette = colourmap;
+// TODO:  return (wxDibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
+  return FALSE;
+}
+
+bool
+wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
+{
+  Palette = new wxPalette();
+  if (!Palette)
+   return FALSE;
+
+  if (!g) g = r;
+  if (!b) b = g;
+  Palette->Create(n, r, g, b);
+  ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
+// TODO:  return (wxDibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
+  return FALSE;
+}
+
+bool
+wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
+{
+  Palette = new wxPalette();
+  if (!Palette)
+   return FALSE;
+
+  byte r[256], g[256], b[256];
+
+  for(int i=0; i<n; i++)
+  {
+   r[i] = rgb_struct[i].red;
+   g[i] = rgb_struct[i].green;
+   b[i] = rgb_struct[i].blue;
+  }
+  // Added by JACS copying from Andrew Davison's additions
+  // to GIF-reading code
+  // Make transparency colour black...
+  if (bgindex != -1)
+    r[bgindex] = g[bgindex] = b[bgindex] = 0;
+
+  Palette->Create(n, r, g, b);
+  ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
+// TODO:  return (wxDibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
+  return FALSE;
+}
+
+void wxPNGReader::NullData()
+{
+  lpbi = NULL;
+  Palette = NULL;
+}
+
+wxBitmap* wxPNGReader::GetBitmap()
+{
+    wxBitmap *bitmap = new wxBitmap;
+    if ( InstantiateBitmap(bitmap) )
+        return bitmap;
+    else
+    {
+        delete bitmap;
+        return NULL;
+    }
+}
+
+bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap)
+{
+// TODO:
+/*
+  HDC dc = ::CreateCompatibleDC(NULL);
+
+  if (dc)
+  {
+        // tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it
+        // is a memory dc that must have a bitmap selected into it)
+        HDC dc2 = GetDC(NULL);
+        HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight());
+        ReleaseDC(NULL, dc2);
+        HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, tmpBitmap);
+
+        if ( Palette )
+        {
+            ::SelectPalette(dc, (HPALETTE) Palette->GetHPALETTE(), FALSE);
+        ::RealizePalette(dc);
+        }
+
+    HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi,
+        CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS);
+
+        ::SelectPalette(dc, NULL, TRUE);
+        ::SelectObject(dc, oldBitmap);
+        ::DeleteObject(tmpBitmap);
+        ::DeleteDC(dc);
+
+        if ( hBitmap )
+        {
+          bitmap->SetHBITMAP((WXHBITMAP) hBitmap);
+          bitmap->SetWidth(GetWidth());
+          bitmap->SetHeight(GetHeight());
+          bitmap->SetDepth(GetDepth());
+          if ( GetDepth() > 1 && Palette )
+            bitmap->SetPalette(*Palette);
+          bitmap->SetOk(TRUE);
+
+
+          // Make a mask if appropriate
+          if ( bgindex > -1 )
+          {
+            wxMask *mask = CreateMask();
+            bitmap->SetMask(mask);
+          }
+      return TRUE;
+        }
+        else
+        {
+          return FALSE;
+        }
+  }
+  else
+    {
+    return FALSE;
+    }
+*/
+  return FALSE;
+}
+
+wxPalette *wxCopyPalette(const wxPalette *cmap)
+{
+  // To get number of entries...
+  WORD count = 0;
+// TODO:  ::GetObject((HPALETTE) cmap->GetHPALETTE(), sizeof(WORD), &count);
+// TODO:
+/*
+  LOGPALETTE* logPal = (LOGPALETTE*)
+     new BYTE[sizeof(LOGPALETTE) + count*sizeof(PALETTEENTRY)];
+  logPal->palVersion = 0x300;
+  logPal->palNumEntries = count;
+  ::GetPaletteEntries((HPALETTE) cmap->GetHPALETTE(), 0, count, logPal->palPalEntry);
+
+  HPALETTE hPalette = ::CreatePalette(logPal);
+  delete[] logPal;
+*/
+  wxPalette *newCmap = new wxPalette;
+// TODO:  newCmap->SetHPALETTE((WXHPALETTE) hPalette);
+  return newCmap;
+}
+
+wxMask *wxPNGReader::CreateMask()
+{
+// TODO:
+/*
+    HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL);
+
+  HDC dc = ::CreateCompatibleDC(NULL);
+    HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap);
+
+    int bgIndex = GetBGIndex();
+
+    int x,y;
+
+    for (x=0; x<GetWidth(); x++)
+    {
+        for (y=0; y<GetHeight(); y++)
+        {
+            int index = GetIndex(x, y);
+            if ( index == bgIndex )
+                ::SetPixel(dc, x, GetHeight() - y - 1, RGB(0, 0, 0));
+            else
+                ::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255));
+
+      }
+    }
+    ::SelectObject(dc, oldBitmap);
+*/
+    wxMask *mask = new wxMask;
+// TODO:    mask->SetMaskBitmap((WXHBITMAP) hBitmap);
+    return mask;
+}
+
+bool wxPNGReader::ReadFile(wxChar * ImageFileName)
+{
+    if (ImageFileName)
+        wxStrcpy(filename, ImageFileName);
+
+    /* open the file */
+    FILE *fp = fopen(wxConvFile.cWX2MB(filename), "rb");
+    if (!fp)
+        return FALSE;
+
+    /* allocate the necessary structures */
+    png_struct *png_ptr = new (png_struct);
+    if (!png_ptr)
+    {
+        fclose(fp);
+        return FALSE;
+    }
+
+    png_info *info_ptr = new (png_info);
+    if (!info_ptr)
+    {
+        fclose(fp);
+        delete(png_ptr);
+        return FALSE;
+    }
+
+    /* set error handling */
+    if (setjmp(png_ptr->jmpbuf))
+    {
+        png_read_destroy(png_ptr, info_ptr, (png_info *)0);
+        fclose(fp);
+        delete(png_ptr);
+        delete(info_ptr);
+
+        /* If we get here, we had a problem reading the file */
+        return FALSE;
+    }
+    //png_set_error(ima_png_error, NULL);
+
+    /* initialize the structures, info first for error handling */
+    png_info_init(info_ptr);
+    png_read_init(png_ptr);
+
+    /* set up the input control */
+    png_init_io(png_ptr, fp);
+
+    /* read the file information */
+    png_read_info(png_ptr, info_ptr);
+
+    /* allocate the memory to hold the image using the fields
+       of png_info. */
+    png_color_16 my_background={ 0, 31, 127, 255, 0 };
+
+    if (info_ptr->valid & PNG_INFO_bKGD)
+    {
+        png_set_background(png_ptr, &(info_ptr->background),
+                PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
+        if ( info_ptr->num_palette > 0 )
+            bgindex = info_ptr->background.index;
+    }
+    else   {
+        png_set_background(png_ptr, &my_background,
+                PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+
+        // Added by JACS: guesswork!
+        if ( info_ptr->num_trans != 0 )
+            bgindex = info_ptr->num_trans - 1 ;
+    }
+
+    /* tell libpng to strip 16 bit depth files down to 8 bits */
+    if (info_ptr->bit_depth == 16)
+        png_set_strip_16(png_ptr);
+
+    int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24;
+    Create(info_ptr->width, info_ptr->height, pixel_depth,
+            info_ptr->color_type);
+
+    if (info_ptr->num_palette>0)
+    {
+        SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette);
+    }
+
+    int row_stride = info_ptr->width * ((pixel_depth+7)>>3);
+    //  printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride);
+    //  printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth);
+
+    byte *row_pointers = new byte[row_stride];
+
+    /* turn on interlace handling */
+    int number_passes;
+    if (info_ptr->interlace_type)
+        number_passes = png_set_interlace_handling(png_ptr);
+    else
+        number_passes = 1;
+    //  printf("NP = %d ", number_passes);
+
+    // don't use the object to prevent warnings from VC++ about "unportable
+    // interaction between setjmp and C++ object destruction" (this is a correct
+    // warning, of course!)
+    wxPNGReaderIter *iter = new wxPNGReaderIter(this);
+    for (int pass=0; pass< number_passes; pass++)
+    {
+        iter->upset();
+        int y=0;
+        do  {
+            //(unsigned char *)iter.GetRow();
+            if (info_ptr->interlace_type)  {
+                if (pass>0)
+                    iter->GetRow(row_pointers, row_stride);
+                png_read_row(png_ptr, row_pointers, NULL);
+            }
+            else
+                png_read_row(png_ptr, row_pointers, NULL);
+
+            iter->SetRow(row_pointers, row_stride);
+            y++;
+        } while(iter->PrevRow());
+        //  printf("Y=%d ",y);
+    }
+
+    delete iter;
+    delete[] row_pointers;
+
+    /* read the rest of the file, getting any additional chunks
+       in info_ptr */
+    png_read_end(png_ptr, info_ptr);
+
+    /* clean up after the read, and free any memory allocated */
+    png_read_destroy(png_ptr, info_ptr, (png_info *)0);
+
+    /* free the structures */
+    delete(png_ptr);
+    delete(info_ptr);
+
+    /* close the file */
+    fclose(fp);
+
+    /* that's it */
+    return TRUE;
+}
+
+
+/* write a png file */
+
+bool wxPNGReader::SaveFile(wxChar * ImageFileName)
+{
+  if (ImageFileName)
+   wxStrcpy(filename, ImageFileName);
+
+  wxPNGReaderIter iter(this);
+  FILE *fp;
+   png_struct *png_ptr;
+  png_info *info_ptr;
+
+   /* open the file */
+  fp = fopen(wxConvFile.cWX2MB(filename), "wb");
+  if (!fp)
+    return FALSE;
+
+  /* allocate the necessary structures */
+  png_ptr = new (png_struct);
+  if (!png_ptr)
+  {
+    fclose(fp);
+    return FALSE;
+  }
+
+  info_ptr = new (png_info);
+  if (!info_ptr)
+  {
+    fclose(fp);
+    delete(png_ptr);
+    return FALSE;
+  }
+
+  /* set error handling */
+  if (setjmp(png_ptr->jmpbuf))
+  {
+    png_write_destroy(png_ptr);
+    fclose(fp);
+    delete(png_ptr);
+    delete(info_ptr);
+
+    /* If we get here, we had a problem reading the file */
+    return FALSE;
+  }
+        //png_set_error(ima_png_error, NULL);
+
+//  printf("writig pg %s ", filename);
+   /* initialize the structures */
+  png_info_init(info_ptr);
+  png_write_init(png_ptr);
+
+  int row_stride = GetWidth() * ((GetDepth()+7)>>3);
+  /* set up the output control */
+   png_init_io(png_ptr, fp);
+
+  /* set the file information here */
+  info_ptr->width = GetWidth();
+  info_ptr->height = GetHeight();
+  info_ptr->pixel_depth = GetDepth();
+  info_ptr->channels = (GetDepth()>8) ? 3: 1;
+  info_ptr->bit_depth = GetDepth()/info_ptr->channels;
+  info_ptr->color_type = GetColorType();
+  info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0;
+  info_ptr->valid = 0;
+  info_ptr->rowbytes = row_stride;
+
+
+// printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels);
+  /* set the palette if there is one */
+  if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette())
+  {
+//    printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
+    info_ptr->valid |= PNG_INFO_PLTE;
+    info_ptr->palette = new png_color[256];
+    info_ptr->num_palette = 256;
+    for (int i=0; i<256; i++)
+     GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
+  }
+//    printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
+
+
+   /* optional significant bit chunk */
+//   info_ptr->valid |= PNG_INFO_sBIT;
+//   info_ptr->sig_bit = true_bit_depth;
+
+  /* optional gamma chunk */
+//   info_ptr->valid |= PNG_INFO_gAMA;
+//   info_ptr->gamma = gamma;
+
+  /* other optional chunks */
+
+   /* write the file information */
+   png_write_info(png_ptr, info_ptr);
+
+   /* set up the transformations you want.  Note that these are
+      all optional.  Only call them if you want them */
+
+  /* shift the pixels up to a legal bit depth and fill in
+      as appropriate to correctly scale the image */
+//   png_set_shift(png_ptr, &(info_ptr->sig_bit));
+
+  /* pack pixels into bytes */
+//   png_set_packing(png_ptr);
+
+  /* flip bgr pixels to rgb */
+//   png_set_bgr(png_ptr);
+
+   /* swap bytes of 16 bit files to most significant bit first */
+//   png_set_swap(png_ptr);
+
+   /* get rid of filler bytes, pack rgb into 3 bytes */
+//   png_set_rgbx(png_ptr);
+
+/* If you are only writing one row at a time, this works */
+
+  byte *row_pointers = new byte[row_stride];
+    iter.upset();
+  do  {
+//    (unsigned char *)iter.GetRow();
+    iter.GetRow(row_pointers, row_stride);
+    png_write_row(png_ptr, row_pointers);
+  } while(iter.PrevRow());
+
+        delete[] row_pointers;
+
+/* write the rest of the file */
+   png_write_end(png_ptr, info_ptr);
+
+  /* clean up after the write, and free any memory allocated */
+   png_write_destroy(png_ptr);
+
+   /* if you malloced the palette, free it here */
+   if (info_ptr->palette)
+    delete[] (info_ptr->palette);
+
+  /* free the structures */
+  delete(png_ptr);
+  delete(info_ptr);
+
+  /* close the file */
+  fclose(fp);
+
+  /* that's it */
+  return TRUE;
+}
+
+static int Power(int x, int y)
+{
+    int z = 1;
+    int i;
+    for ( i = 0; i < y; i++)
+    {
+        z *= x;
+    }
+    return z;
+}
+
+static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
+  'C', 'D', 'E', 'F' };
+
+static void DecToHex(int dec, char *buf)
+{
+  int firstDigit = (int)(dec/16.0);
+  int secondDigit = (int)(dec - (firstDigit*16.0));
+  buf[0] = hexArray[firstDigit];
+  buf[1] = hexArray[secondDigit];
+  buf[2] = 0;
+}
+
+
+bool wxPNGReader::SaveXPM(wxChar *filename, wxChar *name)
+{
+    wxChar nameStr[256];
+    if ( name )
+        wxStrcpy(nameStr, name);
+    else
+    {
+        wxStrcpy(nameStr, filename);
+        wxStripExtension(nameStr);
+    }
+
+    if ( GetDepth() > 4 )
+    {
+        // Only a depth of 4 and below allowed
+        return FALSE;
+    }
+
+    if ( !GetPalette() )
+        return FALSE;
+
+    ofstream str(wxConvFile.cWX2MB(filename));
+    if ( str.bad() )
+        return FALSE;
+
+    int noColours = Power(2, GetDepth());
+
+    // Output header
+    str << "/* XPM */\n";
+    str << "static char * " << nameStr << "_xpm[] = {\n";
+    str << "\"" << GetWidth() << " " << GetHeight() << " " << noColours << " 1\",\n";
+
+    // Output colourmap
+    int base = 97 ; // start from 'a'
+
+    unsigned char red, green, blue;
+    char hexBuf[4];
+    int i;
+    for ( i = 0; i < noColours; i ++)
+    {
+        str << "\"" << (char)(base + i) << "      c #";
+        GetPalette()->GetRGB(i, &red, &green, &blue);
+        DecToHex(red, hexBuf);
+        str << hexBuf;
+        DecToHex(green, hexBuf);
+        str << hexBuf;
+        DecToHex(blue, hexBuf);
+        str << hexBuf;
+        str << "\",\n";
+    }
+
+    // Output the data
+    int x, y;
+    for ( y = 0; y < GetHeight(); y++)
+    {
+        str << "\"";
+        for ( x = 0; x < GetWidth(); x++)
+        {
+            int index = GetIndex(x, y);
+            str << (char)(base + index) ;
+        }
+        str << "\",\n";
+    }
+
+    str << "};\n";
+    str.flush();
+
+    return TRUE;
+}
+
+#include <wx/os2/pnghand.h>
+
+IMPLEMENT_DYNAMIC_CLASS(wxPNGFileHandler, wxBitmapHandler)
+
+bool wxPNGFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
+    int desiredWidth, int desiredHeight)
+{
+    wxPNGReader reader;
+    if (reader.ReadFile(WXSTRINGCAST name))
+    {
+        return reader.InstantiateBitmap(bitmap);
+    }
+    else
+        return FALSE;
+}
+
+bool wxPNGFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *pal)
+{
+    return FALSE;
+}
+
+
diff --git a/src/os2/pngread.cpp b/src/os2/pngread.cpp
deleted file mode 100644 (file)
index e9cb55f..0000000
+++ /dev/null
@@ -1,783 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name:        pnghand.cpp
-// Purpose:     Implements a PNG reader class + handler
-// Author:      David Webster
-// Modified by:
-// Created:     10/10/99
-// RCS-ID:      $Id$
-// Copyright:   (c) David Webster
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#if wxUSE_IOSTREAMH
-#   include <fstream.h>
-#else
-#   include <fstream>
-#endif
-
-#define INCL_DOS
-#define INCL_PM
-#define INCL_GPI
-#include <os2.h>
-#include "wx/palette.h"
-#include "wx/bitmap.h"
-#include "wx/utils.h"
-#include "wx/msw/pngread.h"
-#include "wx/msw/dibutils.h"
-
-extern "C" {
-#include "../png/png.h"
-}
-
-extern "C" void png_read_init PNGARG((png_structp png_ptr));
-extern "C" void png_write_init PNGARG((png_structp png_ptr));
-
-#ifndef GlobalAllocPtr
-#define     GlobalPtrHandle(lp)         \
-                ((HGLOBAL)GlobalHandle(lp))
-
-#define     GlobalLockPtr(lp)                \
-                ((BOOL)GlobalLock(GlobalPtrHandle(lp)))
-#define     GlobalUnlockPtr(lp)      \
-                GlobalUnlock(GlobalPtrHandle(lp))
-
-#define     GlobalAllocPtr(flags, cb)        \
-                (GlobalLock(GlobalAlloc((flags), (cb))))
-#define     GlobalReAllocPtr(lp, cbNew, flags)       \
-                (GlobalUnlockPtr(lp), GlobalLock(GlobalReAlloc(GlobalPtrHandle(lp) , (cbNew), (flags))))
-#define     GlobalFreePtr(lp)                \
-                (GlobalUnlockPtr(lp), (BOOL)GlobalFree(GlobalPtrHandle(lp)))
-#endif
-
-
-void
-ima_png_error(png_struct *png_ptr, char *message)
-{
-//        wxMessageBox(message, "PNG error");
-
-  longjmp(png_ptr->jmpbuf, 1);
-}
-
-
-// static wxGifReaderIter* iter;
-wxPalette *wxCopyPalette(const wxPalette *cmap);
-
-wxPNGReader::wxPNGReader()
-{
-  filetype = 0;
-  RawImage = NULL;      //  Image data
-
-  Width = 0; Height = 0;       //  Dimensions
-  Depth = 0;           // (bits x pixel)
-  ColorType = 0;        // Bit 1 = Palette used
-                  // Bit 2 = Color used
-                  // Bit 3 = Alpha used
-
-  EfeWidth = 0;         // Efective Width
-
-  lpbi = NULL;
-  bgindex = -1;
-  Palette = 0;
-  imageOK = FALSE;
-}
-
-wxPNGReader::wxPNGReader ( wxChar* ImageFileName )
-{
-  imageOK = FALSE;
-  filetype = 0;
-  RawImage = NULL;      //  Image data
-
-  Width = 0; Height = 0;       //  Dimensions
-  Depth = 0;           // (bits x pixel)
-  ColorType = 0;        // Bit 1 = Palette used
-                  // Bit 2 = Color used
-                  // Bit 3 = Alpha used
-
-  EfeWidth = 0;         // Efective Width
-
-  lpbi = NULL;
-  bgindex = -1;
-  Palette = 0;
-
-  imageOK = ReadFile (ImageFileName);
-}
-
-void
-wxPNGReader::Create(int width, int height, int depth, int colortype)
-{
-  Width = width; Height = height; Depth = depth;
-  ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0);
-
-  if (lpbi)  {
-#ifdef __WIN16__
-   GlobalFreePtr((unsigned int) lpbi);
-#else
-   GlobalFreePtr(lpbi);
-#endif
-//   delete Palette;
-  }
-  RawImage = 0;
-  Palette = 0;
-  lpbi = wxDibCreate(Depth, Width, Height);
-  if (lpbi)  {
-    RawImage = (ImagePointerType)wxDibPtr(lpbi);
-    EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
-        imageOK = TRUE;
-  }
-}
-
-wxPNGReader::~wxPNGReader ( )
-{
-  if (lpbi)  {
-#ifdef __WIN16__
-   GlobalFreePtr((unsigned int) lpbi);
-#else
-   GlobalFreePtr(lpbi);
-#endif
-   delete Palette;
-  }
-}
-
-
-int wxPNGReader::GetIndex(int x, int y)
-{
-  if (!Inside(x, y) || (Depth>8)) return -1;
-
-  ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
-  int index = (int)(*ImagePointer);
-  return index;
-}
-
-bool wxPNGReader::GetRGB(int x, int y, byte* r, byte* g, byte* b)
-{
-  if (!Inside(x, y)) return FALSE;
-
-  if (Palette) {
-   return Palette->GetRGB(GetIndex(x, y), r, g, b);
-/*   PALETTEENTRY entry;
-   ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry);
-   *r = entry.peRed;
-   *g = entry.peGreen;
-   *b = entry.peBlue;  */
-  } else {
-   ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
-   *b = ImagePointer[0];
-   *g = ImagePointer[1];
-   *r = ImagePointer[2];
-  }
-  return TRUE;
-}
-
-
-bool wxPNGReader::SetIndex(int x, int y, int index)
-{
-  if (!Inside(x, y) || (Depth>8)) return FALSE;
-
-  ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
-  *ImagePointer = index;
-
-  return TRUE;
-}
-
-bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b)
-{
-  if (!Inside(x, y)) return FALSE;
-
-  if (ColorType & COLORTYPE_PALETTE)
-  {
-   if (!Palette) return FALSE;
-   SetIndex(x, y, Palette->GetPixel(r, g, b));
-
-  } else {
-   ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
-   ImagePointer[0] = b;
-   ImagePointer[1] = g;
-   ImagePointer[2] = r;
-  }
-
-  return TRUE;
-}
-
-bool wxPNGReader::SetPalette(wxPalette* colourmap)
-{
-  if (!colourmap)
-   return FALSE;
-  ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
-  Palette = colourmap;
-  return (wxDibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
-}
-
-bool
-wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
-{
-  Palette = new wxPalette();
-  if (!Palette)
-   return FALSE;
-
-  if (!g) g = r;
-  if (!b) b = g;
-  Palette->Create(n, r, g, b);
-  ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
-  return (wxDibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
-}
-
-bool
-wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
-{
-  Palette = new wxPalette();
-  if (!Palette)
-   return FALSE;
-
-  byte r[256], g[256], b[256];
-
-  for(int i=0; i<n; i++)
-  {
-   r[i] = rgb_struct[i].red;
-   g[i] = rgb_struct[i].green;
-   b[i] = rgb_struct[i].blue;
-  }
-  // Added by JACS copying from Andrew Davison's additions
-  // to GIF-reading code
-  // Make transparency colour black...
-  if (bgindex != -1)
-    r[bgindex] = g[bgindex] = b[bgindex] = 0;
-
-  Palette->Create(n, r, g, b);
-  ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
-  return (wxDibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
-}
-
-void wxPNGReader::NullData()
-{
-  lpbi = NULL;
-  Palette = NULL;
-}
-
-wxBitmap* wxPNGReader::GetBitmap()
-{
-    wxBitmap *bitmap = new wxBitmap;
-    if ( InstantiateBitmap(bitmap) )
-        return bitmap;
-    else
-    {
-        delete bitmap;
-        return NULL;
-    }
-}
-
-bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap)
-{
-  HDC dc = ::CreateCompatibleDC(NULL);
-
-  if (dc)
-  {
-        // tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it
-        // is a memory dc that must have a bitmap selected into it)
-        HDC dc2 = GetDC(NULL);
-        HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight());
-        ReleaseDC(NULL, dc2);
-        HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, tmpBitmap);
-
-        if ( Palette )
-        {
-            ::SelectPalette(dc, (HPALETTE) Palette->GetHPALETTE(), FALSE);
-        ::RealizePalette(dc);
-        }
-
-    HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi,
-        CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS);
-
-        ::SelectPalette(dc, NULL, TRUE);
-        ::SelectObject(dc, oldBitmap);
-        ::DeleteObject(tmpBitmap);
-        ::DeleteDC(dc);
-
-        if ( hBitmap )
-        {
-          bitmap->SetHBITMAP((WXHBITMAP) hBitmap);
-          bitmap->SetWidth(GetWidth());
-          bitmap->SetHeight(GetHeight());
-          bitmap->SetDepth(GetDepth());
-          if ( GetDepth() > 1 && Palette )
-            bitmap->SetPalette(*Palette);
-          bitmap->SetOk(TRUE);
-
-
-          // Make a mask if appropriate
-          if ( bgindex > -1 )
-          {
-            wxMask *mask = CreateMask();
-            bitmap->SetMask(mask);
-          }
-      return TRUE;
-        }
-        else
-        {
-          return FALSE;
-        }
-  }
-  else
-    {
-    return FALSE;
-    }
-}
-
-wxPalette *wxCopyPalette(const wxPalette *cmap)
-{
-  // To get number of entries...
-  WORD count = 0;
-  ::GetObject((HPALETTE) cmap->GetHPALETTE(), sizeof(WORD), &count);
-
-  LOGPALETTE* logPal = (LOGPALETTE*)
-     new BYTE[sizeof(LOGPALETTE) + count*sizeof(PALETTEENTRY)];
-  logPal->palVersion = 0x300;
-  logPal->palNumEntries = count;
-  ::GetPaletteEntries((HPALETTE) cmap->GetHPALETTE(), 0, count, logPal->palPalEntry);
-
-  HPALETTE hPalette = ::CreatePalette(logPal);
-  delete[] logPal;
-
-  wxPalette *newCmap = new wxPalette;
-  newCmap->SetHPALETTE((WXHPALETTE) hPalette);
-  return newCmap;
-}
-
-wxMask *wxPNGReader::CreateMask()
-{
-    HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL);
-
-  HDC dc = ::CreateCompatibleDC(NULL);
-    HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap);
-
-    int bgIndex = GetBGIndex();
-
-    int x,y;
-
-    for (x=0; x<GetWidth(); x++)
-    {
-        for (y=0; y<GetHeight(); y++)
-        {
-            int index = GetIndex(x, y);
-            if ( index == bgIndex )
-                ::SetPixel(dc, x, GetHeight() - y - 1, RGB(0, 0, 0));
-            else
-                ::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255));
-
-      }
-    }
-    ::SelectObject(dc, oldBitmap);
-    wxMask *mask = new wxMask;
-    mask->SetMaskBitmap((WXHBITMAP) hBitmap);
-    return mask;
-}
-
-bool wxPNGReader::ReadFile(wxChar * ImageFileName)
-{
-    if (ImageFileName)
-        wxStrcpy(filename, ImageFileName);
-
-    /* open the file */
-    FILE *fp = fopen(wxConvFile.cWX2MB(filename), "rb");
-    if (!fp)
-        return FALSE;
-
-    /* allocate the necessary structures */
-    png_struct *png_ptr = new (png_struct);
-    if (!png_ptr)
-    {
-        fclose(fp);
-        return FALSE;
-    }
-
-    png_info *info_ptr = new (png_info);
-    if (!info_ptr)
-    {
-        fclose(fp);
-        delete(png_ptr);
-        return FALSE;
-    }
-
-    /* set error handling */
-    if (setjmp(png_ptr->jmpbuf))
-    {
-        png_read_destroy(png_ptr, info_ptr, (png_info *)0);
-        fclose(fp);
-        delete(png_ptr);
-        delete(info_ptr);
-
-        /* If we get here, we had a problem reading the file */
-        return FALSE;
-    }
-    //png_set_error(ima_png_error, NULL);
-
-    /* initialize the structures, info first for error handling */
-    png_info_init(info_ptr);
-    png_read_init(png_ptr);
-
-    /* set up the input control */
-    png_init_io(png_ptr, fp);
-
-    /* read the file information */
-    png_read_info(png_ptr, info_ptr);
-
-    /* allocate the memory to hold the image using the fields
-       of png_info. */
-    png_color_16 my_background={ 0, 31, 127, 255, 0 };
-
-    if (info_ptr->valid & PNG_INFO_bKGD)
-    {
-        png_set_background(png_ptr, &(info_ptr->background),
-                PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
-        if ( info_ptr->num_palette > 0 )
-            bgindex = info_ptr->background.index;
-    }
-    else   {
-        png_set_background(png_ptr, &my_background,
-                PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
-
-        // Added by JACS: guesswork!
-        if ( info_ptr->num_trans != 0 )
-            bgindex = info_ptr->num_trans - 1 ;
-    }
-
-    /* tell libpng to strip 16 bit depth files down to 8 bits */
-    if (info_ptr->bit_depth == 16)
-        png_set_strip_16(png_ptr);
-
-    int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24;
-    Create(info_ptr->width, info_ptr->height, pixel_depth,
-            info_ptr->color_type);
-
-    if (info_ptr->num_palette>0)
-    {
-        SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette);
-    }
-
-    int row_stride = info_ptr->width * ((pixel_depth+7)>>3);
-    //  printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride);
-    //  printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth);
-
-    byte *row_pointers = new byte[row_stride];
-
-    /* turn on interlace handling */
-    int number_passes;
-    if (info_ptr->interlace_type)
-        number_passes = png_set_interlace_handling(png_ptr);
-    else
-        number_passes = 1;
-    //  printf("NP = %d ", number_passes);
-
-    // don't use the object to prevent warnings from VC++ about "unportable
-    // interaction between setjmp and C++ object destruction" (this is a correct
-    // warning, of course!)
-    wxPNGReaderIter *iter = new wxPNGReaderIter(this);
-    for (int pass=0; pass< number_passes; pass++)
-    {
-        iter->upset();
-        int y=0;
-        do  {
-            //(unsigned char *)iter.GetRow();
-            if (info_ptr->interlace_type)  {
-                if (pass>0)
-                    iter->GetRow(row_pointers, row_stride);
-                png_read_row(png_ptr, row_pointers, NULL);
-            }
-            else
-                png_read_row(png_ptr, row_pointers, NULL);
-
-            iter->SetRow(row_pointers, row_stride);
-            y++;
-        } while(iter->PrevRow());
-        //  printf("Y=%d ",y);
-    }
-
-    delete iter;
-    delete[] row_pointers;
-
-    /* read the rest of the file, getting any additional chunks
-       in info_ptr */
-    png_read_end(png_ptr, info_ptr);
-
-    /* clean up after the read, and free any memory allocated */
-    png_read_destroy(png_ptr, info_ptr, (png_info *)0);
-
-    /* free the structures */
-    delete(png_ptr);
-    delete(info_ptr);
-
-    /* close the file */
-    fclose(fp);
-
-    /* that's it */
-    return TRUE;
-}
-
-
-/* write a png file */
-
-bool wxPNGReader::SaveFile(wxChar * ImageFileName)
-{
-  if (ImageFileName)
-   wxStrcpy(filename, ImageFileName);
-
-  wxPNGReaderIter iter(this);
-  FILE *fp;
-   png_struct *png_ptr;
-  png_info *info_ptr;
-
-   /* open the file */
-  fp = fopen(wxConvFile.cWX2MB(filename), "wb");
-  if (!fp)
-    return FALSE;
-
-  /* allocate the necessary structures */
-  png_ptr = new (png_struct);
-  if (!png_ptr)
-  {
-    fclose(fp);
-    return FALSE;
-  }
-
-  info_ptr = new (png_info);
-  if (!info_ptr)
-  {
-    fclose(fp);
-    delete(png_ptr);
-    return FALSE;
-  }
-
-  /* set error handling */
-  if (setjmp(png_ptr->jmpbuf))
-  {
-    png_write_destroy(png_ptr);
-    fclose(fp);
-    delete(png_ptr);
-    delete(info_ptr);
-
-    /* If we get here, we had a problem reading the file */
-    return FALSE;
-  }
-        //png_set_error(ima_png_error, NULL);
-
-//  printf("writig pg %s ", filename);
-   /* initialize the structures */
-  png_info_init(info_ptr);
-  png_write_init(png_ptr);
-
-  int row_stride = GetWidth() * ((GetDepth()+7)>>3);
-  /* set up the output control */
-   png_init_io(png_ptr, fp);
-
-  /* set the file information here */
-  info_ptr->width = GetWidth();
-  info_ptr->height = GetHeight();
-  info_ptr->pixel_depth = GetDepth();
-  info_ptr->channels = (GetDepth()>8) ? 3: 1;
-  info_ptr->bit_depth = GetDepth()/info_ptr->channels;
-  info_ptr->color_type = GetColorType();
-  info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0;
-  info_ptr->valid = 0;
-  info_ptr->rowbytes = row_stride;
-
-
-// printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels);
-  /* set the palette if there is one */
-  if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette())
-  {
-//    printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
-    info_ptr->valid |= PNG_INFO_PLTE;
-    info_ptr->palette = new png_color[256];
-    info_ptr->num_palette = 256;
-    for (int i=0; i<256; i++)
-     GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
-  }
-//    printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
-
-
-   /* optional significant bit chunk */
-//   info_ptr->valid |= PNG_INFO_sBIT;
-//   info_ptr->sig_bit = true_bit_depth;
-
-  /* optional gamma chunk */
-//   info_ptr->valid |= PNG_INFO_gAMA;
-//   info_ptr->gamma = gamma;
-
-  /* other optional chunks */
-
-   /* write the file information */
-   png_write_info(png_ptr, info_ptr);
-
-   /* set up the transformations you want.  Note that these are
-      all optional.  Only call them if you want them */
-
-  /* shift the pixels up to a legal bit depth and fill in
-      as appropriate to correctly scale the image */
-//   png_set_shift(png_ptr, &(info_ptr->sig_bit));
-
-  /* pack pixels into bytes */
-//   png_set_packing(png_ptr);
-
-  /* flip bgr pixels to rgb */
-//   png_set_bgr(png_ptr);
-
-   /* swap bytes of 16 bit files to most significant bit first */
-//   png_set_swap(png_ptr);
-
-   /* get rid of filler bytes, pack rgb into 3 bytes */
-//   png_set_rgbx(png_ptr);
-
-/* If you are only writing one row at a time, this works */
-
-  byte *row_pointers = new byte[row_stride];
-    iter.upset();
-  do  {
-//    (unsigned char *)iter.GetRow();
-    iter.GetRow(row_pointers, row_stride);
-    png_write_row(png_ptr, row_pointers);
-  } while(iter.PrevRow());
-
-        delete[] row_pointers;
-
-/* write the rest of the file */
-   png_write_end(png_ptr, info_ptr);
-
-  /* clean up after the write, and free any memory allocated */
-   png_write_destroy(png_ptr);
-
-   /* if you malloced the palette, free it here */
-   if (info_ptr->palette)
-    delete[] (info_ptr->palette);
-
-  /* free the structures */
-  delete(png_ptr);
-  delete(info_ptr);
-
-  /* close the file */
-  fclose(fp);
-
-  /* that's it */
-  return TRUE;
-}
-
-static int Power(int x, int y)
-{
-    int z = 1;
-    int i;
-    for ( i = 0; i < y; i++)
-    {
-        z *= x;
-    }
-    return z;
-}
-
-static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
-  'C', 'D', 'E', 'F' };
-
-static void DecToHex(int dec, char *buf)
-{
-  int firstDigit = (int)(dec/16.0);
-  int secondDigit = (int)(dec - (firstDigit*16.0));
-  buf[0] = hexArray[firstDigit];
-  buf[1] = hexArray[secondDigit];
-  buf[2] = 0;
-}
-
-
-bool wxPNGReader::SaveXPM(wxChar *filename, wxChar *name)
-{
-    wxChar nameStr[256];
-    if ( name )
-        wxStrcpy(nameStr, name);
-    else
-    {
-        wxStrcpy(nameStr, filename);
-        wxStripExtension(nameStr);
-    }
-
-    if ( GetDepth() > 4 )
-    {
-        // Only a depth of 4 and below allowed
-        return FALSE;
-    }
-
-    if ( !GetPalette() )
-        return FALSE;
-
-    ofstream str(wxConvFile.cWX2MB(filename));
-    if ( str.bad() )
-        return FALSE;
-
-    int noColours = Power(2, GetDepth());
-
-    // Output header
-    str << "/* XPM */\n";
-    str << "static char * " << nameStr << "_xpm[] = {\n";
-    str << "\"" << GetWidth() << " " << GetHeight() << " " << noColours << " 1\",\n";
-
-    // Output colourmap
-    int base = 97 ; // start from 'a'
-
-    unsigned char red, green, blue;
-    char hexBuf[4];
-    int i;
-    for ( i = 0; i < noColours; i ++)
-    {
-        str << "\"" << (char)(base + i) << "      c #";
-        GetPalette()->GetRGB(i, &red, &green, &blue);
-        DecToHex(red, hexBuf);
-        str << hexBuf;
-        DecToHex(green, hexBuf);
-        str << hexBuf;
-        DecToHex(blue, hexBuf);
-        str << hexBuf;
-        str << "\",\n";
-    }
-
-    // Output the data
-    int x, y;
-    for ( y = 0; y < GetHeight(); y++)
-    {
-        str << "\"";
-        for ( x = 0; x < GetWidth(); x++)
-        {
-            int index = GetIndex(x, y);
-            str << (char)(base + index) ;
-        }
-        str << "\",\n";
-    }
-
-    str << "};\n";
-    str.flush();
-
-    return TRUE;
-}
-
-#include <wx/os2/pnghand.h>
-
-IMPLEMENT_DYNAMIC_CLASS(wxPNGFileHandler, wxBitmapHandler)
-
-bool wxPNGFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
-    int desiredWidth, int desiredHeight)
-{
-    wxPNGReader reader;
-    if (reader.ReadFile(WXSTRINGCAST name))
-    {
-        return reader.InstantiateBitmap(bitmap);
-    }
-    else
-        return FALSE;
-}
-
-bool wxPNGFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *pal)
-{
-    return FALSE;
-}
-
-