]> git.saurik.com Git - wxWidgets.git/blame - include/wx/bitmap.h
wxPalette unified. Source cleaning.
[wxWidgets.git] / include / wx / bitmap.h
CommitLineData
1e6feb95
VZ
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$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
1e6feb95
VZ
10///////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_BITMAP_H_BASE_
13#define _WX_BITMAP_H_BASE_
c801d85f 14
1e6feb95
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
1e6feb95
VZ
19#include "wx/defs.h"
20#include "wx/object.h"
21#include "wx/string.h"
1e6feb95 22#include "wx/gdiobj.h"
22bd9387 23#include "wx/gdicmn.h" // for wxBitmapType
1e6feb95 24
1e6feb95
VZ
25class WXDLLEXPORT wxBitmap;
26class WXDLLEXPORT wxBitmapHandler;
22bd9387
VZ
27class WXDLLEXPORT wxImage;
28class WXDLLEXPORT wxMask;
29class WXDLLEXPORT wxPalette;
1e6feb95 30
d22004c4
WS
31#if defined(__WXMGL__) || \
32 defined(__WXMAC__) || \
4611dd06 33 defined(__WXGTK__) || \
d22004c4
WS
34 defined(__WXCOCOA__) || \
35 defined(__WXMOTIF__) || \
36 defined(__WXX11__)
a6a193a0 37// Only used by some ports
b496583b
VS
38// FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
39
1e6feb95
VZ
40// ----------------------------------------------------------------------------
41// wxBitmapHandler: class which knows how to create/load/save bitmaps in
42// different formats
43// ----------------------------------------------------------------------------
44
45class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
46{
47public:
48 wxBitmapHandlerBase()
7ee31b00
GD
49 : m_name()
50 , m_extension()
51 , m_type(wxBITMAP_TYPE_INVALID)
52 { }
1e6feb95
VZ
53
54 virtual ~wxBitmapHandlerBase() { }
55
56 virtual bool Create(wxBitmap *bitmap, void *data, long flags,
57 int width, int height, int depth = 1) = 0;
58 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
59 int desiredWidth, int desiredHeight) = 0;
60 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name,
61 int type, const wxPalette *palette = NULL) = 0;
62
4b61c88d
RR
63 void SetName(const wxString& name) { m_name = name; }
64 void SetExtension(const wxString& ext) { m_extension = ext; }
65 void SetType(wxBitmapType type) { m_type = type; }
66 wxString GetName() const { return m_name; }
67 wxString GetExtension() const { return m_extension; }
68 wxBitmapType GetType() const { return m_type; }
69
70private:
1e6feb95
VZ
71 wxString m_name;
72 wxString m_extension;
73 wxBitmapType m_type;
74
4b61c88d 75private:
1e6feb95
VZ
76 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
77};
78
1e6feb95
VZ
79class WXDLLEXPORT wxBitmapBase : public wxGDIObject
80{
81public:
82 wxBitmapBase() : wxGDIObject() {}
83 virtual ~wxBitmapBase() {}
84
85 /*
86 Derived class must implement these:
87
88 wxBitmap();
89 wxBitmap(int width, int height, int depth = -1);
90 wxBitmap(const char bits[], int width, int height, int depth = 1);
91 wxBitmap(const char **bits);
92 wxBitmap(char **bits);
93 wxBitmap(const wxBitmap& bmp);
94 wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
95 wxBitmap(const wxImage& image, int depth = -1);
96 wxBitmap& operator = (const wxBitmap& bmp);
97 bool operator == (const wxBitmap& bmp) const;
98 bool operator != (const wxBitmap& bmp) const;
99
100 bool Create(int width, int height, int depth = -1);
101
102 static void InitStandardHandlers();
103 */
104
105 virtual bool Ok() const = 0;
106
107 virtual int GetHeight() const = 0;
108 virtual int GetWidth() const = 0;
109 virtual int GetDepth() const = 0;
110
111 virtual wxImage ConvertToImage() const = 0;
112
113 virtual wxMask *GetMask() const = 0;
114 virtual void SetMask(wxMask *mask) = 0;
115
116 virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
117
118 virtual bool SaveFile(const wxString &name, wxBitmapType type,
119 const wxPalette *palette = (wxPalette *)NULL) const = 0;
120 virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0;
121
f28e099e
VZ
122 /*
123 If raw bitmap access is supported (see wx/rawbmp.h), the following
124 methods should be implemented:
125
126 virtual bool GetRawData(wxRawBitmapData *data) = 0;
127 virtual void UngetRawData(wxRawBitmapData *data) = 0;
128 */
129
130#if wxUSE_PALETTE
1e6feb95
VZ
131 virtual wxPalette *GetPalette() const = 0;
132 virtual void SetPalette(const wxPalette& palette) = 0;
f28e099e 133#endif // wxUSE_PALETTE
1e6feb95 134
1e6feb95
VZ
135 // copies the contents and mask of the given (colour) icon to the bitmap
136 virtual bool CopyFromIcon(const wxIcon& icon) = 0;
137
138 // implementation:
139 virtual void SetHeight(int height) = 0;
140 virtual void SetWidth(int width) = 0;
141 virtual void SetDepth(int depth) = 0;
142
143 // Format handling
144 static inline wxList& GetHandlers() { return sm_handlers; }
145 static void AddHandler(wxBitmapHandlerBase *handler);
146 static void InsertHandler(wxBitmapHandlerBase *handler);
147 static bool RemoveHandler(const wxString& name);
148 static wxBitmapHandler *FindHandler(const wxString& name);
149 static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType);
150 static wxBitmapHandler *FindHandler(wxBitmapType bitmapType);
151
152 //static void InitStandardHandlers();
153 // (wxBitmap must implement this one)
154
155 static void CleanUpHandlers();
156
157protected:
158 static wxList sm_handlers;
159
160 DECLARE_ABSTRACT_CLASS(wxBitmapBase)
161};
a6a193a0 162#endif
1e6feb95 163
4055ed82 164#if defined(__WXPALMOS__)
ffecfa5a
JS
165#include "wx/palmos/bitmap.h"
166#elif defined(__WXMSW__)
c801d85f 167#include "wx/msw/bitmap.h"
2049ba38 168#elif defined(__WXMOTIF__)
aae0472b 169#include "wx/x11/bitmap.h"
2049ba38 170#elif defined(__WXGTK__)
c801d85f 171#include "wx/gtk/bitmap.h"
83df96d6
JS
172#elif defined(__WXX11__)
173#include "wx/x11/bitmap.h"
1e6feb95
VZ
174#elif defined(__WXMGL__)
175#include "wx/mgl/bitmap.h"
34138703
JS
176#elif defined(__WXMAC__)
177#include "wx/mac/bitmap.h"
fed66a87
DE
178#elif defined(__WXCOCOA__)
179#include "wx/cocoa/bitmap.h"
1777b9bb
DW
180#elif defined(__WXPM__)
181#include "wx/os2/bitmap.h"
c801d85f
KB
182#endif
183
184#endif
34138703 185 // _WX_BITMAP_H_BASE_