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