1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/bitmap.h
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 #ifndef _WX_GTK_BITMAP_H_
10 #define _WX_GTK_BITMAP_H_
13 typedef struct _cairo cairo_t
;
14 typedef struct _cairo_surface cairo_surface_t
;
16 typedef struct _GdkPixbuf GdkPixbuf
;
17 class WXDLLIMPEXP_FWD_CORE wxPixelDataBase
;
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 class WXDLLIMPEXP_CORE wxMask
: public wxMaskBase
27 wxMask(const wxMask
& mask
);
28 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
30 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
31 #endif // wxUSE_PALETTE
32 wxMask( const wxBitmap
& bitmap
);
34 wxBitmap
GetBitmap() const;
38 wxMask(cairo_surface_t
*);
39 operator cairo_surface_t
*() const;
42 operator GdkPixmap
*() 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
, int depth
= 0);
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
); }
89 bool Create(int width
, int height
, const wxDC
& WXUNUSED(dc
))
90 { return Create(width
,height
); }
93 virtual int GetHeight() const;
94 virtual int GetWidth() const;
95 virtual int GetDepth() const;
98 wxImage
ConvertToImage() const;
101 // copies the contents and mask of the given (colour) icon to the bitmap
102 virtual bool CopyFromIcon(const wxIcon
& icon
);
104 wxMask
*GetMask() const;
105 void SetMask( wxMask
*mask
);
106 wxBitmap
GetMaskBitmap() const;
108 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
110 bool SaveFile(const wxString
&name
, wxBitmapType type
,
111 const wxPalette
*palette
= NULL
) const;
112 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
115 wxPalette
*GetPalette() const;
116 void SetPalette(const wxPalette
& palette
);
117 wxPalette
*GetColourMap() const { return GetPalette(); }
118 #endif // wxUSE_PALETTE
120 static void InitStandardHandlers();
125 void SetHeight( int height
);
126 void SetWidth( int width
);
127 void SetDepth( int depth
);
130 GdkPixbuf
* GetPixbufNoMask() const;
131 cairo_t
* CairoCreate() const;
132 void Draw(cairo_t
* cr
, int x
, int y
, bool useMask
= true, const wxColour
* fg
= NULL
, const wxColour
* bg
= NULL
) const;
133 void SetSourceSurface(cairo_t
* cr
, int x
, int y
, const wxColour
* fg
= NULL
, const wxColour
* bg
= NULL
) const;
135 GdkPixmap
*GetPixmap() const;
136 bool HasPixmap() const;
137 bool HasPixbuf() const;
138 wxBitmap(GdkPixmap
* pixmap
);
140 GdkPixbuf
*GetPixbuf() const;
142 // raw bitmap access support functions
143 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
144 void UngetRawData(wxPixelDataBase
& data
);
146 bool HasAlpha() const;
151 bool CreateFromImage(const wxImage
& image
, int depth
);
152 #endif // wxUSE_IMAGE
155 virtual wxGDIRefData
* CreateGDIRefData() const;
156 virtual wxGDIRefData
* CloneGDIRefData(const wxGDIRefData
* data
) const;
160 void SetPixmap(GdkPixmap
* pixmap
);
162 // to be called from CreateFromImage only!
163 bool CreateFromImageAsPixmap(const wxImage
& image
, int depth
);
164 bool CreateFromImageAsPixbuf(const wxImage
& image
);
165 #endif // wxUSE_IMAGE
168 // implementation only
174 // removes other representations from memory, keeping only 'keep'
175 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
176 void PurgeOtherRepresentations(Representation keep
);
179 DECLARE_DYNAMIC_CLASS(wxBitmap
)
182 #endif // _WX_GTK_BITMAP_H_