]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/bitmap.h
Update to Scintilla 1.53
[wxWidgets.git] / include / wx / cocoa / bitmap.h
CommitLineData
a24aff65
DE
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#if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "bitmap.h"
17#endif
18
19#include "wx/palette.h"
20
21// Bitmap
22class WXDLLEXPORT wxBitmap;
23class WXDLLEXPORT wxBitmapHandler;
24class WXDLLEXPORT wxIcon;
25class WXDLLEXPORT wxCursor;
26class WXDLLEXPORT wxImage;
27
28// A mask is a mono bitmap used for drawing bitmaps
29// transparently.
30class WXDLLEXPORT wxMask: public wxObject
31{
32 DECLARE_DYNAMIC_CLASS(wxMask)
33 DECLARE_NO_COPY_CLASS(wxMask)
34
35public:
36 wxMask();
37
38 // Construct a mask from a bitmap and a colour indicating
39 // the transparent area
40 wxMask(const wxBitmap& bitmap, const wxColour& colour);
41
42 // Construct a mask from a bitmap and a palette index indicating
43 // the transparent area
44 wxMask(const wxBitmap& bitmap, int paletteIndex);
45
46 // Construct a mask from a mono bitmap (copies the bitmap).
47 wxMask(const wxBitmap& bitmap);
48
49 ~wxMask();
50
51 bool Create(const wxBitmap& bitmap, const wxColour& colour);
52 bool Create(const wxBitmap& bitmap, int paletteIndex);
53 bool Create(const wxBitmap& bitmap);
54
55 // Implementation
56// inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
57// inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
58protected:
59// WXHBITMAP m_maskBitmap;
60};
61
62class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
63{
64 DECLARE_NO_COPY_CLASS(wxBitmapRefData)
65
66 friend class WXDLLEXPORT wxBitmap;
67 friend class WXDLLEXPORT wxIcon;
68 friend class WXDLLEXPORT wxCursor;
69public:
70 wxBitmapRefData();
71 ~wxBitmapRefData();
72
73public:
74 int m_width;
75 int m_height;
76 int m_depth;
77 bool m_ok;
78 int m_numColors;
79 wxPalette m_bitmapPalette;
80 int m_quality;
81
82 // TOTO: platofmr specific hBitmap
83// WXHBITMAP m_hBitmap;
84 wxMask * m_bitmapMask; // Optional mask
85};
86
87#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
88
89class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase
90{
91 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
92public:
93 wxBitmapHandler() : m_name(), m_extension(), m_type(0) { }
94 virtual ~wxBitmapHandler();
95
96 virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
97 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
98 int desiredWidth, int desiredHeight);
99 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
100
101 void SetName(const wxString& name) { m_name = name; }
102 void SetExtension(const wxString& ext) { m_extension = ext; }
103 void SetType(long type) { m_type = type; }
104 wxString GetName() const { return m_name; }
105 wxString GetExtension() const { return m_extension; }
106 long GetType() const { return m_type; }
107
108protected:
109 wxString m_name;
110 wxString m_extension;
111 long m_type;
112};
113
114#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
115
116class WXDLLEXPORT wxBitmap: public wxBitmapBase
117{
118 DECLARE_DYNAMIC_CLASS(wxBitmap)
119
120 friend class WXDLLEXPORT wxBitmapHandler;
121
122public:
123 wxBitmap(); // Platform-specific
124
125 // Copy constructors
126 wxBitmap(const wxBitmap& bitmap)
127 : wxBitmapBase()
128 { Ref(bitmap); }
129
130 // Initialize with raw data.
131 wxBitmap(const char bits[], int width, int height, int depth = 1);
132
133 // Initialize with XPM data
134 bool CreateFromXpm(const char **bits);
135 wxBitmap(const char **bits) { CreateFromXpm(bits); }
136 wxBitmap(char **bits);
137
138 // Load a file or resource
139 wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
140
141 // Constructor for generalised creation from data
142 wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1);
143
144 // If depth is omitted, will create a bitmap compatible with the display
145 wxBitmap(int width, int height, int depth = -1);
146
147 // Convert from wxImage:
148 wxBitmap(const wxImage& image, int depth = -1);
149
150 ~wxBitmap();
151
152 wxImage ConvertToImage() const;
153
154 // get the given part of bitmap
155 wxBitmap GetSubBitmap( const wxRect& rect ) const;
156
157 virtual bool Create(int width, int height, int depth = -1);
158 virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1);
159 virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
160 virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
161
162 // copies the contents and mask of the given (colour) icon to the bitmap
163 virtual bool CopyFromIcon(const wxIcon& icon);
164
165 bool Ok() const;
166 int GetWidth() const;
167 int GetHeight() const;
168 int GetDepth() const;
169 int GetQuality() const;
170 void SetWidth(int w);
171 void SetHeight(int h);
172 void SetDepth(int d);
173 void SetQuality(int q);
174 void SetOk(bool isOk);
175
176 wxPalette* GetPalette() const;
177 void SetPalette(const wxPalette& palette);
178
179 wxMask *GetMask() const;
180 void SetMask(wxMask *mask) ;
181
182 int GetBitmapType() const;
183
184 inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
185 inline bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
186 inline bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
187
188 static void InitStandardHandlers();
189protected:
190
191 // TODO: Implementation
192public:
193// void SetHBITMAP(WXHBITMAP bmp);
194// WXHBITMAP GetHBITMAP() const;
195
196// WXHMETAFILE GetPict() const;
197
198 bool FreeResource(bool force = FALSE);
199};
200#endif
201 // _WX_BITMAP_H_