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