1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-11-30 07:58:37 +00:00
|
|
|
// Name: wx/gtk/bitmap.h
|
1998-05-20 14:01:55 +00:00
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
1998-05-28 19:54:07 +00:00
|
|
|
// RCS-ID: $Id$
|
1998-10-24 17:12:05 +00:00
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-08-30 05:55:56 +00:00
|
|
|
#ifndef _WX_GTK_BITMAP_H_
|
|
|
|
#define _WX_GTK_BITMAP_H_
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2004-08-21 22:42:06 +00:00
|
|
|
typedef struct _GdkPixbuf GdkPixbuf;
|
2005-02-13 17:14:19 +00:00
|
|
|
class WXDLLEXPORT wxPixelDataBase;
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxMask
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 22:58:06 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxMask: public wxObject
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-11-06 08:50:52 +00:00
|
|
|
public:
|
1999-08-24 20:26:06 +00:00
|
|
|
wxMask();
|
|
|
|
wxMask( const wxBitmap& bitmap, const wxColour& colour );
|
2005-11-30 07:58:37 +00:00
|
|
|
#if wxUSE_PALETTE
|
1999-08-24 20:26:06 +00:00
|
|
|
wxMask( const wxBitmap& bitmap, int paletteIndex );
|
2005-11-30 07:58:37 +00:00
|
|
|
#endif // wxUSE_PALETTE
|
1999-08-24 20:26:06 +00:00
|
|
|
wxMask( const wxBitmap& bitmap );
|
2006-09-05 20:47:48 +00:00
|
|
|
virtual ~wxMask();
|
2005-11-30 07:58:37 +00:00
|
|
|
|
1999-08-24 20:26:06 +00:00
|
|
|
bool Create( const wxBitmap& bitmap, const wxColour& colour );
|
2005-11-30 07:58:37 +00:00
|
|
|
#if wxUSE_PALETTE
|
1999-08-24 20:26:06 +00:00
|
|
|
bool Create( const wxBitmap& bitmap, int paletteIndex );
|
2005-11-30 07:58:37 +00:00
|
|
|
#endif // wxUSE_PALETTE
|
1999-08-24 20:26:06 +00:00
|
|
|
bool Create( const wxBitmap& bitmap );
|
|
|
|
|
|
|
|
// implementation
|
|
|
|
GdkBitmap *m_bitmap;
|
2005-11-30 07:58:37 +00:00
|
|
|
|
1999-08-24 20:26:06 +00:00
|
|
|
GdkBitmap *GetBitmap() const;
|
2005-11-30 07:58:37 +00:00
|
|
|
|
1999-08-24 20:26:06 +00:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxMask)
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxBitmap
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 22:58:06 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-11-06 08:50:52 +00:00
|
|
|
public:
|
2006-10-07 18:32:11 +00:00
|
|
|
wxBitmap() { }
|
1999-08-24 20:26:06 +00:00
|
|
|
wxBitmap( int width, int height, int depth = -1 );
|
|
|
|
wxBitmap( const char bits[], int width, int height, int depth = 1 );
|
2006-10-08 08:04:49 +00:00
|
|
|
wxBitmap( const char* const* bits );
|
2005-02-05 13:08:44 +00:00
|
|
|
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
|
2001-04-04 23:15:36 +00:00
|
|
|
wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
|
2006-09-05 20:47:48 +00:00
|
|
|
virtual ~wxBitmap();
|
2000-07-15 19:51:35 +00:00
|
|
|
bool operator == ( const wxBitmap& bmp ) const;
|
2006-10-07 18:32:11 +00:00
|
|
|
bool operator != ( const wxBitmap& bmp ) const { return !(*this == bmp); }
|
1999-08-24 20:26:06 +00:00
|
|
|
bool Ok() const;
|
|
|
|
|
2000-02-27 16:48:27 +00:00
|
|
|
bool Create(int width, int height, int depth = -1);
|
2005-11-30 07:58:37 +00:00
|
|
|
|
1999-08-24 20:26:06 +00:00
|
|
|
int GetHeight() const;
|
|
|
|
int GetWidth() const;
|
|
|
|
int GetDepth() const;
|
2005-11-30 07:58:37 +00:00
|
|
|
|
2001-04-04 23:15:36 +00:00
|
|
|
wxImage ConvertToImage() const;
|
1999-08-24 20:26:06 +00:00
|
|
|
|
2001-09-23 22:36:17 +00:00
|
|
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
|
|
virtual bool CopyFromIcon(const wxIcon& icon);
|
|
|
|
|
1999-08-24 20:26:06 +00:00
|
|
|
wxMask *GetMask() const;
|
|
|
|
void SetMask( wxMask *mask );
|
2005-11-30 07:58:37 +00:00
|
|
|
|
1999-12-23 18:18:43 +00:00
|
|
|
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
1999-08-24 20:26:06 +00:00
|
|
|
|
2005-02-05 13:08:44 +00:00
|
|
|
bool SaveFile(const wxString &name, wxBitmapType type,
|
|
|
|
const wxPalette *palette = (wxPalette *)NULL) const;
|
|
|
|
bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
|
1999-08-24 20:26:06 +00:00
|
|
|
|
2005-02-05 13:08:44 +00:00
|
|
|
#if wxUSE_PALETTE
|
1999-08-24 20:26:06 +00:00
|
|
|
wxPalette *GetPalette() const;
|
2005-02-05 13:08:44 +00:00
|
|
|
void SetPalette(const wxPalette& palette);
|
2003-06-30 20:11:23 +00:00
|
|
|
wxPalette *GetColourMap() const { return GetPalette(); };
|
2005-02-05 13:08:44 +00:00
|
|
|
#endif // wxUSE_PALETTE
|
2003-06-30 20:11:23 +00:00
|
|
|
|
2005-02-05 14:17:27 +00:00
|
|
|
static void InitStandardHandlers();
|
1998-12-09 17:30:17 +00:00
|
|
|
|
1999-08-24 20:26:06 +00:00
|
|
|
// implementation
|
1999-11-22 19:44:25 +00:00
|
|
|
// --------------
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-08-24 20:26:06 +00:00
|
|
|
void SetHeight( int height );
|
|
|
|
void SetWidth( int width );
|
|
|
|
void SetDepth( int depth );
|
|
|
|
void SetPixmap( GdkPixmap *pixmap );
|
2006-10-07 18:32:11 +00:00
|
|
|
void SetPixbuf(GdkPixbuf* pixbuf, int depth = 0);
|
1998-12-09 17:30:17 +00:00
|
|
|
|
1999-08-24 20:26:06 +00:00
|
|
|
GdkPixmap *GetPixmap() const;
|
2004-08-21 22:42:06 +00:00
|
|
|
bool HasPixmap() const;
|
|
|
|
bool HasPixbuf() const;
|
|
|
|
GdkPixbuf *GetPixbuf() const;
|
2005-11-30 07:58:37 +00:00
|
|
|
|
2003-10-09 20:01:49 +00:00
|
|
|
// Basically, this corresponds to Win32 StretchBlt()
|
2006-10-07 18:32:11 +00:00
|
|
|
wxBitmap Rescale(int clipx, int clipy, int clipwidth, int clipheight, int width, int height) const;
|
2005-11-30 07:58:37 +00:00
|
|
|
|
2005-02-13 15:35:43 +00:00
|
|
|
// raw bitmap access support functions
|
|
|
|
void *GetRawData(wxPixelDataBase& data, int bpp);
|
|
|
|
void UngetRawData(wxPixelDataBase& data);
|
|
|
|
|
2005-02-15 20:27:46 +00:00
|
|
|
bool HasAlpha() const;
|
|
|
|
void UseAlpha();
|
2005-02-13 17:16:33 +00:00
|
|
|
|
1999-12-16 19:36:05 +00:00
|
|
|
protected:
|
2001-04-04 23:15:36 +00:00
|
|
|
bool CreateFromImage(const wxImage& image, int depth);
|
1999-12-16 19:36:05 +00:00
|
|
|
|
1999-08-24 20:26:06 +00:00
|
|
|
private:
|
2004-08-21 22:42:06 +00:00
|
|
|
// to be called from CreateFromImage only!
|
2006-08-14 06:26:35 +00:00
|
|
|
bool CreateFromImageAsPixmap(const wxImage& image, int depth);
|
2004-08-21 22:42:06 +00:00
|
|
|
bool CreateFromImageAsPixbuf(const wxImage& image);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
friend class wxMemoryDC;
|
2005-02-05 14:17:27 +00:00
|
|
|
friend class wxBitmapHandler;
|
|
|
|
|
2005-11-30 07:58:37 +00:00
|
|
|
private:
|
1999-08-24 20:26:06 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2005-02-05 14:17:27 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxBitmapHandler
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 22:58:06 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
|
2005-02-05 14:17:27 +00:00
|
|
|
{
|
2006-10-08 08:04:49 +00:00
|
|
|
DECLARE_ABSTRACT_CLASS(wxBitmapHandler)
|
2005-02-05 14:17:27 +00:00
|
|
|
};
|
|
|
|
|
2006-08-30 05:55:56 +00:00
|
|
|
#endif // _WX_GTK_BITMAP_H_
|