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