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
|
|
|
|
// Licence: wxWindows licence
|
1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_BITMAP_H_
|
|
|
|
#define _WX_BITMAP_H_
|
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "bitmap.h"
|
|
|
|
#endif
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxDC;
|
|
|
|
class WXDLLEXPORT wxControl;
|
|
|
|
class WXDLLEXPORT wxBitmap;
|
|
|
|
class WXDLLEXPORT wxBitmapHandler;
|
|
|
|
class WXDLLEXPORT wxIcon;
|
1999-12-03 00:03:55 -05:00
|
|
|
class WXDLLEXPORT wxMask;
|
1999-07-29 01:11:30 -04:00
|
|
|
class WXDLLEXPORT wxCursor;
|
1999-10-13 18:34:18 -04:00
|
|
|
class WXDLLEXPORT wxControl;
|
2001-04-04 19:15:36 -04:00
|
|
|
class WXDLLEXPORT wxImage;
|
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
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
class WXDLLEXPORT wxBitmapRefData : public wxGDIImageRefData
|
1999-07-29 01:11:30 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxBitmapRefData();
|
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
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
class WXDLLEXPORT 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)
|
|
|
|
{ Init(); Ref(rBitmap); }
|
|
|
|
|
|
|
|
// Initialize with raw data
|
|
|
|
wxBitmap( const char bits[]
|
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
|
|
|
|
|
|
|
// Initialize with XPM data
|
2001-01-29 00:46:06 -05:00
|
|
|
wxBitmap(const char** ppData);
|
|
|
|
wxBitmap(char** ppData);
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
// Load a file or resource
|
|
|
|
wxBitmap( const wxString& rName
|
|
|
|
,long lType = wxBITMAP_TYPE_BMP_RESOURCE
|
|
|
|
);
|
|
|
|
|
|
|
|
// New constructor for generalised creation from data
|
|
|
|
wxBitmap( void* pData
|
|
|
|
,long lType
|
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
|
|
|
|
|
|
|
// If depth is omitted, will create a bitmap compatible with the display
|
|
|
|
wxBitmap( int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = -1
|
|
|
|
);
|
|
|
|
|
2001-04-04 19:15:36 -04:00
|
|
|
wxBitmap( const wxImage& image, int depth = -1 )
|
|
|
|
{ (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 wxBitmap& rBitmap)
|
|
|
|
{
|
|
|
|
if ( m_refData != rBitmap.m_refData )
|
|
|
|
Ref(rBitmap);
|
|
|
|
return(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxBitmap& operator=(const wxIcon& rIcon)
|
|
|
|
{
|
|
|
|
(void)CopyFromIcon(rIcon);
|
|
|
|
|
|
|
|
return(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxBitmap& operator=(const wxCursor& rCursor)
|
|
|
|
{
|
|
|
|
(void)CopyFromCursor(rCursor);
|
|
|
|
return (*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~wxBitmap();
|
|
|
|
|
2001-04-04 19:15:36 -04:00
|
|
|
wxImage ConvertToImage() const;
|
|
|
|
|
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
|
|
|
|
);
|
|
|
|
virtual bool Create( void* pData
|
|
|
|
,long lType
|
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
|
|
|
virtual bool LoadFile( const wxString& rName
|
|
|
|
,long lType = wxBITMAP_TYPE_BMP_RESOURCE
|
|
|
|
);
|
|
|
|
virtual bool SaveFile( const wxString& rName
|
|
|
|
,int lType
|
|
|
|
,const wxPalette* pCmap = NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
inline wxBitmapRefData* GetBitmapData() const
|
|
|
|
{ return (wxBitmapRefData *)m_refData; }
|
|
|
|
|
|
|
|
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
|
1999-12-05 16:23:52 -05:00
|
|
|
{ return (GetBitmapData() ? (& GetBitmapData()->m_vBitmapPalette) : (wxPalette*) NULL); }
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
void SetPalette(const wxPalette& rPalette);
|
|
|
|
|
|
|
|
inline wxMask* GetMask() const
|
1999-12-05 16:23:52 -05:00
|
|
|
{ return (GetBitmapData() ? GetBitmapData()->m_pBitmapMask : (wxMask*) NULL); }
|
1999-12-03 00:03:55 -05:00
|
|
|
|
|
|
|
void SetMask(wxMask* pMask) ;
|
|
|
|
|
|
|
|
inline bool operator==(const wxBitmap& rBitmap)
|
|
|
|
{ return m_refData == rBitmap.m_refData; }
|
|
|
|
|
|
|
|
inline bool operator!=(const wxBitmap& rBitmap)
|
|
|
|
{ return m_refData != rBitmap.m_refData; }
|
|
|
|
|
|
|
|
#if WXWIN_COMPATIBILITY_2
|
|
|
|
void SetOk(bool bIsOk);
|
|
|
|
#endif // WXWIN_COMPATIBILITY_2
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
#if WXWIN_COMPATIBILITY
|
|
|
|
inline wxPalette* GetColourMap() const
|
|
|
|
{ return GetPalette(); }
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
inline void SetColourMap(wxPalette* pCmap)
|
|
|
|
{ SetPalette(*pCmap); };
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
#endif // WXWIN_COMPATIBILITY
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
// 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
|
1999-12-05 16:23:52 -05:00
|
|
|
{ return (GetBitmapData() ? GetBitmapData()->m_pSelectedInto : (wxDC*) NULL); }
|
1999-12-03 00:03:55 -05: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
|
|
|
|
2001-01-29 00:46:06 -05:00
|
|
|
// inline LONG GetId() const
|
|
|
|
// { return (GetBitmapData() ? GetBitmapData()->m_lId : 0L); }
|
2000-11-27 15:01:19 -05: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
|
|
|
|
2000-12-21 17:07:50 -05:00
|
|
|
// creates the bitmap from XPM data, supposed to be called from ctor
|
|
|
|
bool CreateFromXpm(const char **bits);
|
2001-04-04 19:15:36 -04:00
|
|
|
bool CreateFromImage(const wxImage& image, int depth);
|
2000-12-21 17:07:50 -05:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
private:
|
|
|
|
bool CopyFromIconOrCursor(const wxGDIImage& rIcon);
|
1999-07-29 01:11:30 -04:00
|
|
|
|
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
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
class WXDLLEXPORT wxMask : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxMask();
|
|
|
|
|
|
|
|
// 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
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
class WXDLLEXPORT wxBitmapHandler : public wxGDIImageHandler
|
|
|
|
{
|
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
|
|
|
|
,long lType
|
|
|
|
)
|
|
|
|
: wxGDIImageHandler( rName
|
|
|
|
,rExt
|
|
|
|
,lType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// keep wxBitmapHandler derived from wxGDIImageHandler compatible with the
|
|
|
|
// old class which worked only with bitmaps
|
|
|
|
virtual bool Create( wxBitmap* pBitmap
|
|
|
|
,void* pData
|
|
|
|
,long lFlags
|
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
|
|
|
virtual bool LoadFile( wxBitmap* pBitmap
|
|
|
|
,const wxString& rName
|
1999-12-15 11:59:08 -05:00
|
|
|
,HPS hPs
|
1999-12-03 00:03:55 -05:00
|
|
|
,long lFlags
|
|
|
|
,int nDesiredWidth
|
|
|
|
,int nDesiredHeight
|
|
|
|
);
|
|
|
|
virtual bool SaveFile( wxBitmap* pBitmap
|
|
|
|
,const wxString& rName
|
|
|
|
,int lType
|
|
|
|
,const wxPalette* pPalette = NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual bool Create( wxGDIImage* pImage
|
|
|
|
,void* pData
|
|
|
|
,long lFlags
|
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
,int nDepth = 1
|
|
|
|
);
|
|
|
|
virtual bool Load( wxGDIImage* pImage
|
|
|
|
,const wxString& rName
|
1999-12-15 11:59:08 -05:00
|
|
|
,HPS hPs
|
1999-12-03 00:03:55 -05:00
|
|
|
,long lFlags
|
|
|
|
,int nDesiredWidth
|
|
|
|
,int nDesiredHeight
|
|
|
|
);
|
1999-12-05 16:23:52 -05:00
|
|
|
virtual bool Save( wxGDIImage* pImage
|
|
|
|
,const wxString& rName
|
|
|
|
,int lType
|
1999-12-03 00:03:55 -05:00
|
|
|
);
|
|
|
|
private:
|
|
|
|
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_
|