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
);
35 wxBitmap
GetBitmap() const;
39 wxMask(cairo_surface_t
*);
40 operator cairo_surface_t
*() const;
43 operator GdkPixmap
*() const;
47 virtual void FreeData();
48 virtual bool InitFromColour(const wxBitmap
& bitmap
, const wxColour
& colour
);
49 virtual bool InitFromMonoBitmap(const wxBitmap
& bitmap
);
53 cairo_surface_t
* m_bitmap
;
58 DECLARE_DYNAMIC_CLASS(wxMask
)
61 //-----------------------------------------------------------------------------
63 //-----------------------------------------------------------------------------
65 class WXDLLIMPEXP_CORE wxBitmap
: public wxBitmapBase
69 wxBitmap( int width
, int height
, int depth
= wxBITMAP_SCREEN_DEPTH
)
70 { Create(width
, height
, depth
); }
71 wxBitmap( const wxSize
& sz
, int depth
= wxBITMAP_SCREEN_DEPTH
)
72 { Create(sz
, depth
); }
73 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
74 wxBitmap( const char* const* bits
);
78 { *this = wxBitmap(const_cast<const char* const*>(data
)); }
80 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
82 wxBitmap(const wxImage
& image
, int depth
= wxBITMAP_SCREEN_DEPTH
);
84 wxBitmap(GdkPixbuf
* pixbuf
, int depth
= 0);
87 bool Create(int width
, int height
, int depth
= wxBITMAP_SCREEN_DEPTH
);
88 bool Create(const wxSize
& sz
, int depth
= wxBITMAP_SCREEN_DEPTH
)
89 { return Create(sz
.GetWidth(), sz
.GetHeight(), depth
); }
90 bool Create(int width
, int height
, const wxDC
& WXUNUSED(dc
))
91 { return Create(width
,height
); }
94 virtual int GetHeight() const;
95 virtual int GetWidth() const;
96 virtual int GetDepth() const;
99 wxImage
ConvertToImage() const;
100 #endif // wxUSE_IMAGE
102 // copies the contents and mask of the given (colour) icon to the bitmap
103 virtual bool CopyFromIcon(const wxIcon
& icon
);
105 wxMask
*GetMask() const;
106 void SetMask( wxMask
*mask
);
107 wxBitmap
GetMaskBitmap() const;
109 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
111 bool SaveFile(const wxString
&name
, wxBitmapType type
,
112 const wxPalette
*palette
= NULL
) const;
113 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
116 wxPalette
*GetPalette() const;
117 void SetPalette(const wxPalette
& palette
);
118 wxPalette
*GetColourMap() const { return GetPalette(); }
119 #endif // wxUSE_PALETTE
121 static void InitStandardHandlers();
126 void SetHeight( int height
);
127 void SetWidth( int width
);
128 void SetDepth( int depth
);
131 GdkPixbuf
* GetPixbufNoMask() const;
132 cairo_t
* CairoCreate() const;
133 void Draw(cairo_t
* cr
, int x
, int y
, bool useMask
= true, const wxColour
* fg
= NULL
, const wxColour
* bg
= NULL
) const;
134 void SetSourceSurface(cairo_t
* cr
, int x
, int y
, const wxColour
* fg
= NULL
, const wxColour
* bg
= NULL
) const;
136 GdkPixmap
*GetPixmap() const;
137 bool HasPixmap() const;
138 bool HasPixbuf() const;
139 wxBitmap(GdkPixmap
* pixmap
);
141 GdkPixbuf
*GetPixbuf() const;
143 // raw bitmap access support functions
144 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
145 void UngetRawData(wxPixelDataBase
& data
);
147 bool HasAlpha() const;
152 bool CreateFromImage(const wxImage
& image
, int depth
);
153 #endif // wxUSE_IMAGE
156 virtual wxGDIRefData
* CreateGDIRefData() const;
157 virtual wxGDIRefData
* CloneGDIRefData(const wxGDIRefData
* data
) const;
161 void SetPixmap(GdkPixmap
* pixmap
);
163 // to be called from CreateFromImage only!
164 bool CreateFromImageAsPixmap(const wxImage
& image
, int depth
);
165 bool CreateFromImageAsPixbuf(const wxImage
& image
);
166 #endif // wxUSE_IMAGE
169 // implementation only
175 // removes other representations from memory, keeping only 'keep'
176 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
177 void PurgeOtherRepresentations(Representation keep
);
180 DECLARE_DYNAMIC_CLASS(wxBitmap
)
183 #endif // _WX_GTK_BITMAP_H_