1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/bitmap.h
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_BITMAP_H_
11 #define _WX_GTK_BITMAP_H_
14 typedef struct _cairo cairo_t
;
15 typedef struct _cairo_surface cairo_surface_t
;
17 typedef struct _GdkPixbuf GdkPixbuf
;
18 class WXDLLIMPEXP_FWD_CORE wxPixelDataBase
;
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 class WXDLLIMPEXP_CORE wxMask
: public wxMaskBase
28 wxMask(const wxMask
& mask
);
29 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
31 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
32 #endif // wxUSE_PALETTE
33 wxMask( const wxBitmap
& bitmap
);
38 wxMask(cairo_surface_t
*);
39 cairo_surface_t
* GetBitmap() const;
42 GdkPixmap
* GetBitmap() const;
46 virtual void FreeData();
47 virtual bool InitFromColour(const wxBitmap
& bitmap
, const wxColour
& colour
);
48 virtual bool InitFromMonoBitmap(const wxBitmap
& bitmap
);
52 cairo_surface_t
* m_bitmap
;
57 DECLARE_DYNAMIC_CLASS(wxMask
)
60 //-----------------------------------------------------------------------------
62 //-----------------------------------------------------------------------------
64 class WXDLLIMPEXP_CORE wxBitmap
: public wxBitmapBase
68 wxBitmap( int width
, int height
, int depth
= wxBITMAP_SCREEN_DEPTH
)
69 { Create(width
, height
, depth
); }
70 wxBitmap( const wxSize
& sz
, int depth
= wxBITMAP_SCREEN_DEPTH
)
71 { Create(sz
, depth
); }
72 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
73 wxBitmap( const char* const* bits
);
77 { *this = wxBitmap(const_cast<const char* const*>(data
)); }
79 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
81 wxBitmap(const wxImage
& image
, int depth
= wxBITMAP_SCREEN_DEPTH
);
83 wxBitmap(GdkPixbuf
* pixbuf
);
86 bool Create(int width
, int height
, int depth
= wxBITMAP_SCREEN_DEPTH
);
87 bool Create(const wxSize
& sz
, int depth
= wxBITMAP_SCREEN_DEPTH
)
88 { return Create(sz
.GetWidth(), sz
.GetHeight(), depth
); }
90 virtual int GetHeight() const;
91 virtual int GetWidth() const;
92 virtual int GetDepth() const;
95 wxImage
ConvertToImage() const;
98 // copies the contents and mask of the given (colour) icon to the bitmap
99 virtual bool CopyFromIcon(const wxIcon
& icon
);
101 wxMask
*GetMask() const;
102 void SetMask( wxMask
*mask
);
103 wxBitmap
GetMaskBitmap() const;
105 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
107 bool SaveFile(const wxString
&name
, wxBitmapType type
,
108 const wxPalette
*palette
= NULL
) const;
109 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
112 wxPalette
*GetPalette() const;
113 void SetPalette(const wxPalette
& palette
);
114 wxPalette
*GetColourMap() const { return GetPalette(); }
115 #endif // wxUSE_PALETTE
117 static void InitStandardHandlers();
122 void SetHeight( int height
);
123 void SetWidth( int width
);
124 void SetDepth( int depth
);
127 GdkPixbuf
* GetPixbufNoMask() const;
128 cairo_t
* CairoCreate() const;
129 void Draw(cairo_t
* cr
, int x
, int y
, bool useMask
= true, const wxColour
* fg
= NULL
, const wxColour
* bg
= NULL
) const;
130 void SetSourceSurface(cairo_t
* cr
, int x
, int y
, const wxColour
* fg
= NULL
, const wxColour
* bg
= NULL
) const;
132 GdkPixmap
*GetPixmap() const;
133 bool HasPixmap() const;
134 bool HasPixbuf() const;
136 GdkPixbuf
*GetPixbuf() const;
138 // raw bitmap access support functions
139 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
140 void UngetRawData(wxPixelDataBase
& data
);
142 bool HasAlpha() const;
147 bool CreateFromImage(const wxImage
& image
, int depth
);
148 #endif // wxUSE_IMAGE
151 virtual wxGDIRefData
* CreateGDIRefData() const;
152 virtual wxGDIRefData
* CloneGDIRefData(const wxGDIRefData
* data
) const;
156 void SetPixmap(GdkPixmap
* pixmap
);
158 // to be called from CreateFromImage only!
159 bool CreateFromImageAsPixmap(const wxImage
& image
, int depth
);
160 bool CreateFromImageAsPixbuf(const wxImage
& image
);
161 #endif // wxUSE_IMAGE
164 // implementation only
170 // removes other representations from memory, keeping only 'keep'
171 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
172 void PurgeOtherRepresentations(Representation keep
);
175 DECLARE_DYNAMIC_CLASS(wxBitmap
)
178 #endif // _WX_GTK_BITMAP_H_