]> git.saurik.com Git - wxWidgets.git/commitdiff
wxMSW update for CW, wxMac updated
authorStefan Csomor <csomor@advancedconcepts.ch>
Fri, 3 Dec 1999 14:40:17 +0000 (14:40 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Fri, 3 Dec 1999 14:40:17 +0000 (14:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4802 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/mac/dataform.h [new file with mode: 0644]
include/wx/mac/dataobj.h [new file with mode: 0644]
include/wx/mac/dataobj2.h [new file with mode: 0644]
include/wx/mac/pnghand.h [new file with mode: 0644]
include/wx/mac/pngread.h [new file with mode: 0644]

diff --git a/include/wx/mac/dataform.h b/include/wx/mac/dataform.h
new file mode 100644 (file)
index 0000000..d052bf4
--- /dev/null
@@ -0,0 +1,60 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        os2/dataform.h
+// Purpose:     declaration of the wxDataFormat class
+// Author:      David Webster (lifted from dnd.h)
+// Modified by:
+// Created:     10/21/99
+// RCS-ID:      $Id$
+// Copyright:   (c) 1999 David Webster
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_OS2_DATAFORM_H
+#define _WX_OS2_DATAFORM_H
+
+class wxDataFormat
+{
+public:
+    // the clipboard formats under GDK are GdkAtoms
+    typedef unsigned short NativeFormat;
+
+    wxDataFormat();
+    wxDataFormat(wxDataFormatId vType);
+    wxDataFormat(const wxString& rId);
+    wxDataFormat(const wxChar* pId);
+    wxDataFormat(NativeFormat vFormat);
+
+    wxDataFormat& operator=(NativeFormat vFormat)
+        { SetId(vFormat); return *this; }
+
+    // comparison (must have both versions)
+    bool operator==(NativeFormat vFormat) const
+        { return m_vFormat == (NativeFormat)vFormat; }
+    bool operator!=(NativeFormat vFormat) const
+        { return m_vFormat != (NativeFormat)vFormat; }
+
+    // explicit and implicit conversions to NativeFormat which is one of
+    // standard data types (implicit conversion is useful for preserving the
+    // compatibility with old code)
+    NativeFormat GetFormatId() const { return m_vFormat; }
+    operator NativeFormat() const { return m_vFormat; }
+
+    void SetId(NativeFormat vFormat);
+
+    // string ids are used for custom types - this SetId() must be used for
+    // application-specific formats
+    wxString GetId() const;
+    void SetId(const wxChar* pId);
+
+    // implementation
+    wxDataFormatId GetType() const;
+
+private:
+    wxDataFormatId                  m_vType;
+    NativeFormat                    m_vFormat;
+
+    void PrepareFormats();
+    void SetType(wxDataFormatId vType);
+};
+
+#endif // _WX_GTK_DATAFORM_H
diff --git a/include/wx/mac/dataobj.h b/include/wx/mac/dataobj.h
new file mode 100644 (file)
index 0000000..74cbb92
--- /dev/null
@@ -0,0 +1,32 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        mac/dataobj.h
+// Purpose:     declaration of the wxDataObject
+// Author:      Stefan Csomor (adapted from Robert Roebling's gtk port)
+// Modified by:
+// Created:     10/21/99
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998, 1999 Vadim Zeitlin, Robert Roebling
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_MAC_DATAOBJ_H_
+#define _WX_MAC_DATAOBJ_H_
+
+#ifdef __GNUG__
+    #pragma interface "dataobj.h"
+#endif
+
+// ----------------------------------------------------------------------------
+// wxDataObject is the same as wxDataObjectBase under wxGTK
+// ----------------------------------------------------------------------------
+
+class wxDataObject : public wxDataObjectBase
+{
+public:
+    wxDataObject();
+
+    virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
+};
+
+#endif // _WX_MAC_DATAOBJ_H_
+
diff --git a/include/wx/mac/dataobj2.h b/include/wx/mac/dataobj2.h
new file mode 100644 (file)
index 0000000..a936e22
--- /dev/null
@@ -0,0 +1,90 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        os2/dataobj2.h
+// Purpose:     declaration of standard wxDataObjectSimple-derived classes
+// Author:      David Webster (adapted from Robert Roebling's gtk port
+// Modified by:
+// Created:     10/21/99
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998, 1999 Vadim Zeitlin, Robert Roebling
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_GTK_DATAOBJ2_H_
+#define _WX_GTK_DATAOBJ2_H_
+
+#ifdef __GNUG__
+    #pragma interface "dataobj.h"
+#endif
+
+// ----------------------------------------------------------------------------
+// wxBitmapDataObject is a specialization of wxDataObject for bitmaps
+// ----------------------------------------------------------------------------
+
+class wxBitmapDataObject : public wxBitmapDataObjectBase
+{
+public:
+    // ctors
+    wxBitmapDataObject();
+    wxBitmapDataObject(const wxBitmap& bitmap);
+
+    // destr
+    ~wxBitmapDataObject();
+
+    // override base class virtual to update PNG data too
+    virtual void SetBitmap(const wxBitmap& bitmap);
+
+    // implement base class pure virtuals
+    // ----------------------------------
+
+    virtual size_t GetDataSize() const { return m_pngSize; }
+    virtual bool GetDataHere(void *buf) const;
+    virtual bool SetData(size_t len, const void *buf);
+
+protected:
+    void Init() { m_pngData = (void *)NULL; m_pngSize = 0; }
+    void Clear() { free(m_pngData); }
+    void ClearAll() { Clear(); Init(); }
+
+    size_t      m_pngSize;
+    void       *m_pngData;
+
+    void DoConvertToPng();
+
+private:
+    // Virtual function hiding supression
+    size_t GetDataSize(const wxDataFormat& rFormat) const
+    { return(wxDataObjectSimple::GetDataSize(rFormat)); }
+    bool GetDataHere(const wxDataFormat& rFormat, void* pBuf) const
+    { return(wxDataObjectSimple::GetDataHere(rFormat, pBuf)); }
+    bool SetData(const wxDataFormat& rFormat, size_t nLen, const void* pBuf)
+    { return(wxDataObjectSimple::SetData(rFormat, nLen, pBuf)); }
+};
+
+// ----------------------------------------------------------------------------
+// wxFileDataObject is a specialization of wxDataObject for file names
+// ----------------------------------------------------------------------------
+
+class wxFileDataObject : public wxFileDataObjectBase
+{
+public:
+    // implement base class pure virtuals
+    // ----------------------------------
+
+    void AddFile( const wxString &filename );
+
+    virtual size_t GetDataSize() const;
+    virtual bool GetDataHere(void *buf) const;
+    virtual bool SetData(size_t len, const void *buf);
+
+private:
+    // Virtual function hiding supression
+    size_t GetDataSize(const wxDataFormat& rFormat) const
+    { return(wxDataObjectSimple::GetDataSize(rFormat)); }
+    bool GetDataHere(const wxDataFormat& rFormat, void* pBuf) const
+    { return(wxDataObjectSimple::GetDataHere(rFormat, pBuf)); }
+    bool SetData(const wxDataFormat& rFormat, size_t nLen, const void* pBuf)
+    { return(wxDataObjectSimple::SetData(rFormat, nLen, pBuf)); }
+};
+
+#endif // _WX_GTK_DATAOBJ2_H_
+
diff --git a/include/wx/mac/pnghand.h b/include/wx/mac/pnghand.h
new file mode 100644 (file)
index 0000000..5b43b70
--- /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_
+
diff --git a/include/wx/mac/pngread.h b/include/wx/mac/pngread.h
new file mode 100644 (file)
index 0000000..f6d1d70
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+ * File:       pngread.h
+ * Purpose:    PNG file reader
+ * Author:     Alejandro Aguilar Sierra/Julian Smart
+ * Created:    1995
+ * Copyright:  (c) 1995, Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ *
+ *
+ */
+
+#ifndef _WX_PNGREAD__
+#define _WX_PNGREAD__
+
+#ifdef __GNUG__
+#pragma interface "pngread.h"
+#endif
+
+#ifndef byte
+typedef unsigned char byte;
+#endif
+
+#define WXIMA_COLORS DIB_PAL_COLORS
+
+typedef byte * ImagePointerType;
+
+typedef struct
+{
+       byte red;
+       byte green;
+   byte blue;
+} rgb_color_struct;
+
+
+#define COLORTYPE_PALETTE      1
+#define COLORTYPE_COLOR                2
+#define COLORTYPE_ALPHA                4
+
+class wxPNGReader
+{
+protected:
+  int filetype;
+  char filename[255];
+  ImagePointerType RawImage;           //  Image data
+
+  int Width, Height;                   //  Dimensions
+  int Depth;                                   // (bits x pixel)
+  int ColorType;                               // Bit 1 = Palette used
+                                                                       // Bit 2 = Color used
+                                                                       // Bit 3 = Alpha used
+
+  long EfeWidth;                               // Efective Width
+
+  GWorldPtr lpbi;
+  int bgindex;
+  wxPalette* Palette;
+  bool imageOK;
+friend class wxPNGReaderIter;
+public:
+  wxPNGReader(void);
+  wxPNGReader (char* ImageFileName);     // Read an image file
+  ~wxPNGReader ();
+
+  void Create(int width, int height, int deep, int colortype=-1);
+
+  bool ReadFile( char* ImageFileName=0 );
+  bool SaveFile( char* ImageFileName=0 );
+  bool SaveXPM(char *filename, char *name = 0);
+  int  GetWidth( void ) const { return Width; };
+  int  GetHeight( void ) const { return Height; };
+  int  GetDepth( void ) const { return Depth; };
+  int  GetColorType( void ) const { return ColorType; };
+
+  int  GetIndex(int x, int y);
+  bool GetRGB(int x, int y, byte* r, byte* g, byte* b);
+
+  bool SetIndex(int x, int y, int index);
+  bool SetRGB(int x, int y, byte r, byte g, byte b);
+
+  // ColorMap settings
+  bool SetPalette(wxPalette* colourmap);
+  bool SetPalette(int n, rgb_color_struct *rgb_struct);
+  bool SetPalette(int n, byte *r, byte *g=0, byte *b=0);
+  wxPalette* GetPalette() const { return Palette; }
+
+  void NullData();
+  inline int GetBGIndex(void) { return bgindex; }
+
+  inline bool Inside(int x, int y)
+      { return (0<=y && y<Height && 0<=x && x<Width); }
+
+  virtual wxBitmap *GetBitmap(void);
+  virtual bool InstantiateBitmap(wxBitmap *bitmap);
+  wxMask *CreateMask(void);
+
+  inline bool Ok(void) { return imageOK; }
+};
+
+class wxPNGReaderIter
+{
+protected:
+  int Itx, Ity;                                // Counters
+  int Stepx, Stepy;
+  ImagePointerType IterImage;                  //  Image pointer
+  wxPNGReader *ima;
+public:
+// Constructors
+  wxPNGReaderIter ( void );
+  wxPNGReaderIter ( wxPNGReader *imax );
+  operator wxPNGReader* ();
+
+// Iterators
+  bool ItOK ();
+  void reset ();
+  void upset ();
+  void SetRow(byte *buf, int n);
+  void GetRow(byte *buf, int n);
+  byte GetByte( ) { return IterImage[Itx]; }
+  void SetByte(byte b) { IterImage[Itx] = b; }
+  ImagePointerType GetRow(void);
+  bool NextRow();
+  bool PrevRow();
+  bool NextByte();
+  bool PrevByte();
+
+  void SetSteps(int x, int y=0) {  Stepx = x; Stepy = y; }
+  void GetSteps(int *x, int *y) {  *x = Stepx; *y = Stepy; }
+  bool NextStep();
+  bool PrevStep();
+
+////////////////////////// AD - for interlace ///////////////////////////////
+  void SetY(int y);
+/////////////////////////////////////////////////////////////////////////////
+};
+
+
+inline
+wxPNGReaderIter::wxPNGReaderIter(void)
+{
+  ima = 0;
+  IterImage = 0;
+  Itx = Ity = 0;
+  Stepx = Stepy = 0;
+}
+
+inline
+wxPNGReaderIter::wxPNGReaderIter(wxPNGReader *imax): ima(imax)
+{
+  if (ima)
+        IterImage = ima->RawImage;
+  Itx = Ity = 0;
+  Stepx = Stepy = 0;
+}
+
+inline
+wxPNGReaderIter::operator wxPNGReader* ()
+{
+  return ima;
+}
+
+inline
+bool wxPNGReaderIter::ItOK ()
+{
+  if (ima)
+        return ima->Inside(Itx, Ity);
+  else
+        return FALSE;
+}
+
+
+inline void wxPNGReaderIter::reset()
+{
+  IterImage = ima->RawImage;
+  Itx = Ity = 0;
+}
+
+inline void wxPNGReaderIter::upset()
+{
+  Itx = 0;
+  Ity = ima->Height-1;
+  IterImage = ima->RawImage + ima->EfeWidth*(ima->Height-1);
+}
+
+inline bool wxPNGReaderIter::NextRow()
+{
+  if (++Ity >= ima->Height) return 0;
+  IterImage += ima->EfeWidth;
+  return 1;
+}
+
+inline bool wxPNGReaderIter::PrevRow()
+{
+  if (--Ity < 0) return 0;
+  IterImage -= ima->EfeWidth;
+  return 1;
+}
+
+////////////////////////// AD - for interlace ///////////////////////////////
+inline void wxPNGReaderIter::SetY(int y)
+{
+  if ((y < 0) || (y > ima->Height)) return;
+  Ity = y;
+  IterImage = ima->RawImage + ima->EfeWidth*y;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+inline void wxPNGReaderIter::SetRow(byte *buf, int n)
+{
+// Here should be bcopy or memcpy
+  //_fmemcpy(IterImage, (void far *)buf, n);
+  if (n<0)
+        n = ima->GetWidth();
+
+  for (int i=0; i<n; i++) IterImage[i] = buf[i];
+}
+
+inline void wxPNGReaderIter::GetRow(byte *buf, int n)
+{
+  for (int i=0; i<n; i++) buf[i] = IterImage[i];
+}
+
+inline ImagePointerType wxPNGReaderIter::GetRow()
+{
+  return IterImage;
+}
+
+inline bool wxPNGReaderIter::NextByte()
+{
+  if (++Itx < ima->EfeWidth)
+        return 1;
+  else
+        if (++Ity < ima->Height)
+        {
+               IterImage += ima->EfeWidth;
+               Itx = 0;
+               return 1;
+        } else
+               return 0;
+}
+
+inline bool wxPNGReaderIter::PrevByte()
+{
+  if (--Itx >= 0)
+        return 1;
+  else
+        if (--Ity >= 0)
+        {
+               IterImage -= ima->EfeWidth;
+               Itx = 0;
+               return 1;
+        } else
+               return 0;
+}
+
+inline bool wxPNGReaderIter::NextStep()
+{
+  Itx += Stepx;
+  if (Itx < ima->EfeWidth)
+        return 1;
+  else {
+        Ity += Stepy;
+        if (Ity < ima->Height)
+        {
+               IterImage += ima->EfeWidth;
+               Itx = 0;
+               return 1;
+        } else
+               return 0;
+  }
+}
+
+inline bool wxPNGReaderIter::PrevStep()
+{
+  Itx -= Stepx;
+  if (Itx >= 0)
+        return 1;
+  else {       
+        Ity -= Stepy;
+        if (Ity >= 0 && Ity < ima->Height)
+        {
+               IterImage -= ima->EfeWidth;
+               Itx = 0;
+               return 1;
+        } else
+               return 0;
+  }
+}
+
+#endif
+