]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/dc.cpp
fixed wxMac compilation after ShowWithEffect() changes; also fixed to use correct...
[wxWidgets.git] / src / palmos / dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/dc.cpp
3 // Purpose: wxDC class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/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 #include <string.h>
21
22 // For compilers that support precompilation, includes "wx.h".
23 #include "wx/wxprec.h"
24
25 #ifdef __BORLANDC__
26 #pragma hdrstop
27 #endif
28
29 #ifndef WX_PRECOMP
30 #include "wx/image.h"
31 #include "wx/window.h"
32 #include "wx/dc.h"
33 #include "wx/utils.h"
34 #include "wx/dialog.h"
35 #include "wx/app.h"
36 #include "wx/bitmap.h"
37 #include "wx/dcmemory.h"
38 #include "wx/log.h"
39 #include "wx/icon.h"
40 #include "wx/dcprint.h"
41 #include "wx/module.h"
42 #endif
43
44 #include "wx/sysopt.h"
45 #include "wx/dynlib.h"
46
47 #ifdef wxHAVE_RAW_BITMAP
48 #include "wx/rawbmp.h"
49 #endif
50
51 #include "wx/palmos/dc.h"
52
53 #ifndef AC_SRC_ALPHA
54 #define AC_SRC_ALPHA 1
55 #endif
56
57 #ifndef LAYOUT_RTL
58 #define LAYOUT_RTL 1
59 #endif
60
61 /* Quaternary raster codes */
62 #ifndef MAKEROP4
63 #define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore))
64 #endif
65
66 // apparently with MicroWindows it is possible that HDC is 0 so we have to
67 // check for this ourselves
68 #ifdef __WXMICROWIN__
69 #define WXMICROWIN_CHECK_HDC if ( !GetHDC() ) return;
70 #define WXMICROWIN_CHECK_HDC_RET(x) if ( !GetHDC() ) return x;
71 #else
72 #define WXMICROWIN_CHECK_HDC
73 #define WXMICROWIN_CHECK_HDC_RET(x)
74 #endif
75
76 IMPLEMENT_ABSTRACT_CLASS(wxPalmDCImpl, wxDCImpl)
77
78 // ---------------------------------------------------------------------------
79 // constants
80 // ---------------------------------------------------------------------------
81
82 // ROPs which don't have standard names (see "Ternary Raster Operations" in the
83 // MSDN docs for how this and other numbers in wxDC::Blit() are obtained)
84 #define DSTCOPY 0x00AA0029 // a.k.a. NOP operation
85
86 // ----------------------------------------------------------------------------
87 // macros for logical <-> device coords conversion
88 // ----------------------------------------------------------------------------
89
90 /*
91 We currently let Windows do all the translations itself so these macros are
92 not really needed (any more) but keep them to enhance readability of the
93 code by allowing to see where are the logical and where are the device
94 coordinates used.
95 */
96
97 #ifdef __WXWINCE__
98 #define XLOG2DEV(x) ((x-m_logicalOriginX)*m_signX)
99 #define YLOG2DEV(y) ((y-m_logicalOriginY)*m_signY)
100 #define XDEV2LOG(x) ((x)*m_signX+m_logicalOriginX)
101 #define YDEV2LOG(y) ((y)*m_signY+m_logicalOriginY)
102 #else
103 #define XLOG2DEV(x) (x)
104 #define YLOG2DEV(y) (y)
105 #define XDEV2LOG(x) (x)
106 #define YDEV2LOG(y) (y)
107 #endif
108
109 // ---------------------------------------------------------------------------
110 // private functions
111 // ---------------------------------------------------------------------------
112
113 // ----------------------------------------------------------------------------
114 // private classes
115 // ----------------------------------------------------------------------------
116
117 #if wxUSE_DYNLIB_CLASS
118
119 // helper class to cache dynamically loaded libraries and not attempt reloading
120 // them if it fails
121 class wxOnceOnlyDLLLoader
122 {
123 public:
124 // ctor argument must be a literal string as we don't make a copy of it!
125 wxOnceOnlyDLLLoader(const wxChar *dllName)
126 : m_dllName(dllName)
127 {
128 }
129
130
131 // return the symbol with the given name or NULL if the DLL not loaded
132 // or symbol not present
133 void *GetSymbol(const wxChar *name)
134 {
135 // we're prepared to handle errors here
136 wxLogNull noLog;
137
138 if ( m_dllName )
139 {
140 m_dll.Load(m_dllName);
141
142 // reset the name whether we succeeded or failed so that we don't
143 // try again the next time
144 m_dllName = NULL;
145 }
146
147 return m_dll.IsLoaded() ? m_dll.GetSymbol(name) : NULL;
148 }
149
150 void Unload()
151 {
152 if ( m_dll.IsLoaded() )
153 {
154 m_dll.Unload();
155 }
156 }
157
158 private:
159 wxDynamicLibrary m_dll;
160 const wxChar *m_dllName;
161 };
162
163 #endif // wxUSE_DYNLIB_CLASS
164
165 // ===========================================================================
166 // implementation
167 // ===========================================================================
168
169 // ---------------------------------------------------------------------------
170 // wxPalmDCImpl
171 // ---------------------------------------------------------------------------
172
173 wxPalmDCImpl::wxPalmDCImpl( wxDC *owner, WXHDC hDC ) :
174 wxDCImpl( owner )
175 {
176 Init();
177 m_hDC = hDC;
178 }
179
180 wxPalmDCImpl::~wxPalmDCImpl()
181 {
182 }
183
184 // This will select current objects out of the DC,
185 // which is what you have to do before deleting the
186 // DC.
187 void wxPalmDCImpl::SelectOldObjects(WXHDC dc)
188 {
189 }
190
191 // ---------------------------------------------------------------------------
192 // clipping
193 // ---------------------------------------------------------------------------
194
195 void wxPalmDCImpl::UpdateClipBox()
196 {
197 }
198
199 void
200 wxPalmDCImpl::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
201 {
202 }
203
204 // common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
205 void wxPalmDCImpl::SetClippingHrgn(WXHRGN hrgn)
206 {
207 wxCHECK_RET( hrgn, wxT("invalid clipping region") );
208 }
209
210 void wxPalmDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
211 {
212 }
213
214 void wxPalmDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
215 {
216 }
217
218 void wxPalmDCImpl::DestroyClippingRegion()
219 {
220 }
221
222 // ---------------------------------------------------------------------------
223 // query capabilities
224 // ---------------------------------------------------------------------------
225
226 bool wxPalmDCImpl::CanDrawBitmap() const
227 {
228 return false;
229 }
230
231 bool wxPalmDCImpl::CanGetTextExtent() const
232 {
233 return false;
234 }
235
236 int wxPalmDCImpl::GetDepth() const
237 {
238 return 0;
239 }
240
241 // ---------------------------------------------------------------------------
242 // drawing
243 // ---------------------------------------------------------------------------
244
245 void wxPalmDCImpl::Clear()
246 {
247 }
248
249 bool wxPalmDCImpl::DoFloodFill(wxCoord WXUNUSED_IN_WINCE(x),
250 wxCoord WXUNUSED_IN_WINCE(y),
251 const wxColour& WXUNUSED_IN_WINCE(col),
252 int WXUNUSED_IN_WINCE(style))
253 {
254 return false;
255 }
256
257 bool wxPalmDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
258 {
259 return false;
260 }
261
262 void wxPalmDCImpl::DoCrossHair(wxCoord x, wxCoord y)
263 {
264 }
265
266 void wxPalmDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
267 {
268 }
269
270 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
271 // and ending at (x2, y2)
272 void wxPalmDCImpl::DoDrawArc(wxCoord x1, wxCoord y1,
273 wxCoord x2, wxCoord y2,
274 wxCoord xc, wxCoord yc)
275 {
276 }
277
278 void wxPalmDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1,
279 wxCoord width, wxCoord height)
280 {
281 }
282
283 void wxPalmDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
284 {
285 }
286
287 void wxPalmDCImpl::DoDrawPolygon(int n,
288 wxPoint points[],
289 wxCoord xoffset,
290 wxCoord yoffset,
291 int WXUNUSED_IN_WINCE(fillStyle))
292 {
293 }
294
295 void
296 wxPalmDCImpl::DoDrawPolyPolygon(int n,
297 int count[],
298 wxPoint points[],
299 wxCoord xoffset,
300 wxCoord yoffset,
301 int fillStyle)
302 {
303 }
304
305 void wxPalmDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
306 {
307 }
308
309 void wxPalmDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
310 {
311 }
312
313 void wxPalmDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
314 {
315 }
316
317 void wxPalmDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
318 {
319 }
320
321 #if wxUSE_SPLINES
322 void wxPalmDCImpl::DoDrawSpline(const wxPointList *points)
323 {
324 }
325 #endif
326
327 // Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows
328 void wxPalmDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
329 {
330 }
331
332 void wxPalmDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
333 {
334 }
335
336 void wxPalmDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
337 {
338 }
339
340 void wxPalmDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
341 {
342 }
343
344 void wxPalmDCImpl::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
345 {
346 }
347
348 void wxPalmDCImpl::DoDrawRotatedText(const wxString& text,
349 wxCoord x, wxCoord y,
350 double angle)
351 {
352 }
353
354 // ---------------------------------------------------------------------------
355 // set GDI objects
356 // ---------------------------------------------------------------------------
357
358 #if wxUSE_PALETTE
359
360 void wxPalmDCImpl::DoSelectPalette(bool realize)
361 {
362 }
363
364 void wxPalmDCImpl::SetPalette(const wxPalette& palette)
365 {
366 }
367
368 void wxPalmDCImpl::InitializePalette()
369 {
370 }
371
372 #endif // wxUSE_PALETTE
373
374 // SetFont/Pen/Brush() really ask to be implemented as a single template
375 // function... but doing it is not worth breaking OpenWatcom build <sigh>
376
377 void wxPalmDCImpl::SetFont(const wxFont& font)
378 {
379 }
380
381 void wxPalmDCImpl::SetPen(const wxPen& pen)
382 {
383 }
384
385 void wxPalmDCImpl::SetBrush(const wxBrush& brush)
386 {
387 }
388
389 void wxPalmDCImpl::SetBackground(const wxBrush& brush)
390 {
391 }
392
393 void wxPalmDCImpl::SetBackgroundMode(int mode)
394 {
395 }
396
397 void wxPalmDCImpl::SetLogicalFunction(int function)
398 {
399 }
400
401 void wxPalmDCImpl::SetRop(WXHDC dc)
402 {
403 }
404
405 bool wxPalmDCImpl::StartDoc(const wxString& WXUNUSED(message))
406 {
407 // We might be previewing, so return true to let it continue.
408 return true;
409 }
410
411 void wxPalmDCImpl::EndDoc()
412 {
413 }
414
415 void wxPalmDCImpl::StartPage()
416 {
417 }
418
419 void wxPalmDCImpl::EndPage()
420 {
421 }
422
423 // ---------------------------------------------------------------------------
424 // text metrics
425 // ---------------------------------------------------------------------------
426
427 wxCoord wxPalmDCImpl::GetCharHeight() const
428 {
429 return 0;
430 }
431
432 wxCoord wxPalmDCImpl::GetCharWidth() const
433 {
434 return 0;
435 }
436
437 void wxPalmDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
438 wxCoord *descent, wxCoord *externalLeading,
439 const wxFont *font) const
440 {
441 }
442
443
444 // Each element of the array will be the width of the string up to and
445 // including the coresoponding character in text.
446
447 bool wxPalmDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
448 {
449 return false;
450 }
451
452 void wxPalmDCImpl::RealizeScaleAndOrigin()
453 {
454 }
455
456 void wxPalmDCImpl::SetMapMode(int mode)
457 {
458 }
459
460 void wxPalmDCImpl::SetUserScale(double x, double y)
461 {
462 }
463
464 void wxPalmDCImpl::SetAxisOrientation(bool xLeftRight,
465 bool yBottomUp)
466 {
467 }
468
469 void wxPalmDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y)
470 {
471 }
472
473 void wxPalmDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)
474 {
475 }
476
477 // ---------------------------------------------------------------------------
478 // bit blit
479 // ---------------------------------------------------------------------------
480
481 bool wxPalmDCImpl::DoBlit(wxCoord dstX, wxCoord dstY,
482 wxCoord dstWidth, wxCoord dstHeight,
483 wxDC *source,
484 wxCoord srcX, wxCoord srcY,
485 int rop, bool useMask,
486 wxCoord srcMaskX, wxCoord srcMaskY)
487 {
488 return false;
489 }
490
491 bool wxPalmDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest,
492 wxCoord dstWidth, wxCoord dstHeight,
493 wxDC *source,
494 wxCoord xsrc, wxCoord ysrc,
495 wxCoord srcWidth, wxCoord srcHeight,
496 int rop, bool useMask,
497 wxCoord xsrcMask, wxCoord ysrcMask)
498 {
499 return false;
500 }
501
502 void wxPalmDCImpl::GetDeviceSize(int *width, int *height) const
503 {
504 }
505
506 void wxPalmDCImpl::DoGetSizeMM(int *w, int *h) const
507 {
508 }
509
510 wxSize wxPalmDCImpl::GetPPI() const
511 {
512 return wxSize(0, 0);
513 }
514
515 // For use by wxWidgets only, unless custom units are required.
516 void wxPalmDCImpl::SetLogicalScale(double x, double y)
517 {
518 }
519
520 // ----------------------------------------------------------------------------
521 // DC caching
522 // ----------------------------------------------------------------------------
523
524 #if wxUSE_DC_CACHEING
525
526 /*
527 * This implementation is a bit ugly and uses the old-fashioned wxList class, so I will
528 * improve it in due course, either using arrays, or simply storing pointers to one
529 * entry for the bitmap, and two for the DCs. -- JACS
530 */
531
532 wxObjectList wxPalmDCImpl::sm_bitmapCache;
533 wxObjectList wxPalmDCImpl::sm_dcCache;
534
535 wxDCCacheEntry::wxDCCacheEntry(WXHBITMAP hBitmap, int w, int h, int depth)
536 {
537 m_bitmap = hBitmap;
538 m_dc = 0;
539 m_width = w;
540 m_height = h;
541 m_depth = depth;
542 }
543
544 wxDCCacheEntry::wxDCCacheEntry(WXHDC hDC, int depth)
545 {
546 }
547
548 wxDCCacheEntry::~wxDCCacheEntry()
549 {
550 }
551
552 wxDCCacheEntry* wxPalmDCImpl::FindBitmapInCache(WXHDC dc, int w, int h)
553 {
554 return NULL;
555 }
556
557 wxDCCacheEntry* wxPalmDCImpl::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc)
558 {
559 return NULL;
560 }
561
562 void wxPalmDCImpl::AddToBitmapCache(wxDCCacheEntry* entry)
563 {
564 }
565
566 void wxPalmDCImpl::AddToDCCache(wxDCCacheEntry* entry)
567 {
568 }
569
570 void wxPalmDCImpl::ClearCache()
571 {
572 }
573
574 // Clean up cache at app exit
575 class wxDCModule : public wxModule
576 {
577 public:
578 virtual bool OnInit() { return true; }
579 virtual void OnExit() { wxPalmDCImpl::ClearCache(); }
580
581 private:
582 DECLARE_DYNAMIC_CLASS(wxDCModule)
583 };
584
585 IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
586
587 #endif // wxUSE_DC_CACHEING
588
589 void wxPalmDCImpl::DoGradientFillLinear (const wxRect& rect,
590 const wxColour& initialColour,
591 const wxColour& destColour,
592 wxDirection nDirection)
593 {
594 }
595
596 #if wxUSE_DYNLIB_CLASS
597
598 wxLayoutDirection wxPalmDCImpl::GetLayoutDirection() const
599 {
600 DWORD layout = wxGetDCLayout(GetHdc());
601
602 if ( layout == (DWORD)-1 )
603 return wxLayout_Default;
604
605 return layout & LAYOUT_RTL ? wxLayout_RightToLeft : wxLayout_LeftToRight;
606 }
607
608 void wxPalmDCImpl::SetLayoutDirection(wxLayoutDirection dir)
609 {
610 }
611
612 #else // !wxUSE_DYNLIB_CLASS
613
614 // we can't provide RTL support without dynamic loading, so stub it out
615 wxLayoutDirection wxPalmDCImpl::GetLayoutDirection() const
616 {
617 return wxLayout_Default;
618 }
619
620 void wxPalmDCImpl::SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
621 {
622 }
623
624 #endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS