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