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