]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/dc.cpp
compilation fixes for ANSI build
[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 // common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
201 void wxPalmDCImpl::SetClippingHrgn(WXHRGN hrgn)
202 {
203 wxCHECK_RET( hrgn, wxT("invalid clipping region") );
204 }
205
206 void wxPalmDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
207 {
208 }
209
210 void wxPalmDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
211 {
212 }
213
214 void wxPalmDCImpl::DestroyClippingRegion()
215 {
216 }
217
218 // ---------------------------------------------------------------------------
219 // query capabilities
220 // ---------------------------------------------------------------------------
221
222 bool wxPalmDCImpl::CanDrawBitmap() const
223 {
224 return false;
225 }
226
227 bool wxPalmDCImpl::CanGetTextExtent() const
228 {
229 return false;
230 }
231
232 int wxPalmDCImpl::GetDepth() const
233 {
234 return 0;
235 }
236
237 // ---------------------------------------------------------------------------
238 // drawing
239 // ---------------------------------------------------------------------------
240
241 void wxPalmDCImpl::Clear()
242 {
243 }
244
245 bool wxPalmDCImpl::DoFloodFill(wxCoord WXUNUSED_IN_WINCE(x),
246 wxCoord WXUNUSED_IN_WINCE(y),
247 const wxColour& WXUNUSED_IN_WINCE(col),
248 int WXUNUSED_IN_WINCE(style))
249 {
250 return false;
251 }
252
253 bool wxPalmDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
254 {
255 return false;
256 }
257
258 void wxPalmDCImpl::DoCrossHair(wxCoord x, wxCoord y)
259 {
260 }
261
262 void wxPalmDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
263 {
264 }
265
266 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
267 // and ending at (x2, y2)
268 void wxPalmDCImpl::DoDrawArc(wxCoord x1, wxCoord y1,
269 wxCoord x2, wxCoord y2,
270 wxCoord xc, wxCoord yc)
271 {
272 }
273
274 void wxPalmDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1,
275 wxCoord width, wxCoord height)
276 {
277 }
278
279 void wxPalmDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
280 {
281 }
282
283 void wxPalmDCImpl::DoDrawPolygon(int n,
284 wxPoint points[],
285 wxCoord xoffset,
286 wxCoord yoffset,
287 int WXUNUSED_IN_WINCE(fillStyle))
288 {
289 }
290
291 void
292 wxPalmDCImpl::DoDrawPolyPolygon(int n,
293 int count[],
294 wxPoint points[],
295 wxCoord xoffset,
296 wxCoord yoffset,
297 int fillStyle)
298 {
299 }
300
301 void wxPalmDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
302 {
303 }
304
305 void wxPalmDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
306 {
307 }
308
309 void wxPalmDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
310 {
311 }
312
313 void wxPalmDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
314 {
315 }
316
317 #if wxUSE_SPLINES
318 void wxPalmDCImpl::DoDrawSpline(const wxPointList *points)
319 {
320 }
321 #endif
322
323 // Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows
324 void wxPalmDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
325 {
326 }
327
328 void wxPalmDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
329 {
330 }
331
332 void wxPalmDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
333 {
334 }
335
336 void wxPalmDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
337 {
338 }
339
340 void wxPalmDCImpl::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
341 {
342 }
343
344 void wxPalmDCImpl::DoDrawRotatedText(const wxString& text,
345 wxCoord x, wxCoord y,
346 double angle)
347 {
348 }
349
350 // ---------------------------------------------------------------------------
351 // set GDI objects
352 // ---------------------------------------------------------------------------
353
354 #if wxUSE_PALETTE
355
356 void wxPalmDCImpl::DoSelectPalette(bool realize)
357 {
358 }
359
360 void wxPalmDCImpl::SetPalette(const wxPalette& palette)
361 {
362 }
363
364 void wxPalmDCImpl::InitializePalette()
365 {
366 }
367
368 #endif // wxUSE_PALETTE
369
370 // SetFont/Pen/Brush() really ask to be implemented as a single template
371 // function... but doing it is not worth breaking OpenWatcom build <sigh>
372
373 void wxPalmDCImpl::SetFont(const wxFont& font)
374 {
375 }
376
377 void wxPalmDCImpl::SetPen(const wxPen& pen)
378 {
379 }
380
381 void wxPalmDCImpl::SetBrush(const wxBrush& brush)
382 {
383 }
384
385 void wxPalmDCImpl::SetBackground(const wxBrush& brush)
386 {
387 }
388
389 void wxPalmDCImpl::SetBackgroundMode(int mode)
390 {
391 }
392
393 void wxPalmDCImpl::SetLogicalFunction(int function)
394 {
395 }
396
397 void wxPalmDCImpl::SetRop(WXHDC dc)
398 {
399 }
400
401 bool wxPalmDCImpl::StartDoc(const wxString& WXUNUSED(message))
402 {
403 // We might be previewing, so return true to let it continue.
404 return true;
405 }
406
407 void wxPalmDCImpl::EndDoc()
408 {
409 }
410
411 void wxPalmDCImpl::StartPage()
412 {
413 }
414
415 void wxPalmDCImpl::EndPage()
416 {
417 }
418
419 // ---------------------------------------------------------------------------
420 // text metrics
421 // ---------------------------------------------------------------------------
422
423 wxCoord wxPalmDCImpl::GetCharHeight() const
424 {
425 return 0;
426 }
427
428 wxCoord wxPalmDCImpl::GetCharWidth() const
429 {
430 return 0;
431 }
432
433 void wxPalmDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
434 wxCoord *descent, wxCoord *externalLeading,
435 const wxFont *font) const
436 {
437 }
438
439
440 // Each element of the array will be the width of the string up to and
441 // including the coresoponding character in text.
442
443 bool wxPalmDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
444 {
445 return false;
446 }
447
448 void wxPalmDCImpl::RealizeScaleAndOrigin()
449 {
450 }
451
452 void wxPalmDCImpl::SetMapMode(int mode)
453 {
454 }
455
456 void wxPalmDCImpl::SetUserScale(double x, double y)
457 {
458 }
459
460 void wxPalmDCImpl::SetAxisOrientation(bool xLeftRight,
461 bool yBottomUp)
462 {
463 }
464
465 void wxPalmDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y)
466 {
467 }
468
469 void wxPalmDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)
470 {
471 }
472
473 // ---------------------------------------------------------------------------
474 // bit blit
475 // ---------------------------------------------------------------------------
476
477 bool wxPalmDCImpl::DoBlit(wxCoord dstX, wxCoord dstY,
478 wxCoord dstWidth, wxCoord dstHeight,
479 wxDC *source,
480 wxCoord srcX, wxCoord srcY,
481 int rop, bool useMask,
482 wxCoord srcMaskX, wxCoord srcMaskY)
483 {
484 return false;
485 }
486
487 bool wxPalmDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest,
488 wxCoord dstWidth, wxCoord dstHeight,
489 wxDC *source,
490 wxCoord xsrc, wxCoord ysrc,
491 wxCoord srcWidth, wxCoord srcHeight,
492 int rop, bool useMask,
493 wxCoord xsrcMask, wxCoord ysrcMask)
494 {
495 return false;
496 }
497
498 void wxPalmDCImpl::GetDeviceSize(int *width, int *height) const
499 {
500 }
501
502 void wxPalmDCImpl::DoGetSizeMM(int *w, int *h) const
503 {
504 }
505
506 wxSize wxPalmDCImpl::GetPPI() const
507 {
508 return wxSize(0, 0);
509 }
510
511 // For use by wxWidgets only, unless custom units are required.
512 void wxPalmDCImpl::SetLogicalScale(double x, double y)
513 {
514 }
515
516 // ----------------------------------------------------------------------------
517 // DC caching
518 // ----------------------------------------------------------------------------
519
520 #if wxUSE_DC_CACHEING
521
522 /*
523 * This implementation is a bit ugly and uses the old-fashioned wxList class, so I will
524 * improve it in due course, either using arrays, or simply storing pointers to one
525 * entry for the bitmap, and two for the DCs. -- JACS
526 */
527
528 wxObjectList wxPalmDCImpl::sm_bitmapCache;
529 wxObjectList wxPalmDCImpl::sm_dcCache;
530
531 wxDCCacheEntry::wxDCCacheEntry(WXHBITMAP hBitmap, int w, int h, int depth)
532 {
533 m_bitmap = hBitmap;
534 m_dc = 0;
535 m_width = w;
536 m_height = h;
537 m_depth = depth;
538 }
539
540 wxDCCacheEntry::wxDCCacheEntry(WXHDC hDC, int depth)
541 {
542 }
543
544 wxDCCacheEntry::~wxDCCacheEntry()
545 {
546 }
547
548 wxDCCacheEntry* wxPalmDCImpl::FindBitmapInCache(WXHDC dc, int w, int h)
549 {
550 return NULL;
551 }
552
553 wxDCCacheEntry* wxPalmDCImpl::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc)
554 {
555 return NULL;
556 }
557
558 void wxPalmDCImpl::AddToBitmapCache(wxDCCacheEntry* entry)
559 {
560 }
561
562 void wxPalmDCImpl::AddToDCCache(wxDCCacheEntry* entry)
563 {
564 }
565
566 void wxPalmDCImpl::ClearCache()
567 {
568 }
569
570 // Clean up cache at app exit
571 class wxDCModule : public wxModule
572 {
573 public:
574 virtual bool OnInit() { return true; }
575 virtual void OnExit() { wxPalmDCImpl::ClearCache(); }
576
577 private:
578 DECLARE_DYNAMIC_CLASS(wxDCModule)
579 };
580
581 IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
582
583 #endif // wxUSE_DC_CACHEING
584
585 void wxPalmDCImpl::DoGradientFillLinear (const wxRect& rect,
586 const wxColour& initialColour,
587 const wxColour& destColour,
588 wxDirection nDirection)
589 {
590 }
591
592 #if wxUSE_DYNLIB_CLASS
593
594 wxLayoutDirection wxPalmDCImpl::GetLayoutDirection() const
595 {
596 DWORD layout = wxGetDCLayout(GetHdc());
597
598 if ( layout == (DWORD)-1 )
599 return wxLayout_Default;
600
601 return layout & LAYOUT_RTL ? wxLayout_RightToLeft : wxLayout_LeftToRight;
602 }
603
604 void wxPalmDCImpl::SetLayoutDirection(wxLayoutDirection dir)
605 {
606 }
607
608 #else // !wxUSE_DYNLIB_CLASS
609
610 // we can't provide RTL support without dynamic loading, so stub it out
611 wxLayoutDirection wxPalmDCImpl::GetLayoutDirection() const
612 {
613 return wxLayout_Default;
614 }
615
616 void wxPalmDCImpl::SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
617 {
618 }
619
620 #endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS