]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/bitmap.cpp
No res-include for rpmspec wx24dsp
[wxWidgets.git] / src / palmos / bitmap.cpp
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/bitmap.cpp
3 // Purpose: wxBitmap
4 // Author: William Osborne - minimal working wxPalmOS port
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 bool wxBitmap::CopyFromCursor(const wxCursor& cursor)
191 {
192 return false;
193 }
194
195 bool wxBitmap::CopyFromIcon(const wxIcon& icon)
196 {
197 return false;
198 }
199
200 #ifndef NEVER_USE_DIB
201
202 bool wxBitmap::CopyFromDIB(const wxDIB& dib)
203 {
204 return false:
205 }
206
207 #endif // NEVER_USE_DIB
208
209 wxBitmap::~wxBitmap()
210 {
211 }
212
213 wxBitmap::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
220 bool wxBitmap::CreateFromXpm(const char **data)
221 #else
222 bool wxBitmap::CreateFromXpm(const char **WXUNUSED(data))
223 #endif
224 {
225 return false;
226 }
227
228 wxBitmap::wxBitmap(int w, int h, int d)
229 {
230 }
231
232 wxBitmap::wxBitmap(int w, int h, const wxDC& dc)
233 {
234 }
235
236 wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth)
237 {
238 }
239
240 wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type)
241 {
242 }
243
244 bool wxBitmap::Create(int width, int height, int depth)
245 {
246 return false;
247 }
248
249 bool wxBitmap::Create(int width, int height, const wxDC& dc)
250 {
251 return false;
252 }
253
254 bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc)
255 {
256 return false;
257 }
258
259 #if wxUSE_IMAGE
260
261 // ----------------------------------------------------------------------------
262 // wxImage to/from conversions
263 // ----------------------------------------------------------------------------
264
265 #if wxUSE_WXDIB
266
267 bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
268 {
269 return false;
270 }
271
272 bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc)
273 {
274 return false;
275 }
276
277 bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc)
278 {
279 return false;
280 }
281
282 wxImage 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
296 bool wxBitmap::LoadFile(const wxString& filename, long type)
297 {
298 return false;
299 }
300
301 bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
302 {
303 return false;
304 }
305
306 bool wxBitmap::SaveFile(const wxString& filename,
307 int type,
308 const wxPalette *palette)
309 {
310 return false;
311 }
312
313 // ----------------------------------------------------------------------------
314 // sub bitmap extraction
315 // ----------------------------------------------------------------------------
316
317 wxBitmap 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
328 wxPalette* wxBitmap::GetPalette() const
329 {
330 return (wxPalette *) NULL;
331 }
332 #endif
333
334 wxMask *wxBitmap::GetMask() const
335 {
336 return (wxMask *) NULL;
337 }
338
339 #ifdef __WXDEBUG__
340
341 wxDC *wxBitmap::GetSelectedInto() const
342 {
343 return (wxDC *) NULL;
344 }
345
346 #endif
347
348 void wxBitmap::UseAlpha()
349 {
350 }
351
352 bool wxBitmap::HasAlpha() const
353 {
354 return false;
355 }
356
357 // ----------------------------------------------------------------------------
358 // wxBitmap setters
359 // ----------------------------------------------------------------------------
360
361 #ifdef __WXDEBUG__
362
363 void wxBitmap::SetSelectedInto(wxDC *dc)
364 {
365 }
366
367 #endif
368
369 #if wxUSE_PALETTE
370
371 void wxBitmap::SetPalette(const wxPalette& palette)
372 {
373 }
374
375 #endif // wxUSE_PALETTE
376
377 void wxBitmap::SetMask(wxMask *mask)
378 {
379 }
380
381 // ----------------------------------------------------------------------------
382 // raw bitmap access support
383 // ----------------------------------------------------------------------------
384
385 #ifdef wxHAVE_RAW_BITMAP
386 void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
387 {
388 return NULL;
389 }
390
391 void wxBitmap::UngetRawData(wxPixelDataBase& dataBase)
392 {
393 return;
394 }
395 #endif // #ifdef wxHAVE_RAW_BITMAP
396
397 // ----------------------------------------------------------------------------
398 // wxMask
399 // ----------------------------------------------------------------------------
400
401 wxMask::wxMask()
402 {
403 m_maskBitmap = 0;
404 }
405
406 // Construct a mask from a bitmap and a colour indicating
407 // the transparent area
408 wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
409 {
410 }
411
412 // Construct a mask from a bitmap and a palette index indicating
413 // the transparent area
414 wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
415 {
416 }
417
418 // Construct a mask from a mono bitmap (copies the bitmap).
419 wxMask::wxMask(const wxBitmap& bitmap)
420 {
421 }
422
423 wxMask::~wxMask()
424 {
425 }
426
427 // Create a mask from a mono bitmap (copies the bitmap).
428 bool wxMask::Create(const wxBitmap& bitmap)
429 {
430 return false;
431 }
432
433 // Create a mask from a bitmap and a palette index indicating
434 // the transparent area
435 bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
436 {
437 return false;
438 }
439
440 // Create a mask from a bitmap and a colour indicating
441 // the transparent area
442 bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
443 {
444 return false;
445 }
446
447 // ----------------------------------------------------------------------------
448 // wxBitmapHandler
449 // ----------------------------------------------------------------------------
450
451 bool wxBitmapHandler::Create(wxGDIImage *image,
452 void *data,
453 long flags,
454 int width, int height, int depth)
455 {
456 return false;
457 }
458
459 bool wxBitmapHandler::Load(wxGDIImage *image,
460 const wxString& name,
461 long flags,
462 int width, int height)
463 {
464 return false;
465 }
466
467 bool wxBitmapHandler::Save(wxGDIImage *image,
468 const wxString& name,
469 int type)
470 {
471 return false;
472 }
473
474 bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap),
475 void *WXUNUSED(data),
476 long WXUNUSED(type),
477 int WXUNUSED(width),
478 int WXUNUSED(height),
479 int WXUNUSED(depth))
480 {
481 return false;
482 }
483
484 bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap),
485 const wxString& WXUNUSED(name),
486 long WXUNUSED(type),
487 int WXUNUSED(desiredWidth),
488 int WXUNUSED(desiredHeight))
489 {
490 return false;
491 }
492
493 bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap),
494 const wxString& WXUNUSED(name),
495 int WXUNUSED(type),
496 const wxPalette *WXUNUSED(palette))
497 {
498 return false;
499 }