]> git.saurik.com Git - wxWidgets.git/blob - include/wx/bitmap.h
no real changes, just replaced a long preprocessor expression occuring in 2 places...
[wxWidgets.git] / include / wx / bitmap.h
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$
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_BITMAP_H_BASE_
13 #define _WX_BITMAP_H_BASE_
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/defs.h"
20 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/gdiobj.h"
23 #include "wx/gdicmn.h" // for wxBitmapType
24
25 class WXDLLEXPORT wxBitmap;
26 class WXDLLEXPORT wxBitmapHandler;
27 class WXDLLEXPORT wxImage;
28 class WXDLLEXPORT wxMask;
29 class WXDLLEXPORT wxPalette;
30
31 #if defined(__WXMGL__) || \
32 defined(__WXDFB__) || \
33 defined(__WXMAC__) || \
34 defined(__WXGTK__) || \
35 defined(__WXCOCOA__) || \
36 defined(__WXMOTIF__) || \
37 defined(__WXX11__)
38 #define wxUSE_BITMAP_BASE 1
39 #else
40 #define wxUSE_BITMAP_BASE 0
41 #endif
42
43 // Only used by some ports
44 // FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
45 #if wxUSE_BITMAP_BASE
46
47 // ----------------------------------------------------------------------------
48 // wxBitmapHandler: class which knows how to create/load/save bitmaps in
49 // different formats
50 // ----------------------------------------------------------------------------
51
52 class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
53 {
54 public:
55 wxBitmapHandlerBase()
56 : m_name()
57 , m_extension()
58 , m_type(wxBITMAP_TYPE_INVALID)
59 { }
60
61 virtual ~wxBitmapHandlerBase() { }
62
63 virtual bool Create(wxBitmap *bitmap, void *data, long flags,
64 int width, int height, int depth = 1) = 0;
65 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
66 int desiredWidth, int desiredHeight) = 0;
67 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name,
68 int type, const wxPalette *palette = NULL) = 0;
69
70 void SetName(const wxString& name) { m_name = name; }
71 void SetExtension(const wxString& ext) { m_extension = ext; }
72 void SetType(wxBitmapType type) { m_type = type; }
73 wxString GetName() const { return m_name; }
74 wxString GetExtension() const { return m_extension; }
75 wxBitmapType GetType() const { return m_type; }
76
77 private:
78 wxString m_name;
79 wxString m_extension;
80 wxBitmapType m_type;
81
82 private:
83 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
84 };
85
86 class WXDLLEXPORT wxBitmapBase : public wxGDIObject
87 {
88 public:
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 wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
98 wxBitmap(const wxImage& image, int depth = -1);
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
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
133 virtual wxPalette *GetPalette() const = 0;
134 virtual void SetPalette(const wxPalette& palette) = 0;
135 #endif // wxUSE_PALETTE
136
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 };
164
165 #endif // wxUSE_BITMAP_BASE
166
167 #if defined(__WXPALMOS__)
168 #include "wx/palmos/bitmap.h"
169 #elif defined(__WXMSW__)
170 #include "wx/msw/bitmap.h"
171 #elif defined(__WXMOTIF__)
172 #include "wx/x11/bitmap.h"
173 #elif defined(__WXGTK20__)
174 #include "wx/gtk/bitmap.h"
175 #elif defined(__WXGTK__)
176 #include "wx/gtk1/bitmap.h"
177 #elif defined(__WXX11__)
178 #include "wx/x11/bitmap.h"
179 #elif defined(__WXMGL__)
180 #include "wx/mgl/bitmap.h"
181 #elif defined(__WXDFB__)
182 #include "wx/dfb/bitmap.h"
183 #elif defined(__WXMAC__)
184 #include "wx/mac/bitmap.h"
185 #elif defined(__WXCOCOA__)
186 #include "wx/cocoa/bitmap.h"
187 #elif defined(__WXPM__)
188 #include "wx/os2/bitmap.h"
189 #endif
190
191 #endif // _WX_BITMAP_H_BASE_