]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/os2/dc.cpp
Fix horizontal mouse wheel scrolling in wxGTK.
[wxWidgets.git] / src / os2 / dc.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/os2/dc.cpp
3// Purpose: wxDC class
4// Author: David Webster
5// Modified by:
6// Created: 10/14/99
7// Copyright: (c) David Webster
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifndef WX_PRECOMP
15 #include "wx/window.h"
16 #include "wx/dc.h"
17 #include "wx/utils.h"
18 #include "wx/dialog.h"
19 #include "wx/app.h"
20 #include "wx/bitmap.h"
21 #include "wx/dcmemory.h"
22 #include "wx/log.h"
23 #include "wx/icon.h"
24 #include "wx/msgdlg.h"
25 #include "wx/dcprint.h"
26 #include "wx/statusbr.h"
27 #include "wx/module.h"
28#endif
29
30#include <string.h>
31
32#include "wx/os2/dc.h"
33#include "wx/os2/dcclient.h"
34#include "wx/os2/private.h"
35
36IMPLEMENT_ABSTRACT_CLASS(wxPMDCImpl, wxDCImpl)
37
38//
39// wxWidgets uses the Microsoft convention that the origin is the UPPER left.
40// Native OS/2 however in the GPI and PM define the origin as the LOWER left.
41// In order to map OS/2 GPI/PM y coordinates to wxWidgets coordinates we must
42// perform the following transformation:
43//
44// Parent object height: POBJHEIGHT
45// Desried origin: WXORIGINY
46// Object to place's height: OBJHEIGHT
47//
48// To get the OS2 position from the wxWidgets one:
49//
50// OS2Y = POBJHEIGHT - (WXORIGINY + OBJHEIGHT)
51//
52// For OS/2 wxDC's we will always determine m_vRclPaint as the size of the
53// OS/2 Presentation Space associated with the device context. y is the
54// desired application's y coordinate of the origin in wxWidgets space.
55// objy is the height of the object we are going to draw.
56//
57#define OS2Y(y, objy) ((m_vRclPaint.yTop - m_vRclPaint.yBottom) - (y + objy))
58
59// ---------------------------------------------------------------------------
60// constants
61// ---------------------------------------------------------------------------
62
63static const int VIEWPORT_EXTENT = 1000;
64
65static const int MM_POINTS = 9;
66static const int MM_METRIC = 10;
67
68// ---------------------------------------------------------------------------
69// private functions
70// ---------------------------------------------------------------------------
71
72// convert degrees to radians
73static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
74
75int SetTextColor(
76 HPS hPS
77, int nForegroundColour
78)
79{
80 CHARBUNDLE vCbnd;
81
82 vCbnd.lColor = nForegroundColour;
83 ::GpiSetAttrs( hPS // presentation-space handle
84 ,PRIM_CHAR // Char primitive.
85 ,CBB_COLOR // sets color.
86 ,0 //
87 ,&vCbnd // buffer for attributes.
88 );
89 return 0;
90}
91
92int QueryTextBkColor(
93 HPS hPS
94)
95{
96 CHARBUNDLE vCbnd;
97
98 ::GpiQueryAttrs( hPS // presentation-space handle
99 ,PRIM_CHAR // Char primitive.
100 ,CBB_BACK_COLOR // Background color.
101 ,&vCbnd // buffer for attributes.
102 );
103 return vCbnd.lBackColor;
104}
105
106
107int SetTextBkColor(
108 HPS hPS
109, int nBackgroundColour
110)
111{
112 CHARBUNDLE vCbnd;
113 int rc;
114
115 rc = QueryTextBkColor(hPS);
116
117 vCbnd.lBackColor = nBackgroundColour;
118 ::GpiSetAttrs(hPS, // presentation-space handle
119 PRIM_CHAR, // Char primitive.
120 CBB_BACK_COLOR, // sets color.
121 0,
122 &vCbnd // buffer for attributes.
123 );
124 return rc;
125}
126
127int SetBkMode(
128 HPS hPS
129, int nBackgroundMode
130)
131{
132 if(nBackgroundMode == wxTRANSPARENT)
133 ::GpiSetBackMix( hPS
134 ,BM_LEAVEALONE
135 );
136 else
137 // the background of the primitive takes over whatever is underneath.
138 ::GpiSetBackMix( hPS
139 ,BM_OVERPAINT
140 );
141 return 0;
142}
143
144// ===========================================================================
145// implementation
146// ===========================================================================
147
148#if wxUSE_DC_CACHEING
149
150/*
151 * This implementation is a bit ugly and uses the old-fashioned wxList class, so I will
152 * improve it in due course, either using arrays, or simply storing pointers to one
153 * entry for the bitmap, and two for the DCs. -- JACS
154 */
155
156// ---------------------------------------------------------------------------
157// wxDCCacheEntry
158// ---------------------------------------------------------------------------
159
160wxList wxPMDCImpl::m_svBitmapCache;
161wxList wxPMDCImpl::m_svDCCache;
162
163wxDCCacheEntry::wxDCCacheEntry(
164 WXHBITMAP hBitmap
165, int nWidth
166, int nHeight
167, int nDepth
168)
169{
170 m_hBitmap = hBitmap;
171 m_hPS = NULLHANDLE;
172 m_nWidth = nWidth;
173 m_nHeight = nHeight;
174 m_nDepth = nDepth;
175} // end of wxDCCacheEntry::wxDCCacheEntry
176
177wxDCCacheEntry::wxDCCacheEntry(
178 HPS hPS
179, int nDepth
180)
181{
182 m_hBitmap = NULLHANDLE;
183 m_hPS = hPS;
184 m_nWidth = 0;
185 m_nHeight = 0;
186 m_nDepth = nDepth;
187} // end of wxDCCacheEntry::wxDCCacheEntry
188
189wxDCCacheEntry::~wxDCCacheEntry()
190{
191 if (m_hBitmap)
192 ::GpiDeleteBitmap(m_hBitmap);
193 if (m_hPS)
194 ::GpiDestroyPS(m_hPS);
195} // end of wxDCCacheEntry::~wxDCCacheEntry
196
197wxDCCacheEntry* wxPMDCImpl::FindBitmapInCache(
198 HPS hPS
199, int nWidth
200, int nHeight
201)
202{
203 int nDepth = 24; // we'll fix this later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
204 wxNode* pNode = m_svBitmapCache.First();
205 BITMAPINFOHEADER2 vBmpHdr;
206
207 while(pNode)
208 {
209 wxDCCacheEntry* pEntry = (wxDCCacheEntry*)pNode->Data();
210
211 if (pEntry->m_nDepth == nDepth)
212 {
213 memset(&vBmpHdr, 0, sizeof(BITMAPINFOHEADER2));
214
215 if (pEntry->m_nWidth < nWidth || pEntry->m_nHeight < nHeight)
216 {
217 ::GpiDeleteBitmap((HBITMAP)pEntry->m_hBitmap);
218 vBmpHdr.cbFix = sizeof(BITMAPINFOHEADER2);
219 vBmpHdr.cx = nWidth;
220 vBmpHdr.cy = nHeight;
221 vBmpHdr.cPlanes = 1;
222 vBmpHdr.cBitCount = (USHORT)nDepth;
223
224 pEntry->m_hBitmap = (WXHBITMAP) ::GpiCreateBitmap( hPS
225 ,&vBmpHdr
226 ,0L, NULL, NULL
227 );
228 if (!pEntry->m_hBitmap)
229 {
230 wxLogLastError(wxT("CreateCompatibleBitmap"));
231 }
232 pEntry->m_nWidth = nWidth;
233 pEntry->m_nHeight = nHeight;
234 return pEntry;
235 }
236 return pEntry;
237 }
238 pNode = pNode->Next();
239 }
240 memset(&vBmpHdr, 0, sizeof(BITMAPINFOHEADER2));
241 vBmpHdr.cbFix = sizeof(BITMAPINFOHEADER2);
242 vBmpHdr.cx = nWidth;
243 vBmpHdr.cy = nHeight;
244 vBmpHdr.cPlanes = 1;
245 vBmpHdr.cBitCount = (USHORT)nDepth;
246
247 WXHBITMAP hBitmap = (WXHBITMAP) ::GpiCreateBitmap( hPS
248 ,&vBmpHdr
249 ,0L, NULL, NULL
250 );
251 if (!hBitmap)
252 {
253 wxLogLastError(wxT("CreateCompatibleBitmap"));
254 }
255 wxDCCacheEntry* pEntry = new wxDCCacheEntry( hBitmap
256 ,nWidth
257 ,nHeight
258 ,nDepth
259 );
260 AddToBitmapCache(pEntry);
261 return pEntry;
262} // end of FindBitmapInCache
263
264wxDCCacheEntry* wxPMDCImpl::FindDCInCache(
265 wxDCCacheEntry* pNotThis
266, HPS hPS
267)
268{
269 int nDepth = 24; // we'll fix this up later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
270 wxNode* pNode = m_svDCCache.First();
271
272 while(pNode)
273 {
274 wxDCCacheEntry* pEntry = (wxDCCacheEntry*)pNode->Data();
275
276 //
277 // Don't return the same one as we already have
278 //
279 if (!pNotThis || (pNotThis != pEntry))
280 {
281 if (pEntry->m_nDepth == nDepth)
282 {
283 return pEntry;
284 }
285 }
286 pNode = pNode->Next();
287 }
288 wxDCCacheEntry* pEntry = new wxDCCacheEntry( hPS
289 ,nDepth
290 );
291 AddToDCCache(pEntry);
292 return pEntry;
293} // end of wxPMDCImpl::FindDCInCache
294
295void wxPMDCImpl::AddToBitmapCache(
296 wxDCCacheEntry* pEntry
297)
298{
299 m_svBitmapCache.Append(pEntry);
300} // end of wxPMDCImpl::AddToBitmapCache
301
302void wxPMDCImpl::AddToDCCache(
303 wxDCCacheEntry* pEntry
304)
305{
306 m_svDCCache.Append(pEntry);
307} // end of wxPMDCImpl::AddToDCCache
308
309void wxPMDCImpl::ClearCache()
310{
311 m_svBitmapCache.DeleteContents(true);
312 m_svBitmapCache.Clear();
313 m_svBitmapCache.DeleteContents(false);
314 m_svDCCache.DeleteContents(true);
315 m_svDCCache.Clear();
316 m_svDCCache.DeleteContents(false);
317} // end of wxPMDCImpl::ClearCache
318
319// Clean up cache at app exit
320class wxDCModule : public wxModule
321{
322public:
323 virtual bool OnInit() { return true; }
324 virtual void OnExit() { wxPMDCImpl::ClearCache(); }
325
326private:
327 DECLARE_DYNAMIC_CLASS(wxDCModule)
328}; // end of CLASS wxDCModule
329
330IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
331
332#endif // ndef for wxUSE_DC_CACHEING
333
334// ---------------------------------------------------------------------------
335// wxDC
336// ---------------------------------------------------------------------------
337
338wxPMDCImpl::wxPMDCImpl( wxDC *owner, WXHDC hDC ) :
339 wxDCImpl( owner )
340{
341 Init();
342 m_hDC = hDC;
343} // end of wxPMDCImpl::wxPMDCImpl
344
345wxPMDCImpl::~wxPMDCImpl()
346{
347 if ( m_hDC != 0 )
348 {
349 SelectOldObjects(m_hDC);
350
351 // if we own the HDC, we delete it, otherwise we just release it
352
353 if (m_bOwnsDC)
354 {
355 if(m_hPS)
356 {
357 ::GpiAssociate(m_hPS, NULLHANDLE);
358 ::GpiDestroyPS(m_hPS);
359 }
360 m_hPS = NULLHANDLE;
361 ::DevCloseDC((HDC)m_hDC);
362 }
363 else
364 {
365 //
366 // Just Dissacociate, not destroy if we don't own the DC
367 //
368 if(m_hPS)
369 {
370 ::GpiAssociate(m_hPS, NULLHANDLE);
371 }
372 }
373 }
374} // end of wxPMDCImpl::~wxDC
375
376// This will select current objects out of the DC,
377// which is what you have to do before deleting the
378// DC.
379void wxPMDCImpl::SelectOldObjects(
380 WXHDC hPS
381)
382{
383 if (hPS)
384 {
385 if (m_hOldBitmap)
386 {
387 ::GpiSetBitmap(hPS, (HBITMAP) m_hOldBitmap);
388 if (m_vSelectedBitmap.IsOk())
389 {
390 m_vSelectedBitmap.SetSelectedInto(NULL);
391 }
392 }
393 m_hOldBitmap = 0;
394 //
395 // OS/2 has no other native GDI objects to set in a PS/DC like windows
396 //
397 m_hOldPen = 0;
398 m_hOldBrush = 0;
399 m_hOldFont = 0;
400 m_hOldPalette = 0;
401 }
402
403 m_brush = wxNullBrush;
404 m_pen = wxNullPen;
405 m_palette = wxNullPalette;
406 m_font = wxNullFont;
407 m_backgroundBrush = wxNullBrush;
408 m_vSelectedBitmap = wxNullBitmap;
409} // end of wxPMDCImpl::SelectOldObjects
410
411// ---------------------------------------------------------------------------
412// clipping
413// ---------------------------------------------------------------------------
414
415#define DO_SET_CLIPPING_BOX() \
416{ \
417 RECTL rect; \
418 \
419 ::GpiQueryClipBox(m_hPS, &rect); \
420 \
421 m_clipX1 = (wxCoord) XDEV2LOG(rect.xLeft); \
422 m_clipY1 = (wxCoord) YDEV2LOG(rect.yTop); \
423 m_clipX2 = (wxCoord) XDEV2LOG(rect.xRight); \
424 m_clipY2 = (wxCoord) YDEV2LOG(rect.yBottom); \
425}
426
427void wxPMDCImpl::DoSetClippingRegion(
428 wxCoord vX
429, wxCoord vY
430, wxCoord vWidth
431, wxCoord vHeight
432)
433{
434 RECTL vRect;
435
436 vY = OS2Y(vY,vHeight);
437 m_clipping = true;
438 vRect.xLeft = vX;
439 vRect.yTop = vY + vHeight;
440 vRect.xRight = vX + vWidth;
441 vRect.yBottom = vY;
442 ::GpiIntersectClipRectangle(m_hPS, &vRect);
443 DO_SET_CLIPPING_BOX()
444} // end of wxPMDCImpl::DoSetClippingRegion
445
446void wxPMDCImpl::DoSetDeviceClippingRegion(
447 const wxRegion& rRegion
448)
449{
450 wxCHECK_RET(rRegion.GetHRGN(), wxT("invalid clipping region"));
451 HRGN hRgnOld;
452
453 m_clipping = true;
454 ::GpiSetClipRegion( m_hPS
455 ,(HRGN)rRegion.GetHRGN()
456 ,&hRgnOld
457 );
458 DO_SET_CLIPPING_BOX()
459} // end of wxPMDCImpl::DoSetDeviceClippingRegion
460
461void wxPMDCImpl::DestroyClippingRegion()
462{
463 if (m_clipping && m_hPS)
464 {
465 HRGN hRgnOld;
466 RECTL vRect;
467
468 // TODO: this should restore the previous clipped region
469 // so that OnPaint processing works correctly, and
470 // the update doesn't get destroyed after the first
471 // DestroyClippingRegion
472 vRect.xLeft = XLOG2DEV(0);
473 vRect.yTop = YLOG2DEV(32000);
474 vRect.xRight = XLOG2DEV(32000);
475 vRect.yBottom = YLOG2DEV(0);
476
477 HRGN hRgn = ::GpiCreateRegion(m_hPS, 1, &vRect);
478
479 ::GpiSetClipRegion(m_hPS, hRgn, &hRgnOld);
480 }
481 ResetClipping();
482} // end of wxPMDCImpl::DestroyClippingRegion
483
484// ---------------------------------------------------------------------------
485// query capabilities
486// ---------------------------------------------------------------------------
487
488bool wxPMDCImpl::CanDrawBitmap() const
489{
490 return true;
491}
492
493bool wxPMDCImpl::CanGetTextExtent() const
494{
495 LONG lTechnology = 0L;
496
497 ::DevQueryCaps(GetHDC(), CAPS_TECHNOLOGY, 1L, &lTechnology);
498 return (lTechnology == CAPS_TECH_RASTER_DISPLAY) || (lTechnology == CAPS_TECH_RASTER_PRINTER);
499} // end of wxPMDCImpl::CanGetTextExtent
500
501int wxPMDCImpl::GetDepth() const
502{
503 LONG lCapsColorBitcount;
504 int nBitsPerPixel = 0;
505
506 if(::DevQueryCaps( GetHDC()
507 ,CAPS_COLOR_BITCOUNT
508 ,1L
509 ,&lCapsColorBitcount
510 ))
511 {
512 nBitsPerPixel = (int)lCapsColorBitcount;
513 }
514 return nBitsPerPixel;
515} // end of wxPMDCImpl::GetDepth
516
517// ---------------------------------------------------------------------------
518// drawing
519// ---------------------------------------------------------------------------
520
521void wxPMDCImpl::Clear()
522{
523 //
524 // If this is a canvas DC then just fill with the background color
525 // Otherwise purge the whole thing
526 //
527 if (m_pCanvas)
528 {
529 RECTL vRect;
530
531 ::GpiQueryClipBox(m_hPS, &vRect);
532 ::WinFillRect(m_hPS, &vRect, ::GpiQueryBackColor(m_hPS));
533 }
534 else
535 ::GpiErase(m_hPS);
536} // end of wxPMDCImpl::Clear
537
538bool wxPMDCImpl::DoFloodFill(
539 wxCoord vX
540, wxCoord vY
541, const wxColour& rCol
542, wxFloodFillStyle nStyle
543)
544{
545 POINTL vPtlPos;
546 LONG lColor;
547 LONG lOptions;
548 LONG lHits;
549 bool bSuccess = false;
550
551 vPtlPos.x = vX; // Loads x-coordinate
552 vPtlPos.y = OS2Y(vY,0); // Loads y-coordinate
553 ::GpiMove(m_hPS, &vPtlPos); // Sets current position
554 lColor = rCol.GetPixel();
555 lOptions = FF_BOUNDARY;
556 if(wxFLOOD_SURFACE == nStyle)
557 lOptions = FF_SURFACE;
558
559 if ((lHits = ::GpiFloodFill(m_hPS, lOptions, lColor)) != GPI_ERROR)
560 bSuccess = true;
561
562 return bSuccess;
563} // end of wxPMDCImpl::DoFloodFill
564
565bool wxPMDCImpl::DoGetPixel(
566 wxCoord vX
567, wxCoord vY
568, wxColour* pCol
569) const
570{
571 POINTL vPoint;
572 LONG lColor;
573
574 vPoint.x = vX;
575 vPoint.y = OS2Y(vY,0);
576 lColor = ::GpiQueryPel(m_hPS, &vPoint);
577
578 //
579 // return the color of the pixel
580 //
581 if(pCol)
582 pCol->Set( GetRValue(lColor)
583 ,GetGValue(lColor)
584 ,GetBValue(lColor)
585 );
586 return true;
587} // end of wxPMDCImpl::DoGetPixel
588
589void wxPMDCImpl::DoCrossHair(
590 wxCoord vX
591, wxCoord vY
592)
593{
594 vY = OS2Y(vY,0);
595
596 wxCoord vX1 = vX - VIEWPORT_EXTENT;
597 wxCoord vY1 = vY - VIEWPORT_EXTENT;
598 wxCoord vX2 = vX + VIEWPORT_EXTENT;
599 wxCoord vY2 = vY + VIEWPORT_EXTENT;
600 POINTL vPoint[4];
601
602 vPoint[0].x = vX1;
603 vPoint[0].y = vY;
604
605 vPoint[1].x = vX2;
606 vPoint[1].y = vY;
607
608 ::GpiMove(m_hPS, &vPoint[0]);
609 ::GpiLine(m_hPS, &vPoint[1]);
610
611 vPoint[2].x = vX;
612 vPoint[2].y = vY1;
613
614 vPoint[3].x = vX;
615 vPoint[3].y = vY2;
616
617 ::GpiMove(m_hPS, &vPoint[2]);
618 ::GpiLine(m_hPS, &vPoint[3]);
619 CalcBoundingBox(vX1, vY1);
620 CalcBoundingBox(vX2, vY2);
621} // end of wxPMDCImpl::DoCrossHair
622
623void wxPMDCImpl::DoDrawLine(
624 wxCoord vX1
625, wxCoord vY1
626, wxCoord vX2
627, wxCoord vY2
628)
629{
630 POINTL vPoint[2];
631 COLORREF vColor = 0x00ffffff;
632
633 //
634 // Might be a memory DC with no Paint rect.
635 //
636 if (!(m_vRclPaint.yTop == 0 &&
637 m_vRclPaint.yBottom == 0 &&
638 m_vRclPaint.xRight == 0 &&
639 m_vRclPaint.xLeft == 0))
640 {
641 vY1 = OS2Y(vY1,0);
642 vY2 = OS2Y(vY2,0);
643 }
644 else
645 {
646 if (m_vSelectedBitmap.IsOk())
647 {
648 m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
649 m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
650 vY1 = OS2Y(vY1,0);
651 vY2 = OS2Y(vY2,0);
652 }
653 }
654 vPoint[0].x = vX1;
655 vPoint[0].y = vY1;
656 vPoint[1].x = vX2;
657 vPoint[1].y = vY2;
658 if (m_pen.IsOk())
659 {
660 vColor = m_pen.GetColour().GetPixel();
661 }
662 ::GpiSetColor(m_hPS, vColor);
663 ::GpiMove(m_hPS, &vPoint[0]);
664 ::GpiLine(m_hPS, &vPoint[1]);
665 CalcBoundingBox(vX1, vY1);
666 CalcBoundingBox(vX2, vY2);
667} // end of wxPMDCImpl::DoDrawLine
668
669//////////////////////////////////////////////////////////////////////////////
670// Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
671// and ending at (x2, y2). The current pen is used for the outline and the
672// current brush for filling the shape. The arc is drawn in an anticlockwise
673// direction from the start point to the end point.
674//////////////////////////////////////////////////////////////////////////////
675void wxPMDCImpl::DoDrawArc(
676 wxCoord vX1
677, wxCoord vY1
678, wxCoord vX2
679, wxCoord vY2
680, wxCoord vXc
681, wxCoord vYc
682)
683{
684 POINTL vPtlPos;
685 POINTL vPtlArc[2]; // Structure for current position
686 double dRadius;
687 double dAngl1;
688 double dAngl2;
689 double dAnglmid;
690 wxCoord vXm;
691 wxCoord vYm;
692 ARCPARAMS vArcp; // Structure for arc parameters
693
694 if((vX1 == vXc && vY1 == vXc) || (vX2 == vXc && vY2 == vXc))
695 return; // Draw point ??
696 dRadius = 0.5 * ( hypot( (double)(vY1 - vYc)
697 ,(double)(vX1 - vXc)
698 ) +
699 hypot( (double)(vY2 - vYc)
700 ,(double)(vX2 - vXc)
701 )
702 );
703
704 dAngl1 = atan2( (double)(vY1 - vYc)
705 ,(double)(vX1 - vXc)
706 );
707 dAngl2 = atan2( (double)(vY2 - vYc)
708 ,(double)(vX2 - vXc)
709 );
710 if(dAngl2 < dAngl1)
711 dAngl2 += M_PI * 2;
712
713 //
714 // GpiPointArc can't draw full arc
715 //
716 if(dAngl2 == dAngl1 || (vX1 == vX2 && vY1 == vY2) )
717 {
718 //
719 // Medium point
720 //
721 dAnglmid = (dAngl1 + dAngl2)/2. + M_PI;
722 vXm = (wxCoord)(vXc + dRadius * cos(dAnglmid));
723 vYm = (wxCoord)(vYc + dRadius * sin(dAnglmid));
724 DoDrawArc( vX1, vY1
725 ,vXm, vYm
726 ,vXc, vYc
727 );
728 DoDrawArc( vXm, vYm
729 ,vX2, vY2
730 ,vXc, vYc
731 );
732 return;
733 }
734
735 //
736 // Medium point
737 //
738 dAnglmid = (dAngl1 + dAngl2)/2.;
739 vXm = (wxCoord)(vXc + dRadius * cos(dAnglmid));
740 vYm = (wxCoord)(vYc + dRadius * sin(dAnglmid));
741
742 //
743 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
744 //
745 vArcp.lR = 0;
746 vArcp.lQ = 1;
747 vArcp.lP = 1;
748 vArcp.lS = 0;
749 ::GpiSetArcParams(m_hPS, &vArcp); // Sets parameters to default
750
751 vPtlPos.x = vX1; // Loads x-coordinate
752 vPtlPos.y = vY1; // Loads y-coordinate
753 ::GpiMove(m_hPS, &vPtlPos); // Sets current position
754 vPtlArc[0].x = vXm;
755 vPtlArc[0].y = vYm;
756 vPtlArc[1].x = vX2;
757 vPtlArc[1].y = vY2;
758 ::GpiPointArc(m_hPS, vPtlArc); // Draws the arc
759 CalcBoundingBox( (wxCoord)(vXc - dRadius)
760 ,(wxCoord)(vYc - dRadius)
761 );
762 CalcBoundingBox( (wxCoord)(vXc + dRadius)
763 ,(wxCoord)(vYc + dRadius)
764 );
765} // end of wxPMDCImpl::DoDrawArc
766
767void wxPMDCImpl::DoDrawCheckMark(
768 wxCoord vX1
769, wxCoord vY1
770, wxCoord vWidth
771, wxCoord vHeight
772)
773{
774 POINTL vPoint[2];
775
776 vY1 = OS2Y(vY1,vHeight);
777
778 vPoint[0].x = vX1;
779 vPoint[0].y = vY1;
780 vPoint[1].x = vX1 + vWidth;
781 vPoint[1].y = vY1 + vHeight;
782
783 ::GpiMove(m_hPS, &vPoint[0]);
784 ::GpiBox( m_hPS // handle to a presentation space
785 ,DRO_OUTLINE // draw the box outline ? or ?
786 ,&vPoint[1] // address of the corner
787 ,0L // horizontal corner radius
788 ,0L // vertical corner radius
789 );
790 if(vWidth > 4 && vHeight > 4)
791 {
792 int nTmp;
793
794 vPoint[0].x += 2; vPoint[0].y += 2;
795 vPoint[1].x -= 2; vPoint[1].y -= 2;
796 ::GpiMove(m_hPS, &vPoint[0]);
797 ::GpiLine(m_hPS, &vPoint[1]);
798 nTmp = vPoint[0].x;
799 vPoint[0].x = vPoint[1].x;
800 vPoint[1].x = nTmp;
801 ::GpiMove(m_hPS, &vPoint[0]);
802 ::GpiLine(m_hPS, &vPoint[1]);
803 }
804 CalcBoundingBox( vX1
805 ,vY1
806 );
807
808 wxCoord vX2 = vX1 + vWidth;
809 wxCoord vY2 = vY1 + vHeight;
810
811 CalcBoundingBox( vX2
812 ,vY2
813 );
814} // end of wxPMDCImpl::DoDrawCheckMark
815
816void wxPMDCImpl::DoDrawPoint(
817 wxCoord vX
818, wxCoord vY
819)
820{
821 POINTL vPoint;
822 COLORREF vColor = 0x00ffffff;
823
824 if (m_pen.IsOk())
825 {
826 vColor = m_pen.GetColour().GetPixel();
827 }
828 ::GpiSetColor(m_hPS, vColor);
829 vPoint.x = vX;
830 vPoint.y = OS2Y(vY,0);
831 ::GpiSetPel(m_hPS, &vPoint);
832 CalcBoundingBox( vX
833 ,vY
834 );
835} // end of wxPMDCImpl::DoDrawPoint
836
837void wxPMDCImpl::DoDrawPolygon( int n,
838 const wxPoint vPoints[],
839 wxCoord vXoffset,
840 wxCoord vYoffset,
841 wxPolygonFillMode nFillStyle )
842{
843 ULONG ulCount = 1; // Number of polygons.
844 POLYGON vPlgn; // polygon.
845 ULONG flOptions = 0L; // Drawing options.
846
847 //////////////////////////////////////////////////////////////////////////////
848 // This contains fields of option bits... to draw boundary lines as well as
849 // the area interior.
850 //
851 // Drawing boundary lines:
852 // POLYGON_NOBOUNDARY Does not draw boundary lines.
853 // POLYGON_BOUNDARY Draws boundary lines (the default).
854 //
855 // Construction of the area interior:
856 // POLYGON_ALTERNATE Constructs interior in alternate mode
857 // (the default).
858 // POLYGON_WINDING Constructs interior in winding mode.
859 //////////////////////////////////////////////////////////////////////////////
860
861 ULONG flModel = POLYGON_INCL; // Drawing model.
862
863 //////////////////////////////////////////////////////////////////////////////
864 // Drawing model.
865 // POLYGON_INCL Fill is inclusive of bottom right (the default).
866 // POLYGON_EXCL Fill is exclusive of bottom right.
867 // This is provided to aid migration from other graphics models.
868 //////////////////////////////////////////////////////////////////////////////
869
870 LONG lHits = 0L; // Correlation/error indicator.
871 int i;
872 int nIsTRANSPARENT = 0;
873 LONG lBorderColor = 0L;
874 LONG lColor = 0L;
875
876 lBorderColor = m_pen.GetColour().GetPixel();
877 lColor = m_brush.GetColour().GetPixel();
878 if(m_brush.GetStyle() == wxTRANSPARENT)
879 nIsTRANSPARENT = 1;
880
881 vPlgn.ulPoints = n;
882 vPlgn.aPointl = (POINTL*) calloc( n + 1
883 ,sizeof(POINTL)
884 ); // well, new will call malloc
885
886 for(i = 0; i < n; i++)
887 {
888 vPlgn.aPointl[i].x = vPoints[i].x+vXoffset;
889 vPlgn.aPointl[i].y = OS2Y(vPoints[i].y+vYoffset,0);
890 }
891 flOptions = POLYGON_BOUNDARY;
892 if(nFillStyle == wxWINDING_RULE)
893 flOptions |= POLYGON_WINDING;
894 else
895 flOptions |= POLYGON_ALTERNATE;
896
897 ::GpiSetColor(m_hPS, lBorderColor);
898 ::GpiMove(m_hPS, &vPlgn.aPointl[0]);
899 lHits = ::GpiPolygons(m_hPS, ulCount, &vPlgn, flOptions, flModel);
900 free(vPlgn.aPointl);
901} // end of wxPMDCImpl::DoDrawPolygon
902
903void wxPMDCImpl::DoDrawLines(
904 int n
905, const wxPoint vPoints[]
906, wxCoord vXoffset
907, wxCoord vYoffset
908)
909{
910 POINTL vPoint;
911
912 if (vXoffset != 0L || vYoffset != 0L)
913 {
914 int i;
915
916 vPoint.x = vPoints[0].x + vXoffset;
917 vPoint.y = OS2Y(vPoints[0].y + vYoffset,0);
918 ::GpiMove(m_hPS, &vPoint);
919
920 LONG lBorderColor = m_pen.GetColour().GetPixel();
921
922 ::GpiSetColor(m_hPS, lBorderColor);
923 for(i = 1; i < n; i++)
924 {
925 vPoint.x = vPoints[i].x + vXoffset;
926 vPoint.y = OS2Y(vPoints[i].y + vYoffset,0);
927 ::GpiLine(m_hPS, &vPoint);
928 }
929 }
930 else
931 {
932 int i;
933
934 CalcBoundingBox( vPoints[0].x
935 ,vPoints[0].y
936 );
937 vPoint.x = vPoints[0].x;
938 vPoint.y = OS2Y(vPoints[0].y,0);
939 ::GpiMove(m_hPS, &vPoint);
940
941 for (i = 0; i < n; i++)
942 {
943 CalcBoundingBox( vPoints[i].x
944 ,vPoints[i].y
945 );
946 vPoint.x = vPoints[i].x;
947 vPoint.y = OS2Y(vPoints[i].y,0);
948 ::GpiLine(m_hPS, &vPoint);
949 }
950 }
951} // end of wxPMDCImpl::DoDrawLines
952
953void wxPMDCImpl::DoDrawRectangle(
954 wxCoord vX
955, wxCoord vY
956, wxCoord vWidth
957, wxCoord vHeight
958)
959{
960 POINTL vPoint[2];
961 LONG lControl;
962 LONG lColor;
963 LONG lBorderColor;
964 int nIsTRANSPARENT = 0;
965
966 //
967 // Might be a memory DC with no Paint rect.
968 //
969 if (!(m_vRclPaint.yTop == 0 &&
970 m_vRclPaint.yBottom == 0 &&
971 m_vRclPaint.xRight == 0 &&
972 m_vRclPaint.xLeft == 0))
973 vY = OS2Y(vY,vHeight);
974 else
975 {
976 if (m_vSelectedBitmap.IsOk())
977 {
978 m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
979 m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
980 vY = OS2Y(vY,vHeight);
981 }
982 }
983
984 wxCoord vX2 = vX + vWidth;
985 wxCoord vY2 = vY + vHeight;
986
987 vPoint[0].x = vX;
988 vPoint[0].y = vY;
989 vPoint[1].x = vX + vWidth - 1;
990 vPoint[1].y = vY + vHeight - 1;
991 ::GpiMove(m_hPS, &vPoint[0]);
992 lColor = m_brush.GetColour().GetPixel();
993 lBorderColor = m_pen.GetColour().GetPixel();
994 if (m_brush.GetStyle() == wxTRANSPARENT)
995 nIsTRANSPARENT = 1;
996 if(lColor == lBorderColor || nIsTRANSPARENT)
997 {
998 lControl = DRO_OUTLINEFILL; //DRO_FILL;
999 if(m_brush.GetStyle() == wxTRANSPARENT)
1000 lControl = DRO_OUTLINE;
1001
1002 ::GpiSetColor(m_hPS, lBorderColor);
1003 ::GpiBox( m_hPS // handle to a presentation space
1004 ,lControl // draw the box outline ? or ?
1005 ,&vPoint[1] // address of the corner
1006 ,0L // horizontal corner radius
1007 ,0L // vertical corner radius
1008 );
1009 }
1010 else
1011 {
1012 lControl = DRO_OUTLINE;
1013 ::GpiSetColor( m_hPS
1014 ,lBorderColor
1015 );
1016 ::GpiBox( m_hPS
1017 ,lControl
1018 ,&vPoint[1]
1019 ,0L
1020 ,0L
1021 );
1022 lControl = DRO_FILL;
1023 ::GpiSetColor( m_hPS
1024 ,lColor
1025 );
1026 vPoint[0].x = vX + 1;
1027 vPoint[0].y = vY + 1;
1028 vPoint[1].x = vX + vWidth - 2;
1029 vPoint[1].y = vY + vHeight - 2;
1030 ::GpiMove(m_hPS, &vPoint[0]);
1031 ::GpiBox( m_hPS
1032 ,lControl
1033 ,&vPoint[1]
1034 ,0L
1035 ,0L
1036 );
1037 }
1038 CalcBoundingBox(vX, vY);
1039 CalcBoundingBox(vX2, vY2);
1040} // end of wxPMDCImpl::DoDrawRectangle
1041
1042void wxPMDCImpl::DoDrawRoundedRectangle(
1043 wxCoord vX
1044, wxCoord vY
1045, wxCoord vWidth
1046, wxCoord vHeight
1047, double dRadius
1048)
1049{
1050 POINTL vPoint[2];
1051 LONG lControl;
1052 LONG lColor;
1053 LONG lBorderColor;
1054 int nIsTRANSPARENT = 0;
1055
1056 //
1057 // Might be a memory DC with no Paint rect.
1058 //
1059 if (!(m_vRclPaint.yTop == 0 &&
1060 m_vRclPaint.yBottom == 0 &&
1061 m_vRclPaint.xRight == 0 &&
1062 m_vRclPaint.xLeft == 0))
1063 vY = OS2Y(vY,vHeight);
1064 else
1065 {
1066 if (m_vSelectedBitmap.IsOk())
1067 {
1068 m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
1069 m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
1070 vY = OS2Y(vY,vHeight);
1071 }
1072 }
1073
1074 wxCoord vX2 = (vX + vWidth);
1075 wxCoord vY2 = (vY + vHeight);
1076
1077 vPoint[0].x = vX;
1078 vPoint[0].y = vY;
1079 vPoint[1].x = vX + vWidth - 1;
1080 vPoint[1].y = vY + vHeight - 1;
1081 ::GpiMove(m_hPS, &vPoint[0]);
1082
1083 lColor = m_brush.GetColour().GetPixel();
1084 lBorderColor = m_pen.GetColour().GetPixel();
1085 lControl = DRO_OUTLINEFILL; //DRO_FILL;
1086 if (m_brush.GetStyle() == wxTRANSPARENT)
1087 nIsTRANSPARENT = 1;
1088 if(lColor == lBorderColor || nIsTRANSPARENT)
1089 {
1090 lControl = DRO_OUTLINEFILL; //DRO_FILL;
1091 if(m_brush.GetStyle() == wxTRANSPARENT)
1092 lControl = DRO_OUTLINE;
1093
1094 ::GpiSetColor(m_hPS, lColor);
1095 ::GpiBox( m_hPS // handle to a presentation space
1096 ,lControl // draw the box outline ? or ?
1097 ,&vPoint[1] // address of the corner
1098 ,(LONG)dRadius // horizontal corner radius
1099 ,(LONG)dRadius // vertical corner radius
1100 );
1101 }
1102 else
1103 {
1104 lControl = DRO_OUTLINE;
1105 ::GpiSetColor( m_hPS
1106 ,lBorderColor
1107 );
1108 ::GpiBox( m_hPS
1109 ,lControl
1110 ,&vPoint[1]
1111 ,(LONG)dRadius
1112 ,(LONG)dRadius
1113 );
1114 lControl = DRO_FILL;
1115 ::GpiSetColor( m_hPS
1116 ,lColor
1117 );
1118 vPoint[0].x = vX + 1;
1119 vPoint[0].y = vY + 1;
1120 vPoint[1].x = vX + vWidth - 2;
1121 vPoint[1].y = vY + vHeight - 2;
1122 ::GpiMove(m_hPS, &vPoint[0]);
1123 ::GpiBox( m_hPS
1124 ,lControl
1125 ,&vPoint[1]
1126 ,(LONG)dRadius
1127 ,(LONG)dRadius
1128 );
1129 }
1130
1131 CalcBoundingBox(vX, vY);
1132 CalcBoundingBox(vX2, vY2);
1133} // end of wxPMDCImpl::DoDrawRoundedRectangle
1134
1135// Draw Ellipse within box (x,y) - (x+width, y+height)
1136void wxPMDCImpl::DoDrawEllipse(
1137 wxCoord vX
1138, wxCoord vY
1139, wxCoord vWidth
1140, wxCoord vHeight
1141)
1142{
1143 POINTL vPtlPos; // Structure for current position
1144 FIXED vFxMult; // Multiplier for ellipse
1145 ARCPARAMS vArcp; // Structure for arc parameters
1146
1147 vY = OS2Y(vY,vHeight);
1148
1149 vArcp.lR = 0;
1150 vArcp.lQ = vHeight/2;
1151 vArcp.lP = vWidth/2;
1152 vArcp.lS = 0;
1153 ::GpiSetArcParams( m_hPS
1154 ,&vArcp
1155 ); // Sets parameters to default
1156 vPtlPos.x = vX + vWidth/2; // Loads x-coordinate
1157 vPtlPos.y = vY + vHeight/2; // Loads y-coordinate
1158 ::GpiMove( m_hPS
1159 ,&vPtlPos
1160 ); // Sets current position
1161 vFxMult = MAKEFIXED(1, 0); /* Sets multiplier */
1162
1163 //
1164 // DRO_FILL, DRO_OTLINEFILL - where to get
1165 //
1166 ::GpiFullArc( m_hPS
1167 ,DRO_OUTLINE
1168 ,vFxMult
1169 ); // Draws full arc with center at current position
1170
1171 wxCoord vX2 = (vX + vWidth);
1172 wxCoord vY2 = (vY + vHeight);
1173
1174 CalcBoundingBox(vX, vY);
1175 CalcBoundingBox(vX2, vY2);
1176} // end of wxPMDCImpl::DoDrawEllipse
1177
1178void wxPMDCImpl::DoDrawEllipticArc(
1179 wxCoord vX
1180, wxCoord vY
1181, wxCoord vWidth
1182, wxCoord vHeight
1183, double dSa
1184, double dEa
1185)
1186{
1187 POINTL vPtlPos; // Structure for current position
1188 FIXED vFxMult; // Multiplier for ellipse
1189 ARCPARAMS vArcp; // Structure for arc parameters
1190 FIXED vFSa;
1191 FIXED vFSweepa; // Start angle, sweep angle
1192 double dIntPart;
1193 double dFractPart;
1194
1195 vY = OS2Y(vY,vHeight);
1196
1197 dFractPart = modf(dSa,&dIntPart);
1198 vFSa = MAKEFIXED((int)dIntPart, (int)(dFractPart * 0xffff) );
1199 dFractPart = modf(dEa - dSa, &dIntPart);
1200 vFSweepa = MAKEFIXED((int)dIntPart, (int)(dFractPart * 0xffff) );
1201
1202 //
1203 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1204 //
1205 vArcp.lR = 0;
1206 vArcp.lQ = vHeight/2;
1207 vArcp.lP = vWidth/2;
1208 vArcp.lS = 0;
1209 ::GpiSetArcParams(m_hPS, &vArcp); // Sets parameters to default
1210 vPtlPos.x = (wxCoord)(vX + vWidth/2 * (1. + cos(DegToRad(dSa)))); // Loads x-coordinate
1211 vPtlPos.y = (wxCoord)(vY + vHeight/2 * (1. + sin(DegToRad(dSa)))); // Loads y-coordinate
1212 ::GpiMove(m_hPS, &vPtlPos); // Sets current position
1213
1214 //
1215 // May be not to the center ?
1216 //
1217 vPtlPos.x = vX + vWidth/2 ; // Loads x-coordinate
1218 vPtlPos.y = vY + vHeight/2; // Loads y-coordinate
1219 vFxMult = MAKEFIXED(1, 0); // Sets multiplier
1220
1221 //
1222 // DRO_FILL, DRO_OTLINEFILL - where to get
1223 //
1224 ::GpiPartialArc( m_hPS
1225 ,&vPtlPos
1226 ,vFxMult
1227 ,vFSa
1228 ,vFSweepa
1229 );
1230 wxCoord vX2 = (vX + vWidth);
1231 wxCoord vY2 = (vY + vHeight);
1232
1233 CalcBoundingBox(vX, vY);
1234 CalcBoundingBox(vX2, vY2);
1235} // end of wxPMDCImpl::DoDrawEllipticArc
1236
1237void wxPMDCImpl::DoDrawIcon(
1238 const wxIcon& rIcon
1239, wxCoord vX
1240, wxCoord vY
1241)
1242{
1243 //
1244 // Need to copy back into a bitmap. ::WinDrawPointer uses device coords
1245 // and I don't feel like figuring those out for scrollable windows so
1246 // just convert to a bitmap then let the DoDrawBitmap routine display it
1247 //
1248 if (rIcon.IsXpm())
1249 {
1250 DoDrawBitmap(rIcon.GetXpmSrc(), vX, vY, true);
1251 }
1252 else
1253 {
1254 wxBitmap vBitmap(rIcon);
1255
1256 DoDrawBitmap(vBitmap, vX, vY, false);
1257 }
1258 CalcBoundingBox(vX, vY);
1259 CalcBoundingBox(vX + rIcon.GetWidth(), vY + rIcon.GetHeight());
1260} // end of wxPMDCImpl::DoDrawIcon
1261
1262void wxPMDCImpl::DoDrawBitmap(
1263 const wxBitmap& rBmp
1264, wxCoord vX
1265, wxCoord vY
1266, bool bUseMask
1267)
1268{
1269#if wxUSE_PRINTING_ARCHITECTURE
1270 if (!IsKindOf(CLASSINFO(wxPrinterDC)))
1271#endif
1272 {
1273 HBITMAP hBitmap = (HBITMAP)rBmp.GetHBITMAP();
1274 HBITMAP hBitmapOld = NULLHANDLE;
1275 POINTL vPoint[4];
1276
1277 vY = OS2Y(vY,rBmp.GetHeight());
1278
1279 vPoint[0].x = vX;
1280 vPoint[0].y = vY + rBmp.GetHeight();
1281 vPoint[1].x = vX + rBmp.GetWidth();
1282 vPoint[1].y = vY;
1283 vPoint[2].x = 0;
1284 vPoint[2].y = 0;
1285 vPoint[3].x = rBmp.GetWidth();
1286 vPoint[3].y = rBmp.GetHeight();
1287 if (bUseMask)
1288 {
1289 wxMask* pMask = rBmp.GetMask();
1290
1291 if (pMask)
1292 {
1293 //
1294 // Need to imitate ::MaskBlt in windows.
1295 // 1) Extract the bits from from the bitmap.
1296 // 2) Extract the bits from the mask
1297 // 3) Using the mask bits do the following:
1298 // A) If the mask byte is 00 leave the bitmap byte alone
1299 // B) If the mask byte is FF copy the screen color into
1300 // bitmap byte
1301 // 4) Create a new bitmap and set its bits to the above result
1302 // 5) Blit this to the screen PS
1303 //
1304 HBITMAP hMask = (HBITMAP)pMask->GetMaskBitmap();
1305 HBITMAP hOldMask = NULLHANDLE;
1306 HBITMAP hOldBitmap = NULLHANDLE;
1307 HBITMAP hNewBitmap = NULLHANDLE;
1308 unsigned char* pucBits; // buffer that will contain the bitmap data
1309 unsigned char* pucBitsMask; // buffer that will contain the mask data
1310 unsigned char* pucData; // pointer to use to traverse bitmap data
1311 unsigned char* pucDataMask; // pointer to use to traverse mask data
1312 LONG lHits;
1313 ERRORID vError;
1314 wxString sError;
1315
1316 //
1317 // The usual Memory context creation stuff
1318 //
1319 DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
1320 SIZEL vSize = {0, 0};
1321 HDC hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
1322 HPS hPS = ::GpiCreatePS(vHabmain, hDC, &vSize, PU_PELS | GPIA_ASSOC);
1323
1324 //
1325 // The usual bitmap header stuff
1326 //
1327 BITMAPINFOHEADER2 vHeader;
1328 BITMAPINFO2 vInfo;
1329
1330 memset(&vHeader, '\0', 16);
1331 vHeader.cbFix = 16;
1332
1333 memset(&vInfo, '\0', 16);
1334 vInfo.cbFix = 16;
1335 vInfo.cx = (ULONG)rBmp.GetWidth();
1336 vInfo.cy = (ULONG)rBmp.GetHeight();
1337 vInfo.cPlanes = 1;
1338 vInfo.cBitCount = 24; // Set to desired count going in
1339
1340 //
1341 // Create the buffers for data....all wxBitmaps are 24 bit internally
1342 //
1343 int nBytesPerLine = rBmp.GetWidth() * 3;
1344 int nSizeDWORD = sizeof(DWORD);
1345 int nLineBoundary = nBytesPerLine % nSizeDWORD;
1346 int nPadding = 0;
1347 int i;
1348 int j;
1349 LONG lScans = 0L;
1350 LONG lColor = 0L;
1351
1352 //
1353 // Need to get a background color for mask blitting
1354 //
1355 if (IsKindOf(CLASSINFO(wxWindowDCImpl)))
1356 {
1357 wxWindowDCImpl* pWindowDC = wxDynamicCast(this, wxWindowDCImpl);
1358
1359 lColor = pWindowDC->m_pCanvas->GetBackgroundColour().GetPixel();
1360 }
1361 else if (GetBrush().IsOk())
1362 lColor = GetBrush().GetColour().GetPixel();
1363 else
1364 lColor = m_textBackgroundColour.GetPixel();
1365
1366 //
1367 // Bitmap must be in a double-word aligned address so we may
1368 // have some padding to worry about
1369 //
1370 if (nLineBoundary > 0)
1371 {
1372 nPadding = nSizeDWORD - nLineBoundary;
1373 nBytesPerLine += nPadding;
1374 }
1375 pucBits = (unsigned char *)malloc(nBytesPerLine * rBmp.GetHeight());
1376 pucBitsMask = (unsigned char *)malloc(nBytesPerLine * rBmp.GetHeight());
1377 memset(pucBits, '\0', (nBytesPerLine * rBmp.GetHeight()));
1378 memset(pucBitsMask, '\0', (nBytesPerLine * rBmp.GetHeight()));
1379
1380 //
1381 // Extract the bitmap and mask data
1382 //
1383 if ((hOldBitmap = ::GpiSetBitmap(hPS, hBitmap)) == HBM_ERROR)
1384 {
1385 vError = ::WinGetLastError(vHabmain);
1386 sError = wxPMErrorToStr(vError);
1387 }
1388 ::GpiQueryBitmapInfoHeader(hBitmap, &vHeader);
1389 vInfo.cBitCount = 24;
1390 if ((lScans = ::GpiQueryBitmapBits( hPS
1391 ,0L
1392 ,(LONG)rBmp.GetHeight()
1393 ,(PBYTE)pucBits
1394 ,&vInfo
1395 )) == GPI_ALTERROR)
1396 {
1397 vError = ::WinGetLastError(vHabmain);
1398 sError = wxPMErrorToStr(vError);
1399 }
1400 if ((hOldMask = ::GpiSetBitmap(hPS, hMask)) == HBM_ERROR)
1401 {
1402 vError = ::WinGetLastError(vHabmain);
1403 sError = wxPMErrorToStr(vError);
1404 }
1405 ::GpiQueryBitmapInfoHeader(hMask, &vHeader);
1406 vInfo.cBitCount = 24;
1407 if ((lScans = ::GpiQueryBitmapBits( hPS
1408 ,0L
1409 ,(LONG)rBmp.GetHeight()
1410 ,(PBYTE)pucBitsMask
1411 ,&vInfo
1412 )) == GPI_ALTERROR)
1413 {
1414 vError = ::WinGetLastError(vHabmain);
1415 sError = wxPMErrorToStr(vError);
1416 }
1417 if (( hMask = ::GpiSetBitmap(hPS, hOldMask)) == HBM_ERROR)
1418 {
1419 vError = ::WinGetLastError(vHabmain);
1420 sError = wxPMErrorToStr(vError);
1421 }
1422
1423 //
1424 // Now set the bytes(bits) according to the mask values
1425 // 3 bytes per pel...must handle one at a time
1426 //
1427 pucData = pucBits;
1428 pucDataMask = pucBitsMask;
1429
1430 //
1431 // 16 bit kludge really only kinda works. The mask gets applied
1432 // where needed but the original bitmap bits are dorked sometimes
1433 //
1434 bool bpp16 = (wxDisplayDepth() == 16);
1435
1436 for (i = 0; i < rBmp.GetHeight(); i++)
1437 {
1438 for (j = 0; j < rBmp.GetWidth(); j++)
1439 {
1440 // Byte 1
1441 if (bpp16 && *pucDataMask == 0xF8) // 16 bit display gobblygook
1442 pucData++;
1443 else if (*pucDataMask == 0xFF) // leave bitmap byte alone
1444 pucData++;
1445 else
1446 {
1447 *pucData = ((unsigned char)(lColor >> 16));
1448 pucData++;
1449 }
1450 // Byte 2
1451 if (bpp16 && *(pucDataMask + 1) == 0xFC) // 16 bit display gobblygook
1452 pucData++;
1453 else if (*(pucDataMask + 1) == 0xFF) // leave bitmap byte alone
1454 pucData++;
1455 else
1456 {
1457 *pucData = ((unsigned char)(lColor >> 8));
1458 pucData++;
1459 }
1460
1461 // Byte 3
1462 if (bpp16 && *(pucDataMask + 2) == 0xF8) // 16 bit display gobblygook
1463 pucData++;
1464 else if (*(pucDataMask + 2) == 0xFF) // leave bitmap byte alone
1465 pucData++;
1466 else
1467 {
1468 *pucData = ((unsigned char)lColor);
1469 pucData++;
1470 }
1471 pucDataMask += 3;
1472 }
1473 for (j = 0; j < nPadding; j++)
1474 {
1475 pucData++;
1476 pucDataMask++;
1477 }
1478 }
1479 //
1480 // Create a new bitmap
1481 //
1482 vHeader.cx = (ULONG)rBmp.GetWidth();
1483 vHeader.cy = (ULONG)rBmp.GetHeight();
1484 vHeader.cPlanes = 1L;
1485 vHeader.cBitCount = 24;
1486 if ((hNewBitmap = ::GpiCreateBitmap( hPS
1487 ,&vHeader
1488 ,CBM_INIT
1489 ,(PBYTE)pucBits
1490 ,&vInfo
1491 )) == GPI_ERROR)
1492 {
1493 vError = ::WinGetLastError(vHabmain);
1494 sError = wxPMErrorToStr(vError);
1495 }
1496
1497 //
1498 // Now blit it to the screen PS
1499 //
1500 if ((lHits = ::GpiWCBitBlt( (HPS)GetHPS()
1501 ,hNewBitmap
1502 ,4
1503 ,vPoint
1504 ,ROP_SRCCOPY
1505 ,BBO_IGNORE
1506 )) == GPI_ERROR)
1507 {
1508 vError = ::WinGetLastError(vHabmain);
1509 sError = wxPMErrorToStr(vError);
1510 }
1511
1512 //
1513 // Clean up
1514 //
1515 free(pucBits);
1516 free(pucBitsMask);
1517 ::GpiSetBitmap(hPS, NULLHANDLE);
1518 ::GpiDeleteBitmap(hNewBitmap);
1519 ::GpiDestroyPS(hPS);
1520 ::DevCloseDC(hDC);
1521 }
1522 }
1523 else
1524 {
1525 ULONG lOldForeGround = ::GpiQueryColor((HPS)GetHPS());
1526 ULONG lOldBackGround = ::GpiQueryBackColor((HPS)GetHPS());
1527
1528 if (m_textForegroundColour.IsOk())
1529 {
1530 ::GpiSetColor( (HPS)GetHPS()
1531 ,m_textForegroundColour.GetPixel()
1532 );
1533 }
1534 if (m_textBackgroundColour.IsOk())
1535 {
1536 ::GpiSetBackColor( (HPS)GetHPS()
1537 ,m_textBackgroundColour.GetPixel()
1538 );
1539 }
1540 //
1541 // Need to alter bits in a mono bitmap to match the new
1542 // background-foreground if it is different.
1543 //
1544 if (rBmp.IsMono() &&
1545 ((m_textForegroundColour.GetPixel() != lOldForeGround) ||
1546 (m_textBackgroundColour.GetPixel() != lOldBackGround)))
1547 {
1548 DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
1549 SIZEL vSize = {0, 0};
1550 HDC hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
1551 HPS hPS = ::GpiCreatePS(vHabmain, hDC, &vSize, PU_PELS | GPIA_ASSOC);
1552
1553 int nBytesPerLine = rBmp.GetWidth() * 3;
1554 int i, j;
1555 LONG lForeGround = m_textForegroundColour.GetPixel();
1556 LONG lBackGround = m_textBackgroundColour.GetPixel();
1557 LONG lScans;
1558 HBITMAP hOldBitmap = NULLHANDLE;
1559 BITMAPINFO2 vInfo;
1560 ERRORID vError;
1561 wxString sError;
1562
1563
1564 memset(&vInfo, '\0', 16);
1565 vInfo.cbFix = 16;
1566 vInfo.cx = (ULONG)rBmp.GetWidth();
1567 vInfo.cy = (ULONG)rBmp.GetHeight();
1568 vInfo.cPlanes = 1;
1569 vInfo.cBitCount = 24;
1570
1571 unsigned char* pucBits; // buffer that will contain the bitmap data
1572 unsigned char* pucData; // pointer to use to traverse bitmap data
1573
1574 pucBits = new unsigned char[nBytesPerLine * rBmp.GetHeight()];
1575 memset(pucBits, '\0', (nBytesPerLine * rBmp.GetHeight()));
1576
1577 if ((hOldBitmap = ::GpiSetBitmap(hPS, hBitmap)) == HBM_ERROR)
1578 {
1579 vError = ::WinGetLastError(vHabmain);
1580 sError = wxPMErrorToStr(vError);
1581 delete [] pucBits;
1582 return;
1583 }
1584 if ((lScans = ::GpiQueryBitmapBits( hPS
1585 ,0L
1586 ,(LONG)rBmp.GetHeight()
1587 ,(PBYTE)pucBits
1588 ,&vInfo
1589 )) == GPI_ALTERROR)
1590 {
1591 vError = ::WinGetLastError(vHabmain);
1592 sError = wxPMErrorToStr(vError);
1593 delete [] pucBits;
1594 return;
1595 }
1596 unsigned char cOldRedFore = (unsigned char)(lOldForeGround >> 16);
1597 unsigned char cOldGreenFore = (unsigned char)(lOldForeGround >> 8);
1598 unsigned char cOldBlueFore = (unsigned char)lOldForeGround;
1599
1600 unsigned char cRedFore = (unsigned char)(lForeGround >> 16);
1601 unsigned char cGreenFore = (unsigned char)(lForeGround >> 8);
1602 unsigned char cBlueFore = (unsigned char)lForeGround;
1603
1604 unsigned char cRedBack = (unsigned char)(lBackGround >> 16);
1605 unsigned char cGreenBack = (unsigned char)(lBackGround >> 8);
1606 unsigned char cBlueBack = (unsigned char)lBackGround;
1607
1608 pucData = pucBits;
1609 for (i = 0; i < rBmp.GetHeight(); i++)
1610 {
1611 for (j = 0; j < rBmp.GetWidth(); j++)
1612 {
1613 unsigned char cBmpRed = *pucData;
1614 unsigned char cBmpGreen = *(pucData + 1);
1615 unsigned char cBmpBlue = *(pucData + 2);
1616
1617 if ((cBmpRed == cOldRedFore) &&
1618 (cBmpGreen == cOldGreenFore) &&
1619 (cBmpBlue == cOldBlueFore))
1620 {
1621 *pucData = cBlueFore;
1622 pucData++;
1623 *pucData = cGreenFore;
1624 pucData++;
1625 *pucData = cRedFore;
1626 pucData++;
1627 }
1628 else
1629 {
1630 *pucData = cBlueBack;
1631 pucData++;
1632 *pucData = cGreenBack;
1633 pucData++;
1634 *pucData = cRedBack;
1635 pucData++;
1636 }
1637 }
1638 }
1639 if ((lScans = ::GpiSetBitmapBits( hPS
1640 ,0L
1641 ,(LONG)rBmp.GetHeight()
1642 ,(PBYTE)pucBits
1643 ,&vInfo
1644 )) == GPI_ALTERROR)
1645 {
1646 vError = ::WinGetLastError(vHabmain);
1647 sError = wxPMErrorToStr(vError);
1648 return;
1649 }
1650 delete [] pucBits;
1651 ::GpiSetBitmap(hPS, NULLHANDLE);
1652 ::GpiDestroyPS(hPS);
1653 ::DevCloseDC(hDC);
1654 }
1655 ::GpiWCBitBlt( (HPS)GetHPS()
1656 ,hBitmap
1657 ,4
1658 ,vPoint
1659 ,ROP_SRCCOPY
1660 ,BBO_IGNORE
1661 );
1662 ::GpiSetBitmap((HPS)GetHPS(), hBitmapOld);
1663 ::GpiSetColor((HPS)GetHPS(), lOldForeGround);
1664 ::GpiSetBackColor((HPS)GetHPS(), lOldBackGround);
1665 }
1666 }
1667} // end of wxPMDCImpl::DoDrawBitmap
1668
1669void wxPMDCImpl::DoDrawText(
1670 const wxString& rsText
1671, wxCoord vX
1672, wxCoord vY
1673)
1674{
1675 wxCoord vWidth;
1676 wxCoord vHeight;
1677
1678 DrawAnyText( rsText
1679 ,vX
1680 ,vY
1681 );
1682
1683 CalcBoundingBox(vX, vY);
1684 GetOwner()->GetTextExtent(rsText, &vWidth, &vHeight);
1685 CalcBoundingBox((vX + vWidth), (vY + vHeight));
1686} // end of wxPMDCImpl::DoDrawText
1687
1688void wxPMDCImpl::DrawAnyText( const wxString& rsText,
1689 wxCoord vX,
1690 wxCoord vY )
1691{
1692 int nOldBackground = 0;
1693 POINTL vPtlStart;
1694 LONG lHits;
1695 wxCoord vTextX = 0;
1696 wxCoord vTextY = 0;
1697
1698 //
1699 // prepare for drawing the text
1700 //
1701
1702 //
1703 // Set text color attributes
1704 //
1705 if (m_textForegroundColour.IsOk())
1706 {
1707 SetTextColor( m_hPS
1708 ,(int)m_textForegroundColour.GetPixel()
1709 );
1710 }
1711
1712 if (m_textBackgroundColour.IsOk())
1713 {
1714 nOldBackground = SetTextBkColor( m_hPS
1715 ,(int)m_textBackgroundColour.GetPixel()
1716 );
1717 }
1718 SetBkMode( m_hPS
1719 ,m_backgroundMode
1720 );
1721 GetOwner()->GetTextExtent( rsText
1722 ,&vTextX
1723 ,&vTextY
1724 );
1725 vPtlStart.x = vX;
1726 if (!(m_vRclPaint.yTop == 0 &&
1727 m_vRclPaint.yBottom == 0 &&
1728 m_vRclPaint.xRight == 0 &&
1729 m_vRclPaint.xLeft == 0))
1730 {
1731 vPtlStart.y = OS2Y(vY,vTextY);
1732 }
1733 else
1734 {
1735 if (m_vSelectedBitmap.IsOk())
1736 {
1737 m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
1738 m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
1739 vPtlStart.y = OS2Y(vY,vTextY);
1740 }
1741 else
1742 vPtlStart.y = vY;
1743 }
1744
1745 ::GpiMove(m_hPS, &vPtlStart);
1746 lHits = ::GpiCharString( m_hPS
1747 ,rsText.length()
1748 ,rsText.char_str()
1749 );
1750 if (lHits != GPI_OK)
1751 {
1752 wxLogLastError(wxT("TextOut"));
1753 }
1754
1755 //
1756 // Restore the old parameters (text foreground colour may be left because
1757 // it never is set to anything else, but background should remain
1758 // transparent even if we just drew an opaque string)
1759 //
1760 if (m_textBackgroundColour.IsOk())
1761 SetTextBkColor( m_hPS
1762 ,nOldBackground
1763 );
1764 SetBkMode( m_hPS
1765 ,wxTRANSPARENT
1766 );
1767}
1768
1769void wxPMDCImpl::DoDrawRotatedText(
1770 const wxString& rsText
1771, wxCoord vX
1772, wxCoord vY
1773, double dAngle
1774)
1775{
1776 if (dAngle == 0.0)
1777 {
1778 DoDrawText( rsText
1779 ,vX
1780 ,vY
1781 );
1782 }
1783
1784 // TODO:
1785 /*
1786 if ( angle == 0.0 )
1787 {
1788 DoDrawText(text, x, y);
1789 }
1790 else
1791 {
1792 LOGFONT lf;
1793 wxFillLogFont(&lf, &m_font);
1794
1795 // GDI wants the angle in tenth of degree
1796 long angle10 = (long)(angle * 10);
1797 lf.lfEscapement = angle10;
1798 lf. lfOrientation = angle10;
1799
1800 HFONT hfont = ::CreateFontIndirect(&lf);
1801 if ( !hfont )
1802 {
1803 wxLogLastError("CreateFont");
1804 }
1805 else
1806 {
1807 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1808
1809 DrawAnyText(text, x, y);
1810
1811 (void)::SelectObject(GetHdc(), hfontOld);
1812 }
1813
1814 // call the bounding box by adding all four vertices of the rectangle
1815 // containing the text to it (simpler and probably not slower than
1816 // determining which of them is really topmost/leftmost/...)
1817 wxCoord w, h;
1818 GetTextExtent(text, &w, &h);
1819
1820 double rad = DegToRad(angle);
1821
1822 // "upper left" and "upper right"
1823 CalcBoundingBox(x, y);
1824 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1825 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1826
1827 // "bottom left" and "bottom right"
1828 x += (wxCoord)(h*sin(rad));
1829 y += (wxCoord)(h*cos(rad));
1830 CalcBoundingBox(x, y);
1831 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1832 }
1833*/
1834}
1835
1836// ---------------------------------------------------------------------------
1837// set GDI objects
1838// ---------------------------------------------------------------------------
1839
1840void wxPMDCImpl::DoSelectPalette( bool WXUNUSED(bRealize) )
1841{
1842 //
1843 // Set the old object temporarily, in case the assignment deletes an object
1844 // that's not yet selected out.
1845 //
1846 if (m_hOldPalette)
1847 {
1848 m_hOldPalette = 0;
1849 }
1850
1851 if (m_palette.IsOk())
1852 {
1853 HPALETTE hOldPal;
1854
1855 hOldPal = ::GpiSelectPalette((HDC) m_hPS, (HPALETTE) m_palette.GetHPALETTE());
1856 if (!m_hOldPalette)
1857 m_hOldPalette = (WXHPALETTE)hOldPal;
1858 }
1859} // end of wxPMDCImpl::DoSelectPalette
1860
1861void wxPMDCImpl::InitializePalette()
1862{
1863 if (wxDisplayDepth() <= 8 )
1864 {
1865 //
1866 // Look for any window or parent that has a custom palette. If any has
1867 // one then we need to use it in drawing operations
1868 //
1869 wxWindow* pWin = m_pCanvas->GetAncestorWithCustomPalette();
1870
1871 m_hasCustomPalette = pWin && pWin->HasCustomPalette();
1872 if (m_hasCustomPalette)
1873 {
1874 m_palette = pWin->GetPalette();
1875
1876 //
1877 // turn on PM translation for this palette
1878 //
1879 DoSelectPalette();
1880 }
1881 }
1882} // end of wxPMDCImpl::InitializePalette
1883
1884void wxPMDCImpl::SetPalette(
1885 const wxPalette& rPalette
1886)
1887{
1888 if (m_hOldFont)
1889 {
1890 m_hOldFont = 0;
1891 }
1892 m_palette = rPalette;
1893 if (!rPalette.IsOk())
1894 {
1895 if (m_hOldFont)
1896 {
1897 m_hOldFont = 0;
1898 }
1899 }
1900 HPALETTE hOldPal = ::GpiSelectPalette((HDC) m_hPS, (HPALETTE) m_palette.GetHPALETTE());
1901 if (!m_hOldPalette)
1902 m_hOldPalette = (WXHPALETTE)hOldPal;
1903} // end of wxPMDCImpl::SetPalette
1904
1905void wxPMDCImpl::SetFont(
1906 const wxFont& rFont
1907)
1908{
1909 //
1910 // Set the old object temporarily, in case the assignment deletes an object
1911 // that's not yet selected out.
1912 //
1913 if (m_hOldFont)
1914 {
1915 m_hOldFont = 0;
1916 }
1917 m_font = rFont;
1918 if (!rFont.IsOk())
1919 {
1920 m_hOldFont = 0;
1921 }
1922
1923 m_font.SetPS(m_hPS); // this will realize the font
1924
1925 if (m_font.IsOk())
1926 {
1927 HFONT hFont = m_font.GetResourceHandle();
1928 if (hFont == (HFONT) NULL)
1929 {
1930 wxLogDebug(wxT("::SelectObject failed in wxPMDCImpl::SetFont."));
1931 }
1932 if (!m_hOldFont)
1933 m_hOldFont = (WXHFONT) hFont;
1934 }
1935} // end of wxPMDCImpl::SetFont
1936
1937void wxPMDCImpl::SetPen(
1938 const wxPen& rPen
1939)
1940{
1941 if (m_pen == rPen)
1942 return;
1943 m_pen = rPen;
1944 if (!m_pen.IsOk())
1945 return;
1946
1947 if (m_hOldPen)
1948 m_hOldPen = 0L;
1949 m_pen = rPen;
1950
1951 if (!m_pen.IsOk())
1952 {
1953 if (m_hOldPen)
1954 {
1955 m_pen.SetPS((HPS)m_hOldPen);
1956 }
1957 m_hOldPen = 0L;
1958 }
1959
1960 if (m_pen.IsOk())
1961 {
1962 if (m_pen.GetResourceHandle())
1963 {
1964 m_pen.SetPS(m_hPS);
1965 if (!m_hOldPen)
1966 m_hOldPen = m_pen.GetPS();
1967 }
1968 ::GpiSetColor(m_hPS, m_pen.GetColour().GetPixel());
1969 }
1970}
1971
1972void wxPMDCImpl::SetBrush(
1973 const wxBrush& rBrush
1974)
1975{
1976 if (m_hOldBrush)
1977 m_hOldBrush = 0L;
1978 m_brush = rBrush;
1979 if (!m_brush.IsOk())
1980 if (m_brush == rBrush)
1981 return;
1982 if (!m_brush.IsOk())
1983 if (m_hOldBrush)
1984 m_hOldBrush = 0L;
1985
1986 if (!m_brush.IsOk())
1987 {
1988 if (m_hOldBrush)
1989 {
1990 m_brush.SetPS((HPS)m_hOldBrush);
1991 }
1992 m_hOldBrush = 0L;
1993 }
1994
1995 if (m_brush.IsOk())
1996 {
1997 if (m_brush.GetResourceHandle())
1998 {
1999 m_brush.SetPS(m_hPS);
2000 if (!m_hOldBrush)
2001 m_hOldBrush = (WXHWND)m_brush.GetPS();
2002 }
2003 }
2004} // end of wxPMDCImpl::SetBrush
2005
2006void wxPMDCImpl::SetBackground(const wxBrush& rBrush)
2007{
2008 m_backgroundBrush = rBrush;
2009
2010 if (m_backgroundBrush.IsOk())
2011 {
2012 (void)::GpiSetBackColor((HPS)m_hPS, m_backgroundBrush.GetColour().GetPixel());
2013 }
2014} // end of wxPMDCImpl::SetBackground
2015
2016void wxPMDCImpl::SetBackgroundMode(int nMode)
2017{
2018 m_backgroundMode = nMode;
2019} // end of wxPMDCImpl::SetBackgroundMode
2020
2021void wxPMDCImpl::SetLogicalFunction(wxRasterOperationMode nFunction)
2022{
2023 m_logicalFunction = nFunction;
2024 SetRop((WXHDC)m_hDC);
2025} // wxPMDCImpl::SetLogicalFunction
2026
2027void wxPMDCImpl::SetRop(WXHDC hDC)
2028{
2029 if (!hDC || m_logicalFunction < 0)
2030 return;
2031
2032 LONG lCRop;
2033 switch (m_logicalFunction)
2034 {
2035 case wxXOR:
2036 lCRop = FM_XOR;
2037 break;
2038
2039 case wxINVERT:
2040 lCRop = FM_INVERT;
2041 break;
2042
2043 case wxOR_REVERSE:
2044 lCRop = FM_MERGESRCNOT;
2045 break;
2046
2047 case wxAND_REVERSE:
2048 lCRop = FM_NOTMASKSRC;
2049 break;
2050
2051 case wxCLEAR:
2052 lCRop = FM_ONE;
2053 break;
2054
2055 case wxSET:
2056 lCRop = FM_ZERO;
2057 break;
2058
2059 case wxSRC_INVERT:
2060 lCRop = FM_MERGENOTSRC;
2061 break;
2062
2063 case wxOR_INVERT:
2064 lCRop = FM_MERGESRCNOT;
2065 break;
2066
2067 case wxAND:
2068 lCRop = FM_AND;
2069 break;
2070
2071 case wxOR:
2072 lCRop = FM_OR;
2073 break;
2074
2075 case wxAND_INVERT:
2076 lCRop = FM_SUBTRACT;
2077 break;
2078
2079 case wxEQUIV:
2080 case wxNAND:
2081 case wxCOPY:
2082 default:
2083 lCRop = FM_OVERPAINT;
2084 break;
2085 }
2086 ::GpiSetMix((HPS)hDC, lCRop);
2087} // end of wxPMDCImpl::SetRop
2088
2089bool wxPMDCImpl::StartDoc( const wxString& WXUNUSED(rsMessage) )
2090{
2091 // We might be previewing, so return true to let it continue.
2092 return true;
2093} // end of wxPMDCImpl::StartDoc
2094
2095void wxPMDCImpl::EndDoc()
2096{
2097} // end of wxPMDCImpl::EndDoc
2098
2099void wxPMDCImpl::StartPage()
2100{
2101} // end of wxPMDCImpl::StartPage
2102
2103void wxPMDCImpl::EndPage()
2104{
2105} // end of wxPMDCImpl::EndPage
2106
2107// ---------------------------------------------------------------------------
2108// text metrics
2109// ---------------------------------------------------------------------------
2110
2111wxCoord wxPMDCImpl::GetCharHeight() const
2112{
2113 FONTMETRICS vFM; // metrics structure
2114
2115 ::GpiQueryFontMetrics( m_hPS
2116 ,sizeof(FONTMETRICS)
2117 ,&vFM
2118 );
2119 return YDEV2LOGREL(vFM.lXHeight);
2120}
2121
2122wxCoord wxPMDCImpl::GetCharWidth() const
2123{
2124 FONTMETRICS vFM; // metrics structure
2125
2126 ::GpiQueryFontMetrics( m_hPS
2127 ,sizeof(FONTMETRICS)
2128 ,&vFM
2129 );
2130 return XDEV2LOGREL(vFM.lAveCharWidth);
2131}
2132
2133void wxPMDCImpl::DoGetTextExtent(
2134 const wxString& rsString
2135, wxCoord* pvX
2136, wxCoord* pvY
2137, wxCoord* pvDescent
2138, wxCoord* pvExternalLeading
2139, const wxFont* pTheFont
2140) const
2141{
2142 POINTL avPoint[TXTBOX_COUNT];
2143 POINTL vPtMin;
2144 POINTL vPtMax;
2145 int i;
2146 int l;
2147 FONTMETRICS vFM; // metrics structure
2148 BOOL bRc;
2149 ERRORID vErrorCode; // last error id code
2150 wxFont* pFontToUse = (wxFont*)pTheFont;
2151
2152 wxChar zMsg[128]; // DEBUG
2153 wxString sError;
2154
2155 if (!pFontToUse)
2156 pFontToUse = (wxFont*)&m_font;
2157 l = rsString.length();
2158
2159 //
2160 // In world coordinates.
2161 //
2162 if (!m_hPS)
2163 {
2164 (void)wxMessageBox( wxT("wxWidgets core library")
2165 ,"Using uninitialized DC for measuring text!\n"
2166 ,wxICON_INFORMATION
2167 );
2168 }
2169
2170 bRc = ::GpiQueryTextBox( m_hPS
2171 ,l
2172 ,rsString.char_str()
2173 ,TXTBOX_COUNT // return maximum information
2174 ,avPoint // array of coordinates points
2175 );
2176 if(!bRc)
2177 {
2178 vErrorCode = ::WinGetLastError(wxGetInstance());
2179 sError = wxPMErrorToStr(vErrorCode);
2180 // DEBUG
2181 wxSprintf(zMsg, wxT("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString.c_str(), vErrorCode, sError.c_str());
2182 (void)wxMessageBox( wxT("wxWidgets core library")
2183 ,zMsg
2184 ,wxICON_INFORMATION
2185 );
2186 }
2187
2188 vPtMin.x = avPoint[0].x;
2189 vPtMax.x = avPoint[0].x;
2190 vPtMin.y = avPoint[0].y;
2191 vPtMax.y = avPoint[0].y;
2192 for (i = 1; i < 4; i++)
2193 {
2194 if(vPtMin.x > avPoint[i].x) vPtMin.x = avPoint[i].x;
2195 if(vPtMin.y > avPoint[i].y) vPtMin.y = avPoint[i].y;
2196 if(vPtMax.x < avPoint[i].x) vPtMax.x = avPoint[i].x;
2197 if(vPtMax.y < avPoint[i].y) vPtMax.y = avPoint[i].y;
2198 }
2199 ::GpiQueryFontMetrics( m_hPS
2200 ,sizeof(FONTMETRICS)
2201 ,&vFM
2202 );
2203
2204 if (pvX)
2205 *pvX = (wxCoord)(vPtMax.x - vPtMin.x + 1);
2206 if (pvY)
2207 *pvY = (wxCoord)(vPtMax.y - vPtMin.y + 1);
2208 if (pvDescent)
2209 *pvDescent = vFM.lMaxDescender;
2210 if (pvExternalLeading)
2211 *pvExternalLeading = vFM.lExternalLeading;
2212}
2213
2214void wxPMDCImpl::SetMapMode(
2215 wxMappingMode nMode
2216)
2217{
2218 int nPixelWidth = 0;
2219 int nPixelHeight = 0;
2220 int nMmWidth = 1;
2221 int nMmHeight = 1;
2222 LONG lArray[CAPS_VERTICAL_RESOLUTION+1];
2223
2224 m_mappingMode = nMode;
2225
2226 if(::DevQueryCaps( m_hDC
2227 ,CAPS_FAMILY // id of first item
2228 ,CAPS_VERTICAL_RESOLUTION+1 // number of items wanted
2229 ,lArray
2230 ))
2231 {
2232 LONG lHorzRes;
2233 LONG lVertRes;
2234
2235 nPixelWidth = lArray[CAPS_WIDTH];
2236 nPixelHeight = lArray[CAPS_HEIGHT];
2237 lHorzRes = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
2238 lVertRes = lArray[CAPS_VERTICAL_RESOLUTION]; // returns pel/meter
2239 nMmWidth = (lHorzRes/1000) * nPixelWidth;
2240 nMmHeight = (lVertRes/1000) * nPixelHeight;
2241 }
2242 if ((nPixelWidth == 0) || (nPixelHeight == 0) || (nMmWidth == 0) || (nMmHeight == 0))
2243 {
2244 return;
2245 }
2246
2247 double dMm2pixelsX = nPixelWidth/(double)nMmWidth;
2248 double dMm2pixelsY = nPixelHeight/(double)nMmHeight;
2249
2250 switch (nMode)
2251 {
2252 case wxMM_TWIPS:
2253 m_logicalScaleX = (twips2mm * dMm2pixelsX);
2254 m_logicalScaleY = (twips2mm * dMm2pixelsY);
2255 break;
2256
2257 case wxMM_POINTS:
2258 m_logicalScaleX = (pt2mm * dMm2pixelsX);
2259 m_logicalScaleY = (pt2mm * dMm2pixelsY);
2260 break;
2261
2262 case wxMM_METRIC:
2263 m_logicalScaleX = dMm2pixelsX;
2264 m_logicalScaleY = dMm2pixelsY;
2265 break;
2266
2267 case wxMM_LOMETRIC:
2268 m_logicalScaleX = (dMm2pixelsX/10.0);
2269 m_logicalScaleY = (dMm2pixelsY/10.0);
2270 break;
2271
2272 case wxMM_TEXT:
2273 default:
2274 m_logicalScaleX = 1.0;
2275 m_logicalScaleY = 1.0;
2276 break;
2277 }
2278
2279 SIZEL vSize;
2280 ULONG ulOptions;
2281
2282 ulOptions = ::GpiQueryPS(m_hPS, &vSize);
2283 if (!ulOptions & PU_ARBITRARY)
2284 {
2285 ulOptions = PU_ARBITRARY | GPIF_DEFAULT;
2286 ::GpiSetPS(m_hPS, &vSize, ulOptions);
2287 }
2288 ComputeScaleAndOrigin();
2289
2290}; // end of wxPMDCImpl::SetMapMode
2291
2292void wxPMDCImpl::SetUserScale( double dX,
2293 double dY )
2294{
2295 m_userScaleX = dX;
2296 m_userScaleY = dY;
2297
2298 SetMapMode(m_mappingMode);
2299} // end of wxPMDCImpl::SetUserScale
2300
2301void wxPMDCImpl::SetAxisOrientation( bool bXLeftRight,
2302 bool bYBottomUp )
2303{
2304 m_signX = bXLeftRight ? 1 : -1;
2305 m_signY = bYBottomUp ? -1 : 1;
2306
2307 SetMapMode(m_mappingMode);
2308} // end of wxPMDCImpl::SetAxisOrientation
2309
2310void wxPMDCImpl::SetLogicalOrigin(
2311 wxCoord vX
2312, wxCoord vY
2313)
2314{
2315 RECTL vRect;
2316
2317 ::GpiQueryPageViewport( m_hPS
2318 ,&vRect
2319 );
2320 vRect.xRight -= vX;
2321 vRect.yTop += vY;
2322 vRect.xLeft = vX;
2323 vRect.yBottom = vY;
2324 ::GpiSetPageViewport( m_hPS
2325 ,&vRect
2326 );
2327}; // end of wxPMDCImpl::SetLogicalOrigin
2328
2329void wxPMDCImpl::SetDeviceOrigin(
2330 wxCoord vX
2331, wxCoord vY
2332)
2333{
2334 RECTL vRect;
2335
2336 m_deviceOriginX = vX;
2337 m_deviceOriginY = vY;
2338 ::GpiQueryPageViewport( m_hPS
2339 ,&vRect
2340 );
2341 vRect.xLeft += vX;
2342 vRect.xRight += vX;
2343 vRect.yBottom -= vY;
2344 vRect.yTop -= vY;
2345 ::GpiSetPageViewport( m_hPS
2346 ,&vRect
2347 );
2348}; // end of wxPMDCImpl::SetDeviceOrigin
2349
2350// ---------------------------------------------------------------------------
2351// bit blit
2352// ---------------------------------------------------------------------------
2353
2354bool wxPMDCImpl::DoBlit( wxCoord vXdest,
2355 wxCoord vYdest,
2356 wxCoord vWidth,
2357 wxCoord vHeight,
2358 wxDC* pSource,
2359 wxCoord vXsrc,
2360 wxCoord vYsrc,
2361 wxRasterOperationMode nRop,
2362 bool bUseMask,
2363 wxCoord WXUNUSED(vXsrcMask),
2364 wxCoord WXUNUSED(vYsrcMask) )
2365{
2366 wxMask* pMask = NULL;
2367 CHARBUNDLE vCbnd;
2368 COLORREF vOldTextColor;
2369 COLORREF vOldBackground = ::GpiQueryBackColor(m_hPS);
2370
2371 wxDCImpl *impl = pSource->GetImpl();
2372 wxPMDCImpl *pm_impl = wxDynamicCast( impl, wxPMDCImpl );
2373 if (!pm_impl)
2374 {
2375 // TODO: Do we want to be able to blit
2376 // from other DCs too?
2377 return false;
2378 }
2379
2380 if (bUseMask)
2381 {
2382 const wxBitmap& rBmp = pm_impl->GetSelectedBitmap();
2383
2384 pMask = rBmp.GetMask();
2385 if (!(rBmp.IsOk() && pMask && pMask->GetMaskBitmap()))
2386 {
2387 bUseMask = false;
2388 }
2389 }
2390
2391 ::GpiQueryAttrs( m_hPS
2392 ,PRIM_CHAR
2393 ,CBB_COLOR
2394 ,&vCbnd
2395 );
2396 vOldTextColor = (COLORREF)vCbnd.lColor;
2397
2398 if (m_textForegroundColour.IsOk())
2399 {
2400 vCbnd.lColor = (LONG)m_textForegroundColour.GetPixel();
2401 ::GpiSetAttrs( m_hPS // presentation-space handle
2402 ,PRIM_CHAR // Char primitive.
2403 ,CBB_COLOR // sets color.
2404 ,0
2405 ,&vCbnd // buffer for attributes.
2406 );
2407 }
2408 if (m_textBackgroundColour.IsOk())
2409 {
2410 ::GpiSetBackColor(m_hPS, (LONG)m_textBackgroundColour.GetPixel());
2411 }
2412
2413 LONG lRop = ROP_SRCCOPY;
2414
2415 switch (nRop)
2416 {
2417 case wxXOR: lRop = ROP_SRCINVERT; break;
2418 case wxINVERT: lRop = ROP_DSTINVERT; break;
2419 case wxOR_REVERSE: lRop = 0x00DD0228; break;
2420 case wxAND_REVERSE: lRop = ROP_SRCERASE; break;
2421 case wxCLEAR: lRop = ROP_ZERO; break;
2422 case wxSET: lRop = ROP_ONE; break;
2423 case wxOR_INVERT: lRop = ROP_MERGEPAINT; break;
2424 case wxAND: lRop = ROP_SRCAND; break;
2425 case wxOR: lRop = ROP_SRCPAINT; break;
2426 case wxEQUIV: lRop = 0x00990066; break;
2427 case wxNAND: lRop = 0x007700E6; break;
2428 case wxAND_INVERT: lRop = 0x00220326; break;
2429 case wxCOPY: lRop = ROP_SRCCOPY; break;
2430 case wxNO_OP: lRop = ROP_NOTSRCERASE; break;
2431 case wxSRC_INVERT: lRop = ROP_SRCINVERT; break;
2432 case wxNOR: lRop = ROP_NOTSRCCOPY; break;
2433 default:
2434 wxFAIL_MSG( wxT("unsupported logical function") );
2435 return false;
2436 }
2437
2438 bool bSuccess;
2439
2440 if (bUseMask)
2441 {
2442 //
2443 // Blit bitmap with mask
2444 //
2445
2446 //
2447 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2448 //
2449 HDC hDCMask;
2450 HDC hDCBuffer;
2451 HPS hPSMask;
2452 HPS hPSBuffer;
2453 DEVOPENSTRUC vDOP = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
2454 BITMAPINFOHEADER2 vBmpHdr;
2455 HBITMAP hBufBitmap;
2456 SIZEL vSize = {0, 0};
2457 LONG rc;
2458
2459 memset(&vBmpHdr, 0, sizeof(BITMAPINFOHEADER2));
2460 vBmpHdr.cbFix = sizeof(BITMAPINFOHEADER2);
2461 vBmpHdr.cx = vWidth;
2462 vBmpHdr.cy = vHeight;
2463 vBmpHdr.cPlanes = 1;
2464 vBmpHdr.cBitCount = 24;
2465
2466#if wxUSE_DC_CACHEING
2467 {
2468 //
2469 // create a temp buffer bitmap and DCs to access it and the mask
2470 //
2471 wxDCCacheEntry* pDCCacheEntry1 = FindDCInCache( NULL
2472 ,pm_impl->GetHPS()
2473 );
2474 wxDCCacheEntry* pDCCacheEntry2 = FindDCInCache( pDCCacheEntry1
2475 ,GetHPS()
2476 );
2477 wxDCCacheEntry* pBitmapCacheEntry = FindBitmapInCache( GetHPS()
2478 ,vWidth
2479 ,vHeight
2480 );
2481
2482 hPSMask = pDCCacheEntry1->m_hPS;
2483 hDCBuffer = (HDC)pDCCacheEntry2->m_hPS;
2484 hBufBitmap = (HBITMAP)pBitmapCacheEntry->m_hBitmap;
2485 wxUnusedVar(hDCMask);
2486 }
2487#else
2488 {
2489 hDCMask = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDOP, NULLHANDLE);
2490 hDCBuffer = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDOP, NULLHANDLE);
2491 hPSMask = ::GpiCreatePS(vHabmain, hDCMask, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
2492 hPSBuffer = ::GpiCreatePS(vHabmain, hDCBuffer, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
2493 hBufBitmap = ::GpiCreateBitmap(GetHPS(), &vBmpHdr, 0L, NULL, NULL);
2494 }
2495#endif
2496
2497 POINTL aPoint1[4] = { {0, 0}
2498 ,{vWidth, vHeight}
2499 ,{vXdest, vYdest}
2500 ,{vXdest + vWidth, vYdest + vHeight}
2501 };
2502 POINTL aPoint2[4] = { {0, 0}
2503 ,{vWidth, vHeight}
2504 ,{vXsrc, vYsrc}
2505 ,{vXsrc + vWidth, vYsrc + vHeight}
2506 };
2507 POINTL aPoint3[4] = { {vXdest, vYdest}
2508 ,{vXdest + vWidth, vYdest + vHeight}
2509 ,{vXsrc, vYsrc}
2510 ,{vXsrc + vWidth, vYsrc + vHeight}
2511 };
2512 POINTL aPoint4[4] = { {vXdest, vYdest}
2513 ,{vXdest + vWidth, vYdest + vHeight}
2514 ,{0, 0}
2515 ,{vWidth, vHeight}
2516 };
2517 ::GpiSetBitmap(hPSMask, (HBITMAP) pMask->GetMaskBitmap());
2518 ::GpiSetBitmap(hPSBuffer, (HBITMAP) hBufBitmap);
2519
2520 //
2521 // Copy dest to buffer
2522 //
2523 rc = ::GpiBitBlt( hPSBuffer
2524 ,GetHPS()
2525 ,4L
2526 ,aPoint1
2527 ,ROP_SRCCOPY
2528 ,BBO_IGNORE
2529 );
2530 if (rc == GPI_ERROR)
2531 {
2532 wxLogLastError(wxT("BitBlt"));
2533 }
2534
2535 //
2536 // Copy src to buffer using selected raster op
2537 //
2538 rc = ::GpiBitBlt( hPSBuffer
2539 ,GetHPS()
2540 ,4L
2541 ,aPoint2
2542 ,lRop
2543 ,BBO_IGNORE
2544 );
2545 if (rc == GPI_ERROR)
2546 {
2547 wxLogLastError(wxT("BitBlt"));
2548 }
2549
2550 //
2551 // Set masked area in buffer to BLACK (pixel value 0)
2552 //
2553 COLORREF vPrevBkCol = ::GpiQueryBackColor(GetHPS());
2554 COLORREF vPrevCol = ::GpiQueryColor(GetHPS());
2555
2556 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2557 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2558
2559 rc = ::GpiBitBlt( hPSBuffer
2560 ,hPSMask
2561 ,4L
2562 ,aPoint2
2563 ,ROP_SRCAND
2564 ,BBO_IGNORE
2565 );
2566 if (rc == GPI_ERROR)
2567 {
2568 wxLogLastError(wxT("BitBlt"));
2569 }
2570
2571 //
2572 // Set unmasked area in dest to BLACK
2573 //
2574 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2575 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2576 rc = ::GpiBitBlt( GetHPS()
2577 ,hPSMask
2578 ,4L
2579 ,aPoint3
2580 ,ROP_SRCAND
2581 ,BBO_IGNORE
2582 );
2583 if (rc == GPI_ERROR)
2584 {
2585 wxLogLastError(wxT("BitBlt"));
2586 }
2587
2588 //
2589 // Restore colours to original values
2590 //
2591 ::GpiSetBackColor(GetHPS(), vPrevBkCol);
2592 ::GpiSetColor(GetHPS(), vPrevCol);
2593
2594 //
2595 // OR buffer to dest
2596 //
2597 rc = ::GpiBitBlt( GetHPS()
2598 ,hPSMask
2599 ,4L
2600 ,aPoint4
2601 ,ROP_SRCPAINT
2602 ,BBO_IGNORE
2603 );
2604 if (rc == GPI_ERROR)
2605 {
2606 bSuccess = false;
2607 wxLogLastError(wxT("BitBlt"));
2608 }
2609
2610 //
2611 // Tidy up temporary DCs and bitmap
2612 //
2613 ::GpiSetBitmap(hPSMask, NULLHANDLE);
2614 ::GpiSetBitmap(hPSBuffer, NULLHANDLE);
2615#if !wxUSE_DC_CACHEING
2616 ::GpiDestroyPS(hPSMask);
2617 ::GpiDestroyPS(hPSBuffer);
2618 ::DevCloseDC(hDCMask);
2619 ::DevCloseDC(hDCBuffer);
2620 ::GpiDeleteBitmap(hBufBitmap);
2621#endif
2622 bSuccess = true;
2623 }
2624 else // no mask, just BitBlt() it
2625 {
2626 POINTL aPoint[4] = { {vXdest, vYdest}
2627 ,{vXdest + vWidth, vYdest + vHeight}
2628 ,{vXsrc, vYsrc}
2629 ,{vXsrc + vWidth, vYsrc + vHeight}
2630 };
2631
2632 bSuccess = (::GpiBitBlt( m_hPS
2633 ,pm_impl->GetHPS()
2634 ,4L
2635 ,aPoint
2636 ,lRop
2637 ,BBO_IGNORE
2638 ) != GPI_ERROR);
2639 if (!bSuccess )
2640 {
2641 wxLogLastError(wxT("BitBlt"));
2642 }
2643 }
2644 vCbnd.lColor = (LONG)vOldTextColor;
2645 ::GpiSetAttrs( m_hPS // presentation-space handle
2646 ,PRIM_CHAR // Char primitive.
2647 ,CBB_COLOR // sets color.
2648 ,0
2649 ,&vCbnd // buffer for attributes.
2650 );
2651 ::GpiSetBackColor(m_hPS, (LONG)vOldBackground);
2652 return bSuccess;
2653}
2654
2655void wxPMDCImpl::DoGetSize( int* pnWidth,
2656 int* pnHeight ) const
2657{
2658 LONG lArray[CAPS_HEIGHT+1];
2659
2660 if(::DevQueryCaps( m_hDC
2661 ,CAPS_FAMILY
2662 ,CAPS_HEIGHT+1
2663 ,lArray
2664 ))
2665 {
2666 if (pnWidth)
2667 *pnWidth = lArray[CAPS_WIDTH];
2668 if (pnHeight)
2669 *pnHeight = lArray[CAPS_HEIGHT];
2670 }
2671}; // end of wxPMDCImpl::DoGetSize(
2672
2673void wxPMDCImpl::DoGetSizeMM( int* pnWidth,
2674 int* pnHeight ) const
2675{
2676 LONG lArray[CAPS_VERTICAL_RESOLUTION+1];
2677
2678 if(::DevQueryCaps( m_hDC
2679 ,CAPS_FAMILY
2680 ,CAPS_VERTICAL_RESOLUTION+1
2681 ,lArray
2682 ))
2683 {
2684 if(pnWidth)
2685 {
2686 int nWidth = lArray[CAPS_WIDTH];
2687 int nHorzRes = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
2688 // use fp to avoid returning 0 if nHorzRes < 1000
2689 *pnWidth = (int)((nHorzRes/1000.0) * nWidth);
2690 }
2691
2692 if(pnHeight)
2693 {
2694 int nHeight = lArray[CAPS_HEIGHT];
2695 int nVertRes = lArray[CAPS_VERTICAL_RESOLUTION]; // returns pel/meter
2696 // use fp to avoid returning 0 if nVertRes < 1000
2697 *pnHeight = (int)((nVertRes/1000.0) * nHeight);
2698 }
2699 }
2700}; // end of wxPMDCImpl::DoGetSizeMM
2701
2702wxSize wxPMDCImpl::GetPPI() const
2703{
2704 LONG lArray[CAPS_VERTICAL_RESOLUTION+1];
2705 int nWidth = 0;
2706 int nHeight = 0;
2707
2708 if(::DevQueryCaps( m_hDC
2709 ,CAPS_FAMILY
2710 ,CAPS_VERTICAL_RESOLUTION+1
2711 ,lArray
2712 ))
2713 {
2714 int nPelWidth;
2715 int nPelHeight;
2716 int nHorzRes;
2717 int nVertRes;
2718
2719 nPelWidth = lArray[CAPS_WIDTH];
2720 nPelHeight = lArray[CAPS_HEIGHT];
2721 nHorzRes = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
2722 nVertRes = lArray[CAPS_VERTICAL_RESOLUTION]; // returns pel/meter
2723 nWidth = (int)((nHorzRes/39.3) * nPelWidth);
2724 nHeight = (int)((nVertRes/39.3) * nPelHeight);
2725 }
2726 wxSize ppisize(nWidth, nHeight);
2727 return ppisize;
2728} // end of wxPMDCImpl::GetPPI
2729
2730void wxPMDCImpl::SetLogicalScale( double dX, double dY )
2731{
2732 m_logicalScaleX = dX;
2733 m_logicalScaleY = dY;
2734}; // end of wxPMDCImpl::SetLogicalScale