]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/bitmap.cpp
compilation fix for GTK+ 2.0
[wxWidgets.git] / src / palmos / bitmap.cpp
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: bitmap.cpp
3 // Purpose: wxBitmap
4 // Author: William Osborne
5 // Modified by:
6 // Created: 10/08/04
7 // RCS-ID: $Id:
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
65 class WXDLLEXPORT wxBitmapRefData : public wxGDIImageRefData
66 {
67 public:
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
83 public:
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
100 private:
101 wxMask *m_bitmapMask;
102
103 DECLARE_NO_COPY_CLASS(wxBitmapRefData)
104 };
105
106 // ----------------------------------------------------------------------------
107 // macros
108 // ----------------------------------------------------------------------------
109
110 IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
111 IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
112
113 IMPLEMENT_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
156 wxBitmapRefData::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 =
169 m_hasAlpha = FALSE;
170 }
171
172 void wxBitmapRefData::Free()
173 {
174 }
175
176 // ----------------------------------------------------------------------------
177 // wxBitmap creation
178 // ----------------------------------------------------------------------------
179
180 // this function should be called from all wxBitmap ctors
181 void wxBitmap::Init()
182 {
183 }
184
185 wxGDIImageRefData *wxBitmap::CreateData() const
186 {
187 return NULL;
188 }
189
190 #ifdef __WIN32__
191
192 bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon)
193 {
194 return FALSE;
195 }
196
197 #endif // Win32
198
199 bool wxBitmap::CopyFromCursor(const wxCursor& cursor)
200 {
201 return FALSE;
202 }
203
204 bool wxBitmap::CopyFromIcon(const wxIcon& icon)
205 {
206 return FALSE;
207 }
208
209 #ifndef NEVER_USE_DIB
210
211 bool wxBitmap::CopyFromDIB(const wxDIB& dib)
212 {
213 return FALSE:
214 }
215
216 #endif // NEVER_USE_DIB
217
218 wxBitmap::~wxBitmap()
219 {
220 }
221
222 wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
223 {
224 Init();
225 }
226
227 // Create from XPM data
228 #if wxUSE_IMAGE && wxUSE_XPM
229 bool wxBitmap::CreateFromXpm(const char **data)
230 #else
231 bool wxBitmap::CreateFromXpm(const char **WXUNUSED(data))
232 #endif
233 {
234 return FALSE;
235 }
236
237 wxBitmap::wxBitmap(int w, int h, int d)
238 {
239 }
240
241 wxBitmap::wxBitmap(int w, int h, const wxDC& dc)
242 {
243 }
244
245 wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth)
246 {
247 }
248
249 wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type)
250 {
251 }
252
253 bool wxBitmap::Create(int width, int height, int depth)
254 {
255 return FALSE;
256 }
257
258 bool wxBitmap::Create(int width, int height, const wxDC& dc)
259 {
260 return FALSE;
261 }
262
263 bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc)
264 {
265 return FALSE;
266 }
267
268 #if wxUSE_IMAGE
269
270 // ----------------------------------------------------------------------------
271 // wxImage to/from conversions
272 // ----------------------------------------------------------------------------
273
274 #if wxUSE_WXDIB
275
276 bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
277 {
278 return FALSE;
279 }
280
281 bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc)
282 {
283 return FALSE;
284 }
285
286 bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc)
287 {
288 return FALSE;
289 }
290
291 wxImage wxBitmap::ConvertToImage() const
292 {
293 wxImage image;
294 return image;
295 }
296
297 #endif // wxUSE_WXDIB
298
299 #endif // wxUSE_IMAGE
300
301 // ----------------------------------------------------------------------------
302 // loading and saving bitmaps
303 // ----------------------------------------------------------------------------
304
305 bool wxBitmap::LoadFile(const wxString& filename, long type)
306 {
307 return FALSE;
308 }
309
310 bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
311 {
312 return FALSE;
313 }
314
315 bool wxBitmap::SaveFile(const wxString& filename,
316 int type,
317 const wxPalette *palette)
318 {
319 return FALSE;
320 }
321
322 // ----------------------------------------------------------------------------
323 // sub bitmap extraction
324 // ----------------------------------------------------------------------------
325
326 wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
327 {
328 wxBitmap ret( 0, 0 );
329 return ret;
330 }
331
332 // ----------------------------------------------------------------------------
333 // wxBitmap accessors
334 // ----------------------------------------------------------------------------
335
336 #if wxUSE_PALETTE
337 wxPalette* wxBitmap::GetPalette() const
338 {
339 return (wxPalette *) NULL;
340 }
341 #endif
342
343 wxMask *wxBitmap::GetMask() const
344 {
345 return (wxMask *) NULL;
346 }
347
348 #ifdef __WXDEBUG__
349
350 wxDC *wxBitmap::GetSelectedInto() const
351 {
352 return (wxDC *) NULL;
353 }
354
355 #endif
356
357 #if WXWIN_COMPATIBILITY_2_4
358
359 int wxBitmap::GetQuality() const
360 {
361 return 0;
362 }
363
364 #endif // WXWIN_COMPATIBILITY_2_4
365
366 void wxBitmap::UseAlpha()
367 {
368 }
369
370 bool wxBitmap::HasAlpha() const
371 {
372 return FALSE;
373 }
374
375 // ----------------------------------------------------------------------------
376 // wxBitmap setters
377 // ----------------------------------------------------------------------------
378
379 #ifdef __WXDEBUG__
380
381 void wxBitmap::SetSelectedInto(wxDC *dc)
382 {
383 }
384
385 #endif
386
387 #if wxUSE_PALETTE
388
389 void wxBitmap::SetPalette(const wxPalette& palette)
390 {
391 }
392
393 #endif // wxUSE_PALETTE
394
395 void wxBitmap::SetMask(wxMask *mask)
396 {
397 }
398
399 #if WXWIN_COMPATIBILITY_2_4
400
401 void wxBitmap::SetQuality(int WXUNUSED(quality))
402 {
403 }
404
405 #endif // WXWIN_COMPATIBILITY_2_4
406
407 // ----------------------------------------------------------------------------
408 // raw bitmap access support
409 // ----------------------------------------------------------------------------
410
411 #ifdef wxHAVE_RAW_BITMAP
412 void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
413 {
414 return NULL;
415 }
416
417 void wxBitmap::UngetRawData(wxPixelDataBase& dataBase)
418 {
419 return;
420 }
421 #endif // #ifdef wxHAVE_RAW_BITMAP
422
423 // ----------------------------------------------------------------------------
424 // wxMask
425 // ----------------------------------------------------------------------------
426
427 wxMask::wxMask()
428 {
429 m_maskBitmap = 0;
430 }
431
432 // Construct a mask from a bitmap and a colour indicating
433 // the transparent area
434 wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
435 {
436 }
437
438 // Construct a mask from a bitmap and a palette index indicating
439 // the transparent area
440 wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
441 {
442 }
443
444 // Construct a mask from a mono bitmap (copies the bitmap).
445 wxMask::wxMask(const wxBitmap& bitmap)
446 {
447 }
448
449 wxMask::~wxMask()
450 {
451 }
452
453 // Create a mask from a mono bitmap (copies the bitmap).
454 bool wxMask::Create(const wxBitmap& bitmap)
455 {
456 return FALSE;
457 }
458
459 // Create a mask from a bitmap and a palette index indicating
460 // the transparent area
461 bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
462 {
463 return FALSE;
464 }
465
466 // Create a mask from a bitmap and a colour indicating
467 // the transparent area
468 bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
469 {
470 return FALSE;
471 }
472
473 // ----------------------------------------------------------------------------
474 // wxBitmapHandler
475 // ----------------------------------------------------------------------------
476
477 bool wxBitmapHandler::Create(wxGDIImage *image,
478 void *data,
479 long flags,
480 int width, int height, int depth)
481 {
482 return FALSE;
483 }
484
485 bool wxBitmapHandler::Load(wxGDIImage *image,
486 const wxString& name,
487 long flags,
488 int width, int height)
489 {
490 return FALSE;
491 }
492
493 bool wxBitmapHandler::Save(wxGDIImage *image,
494 const wxString& name,
495 int type)
496 {
497 return FALSE;
498 }
499
500 bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap),
501 void *WXUNUSED(data),
502 long WXUNUSED(type),
503 int WXUNUSED(width),
504 int WXUNUSED(height),
505 int WXUNUSED(depth))
506 {
507 return FALSE;
508 }
509
510 bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap),
511 const wxString& WXUNUSED(name),
512 long WXUNUSED(type),
513 int WXUNUSED(desiredWidth),
514 int WXUNUSED(desiredHeight))
515 {
516 return FALSE;
517 }
518
519 bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap),
520 const wxString& WXUNUSED(name),
521 int WXUNUSED(type),
522 const wxPalette *WXUNUSED(palette))
523 {
524 return FALSE;
525 }