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
); }
91 virtual int GetHeight() const;
92 virtual int GetWidth() const;
93 virtual int GetDepth() const;
96 wxImage
ConvertToImage() const;
99 // copies the contents and mask of the given (colour) icon to the bitmap
100 virtual bool CopyFromIcon(const wxIcon
& icon
);
102 wxMask
*GetMask() const;
103 void SetMask( wxMask
*mask
);
104 wxBitmap
GetMaskBitmap() const;
106 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
108 bool SaveFile(const wxString
&name
, wxBitmapType type
,
109 const wxPalette
*palette
= NULL
) const;
110 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
113 wxPalette
*GetPalette() const;
114 void SetPalette(const wxPalette
& palette
);
115 wxPalette
*GetColourMap() const { return GetPalette(); }
116 #endif // wxUSE_PALETTE
118 static void InitStandardHandlers();
123 void SetHeight( int height
);
124 void SetWidth( int width
);
125 void SetDepth( int depth
);
128 GdkPixbuf
* GetPixbufNoMask() const;
129 cairo_t
* CairoCreate() const;
130 void Draw(cairo_t
* cr
, int x
, int y
, bool useMask
= true, const wxColour
* fg
= NULL
, const wxColour
* bg
= NULL
) const;
131 void SetSourceSurface(cairo_t
* cr
, int x
, int y
, const wxColour
* fg
= NULL
, const wxColour
* bg
= NULL
) const;
133 GdkPixmap
*GetPixmap() const;
134 bool HasPixmap() const;
135 bool HasPixbuf() const;
136 wxBitmap(GdkPixmap
* pixmap
);
138 GdkPixbuf
*GetPixbuf() const;
140 // raw bitmap access support functions
141 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
142 void UngetRawData(wxPixelDataBase
& data
);
144 bool HasAlpha() const;
149 bool CreateFromImage(const wxImage
& image
, int depth
);
150 #endif // wxUSE_IMAGE
153 virtual wxGDIRefData
* CreateGDIRefData() const;
154 virtual wxGDIRefData
* CloneGDIRefData(const wxGDIRefData
* data
) const;
158 void SetPixmap(GdkPixmap
* pixmap
);
160 // to be called from CreateFromImage only!
161 bool CreateFromImageAsPixmap(const wxImage
& image
, int depth
);
162 bool CreateFromImageAsPixbuf(const wxImage
& image
);
163 #endif // wxUSE_IMAGE
166 // implementation only
172 // removes other representations from memory, keeping only 'keep'
173 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
174 void PurgeOtherRepresentations(Representation keep
);
177 DECLARE_DYNAMIC_CLASS(wxBitmap
)
180 #endif // _WX_GTK_BITMAP_H_