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