]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
0b04c4e0 | 2 | // Name: wx/gtk/bitmap.h |
c801d85f KB |
3 | // Purpose: |
4 | // Author: Robert Roebling | |
6f65e337 | 5 | // RCS-ID: $Id$ |
01111366 | 6 | // Copyright: (c) 1998 Robert Roebling |
65571936 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
0416c418 PC |
10 | #ifndef _WX_GTK_BITMAP_H_ |
11 | #define _WX_GTK_BITMAP_H_ | |
c801d85f | 12 | |
9dc44eff PC |
13 | #ifdef __WXGTK3__ |
14 | typedef struct _cairo cairo_t; | |
15 | typedef struct _cairo_surface cairo_surface_t; | |
16 | #endif | |
feac7937 | 17 | typedef struct _GdkPixbuf GdkPixbuf; |
b5dbe15d | 18 | class WXDLLIMPEXP_FWD_CORE wxPixelDataBase; |
f383c5b8 | 19 | |
c801d85f KB |
20 | //----------------------------------------------------------------------------- |
21 | // wxMask | |
22 | //----------------------------------------------------------------------------- | |
23 | ||
60a3d1c6 | 24 | class WXDLLIMPEXP_CORE wxMask: public wxMaskBase |
c801d85f | 25 | { |
fd0eed64 | 26 | public: |
8636aed8 | 27 | wxMask(); |
27297c82 | 28 | wxMask(const wxMask& mask); |
8636aed8 | 29 | wxMask( const wxBitmap& bitmap, const wxColour& colour ); |
0b04c4e0 | 30 | #if wxUSE_PALETTE |
8636aed8 | 31 | wxMask( const wxBitmap& bitmap, int paletteIndex ); |
0b04c4e0 | 32 | #endif // wxUSE_PALETTE |
8636aed8 | 33 | wxMask( const wxBitmap& bitmap ); |
d3c7fc99 | 34 | virtual ~wxMask(); |
5ca21fe7 | 35 | wxBitmap GetBitmap() const; |
0b04c4e0 | 36 | |
8636aed8 | 37 | // implementation |
9dc44eff PC |
38 | #ifdef __WXGTK3__ |
39 | wxMask(cairo_surface_t*); | |
5ca21fe7 | 40 | operator cairo_surface_t*() const; |
9dc44eff | 41 | #else |
2d13e22f | 42 | wxMask(GdkPixmap*); |
5ca21fe7 | 43 | operator GdkPixmap*() const; |
9dc44eff | 44 | #endif |
0b04c4e0 | 45 | |
60a3d1c6 PC |
46 | protected: |
47 | virtual void FreeData(); | |
48 | virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour); | |
49 | virtual bool InitFromMonoBitmap(const wxBitmap& bitmap); | |
50 | ||
2d13e22f | 51 | private: |
9dc44eff PC |
52 | #ifdef __WXGTK3__ |
53 | cairo_surface_t* m_bitmap; | |
54 | #else | |
2d13e22f | 55 | GdkPixmap* m_bitmap; |
9dc44eff | 56 | #endif |
2d13e22f | 57 | |
8636aed8 | 58 | DECLARE_DYNAMIC_CLASS(wxMask) |
c801d85f KB |
59 | }; |
60 | ||
61 | //----------------------------------------------------------------------------- | |
62 | // wxBitmap | |
63 | //----------------------------------------------------------------------------- | |
64 | ||
20123d49 | 65 | class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase |
c801d85f | 66 | { |
fd0eed64 | 67 | public: |
23656673 | 68 | wxBitmap() { } |
03647350 | 69 | wxBitmap( int width, int height, int depth = wxBITMAP_SCREEN_DEPTH ) |
732d8c74 | 70 | { Create(width, height, depth); } |
03647350 | 71 | wxBitmap( const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH ) |
732d8c74 | 72 | { Create(sz, depth); } |
8636aed8 | 73 | wxBitmap( const char bits[], int width, int height, int depth = 1 ); |
452418c4 | 74 | wxBitmap( const char* const* bits ); |
459f812b | 75 | #ifdef wxNEEDS_CHARPP |
4a4bf7ee SN |
76 | // needed for old GCC |
77 | wxBitmap(char** data) | |
732d8c74 | 78 | { *this = wxBitmap(const_cast<const char* const*>(data)); } |
4a4bf7ee | 79 | #endif |
cbea3ec6 | 80 | wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE ); |
c0521644 | 81 | #if wxUSE_IMAGE |
9dc44eff | 82 | wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH); |
c0521644 | 83 | #endif // wxUSE_IMAGE |
5ca21fe7 | 84 | wxBitmap(GdkPixbuf* pixbuf, int depth = 0); |
d3c7fc99 | 85 | virtual ~wxBitmap(); |
8636aed8 | 86 | |
e86f2cc8 | 87 | bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); |
732d8c74 FM |
88 | bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) |
89 | { return Create(sz.GetWidth(), sz.GetHeight(), depth); } | |
0b04c4e0 | 90 | |
8f884a0d VZ |
91 | virtual int GetHeight() const; |
92 | virtual int GetWidth() const; | |
93 | virtual int GetDepth() const; | |
0b04c4e0 | 94 | |
c0521644 | 95 | #if wxUSE_IMAGE |
fd859211 | 96 | wxImage ConvertToImage() const; |
c0521644 | 97 | #endif // wxUSE_IMAGE |
8636aed8 | 98 | |
db0aec83 VS |
99 | // copies the contents and mask of the given (colour) icon to the bitmap |
100 | virtual bool CopyFromIcon(const wxIcon& icon); | |
101 | ||
8636aed8 RR |
102 | wxMask *GetMask() const; |
103 | void SetMask( wxMask *mask ); | |
9dc44eff | 104 | wxBitmap GetMaskBitmap() const; |
0b04c4e0 | 105 | |
17bec151 | 106 | wxBitmap GetSubBitmap( const wxRect& rect ) const; |
8636aed8 | 107 | |
4611dd06 | 108 | bool SaveFile(const wxString &name, wxBitmapType type, |
d3b9f782 | 109 | const wxPalette *palette = NULL) const; |
cbea3ec6 | 110 | bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); |
8636aed8 | 111 | |
4611dd06 | 112 | #if wxUSE_PALETTE |
8636aed8 | 113 | wxPalette *GetPalette() const; |
4611dd06 | 114 | void SetPalette(const wxPalette& palette); |
6dd0883d | 115 | wxPalette *GetColourMap() const { return GetPalette(); } |
4611dd06 | 116 | #endif // wxUSE_PALETTE |
55e90a2e | 117 | |
4b61c88d | 118 | static void InitStandardHandlers(); |
8bbe427f | 119 | |
8636aed8 | 120 | // implementation |
20e05ffb | 121 | // -------------- |
c801d85f | 122 | |
8636aed8 RR |
123 | void SetHeight( int height ); |
124 | void SetWidth( int width ); | |
125 | void SetDepth( int depth ); | |
8bbe427f | 126 | |
9dc44eff PC |
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 | |
8636aed8 | 133 | GdkPixmap *GetPixmap() const; |
feac7937 | 134 | bool HasPixmap() const; |
feac7937 | 135 | bool HasPixbuf() const; |
5ca21fe7 | 136 | wxBitmap(GdkPixmap* pixmap); |
9dc44eff | 137 | #endif |
feac7937 | 138 | GdkPixbuf *GetPixbuf() const; |
0b04c4e0 | 139 | |
284f2b59 RR |
140 | // raw bitmap access support functions |
141 | void *GetRawData(wxPixelDataBase& data, int bpp); | |
142 | void UngetRawData(wxPixelDataBase& data); | |
143 | ||
0ff2a74d | 144 | bool HasAlpha() const; |
d2400c3f | 145 | |
e838cc14 | 146 | protected: |
9dc44eff | 147 | #ifndef __WXGTK3__ |
c0521644 | 148 | #if wxUSE_IMAGE |
fd859211 | 149 | bool CreateFromImage(const wxImage& image, int depth); |
c0521644 | 150 | #endif // wxUSE_IMAGE |
9dc44eff | 151 | #endif |
e838cc14 | 152 | |
8f884a0d VZ |
153 | virtual wxGDIRefData* CreateGDIRefData() const; |
154 | virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const; | |
4c44e0d0 | 155 | |
8636aed8 | 156 | private: |
9dc44eff | 157 | #ifndef __WXGTK3__ |
06497cba | 158 | void SetPixmap(GdkPixmap* pixmap); |
c0521644 | 159 | #if wxUSE_IMAGE |
feac7937 | 160 | // to be called from CreateFromImage only! |
5ac1d44a | 161 | bool CreateFromImageAsPixmap(const wxImage& image, int depth); |
feac7937 | 162 | bool CreateFromImageAsPixbuf(const wxImage& image); |
c0521644 | 163 | #endif // wxUSE_IMAGE |
feac7937 | 164 | |
ab171e95 RR |
165 | public: |
166 | // implementation only | |
feac7937 VS |
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); | |
9dc44eff | 175 | #endif |
feac7937 | 176 | |
8636aed8 | 177 | DECLARE_DYNAMIC_CLASS(wxBitmap) |
c801d85f KB |
178 | }; |
179 | ||
0416c418 | 180 | #endif // _WX_GTK_BITMAP_H_ |