]>
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 | ||
10 | ||
11 | #ifndef __GTKBITMAPH__ | |
12 | #define __GTKBITMAPH__ | |
13 | ||
c801d85f KB |
14 | #include "wx/defs.h" |
15 | #include "wx/object.h" | |
16 | #include "wx/string.h" | |
17 | #include "wx/palette.h" | |
58c837a4 | 18 | #include "wx/gdiobj.h" |
c801d85f | 19 | |
feac7937 | 20 | typedef struct _GdkPixbuf GdkPixbuf; |
feac7937 | 21 | |
f383c5b8 VZ |
22 | class WXDLLEXPORT wxPixelDataBase; |
23 | ||
c801d85f KB |
24 | //----------------------------------------------------------------------------- |
25 | // classes | |
26 | //----------------------------------------------------------------------------- | |
27 | ||
20123d49 MW |
28 | class WXDLLIMPEXP_CORE wxMask; |
29 | class WXDLLIMPEXP_CORE wxBitmap; | |
30 | class WXDLLIMPEXP_CORE wxImage; | |
c801d85f KB |
31 | |
32 | //----------------------------------------------------------------------------- | |
33 | // wxMask | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
20123d49 | 36 | class WXDLLIMPEXP_CORE wxMask: public wxObject |
c801d85f | 37 | { |
fd0eed64 | 38 | public: |
8636aed8 RR |
39 | wxMask(); |
40 | wxMask( const wxBitmap& bitmap, const wxColour& colour ); | |
0b04c4e0 | 41 | #if wxUSE_PALETTE |
8636aed8 | 42 | wxMask( const wxBitmap& bitmap, int paletteIndex ); |
0b04c4e0 | 43 | #endif // wxUSE_PALETTE |
8636aed8 RR |
44 | wxMask( const wxBitmap& bitmap ); |
45 | ~wxMask(); | |
0b04c4e0 | 46 | |
8636aed8 | 47 | bool Create( const wxBitmap& bitmap, const wxColour& colour ); |
0b04c4e0 | 48 | #if wxUSE_PALETTE |
8636aed8 | 49 | bool Create( const wxBitmap& bitmap, int paletteIndex ); |
0b04c4e0 | 50 | #endif // wxUSE_PALETTE |
8636aed8 RR |
51 | bool Create( const wxBitmap& bitmap ); |
52 | ||
53 | // implementation | |
54 | GdkBitmap *m_bitmap; | |
0b04c4e0 | 55 | |
8636aed8 | 56 | GdkBitmap *GetBitmap() const; |
0b04c4e0 | 57 | |
8636aed8 RR |
58 | private: |
59 | DECLARE_DYNAMIC_CLASS(wxMask) | |
c801d85f KB |
60 | }; |
61 | ||
62 | //----------------------------------------------------------------------------- | |
63 | // wxBitmap | |
64 | //----------------------------------------------------------------------------- | |
65 | ||
20123d49 | 66 | class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase |
c801d85f | 67 | { |
fd0eed64 | 68 | public: |
8636aed8 RR |
69 | wxBitmap(); |
70 | wxBitmap( int width, int height, int depth = -1 ); | |
71 | wxBitmap( const char bits[], int width, int height, int depth = 1 ); | |
e838cc14 VZ |
72 | wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); } |
73 | wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); } | |
4611dd06 | 74 | wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM ); |
fd859211 | 75 | wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } |
8636aed8 | 76 | ~wxBitmap(); |
f6bcfd97 BP |
77 | bool operator == ( const wxBitmap& bmp ) const; |
78 | bool operator != ( const wxBitmap& bmp ) const; | |
8636aed8 RR |
79 | bool Ok() const; |
80 | ||
c826213d | 81 | bool Create(int width, int height, int depth = -1); |
0b04c4e0 | 82 | |
8636aed8 RR |
83 | int GetHeight() const; |
84 | int GetWidth() const; | |
85 | int GetDepth() const; | |
0b04c4e0 | 86 | |
fd859211 | 87 | wxImage ConvertToImage() const; |
8636aed8 | 88 | |
db0aec83 VS |
89 | // copies the contents and mask of the given (colour) icon to the bitmap |
90 | virtual bool CopyFromIcon(const wxIcon& icon); | |
91 | ||
8636aed8 RR |
92 | wxMask *GetMask() const; |
93 | void SetMask( wxMask *mask ); | |
0b04c4e0 | 94 | |
17bec151 | 95 | wxBitmap GetSubBitmap( const wxRect& rect ) const; |
8636aed8 | 96 | |
4611dd06 RR |
97 | bool SaveFile(const wxString &name, wxBitmapType type, |
98 | const wxPalette *palette = (wxPalette *)NULL) const; | |
99 | bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM ); | |
8636aed8 | 100 | |
4611dd06 | 101 | #if wxUSE_PALETTE |
8636aed8 | 102 | wxPalette *GetPalette() const; |
4611dd06 | 103 | void SetPalette(const wxPalette& palette); |
55e90a2e | 104 | wxPalette *GetColourMap() const { return GetPalette(); }; |
4611dd06 | 105 | #endif // wxUSE_PALETTE |
55e90a2e | 106 | |
4b61c88d | 107 | static void InitStandardHandlers(); |
8bbe427f | 108 | |
8636aed8 | 109 | // implementation |
20e05ffb | 110 | // -------------- |
c801d85f | 111 | |
8636aed8 RR |
112 | void SetHeight( int height ); |
113 | void SetWidth( int width ); | |
114 | void SetDepth( int depth ); | |
115 | void SetPixmap( GdkPixmap *pixmap ); | |
feac7937 | 116 | void SetPixbuf(GdkPixbuf *pixbuf); |
8bbe427f | 117 | |
8636aed8 | 118 | GdkPixmap *GetPixmap() const; |
feac7937 | 119 | bool HasPixmap() const; |
feac7937 VS |
120 | bool HasPixbuf() const; |
121 | GdkPixbuf *GetPixbuf() const; | |
0b04c4e0 | 122 | |
783da845 RR |
123 | // Basically, this corresponds to Win32 StretchBlt() |
124 | wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height ); | |
0b04c4e0 | 125 | |
284f2b59 RR |
126 | // raw bitmap access support functions |
127 | void *GetRawData(wxPixelDataBase& data, int bpp); | |
128 | void UngetRawData(wxPixelDataBase& data); | |
129 | ||
0ff2a74d RR |
130 | bool HasAlpha() const; |
131 | void UseAlpha(); | |
d2400c3f | 132 | |
e838cc14 VZ |
133 | protected: |
134 | bool CreateFromXpm(const char **bits); | |
fd859211 | 135 | bool CreateFromImage(const wxImage& image, int depth); |
e838cc14 | 136 | |
8636aed8 | 137 | private: |
feac7937 | 138 | // to be called from CreateFromImage only! |
5ac1d44a | 139 | bool CreateFromImageAsPixmap(const wxImage& image, int depth); |
feac7937 VS |
140 | bool CreateFromImageAsPixbuf(const wxImage& image); |
141 | ||
142 | enum Representation | |
143 | { | |
144 | Pixmap, | |
145 | Pixbuf | |
146 | }; | |
147 | // removes other representations from memory, keeping only 'keep' | |
148 | // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf): | |
149 | void PurgeOtherRepresentations(Representation keep); | |
150 | ||
151 | friend class wxMemoryDC; | |
4b61c88d RR |
152 | friend class wxBitmapHandler; |
153 | ||
0b04c4e0 | 154 | private: |
8636aed8 | 155 | DECLARE_DYNAMIC_CLASS(wxBitmap) |
c801d85f KB |
156 | }; |
157 | ||
4b61c88d RR |
158 | //----------------------------------------------------------------------------- |
159 | // wxBitmapHandler | |
160 | //----------------------------------------------------------------------------- | |
161 | ||
20123d49 | 162 | class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase |
4b61c88d RR |
163 | { |
164 | public: | |
165 | wxBitmapHandler() { } | |
166 | virtual ~wxBitmapHandler(); | |
167 | ||
168 | virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); | |
169 | virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, | |
170 | int desiredWidth, int desiredHeight); | |
171 | virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); | |
172 | ||
173 | private: | |
174 | DECLARE_DYNAMIC_CLASS(wxBitmapHandler) | |
175 | }; | |
176 | ||
177 | ||
c801d85f | 178 | #endif // __GTKBITMAPH__ |