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 WXDLLIMPEXP_CORE wxBitmapHandler
: public wxBitmapHandlerBase
67 DECLARE_ABSTRACT_CLASS(wxBitmapHandler
)
70 class WXDLLIMPEXP_CORE wxBitmap
: public wxBitmapBase
74 wxBitmap( int width
, int height
, int depth
= -1 );
75 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
76 wxBitmap( const char* const* bits
);
77 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
80 bool operator == ( const wxBitmap
& bmp
) const;
81 bool operator != ( const wxBitmap
& bmp
) const;
82 bool Ok() const { return IsOk(); }
85 static void InitStandardHandlers();
87 bool Create(int width
, int height
, int depth
= -1);
88 bool Create(const void* data
, wxBitmapType type
,
89 int width
, int height
, int depth
= -1);
90 // create the wxBitmap using a _copy_ of the pixmap
91 bool Create(WXPixmap pixmap
);
93 int GetHeight() const;
98 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
99 wxImage
ConvertToImage() const;
100 bool CreateFromImage(const wxImage
& image
, int depth
= -1);
101 #endif // wxUSE_IMAGE
103 // copies the contents and mask of the given (colour) icon to the bitmap
104 virtual bool CopyFromIcon(const wxIcon
& icon
);
106 wxMask
*GetMask() const;
107 void SetMask( wxMask
*mask
);
109 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
111 bool SaveFile( const wxString
&name
, wxBitmapType type
, const wxPalette
*palette
= (wxPalette
*) NULL
) const;
112 bool LoadFile( const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
114 wxPalette
*GetPalette() const;
115 wxPalette
*GetColourMap() const
116 { return GetPalette(); };
117 virtual void SetPalette(const wxPalette
& palette
);
122 void SetHeight( int height
);
123 void SetWidth( int width
);
124 void SetDepth( int depth
);
125 void SetPixmap( WXPixmap pixmap
);
126 void SetBitmap( WXPixmap bitmap
);
128 WXPixmap
GetPixmap() const;
129 WXPixmap
GetBitmap() const;
131 WXPixmap
GetDrawable() const;
133 WXDisplay
*GetDisplay() const;
136 DECLARE_DYNAMIC_CLASS(wxBitmap
)