1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBitmap class interface
4 // Author: Vaclav Slavik
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_BITMAP_H_BASE_
13 #define _WX_BITMAP_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/gdiobj.h"
23 #include "wx/gdicmn.h" // for wxBitmapType
25 class WXDLLEXPORT wxBitmap
;
26 class WXDLLEXPORT wxBitmapHandler
;
27 class WXDLLEXPORT wxImage
;
28 class WXDLLEXPORT wxMask
;
29 class WXDLLEXPORT wxPalette
;
31 #if defined(__WXMGL__) || \
32 defined(__WXDFB__) || \
33 defined(__WXMAC__) || \
34 defined(__WXGTK__) || \
35 defined(__WXCOCOA__) || \
36 defined(__WXMOTIF__) || \
38 // Only used by some ports
39 // FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
41 // ----------------------------------------------------------------------------
42 // wxBitmapHandler: class which knows how to create/load/save bitmaps in
44 // ----------------------------------------------------------------------------
46 class WXDLLEXPORT wxBitmapHandlerBase
: public wxObject
52 , m_type(wxBITMAP_TYPE_INVALID
)
55 virtual ~wxBitmapHandlerBase() { }
57 virtual bool Create(wxBitmap
*bitmap
, void *data
, long flags
,
58 int width
, int height
, int depth
= 1) = 0;
59 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
60 int desiredWidth
, int desiredHeight
) = 0;
61 virtual bool SaveFile(const wxBitmap
*bitmap
, const wxString
& name
,
62 int type
, const wxPalette
*palette
= NULL
) = 0;
64 void SetName(const wxString
& name
) { m_name
= name
; }
65 void SetExtension(const wxString
& ext
) { m_extension
= ext
; }
66 void SetType(wxBitmapType type
) { m_type
= type
; }
67 wxString
GetName() const { return m_name
; }
68 wxString
GetExtension() const { return m_extension
; }
69 wxBitmapType
GetType() const { return m_type
; }
77 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase
)
80 class WXDLLEXPORT wxBitmapBase
: public wxGDIObject
84 Derived class must implement these:
87 wxBitmap(int width, int height, int depth = -1);
88 wxBitmap(const char bits[], int width, int height, int depth = 1);
89 wxBitmap(const char **bits);
90 wxBitmap(char **bits);
91 wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
92 wxBitmap(const wxImage& image, int depth = -1);
93 bool operator == (const wxBitmap& bmp) const;
94 bool operator != (const wxBitmap& bmp) const;
96 bool Create(int width, int height, int depth = -1);
98 static void InitStandardHandlers();
101 virtual bool Ok() const = 0;
103 virtual int GetHeight() const = 0;
104 virtual int GetWidth() const = 0;
105 virtual int GetDepth() const = 0;
107 virtual wxImage
ConvertToImage() const = 0;
109 virtual wxMask
*GetMask() const = 0;
110 virtual void SetMask(wxMask
*mask
) = 0;
112 virtual wxBitmap
GetSubBitmap(const wxRect
& rect
) const = 0;
114 virtual bool SaveFile(const wxString
&name
, wxBitmapType type
,
115 const wxPalette
*palette
= (wxPalette
*)NULL
) const = 0;
116 virtual bool LoadFile(const wxString
&name
, wxBitmapType type
) = 0;
119 If raw bitmap access is supported (see wx/rawbmp.h), the following
120 methods should be implemented:
122 virtual bool GetRawData(wxRawBitmapData *data) = 0;
123 virtual void UngetRawData(wxRawBitmapData *data) = 0;
127 virtual wxPalette
*GetPalette() const = 0;
128 virtual void SetPalette(const wxPalette
& palette
) = 0;
129 #endif // wxUSE_PALETTE
131 // copies the contents and mask of the given (colour) icon to the bitmap
132 virtual bool CopyFromIcon(const wxIcon
& icon
) = 0;
135 virtual void SetHeight(int height
) = 0;
136 virtual void SetWidth(int width
) = 0;
137 virtual void SetDepth(int depth
) = 0;
140 static inline wxList
& GetHandlers() { return sm_handlers
; }
141 static void AddHandler(wxBitmapHandlerBase
*handler
);
142 static void InsertHandler(wxBitmapHandlerBase
*handler
);
143 static bool RemoveHandler(const wxString
& name
);
144 static wxBitmapHandler
*FindHandler(const wxString
& name
);
145 static wxBitmapHandler
*FindHandler(const wxString
& extension
, wxBitmapType bitmapType
);
146 static wxBitmapHandler
*FindHandler(wxBitmapType bitmapType
);
148 //static void InitStandardHandlers();
149 // (wxBitmap must implement this one)
151 static void CleanUpHandlers();
154 static wxList sm_handlers
;
156 DECLARE_ABSTRACT_CLASS(wxBitmapBase
)
160 #if defined(__WXPALMOS__)
161 #include "wx/palmos/bitmap.h"
162 #elif defined(__WXMSW__)
163 #include "wx/msw/bitmap.h"
164 #elif defined(__WXMOTIF__)
165 #include "wx/x11/bitmap.h"
166 #elif defined(__WXGTK20__)
167 #include "wx/gtk/bitmap.h"
168 #elif defined(__WXGTK__)
169 #include "wx/gtk1/bitmap.h"
170 #elif defined(__WXX11__)
171 #include "wx/x11/bitmap.h"
172 #elif defined(__WXMGL__)
173 #include "wx/mgl/bitmap.h"
174 #elif defined(__WXDFB__)
175 #include "wx/dfb/bitmap.h"
176 #elif defined(__WXMAC__)
177 #include "wx/mac/bitmap.h"
178 #elif defined(__WXCOCOA__)
179 #include "wx/cocoa/bitmap.h"
180 #elif defined(__WXPM__)
181 #include "wx/os2/bitmap.h"
185 // _WX_BITMAP_H_BASE_