]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/bitmap.h
No real changes, just make wxWindow::CanScroll() virtual.
[wxWidgets.git] / include / wx / gtk / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/bitmap.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 #ifndef _WX_GTK_BITMAP_H_
10 #define _WX_GTK_BITMAP_H_
11
12 #ifdef __WXGTK3__
13 typedef struct _cairo cairo_t;
14 typedef struct _cairo_surface cairo_surface_t;
15 #endif
16 typedef struct _GdkPixbuf GdkPixbuf;
17 class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
18
19 //-----------------------------------------------------------------------------
20 // wxMask
21 //-----------------------------------------------------------------------------
22
23 class WXDLLIMPEXP_CORE wxMask: public wxMaskBase
24 {
25 public:
26 wxMask();
27 wxMask(const wxMask& mask);
28 wxMask( const wxBitmap& bitmap, const wxColour& colour );
29 #if wxUSE_PALETTE
30 wxMask( const wxBitmap& bitmap, int paletteIndex );
31 #endif // wxUSE_PALETTE
32 wxMask( const wxBitmap& bitmap );
33 virtual ~wxMask();
34 wxBitmap GetBitmap() const;
35
36 // implementation
37 #ifdef __WXGTK3__
38 wxMask(cairo_surface_t*);
39 operator cairo_surface_t*() const;
40 #else
41 wxMask(GdkPixmap*);
42 operator GdkPixmap*() 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, int depth = 0);
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 bool Create(int width, int height, const wxDC& WXUNUSED(dc))
90 { return Create(width,height); }
91
92
93 virtual int GetHeight() const;
94 virtual int GetWidth() const;
95 virtual int GetDepth() const;
96
97 #if wxUSE_IMAGE
98 wxImage ConvertToImage() const;
99 #endif // wxUSE_IMAGE
100
101 // copies the contents and mask of the given (colour) icon to the bitmap
102 virtual bool CopyFromIcon(const wxIcon& icon);
103
104 wxMask *GetMask() const;
105 void SetMask( wxMask *mask );
106 wxBitmap GetMaskBitmap() const;
107
108 wxBitmap GetSubBitmap( const wxRect& rect ) const;
109
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);
113
114 #if wxUSE_PALETTE
115 wxPalette *GetPalette() const;
116 void SetPalette(const wxPalette& palette);
117 wxPalette *GetColourMap() const { return GetPalette(); }
118 #endif // wxUSE_PALETTE
119
120 static void InitStandardHandlers();
121
122 // implementation
123 // --------------
124
125 void SetHeight( int height );
126 void SetWidth( int width );
127 void SetDepth( int depth );
128
129 #ifdef __WXGTK3__
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;
134 #else
135 GdkPixmap *GetPixmap() const;
136 bool HasPixmap() const;
137 bool HasPixbuf() const;
138 wxBitmap(GdkPixmap* pixmap);
139 #endif
140 GdkPixbuf *GetPixbuf() const;
141
142 // raw bitmap access support functions
143 void *GetRawData(wxPixelDataBase& data, int bpp);
144 void UngetRawData(wxPixelDataBase& data);
145
146 bool HasAlpha() const;
147
148 protected:
149 #ifndef __WXGTK3__
150 #if wxUSE_IMAGE
151 bool CreateFromImage(const wxImage& image, int depth);
152 #endif // wxUSE_IMAGE
153 #endif
154
155 virtual wxGDIRefData* CreateGDIRefData() const;
156 virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
157
158 private:
159 #ifndef __WXGTK3__
160 void SetPixmap(GdkPixmap* pixmap);
161 #if wxUSE_IMAGE
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
166
167 public:
168 // implementation only
169 enum Representation
170 {
171 Pixmap,
172 Pixbuf
173 };
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);
177 #endif
178
179 DECLARE_DYNAMIC_CLASS(wxBitmap)
180 };
181
182 #endif // _WX_GTK_BITMAP_H_