1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBitmap class interface
4 // Author: Vaclav Slavik
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_BITMAP_H_BASE_
13 #define _WX_BITMAP_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #pragma interface "bitmapbase.h"
24 #include "wx/object.h"
25 #include "wx/string.h"
26 #include "wx/gdiobj.h"
27 #include "wx/gdicmn.h" // for wxBitmapType
29 class WXDLLEXPORT wxBitmap
;
30 class WXDLLEXPORT wxBitmapHandler
;
31 class WXDLLEXPORT wxImage
;
32 class WXDLLEXPORT wxMask
;
33 class WXDLLEXPORT wxPalette
;
35 #if !defined(__WXMSW__)
37 // Only used by some ports
38 // ----------------------------------------------------------------------------
39 // wxBitmapHandler: class which knows how to create/load/save bitmaps in
41 // ----------------------------------------------------------------------------
43 class WXDLLEXPORT wxBitmapHandlerBase
: public wxObject
48 m_type
= wxBITMAP_TYPE_INVALID
;
51 virtual ~wxBitmapHandlerBase() { }
53 virtual bool Create(wxBitmap
*bitmap
, void *data
, long flags
,
54 int width
, int height
, int depth
= 1) = 0;
55 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
56 int desiredWidth
, int desiredHeight
) = 0;
57 virtual bool SaveFile(const wxBitmap
*bitmap
, const wxString
& name
,
58 int type
, const wxPalette
*palette
= NULL
) = 0;
60 void SetName(const wxString
& name
) { m_name
= name
; }
61 void SetExtension(const wxString
& ext
) { m_extension
= ext
; }
62 void SetType(wxBitmapType type
) { m_type
= type
; }
63 wxString
GetName() const { return m_name
; }
64 wxString
GetExtension() const { return m_extension
; }
65 wxBitmapType
GetType() const { return m_type
; }
72 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase
)
75 class WXDLLEXPORT wxBitmapBase
: public wxGDIObject
78 wxBitmapBase() : wxGDIObject() {}
79 virtual ~wxBitmapBase() {}
82 Derived class must implement these:
85 wxBitmap(int width, int height, int depth = -1);
86 wxBitmap(const char bits[], int width, int height, int depth = 1);
87 wxBitmap(const char **bits);
88 wxBitmap(char **bits);
89 wxBitmap(const wxBitmap& bmp);
90 wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
91 wxBitmap(const wxImage& image, int depth = -1);
92 wxBitmap& operator = (const wxBitmap& bmp);
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;
118 virtual wxPalette
*GetPalette() const = 0;
119 virtual void SetPalette(const wxPalette
& palette
) = 0;
121 #if WXWIN_COMPATIBILITY
122 wxPalette
*GetColourMap() const { return GetPalette(); }
123 void SetColourMap(wxPalette
*cmap
) { SetPalette(*cmap
); };
124 #endif // WXWIN_COMPATIBILITY
126 // copies the contents and mask of the given (colour) icon to the bitmap
127 virtual bool CopyFromIcon(const wxIcon
& icon
) = 0;
130 virtual void SetHeight(int height
) = 0;
131 virtual void SetWidth(int width
) = 0;
132 virtual void SetDepth(int depth
) = 0;
135 static inline wxList
& GetHandlers() { return sm_handlers
; }
136 static void AddHandler(wxBitmapHandlerBase
*handler
);
137 static void InsertHandler(wxBitmapHandlerBase
*handler
);
138 static bool RemoveHandler(const wxString
& name
);
139 static wxBitmapHandler
*FindHandler(const wxString
& name
);
140 static wxBitmapHandler
*FindHandler(const wxString
& extension
, wxBitmapType bitmapType
);
141 static wxBitmapHandler
*FindHandler(wxBitmapType bitmapType
);
143 //static void InitStandardHandlers();
144 // (wxBitmap must implement this one)
146 static void CleanUpHandlers();
149 static wxList sm_handlers
;
151 DECLARE_ABSTRACT_CLASS(wxBitmapBase
)
155 #if defined(__WXMSW__)
156 #include "wx/msw/bitmap.h"
157 #elif defined(__WXMOTIF__)
158 #include "wx/motif/bitmap.h"
159 #elif defined(__WXGTK__)
160 #include "wx/gtk/bitmap.h"
161 #elif defined(__WXMGL__)
162 #include "wx/mgl/bitmap.h"
163 #elif defined(__WXQT__)
164 #include "wx/qt/bitmap.h"
165 #elif defined(__WXMAC__)
166 #include "wx/mac/bitmap.h"
167 #elif defined(__WXPM__)
168 #include "wx/os2/bitmap.h"
169 #elif defined(__WXSTUBS__)
170 #include "wx/stubs/bitmap.h"
174 // _WX_BITMAP_H_BASE_