]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/bitmap.h
Don't use the "wxHtmlWindow" name, so the classname lookup function
[wxWidgets.git] / include / wx / mac / carbon / bitmap.h
CommitLineData
8cf73271
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: bitmap.h
3// Purpose: wxBitmap class
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
8cf73271
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_BITMAP_H_
13#define _WX_BITMAP_H_
14
8cf73271
SC
15#include "wx/palette.h"
16
17// Bitmap
18class WXDLLEXPORT wxBitmap;
20b69855 19class wxBitmapRefData ;
8cf73271
SC
20class WXDLLEXPORT wxBitmapHandler;
21class WXDLLEXPORT wxControl;
22class WXDLLEXPORT wxCursor;
23class WXDLLEXPORT wxDC;
24class WXDLLEXPORT wxIcon;
25class WXDLLEXPORT wxImage;
26class WXDLLEXPORT wxPixelDataBase;
27
28// A mask is a bitmap used for drawing bitmaps
20b69855
SC
29// Internally it is stored as a 8 bit deep memory chunk, 0 = black means the source will be drawn
30// 255 = white means the source will not be drawn, no other values will be present
31// 8 bit is chosen only for performance reasons, note also that this is the inverse value range
32// from alpha, where 0 = invisible , 255 = fully drawn
33
8cf73271
SC
34class WXDLLEXPORT wxMask: public wxObject
35{
36 DECLARE_DYNAMIC_CLASS(wxMask)
37 DECLARE_NO_COPY_CLASS(wxMask)
38
39public:
20b69855 40 wxMask();
8cf73271 41
20b69855
SC
42 // Construct a mask from a bitmap and a colour indicating
43 // the transparent area
44 wxMask(const wxBitmap& bitmap, const wxColour& colour);
8cf73271 45
20b69855
SC
46 // Construct a mask from a mono bitmap (black meaning show pixels, white meaning transparent)
47 wxMask(const wxBitmap& bitmap);
48
835a3473 49 // implementation helper only : construct a mask from a 32 bit memory buffer
20b69855 50 wxMask(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ;
8cf73271 51
d3c7fc99 52 virtual ~wxMask();
20b69855
SC
53
54 bool Create(const wxBitmap& bitmap, const wxColour& colour);
55 bool Create(const wxBitmap& bitmap);
56 bool Create(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ;
8cf73271 57
20b69855
SC
58 // Implementation below
59
60 void Init() ;
61
62 // a 8 bit depth mask
63 void* GetRawAccess() const;
64 int GetBytesPerRow() const { return m_bytesPerRow ; }
65 // renders/updates native representation when necessary
66 void RealizeNative() ;
71cc158e 67
20b69855 68 WXHBITMAP GetHBITMAP() const ;
71cc158e 69
20b69855
SC
70
71private:
72 wxMemoryBuffer m_memBuf ;
73 int m_bytesPerRow ;
74 int m_width ;
75 int m_height ;
71cc158e 76
20b69855 77 WXHBITMAP m_maskBitmap ;
71cc158e 78
20b69855 79};
8cf73271 80
452418c4 81class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
8cf73271 82{
452418c4 83 DECLARE_ABSTRACT_CLASS(wxBitmapHandler)
8cf73271
SC
84};
85
8cf73271
SC
86class WXDLLEXPORT wxBitmap: public wxBitmapBase
87{
20b69855 88 DECLARE_DYNAMIC_CLASS(wxBitmap)
8cf73271 89
20b69855 90 friend class WXDLLEXPORT wxBitmapHandler;
8cf73271
SC
91
92public:
20b69855
SC
93 wxBitmap(); // Platform-specific
94
20b69855
SC
95 // Initialize with raw data.
96 wxBitmap(const char bits[], int width, int height, int depth = 1);
97
98 // Initialize with XPM data
452418c4 99 wxBitmap(const char* const* bits);
20b69855
SC
100
101 // Load a file or resource
102 wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_PICT_RESOURCE);
103
104 // Constructor for generalised creation from data
452418c4 105 wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1);
20b69855
SC
106
107 // If depth is omitted, will create a bitmap compatible with the display
108 wxBitmap(int width, int height, int depth = -1);
109
110 // Convert from wxImage:
111 wxBitmap(const wxImage& image, int depth = -1);
112
113 // Convert from wxIcon
114 wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
115
d3c7fc99 116 virtual ~wxBitmap();
20b69855
SC
117
118 wxImage ConvertToImage() const;
119
120 // get the given part of bitmap
121 wxBitmap GetSubBitmap( const wxRect& rect ) const;
122
123 virtual bool Create(int width, int height, int depth = -1);
452418c4 124 virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
20b69855
SC
125 // virtual bool Create( WXHICON icon) ;
126 virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
127 virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
128
129 wxBitmapRefData *GetBitmapData() const
130 { return (wxBitmapRefData *)m_refData; }
131
132 // copies the contents and mask of the given (colour) icon to the bitmap
133 virtual bool CopyFromIcon(const wxIcon& icon);
134
b7cacb43
VZ
135 bool Ok() const { return IsOk(); }
136 bool IsOk() const;
20b69855
SC
137 int GetWidth() const;
138 int GetHeight() const;
139 int GetDepth() const;
140 void SetWidth(int w);
141 void SetHeight(int h);
142 void SetDepth(int d);
143 void SetOk(bool isOk);
144
145#if WXWIN_COMPATIBILITY_2_4
146 // these functions do nothing and are only there for backwards
147 // compatibility
148 wxDEPRECATED( int GetQuality() const );
149 wxDEPRECATED( void SetQuality(int quality) );
150#endif // WXWIN_COMPATIBILITY_2_4
8cf73271
SC
151
152#if wxUSE_PALETTE
20b69855
SC
153 wxPalette* GetPalette() const;
154 void SetPalette(const wxPalette& palette);
8cf73271
SC
155#endif // wxUSE_PALETTE
156
20b69855
SC
157 wxMask *GetMask() const;
158 void SetMask(wxMask *mask) ;
8cf73271 159
20b69855 160 static void InitStandardHandlers();
8cf73271
SC
161
162 // raw bitmap access support functions, for internal use only
163 void *GetRawData(wxPixelDataBase& data, int bpp);
164 void UngetRawData(wxPixelDataBase& data);
165
20b69855
SC
166 // these functions are internal and shouldn't be used, they risk to
167 // disappear in the future
168 bool HasAlpha() const;
8cf73271
SC
169 void UseAlpha();
170
20b69855
SC
171 // returns the 'native' implementation, a GWorldPtr for the content and one for the mask
172 WXHBITMAP GetHBITMAP( WXHBITMAP * mask = NULL ) const;
8cf73271 173
30e77b5c 174#ifdef __WXMAC_OSX__
20b69855
SC
175 // returns a CGImageRef which must released after usage with CGImageRelease
176 WXCGIMAGEREF CGImageCreate() const ;
177#endif
178 // get read only access to the underlying buffer
179 void *GetRawAccess() const ;
180 // brackets to the underlying OS structure for read/write access
181 // makes sure that no cached images will be constructed until terminated
182 void *BeginRawAccess() ;
183 void EndRawAccess() ;
8cf73271
SC
184};
185#endif
186 // _WX_BITMAP_H_