1999-01-01 11:05:26 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: bitmap.h
|
|
|
|
// Purpose: wxBitmap class
|
2003-02-28 16:54:04 -05:00
|
|
|
// Author: Stefan Csomor
|
1999-01-01 11:05:26 -05:00
|
|
|
// Modified by:
|
2003-02-28 16:54:04 -05:00
|
|
|
// Created: 1998-01-01
|
1999-01-01 11:05:26 -05:00
|
|
|
// RCS-ID: $Id$
|
2003-02-28 16:54:04 -05:00
|
|
|
// Copyright: (c) Stefan Csomor
|
2003-02-28 18:36:37 -05:00
|
|
|
// Licence: wxWindows licence
|
1999-01-01 11:05:26 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_BITMAP_H_
|
|
|
|
#define _WX_BITMAP_H_
|
|
|
|
|
2002-08-31 07:29:13 -04:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2001-06-30 06:14:48 -04:00
|
|
|
#pragma interface "bitmap.h"
|
1999-01-01 11:05:26 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/palette.h"
|
|
|
|
|
|
|
|
// Bitmap
|
|
|
|
class WXDLLEXPORT wxDC;
|
|
|
|
class WXDLLEXPORT wxControl;
|
|
|
|
class WXDLLEXPORT wxBitmap;
|
|
|
|
class WXDLLEXPORT wxBitmapHandler;
|
|
|
|
class WXDLLEXPORT wxIcon;
|
|
|
|
class WXDLLEXPORT wxCursor;
|
2001-04-04 19:15:36 -04:00
|
|
|
class WXDLLEXPORT wxImage;
|
1999-01-01 11:05:26 -05:00
|
|
|
|
|
|
|
// A mask is a mono bitmap used for drawing bitmaps
|
|
|
|
// transparently.
|
|
|
|
class WXDLLEXPORT wxMask: public wxObject
|
|
|
|
{
|
2002-05-08 09:30:26 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxMask)
|
|
|
|
DECLARE_NO_COPY_CLASS(wxMask)
|
1999-01-01 11:05:26 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
wxMask();
|
|
|
|
|
|
|
|
// Construct a mask from a bitmap and a colour indicating
|
|
|
|
// the transparent area
|
|
|
|
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
|
|
|
|
|
|
|
// Construct a mask from a bitmap and a palette index indicating
|
|
|
|
// the transparent area
|
|
|
|
wxMask(const wxBitmap& bitmap, int paletteIndex);
|
|
|
|
|
|
|
|
// Construct a mask from a mono bitmap (copies the bitmap).
|
|
|
|
wxMask(const wxBitmap& bitmap);
|
|
|
|
|
|
|
|
~wxMask();
|
|
|
|
|
|
|
|
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
|
|
|
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
|
|
|
bool Create(const wxBitmap& bitmap);
|
|
|
|
|
|
|
|
// Implementation
|
2001-04-01 16:42:05 -04:00
|
|
|
bool PointMasked(int x, int y);
|
1999-01-01 11:05:26 -05:00
|
|
|
inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
|
|
|
|
inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
|
|
|
|
protected:
|
|
|
|
WXHBITMAP m_maskBitmap;
|
|
|
|
};
|
|
|
|
|
2001-05-16 12:23:13 -04:00
|
|
|
enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict , kMacBitmapTypeIcon } ;
|
1999-11-05 04:16:09 -05:00
|
|
|
|
1999-01-01 11:05:26 -05:00
|
|
|
class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
|
|
|
|
{
|
2002-05-08 09:30:26 -04:00
|
|
|
DECLARE_NO_COPY_CLASS(wxBitmapRefData)
|
|
|
|
|
1999-01-01 11:05:26 -05:00
|
|
|
friend class WXDLLEXPORT wxBitmap;
|
|
|
|
friend class WXDLLEXPORT wxIcon;
|
|
|
|
friend class WXDLLEXPORT wxCursor;
|
|
|
|
public:
|
|
|
|
wxBitmapRefData();
|
|
|
|
~wxBitmapRefData();
|
|
|
|
|
|
|
|
public:
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
|
|
|
int m_depth;
|
|
|
|
bool m_ok;
|
|
|
|
int m_numColors;
|
|
|
|
wxPalette m_bitmapPalette;
|
|
|
|
int m_quality;
|
|
|
|
|
2003-02-28 18:36:37 -05:00
|
|
|
int m_bitmapType ;
|
|
|
|
WXHMETAFILE m_hPict ;
|
2002-05-08 09:30:26 -04:00
|
|
|
WXHBITMAP m_hBitmap;
|
|
|
|
WXHICON m_hIcon ;
|
1999-01-01 11:05:26 -05:00
|
|
|
wxMask * m_bitmapMask; // Optional mask
|
|
|
|
};
|
|
|
|
|
|
|
|
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
|
|
|
|
|
2001-06-28 17:23:41 -04:00
|
|
|
class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase
|
1999-01-01 11:05:26 -05:00
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
|
|
|
|
public:
|
2002-05-08 09:30:26 -04:00
|
|
|
wxBitmapHandler() : m_name(), m_extension(), m_type(0) { }
|
|
|
|
virtual ~wxBitmapHandler();
|
1999-01-01 11:05:26 -05:00
|
|
|
|
|
|
|
virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
|
|
|
|
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
|
|
|
int desiredWidth, int desiredHeight);
|
2001-06-28 17:23:41 -04:00
|
|
|
virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
|
1999-01-01 11:05:26 -05:00
|
|
|
|
2002-05-08 09:30:26 -04:00
|
|
|
void SetName(const wxString& name) { m_name = name; }
|
|
|
|
void SetExtension(const wxString& ext) { m_extension = ext; }
|
|
|
|
void SetType(long type) { m_type = type; }
|
|
|
|
wxString GetName() const { return m_name; }
|
|
|
|
wxString GetExtension() const { return m_extension; }
|
|
|
|
long GetType() const { return m_type; }
|
|
|
|
|
1999-01-01 11:05:26 -05:00
|
|
|
protected:
|
|
|
|
wxString m_name;
|
|
|
|
wxString m_extension;
|
|
|
|
long m_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
|
|
|
|
|
2001-06-28 17:23:41 -04:00
|
|
|
class WXDLLEXPORT wxBitmap: public wxBitmapBase
|
1999-01-01 11:05:26 -05:00
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
|
|
|
|
|
|
|
friend class WXDLLEXPORT wxBitmapHandler;
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxBitmap(); // Platform-specific
|
|
|
|
|
|
|
|
// Copy constructors
|
2002-05-08 09:30:26 -04:00
|
|
|
wxBitmap(const wxBitmap& bitmap)
|
|
|
|
: wxBitmapBase()
|
2001-12-01 12:48:29 -05:00
|
|
|
{ Ref(bitmap); }
|
1999-01-01 11:05:26 -05:00
|
|
|
|
|
|
|
// Initialize with raw data.
|
|
|
|
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
|
|
|
|
|
|
|
// Initialize with XPM data
|
2001-05-08 10:01:50 -04:00
|
|
|
bool CreateFromXpm(const char **bits);
|
|
|
|
wxBitmap(const char **bits);
|
|
|
|
wxBitmap(char **bits);
|
1999-01-01 11:05:26 -05:00
|
|
|
|
|
|
|
// Load a file or resource
|
2001-06-28 17:23:41 -04:00
|
|
|
wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_PICT_RESOURCE);
|
1999-01-01 11:05:26 -05:00
|
|
|
|
|
|
|
// Constructor for generalised creation from data
|
2001-06-28 17:23:41 -04:00
|
|
|
wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1);
|
1999-01-01 11:05:26 -05:00
|
|
|
|
|
|
|
// If depth is omitted, will create a bitmap compatible with the display
|
|
|
|
wxBitmap(int width, int height, int depth = -1);
|
2001-04-04 19:15:36 -04:00
|
|
|
|
|
|
|
// Convert from wxImage:
|
|
|
|
wxBitmap(const wxImage& image, int depth = -1);
|
|
|
|
|
1999-01-01 11:05:26 -05:00
|
|
|
~wxBitmap();
|
2001-04-04 19:15:36 -04:00
|
|
|
|
|
|
|
wxImage ConvertToImage() const;
|
1999-01-01 11:05:26 -05:00
|
|
|
|
2001-04-01 16:42:05 -04:00
|
|
|
// get the given part of bitmap
|
|
|
|
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
|
|
|
|
1999-01-01 11:05:26 -05:00
|
|
|
virtual bool Create(int width, int height, int depth = -1);
|
2001-06-28 17:23:41 -04:00
|
|
|
virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1);
|
|
|
|
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
|
|
|
|
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
|
|
|
|
|
|
|
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
|
|
virtual bool CopyFromIcon(const wxIcon& icon);
|
1999-01-01 11:05:26 -05:00
|
|
|
|
2001-04-01 16:42:05 -04:00
|
|
|
bool Ok() const;
|
|
|
|
int GetWidth() const;
|
|
|
|
int GetHeight() const;
|
|
|
|
int GetDepth() const;
|
|
|
|
int GetQuality() const;
|
1999-01-01 11:05:26 -05:00
|
|
|
void SetWidth(int w);
|
|
|
|
void SetHeight(int h);
|
|
|
|
void SetDepth(int d);
|
|
|
|
void SetQuality(int q);
|
|
|
|
void SetOk(bool isOk);
|
|
|
|
|
2001-04-01 16:42:05 -04:00
|
|
|
wxPalette* GetPalette() const;
|
1999-01-01 11:05:26 -05:00
|
|
|
void SetPalette(const wxPalette& palette);
|
|
|
|
|
2001-04-01 16:42:05 -04:00
|
|
|
wxMask *GetMask() const;
|
1999-01-01 11:05:26 -05:00
|
|
|
void SetMask(wxMask *mask) ;
|
|
|
|
|
2001-04-01 16:42:05 -04:00
|
|
|
int GetBitmapType() const;
|
|
|
|
|
1999-01-01 11:05:26 -05:00
|
|
|
inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
|
2002-03-17 09:23:02 -05:00
|
|
|
inline bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
|
|
|
|
inline bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
|
1999-01-01 11:05:26 -05:00
|
|
|
|
|
|
|
static void InitStandardHandlers();
|
|
|
|
public:
|
2001-04-01 16:42:05 -04:00
|
|
|
WXHBITMAP GetHBITMAP() const;
|
2001-05-16 12:23:13 -04:00
|
|
|
inline WXHICON GetHICON() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hIcon : 0); }
|
2003-02-09 04:11:43 -05:00
|
|
|
WXHMETAFILE GetPict(bool *created = NULL ) const;
|
|
|
|
|
|
|
|
void SetHBITMAP(WXHBITMAP bmp);
|
|
|
|
void SetHICON(WXHICON ico);
|
|
|
|
void SetPict( WXHMETAFILE pict ) ;
|
2001-04-01 16:42:05 -04:00
|
|
|
|
1999-01-01 11:05:26 -05:00
|
|
|
bool FreeResource(bool force = FALSE);
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
// _WX_BITMAP_H_
|