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/palette.h"
27 #include "wx/gdiobj.h"
29 class WXDLLEXPORT wxImage
;
30 class WXDLLEXPORT wxMask
;
31 class WXDLLEXPORT wxBitmap
;
32 class WXDLLEXPORT wxBitmapHandler
;
34 // ----------------------------------------------------------------------------
35 // wxBitmapHandler: class which knows how to create/load/save bitmaps in
37 // ----------------------------------------------------------------------------
39 class WXDLLEXPORT wxBitmapHandlerBase
: public wxObject
44 m_type
= wxBITMAP_TYPE_INVALID
;
47 virtual ~wxBitmapHandlerBase() { }
49 virtual bool Create(wxBitmap
*bitmap
, void *data
, long flags
,
50 int width
, int height
, int depth
= 1) = 0;
51 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
52 int desiredWidth
, int desiredHeight
) = 0;
53 virtual bool SaveFile(const wxBitmap
*bitmap
, const wxString
& name
,
54 int type
, const wxPalette
*palette
= NULL
) = 0;
56 void SetName(const wxString
& name
) { m_name
= name
; }
57 void SetExtension(const wxString
& ext
) { m_extension
= ext
; }
58 void SetType(wxBitmapType type
) { m_type
= type
; }
59 wxString
GetName() const { return m_name
; }
60 wxString
GetExtension() const { return m_extension
; }
61 wxBitmapType
GetType() const { return m_type
; }
68 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase
)
73 class WXDLLEXPORT wxBitmapBase
: public wxGDIObject
76 wxBitmapBase() : wxGDIObject() {}
77 virtual ~wxBitmapBase() {}
80 Derived class must implement these:
83 wxBitmap(int width, int height, int depth = -1);
84 wxBitmap(const char bits[], int width, int height, int depth = 1);
85 wxBitmap(const char **bits);
86 wxBitmap(char **bits);
87 wxBitmap(const wxBitmap& bmp);
88 wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
89 wxBitmap(const wxImage& image, int depth = -1);
90 wxBitmap& operator = (const wxBitmap& bmp);
91 bool operator == (const wxBitmap& bmp) const;
92 bool operator != (const wxBitmap& bmp) const;
94 bool Create(int width, int height, int depth = -1);
96 static void InitStandardHandlers();
99 virtual bool Ok() const = 0;
101 virtual int GetHeight() const = 0;
102 virtual int GetWidth() const = 0;
103 virtual int GetDepth() const = 0;
105 virtual wxImage
ConvertToImage() const = 0;
107 virtual wxMask
*GetMask() const = 0;
108 virtual void SetMask(wxMask
*mask
) = 0;
110 virtual wxBitmap
GetSubBitmap(const wxRect
& rect
) const = 0;
112 virtual bool SaveFile(const wxString
&name
, wxBitmapType type
,
113 const wxPalette
*palette
= (wxPalette
*)NULL
) const = 0;
114 virtual bool LoadFile(const wxString
&name
, wxBitmapType type
) = 0;
116 virtual wxPalette
*GetPalette() const = 0;
117 virtual void SetPalette(const wxPalette
& palette
) = 0;
119 #if WXWIN_COMPATIBILITY
120 wxPalette
*GetColourMap() const { return GetPalette(); }
121 void SetColourMap(wxPalette
*cmap
) { SetPalette(*cmap
); };
122 #endif // WXWIN_COMPATIBILITY
124 // copies the contents and mask of the given (colour) icon to the bitmap
125 virtual bool CopyFromIcon(const wxIcon
& icon
) = 0;
128 virtual void SetHeight(int height
) = 0;
129 virtual void SetWidth(int width
) = 0;
130 virtual void SetDepth(int depth
) = 0;
133 static inline wxList
& GetHandlers() { return sm_handlers
; }
134 static void AddHandler(wxBitmapHandlerBase
*handler
);
135 static void InsertHandler(wxBitmapHandlerBase
*handler
);
136 static bool RemoveHandler(const wxString
& name
);
137 static wxBitmapHandler
*FindHandler(const wxString
& name
);
138 static wxBitmapHandler
*FindHandler(const wxString
& extension
, wxBitmapType bitmapType
);
139 static wxBitmapHandler
*FindHandler(wxBitmapType bitmapType
);
141 //static void InitStandardHandlers();
142 // (wxBitmap must implement this one)
144 static void CleanUpHandlers();
147 static wxList sm_handlers
;
149 DECLARE_ABSTRACT_CLASS(wxBitmapBase
)
154 #if defined(__WXMSW__)
155 #include "wx/msw/bitmap.h"
156 #elif defined(__WXMOTIF__)
157 #include "wx/motif/bitmap.h"
158 #elif defined(__WXGTK__)
159 #include "wx/gtk/bitmap.h"
160 #elif defined(__WXMGL__)
161 #include "wx/mgl/bitmap.h"
162 #elif defined(__WXQT__)
163 #include "wx/qt/bitmap.h"
164 #elif defined(__WXMAC__)
165 #include "wx/mac/bitmap.h"
166 #elif defined(__WXPM__)
167 #include "wx/os2/bitmap.h"
168 #elif defined(__WXSTUBS__)
169 #include "wx/stubs/bitmap.h"
173 // _WX_BITMAP_H_BASE_