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