]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/bitmap.h
Fix so OGL can build without wxBuffer
[wxWidgets.git] / include / wx / mac / bitmap.h
CommitLineData
0dbd6262
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: bitmap.h
3// Purpose: wxBitmap class
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_BITMAP_H_
13#define _WX_BITMAP_H_
14
15#ifdef __GNUG__
b698c8e9 16 #pragma interface "bitmap.h"
0dbd6262
SC
17#endif
18
0dbd6262
SC
19#include "wx/palette.h"
20
21// Bitmap
22class WXDLLEXPORT wxDC;
23class WXDLLEXPORT wxControl;
24class WXDLLEXPORT wxBitmap;
25class WXDLLEXPORT wxBitmapHandler;
26class WXDLLEXPORT wxIcon;
27class WXDLLEXPORT wxCursor;
fd859211 28class WXDLLEXPORT wxImage;
0dbd6262
SC
29
30// A mask is a mono bitmap used for drawing bitmaps
31// transparently.
32class WXDLLEXPORT wxMask: public wxObject
33{
34 DECLARE_DYNAMIC_CLASS(wxMask)
35
36public:
37 wxMask();
38
39 // Construct a mask from a bitmap and a colour indicating
40 // the transparent area
41 wxMask(const wxBitmap& bitmap, const wxColour& colour);
42
43 // Construct a mask from a bitmap and a palette index indicating
44 // the transparent area
45 wxMask(const wxBitmap& bitmap, int paletteIndex);
46
47 // Construct a mask from a mono bitmap (copies the bitmap).
48 wxMask(const wxBitmap& bitmap);
49
50 ~wxMask();
51
52 bool Create(const wxBitmap& bitmap, const wxColour& colour);
53 bool Create(const wxBitmap& bitmap, int paletteIndex);
54 bool Create(const wxBitmap& bitmap);
55
0dbd6262 56 // Implementation
5fde6fcc 57 bool PointMasked(int x, int y);
0dbd6262
SC
58 inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
59 inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
60protected:
61 WXHBITMAP m_maskBitmap;
0dbd6262
SC
62};
63
3dec57ad 64enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict , kMacBitmapTypeIcon } ;
519cb848 65
0dbd6262
SC
66class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
67{
68 friend class WXDLLEXPORT wxBitmap;
69 friend class WXDLLEXPORT wxIcon;
70 friend class WXDLLEXPORT wxCursor;
71public:
72 wxBitmapRefData();
73 ~wxBitmapRefData();
74
75public:
76 int m_width;
77 int m_height;
78 int m_depth;
79 bool m_ok;
80 int m_numColors;
81 wxPalette m_bitmapPalette;
82 int m_quality;
83
5273bf2f
SC
84 int m_bitmapType ;
85 WXHMETAFILE m_hPict ;
86 WXHBITMAP m_hBitmap;
87 WXHICON m_hIcon ;
0dbd6262
SC
88 wxMask * m_bitmapMask; // Optional mask
89};
90
91#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
92
584bede0 93class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase
0dbd6262
SC
94{
95 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
96public:
97 wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; };
f11bdd03
GD
98#ifdef __DARWIN__
99 virtual ~wxBitmapHandler() { }
03e11df5 100#endif
0dbd6262
SC
101
102 virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
103 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
104 int desiredWidth, int desiredHeight);
584bede0 105 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
0dbd6262
SC
106
107 inline void SetName(const wxString& name) { m_name = name; }
108 inline void SetExtension(const wxString& ext) { m_extension = ext; }
109 inline void SetType(long type) { m_type = type; }
110 inline wxString GetName() const { return m_name; }
111 inline wxString GetExtension() const { return m_extension; }
112 inline long GetType() const { return m_type; }
113protected:
114 wxString m_name;
115 wxString m_extension;
116 long m_type;
117};
118
119#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
120
584bede0 121class WXDLLEXPORT wxBitmap: public wxBitmapBase
0dbd6262
SC
122{
123 DECLARE_DYNAMIC_CLASS(wxBitmap)
124
125 friend class WXDLLEXPORT wxBitmapHandler;
126
127public:
128 wxBitmap(); // Platform-specific
129
130 // Copy constructors
131 inline wxBitmap(const wxBitmap& bitmap)
d71c423e 132 { Ref(bitmap); }
0dbd6262
SC
133
134 // Initialize with raw data.
135 wxBitmap(const char bits[], int width, int height, int depth = 1);
136
0dbd6262 137 // Initialize with XPM data
b7d667c5
GD
138 bool CreateFromXpm(const char **bits);
139 wxBitmap(const char **bits);
140 wxBitmap(char **bits);
0dbd6262
SC
141
142 // Load a file or resource
584bede0 143 wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_PICT_RESOURCE);
0dbd6262
SC
144
145 // Constructor for generalised creation from data
584bede0 146 wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1);
0dbd6262
SC
147
148 // If depth is omitted, will create a bitmap compatible with the display
149 wxBitmap(int width, int height, int depth = -1);
fd859211
VS
150
151 // Convert from wxImage:
152 wxBitmap(const wxImage& image, int depth = -1);
153
0dbd6262 154 ~wxBitmap();
fd859211
VS
155
156 wxImage ConvertToImage() const;
0dbd6262 157
5fde6fcc
GD
158 // get the given part of bitmap
159 wxBitmap GetSubBitmap( const wxRect& rect ) const;
160
0dbd6262 161 virtual bool Create(int width, int height, int depth = -1);
584bede0
GD
162 virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1);
163 virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
164 virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
165
166 // copies the contents and mask of the given (colour) icon to the bitmap
167 virtual bool CopyFromIcon(const wxIcon& icon);
0dbd6262 168
5fde6fcc
GD
169 bool Ok() const;
170 int GetWidth() const;
171 int GetHeight() const;
172 int GetDepth() const;
173 int GetQuality() const;
0dbd6262
SC
174 void SetWidth(int w);
175 void SetHeight(int h);
176 void SetDepth(int d);
177 void SetQuality(int q);
178 void SetOk(bool isOk);
179
5fde6fcc 180 wxPalette* GetPalette() const;
0dbd6262
SC
181 void SetPalette(const wxPalette& palette);
182
5fde6fcc 183 wxMask *GetMask() const;
0dbd6262
SC
184 void SetMask(wxMask *mask) ;
185
5fde6fcc
GD
186 int GetBitmapType() const;
187
0dbd6262
SC
188 inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
189 inline bool operator == (const wxBitmap& bitmap) { return m_refData == bitmap.m_refData; }
190 inline bool operator != (const wxBitmap& bitmap) { return m_refData != bitmap.m_refData; }
191
0dbd6262 192 static void InitStandardHandlers();
0dbd6262 193protected:
0dbd6262 194
0dbd6262
SC
195 // TODO: Implementation
196public:
197 void SetHBITMAP(WXHBITMAP bmp);
5fde6fcc 198 WXHBITMAP GetHBITMAP() const;
3dec57ad
SC
199 void SetHICON(WXHICON ico);
200 inline WXHICON GetHICON() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hIcon : 0); }
03e11df5 201
5273bf2f 202 WXHMETAFILE GetPict() const;
5fde6fcc 203
0dbd6262 204 bool FreeResource(bool force = FALSE);
0dbd6262
SC
205};
206#endif
207 // _WX_BITMAP_H_