]> git.saurik.com Git - wxWidgets.git/blame - include/wx/bitmap.h
small sample cleanup (formatting, use stock menu items)
[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 31#if defined(__WXMGL__) || \
b3c86150 32 defined(__WXDFB__) || \
d22004c4 33 defined(__WXMAC__) || \
4611dd06 34 defined(__WXGTK__) || \
d22004c4
WS
35 defined(__WXCOCOA__) || \
36 defined(__WXMOTIF__) || \
37 defined(__WXX11__)
a6a193a0 38// Only used by some ports
b496583b
VS
39// FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
40
1e6feb95
VZ
41// ----------------------------------------------------------------------------
42// wxBitmapHandler: class which knows how to create/load/save bitmaps in
43// different formats
44// ----------------------------------------------------------------------------
45
46class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
47{
48public:
49 wxBitmapHandlerBase()
7ee31b00
GD
50 : m_name()
51 , m_extension()
52 , m_type(wxBITMAP_TYPE_INVALID)
53 { }
1e6feb95
VZ
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
4b61c88d
RR
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
71private:
1e6feb95
VZ
72 wxString m_name;
73 wxString m_extension;
74 wxBitmapType m_type;
75
4b61c88d 76private:
1e6feb95
VZ
77 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
78};
79
1e6feb95
VZ
80class WXDLLEXPORT wxBitmapBase : public wxGDIObject
81{
82public:
1e6feb95
VZ
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);
1e6feb95
VZ
91 wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
92 wxBitmap(const wxImage& image, int depth = -1);
1e6feb95
VZ
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
f28e099e
VZ
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
1e6feb95
VZ
127 virtual wxPalette *GetPalette() const = 0;
128 virtual void SetPalette(const wxPalette& palette) = 0;
f28e099e 129#endif // wxUSE_PALETTE
1e6feb95 130
1e6feb95
VZ
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
153protected:
154 static wxList sm_handlers;
155
156 DECLARE_ABSTRACT_CLASS(wxBitmapBase)
157};
a6a193a0 158#endif
1e6feb95 159
4055ed82 160#if defined(__WXPALMOS__)
ffecfa5a
JS
161#include "wx/palmos/bitmap.h"
162#elif defined(__WXMSW__)
c801d85f 163#include "wx/msw/bitmap.h"
2049ba38 164#elif defined(__WXMOTIF__)
aae0472b 165#include "wx/x11/bitmap.h"
1be7a35c 166#elif defined(__WXGTK20__)
c801d85f 167#include "wx/gtk/bitmap.h"
1be7a35c
MR
168#elif defined(__WXGTK__)
169#include "wx/gtk1/bitmap.h"
83df96d6
JS
170#elif defined(__WXX11__)
171#include "wx/x11/bitmap.h"
1e6feb95
VZ
172#elif defined(__WXMGL__)
173#include "wx/mgl/bitmap.h"
b3c86150
VS
174#elif defined(__WXDFB__)
175#include "wx/dfb/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_