]> git.saurik.com Git - wxWidgets.git/blob - include/wx/bitmap.h
Implement most of AppendRow(), PrependRow(), InsertRow(),
[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(__WXDFB__) || \
33 defined(__WXMAC__) || \
34 defined(__WXGTK__) || \
35 defined(__WXCOCOA__) || \
36 defined(__WXMOTIF__) || \
37 defined(__WXX11__)
38 // Only used by some ports
39 // FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
40
41 // ----------------------------------------------------------------------------
42 // wxBitmapHandler: class which knows how to create/load/save bitmaps in
43 // different formats
44 // ----------------------------------------------------------------------------
45
46 class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
47 {
48 public:
49 wxBitmapHandlerBase()
50 : m_name()
51 , m_extension()
52 , m_type(wxBITMAP_TYPE_INVALID)
53 { }
54
55 virtual ~wxBitmapHandlerBase() { }
56
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;
63
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; }
70
71 private:
72 wxString m_name;
73 wxString m_extension;
74 wxBitmapType m_type;
75
76 private:
77 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
78 };
79
80 class WXDLLEXPORT wxBitmapBase : public wxGDIObject
81 {
82 public:
83 /*
84 Derived class must implement these:
85
86 wxBitmap();
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;
95
96 bool Create(int width, int height, int depth = -1);
97
98 static void InitStandardHandlers();
99 */
100
101 virtual bool Ok() const = 0;
102
103 virtual int GetHeight() const = 0;
104 virtual int GetWidth() const = 0;
105 virtual int GetDepth() const = 0;
106
107 virtual wxImage ConvertToImage() const = 0;
108
109 virtual wxMask *GetMask() const = 0;
110 virtual void SetMask(wxMask *mask) = 0;
111
112 virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
113
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;
117
118 /*
119 If raw bitmap access is supported (see wx/rawbmp.h), the following
120 methods should be implemented:
121
122 virtual bool GetRawData(wxRawBitmapData *data) = 0;
123 virtual void UngetRawData(wxRawBitmapData *data) = 0;
124 */
125
126 #if wxUSE_PALETTE
127 virtual wxPalette *GetPalette() const = 0;
128 virtual void SetPalette(const wxPalette& palette) = 0;
129 #endif // wxUSE_PALETTE
130
131 // copies the contents and mask of the given (colour) icon to the bitmap
132 virtual bool CopyFromIcon(const wxIcon& icon) = 0;
133
134 // implementation:
135 virtual void SetHeight(int height) = 0;
136 virtual void SetWidth(int width) = 0;
137 virtual void SetDepth(int depth) = 0;
138
139 // Format handling
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);
147
148 //static void InitStandardHandlers();
149 // (wxBitmap must implement this one)
150
151 static void CleanUpHandlers();
152
153 protected:
154 static wxList sm_handlers;
155
156 DECLARE_ABSTRACT_CLASS(wxBitmapBase)
157 };
158 #endif
159
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"
182 #endif
183
184 #endif
185 // _WX_BITMAP_H_BASE_