]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/dc.cpp
Remove wxUSE_WCHAR_T checks.
[wxWidgets.git] / src / palmos / dc.cpp
CommitLineData
ffecfa5a 1/////////////////////////////////////////////////////////////////////////////
e2731512 2// Name: src/palmos/dc.cpp
ffecfa5a 3// Purpose: wxDC class
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/13/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
e2fc40b4
VZ
20#include <string.h>
21
ffecfa5a
JS
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
e2fc40b4 30 #include "wx/image.h"
ffecfa5a
JS
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"
6d50343d 40 #include "wx/dcprint.h"
02761f6c 41 #include "wx/module.h"
ffecfa5a
JS
42#endif
43
44#include "wx/sysopt.h"
e2fc40b4 45#include "wx/dynlib.h"
ffecfa5a 46
e2fc40b4 47#include "wx/palmos/dc.h"
ffecfa5a
JS
48
49#ifndef AC_SRC_ALPHA
e2fc40b4
VZ
50 #define AC_SRC_ALPHA 1
51#endif
52
53#ifndef LAYOUT_RTL
54 #define LAYOUT_RTL 1
ffecfa5a
JS
55#endif
56
57/* Quaternary raster codes */
58#ifndef MAKEROP4
59#define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore))
60#endif
61
e2fc40b4
VZ
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
72IMPLEMENT_ABSTRACT_CLASS(wxPalmDCImpl, wxDCImpl)
ffecfa5a
JS
73
74// ---------------------------------------------------------------------------
75// constants
76// ---------------------------------------------------------------------------
77
e2fc40b4
VZ
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
ffecfa5a 81
e2fc40b4
VZ
82// ----------------------------------------------------------------------------
83// macros for logical <-> device coords conversion
84// ----------------------------------------------------------------------------
ffecfa5a 85
e2fc40b4
VZ
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
ffecfa5a
JS
104
105// ---------------------------------------------------------------------------
106// private functions
107// ---------------------------------------------------------------------------
108
109// ----------------------------------------------------------------------------
110// private classes
111// ----------------------------------------------------------------------------
112
e2fc40b4
VZ
113#if wxUSE_DYNLIB_CLASS
114
115// helper class to cache dynamically loaded libraries and not attempt reloading
116// them if it fails
117class wxOnceOnlyDLLLoader
118{
119public:
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
154private:
155 wxDynamicLibrary m_dll;
156 const wxChar *m_dllName;
157};
158
159#endif // wxUSE_DYNLIB_CLASS
160
ffecfa5a
JS
161// ===========================================================================
162// implementation
163// ===========================================================================
164
165// ---------------------------------------------------------------------------
e2fc40b4 166// wxPalmDCImpl
ffecfa5a
JS
167// ---------------------------------------------------------------------------
168
e2fc40b4
VZ
169wxPalmDCImpl::wxPalmDCImpl( wxDC *owner, WXHDC hDC ) :
170 wxDCImpl( owner )
ffecfa5a 171{
e2fc40b4
VZ
172 Init();
173 m_hDC = hDC;
ffecfa5a
JS
174}
175
e2fc40b4 176wxPalmDCImpl::~wxPalmDCImpl()
ffecfa5a
JS
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.
e2fc40b4 183void wxPalmDCImpl::SelectOldObjects(WXHDC dc)
ffecfa5a
JS
184{
185}
186
187// ---------------------------------------------------------------------------
188// clipping
189// ---------------------------------------------------------------------------
190
e2fc40b4 191void wxPalmDCImpl::UpdateClipBox()
ffecfa5a
JS
192{
193}
194
195void
e2fc40b4 196wxPalmDCImpl::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
ffecfa5a
JS
197{
198}
199
e2fc40b4 200void wxPalmDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
ffecfa5a
JS
201{
202}
203
fdaad94e 204void wxPalmDCImpl::DoSetDeviceClippingRegion(const wxRegion& region)
ffecfa5a
JS
205{
206}
207
e2fc40b4 208void wxPalmDCImpl::DestroyClippingRegion()
ffecfa5a
JS
209{
210}
211
212// ---------------------------------------------------------------------------
213// query capabilities
214// ---------------------------------------------------------------------------
215
e2fc40b4 216bool wxPalmDCImpl::CanDrawBitmap() const
ffecfa5a
JS
217{
218 return false;
219}
220
e2fc40b4 221bool wxPalmDCImpl::CanGetTextExtent() const
ffecfa5a
JS
222{
223 return false;
224}
225
e2fc40b4 226int wxPalmDCImpl::GetDepth() const
ffecfa5a
JS
227{
228 return 0;
229}
230
231// ---------------------------------------------------------------------------
232// drawing
233// ---------------------------------------------------------------------------
234
e2fc40b4 235void wxPalmDCImpl::Clear()
ffecfa5a
JS
236{
237}
238
e2fc40b4
VZ
239bool wxPalmDCImpl::DoFloodFill(wxCoord WXUNUSED_IN_WINCE(x),
240 wxCoord WXUNUSED_IN_WINCE(y),
241 const wxColour& WXUNUSED_IN_WINCE(col),
89efaf2b 242 wxFloodFillStyle WXUNUSED_IN_WINCE(style))
ffecfa5a
JS
243{
244 return false;
245}
246
e2fc40b4 247bool wxPalmDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
ffecfa5a
JS
248{
249 return false;
250}
251
e2fc40b4 252void wxPalmDCImpl::DoCrossHair(wxCoord x, wxCoord y)
ffecfa5a
JS
253{
254}
255
e2fc40b4 256void wxPalmDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
ffecfa5a
JS
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)
e2fc40b4 262void wxPalmDCImpl::DoDrawArc(wxCoord x1, wxCoord y1,
ffecfa5a
JS
263 wxCoord x2, wxCoord y2,
264 wxCoord xc, wxCoord yc)
265{
266}
267
e2fc40b4 268void wxPalmDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1,
ffecfa5a
JS
269 wxCoord width, wxCoord height)
270{
271}
272
e2fc40b4 273void wxPalmDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
ffecfa5a
JS
274{
275}
276
e2fc40b4
VZ
277void wxPalmDCImpl::DoDrawPolygon(int n,
278 wxPoint points[],
279 wxCoord xoffset,
280 wxCoord yoffset,
89efaf2b 281 wxPolygonFillMode WXUNUSED_IN_WINCE(fillStyle))
ffecfa5a
JS
282{
283}
284
285void
e2fc40b4 286wxPalmDCImpl::DoDrawPolyPolygon(int n,
ffecfa5a
JS
287 int count[],
288 wxPoint points[],
289 wxCoord xoffset,
290 wxCoord yoffset,
89efaf2b 291 wxPolygonFillMode fillStyle)
ffecfa5a
JS
292{
293}
294
e2fc40b4 295void wxPalmDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
ffecfa5a
JS
296{
297}
298
e2fc40b4 299void wxPalmDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
ffecfa5a
JS
300{
301}
302
e2fc40b4 303void wxPalmDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
ffecfa5a
JS
304{
305}
306
e2fc40b4 307void wxPalmDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
ffecfa5a
JS
308{
309}
310
e2fc40b4
VZ
311#if wxUSE_SPLINES
312void wxPalmDCImpl::DoDrawSpline(const wxPointList *points)
313{
314}
315#endif
316
317// Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows
318void wxPalmDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
ffecfa5a
JS
319{
320}
321
e2fc40b4 322void wxPalmDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
ffecfa5a
JS
323{
324}
325
e2fc40b4 326void wxPalmDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
ffecfa5a
JS
327{
328}
329
e2fc40b4 330void wxPalmDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
ffecfa5a
JS
331{
332}
333
e2fc40b4 334void wxPalmDCImpl::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
ffecfa5a
JS
335{
336}
337
e2fc40b4 338void wxPalmDCImpl::DoDrawRotatedText(const wxString& text,
ffecfa5a
JS
339 wxCoord x, wxCoord y,
340 double angle)
341{
342}
343
344// ---------------------------------------------------------------------------
345// set GDI objects
346// ---------------------------------------------------------------------------
347
348#if wxUSE_PALETTE
349
e2fc40b4 350void wxPalmDCImpl::DoSelectPalette(bool realize)
ffecfa5a
JS
351{
352}
353
e2fc40b4 354void wxPalmDCImpl::SetPalette(const wxPalette& palette)
ffecfa5a
JS
355{
356}
357
e2fc40b4 358void wxPalmDCImpl::InitializePalette()
ffecfa5a
JS
359{
360}
361
362#endif // wxUSE_PALETTE
363
e2fc40b4
VZ
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
367void wxPalmDCImpl::SetFont(const wxFont& font)
ffecfa5a
JS
368{
369}
370
e2fc40b4 371void wxPalmDCImpl::SetPen(const wxPen& pen)
ffecfa5a
JS
372{
373}
374
e2fc40b4 375void wxPalmDCImpl::SetBrush(const wxBrush& brush)
ffecfa5a
JS
376{
377}
378
e2fc40b4 379void wxPalmDCImpl::SetBackground(const wxBrush& brush)
ffecfa5a
JS
380{
381}
382
e2fc40b4 383void wxPalmDCImpl::SetBackgroundMode(int mode)
ffecfa5a
JS
384{
385}
386
89efaf2b 387void wxPalmDCImpl::SetLogicalFunction(wxRasterOperationMode function)
ffecfa5a
JS
388{
389}
390
e2fc40b4 391void wxPalmDCImpl::SetRop(WXHDC dc)
ffecfa5a
JS
392{
393}
394
e2fc40b4 395bool wxPalmDCImpl::StartDoc(const wxString& WXUNUSED(message))
ffecfa5a 396{
e2fc40b4 397 // We might be previewing, so return true to let it continue.
ffecfa5a
JS
398 return true;
399}
400
e2fc40b4 401void wxPalmDCImpl::EndDoc()
ffecfa5a
JS
402{
403}
404
e2fc40b4 405void wxPalmDCImpl::StartPage()
ffecfa5a
JS
406{
407}
408
e2fc40b4 409void wxPalmDCImpl::EndPage()
ffecfa5a
JS
410{
411}
412
413// ---------------------------------------------------------------------------
414// text metrics
415// ---------------------------------------------------------------------------
416
e2fc40b4 417wxCoord wxPalmDCImpl::GetCharHeight() const
ffecfa5a
JS
418{
419 return 0;
420}
421
e2fc40b4 422wxCoord wxPalmDCImpl::GetCharWidth() const
ffecfa5a
JS
423{
424 return 0;
425}
426
e2fc40b4 427void wxPalmDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
ffecfa5a 428 wxCoord *descent, wxCoord *externalLeading,
c94f845b 429 const wxFont *font) const
ffecfa5a
JS
430{
431}
432
433
e2fc40b4
VZ
434// Each element of the array will be the width of the string up to and
435// including the coresoponding character in text.
436
437bool wxPalmDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
ffecfa5a
JS
438{
439 return false;
440}
441
e2fc40b4 442void wxPalmDCImpl::RealizeScaleAndOrigin()
ffecfa5a
JS
443{
444}
445
89efaf2b 446void wxPalmDCImpl::SetMapMode(wxMappingMode mode)
ffecfa5a
JS
447{
448}
449
e2fc40b4 450void wxPalmDCImpl::SetUserScale(double x, double y)
ffecfa5a
JS
451{
452}
453
e2fc40b4
VZ
454void wxPalmDCImpl::SetAxisOrientation(bool xLeftRight,
455 bool yBottomUp)
ffecfa5a
JS
456{
457}
458
e2fc40b4 459void wxPalmDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y)
ffecfa5a
JS
460{
461}
462
e2fc40b4 463void wxPalmDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)
ffecfa5a
JS
464{
465}
466
467// ---------------------------------------------------------------------------
e2fc40b4 468// bit blit
ffecfa5a
JS
469// ---------------------------------------------------------------------------
470
e2fc40b4
VZ
471bool wxPalmDCImpl::DoBlit(wxCoord dstX, wxCoord dstY,
472 wxCoord dstWidth, wxCoord dstHeight,
473 wxDC *source,
474 wxCoord srcX, wxCoord srcY,
89efaf2b 475 wxRasterOperationMode rop, bool useMask,
e2fc40b4 476 wxCoord srcMaskX, wxCoord srcMaskY)
ffecfa5a 477{
e2fc40b4 478 return false;
ffecfa5a
JS
479}
480
e2fc40b4
VZ
481bool wxPalmDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest,
482 wxCoord dstWidth, wxCoord dstHeight,
483 wxDC *source,
484 wxCoord xsrc, wxCoord ysrc,
485 wxCoord srcWidth, wxCoord srcHeight,
89efaf2b 486 wxRasterOperationMode rop, bool useMask,
e2fc40b4 487 wxCoord xsrcMask, wxCoord ysrcMask)
ffecfa5a
JS
488{
489 return false;
490}
491
e2fc40b4 492void wxPalmDCImpl::GetDeviceSize(int *width, int *height) const
ffecfa5a
JS
493{
494}
495
e2fc40b4 496void wxPalmDCImpl::DoGetSizeMM(int *w, int *h) const
ffecfa5a
JS
497{
498}
499
e2fc40b4 500wxSize wxPalmDCImpl::GetPPI() const
ffecfa5a
JS
501{
502 return wxSize(0, 0);
503}
504
e2fc40b4
VZ
505// For use by wxWidgets only, unless custom units are required.
506void wxPalmDCImpl::SetLogicalScale(double x, double y)
ffecfa5a
JS
507{
508}
509
510// ----------------------------------------------------------------------------
511// DC caching
512// ----------------------------------------------------------------------------
513
514#if wxUSE_DC_CACHEING
515
e2fc40b4
VZ
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
522wxObjectList wxPalmDCImpl::sm_bitmapCache;
523wxObjectList wxPalmDCImpl::sm_dcCache;
ffecfa5a
JS
524
525wxDCCacheEntry::wxDCCacheEntry(WXHBITMAP hBitmap, int w, int h, int depth)
526{
e2fc40b4
VZ
527 m_bitmap = hBitmap;
528 m_dc = 0;
529 m_width = w;
530 m_height = h;
531 m_depth = depth;
ffecfa5a
JS
532}
533
534wxDCCacheEntry::wxDCCacheEntry(WXHDC hDC, int depth)
535{
536}
537
538wxDCCacheEntry::~wxDCCacheEntry()
539{
540}
541
e2fc40b4 542wxDCCacheEntry* wxPalmDCImpl::FindBitmapInCache(WXHDC dc, int w, int h)
ffecfa5a
JS
543{
544 return NULL;
545}
546
e2fc40b4 547wxDCCacheEntry* wxPalmDCImpl::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc)
ffecfa5a
JS
548{
549 return NULL;
550}
551
e2fc40b4 552void wxPalmDCImpl::AddToBitmapCache(wxDCCacheEntry* entry)
ffecfa5a
JS
553{
554}
555
e2fc40b4 556void wxPalmDCImpl::AddToDCCache(wxDCCacheEntry* entry)
ffecfa5a
JS
557{
558}
559
e2fc40b4 560void wxPalmDCImpl::ClearCache()
ffecfa5a
JS
561{
562}
563
e2fc40b4 564// Clean up cache at app exit
ffecfa5a
JS
565class wxDCModule : public wxModule
566{
567public:
568 virtual bool OnInit() { return true; }
e2fc40b4 569 virtual void OnExit() { wxPalmDCImpl::ClearCache(); }
ffecfa5a
JS
570
571private:
572 DECLARE_DYNAMIC_CLASS(wxDCModule)
573};
574
575IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
576
577#endif // wxUSE_DC_CACHEING
e2fc40b4
VZ
578
579void 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
588wxLayoutDirection 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
598void 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
605wxLayoutDirection wxPalmDCImpl::GetLayoutDirection() const
606{
607 return wxLayout_Default;
608}
609
610void wxPalmDCImpl::SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
611{
612}
613
614#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS