]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/dc.cpp
specify the name of the control (#9515)
[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
200// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
e2fc40b4 201void wxPalmDCImpl::SetClippingHrgn(WXHRGN hrgn)
ffecfa5a 202{
e2fc40b4 203 wxCHECK_RET( hrgn, wxT("invalid clipping region") );
ffecfa5a
JS
204}
205
e2fc40b4 206void wxPalmDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
ffecfa5a
JS
207{
208}
209
e2fc40b4 210void wxPalmDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
ffecfa5a
JS
211{
212}
213
e2fc40b4 214void wxPalmDCImpl::DestroyClippingRegion()
ffecfa5a
JS
215{
216}
217
218// ---------------------------------------------------------------------------
219// query capabilities
220// ---------------------------------------------------------------------------
221
e2fc40b4 222bool wxPalmDCImpl::CanDrawBitmap() const
ffecfa5a
JS
223{
224 return false;
225}
226
e2fc40b4 227bool wxPalmDCImpl::CanGetTextExtent() const
ffecfa5a
JS
228{
229 return false;
230}
231
e2fc40b4 232int wxPalmDCImpl::GetDepth() const
ffecfa5a
JS
233{
234 return 0;
235}
236
237// ---------------------------------------------------------------------------
238// drawing
239// ---------------------------------------------------------------------------
240
e2fc40b4 241void wxPalmDCImpl::Clear()
ffecfa5a
JS
242{
243}
244
e2fc40b4
VZ
245bool 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))
ffecfa5a
JS
249{
250 return false;
251}
252
e2fc40b4 253bool wxPalmDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
ffecfa5a
JS
254{
255 return false;
256}
257
e2fc40b4 258void wxPalmDCImpl::DoCrossHair(wxCoord x, wxCoord y)
ffecfa5a
JS
259{
260}
261
e2fc40b4 262void wxPalmDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
ffecfa5a
JS
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)
e2fc40b4 268void wxPalmDCImpl::DoDrawArc(wxCoord x1, wxCoord y1,
ffecfa5a
JS
269 wxCoord x2, wxCoord y2,
270 wxCoord xc, wxCoord yc)
271{
272}
273
e2fc40b4 274void wxPalmDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1,
ffecfa5a
JS
275 wxCoord width, wxCoord height)
276{
277}
278
e2fc40b4 279void wxPalmDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
ffecfa5a
JS
280{
281}
282
e2fc40b4
VZ
283void wxPalmDCImpl::DoDrawPolygon(int n,
284 wxPoint points[],
285 wxCoord xoffset,
286 wxCoord yoffset,
287 int WXUNUSED_IN_WINCE(fillStyle))
ffecfa5a
JS
288{
289}
290
291void
e2fc40b4 292wxPalmDCImpl::DoDrawPolyPolygon(int n,
ffecfa5a
JS
293 int count[],
294 wxPoint points[],
295 wxCoord xoffset,
296 wxCoord yoffset,
297 int fillStyle)
298{
299}
300
e2fc40b4 301void wxPalmDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
ffecfa5a
JS
302{
303}
304
e2fc40b4 305void wxPalmDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
ffecfa5a
JS
306{
307}
308
e2fc40b4 309void wxPalmDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
ffecfa5a
JS
310{
311}
312
e2fc40b4 313void wxPalmDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
ffecfa5a
JS
314{
315}
316
e2fc40b4
VZ
317#if wxUSE_SPLINES
318void wxPalmDCImpl::DoDrawSpline(const wxPointList *points)
319{
320}
321#endif
322
323// Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows
324void wxPalmDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
ffecfa5a
JS
325{
326}
327
e2fc40b4 328void wxPalmDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
ffecfa5a
JS
329{
330}
331
e2fc40b4 332void wxPalmDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
ffecfa5a
JS
333{
334}
335
e2fc40b4 336void wxPalmDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
ffecfa5a
JS
337{
338}
339
e2fc40b4 340void wxPalmDCImpl::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
ffecfa5a
JS
341{
342}
343
e2fc40b4 344void wxPalmDCImpl::DoDrawRotatedText(const wxString& text,
ffecfa5a
JS
345 wxCoord x, wxCoord y,
346 double angle)
347{
348}
349
350// ---------------------------------------------------------------------------
351// set GDI objects
352// ---------------------------------------------------------------------------
353
354#if wxUSE_PALETTE
355
e2fc40b4 356void wxPalmDCImpl::DoSelectPalette(bool realize)
ffecfa5a
JS
357{
358}
359
e2fc40b4 360void wxPalmDCImpl::SetPalette(const wxPalette& palette)
ffecfa5a
JS
361{
362}
363
e2fc40b4 364void wxPalmDCImpl::InitializePalette()
ffecfa5a
JS
365{
366}
367
368#endif // wxUSE_PALETTE
369
e2fc40b4
VZ
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
373void wxPalmDCImpl::SetFont(const wxFont& font)
ffecfa5a
JS
374{
375}
376
e2fc40b4 377void wxPalmDCImpl::SetPen(const wxPen& pen)
ffecfa5a
JS
378{
379}
380
e2fc40b4 381void wxPalmDCImpl::SetBrush(const wxBrush& brush)
ffecfa5a
JS
382{
383}
384
e2fc40b4 385void wxPalmDCImpl::SetBackground(const wxBrush& brush)
ffecfa5a
JS
386{
387}
388
e2fc40b4 389void wxPalmDCImpl::SetBackgroundMode(int mode)
ffecfa5a
JS
390{
391}
392
e2fc40b4 393void wxPalmDCImpl::SetLogicalFunction(int function)
ffecfa5a
JS
394{
395}
396
e2fc40b4 397void wxPalmDCImpl::SetRop(WXHDC dc)
ffecfa5a
JS
398{
399}
400
e2fc40b4 401bool wxPalmDCImpl::StartDoc(const wxString& WXUNUSED(message))
ffecfa5a 402{
e2fc40b4 403 // We might be previewing, so return true to let it continue.
ffecfa5a
JS
404 return true;
405}
406
e2fc40b4 407void wxPalmDCImpl::EndDoc()
ffecfa5a
JS
408{
409}
410
e2fc40b4 411void wxPalmDCImpl::StartPage()
ffecfa5a
JS
412{
413}
414
e2fc40b4 415void wxPalmDCImpl::EndPage()
ffecfa5a
JS
416{
417}
418
419// ---------------------------------------------------------------------------
420// text metrics
421// ---------------------------------------------------------------------------
422
e2fc40b4 423wxCoord wxPalmDCImpl::GetCharHeight() const
ffecfa5a
JS
424{
425 return 0;
426}
427
e2fc40b4 428wxCoord wxPalmDCImpl::GetCharWidth() const
ffecfa5a
JS
429{
430 return 0;
431}
432
e2fc40b4 433void wxPalmDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
ffecfa5a 434 wxCoord *descent, wxCoord *externalLeading,
c94f845b 435 const wxFont *font) const
ffecfa5a
JS
436{
437}
438
439
e2fc40b4
VZ
440// Each element of the array will be the width of the string up to and
441// including the coresoponding character in text.
442
443bool wxPalmDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
ffecfa5a
JS
444{
445 return false;
446}
447
e2fc40b4 448void wxPalmDCImpl::RealizeScaleAndOrigin()
ffecfa5a
JS
449{
450}
451
e2fc40b4 452void wxPalmDCImpl::SetMapMode(int mode)
ffecfa5a
JS
453{
454}
455
e2fc40b4 456void wxPalmDCImpl::SetUserScale(double x, double y)
ffecfa5a
JS
457{
458}
459
e2fc40b4
VZ
460void wxPalmDCImpl::SetAxisOrientation(bool xLeftRight,
461 bool yBottomUp)
ffecfa5a
JS
462{
463}
464
e2fc40b4 465void wxPalmDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y)
ffecfa5a
JS
466{
467}
468
e2fc40b4 469void wxPalmDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)
ffecfa5a
JS
470{
471}
472
473// ---------------------------------------------------------------------------
e2fc40b4 474// bit blit
ffecfa5a
JS
475// ---------------------------------------------------------------------------
476
e2fc40b4
VZ
477bool 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)
ffecfa5a 483{
e2fc40b4 484 return false;
ffecfa5a
JS
485}
486
e2fc40b4
VZ
487bool 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)
ffecfa5a
JS
494{
495 return false;
496}
497
e2fc40b4 498void wxPalmDCImpl::GetDeviceSize(int *width, int *height) const
ffecfa5a
JS
499{
500}
501
e2fc40b4 502void wxPalmDCImpl::DoGetSizeMM(int *w, int *h) const
ffecfa5a
JS
503{
504}
505
e2fc40b4 506wxSize wxPalmDCImpl::GetPPI() const
ffecfa5a
JS
507{
508 return wxSize(0, 0);
509}
510
e2fc40b4
VZ
511// For use by wxWidgets only, unless custom units are required.
512void wxPalmDCImpl::SetLogicalScale(double x, double y)
ffecfa5a
JS
513{
514}
515
516// ----------------------------------------------------------------------------
517// DC caching
518// ----------------------------------------------------------------------------
519
520#if wxUSE_DC_CACHEING
521
e2fc40b4
VZ
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
528wxObjectList wxPalmDCImpl::sm_bitmapCache;
529wxObjectList wxPalmDCImpl::sm_dcCache;
ffecfa5a
JS
530
531wxDCCacheEntry::wxDCCacheEntry(WXHBITMAP hBitmap, int w, int h, int depth)
532{
e2fc40b4
VZ
533 m_bitmap = hBitmap;
534 m_dc = 0;
535 m_width = w;
536 m_height = h;
537 m_depth = depth;
ffecfa5a
JS
538}
539
540wxDCCacheEntry::wxDCCacheEntry(WXHDC hDC, int depth)
541{
542}
543
544wxDCCacheEntry::~wxDCCacheEntry()
545{
546}
547
e2fc40b4 548wxDCCacheEntry* wxPalmDCImpl::FindBitmapInCache(WXHDC dc, int w, int h)
ffecfa5a
JS
549{
550 return NULL;
551}
552
e2fc40b4 553wxDCCacheEntry* wxPalmDCImpl::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc)
ffecfa5a
JS
554{
555 return NULL;
556}
557
e2fc40b4 558void wxPalmDCImpl::AddToBitmapCache(wxDCCacheEntry* entry)
ffecfa5a
JS
559{
560}
561
e2fc40b4 562void wxPalmDCImpl::AddToDCCache(wxDCCacheEntry* entry)
ffecfa5a
JS
563{
564}
565
e2fc40b4 566void wxPalmDCImpl::ClearCache()
ffecfa5a
JS
567{
568}
569
e2fc40b4 570// Clean up cache at app exit
ffecfa5a
JS
571class wxDCModule : public wxModule
572{
573public:
574 virtual bool OnInit() { return true; }
e2fc40b4 575 virtual void OnExit() { wxPalmDCImpl::ClearCache(); }
ffecfa5a
JS
576
577private:
578 DECLARE_DYNAMIC_CLASS(wxDCModule)
579};
580
581IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
582
583#endif // wxUSE_DC_CACHEING
e2fc40b4
VZ
584
585void 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
594wxLayoutDirection 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
604void 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
611wxLayoutDirection wxPalmDCImpl::GetLayoutDirection() const
612{
613 return wxLayout_Default;
614}
615
616void wxPalmDCImpl::SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
617{
618}
619
620#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS