]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/bitmap.h
removed libxpm dependencies from makefiles
[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__
16#pragma interface "bitmap.h"
17#endif
18
19#include "wx/gdiobj.h"
20#include "wx/gdicmn.h"
21#include "wx/palette.h"
22
23// Bitmap
24class WXDLLEXPORT wxDC;
25class WXDLLEXPORT wxControl;
26class WXDLLEXPORT wxBitmap;
27class WXDLLEXPORT wxBitmapHandler;
28class WXDLLEXPORT wxIcon;
29class WXDLLEXPORT wxCursor;
fd859211 30class WXDLLEXPORT wxImage;
0dbd6262 31
03e11df5
GD
32GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
33void wxMacDestroyGWorld( GWorldPtr gw ) ;
519cb848 34PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
03e11df5 35void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
519cb848
SC
36CTabHandle wxMacCreateColorTable( int numColors ) ;
37
0dbd6262
SC
38// A mask is a mono bitmap used for drawing bitmaps
39// transparently.
40class WXDLLEXPORT wxMask: public wxObject
41{
42 DECLARE_DYNAMIC_CLASS(wxMask)
43
44public:
45 wxMask();
46
47 // Construct a mask from a bitmap and a colour indicating
48 // the transparent area
49 wxMask(const wxBitmap& bitmap, const wxColour& colour);
50
51 // Construct a mask from a bitmap and a palette index indicating
52 // the transparent area
53 wxMask(const wxBitmap& bitmap, int paletteIndex);
54
55 // Construct a mask from a mono bitmap (copies the bitmap).
56 wxMask(const wxBitmap& bitmap);
57
58 ~wxMask();
59
60 bool Create(const wxBitmap& bitmap, const wxColour& colour);
61 bool Create(const wxBitmap& bitmap, int paletteIndex);
62 bool Create(const wxBitmap& bitmap);
63
0dbd6262 64 // Implementation
5fde6fcc 65 bool PointMasked(int x, int y);
0dbd6262
SC
66 inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
67 inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
68protected:
69 WXHBITMAP m_maskBitmap;
0dbd6262
SC
70};
71
519cb848
SC
72enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict } ;
73
0dbd6262
SC
74class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
75{
76 friend class WXDLLEXPORT wxBitmap;
77 friend class WXDLLEXPORT wxIcon;
78 friend class WXDLLEXPORT wxCursor;
79public:
80 wxBitmapRefData();
81 ~wxBitmapRefData();
82
83public:
84 int m_width;
85 int m_height;
86 int m_depth;
87 bool m_ok;
88 int m_numColors;
89 wxPalette m_bitmapPalette;
90 int m_quality;
91
519cb848
SC
92 int m_bitmapType ;
93 PicHandle m_hPict ;
94 WXHBITMAP m_hBitmap;
0dbd6262
SC
95 wxMask * m_bitmapMask; // Optional mask
96};
97
98#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
99
100class WXDLLEXPORT wxBitmapHandler: public wxObject
101{
102 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
103public:
104 wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; };
03e11df5
GD
105#ifdef __WXMAC_X__
106 virtual ~wxBitmapHandler() {} // Added min for Mac X
107#endif
0dbd6262
SC
108
109 virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
110 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
111 int desiredWidth, int desiredHeight);
112 virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
113
114 inline void SetName(const wxString& name) { m_name = name; }
115 inline void SetExtension(const wxString& ext) { m_extension = ext; }
116 inline void SetType(long type) { m_type = type; }
117 inline wxString GetName() const { return m_name; }
118 inline wxString GetExtension() const { return m_extension; }
119 inline long GetType() const { return m_type; }
120protected:
121 wxString m_name;
122 wxString m_extension;
123 long m_type;
124};
125
126#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
127
128class WXDLLEXPORT wxBitmap: public wxGDIObject
129{
130 DECLARE_DYNAMIC_CLASS(wxBitmap)
131
132 friend class WXDLLEXPORT wxBitmapHandler;
133
134public:
135 wxBitmap(); // Platform-specific
136
137 // Copy constructors
138 inline wxBitmap(const wxBitmap& bitmap)
139 { Ref(bitmap); if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this); }
140
141 // Initialize with raw data.
142 wxBitmap(const char bits[], int width, int height, int depth = 1);
143
0dbd6262 144 // Initialize with XPM data
b7d667c5
GD
145 bool CreateFromXpm(const char **bits);
146 wxBitmap(const char **bits);
147 wxBitmap(char **bits);
0dbd6262
SC
148
149 // Load a file or resource
519cb848 150 wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_PICT_RESOURCE);
0dbd6262
SC
151
152 // Constructor for generalised creation from data
153 wxBitmap(void *data, long type, int width, int height, int depth = 1);
154
155 // If depth is omitted, will create a bitmap compatible with the display
156 wxBitmap(int width, int height, int depth = -1);
fd859211
VS
157
158 // Convert from wxImage:
159 wxBitmap(const wxImage& image, int depth = -1);
160
0dbd6262 161 ~wxBitmap();
fd859211
VS
162
163 wxImage ConvertToImage() const;
0dbd6262 164
5fde6fcc
GD
165 // get the given part of bitmap
166 wxBitmap GetSubBitmap( const wxRect& rect ) const;
167
0dbd6262
SC
168 virtual bool Create(int width, int height, int depth = -1);
169 virtual bool Create(void *data, long type, int width, int height, int depth = 1);
170 virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE);
171 virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL);
172
5fde6fcc
GD
173 bool Ok() const;
174 int GetWidth() const;
175 int GetHeight() const;
176 int GetDepth() const;
177 int GetQuality() const;
0dbd6262
SC
178 void SetWidth(int w);
179 void SetHeight(int h);
180 void SetDepth(int d);
181 void SetQuality(int q);
182 void SetOk(bool isOk);
183
5fde6fcc 184 wxPalette* GetPalette() const;
0dbd6262
SC
185 void SetPalette(const wxPalette& palette);
186
5fde6fcc 187 wxMask *GetMask() const;
0dbd6262
SC
188 void SetMask(wxMask *mask) ;
189
5fde6fcc
GD
190 int GetBitmapType() const;
191
0dbd6262
SC
192 inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
193 inline bool operator == (const wxBitmap& bitmap) { return m_refData == bitmap.m_refData; }
194 inline bool operator != (const wxBitmap& bitmap) { return m_refData != bitmap.m_refData; }
195
196 // Format handling
197 static inline wxList& GetHandlers() { return sm_handlers; }
198 static void AddHandler(wxBitmapHandler *handler);
199 static void InsertHandler(wxBitmapHandler *handler);
200 static bool RemoveHandler(const wxString& name);
201 static wxBitmapHandler *FindHandler(const wxString& name);
202 static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType);
203 static wxBitmapHandler *FindHandler(long bitmapType);
204
205 static void InitStandardHandlers();
206 static void CleanUpHandlers();
207protected:
208 static wxList sm_handlers;
209
0dbd6262
SC
210 // TODO: Implementation
211public:
212 void SetHBITMAP(WXHBITMAP bmp);
5fde6fcc 213 WXHBITMAP GetHBITMAP() const;
03e11df5 214
5fde6fcc
GD
215 PicHandle GetPict() const;
216
0dbd6262 217 bool FreeResource(bool force = FALSE);
0dbd6262
SC
218};
219#endif
220 // _WX_BITMAP_H_