]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/bitmap.cpp
added ping location for IRIX
[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
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
ffecfa5a
JS
348void wxBitmap::UseAlpha()
349{
350}
351
352bool wxBitmap::HasAlpha() const
353{
4055ed82 354 return false;
ffecfa5a
JS
355}
356
357// ----------------------------------------------------------------------------
358// wxBitmap setters
359// ----------------------------------------------------------------------------
360
361#ifdef __WXDEBUG__
362
363void wxBitmap::SetSelectedInto(wxDC *dc)
364{
365}
366
367#endif
368
369#if wxUSE_PALETTE
370
371void wxBitmap::SetPalette(const wxPalette& palette)
372{
373}
374
375#endif // wxUSE_PALETTE
376
377void wxBitmap::SetMask(wxMask *mask)
378{
379}
380
ffecfa5a
JS
381// ----------------------------------------------------------------------------
382// raw bitmap access support
383// ----------------------------------------------------------------------------
384
385#ifdef wxHAVE_RAW_BITMAP
386void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
387{
388 return NULL;
389}
390
391void wxBitmap::UngetRawData(wxPixelDataBase& dataBase)
392{
393 return;
394}
395#endif // #ifdef wxHAVE_RAW_BITMAP
396
397// ----------------------------------------------------------------------------
398// wxMask
399// ----------------------------------------------------------------------------
400
401wxMask::wxMask()
402{
403 m_maskBitmap = 0;
404}
405
406// Construct a mask from a bitmap and a colour indicating
407// the transparent area
408wxMask::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
414wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
415{
416}
417
418// Construct a mask from a mono bitmap (copies the bitmap).
419wxMask::wxMask(const wxBitmap& bitmap)
420{
421}
422
423wxMask::~wxMask()
424{
425}
426
427// Create a mask from a mono bitmap (copies the bitmap).
428bool wxMask::Create(const wxBitmap& bitmap)
429{
4055ed82 430 return false;
ffecfa5a
JS
431}
432
433// Create a mask from a bitmap and a palette index indicating
434// the transparent area
435bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
436{
4055ed82 437 return false;
ffecfa5a
JS
438}
439
440// Create a mask from a bitmap and a colour indicating
441// the transparent area
442bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
443{
4055ed82 444 return false;
ffecfa5a
JS
445}
446
447// ----------------------------------------------------------------------------
448// wxBitmapHandler
449// ----------------------------------------------------------------------------
450
451bool wxBitmapHandler::Create(wxGDIImage *image,
452 void *data,
453 long flags,
454 int width, int height, int depth)
455{
4055ed82 456 return false;
ffecfa5a
JS
457}
458
459bool wxBitmapHandler::Load(wxGDIImage *image,
460 const wxString& name,
461 long flags,
462 int width, int height)
463{
4055ed82 464 return false;
ffecfa5a
JS
465}
466
467bool wxBitmapHandler::Save(wxGDIImage *image,
468 const wxString& name,
469 int type)
470{
4055ed82 471 return false;
ffecfa5a
JS
472}
473
474bool 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{
4055ed82 481 return false;
ffecfa5a
JS
482}
483
484bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap),
485 const wxString& WXUNUSED(name),
486 long WXUNUSED(type),
487 int WXUNUSED(desiredWidth),
488 int WXUNUSED(desiredHeight))
489{
4055ed82 490 return false;
ffecfa5a
JS
491}
492
493bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap),
494 const wxString& WXUNUSED(name),
495 int WXUNUSED(type),
496 const wxPalette *WXUNUSED(palette))
497{
4055ed82 498 return false;
ffecfa5a 499}