]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/dc.cpp
Split wxDataViewVirtualModel fork wxDataViewIndexModel to make the code clearer and...
[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
JS
46
47#ifdef wxHAVE_RAW_BITMAP
48#include "wx/rawbmp.h"
49#endif
50
e2fc40b4 51#include "wx/palmos/dc.h"
ffecfa5a
JS
52
53#ifndef AC_SRC_ALPHA
e2fc40b4
VZ
54 #define AC_SRC_ALPHA 1
55#endif
56
57#ifndef LAYOUT_RTL
58 #define LAYOUT_RTL 1
ffecfa5a
JS
59#endif
60
61/* Quaternary raster codes */
62#ifndef MAKEROP4
63#define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore))
64#endif
65
e2fc40b4
VZ
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
76IMPLEMENT_ABSTRACT_CLASS(wxPalmDCImpl, wxDCImpl)
ffecfa5a
JS
77
78// ---------------------------------------------------------------------------
79// constants
80// ---------------------------------------------------------------------------
81
e2fc40b4
VZ
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
ffecfa5a 85
e2fc40b4
VZ
86// ----------------------------------------------------------------------------
87// macros for logical <-> device coords conversion
88// ----------------------------------------------------------------------------
ffecfa5a 89
e2fc40b4
VZ
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
ffecfa5a
JS
108
109// ---------------------------------------------------------------------------
110// private functions
111// ---------------------------------------------------------------------------
112
113// ----------------------------------------------------------------------------
114// private classes
115// ----------------------------------------------------------------------------
116
e2fc40b4
VZ
117#if wxUSE_DYNLIB_CLASS
118
119// helper class to cache dynamically loaded libraries and not attempt reloading
120// them if it fails
121class wxOnceOnlyDLLLoader
122{
123public:
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
158private:
159 wxDynamicLibrary m_dll;
160 const wxChar *m_dllName;
161};
162
163#endif // wxUSE_DYNLIB_CLASS
164
ffecfa5a
JS
165// ===========================================================================
166// implementation
167// ===========================================================================
168
169// ---------------------------------------------------------------------------
e2fc40b4 170// wxPalmDCImpl
ffecfa5a
JS
171// ---------------------------------------------------------------------------
172
e2fc40b4
VZ
173wxPalmDCImpl::wxPalmDCImpl( wxDC *owner, WXHDC hDC ) :
174 wxDCImpl( owner )
ffecfa5a 175{
e2fc40b4
VZ
176 Init();
177 m_hDC = hDC;
ffecfa5a
JS
178}
179
e2fc40b4 180wxPalmDCImpl::~wxPalmDCImpl()
ffecfa5a
JS
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.
e2fc40b4 187void wxPalmDCImpl::SelectOldObjects(WXHDC dc)
ffecfa5a
JS
188{
189}
190
191// ---------------------------------------------------------------------------
192// clipping
193// ---------------------------------------------------------------------------
194
e2fc40b4 195void wxPalmDCImpl::UpdateClipBox()
ffecfa5a
JS
196{
197}
198
199void
e2fc40b4 200wxPalmDCImpl::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
ffecfa5a
JS
201{
202}
203
204// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
e2fc40b4 205void wxPalmDCImpl::SetClippingHrgn(WXHRGN hrgn)
ffecfa5a 206{
e2fc40b4 207 wxCHECK_RET( hrgn, wxT("invalid clipping region") );
ffecfa5a
JS
208}
209
e2fc40b4 210void wxPalmDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
ffecfa5a
JS
211{
212}
213
e2fc40b4 214void wxPalmDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
ffecfa5a
JS
215{
216}
217
e2fc40b4 218void wxPalmDCImpl::DestroyClippingRegion()
ffecfa5a
JS
219{
220}
221
222// ---------------------------------------------------------------------------
223// query capabilities
224// ---------------------------------------------------------------------------
225
e2fc40b4 226bool wxPalmDCImpl::CanDrawBitmap() const
ffecfa5a
JS
227{
228 return false;
229}
230
e2fc40b4 231bool wxPalmDCImpl::CanGetTextExtent() const
ffecfa5a
JS
232{
233 return false;
234}
235
e2fc40b4 236int wxPalmDCImpl::GetDepth() const
ffecfa5a
JS
237{
238 return 0;
239}
240
241// ---------------------------------------------------------------------------
242// drawing
243// ---------------------------------------------------------------------------
244
e2fc40b4 245void wxPalmDCImpl::Clear()
ffecfa5a
JS
246{
247}
248
e2fc40b4
VZ
249bool 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))
ffecfa5a
JS
253{
254 return false;
255}
256
e2fc40b4 257bool wxPalmDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
ffecfa5a
JS
258{
259 return false;
260}
261
e2fc40b4 262void wxPalmDCImpl::DoCrossHair(wxCoord x, wxCoord y)
ffecfa5a
JS
263{
264}
265
e2fc40b4 266void wxPalmDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
ffecfa5a
JS
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)
e2fc40b4 272void wxPalmDCImpl::DoDrawArc(wxCoord x1, wxCoord y1,
ffecfa5a
JS
273 wxCoord x2, wxCoord y2,
274 wxCoord xc, wxCoord yc)
275{
276}
277
e2fc40b4 278void wxPalmDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1,
ffecfa5a
JS
279 wxCoord width, wxCoord height)
280{
281}
282
e2fc40b4 283void wxPalmDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
ffecfa5a
JS
284{
285}
286
e2fc40b4
VZ
287void wxPalmDCImpl::DoDrawPolygon(int n,
288 wxPoint points[],
289 wxCoord xoffset,
290 wxCoord yoffset,
291 int WXUNUSED_IN_WINCE(fillStyle))
ffecfa5a
JS
292{
293}
294
295void
e2fc40b4 296wxPalmDCImpl::DoDrawPolyPolygon(int n,
ffecfa5a
JS
297 int count[],
298 wxPoint points[],
299 wxCoord xoffset,
300 wxCoord yoffset,
301 int fillStyle)
302{
303}
304
e2fc40b4 305void wxPalmDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
ffecfa5a
JS
306{
307}
308
e2fc40b4 309void wxPalmDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
ffecfa5a
JS
310{
311}
312
e2fc40b4 313void wxPalmDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
ffecfa5a
JS
314{
315}
316
e2fc40b4 317void wxPalmDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
ffecfa5a
JS
318{
319}
320
e2fc40b4
VZ
321#if wxUSE_SPLINES
322void wxPalmDCImpl::DoDrawSpline(const wxPointList *points)
323{
324}
325#endif
326
327// Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows
328void wxPalmDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
ffecfa5a
JS
329{
330}
331
e2fc40b4 332void wxPalmDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
ffecfa5a
JS
333{
334}
335
e2fc40b4 336void wxPalmDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
ffecfa5a
JS
337{
338}
339
e2fc40b4 340void wxPalmDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
ffecfa5a
JS
341{
342}
343
e2fc40b4 344void wxPalmDCImpl::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
ffecfa5a
JS
345{
346}
347
e2fc40b4 348void wxPalmDCImpl::DoDrawRotatedText(const wxString& text,
ffecfa5a
JS
349 wxCoord x, wxCoord y,
350 double angle)
351{
352}
353
354// ---------------------------------------------------------------------------
355// set GDI objects
356// ---------------------------------------------------------------------------
357
358#if wxUSE_PALETTE
359
e2fc40b4 360void wxPalmDCImpl::DoSelectPalette(bool realize)
ffecfa5a
JS
361{
362}
363
e2fc40b4 364void wxPalmDCImpl::SetPalette(const wxPalette& palette)
ffecfa5a
JS
365{
366}
367
e2fc40b4 368void wxPalmDCImpl::InitializePalette()
ffecfa5a
JS
369{
370}
371
372#endif // wxUSE_PALETTE
373
e2fc40b4
VZ
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
377void wxPalmDCImpl::SetFont(const wxFont& font)
ffecfa5a
JS
378{
379}
380
e2fc40b4 381void wxPalmDCImpl::SetPen(const wxPen& pen)
ffecfa5a
JS
382{
383}
384
e2fc40b4 385void wxPalmDCImpl::SetBrush(const wxBrush& brush)
ffecfa5a
JS
386{
387}
388
e2fc40b4 389void wxPalmDCImpl::SetBackground(const wxBrush& brush)
ffecfa5a
JS
390{
391}
392
e2fc40b4 393void wxPalmDCImpl::SetBackgroundMode(int mode)
ffecfa5a
JS
394{
395}
396
e2fc40b4 397void wxPalmDCImpl::SetLogicalFunction(int function)
ffecfa5a
JS
398{
399}
400
e2fc40b4 401void wxPalmDCImpl::SetRop(WXHDC dc)
ffecfa5a
JS
402{
403}
404
e2fc40b4 405bool wxPalmDCImpl::StartDoc(const wxString& WXUNUSED(message))
ffecfa5a 406{
e2fc40b4 407 // We might be previewing, so return true to let it continue.
ffecfa5a
JS
408 return true;
409}
410
e2fc40b4 411void wxPalmDCImpl::EndDoc()
ffecfa5a
JS
412{
413}
414
e2fc40b4 415void wxPalmDCImpl::StartPage()
ffecfa5a
JS
416{
417}
418
e2fc40b4 419void wxPalmDCImpl::EndPage()
ffecfa5a
JS
420{
421}
422
423// ---------------------------------------------------------------------------
424// text metrics
425// ---------------------------------------------------------------------------
426
e2fc40b4 427wxCoord wxPalmDCImpl::GetCharHeight() const
ffecfa5a
JS
428{
429 return 0;
430}
431
e2fc40b4 432wxCoord wxPalmDCImpl::GetCharWidth() const
ffecfa5a
JS
433{
434 return 0;
435}
436
e2fc40b4 437void wxPalmDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
ffecfa5a 438 wxCoord *descent, wxCoord *externalLeading,
c94f845b 439 const wxFont *font) const
ffecfa5a
JS
440{
441}
442
443
e2fc40b4
VZ
444// Each element of the array will be the width of the string up to and
445// including the coresoponding character in text.
446
447bool wxPalmDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
ffecfa5a
JS
448{
449 return false;
450}
451
e2fc40b4 452void wxPalmDCImpl::RealizeScaleAndOrigin()
ffecfa5a
JS
453{
454}
455
e2fc40b4 456void wxPalmDCImpl::SetMapMode(int mode)
ffecfa5a
JS
457{
458}
459
e2fc40b4 460void wxPalmDCImpl::SetUserScale(double x, double y)
ffecfa5a
JS
461{
462}
463
e2fc40b4
VZ
464void wxPalmDCImpl::SetAxisOrientation(bool xLeftRight,
465 bool yBottomUp)
ffecfa5a
JS
466{
467}
468
e2fc40b4 469void wxPalmDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y)
ffecfa5a
JS
470{
471}
472
e2fc40b4 473void wxPalmDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)
ffecfa5a
JS
474{
475}
476
477// ---------------------------------------------------------------------------
e2fc40b4 478// bit blit
ffecfa5a
JS
479// ---------------------------------------------------------------------------
480
e2fc40b4
VZ
481bool 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)
ffecfa5a 487{
e2fc40b4 488 return false;
ffecfa5a
JS
489}
490
e2fc40b4
VZ
491bool 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)
ffecfa5a
JS
498{
499 return false;
500}
501
e2fc40b4 502void wxPalmDCImpl::GetDeviceSize(int *width, int *height) const
ffecfa5a
JS
503{
504}
505
e2fc40b4 506void wxPalmDCImpl::DoGetSizeMM(int *w, int *h) const
ffecfa5a
JS
507{
508}
509
e2fc40b4 510wxSize wxPalmDCImpl::GetPPI() const
ffecfa5a
JS
511{
512 return wxSize(0, 0);
513}
514
e2fc40b4
VZ
515// For use by wxWidgets only, unless custom units are required.
516void wxPalmDCImpl::SetLogicalScale(double x, double y)
ffecfa5a
JS
517{
518}
519
520// ----------------------------------------------------------------------------
521// DC caching
522// ----------------------------------------------------------------------------
523
524#if wxUSE_DC_CACHEING
525
e2fc40b4
VZ
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
532wxObjectList wxPalmDCImpl::sm_bitmapCache;
533wxObjectList wxPalmDCImpl::sm_dcCache;
ffecfa5a
JS
534
535wxDCCacheEntry::wxDCCacheEntry(WXHBITMAP hBitmap, int w, int h, int depth)
536{
e2fc40b4
VZ
537 m_bitmap = hBitmap;
538 m_dc = 0;
539 m_width = w;
540 m_height = h;
541 m_depth = depth;
ffecfa5a
JS
542}
543
544wxDCCacheEntry::wxDCCacheEntry(WXHDC hDC, int depth)
545{
546}
547
548wxDCCacheEntry::~wxDCCacheEntry()
549{
550}
551
e2fc40b4 552wxDCCacheEntry* wxPalmDCImpl::FindBitmapInCache(WXHDC dc, int w, int h)
ffecfa5a
JS
553{
554 return NULL;
555}
556
e2fc40b4 557wxDCCacheEntry* wxPalmDCImpl::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc)
ffecfa5a
JS
558{
559 return NULL;
560}
561
e2fc40b4 562void wxPalmDCImpl::AddToBitmapCache(wxDCCacheEntry* entry)
ffecfa5a
JS
563{
564}
565
e2fc40b4 566void wxPalmDCImpl::AddToDCCache(wxDCCacheEntry* entry)
ffecfa5a
JS
567{
568}
569
e2fc40b4 570void wxPalmDCImpl::ClearCache()
ffecfa5a
JS
571{
572}
573
e2fc40b4 574// Clean up cache at app exit
ffecfa5a
JS
575class wxDCModule : public wxModule
576{
577public:
578 virtual bool OnInit() { return true; }
e2fc40b4 579 virtual void OnExit() { wxPalmDCImpl::ClearCache(); }
ffecfa5a
JS
580
581private:
582 DECLARE_DYNAMIC_CLASS(wxDCModule)
583};
584
585IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
586
587#endif // wxUSE_DC_CACHEING
e2fc40b4
VZ
588
589void 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
598wxLayoutDirection 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
608void 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
615wxLayoutDirection wxPalmDCImpl::GetLayoutDirection() const
616{
617 return wxLayout_Default;
618}
619
620void wxPalmDCImpl::SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
621{
622}
623
624#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS