]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/bitmap.h
Applied rowspan patch #15276 (dghart)
[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 wxBitmap GetBitmap() const;
36
37 // implementation
38 #ifdef __WXGTK3__
39 wxMask(cairo_surface_t*);
40 operator cairo_surface_t*() const;
41 #else
42 wxMask(GdkPixmap*);
43 operator GdkPixmap*() const;
44 #endif
45
46 protected:
47 virtual void FreeData();
48 virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour);
49 virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
50
51 private:
52 #ifdef __WXGTK3__
53 cairo_surface_t* m_bitmap;
54 #else
55 GdkPixmap* m_bitmap;
56 #endif
57
58 DECLARE_DYNAMIC_CLASS(wxMask)
59 };
60
61 //-----------------------------------------------------------------------------
62 // wxBitmap
63 //-----------------------------------------------------------------------------
64
65 class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
66 {
67 public:
68 wxBitmap() { }
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 );
75 #ifdef wxNEEDS_CHARPP
76 // needed for old GCC
77 wxBitmap(char** data)
78 { *this = wxBitmap(const_cast<const char* const*>(data)); }
79 #endif
80 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
81 #if wxUSE_IMAGE
82 wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH);
83 #endif // wxUSE_IMAGE
84 wxBitmap(GdkPixbuf* pixbuf, int depth = 0);
85 virtual ~wxBitmap();
86
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
91 virtual int GetHeight() const;
92 virtual int GetWidth() const;
93 virtual int GetDepth() const;
94
95 #if wxUSE_IMAGE
96 wxImage ConvertToImage() const;
97 #endif // wxUSE_IMAGE
98
99 // copies the contents and mask of the given (colour) icon to the bitmap
100 virtual bool CopyFromIcon(const wxIcon& icon);
101
102 wxMask *GetMask() const;
103 void SetMask( wxMask *mask );
104 wxBitmap GetMaskBitmap() const;
105
106 wxBitmap GetSubBitmap( const wxRect& rect ) const;
107
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);
111
112 #if wxUSE_PALETTE
113 wxPalette *GetPalette() const;
114 void SetPalette(const wxPalette& palette);
115 wxPalette *GetColourMap() const { return GetPalette(); }
116 #endif // wxUSE_PALETTE
117
118 static void InitStandardHandlers();
119
120 // implementation
121 // --------------
122
123 void SetHeight( int height );
124 void SetWidth( int width );
125 void SetDepth( int depth );
126
127 #ifdef __WXGTK3__
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;
132 #else
133 GdkPixmap *GetPixmap() const;
134 bool HasPixmap() const;
135 bool HasPixbuf() const;
136 wxBitmap(GdkPixmap* pixmap);
137 #endif
138 GdkPixbuf *GetPixbuf() const;
139
140 // raw bitmap access support functions
141 void *GetRawData(wxPixelDataBase& data, int bpp);
142 void UngetRawData(wxPixelDataBase& data);
143
144 bool HasAlpha() const;
145
146 protected:
147 #ifndef __WXGTK3__
148 #if wxUSE_IMAGE
149 bool CreateFromImage(const wxImage& image, int depth);
150 #endif // wxUSE_IMAGE
151 #endif
152
153 virtual wxGDIRefData* CreateGDIRefData() const;
154 virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
155
156 private:
157 #ifndef __WXGTK3__
158 void SetPixmap(GdkPixmap* pixmap);
159 #if wxUSE_IMAGE
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
164
165 public:
166 // implementation only
167 enum Representation
168 {
169 Pixmap,
170 Pixbuf
171 };
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);
175 #endif
176
177 DECLARE_DYNAMIC_CLASS(wxBitmap)
178 };
179
180 #endif // _WX_GTK_BITMAP_H_