]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/bitmap.cpp
check that the version of __sync_sub_and_fetch that returns a value is supported...
[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
48#ifdef wxHAVE_RAW_BITMAP
49#include "wx/rawbmp.h"
50#endif
51
52// missing from mingw32 header
53#ifndef CLR_INVALID
54 #define CLR_INVALID ((COLORREF)-1)
55#endif // no CLR_INVALID
56
57// ----------------------------------------------------------------------------
58// Bitmap data
59// ----------------------------------------------------------------------------
60
61class WXDLLEXPORT wxBitmapRefData : public wxGDIImageRefData
62{
63public:
64 wxBitmapRefData();
65 virtual ~wxBitmapRefData() { Free(); }
66
67 virtual void Free();
68
69 // set the mask object to use as the mask, we take ownership of it
70 void SetMask(wxMask *mask)
71 {
72 delete m_bitmapMask;
73 m_bitmapMask = mask;
74 }
75
76 // return the mask
77 wxMask *GetMask() const { return m_bitmapMask; }
78
79public:
80#if wxUSE_PALETTE
81 wxPalette m_bitmapPalette;
82#endif // wxUSE_PALETTE
83
84#ifdef __WXDEBUG__
85 wxDC *m_selectedInto;
86#endif // __WXDEBUG__
87
88#if wxUSE_WXDIB
89 wxDIB *m_dib;
90#endif
91
92 bool m_hasAlpha;
93
94 bool m_isDIB;
95
96private:
97 wxMask *m_bitmapMask;
98
99 DECLARE_NO_COPY_CLASS(wxBitmapRefData)
100};
101
102// ----------------------------------------------------------------------------
103// macros
104// ----------------------------------------------------------------------------
105
106IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
107IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
108
109IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
110
111// ============================================================================
112// implementation
113// ============================================================================
114
115// ----------------------------------------------------------------------------
116// helper functions
117// ----------------------------------------------------------------------------
118
119#if !wxUSE_WXDIB
120 #define NEVER_USE_DIB
121#else
122 static inline bool wxShouldCreateDIB(int w, int h, int d, WXHDC hdc)
123 {
124 // here is the logic:
125 //
126 // (a) if hdc is specified, the caller explicitly wants DDB
127 // (b) otherwise, create a DIB if depth >= 24 (we don't support 16bpp
128 // or less DIBs anyhow)
129 // (c) finally, create DIBs under Win9x even if the depth hasn't been
130 // explicitly specified but the current display depth is 24 or
131 // more and the image is "big", i.e. > 16Mb which is the
132 // theoretical limit for DDBs under Win9x
133 //
134 // consequences (all of which seem to make sense):
135 //
136 // (i) by default, DDBs are created (depth == -1 usually)
137 // (ii) DIBs can be created by explicitly specifying the depth
138 // (iii) using a DC always forces creating a DDB
139 return !hdc &&
140 (d >= 24 ||
141 (d == -1 &&
142 wxDIB::GetLineSize(w, wxDisplayDepth())*h > 16*1024*1024));
143 }
144
145 #define SOMETIMES_USE_DIB
146#endif // different DIB usage scenarious
147
148// ----------------------------------------------------------------------------
149// wxBitmapRefData
150// ----------------------------------------------------------------------------
151
152wxBitmapRefData::wxBitmapRefData()
153{
154#ifdef __WXDEBUG__
155 m_selectedInto = NULL;
156#endif
157 m_bitmapMask = NULL;
158
159 m_hBitmap = (WXHBITMAP) NULL;
160#if wxUSE_WXDIB
161 m_dib = NULL;
162#endif
163
164 m_isDIB =
4055ed82 165 m_hasAlpha = false;
ffecfa5a
JS
166}
167
168void wxBitmapRefData::Free()
169{
170}
171
172// ----------------------------------------------------------------------------
173// wxBitmap creation
174// ----------------------------------------------------------------------------
175
176// this function should be called from all wxBitmap ctors
177void wxBitmap::Init()
178{
179}
180
181wxGDIImageRefData *wxBitmap::CreateData() const
182{
183 return NULL;
184}
185
ffecfa5a
JS
186bool wxBitmap::CopyFromCursor(const wxCursor& cursor)
187{
4055ed82 188 return false;
ffecfa5a
JS
189}
190
191bool wxBitmap::CopyFromIcon(const wxIcon& icon)
192{
4055ed82 193 return false;
ffecfa5a
JS
194}
195
196#ifndef NEVER_USE_DIB
197
198bool wxBitmap::CopyFromDIB(const wxDIB& dib)
199{
4055ed82 200 return false:
ffecfa5a
JS
201}
202
203#endif // NEVER_USE_DIB
204
205wxBitmap::~wxBitmap()
206{
207}
208
209wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
210{
211 Init();
212}
213
ffecfa5a
JS
214wxBitmap::wxBitmap(int w, int h, int d)
215{
216}
217
218wxBitmap::wxBitmap(int w, int h, const wxDC& dc)
219{
220}
221
452418c4 222wxBitmap::wxBitmap(const void* data, long type, int width, int height, int depth)
ffecfa5a
JS
223{
224}
225
226wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type)
227{
228}
229
230bool wxBitmap::Create(int width, int height, int depth)
231{
4055ed82 232 return false;
ffecfa5a
JS
233}
234
235bool wxBitmap::Create(int width, int height, const wxDC& dc)
236{
4055ed82 237 return false;
ffecfa5a
JS
238}
239
240bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc)
241{
4055ed82 242 return false;
ffecfa5a
JS
243}
244
245#if wxUSE_IMAGE
246
247// ----------------------------------------------------------------------------
248// wxImage to/from conversions
249// ----------------------------------------------------------------------------
250
251#if wxUSE_WXDIB
252
253bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
254{
4055ed82 255 return false;
ffecfa5a
JS
256}
257
258bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc)
259{
4055ed82 260 return false;
ffecfa5a
JS
261}
262
263bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc)
264{
4055ed82 265 return false;
ffecfa5a
JS
266}
267
268wxImage wxBitmap::ConvertToImage() const
269{
270 wxImage image;
271 return image;
272}
273
274#endif // wxUSE_WXDIB
275
276#endif // wxUSE_IMAGE
277
278// ----------------------------------------------------------------------------
279// loading and saving bitmaps
280// ----------------------------------------------------------------------------
281
282bool wxBitmap::LoadFile(const wxString& filename, long type)
283{
4055ed82 284 return false;
ffecfa5a
JS
285}
286
452418c4 287bool wxBitmap::Create(const void* data, long type, int width, int height, int depth)
ffecfa5a 288{
4055ed82 289 return false;
ffecfa5a
JS
290}
291
292bool wxBitmap::SaveFile(const wxString& filename,
293 int type,
294 const wxPalette *palette)
295{
4055ed82 296 return false;
ffecfa5a
JS
297}
298
299// ----------------------------------------------------------------------------
300// sub bitmap extraction
301// ----------------------------------------------------------------------------
302
303wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
304{
305 wxBitmap ret( 0, 0 );
306 return ret;
307}
308
309// ----------------------------------------------------------------------------
310// wxBitmap accessors
311// ----------------------------------------------------------------------------
312
313#if wxUSE_PALETTE
314wxPalette* wxBitmap::GetPalette() const
315{
316 return (wxPalette *) NULL;
317}
318#endif
319
320wxMask *wxBitmap::GetMask() const
321{
322 return (wxMask *) NULL;
323}
324
325#ifdef __WXDEBUG__
326
327wxDC *wxBitmap::GetSelectedInto() const
328{
329 return (wxDC *) NULL;
330}
331
332#endif
333
ffecfa5a
JS
334bool wxBitmap::HasAlpha() const
335{
4055ed82 336 return false;
ffecfa5a
JS
337}
338
339// ----------------------------------------------------------------------------
340// wxBitmap setters
341// ----------------------------------------------------------------------------
342
343#ifdef __WXDEBUG__
344
345void wxBitmap::SetSelectedInto(wxDC *dc)
346{
347}
348
349#endif
350
351#if wxUSE_PALETTE
352
353void wxBitmap::SetPalette(const wxPalette& palette)
354{
355}
356
357#endif // wxUSE_PALETTE
358
359void wxBitmap::SetMask(wxMask *mask)
360{
361}
362
ffecfa5a
JS
363// ----------------------------------------------------------------------------
364// raw bitmap access support
365// ----------------------------------------------------------------------------
366
367#ifdef wxHAVE_RAW_BITMAP
368void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
369{
370 return NULL;
371}
372
373void wxBitmap::UngetRawData(wxPixelDataBase& dataBase)
374{
375 return;
376}
377#endif // #ifdef wxHAVE_RAW_BITMAP
378
379// ----------------------------------------------------------------------------
380// wxMask
381// ----------------------------------------------------------------------------
382
383wxMask::wxMask()
384{
385 m_maskBitmap = 0;
386}
387
388// Construct a mask from a bitmap and a colour indicating
389// the transparent area
390wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
391{
392}
393
394// Construct a mask from a bitmap and a palette index indicating
395// the transparent area
396wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
397{
398}
399
400// Construct a mask from a mono bitmap (copies the bitmap).
401wxMask::wxMask(const wxBitmap& bitmap)
402{
403}
404
405wxMask::~wxMask()
406{
407}
408
409// Create a mask from a mono bitmap (copies the bitmap).
410bool wxMask::Create(const wxBitmap& bitmap)
411{
4055ed82 412 return false;
ffecfa5a
JS
413}
414
415// Create a mask from a bitmap and a palette index indicating
416// the transparent area
417bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
418{
4055ed82 419 return false;
ffecfa5a
JS
420}
421
422// Create a mask from a bitmap and a colour indicating
423// the transparent area
424bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
425{
4055ed82 426 return false;
ffecfa5a
JS
427}
428
429// ----------------------------------------------------------------------------
430// wxBitmapHandler
431// ----------------------------------------------------------------------------
432
433bool wxBitmapHandler::Create(wxGDIImage *image,
452418c4 434 const void* data,
ffecfa5a
JS
435 long flags,
436 int width, int height, int depth)
437{
4055ed82 438 return false;
ffecfa5a
JS
439}
440
441bool wxBitmapHandler::Load(wxGDIImage *image,
442 const wxString& name,
443 long flags,
444 int width, int height)
445{
4055ed82 446 return false;
ffecfa5a
JS
447}
448
449bool wxBitmapHandler::Save(wxGDIImage *image,
450 const wxString& name,
451 int type)
452{
4055ed82 453 return false;
ffecfa5a
JS
454}
455
456bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap),
452418c4 457 const void* WXUNUSED(data),
ffecfa5a
JS
458 long WXUNUSED(type),
459 int WXUNUSED(width),
460 int WXUNUSED(height),
461 int WXUNUSED(depth))
462{
4055ed82 463 return false;
ffecfa5a
JS
464}
465
466bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap),
467 const wxString& WXUNUSED(name),
468 long WXUNUSED(type),
469 int WXUNUSED(desiredWidth),
470 int WXUNUSED(desiredHeight))
471{
4055ed82 472 return false;
ffecfa5a
JS
473}
474
475bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap),
476 const wxString& WXUNUSED(name),
477 int WXUNUSED(type),
478 const wxPalette *WXUNUSED(palette))
479{
4055ed82 480 return false;
ffecfa5a 481}