]> git.saurik.com Git - wxWidgets.git/blob - include/wx/bitmap.h
first impl (needs extending)
[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) wxWindows 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 #ifdef __GNUG__
20 #pragma interface "bitmapbase.h"
21 #endif
22
23 #include "wx/defs.h"
24 #include "wx/object.h"
25 #include "wx/string.h"
26 #include "wx/gdiobj.h"
27 #include "wx/gdicmn.h" // for wxBitmapType
28
29 class WXDLLEXPORT wxBitmap;
30 class WXDLLEXPORT wxBitmapHandler;
31 class WXDLLEXPORT wxImage;
32 class WXDLLEXPORT wxMask;
33 class WXDLLEXPORT wxPalette;
34
35 #if !defined(__WXMSW__)
36
37 // Only used by some ports
38 // ----------------------------------------------------------------------------
39 // wxBitmapHandler: class which knows how to create/load/save bitmaps in
40 // different formats
41 // ----------------------------------------------------------------------------
42
43 class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
44 {
45 public:
46 wxBitmapHandlerBase()
47 {
48 m_type = wxBITMAP_TYPE_INVALID;
49 }
50
51 virtual ~wxBitmapHandlerBase() { }
52
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;
59
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; }
66
67 protected:
68 wxString m_name;
69 wxString m_extension;
70 wxBitmapType m_type;
71
72 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
73 };
74
75 class WXDLLEXPORT wxBitmapBase : public wxGDIObject
76 {
77 public:
78 wxBitmapBase() : wxGDIObject() {}
79 virtual ~wxBitmapBase() {}
80
81 /*
82 Derived class must implement these:
83
84 wxBitmap();
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;
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 virtual wxPalette *GetPalette() const = 0;
119 virtual void SetPalette(const wxPalette& palette) = 0;
120
121 #if WXWIN_COMPATIBILITY
122 wxPalette *GetColourMap() const { return GetPalette(); }
123 void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
124 #endif // WXWIN_COMPATIBILITY
125
126 // copies the contents and mask of the given (colour) icon to the bitmap
127 virtual bool CopyFromIcon(const wxIcon& icon) = 0;
128
129 // implementation:
130 virtual void SetHeight(int height) = 0;
131 virtual void SetWidth(int width) = 0;
132 virtual void SetDepth(int depth) = 0;
133
134 // Format handling
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);
142
143 //static void InitStandardHandlers();
144 // (wxBitmap must implement this one)
145
146 static void CleanUpHandlers();
147
148 protected:
149 static wxList sm_handlers;
150
151 DECLARE_ABSTRACT_CLASS(wxBitmapBase)
152 };
153 #endif
154
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"
171 #endif
172
173 #endif
174 // _WX_BITMAP_H_BASE_