1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBitmap class
4 // Author: Julian Smart, Robert Roebling
8 // Copyright: (c) Julian Smart, Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #include "wx/object.h"
17 #include "wx/string.h"
18 #include "wx/palette.h"
19 #include "wx/gdiobj.h"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 class WXDLLIMPEXP_CORE wxMask
;
26 class WXDLLIMPEXP_CORE wxBitmap
;
27 class WXDLLIMPEXP_CORE wxImage
;
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 class WXDLLIMPEXP_CORE wxMask
: public wxObject
37 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
38 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
39 wxMask( const wxBitmap
& bitmap
);
42 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
43 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
44 bool Create( const wxBitmap
& bitmap
);
47 WXPixmap
GetBitmap() const { return m_bitmap
; }
48 void SetBitmap( WXPixmap bitmap
) { m_bitmap
= bitmap
; }
50 WXDisplay
*GetDisplay() const { return m_display
; }
51 void SetDisplay( WXDisplay
*display
) { m_display
= display
; }
58 DECLARE_DYNAMIC_CLASS(wxMask
)
61 //-----------------------------------------------------------------------------
63 //-----------------------------------------------------------------------------
65 class WXDLLEXPORT wxBitmapHandler
: public wxBitmapHandlerBase
68 wxBitmapHandler() : wxBitmapHandlerBase() {}
70 DECLARE_DYNAMIC_CLASS(wxBitmapHandler
)
73 class WXDLLIMPEXP_CORE wxBitmap
: public wxBitmapBase
77 wxBitmap( int width
, int height
, int depth
= -1 );
78 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
79 wxBitmap( const char **bits
) { (void)CreateFromXpm(bits
); }
80 wxBitmap( char **bits
) { (void)CreateFromXpm((const char **)bits
); }
81 wxBitmap( const wxBitmap
& bmp
);
82 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
85 wxBitmap
& operator = ( const wxBitmap
& bmp
);
86 bool operator == ( const wxBitmap
& bmp
) const;
87 bool operator != ( const wxBitmap
& bmp
) const;
90 static void InitStandardHandlers();
92 bool Create(int width
, int height
, int depth
= -1);
93 bool Create(void* data
, wxBitmapType type
,
94 int width
, int height
, int depth
= -1);
95 // create the wxBitmap using a _copy_ of the pixmap
96 bool Create(WXPixmap pixmap
);
98 int GetHeight() const;
100 int GetDepth() const;
103 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
104 wxImage
ConvertToImage() const;
105 bool CreateFromImage(const wxImage
& image
, int depth
= -1);
106 #endif // wxUSE_IMAGE
108 // copies the contents and mask of the given (colour) icon to the bitmap
109 virtual bool CopyFromIcon(const wxIcon
& icon
);
111 wxMask
*GetMask() const;
112 void SetMask( wxMask
*mask
);
114 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
116 bool SaveFile( const wxString
&name
, wxBitmapType type
, const wxPalette
*palette
= (wxPalette
*) NULL
) const;
117 bool LoadFile( const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
119 wxPalette
*GetPalette() const;
120 wxPalette
*GetColourMap() const
121 { return GetPalette(); };
122 virtual void SetPalette(const wxPalette
& palette
);
127 void SetHeight( int height
);
128 void SetWidth( int width
);
129 void SetDepth( int depth
);
130 void SetPixmap( WXPixmap pixmap
);
131 void SetBitmap( WXPixmap bitmap
);
133 WXPixmap
GetPixmap() const;
134 WXPixmap
GetBitmap() const;
136 WXPixmap
GetDrawable() const;
138 WXDisplay
*GetDisplay() const;
141 bool CreateFromXpm(const char **bits
);
144 DECLARE_DYNAMIC_CLASS(wxBitmap
)