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