]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/palmos/dc.cpp
ensure that dialog gripper is always positioned below the other children, even if...
[wxWidgets.git] / src / palmos / dc.cpp
... / ...
CommitLineData
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
72IMPLEMENT_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
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
161// ===========================================================================
162// implementation
163// ===========================================================================
164
165// ---------------------------------------------------------------------------
166// wxPalmDCImpl
167// ---------------------------------------------------------------------------
168
169wxPalmDCImpl::wxPalmDCImpl( wxDC *owner, WXHDC hDC ) :
170 wxDCImpl( owner )
171{
172 Init();
173 m_hDC = hDC;
174}
175
176wxPalmDCImpl::~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.
183void wxPalmDCImpl::SelectOldObjects(WXHDC dc)
184{
185}
186
187// ---------------------------------------------------------------------------
188// clipping
189// ---------------------------------------------------------------------------
190
191void wxPalmDCImpl::UpdateClipBox()
192{
193}
194
195void
196wxPalmDCImpl::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
197{
198}
199
200// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
201void wxPalmDCImpl::SetClippingHrgn(WXHRGN hrgn)
202{
203 wxCHECK_RET( hrgn, wxT("invalid clipping region") );
204}
205
206void wxPalmDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
207{
208}
209
210void wxPalmDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
211{
212}
213
214void wxPalmDCImpl::DestroyClippingRegion()
215{
216}
217
218// ---------------------------------------------------------------------------
219// query capabilities
220// ---------------------------------------------------------------------------
221
222bool wxPalmDCImpl::CanDrawBitmap() const
223{
224 return false;
225}
226
227bool wxPalmDCImpl::CanGetTextExtent() const
228{
229 return false;
230}
231
232int wxPalmDCImpl::GetDepth() const
233{
234 return 0;
235}
236
237// ---------------------------------------------------------------------------
238// drawing
239// ---------------------------------------------------------------------------
240
241void wxPalmDCImpl::Clear()
242{
243}
244
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))
249{
250 return false;
251}
252
253bool wxPalmDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
254{
255 return false;
256}
257
258void wxPalmDCImpl::DoCrossHair(wxCoord x, wxCoord y)
259{
260}
261
262void 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)
268void wxPalmDCImpl::DoDrawArc(wxCoord x1, wxCoord y1,
269 wxCoord x2, wxCoord y2,
270 wxCoord xc, wxCoord yc)
271{
272}
273
274void wxPalmDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1,
275 wxCoord width, wxCoord height)
276{
277}
278
279void wxPalmDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
280{
281}
282
283void wxPalmDCImpl::DoDrawPolygon(int n,
284 wxPoint points[],
285 wxCoord xoffset,
286 wxCoord yoffset,
287 int WXUNUSED_IN_WINCE(fillStyle))
288{
289}
290
291void
292wxPalmDCImpl::DoDrawPolyPolygon(int n,
293 int count[],
294 wxPoint points[],
295 wxCoord xoffset,
296 wxCoord yoffset,
297 int fillStyle)
298{
299}
300
301void wxPalmDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
302{
303}
304
305void wxPalmDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
306{
307}
308
309void wxPalmDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
310{
311}
312
313void wxPalmDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
314{
315}
316
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)
325{
326}
327
328void wxPalmDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
329{
330}
331
332void wxPalmDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
333{
334}
335
336void wxPalmDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
337{
338}
339
340void wxPalmDCImpl::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
341{
342}
343
344void 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
356void wxPalmDCImpl::DoSelectPalette(bool realize)
357{
358}
359
360void wxPalmDCImpl::SetPalette(const wxPalette& palette)
361{
362}
363
364void 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
373void wxPalmDCImpl::SetFont(const wxFont& font)
374{
375}
376
377void wxPalmDCImpl::SetPen(const wxPen& pen)
378{
379}
380
381void wxPalmDCImpl::SetBrush(const wxBrush& brush)
382{
383}
384
385void wxPalmDCImpl::SetBackground(const wxBrush& brush)
386{
387}
388
389void wxPalmDCImpl::SetBackgroundMode(int mode)
390{
391}
392
393void wxPalmDCImpl::SetLogicalFunction(int function)
394{
395}
396
397void wxPalmDCImpl::SetRop(WXHDC dc)
398{
399}
400
401bool wxPalmDCImpl::StartDoc(const wxString& WXUNUSED(message))
402{
403 // We might be previewing, so return true to let it continue.
404 return true;
405}
406
407void wxPalmDCImpl::EndDoc()
408{
409}
410
411void wxPalmDCImpl::StartPage()
412{
413}
414
415void wxPalmDCImpl::EndPage()
416{
417}
418
419// ---------------------------------------------------------------------------
420// text metrics
421// ---------------------------------------------------------------------------
422
423wxCoord wxPalmDCImpl::GetCharHeight() const
424{
425 return 0;
426}
427
428wxCoord wxPalmDCImpl::GetCharWidth() const
429{
430 return 0;
431}
432
433void 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
443bool wxPalmDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
444{
445 return false;
446}
447
448void wxPalmDCImpl::RealizeScaleAndOrigin()
449{
450}
451
452void wxPalmDCImpl::SetMapMode(int mode)
453{
454}
455
456void wxPalmDCImpl::SetUserScale(double x, double y)
457{
458}
459
460void wxPalmDCImpl::SetAxisOrientation(bool xLeftRight,
461 bool yBottomUp)
462{
463}
464
465void wxPalmDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y)
466{
467}
468
469void wxPalmDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)
470{
471}
472
473// ---------------------------------------------------------------------------
474// bit blit
475// ---------------------------------------------------------------------------
476
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)
483{
484 return false;
485}
486
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)
494{
495 return false;
496}
497
498void wxPalmDCImpl::GetDeviceSize(int *width, int *height) const
499{
500}
501
502void wxPalmDCImpl::DoGetSizeMM(int *w, int *h) const
503{
504}
505
506wxSize wxPalmDCImpl::GetPPI() const
507{
508 return wxSize(0, 0);
509}
510
511// For use by wxWidgets only, unless custom units are required.
512void 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
528wxObjectList wxPalmDCImpl::sm_bitmapCache;
529wxObjectList wxPalmDCImpl::sm_dcCache;
530
531wxDCCacheEntry::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
540wxDCCacheEntry::wxDCCacheEntry(WXHDC hDC, int depth)
541{
542}
543
544wxDCCacheEntry::~wxDCCacheEntry()
545{
546}
547
548wxDCCacheEntry* wxPalmDCImpl::FindBitmapInCache(WXHDC dc, int w, int h)
549{
550 return NULL;
551}
552
553wxDCCacheEntry* wxPalmDCImpl::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc)
554{
555 return NULL;
556}
557
558void wxPalmDCImpl::AddToBitmapCache(wxDCCacheEntry* entry)
559{
560}
561
562void wxPalmDCImpl::AddToDCCache(wxDCCacheEntry* entry)
563{
564}
565
566void wxPalmDCImpl::ClearCache()
567{
568}
569
570// Clean up cache at app exit
571class wxDCModule : public wxModule
572{
573public:
574 virtual bool OnInit() { return true; }
575 virtual void OnExit() { wxPalmDCImpl::ClearCache(); }
576
577private:
578 DECLARE_DYNAMIC_CLASS(wxDCModule)
579};
580
581IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
582
583#endif // wxUSE_DC_CACHEING
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