]> git.saurik.com Git - wxWidgets.git/blob - include/wx/bitmap.h
Now wxFrame derives from wxFrameMSW/GTK in non-wxUniv mode. Fixes RTTI problems.
[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 // ----------------------------------------------------------------------------
36 // wxBitmapHandler: class which knows how to create/load/save bitmaps in
37 // different formats
38 // ----------------------------------------------------------------------------
39
40 class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
41 {
42 public:
43 wxBitmapHandlerBase()
44 {
45 m_type = wxBITMAP_TYPE_INVALID;
46 }
47
48 virtual ~wxBitmapHandlerBase() { }
49
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;
56
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; }
63
64 protected:
65 wxString m_name;
66 wxString m_extension;
67 wxBitmapType m_type;
68
69 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
70 };
71
72
73
74 class WXDLLEXPORT wxBitmapBase : public wxGDIObject
75 {
76 public:
77 wxBitmapBase() : wxGDIObject() {}
78 virtual ~wxBitmapBase() {}
79
80 /*
81 Derived class must implement these:
82
83 wxBitmap();
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;
94
95 bool Create(int width, int height, int depth = -1);
96
97 static void InitStandardHandlers();
98 */
99
100 virtual bool Ok() const = 0;
101
102 virtual int GetHeight() const = 0;
103 virtual int GetWidth() const = 0;
104 virtual int GetDepth() const = 0;
105
106 virtual wxImage ConvertToImage() const = 0;
107
108 virtual wxMask *GetMask() const = 0;
109 virtual void SetMask(wxMask *mask) = 0;
110
111 virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
112
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;
116
117 virtual wxPalette *GetPalette() const = 0;
118 virtual void SetPalette(const wxPalette& palette) = 0;
119
120 #if WXWIN_COMPATIBILITY
121 wxPalette *GetColourMap() const { return GetPalette(); }
122 void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
123 #endif // WXWIN_COMPATIBILITY
124
125 // copies the contents and mask of the given (colour) icon to the bitmap
126 virtual bool CopyFromIcon(const wxIcon& icon) = 0;
127
128 // implementation:
129 virtual void SetHeight(int height) = 0;
130 virtual void SetWidth(int width) = 0;
131 virtual void SetDepth(int depth) = 0;
132
133 // Format handling
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);
141
142 //static void InitStandardHandlers();
143 // (wxBitmap must implement this one)
144
145 static void CleanUpHandlers();
146
147 protected:
148 static wxList sm_handlers;
149
150 DECLARE_ABSTRACT_CLASS(wxBitmapBase)
151 };
152
153
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_