]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/bitmap.cpp
Add some version checks to help compiling on OSX.
[wxWidgets.git] / src / palmos / bitmap.cpp
CommitLineData
ffecfa5a 1////////////////////////////////////////////////////////////////////////////
e2731512 2// Name: src/palmos/bitmap.cpp
ffecfa5a 3// Purpose: wxBitmap
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/08/04
e2731512 7// RCS-ID: $Id$
ffecfa5a
JS
8// Copyright: (c) William Osborne
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
ffecfa5a
JS
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
e4db172a
WS
27#include "wx/bitmap.h"
28
ffecfa5a
JS
29#ifndef WX_PRECOMP
30 #include <stdio.h>
31
32 #include "wx/list.h"
33 #include "wx/utils.h"
34 #include "wx/app.h"
35 #include "wx/palette.h"
36 #include "wx/dcmemory.h"
ffecfa5a 37 #include "wx/icon.h"
e4db172a 38 #include "wx/log.h"
155ecd4c 39 #include "wx/image.h"
ffecfa5a
JS
40#endif
41
ffecfa5a
JS
42#if wxUSE_WXDIB
43#include "wx/palmos/dib.h"
44#endif
45
ffecfa5a
JS
46#include "wx/xpmdecod.h"
47
ffecfa5a
JS
48// missing from mingw32 header
49#ifndef CLR_INVALID
50 #define CLR_INVALID ((COLORREF)-1)
51#endif // no CLR_INVALID
52
53// ----------------------------------------------------------------------------
54// Bitmap data
55// ----------------------------------------------------------------------------
56
57class WXDLLEXPORT wxBitmapRefData : public wxGDIImageRefData
58{
59public:
60 wxBitmapRefData();
61 virtual ~wxBitmapRefData() { Free(); }
62
63 virtual void Free();
64
65 // set the mask object to use as the mask, we take ownership of it
66 void SetMask(wxMask *mask)
67 {
68 delete m_bitmapMask;
69 m_bitmapMask = mask;
70 }
71
72 // return the mask
73 wxMask *GetMask() const { return m_bitmapMask; }
74
75public:
76#if wxUSE_PALETTE
77 wxPalette m_bitmapPalette;
78#endif // wxUSE_PALETTE
79
ffecfa5a
JS
80#if wxUSE_WXDIB
81 wxDIB *m_dib;
82#endif
83
84 bool m_hasAlpha;
85
86 bool m_isDIB;
87
88private:
89 wxMask *m_bitmapMask;
90
c0c133e1 91 wxDECLARE_NO_COPY_CLASS(wxBitmapRefData);
ffecfa5a
JS
92};
93
94// ----------------------------------------------------------------------------
95// macros
96// ----------------------------------------------------------------------------
97
98IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
99IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
100
101IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
102
103// ============================================================================
104// implementation
105// ============================================================================
106
107// ----------------------------------------------------------------------------
108// helper functions
109// ----------------------------------------------------------------------------
110
111#if !wxUSE_WXDIB
112 #define NEVER_USE_DIB
113#else
114 static inline bool wxShouldCreateDIB(int w, int h, int d, WXHDC hdc)
115 {
116 // here is the logic:
117 //
118 // (a) if hdc is specified, the caller explicitly wants DDB
119 // (b) otherwise, create a DIB if depth >= 24 (we don't support 16bpp
120 // or less DIBs anyhow)
121 // (c) finally, create DIBs under Win9x even if the depth hasn't been
122 // explicitly specified but the current display depth is 24 or
123 // more and the image is "big", i.e. > 16Mb which is the
124 // theoretical limit for DDBs under Win9x
125 //
126 // consequences (all of which seem to make sense):
127 //
128 // (i) by default, DDBs are created (depth == -1 usually)
129 // (ii) DIBs can be created by explicitly specifying the depth
130 // (iii) using a DC always forces creating a DDB
131 return !hdc &&
132 (d >= 24 ||
133 (d == -1 &&
134 wxDIB::GetLineSize(w, wxDisplayDepth())*h > 16*1024*1024));
135 }
136
137 #define SOMETIMES_USE_DIB
138#endif // different DIB usage scenarious
139
140// ----------------------------------------------------------------------------
141// wxBitmapRefData
142// ----------------------------------------------------------------------------
143
144wxBitmapRefData::wxBitmapRefData()
145{
ffecfa5a
JS
146 m_bitmapMask = NULL;
147
148 m_hBitmap = (WXHBITMAP) NULL;
149#if wxUSE_WXDIB
150 m_dib = NULL;
151#endif
152
153 m_isDIB =
4055ed82 154 m_hasAlpha = false;
ffecfa5a
JS
155}
156
157void wxBitmapRefData::Free()
158{
159}
160
161// ----------------------------------------------------------------------------
162// wxBitmap creation
163// ----------------------------------------------------------------------------
164
165// this function should be called from all wxBitmap ctors
166void wxBitmap::Init()
167{
168}
169
170wxGDIImageRefData *wxBitmap::CreateData() const
171{
172 return NULL;
173}
174
ffecfa5a
JS
175bool wxBitmap::CopyFromCursor(const wxCursor& cursor)
176{
4055ed82 177 return false;
ffecfa5a
JS
178}
179
180bool wxBitmap::CopyFromIcon(const wxIcon& icon)
181{
4055ed82 182 return false;
ffecfa5a
JS
183}
184
185#ifndef NEVER_USE_DIB
186
187bool wxBitmap::CopyFromDIB(const wxDIB& dib)
188{
4055ed82 189 return false:
ffecfa5a
JS
190}
191
192#endif // NEVER_USE_DIB
193
ffecfa5a
JS
194wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
195{
196 Init();
197}
198
ffecfa5a
JS
199wxBitmap::wxBitmap(int w, int h, const wxDC& dc)
200{
201}
202
452418c4 203wxBitmap::wxBitmap(const void* data, long type, int width, int height, int depth)
ffecfa5a
JS
204{
205}
206
207wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type)
208{
209}
210
211bool wxBitmap::Create(int width, int height, int depth)
212{
4055ed82 213 return false;
ffecfa5a
JS
214}
215
216bool wxBitmap::Create(int width, int height, const wxDC& dc)
217{
4055ed82 218 return false;
ffecfa5a
JS
219}
220
221bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc)
222{
4055ed82 223 return false;
ffecfa5a
JS
224}
225
226#if wxUSE_IMAGE
227
228// ----------------------------------------------------------------------------
229// wxImage to/from conversions
230// ----------------------------------------------------------------------------
231
232#if wxUSE_WXDIB
233
234bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
235{
4055ed82 236 return false;
ffecfa5a
JS
237}
238
239bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc)
240{
4055ed82 241 return false;
ffecfa5a
JS
242}
243
244bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc)
245{
4055ed82 246 return false;
ffecfa5a
JS
247}
248
249wxImage wxBitmap::ConvertToImage() const
250{
251 wxImage image;
252 return image;
253}
254
255#endif // wxUSE_WXDIB
256
257#endif // wxUSE_IMAGE
258
259// ----------------------------------------------------------------------------
260// loading and saving bitmaps
261// ----------------------------------------------------------------------------
262
263bool wxBitmap::LoadFile(const wxString& filename, long type)
264{
4055ed82 265 return false;
ffecfa5a
JS
266}
267
452418c4 268bool wxBitmap::Create(const void* data, long type, int width, int height, int depth)
ffecfa5a 269{
4055ed82 270 return false;
ffecfa5a
JS
271}
272
273bool wxBitmap::SaveFile(const wxString& filename,
274 int type,
275 const wxPalette *palette)
276{
4055ed82 277 return false;
ffecfa5a
JS
278}
279
280// ----------------------------------------------------------------------------
281// sub bitmap extraction
282// ----------------------------------------------------------------------------
283
284wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
285{
286 wxBitmap ret( 0, 0 );
287 return ret;
288}
289
290// ----------------------------------------------------------------------------
291// wxBitmap accessors
292// ----------------------------------------------------------------------------
293
294#if wxUSE_PALETTE
295wxPalette* wxBitmap::GetPalette() const
296{
d3b9f782 297 return NULL;
ffecfa5a
JS
298}
299#endif
300
301wxMask *wxBitmap::GetMask() const
302{
d3b9f782 303 return NULL;
ffecfa5a
JS
304}
305
ffecfa5a
JS
306bool wxBitmap::HasAlpha() const
307{
4055ed82 308 return false;
ffecfa5a
JS
309}
310
311// ----------------------------------------------------------------------------
312// wxBitmap setters
313// ----------------------------------------------------------------------------
314
ffecfa5a
JS
315#if wxUSE_PALETTE
316
317void wxBitmap::SetPalette(const wxPalette& palette)
318{
319}
320
321#endif // wxUSE_PALETTE
322
323void wxBitmap::SetMask(wxMask *mask)
324{
325}
326
ffecfa5a
JS
327// ----------------------------------------------------------------------------
328// raw bitmap access support
329// ----------------------------------------------------------------------------
330
ffecfa5a
JS
331// ----------------------------------------------------------------------------
332// wxMask
333// ----------------------------------------------------------------------------
334
335wxMask::wxMask()
336{
337 m_maskBitmap = 0;
338}
339
340// Construct a mask from a bitmap and a colour indicating
341// the transparent area
342wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
343{
344}
345
346// Construct a mask from a bitmap and a palette index indicating
347// the transparent area
348wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
349{
350}
351
352// Construct a mask from a mono bitmap (copies the bitmap).
353wxMask::wxMask(const wxBitmap& bitmap)
354{
355}
356
357wxMask::~wxMask()
358{
359}
360
361// Create a mask from a mono bitmap (copies the bitmap).
362bool wxMask::Create(const wxBitmap& bitmap)
363{
4055ed82 364 return false;
ffecfa5a
JS
365}
366
367// Create a mask from a bitmap and a palette index indicating
368// the transparent area
369bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
370{
4055ed82 371 return false;
ffecfa5a
JS
372}
373
374// Create a mask from a bitmap and a colour indicating
375// the transparent area
376bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
377{
4055ed82 378 return false;
ffecfa5a
JS
379}
380
381// ----------------------------------------------------------------------------
382// wxBitmapHandler
383// ----------------------------------------------------------------------------
384
385bool wxBitmapHandler::Create(wxGDIImage *image,
452418c4 386 const void* data,
ffecfa5a
JS
387 long flags,
388 int width, int height, int depth)
389{
4055ed82 390 return false;
ffecfa5a
JS
391}
392
393bool wxBitmapHandler::Load(wxGDIImage *image,
394 const wxString& name,
395 long flags,
396 int width, int height)
397{
4055ed82 398 return false;
ffecfa5a
JS
399}
400
401bool wxBitmapHandler::Save(wxGDIImage *image,
402 const wxString& name,
403 int type)
404{
4055ed82 405 return false;
ffecfa5a
JS
406}
407
408bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap),
452418c4 409 const void* WXUNUSED(data),
ffecfa5a
JS
410 long WXUNUSED(type),
411 int WXUNUSED(width),
412 int WXUNUSED(height),
413 int WXUNUSED(depth))
414{
4055ed82 415 return false;
ffecfa5a
JS
416}
417
418bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap),
419 const wxString& WXUNUSED(name),
420 long WXUNUSED(type),
421 int WXUNUSED(desiredWidth),
422 int WXUNUSED(desiredHeight))
423{
4055ed82 424 return false;
ffecfa5a
JS
425}
426
427bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap),
428 const wxString& WXUNUSED(name),
429 int WXUNUSED(type),
430 const wxPalette *WXUNUSED(palette))
431{
4055ed82 432 return false;
ffecfa5a 433}