]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/bitmap.h | |
3 | // Purpose: wxBitmap class interface | |
4 | // Author: Vaclav Slavik | |
5 | // Modified by: | |
6 | // Created: 22.04.01 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
1e6feb95 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_BITMAP_H_BASE_ |
13 | #define _WX_BITMAP_H_BASE_ | |
c801d85f | 14 | |
1e6feb95 VZ |
15 | // ---------------------------------------------------------------------------- |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
12028905 | 19 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
1e6feb95 VZ |
20 | #pragma interface "bitmapbase.h" |
21 | #endif | |
22 | ||
23 | #include "wx/defs.h" | |
24 | #include "wx/object.h" | |
25 | #include "wx/string.h" | |
1e6feb95 | 26 | #include "wx/gdiobj.h" |
22bd9387 | 27 | #include "wx/gdicmn.h" // for wxBitmapType |
1e6feb95 | 28 | |
1e6feb95 VZ |
29 | class WXDLLEXPORT wxBitmap; |
30 | class WXDLLEXPORT wxBitmapHandler; | |
22bd9387 VZ |
31 | class WXDLLEXPORT wxImage; |
32 | class WXDLLEXPORT wxMask; | |
33 | class WXDLLEXPORT wxPalette; | |
1e6feb95 | 34 | |
d22004c4 WS |
35 | #if defined(__WXMGL__) || \ |
36 | defined(__WXMAC__) || \ | |
37 | defined(__WXCOCOA__) || \ | |
38 | defined(__WXMOTIF__) || \ | |
39 | defined(__WXX11__) | |
a6a193a0 | 40 | // Only used by some ports |
b496583b VS |
41 | // FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes |
42 | ||
1e6feb95 VZ |
43 | // ---------------------------------------------------------------------------- |
44 | // wxBitmapHandler: class which knows how to create/load/save bitmaps in | |
45 | // different formats | |
46 | // ---------------------------------------------------------------------------- | |
47 | ||
48 | class WXDLLEXPORT wxBitmapHandlerBase : public wxObject | |
49 | { | |
50 | public: | |
51 | wxBitmapHandlerBase() | |
7ee31b00 GD |
52 | : m_name() |
53 | , m_extension() | |
54 | , m_type(wxBITMAP_TYPE_INVALID) | |
55 | { } | |
1e6feb95 VZ |
56 | |
57 | virtual ~wxBitmapHandlerBase() { } | |
58 | ||
59 | virtual bool Create(wxBitmap *bitmap, void *data, long flags, | |
60 | int width, int height, int depth = 1) = 0; | |
61 | virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, | |
62 | int desiredWidth, int desiredHeight) = 0; | |
63 | virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, | |
64 | int type, const wxPalette *palette = NULL) = 0; | |
65 | ||
66 | void SetName(const wxString& name) { m_name = name; } | |
67 | void SetExtension(const wxString& ext) { m_extension = ext; } | |
68 | void SetType(wxBitmapType type) { m_type = type; } | |
69 | wxString GetName() const { return m_name; } | |
70 | wxString GetExtension() const { return m_extension; } | |
71 | wxBitmapType GetType() const { return m_type; } | |
72 | ||
73 | protected: | |
74 | wxString m_name; | |
75 | wxString m_extension; | |
76 | wxBitmapType m_type; | |
77 | ||
78 | DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase) | |
79 | }; | |
80 | ||
1e6feb95 VZ |
81 | class WXDLLEXPORT wxBitmapBase : public wxGDIObject |
82 | { | |
83 | public: | |
84 | wxBitmapBase() : wxGDIObject() {} | |
85 | virtual ~wxBitmapBase() {} | |
86 | ||
87 | /* | |
88 | Derived class must implement these: | |
89 | ||
90 | wxBitmap(); | |
91 | wxBitmap(int width, int height, int depth = -1); | |
92 | wxBitmap(const char bits[], int width, int height, int depth = 1); | |
93 | wxBitmap(const char **bits); | |
94 | wxBitmap(char **bits); | |
95 | wxBitmap(const wxBitmap& bmp); | |
96 | wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM); | |
97 | wxBitmap(const wxImage& image, int depth = -1); | |
98 | wxBitmap& operator = (const wxBitmap& bmp); | |
99 | bool operator == (const wxBitmap& bmp) const; | |
100 | bool operator != (const wxBitmap& bmp) const; | |
101 | ||
102 | bool Create(int width, int height, int depth = -1); | |
103 | ||
104 | static void InitStandardHandlers(); | |
105 | */ | |
106 | ||
107 | virtual bool Ok() const = 0; | |
108 | ||
109 | virtual int GetHeight() const = 0; | |
110 | virtual int GetWidth() const = 0; | |
111 | virtual int GetDepth() const = 0; | |
112 | ||
113 | virtual wxImage ConvertToImage() const = 0; | |
114 | ||
115 | virtual wxMask *GetMask() const = 0; | |
116 | virtual void SetMask(wxMask *mask) = 0; | |
117 | ||
118 | virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0; | |
119 | ||
120 | virtual bool SaveFile(const wxString &name, wxBitmapType type, | |
121 | const wxPalette *palette = (wxPalette *)NULL) const = 0; | |
122 | virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0; | |
123 | ||
f28e099e VZ |
124 | /* |
125 | If raw bitmap access is supported (see wx/rawbmp.h), the following | |
126 | methods should be implemented: | |
127 | ||
128 | virtual bool GetRawData(wxRawBitmapData *data) = 0; | |
129 | virtual void UngetRawData(wxRawBitmapData *data) = 0; | |
130 | */ | |
131 | ||
132 | #if wxUSE_PALETTE | |
1e6feb95 VZ |
133 | virtual wxPalette *GetPalette() const = 0; |
134 | virtual void SetPalette(const wxPalette& palette) = 0; | |
f28e099e | 135 | #endif // wxUSE_PALETTE |
1e6feb95 | 136 | |
1e6feb95 VZ |
137 | // copies the contents and mask of the given (colour) icon to the bitmap |
138 | virtual bool CopyFromIcon(const wxIcon& icon) = 0; | |
139 | ||
140 | // implementation: | |
141 | virtual void SetHeight(int height) = 0; | |
142 | virtual void SetWidth(int width) = 0; | |
143 | virtual void SetDepth(int depth) = 0; | |
144 | ||
145 | // Format handling | |
146 | static inline wxList& GetHandlers() { return sm_handlers; } | |
147 | static void AddHandler(wxBitmapHandlerBase *handler); | |
148 | static void InsertHandler(wxBitmapHandlerBase *handler); | |
149 | static bool RemoveHandler(const wxString& name); | |
150 | static wxBitmapHandler *FindHandler(const wxString& name); | |
151 | static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType); | |
152 | static wxBitmapHandler *FindHandler(wxBitmapType bitmapType); | |
153 | ||
154 | //static void InitStandardHandlers(); | |
155 | // (wxBitmap must implement this one) | |
156 | ||
157 | static void CleanUpHandlers(); | |
158 | ||
159 | protected: | |
160 | static wxList sm_handlers; | |
161 | ||
162 | DECLARE_ABSTRACT_CLASS(wxBitmapBase) | |
163 | }; | |
a6a193a0 | 164 | #endif |
1e6feb95 | 165 | |
4055ed82 | 166 | #if defined(__WXPALMOS__) |
ffecfa5a JS |
167 | #include "wx/palmos/bitmap.h" |
168 | #elif defined(__WXMSW__) | |
c801d85f | 169 | #include "wx/msw/bitmap.h" |
2049ba38 | 170 | #elif defined(__WXMOTIF__) |
aae0472b | 171 | #include "wx/x11/bitmap.h" |
2049ba38 | 172 | #elif defined(__WXGTK__) |
c801d85f | 173 | #include "wx/gtk/bitmap.h" |
83df96d6 JS |
174 | #elif defined(__WXX11__) |
175 | #include "wx/x11/bitmap.h" | |
1e6feb95 VZ |
176 | #elif defined(__WXMGL__) |
177 | #include "wx/mgl/bitmap.h" | |
34138703 JS |
178 | #elif defined(__WXMAC__) |
179 | #include "wx/mac/bitmap.h" | |
fed66a87 DE |
180 | #elif defined(__WXCOCOA__) |
181 | #include "wx/cocoa/bitmap.h" | |
1777b9bb DW |
182 | #elif defined(__WXPM__) |
183 | #include "wx/os2/bitmap.h" | |
c801d85f KB |
184 | #endif |
185 | ||
186 | #endif | |
34138703 | 187 | // _WX_BITMAP_H_BASE_ |