]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/bitmap.h
remove unnecessary include of wx/cairo.h
[wxWidgets.git] / include / wx / gtk / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/bitmap.h
3 // Purpose:
4 // Author: Robert Roebling
5 // RCS-ID: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_GTK_BITMAP_H_
11 #define _WX_GTK_BITMAP_H_
12
13 #ifdef __WXGTK3__
14 typedef struct _cairo cairo_t;
15 typedef struct _cairo_surface cairo_surface_t;
16 #endif
17 typedef struct _GdkPixbuf GdkPixbuf;
18 class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
19
20 //-----------------------------------------------------------------------------
21 // wxMask
22 //-----------------------------------------------------------------------------
23
24 class WXDLLIMPEXP_CORE wxMask: public wxMaskBase
25 {
26 public:
27 wxMask();
28 wxMask(const wxMask& mask);
29 wxMask( const wxBitmap& bitmap, const wxColour& colour );
30 #if wxUSE_PALETTE
31 wxMask( const wxBitmap& bitmap, int paletteIndex );
32 #endif // wxUSE_PALETTE
33 wxMask( const wxBitmap& bitmap );
34 virtual ~wxMask();
35
36 // implementation
37 #ifdef __WXGTK3__
38 wxMask(cairo_surface_t*);
39 cairo_surface_t* GetBitmap() const;
40 #else
41 wxMask(GdkPixmap*);
42 GdkPixmap* GetBitmap() const;
43 #endif
44
45 protected:
46 virtual void FreeData();
47 virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour);
48 virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
49
50 private:
51 #ifdef __WXGTK3__
52 cairo_surface_t* m_bitmap;
53 #else
54 GdkPixmap* m_bitmap;
55 #endif
56
57 DECLARE_DYNAMIC_CLASS(wxMask)
58 };
59
60 //-----------------------------------------------------------------------------
61 // wxBitmap
62 //-----------------------------------------------------------------------------
63
64 class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
65 {
66 public:
67 wxBitmap() { }
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 );
74 #ifdef wxNEEDS_CHARPP
75 // needed for old GCC
76 wxBitmap(char** data)
77 { *this = wxBitmap(const_cast<const char* const*>(data)); }
78 #endif
79 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
80 #if wxUSE_IMAGE
81 wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH);
82 #endif // wxUSE_IMAGE
83 wxBitmap(GdkPixbuf* pixbuf);
84 virtual ~wxBitmap();
85
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
90 virtual int GetHeight() const;
91 virtual int GetWidth() const;
92 virtual int GetDepth() const;
93
94 #if wxUSE_IMAGE
95 wxImage ConvertToImage() const;
96 #endif // wxUSE_IMAGE
97
98 // copies the contents and mask of the given (colour) icon to the bitmap
99 virtual bool CopyFromIcon(const wxIcon& icon);
100
101 wxMask *GetMask() const;
102 void SetMask( wxMask *mask );
103 wxBitmap GetMaskBitmap() const;
104
105 wxBitmap GetSubBitmap( const wxRect& rect ) const;
106
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);
110
111 #if wxUSE_PALETTE
112 wxPalette *GetPalette() const;
113 void SetPalette(const wxPalette& palette);
114 wxPalette *GetColourMap() const { return GetPalette(); }
115 #endif // wxUSE_PALETTE
116
117 static void InitStandardHandlers();
118
119 // implementation
120 // --------------
121
122 void SetHeight( int height );
123 void SetWidth( int width );
124 void SetDepth( int depth );
125
126 #ifdef __WXGTK3__
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;
131 #else
132 GdkPixmap *GetPixmap() const;
133 bool HasPixmap() const;
134 bool HasPixbuf() const;
135 #endif
136 GdkPixbuf *GetPixbuf() const;
137
138 // raw bitmap access support functions
139 void *GetRawData(wxPixelDataBase& data, int bpp);
140 void UngetRawData(wxPixelDataBase& data);
141
142 bool HasAlpha() const;
143
144 protected:
145 #ifndef __WXGTK3__
146 #if wxUSE_IMAGE
147 bool CreateFromImage(const wxImage& image, int depth);
148 #endif // wxUSE_IMAGE
149 #endif
150
151 virtual wxGDIRefData* CreateGDIRefData() const;
152 virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
153
154 private:
155 #ifndef __WXGTK3__
156 void SetPixmap(GdkPixmap* pixmap);
157 #if wxUSE_IMAGE
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
162
163 public:
164 // implementation only
165 enum Representation
166 {
167 Pixmap,
168 Pixbuf
169 };
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);
173 #endif
174
175 DECLARE_DYNAMIC_CLASS(wxBitmap)
176 };
177
178 #endif // _WX_GTK_BITMAP_H_