]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/bitmap.h
fixed doxygen warnings produced by the ifacecheck fixes
[wxWidgets.git] / include / wx / os2 / bitmap.h
CommitLineData
0e320a79 1/////////////////////////////////////////////////////////////////////////////
3b9e3455 2// Name: wx/os2/bitmap.h
0e320a79 3// Purpose: wxBitmap class
d88de032 4// Author: David Webster
0e320a79 5// Modified by:
3b9e3455 6// Created: 11/28/99
0e320a79 7// RCS-ID: $Id$
d88de032 8// Copyright: (c) David Webster
65571936 9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_BITMAP_H_
13#define _WX_BITMAP_H_
14
58b16424 15#include "wx/os2/private.h"
3b9e3455 16#include "wx/os2/gdiimage.h"
0e320a79
DW
17#include "wx/gdicmn.h"
18#include "wx/palette.h"
19
b5dbe15d
VS
20class WXDLLIMPEXP_FWD_CORE wxDC;
21class WXDLLIMPEXP_FWD_CORE wxControl;
22class WXDLLIMPEXP_FWD_CORE wxBitmap;
23class WXDLLIMPEXP_FWD_CORE wxBitmapHandler;
24class WXDLLIMPEXP_FWD_CORE wxIcon;
25class WXDLLIMPEXP_FWD_CORE wxMask;
26class WXDLLIMPEXP_FWD_CORE wxCursor;
27class WXDLLIMPEXP_FWD_CORE wxControl;
28class WXDLLIMPEXP_FWD_CORE wxImage;
6b5c2d52 29class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
0e320a79 30
3b9e3455
DW
31// ----------------------------------------------------------------------------
32// Bitmap data
33//
34// NB: this class is private, but declared here to make it possible inline
35// wxBitmap functions accessing it
36// ----------------------------------------------------------------------------
0e320a79 37
53a2db12 38class WXDLLIMPEXP_CORE wxBitmapRefData : public wxGDIImageRefData
0e320a79 39{
0e320a79
DW
40public:
41 wxBitmapRefData();
cd7ff808 42 wxBitmapRefData(const wxBitmapRefData &tocopy);
3b9e3455
DW
43 virtual ~wxBitmapRefData() { Free(); }
44
45 virtual void Free();
0e320a79
DW
46
47public:
3b9e3455
DW
48 int m_nNumColors;
49 wxPalette m_vBitmapPalette;
50 int m_nQuality;
0e320a79 51
3b9e3455
DW
52 // OS2-specific
53 // ------------
0e320a79 54
3b9e3455 55 wxDC* m_pSelectedInto;
3b9e3455 56
8bb6da4a
DW
57 //
58 // Optional mask for transparent drawing
59 //
3b9e3455 60 wxMask* m_pBitmapMask;
8bb6da4a 61}; // end of CLASS wxBitmapRefData
0e320a79 62
3b9e3455
DW
63// ----------------------------------------------------------------------------
64// wxBitmap: a mono or colour bitmap
65// ----------------------------------------------------------------------------
0e320a79 66
53a2db12 67class WXDLLIMPEXP_CORE wxBitmap : public wxGDIImage
0e320a79 68{
0e320a79 69public:
3b9e3455
DW
70 // default ctor creates an invalid bitmap, you must Create() it later
71 wxBitmap() { Init(); }
72
73 // Copy constructors
74 inline wxBitmap(const wxBitmap& rBitmap)
f8855e47
VZ
75 : wxGDIImage(rBitmap)
76 {
77 Init();
78 SetHandle(rBitmap.GetHandle());
79 }
3b9e3455
DW
80
81 // Initialize with raw data
82 wxBitmap( const char bits[]
83 ,int nWidth
84 ,int nHeight
85 ,int nDepth = 1
86 );
87
88 // Initialize with XPM data
452418c4 89 wxBitmap(const char* const* bits);
459f812b 90#ifdef wxNEEDS_CHARPP
4a4bf7ee
SN
91 // needed for old GCC
92 wxBitmap(char** data)
93 {
5c33522f 94 *this = wxBitmap(const_cast<const char* const*>(data));
4a4bf7ee
SN
95 }
96#endif
3b9e3455 97
b6f4144e
DW
98 // Load a resource
99 wxBitmap( int nId
cbea3ec6 100 ,wxBitmapType lType = wxBITMAP_DEFAULT_TYPE
3b9e3455
DW
101 );
102
b6f4144e
DW
103 // For compatiability with other ports, under OS/2 does same as default ctor
104 inline wxBitmap( const wxString& WXUNUSED(rFilename)
6b5c2d52 105 ,wxBitmapType WXUNUSED(lType)
b6f4144e
DW
106 )
107 { Init(); }
3b9e3455 108 // New constructor for generalised creation from data
452418c4 109 wxBitmap( const void* pData
6b5c2d52 110 ,wxBitmapType lType
3b9e3455
DW
111 ,int nWidth
112 ,int nHeight
113 ,int nDepth = 1
114 );
115
116 // If depth is omitted, will create a bitmap compatible with the display
7e1e6965 117 wxBitmap( int nWidth, int nHeight, int nDepth = -1 );
3b9e3455 118
98edf626 119 wxBitmap( const wxImage& image, int depth = -1 )
fd859211
VS
120 { (void)CreateFromImage(image, depth); }
121
3b9e3455
DW
122 // we must have this, otherwise icons are silently copied into bitmaps using
123 // the copy ctor but the resulting bitmap is invalid!
124 inline wxBitmap(const wxIcon& rIcon)
125 { Init(); CopyFromIcon(rIcon); }
126
3b9e3455
DW
127 wxBitmap& operator=(const wxIcon& rIcon)
128 {
129 (void)CopyFromIcon(rIcon);
130
131 return(*this);
132 }
133
134 wxBitmap& operator=(const wxCursor& rCursor)
135 {
136 (void)CopyFromCursor(rCursor);
137 return (*this);
138 }
139
140 virtual ~wxBitmap();
141
98edf626 142 wxImage ConvertToImage() const;
fd859211 143
341366c6
DW
144 // get the given part of bitmap
145 wxBitmap GetSubBitmap(const wxRect& rRect) const;
146
3b9e3455
DW
147 // copies the contents and mask of the given (colour) icon to the bitmap
148 bool CopyFromIcon(const wxIcon& rIcon);
149
150 // copies the contents and mask of the given cursor to the bitmap
151 bool CopyFromCursor(const wxCursor& rCursor);
152
153 virtual bool Create( int nWidth
154 ,int nHeight
155 ,int nDepth = -1
156 );
452418c4 157 virtual bool Create( const void* pData
6b5c2d52 158 ,wxBitmapType lType
3b9e3455
DW
159 ,int nWidth
160 ,int nHeight
161 ,int nDepth = 1
162 );
b6f4144e 163 virtual bool LoadFile( int nId
cbea3ec6 164 ,wxBitmapType lType = wxBITMAP_DEFAULT_TYPE
3b9e3455 165 );
c90c3400 166 virtual bool LoadFile( const wxString& rName
cbea3ec6 167 ,wxBitmapType lType = wxBITMAP_DEFAULT_TYPE
c90c3400 168 );
3b9e3455 169 virtual bool SaveFile( const wxString& rName
6b5c2d52 170 ,wxBitmapType lType
3b9e3455
DW
171 ,const wxPalette* pCmap = NULL
172 );
173
174 inline wxBitmapRefData* GetBitmapData() const
175 { return (wxBitmapRefData *)m_refData; }
176
6b5c2d52
SN
177 // raw bitmap access support functions
178 void *GetRawData(wxPixelDataBase& data, int bpp);
179 void UngetRawData(wxPixelDataBase& data);
180
3b9e3455 181 inline int GetQuality() const
58b16424 182 { return (GetBitmapData() ? GetBitmapData()->m_nQuality : 0); }
3b9e3455
DW
183
184 void SetQuality(int nQ);
185
186 wxPalette* GetPalette() const
58b16424 187 { return (GetBitmapData() ? (& GetBitmapData()->m_vBitmapPalette) : (wxPalette*) NULL); }
3b9e3455
DW
188
189 void SetPalette(const wxPalette& rPalette);
190
191 inline wxMask* GetMask() const
58b16424 192 { return (GetBitmapData() ? GetBitmapData()->m_pBitmapMask : (wxMask*) NULL); }
3b9e3455
DW
193
194 void SetMask(wxMask* pMask) ;
195
3b9e3455
DW
196 // Implementation
197public:
58b16424
DW
198 inline void SetHBITMAP(WXHBITMAP hBmp)
199 { SetHandle((WXHANDLE)hBmp); }
3b9e3455
DW
200
201 inline WXHBITMAP GetHBITMAP() const
202 { return (WXHBITMAP)GetHandle(); }
203
204 inline void SetSelectedInto(wxDC* pDc)
58b16424 205 { if (GetBitmapData()) GetBitmapData()->m_pSelectedInto = pDc; }
3b9e3455
DW
206
207 inline wxDC* GetSelectedInto() const
58b16424 208 { return (GetBitmapData() ? GetBitmapData()->m_pSelectedInto : (wxDC*) NULL); }
3b9e3455 209
79c09341 210 inline bool IsMono(void) const { return m_bIsMono; }
1759c491 211
4f72fe4f 212 // An OS/2 version that probably doesn't do anything like the msw version
3b9e3455 213 wxBitmap GetBitmapForDC(wxDC& rDc) const;
0e320a79 214
3b9e3455
DW
215protected:
216 // common part of all ctors
217 void Init();
0e320a79 218
3b9e3455
DW
219 inline virtual wxGDIImageRefData* CreateData() const
220 { return new wxBitmapRefData; }
0e320a79 221
fd859211 222 bool CreateFromImage(const wxImage& image, int depth);
341366c6 223
8f884a0d 224 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
cd7ff808 225
3b9e3455
DW
226private:
227 bool CopyFromIconOrCursor(const wxGDIImage& rIcon);
0e320a79 228
79c09341 229 bool m_bIsMono;
3b9e3455 230 DECLARE_DYNAMIC_CLASS(wxBitmap)
341366c6 231}; // end of CLASS wxBitmap
d88de032 232
3b9e3455
DW
233// ----------------------------------------------------------------------------
234// wxMask: a mono bitmap used for drawing bitmaps transparently.
235// ----------------------------------------------------------------------------
0e320a79 236
53a2db12 237class WXDLLIMPEXP_CORE wxMask : public wxObject
3b9e3455
DW
238{
239public:
240 wxMask();
cd7ff808 241 wxMask( const wxMask& tocopy);
3b9e3455
DW
242
243 // Construct a mask from a bitmap and a colour indicating the transparent
244 // area
245 wxMask( const wxBitmap& rBitmap
246 ,const wxColour& rColour
247 );
248
249 // Construct a mask from a bitmap and a palette index indicating the
250 // transparent area
251 wxMask( const wxBitmap& rBitmap
252 ,int nPaletteIndex
253 );
254
255 // Construct a mask from a mono bitmap (copies the bitmap).
256 wxMask(const wxBitmap& rBitmap);
257
258 // construct a mask from the givne bitmap handle
259 wxMask(WXHBITMAP hBmp)
260 { m_hMaskBitmap = hBmp; }
261
262 virtual ~wxMask();
263
264 bool Create( const wxBitmap& bitmap
265 ,const wxColour& rColour
266 );
267 bool Create( const wxBitmap& rBitmap
268 ,int nPaletteIndex
269 );
270 bool Create(const wxBitmap& rBitmap);
271
272 // Implementation
273 WXHBITMAP GetMaskBitmap() const
274 { return m_hMaskBitmap; }
275 void SetMaskBitmap(WXHBITMAP hBmp)
276 { m_hMaskBitmap = hBmp; }
0e320a79 277
0e320a79 278protected:
3b9e3455
DW
279 WXHBITMAP m_hMaskBitmap;
280 DECLARE_DYNAMIC_CLASS(wxMask)
8bb6da4a 281}; // end of CLASS wxMask
3b9e3455
DW
282
283// ----------------------------------------------------------------------------
284// wxBitmapHandler is a class which knows how to load/save bitmaps to/from file
285// ----------------------------------------------------------------------------
0e320a79 286
53a2db12 287class WXDLLIMPEXP_CORE wxBitmapHandler : public wxGDIImageHandler
3b9e3455 288{
0e320a79 289public:
3b9e3455
DW
290 inline wxBitmapHandler()
291 { m_lType = wxBITMAP_TYPE_INVALID; }
292
293 inline wxBitmapHandler( const wxString& rName
294 ,const wxString& rExt
e86f2cc8 295 ,wxBitmapType lType
3b9e3455
DW
296 )
297 : wxGDIImageHandler( rName
298 ,rExt
299 ,lType)
300 {
301 }
302
303 // keep wxBitmapHandler derived from wxGDIImageHandler compatible with the
304 // old class which worked only with bitmaps
305 virtual bool Create( wxBitmap* pBitmap
452418c4 306 ,const void* pData
e86f2cc8 307 ,wxBitmapType lType
3b9e3455
DW
308 ,int nWidth
309 ,int nHeight
310 ,int nDepth = 1
311 );
312 virtual bool LoadFile( wxBitmap* pBitmap
b6f4144e 313 ,int nId
e86f2cc8 314 ,wxBitmapType lType
3b9e3455
DW
315 ,int nDesiredWidth
316 ,int nDesiredHeight
317 );
c90c3400
SN
318 virtual bool LoadFile( wxBitmap* pBitmap
319 ,const wxString& rName
e86f2cc8 320 ,wxBitmapType lType
c90c3400
SN
321 ,int nDesiredWidth
322 ,int nDesiredHeight
323 );
3b9e3455
DW
324 virtual bool SaveFile( wxBitmap* pBitmap
325 ,const wxString& rName
e86f2cc8 326 ,wxBitmapType lType
3b9e3455 327 ,const wxPalette* pPalette = NULL
e86f2cc8 328 ) const;
3b9e3455
DW
329
330 virtual bool Create( wxGDIImage* pImage
452418c4 331 ,const void* pData
6b5c2d52 332 ,wxBitmapType lFlags
3b9e3455
DW
333 ,int nWidth
334 ,int nHeight
335 ,int nDepth = 1
336 );
337 virtual bool Load( wxGDIImage* pImage
b6f4144e 338 ,int nId
6b5c2d52 339 ,wxBitmapType lFlags
3b9e3455
DW
340 ,int nDesiredWidth
341 ,int nDesiredHeight
342 );
6b5c2d52
SN
343 virtual bool Save( const wxGDIImage* pImage
344 ,const wxString& rName
345 ,wxBitmapType lType
e86f2cc8 346 ) const;
3b9e3455 347private:
7e1e6965
WS
348 inline virtual bool Load( wxGDIImage* WXUNUSED(pImage)
349 ,const wxString& WXUNUSED(rName)
4b3f61d1 350 ,WXHANDLE WXUNUSED(hPs)
6b5c2d52 351 ,wxBitmapType WXUNUSED(lFlags)
7e1e6965
WS
352 ,int WXUNUSED(nDesiredWidth)
353 ,int WXUNUSED(nDesiredHeight)
b6f4144e 354 )
7e1e6965 355 { return false; }
3b9e3455 356 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
8bb6da4a 357}; // end of CLASS wxBitmapHandler
3b9e3455 358
0e320a79
DW
359#endif
360 // _WX_BITMAP_H_