1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1999-12-03 00:03:55 -05:00
|
|
|
// Name: wx/os2/bitmap.h
|
1999-07-29 01:11:30 -04:00
|
|
|
// Purpose: wxBitmap class
|
1999-10-13 18:34:18 -04:00
|
|
|
// Author: David Webster
|
1999-07-29 01:11:30 -04:00
|
|
|
// Modified by:
|
1999-12-03 00:03:55 -05:00
|
|
|
// Created: 11/28/99
|
1999-07-29 01:11:30 -04:00
|
|
|
// RCS-ID: $Id$
|
1999-10-13 18:34:18 -04:00
|
|
|
// Copyright: (c) David Webster
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_BITMAP_H_
|
|
|
|
#define _WX_BITMAP_H_
|
|
|
|
|
1999-12-05 16:23:52 -05:00
|
|
|
#include "wx/os2/private.h"
|
1999-12-03 00:03:55 -05:00
|
|
|
#include "wx/os2/gdiimage.h"
|
1999-07-29 01:11:30 -04:00
|
|
|
#include "wx/gdicmn.h"
|
|
|
|
#include "wx/palette.h"
|
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxDC;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxControl;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxBitmap;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxBitmapHandler;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxIcon;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxMask;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxCursor;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxControl;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxImage;
|
2008-03-29 15:34:37 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Bitmap data
|
|
|
|
//
|
|
|
|
// NB: this class is private, but declared here to make it possible inline
|
|
|
|
// wxBitmap functions accessing it
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxBitmapRefData : public wxGDIImageRefData
|
1999-07-29 01:11:30 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxBitmapRefData();
|
2006-10-31 20:01:32 -05:00
|
|
|
wxBitmapRefData(const wxBitmapRefData &tocopy);
|
1999-12-03 00:03:55 -05:00
|
|
|
virtual ~wxBitmapRefData() { Free(); }
|
|
|
|
|
|
|
|
virtual void Free();
|
1999-07-29 01:11:30 -04:00
|
|
|
|
|
|
|
public:
|
1999-12-03 00:03:55 -05:00
|
|
|
int m_nNumColors;
|
|
|
|
wxPalette m_vBitmapPalette;
|
|
|
|
int m_nQuality;
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
// OS2-specific
|
|
|
|
// ------------
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
wxDC* m_pSelectedInto;
|
|
|
|
|
2001-01-29 00:46:06 -05:00
|
|
|
//
|
|
|
|
// Optional mask for transparent drawing
|
|
|
|
//
|
1999-12-03 00:03:55 -05:00
|
|
|
wxMask* m_pBitmapMask;
|
2001-01-29 00:46:06 -05:00
|
|
|
}; // end of CLASS wxBitmapRefData
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxBitmap: a mono or colour bitmap
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxBitmap : public wxGDIImage
|
1999-07-29 01:11:30 -04:00
|
|
|
{
|
|
|
|
public:
|
1999-12-03 00:03:55 -05:00
|
|
|
// default ctor creates an invalid bitmap, you must Create() it later
|
|
|
|
wxBitmap() { Init(); }
|
|
|
|
|
|
|
|
// Copy constructors
|
|
|
|
inline wxBitmap(const wxBitmap& rBitmap)
|
2006-02-08 19:51:23 -05:00
|
|
|
: wxGDIImage(rBitmap)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
SetHandle(rBitmap.GetHandle());
|
|
|
|
}
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
// Initialize with raw data
|
|
|
|
wxBitmap( const char bits[]
|
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
|
|
|
|
|
|
|
// Initialize with XPM data
|
2006-10-08 04:04:49 -04:00
|
|
|
wxBitmap(const char* const* bits);
|
2006-10-31 20:16:01 -05:00
|
|
|
#ifdef wxNEEDS_CHARPP
|
2006-10-30 03:07:51 -05:00
|
|
|
// needed for old GCC
|
|
|
|
wxBitmap(char** data)
|
|
|
|
{
|
2008-11-01 22:39:52 -04:00
|
|
|
*this = wxBitmap(const_cast<const char* const*>(data));
|
2006-10-30 03:07:51 -05:00
|
|
|
}
|
|
|
|
#endif
|
1999-12-03 00:03:55 -05:00
|
|
|
|
2002-07-07 23:38:01 -04:00
|
|
|
// Load a resource
|
|
|
|
wxBitmap( int nId
|
2008-09-21 16:03:14 -04:00
|
|
|
,wxBitmapType lType = wxBITMAP_DEFAULT_TYPE
|
1999-12-03 00:03:55 -05:00
|
|
|
);
|
|
|
|
|
2002-07-07 23:38:01 -04:00
|
|
|
// For compatiability with other ports, under OS/2 does same as default ctor
|
|
|
|
inline wxBitmap( const wxString& WXUNUSED(rFilename)
|
2008-03-29 15:34:37 -04:00
|
|
|
,wxBitmapType WXUNUSED(lType)
|
2002-07-07 23:38:01 -04:00
|
|
|
)
|
|
|
|
{ Init(); }
|
1999-12-03 00:03:55 -05:00
|
|
|
// New constructor for generalised creation from data
|
2006-10-08 04:04:49 -04:00
|
|
|
wxBitmap( const void* pData
|
2008-03-29 15:34:37 -04:00
|
|
|
,wxBitmapType lType
|
1999-12-03 00:03:55 -05:00
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
|
|
|
|
|
|
|
// If depth is omitted, will create a bitmap compatible with the display
|
2005-07-21 13:18:43 -04:00
|
|
|
wxBitmap( int nWidth, int nHeight, int nDepth = -1 );
|
1999-12-03 00:03:55 -05:00
|
|
|
|
2002-02-17 23:30:35 -05:00
|
|
|
wxBitmap( const wxImage& image, int depth = -1 )
|
2001-04-04 19:15:36 -04:00
|
|
|
{ (void)CreateFromImage(image, depth); }
|
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
// we must have this, otherwise icons are silently copied into bitmaps using
|
|
|
|
// the copy ctor but the resulting bitmap is invalid!
|
|
|
|
inline wxBitmap(const wxIcon& rIcon)
|
|
|
|
{ Init(); CopyFromIcon(rIcon); }
|
|
|
|
|
|
|
|
wxBitmap& operator=(const wxIcon& rIcon)
|
|
|
|
{
|
|
|
|
(void)CopyFromIcon(rIcon);
|
|
|
|
|
|
|
|
return(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxBitmap& operator=(const wxCursor& rCursor)
|
|
|
|
{
|
|
|
|
(void)CopyFromCursor(rCursor);
|
|
|
|
return (*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~wxBitmap();
|
|
|
|
|
2002-02-17 23:30:35 -05:00
|
|
|
wxImage ConvertToImage() const;
|
2001-04-04 19:15:36 -04:00
|
|
|
|
2000-12-21 17:07:50 -05:00
|
|
|
// get the given part of bitmap
|
|
|
|
wxBitmap GetSubBitmap(const wxRect& rRect) const;
|
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
|
|
bool CopyFromIcon(const wxIcon& rIcon);
|
|
|
|
|
|
|
|
// copies the contents and mask of the given cursor to the bitmap
|
|
|
|
bool CopyFromCursor(const wxCursor& rCursor);
|
|
|
|
|
|
|
|
virtual bool Create( int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = -1
|
|
|
|
);
|
2006-10-08 04:04:49 -04:00
|
|
|
virtual bool Create( const void* pData
|
2008-03-29 15:34:37 -04:00
|
|
|
,wxBitmapType lType
|
1999-12-03 00:03:55 -05:00
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
2002-07-07 23:38:01 -04:00
|
|
|
virtual bool LoadFile( int nId
|
2008-09-21 16:03:14 -04:00
|
|
|
,wxBitmapType lType = wxBITMAP_DEFAULT_TYPE
|
1999-12-03 00:03:55 -05:00
|
|
|
);
|
2005-09-18 19:27:28 -04:00
|
|
|
virtual bool LoadFile( const wxString& rName
|
2008-09-21 16:03:14 -04:00
|
|
|
,wxBitmapType lType = wxBITMAP_DEFAULT_TYPE
|
2005-09-18 19:27:28 -04:00
|
|
|
);
|
1999-12-03 00:03:55 -05:00
|
|
|
virtual bool SaveFile( const wxString& rName
|
2008-03-29 15:34:37 -04:00
|
|
|
,wxBitmapType lType
|
1999-12-03 00:03:55 -05:00
|
|
|
,const wxPalette* pCmap = NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
inline wxBitmapRefData* GetBitmapData() const
|
|
|
|
{ return (wxBitmapRefData *)m_refData; }
|
|
|
|
|
2008-03-29 15:34:37 -04:00
|
|
|
// raw bitmap access support functions
|
|
|
|
void *GetRawData(wxPixelDataBase& data, int bpp);
|
|
|
|
void UngetRawData(wxPixelDataBase& data);
|
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
inline int GetQuality() const
|
1999-12-05 16:23:52 -05:00
|
|
|
{ return (GetBitmapData() ? GetBitmapData()->m_nQuality : 0); }
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
void SetQuality(int nQ);
|
|
|
|
|
|
|
|
wxPalette* GetPalette() const
|
2009-01-19 08:55:27 -05:00
|
|
|
{ return (GetBitmapData() ? (& GetBitmapData()->m_vBitmapPalette) : NULL); }
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
void SetPalette(const wxPalette& rPalette);
|
|
|
|
|
|
|
|
inline wxMask* GetMask() const
|
2009-01-19 08:55:27 -05:00
|
|
|
{ return (GetBitmapData() ? GetBitmapData()->m_pBitmapMask : NULL); }
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
void SetMask(wxMask* pMask) ;
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
public:
|
1999-12-05 16:23:52 -05:00
|
|
|
inline void SetHBITMAP(WXHBITMAP hBmp)
|
|
|
|
{ SetHandle((WXHANDLE)hBmp); }
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
inline WXHBITMAP GetHBITMAP() const
|
|
|
|
{ return (WXHBITMAP)GetHandle(); }
|
|
|
|
|
|
|
|
inline void SetSelectedInto(wxDC* pDc)
|
1999-12-05 16:23:52 -05:00
|
|
|
{ if (GetBitmapData()) GetBitmapData()->m_pSelectedInto = pDc; }
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
inline wxDC* GetSelectedInto() const
|
2009-01-19 08:55:27 -05:00
|
|
|
{ return (GetBitmapData() ? GetBitmapData()->m_pSelectedInto : NULL); }
|
1999-12-03 00:03:55 -05:00
|
|
|
|
2002-05-06 17:47:16 -04:00
|
|
|
inline bool IsMono(void) const { return m_bIsMono; }
|
2002-05-08 01:22:36 -04:00
|
|
|
|
1999-12-03 17:23:58 -05:00
|
|
|
// An OS/2 version that probably doesn't do anything like the msw version
|
1999-12-03 00:03:55 -05:00
|
|
|
wxBitmap GetBitmapForDC(wxDC& rDc) const;
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
protected:
|
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
inline virtual wxGDIImageRefData* CreateData() const
|
|
|
|
{ return new wxBitmapRefData; }
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2001-04-04 19:15:36 -04:00
|
|
|
bool CreateFromImage(const wxImage& image, int depth);
|
2000-12-21 17:07:50 -05:00
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
2006-10-31 20:01:32 -05:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
private:
|
|
|
|
bool CopyFromIconOrCursor(const wxGDIImage& rIcon);
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2002-05-06 17:47:16 -04:00
|
|
|
bool m_bIsMono;
|
1999-12-03 00:03:55 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
2000-12-21 17:07:50 -05:00
|
|
|
}; // end of CLASS wxBitmap
|
1999-10-13 18:34:18 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxMask: a mono bitmap used for drawing bitmaps transparently.
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMask : public wxObject
|
1999-12-03 00:03:55 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxMask();
|
2006-10-31 20:01:32 -05:00
|
|
|
wxMask( const wxMask& tocopy);
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
// Construct a mask from a bitmap and a colour indicating the transparent
|
|
|
|
// area
|
|
|
|
wxMask( const wxBitmap& rBitmap
|
|
|
|
,const wxColour& rColour
|
|
|
|
);
|
|
|
|
|
|
|
|
// Construct a mask from a bitmap and a palette index indicating the
|
|
|
|
// transparent area
|
|
|
|
wxMask( const wxBitmap& rBitmap
|
|
|
|
,int nPaletteIndex
|
|
|
|
);
|
|
|
|
|
|
|
|
// Construct a mask from a mono bitmap (copies the bitmap).
|
|
|
|
wxMask(const wxBitmap& rBitmap);
|
|
|
|
|
|
|
|
// construct a mask from the givne bitmap handle
|
|
|
|
wxMask(WXHBITMAP hBmp)
|
|
|
|
{ m_hMaskBitmap = hBmp; }
|
|
|
|
|
|
|
|
virtual ~wxMask();
|
|
|
|
|
|
|
|
bool Create( const wxBitmap& bitmap
|
|
|
|
,const wxColour& rColour
|
|
|
|
);
|
|
|
|
bool Create( const wxBitmap& rBitmap
|
|
|
|
,int nPaletteIndex
|
|
|
|
);
|
|
|
|
bool Create(const wxBitmap& rBitmap);
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
WXHBITMAP GetMaskBitmap() const
|
|
|
|
{ return m_hMaskBitmap; }
|
|
|
|
void SetMaskBitmap(WXHBITMAP hBmp)
|
|
|
|
{ m_hMaskBitmap = hBmp; }
|
1999-07-29 01:11:30 -04:00
|
|
|
|
|
|
|
protected:
|
1999-12-03 00:03:55 -05:00
|
|
|
WXHBITMAP m_hMaskBitmap;
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxMask)
|
2001-01-29 00:46:06 -05:00
|
|
|
}; // end of CLASS wxMask
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxBitmapHandler is a class which knows how to load/save bitmaps to/from file
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxBitmapHandler : public wxGDIImageHandler
|
1999-12-03 00:03:55 -05:00
|
|
|
{
|
1999-07-29 01:11:30 -04:00
|
|
|
public:
|
1999-12-03 00:03:55 -05:00
|
|
|
inline wxBitmapHandler()
|
|
|
|
{ m_lType = wxBITMAP_TYPE_INVALID; }
|
|
|
|
|
|
|
|
inline wxBitmapHandler( const wxString& rName
|
|
|
|
,const wxString& rExt
|
2008-03-25 16:31:48 -04:00
|
|
|
,wxBitmapType lType
|
1999-12-03 00:03:55 -05:00
|
|
|
)
|
|
|
|
: wxGDIImageHandler( rName
|
|
|
|
,rExt
|
|
|
|
,lType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// keep wxBitmapHandler derived from wxGDIImageHandler compatible with the
|
|
|
|
// old class which worked only with bitmaps
|
|
|
|
virtual bool Create( wxBitmap* pBitmap
|
2006-10-08 04:04:49 -04:00
|
|
|
,const void* pData
|
2008-03-25 16:31:48 -04:00
|
|
|
,wxBitmapType lType
|
1999-12-03 00:03:55 -05:00
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
|
|
|
virtual bool LoadFile( wxBitmap* pBitmap
|
2002-07-07 23:38:01 -04:00
|
|
|
,int nId
|
2008-03-25 16:31:48 -04:00
|
|
|
,wxBitmapType lType
|
1999-12-03 00:03:55 -05:00
|
|
|
,int nDesiredWidth
|
|
|
|
,int nDesiredHeight
|
|
|
|
);
|
2005-09-18 19:27:28 -04:00
|
|
|
virtual bool LoadFile( wxBitmap* pBitmap
|
|
|
|
,const wxString& rName
|
2008-03-25 16:31:48 -04:00
|
|
|
,wxBitmapType lType
|
2005-09-18 19:27:28 -04:00
|
|
|
,int nDesiredWidth
|
|
|
|
,int nDesiredHeight
|
|
|
|
);
|
1999-12-03 00:03:55 -05:00
|
|
|
virtual bool SaveFile( wxBitmap* pBitmap
|
|
|
|
,const wxString& rName
|
2008-03-25 16:31:48 -04:00
|
|
|
,wxBitmapType lType
|
1999-12-03 00:03:55 -05:00
|
|
|
,const wxPalette* pPalette = NULL
|
2008-03-25 16:31:48 -04:00
|
|
|
) const;
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
virtual bool Create( wxGDIImage* pImage
|
2006-10-08 04:04:49 -04:00
|
|
|
,const void* pData
|
2008-03-29 15:34:37 -04:00
|
|
|
,wxBitmapType lFlags
|
1999-12-03 00:03:55 -05:00
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
|
|
|
virtual bool Load( wxGDIImage* pImage
|
2002-07-07 23:38:01 -04:00
|
|
|
,int nId
|
2008-03-29 15:34:37 -04:00
|
|
|
,wxBitmapType lFlags
|
1999-12-03 00:03:55 -05:00
|
|
|
,int nDesiredWidth
|
|
|
|
,int nDesiredHeight
|
|
|
|
);
|
2008-03-29 15:34:37 -04:00
|
|
|
virtual bool Save( const wxGDIImage* pImage
|
|
|
|
,const wxString& rName
|
|
|
|
,wxBitmapType lType
|
2008-03-25 16:31:48 -04:00
|
|
|
) const;
|
1999-12-03 00:03:55 -05:00
|
|
|
private:
|
2005-07-21 13:18:43 -04:00
|
|
|
inline virtual bool Load( wxGDIImage* WXUNUSED(pImage)
|
|
|
|
,const wxString& WXUNUSED(rName)
|
2008-01-12 10:05:15 -05:00
|
|
|
,WXHANDLE WXUNUSED(hPs)
|
2008-03-29 15:34:37 -04:00
|
|
|
,wxBitmapType WXUNUSED(lFlags)
|
2005-07-21 13:18:43 -04:00
|
|
|
,int WXUNUSED(nDesiredWidth)
|
|
|
|
,int WXUNUSED(nDesiredHeight)
|
2002-07-07 23:38:01 -04:00
|
|
|
)
|
2005-07-21 13:18:43 -04:00
|
|
|
{ return false; }
|
1999-12-03 00:03:55 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
|
2001-01-29 00:46:06 -05:00
|
|
|
}; // end of CLASS wxBitmapHandler
|
1999-12-03 00:03:55 -05:00
|
|
|
|
1999-07-29 01:11:30 -04:00
|
|
|
#endif
|
|
|
|
// _WX_BITMAP_H_
|