1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/x11/bitmap.h
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_FWD_CORE wxMask
;
26 class WXDLLIMPEXP_FWD_CORE wxBitmap
;
27 class WXDLLIMPEXP_FWD_CORE wxImage
;
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 class WXDLLIMPEXP_CORE wxMask
: public wxObject
37 wxMask(const wxMask
& mask
);
38 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
39 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
40 wxMask( const wxBitmap
& bitmap
);
43 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
44 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
45 bool Create( const wxBitmap
& bitmap
);
48 WXPixmap
GetBitmap() const { return m_bitmap
; }
49 void SetBitmap( WXPixmap bitmap
) { m_bitmap
= bitmap
; }
51 WXDisplay
*GetDisplay() const { return m_display
; }
52 void SetDisplay( WXDisplay
*display
) { m_display
= display
; }
60 DECLARE_DYNAMIC_CLASS(wxMask
)
63 //-----------------------------------------------------------------------------
65 //-----------------------------------------------------------------------------
67 class WXDLLIMPEXP_CORE wxBitmap
: public wxBitmapBase
71 wxBitmap( int width
, int height
, int depth
= -1 ) { Create( width
, height
, depth
); }
72 wxBitmap( const wxSize
& sz
, int depth
= -1 ) { Create( sz
, depth
); }
74 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
75 wxBitmap( const char* const* bits
);
80 *this = wxBitmap(const_cast<const char* const*>(data
));
83 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
86 static void InitStandardHandlers();
88 bool Create(int width
, int height
, int depth
= wxBITMAP_SCREEN_DEPTH
);
89 bool Create(const wxSize
& sz
, int depth
= wxBITMAP_SCREEN_DEPTH
)
90 { return Create(sz
.GetWidth(), sz
.GetHeight(), depth
); }
92 bool Create(const void* data
, wxBitmapType type
,
93 int width
, int height
, int depth
= -1);
94 // create the wxBitmap using a _copy_ of the pixmap
95 bool Create(WXPixmap pixmap
);
97 int GetHeight() const;
102 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
103 wxImage
ConvertToImage() const;
104 bool CreateFromImage(const wxImage
& image
, int depth
= -1);
105 #endif // wxUSE_IMAGE
107 // copies the contents and mask of the given (colour) icon to the bitmap
108 virtual bool CopyFromIcon(const wxIcon
& icon
);
110 wxMask
*GetMask() const;
111 void SetMask( wxMask
*mask
);
113 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
115 bool SaveFile( const wxString
&name
, wxBitmapType type
, const wxPalette
*palette
= NULL
) const;
116 bool LoadFile( const wxString
&name
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
118 wxPalette
*GetPalette() const;
119 wxPalette
*GetColourMap() const
120 { return GetPalette(); };
121 virtual void SetPalette(const wxPalette
& palette
);
126 void SetHeight( int height
);
127 void SetWidth( int width
);
128 void SetDepth( int depth
);
129 void SetPixmap( WXPixmap pixmap
);
130 void SetBitmap( WXPixmap bitmap
);
132 WXPixmap
GetPixmap() const;
133 WXPixmap
GetBitmap() const;
135 WXPixmap
GetDrawable() const;
137 WXDisplay
*GetDisplay() const;
140 virtual wxGDIRefData
*CreateGDIRefData() const;
141 virtual wxGDIRefData
*CloneGDIRefData(const wxGDIRefData
*data
) const;
144 DECLARE_DYNAMIC_CLASS(wxBitmap
)
147 #endif // _WX_BITMAP_H_