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 // ----------------------------------------------------------------------------
36 // wxBitmapHandler: class which knows how to create/load/save bitmaps in
38 // ----------------------------------------------------------------------------
40 class WXDLLEXPORT wxBitmapHandlerBase
: public wxObject
45 m_type
= wxBITMAP_TYPE_INVALID
;
48 virtual ~wxBitmapHandlerBase() { }
50 virtual bool Create(wxBitmap
*bitmap
, void *data
, long flags
,
51 int width
, int height
, int depth
= 1) = 0;
52 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
53 int desiredWidth
, int desiredHeight
) = 0;
54 virtual bool SaveFile(const wxBitmap
*bitmap
, const wxString
& name
,
55 int type
, const wxPalette
*palette
= NULL
) = 0;
57 void SetName(const wxString
& name
) { m_name
= name
; }
58 void SetExtension(const wxString
& ext
) { m_extension
= ext
; }
59 void SetType(wxBitmapType type
) { m_type
= type
; }
60 wxString
GetName() const { return m_name
; }
61 wxString
GetExtension() const { return m_extension
; }
62 wxBitmapType
GetType() const { return m_type
; }
69 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase
)
74 class WXDLLEXPORT wxBitmapBase
: public wxGDIObject
77 wxBitmapBase() : wxGDIObject() {}
78 virtual ~wxBitmapBase() {}
81 Derived class must implement these:
84 wxBitmap(int width, int height, int depth = -1);
85 wxBitmap(const char bits[], int width, int height, int depth = 1);
86 wxBitmap(const char **bits);
87 wxBitmap(char **bits);
88 wxBitmap(const wxBitmap& bmp);
89 wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
90 wxBitmap(const wxImage& image, int depth = -1);
91 wxBitmap& operator = (const wxBitmap& bmp);
92 bool operator == (const wxBitmap& bmp) const;
93 bool operator != (const wxBitmap& bmp) const;
95 bool Create(int width, int height, int depth = -1);
97 static void InitStandardHandlers();
100 virtual bool Ok() const = 0;
102 virtual int GetHeight() const = 0;
103 virtual int GetWidth() const = 0;
104 virtual int GetDepth() const = 0;
106 virtual wxImage
ConvertToImage() const = 0;
108 virtual wxMask
*GetMask() const = 0;
109 virtual void SetMask(wxMask
*mask
) = 0;
111 virtual wxBitmap
GetSubBitmap(const wxRect
& rect
) const = 0;
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;
117 virtual wxPalette
*GetPalette() const = 0;
118 virtual void SetPalette(const wxPalette
& palette
) = 0;
120 #if WXWIN_COMPATIBILITY
121 wxPalette
*GetColourMap() const { return GetPalette(); }
122 void SetColourMap(wxPalette
*cmap
) { SetPalette(*cmap
); };
123 #endif // WXWIN_COMPATIBILITY
125 // copies the contents and mask of the given (colour) icon to the bitmap
126 virtual bool CopyFromIcon(const wxIcon
& icon
) = 0;
129 virtual void SetHeight(int height
) = 0;
130 virtual void SetWidth(int width
) = 0;
131 virtual void SetDepth(int depth
) = 0;
134 static inline wxList
& GetHandlers() { return sm_handlers
; }
135 static void AddHandler(wxBitmapHandlerBase
*handler
);
136 static void InsertHandler(wxBitmapHandlerBase
*handler
);
137 static bool RemoveHandler(const wxString
& name
);
138 static wxBitmapHandler
*FindHandler(const wxString
& name
);
139 static wxBitmapHandler
*FindHandler(const wxString
& extension
, wxBitmapType bitmapType
);
140 static wxBitmapHandler
*FindHandler(wxBitmapType bitmapType
);
142 //static void InitStandardHandlers();
143 // (wxBitmap must implement this one)
145 static void CleanUpHandlers();
148 static wxList sm_handlers
;
150 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_