1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-11-30 02:58:37 -05:00
|
|
|
// Name: wx/gtk/bitmap.h
|
1998-05-20 10:01:55 -04:00
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
1998-05-28 15:54:07 -04:00
|
|
|
// RCS-ID: $Id$
|
1998-10-24 13:12:05 -04:00
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-08-30 01:55:56 -04:00
|
|
|
#ifndef _WX_GTK_BITMAP_H_
|
|
|
|
#define _WX_GTK_BITMAP_H_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2004-08-21 18:42:06 -04:00
|
|
|
typedef struct _GdkPixbuf GdkPixbuf;
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
|
2005-02-13 12:14:19 -05:00
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxMask
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2009-10-17 16:06:34 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMask: public wxMaskBase
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1998-11-06 03:50:52 -05:00
|
|
|
public:
|
1999-08-24 16:26:06 -04:00
|
|
|
wxMask();
|
|
|
|
wxMask( const wxBitmap& bitmap, const wxColour& colour );
|
2005-11-30 02:58:37 -05:00
|
|
|
#if wxUSE_PALETTE
|
1999-08-24 16:26:06 -04:00
|
|
|
wxMask( const wxBitmap& bitmap, int paletteIndex );
|
2005-11-30 02:58:37 -05:00
|
|
|
#endif // wxUSE_PALETTE
|
1999-08-24 16:26:06 -04:00
|
|
|
wxMask( const wxBitmap& bitmap );
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxMask();
|
2005-11-30 02:58:37 -05:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
// implementation
|
|
|
|
GdkBitmap *m_bitmap;
|
|
|
|
GdkBitmap *GetBitmap() const;
|
2005-11-30 02:58:37 -05:00
|
|
|
|
2009-10-17 16:06:34 -04:00
|
|
|
protected:
|
|
|
|
virtual void FreeData();
|
|
|
|
virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour);
|
|
|
|
virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
|
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxMask)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxBitmap
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1998-11-06 03:50:52 -05:00
|
|
|
public:
|
2006-10-07 14:32:11 -04:00
|
|
|
wxBitmap() { }
|
2009-08-21 06:41:26 -04:00
|
|
|
wxBitmap( int width, int height, int depth = wxBITMAP_SCREEN_DEPTH )
|
2009-03-14 09:57:51 -04:00
|
|
|
{ Create(width, height, depth); }
|
2009-08-21 06:41:26 -04:00
|
|
|
wxBitmap( const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH )
|
2009-03-14 09:57:51 -04:00
|
|
|
{ Create(sz, depth); }
|
1999-08-24 16:26:06 -04:00
|
|
|
wxBitmap( const char bits[], int width, int height, int depth = 1 );
|
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)
|
2009-03-14 09:57:51 -04:00
|
|
|
{ *this = wxBitmap(const_cast<const char* const*>(data)); }
|
2006-10-30 03:07:51 -05:00
|
|
|
#endif
|
2008-09-21 16:03:14 -04:00
|
|
|
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
|
2007-07-10 20:02:11 -04:00
|
|
|
#if wxUSE_IMAGE
|
2008-03-25 16:31:48 -04:00
|
|
|
wxBitmap( const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH )
|
|
|
|
{ (void)CreateFromImage(image, depth); }
|
2007-07-10 20:02:11 -04:00
|
|
|
#endif // wxUSE_IMAGE
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxBitmap();
|
1999-08-24 16:26:06 -04:00
|
|
|
|
2008-03-25 16:31:48 -04:00
|
|
|
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
|
2009-03-14 09:57:51 -04:00
|
|
|
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
|
|
|
|
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
|
2005-11-30 02:58:37 -05:00
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
virtual int GetHeight() const;
|
|
|
|
virtual int GetWidth() const;
|
|
|
|
virtual int GetDepth() const;
|
2005-11-30 02:58:37 -05:00
|
|
|
|
2007-07-10 20:02:11 -04:00
|
|
|
#if wxUSE_IMAGE
|
2001-04-04 19:15:36 -04:00
|
|
|
wxImage ConvertToImage() const;
|
2007-07-10 20:02:11 -04:00
|
|
|
#endif // wxUSE_IMAGE
|
1999-08-24 16:26:06 -04:00
|
|
|
|
2001-09-23 18:36:17 -04:00
|
|
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
|
|
virtual bool CopyFromIcon(const wxIcon& icon);
|
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
wxMask *GetMask() const;
|
|
|
|
void SetMask( wxMask *mask );
|
2005-11-30 02:58:37 -05:00
|
|
|
|
1999-12-23 13:18:43 -05:00
|
|
|
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
1999-08-24 16:26:06 -04:00
|
|
|
|
2005-02-05 08:08:44 -05:00
|
|
|
bool SaveFile(const wxString &name, wxBitmapType type,
|
2009-01-19 08:55:27 -05:00
|
|
|
const wxPalette *palette = NULL) const;
|
2008-09-21 16:03:14 -04:00
|
|
|
bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
|
1999-08-24 16:26:06 -04:00
|
|
|
|
2005-02-05 08:08:44 -05:00
|
|
|
#if wxUSE_PALETTE
|
1999-08-24 16:26:06 -04:00
|
|
|
wxPalette *GetPalette() const;
|
2005-02-05 08:08:44 -05:00
|
|
|
void SetPalette(const wxPalette& palette);
|
2003-06-30 16:11:23 -04:00
|
|
|
wxPalette *GetColourMap() const { return GetPalette(); };
|
2005-02-05 08:08:44 -05:00
|
|
|
#endif // wxUSE_PALETTE
|
2003-06-30 16:11:23 -04:00
|
|
|
|
2005-02-05 09:17:27 -05:00
|
|
|
static void InitStandardHandlers();
|
1998-12-09 12:30:17 -05:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
// implementation
|
1999-11-22 14:44:25 -05:00
|
|
|
// --------------
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
void SetHeight( int height );
|
|
|
|
void SetWidth( int width );
|
|
|
|
void SetDepth( int depth );
|
|
|
|
void SetPixmap( GdkPixmap *pixmap );
|
2006-10-07 14:32:11 -04:00
|
|
|
void SetPixbuf(GdkPixbuf* pixbuf, int depth = 0);
|
1998-12-09 12:30:17 -05:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
GdkPixmap *GetPixmap() const;
|
2004-08-21 18:42:06 -04:00
|
|
|
bool HasPixmap() const;
|
|
|
|
bool HasPixbuf() const;
|
|
|
|
GdkPixbuf *GetPixbuf() const;
|
2005-11-30 02:58:37 -05:00
|
|
|
|
2005-02-13 10:35:43 -05:00
|
|
|
// raw bitmap access support functions
|
|
|
|
void *GetRawData(wxPixelDataBase& data, int bpp);
|
|
|
|
void UngetRawData(wxPixelDataBase& data);
|
|
|
|
|
2005-02-15 15:27:46 -05:00
|
|
|
bool HasAlpha() const;
|
2005-02-13 12:16:33 -05:00
|
|
|
|
1999-12-16 14:36:05 -05:00
|
|
|
protected:
|
2007-07-10 20:02:11 -04:00
|
|
|
#if wxUSE_IMAGE
|
2001-04-04 19:15:36 -04:00
|
|
|
bool CreateFromImage(const wxImage& image, int depth);
|
2007-07-10 20:02:11 -04:00
|
|
|
#endif // wxUSE_IMAGE
|
1999-12-16 14:36:05 -05:00
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
virtual wxGDIRefData* CreateGDIRefData() const;
|
|
|
|
virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
|
2006-10-24 12:44:26 -04:00
|
|
|
|
1999-08-24 16:26:06 -04:00
|
|
|
private:
|
2007-07-10 20:02:11 -04:00
|
|
|
#if wxUSE_IMAGE
|
2004-08-21 18:42:06 -04:00
|
|
|
// to be called from CreateFromImage only!
|
2006-08-14 02:26:35 -04:00
|
|
|
bool CreateFromImageAsPixmap(const wxImage& image, int depth);
|
2004-08-21 18:42:06 -04:00
|
|
|
bool CreateFromImageAsPixbuf(const wxImage& image);
|
2007-07-10 20:02:11 -04:00
|
|
|
#endif // wxUSE_IMAGE
|
2004-08-21 18:42:06 -04:00
|
|
|
|
2007-09-23 07:27:41 -04:00
|
|
|
public:
|
|
|
|
// implementation only
|
2004-08-21 18:42:06 -04:00
|
|
|
enum Representation
|
|
|
|
{
|
|
|
|
Pixmap,
|
|
|
|
Pixbuf
|
|
|
|
};
|
|
|
|
// removes other representations from memory, keeping only 'keep'
|
|
|
|
// (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
|
|
|
|
void PurgeOtherRepresentations(Representation keep);
|
|
|
|
|
2005-11-30 02:58:37 -05:00
|
|
|
private:
|
1999-08-24 16:26:06 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2006-08-30 01:55:56 -04:00
|
|
|
#endif // _WX_GTK_BITMAP_H_
|