1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBitmap class
4 // Author: Julian Smart, Robert Roebling
8 // Copyright: (c) Julian Smart, Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "bitmap.h"
20 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/palette.h"
23 #include "wx/gdiobj.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 class wxMask
: public wxObject
41 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
42 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
43 wxMask( const wxBitmap
& bitmap
);
46 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
47 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
48 bool Create( const wxBitmap
& bitmap
);
51 WXPixmap
GetBitmap() const { return m_bitmap
; }
52 void SetBitmap( WXPixmap bitmap
) { m_bitmap
= bitmap
; }
54 WXDisplay
*GetDisplay() const { return m_display
; }
55 void SetDisplay( WXDisplay
*display
) { m_display
= display
; }
62 DECLARE_DYNAMIC_CLASS(wxMask
)
65 //-----------------------------------------------------------------------------
67 //-----------------------------------------------------------------------------
69 class WXDLLEXPORT wxBitmapHandler
: public wxBitmapHandlerBase
72 wxBitmapHandler() : wxBitmapHandlerBase() {}
74 DECLARE_DYNAMIC_CLASS(wxBitmapHandler
)
77 class wxBitmap
: public wxBitmapBase
81 wxBitmap( int width
, int height
, int depth
= -1 );
82 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
83 wxBitmap( const char **bits
) { (void)CreateFromXpm(bits
); }
84 wxBitmap( char **bits
) { (void)CreateFromXpm((const char **)bits
); }
85 wxBitmap( const wxBitmap
& bmp
);
86 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
89 wxBitmap
& operator = ( const wxBitmap
& bmp
);
90 bool operator == ( const wxBitmap
& bmp
) const;
91 bool operator != ( const wxBitmap
& bmp
) const;
94 static void InitStandardHandlers();
96 bool Create(int width
, int height
, int depth
= -1);
97 bool Create(void* data
, wxBitmapType type
,
98 int width
, int height
, int depth
= -1);
99 // create the wxBitmap using a _copy_ of the pixmap
100 bool Create(WXPixmap pixmap
);
102 int GetHeight() const;
103 int GetWidth() const;
104 int GetDepth() const;
107 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
108 wxImage
ConvertToImage() const;
109 bool CreateFromImage(const wxImage
& image
, int depth
= -1);
110 #endif // wxUSE_IMAGE
112 // copies the contents and mask of the given (colour) icon to the bitmap
113 virtual bool CopyFromIcon(const wxIcon
& icon
);
115 wxMask
*GetMask() const;
116 void SetMask( wxMask
*mask
);
118 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
120 bool SaveFile( const wxString
&name
, wxBitmapType type
, const wxPalette
*palette
= (wxPalette
*) NULL
) const;
121 bool LoadFile( const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
123 wxPalette
*GetPalette() const;
124 wxPalette
*GetColourMap() const
125 { return GetPalette(); };
126 virtual void SetPalette(const wxPalette
& palette
);
131 void SetHeight( int height
);
132 void SetWidth( int width
);
133 void SetDepth( int depth
);
134 void SetPixmap( WXPixmap pixmap
);
135 void SetBitmap( WXPixmap bitmap
);
137 WXPixmap
GetPixmap() const;
138 WXPixmap
GetBitmap() const;
140 WXPixmap
GetDrawable() const;
142 WXDisplay
*GetDisplay() const;
145 bool CreateFromXpm(const char **bits
);
148 DECLARE_DYNAMIC_CLASS(wxBitmap
)