1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/dc.cpp
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
15 #include "wx/window.h"
18 #include "wx/dialog.h"
20 #include "wx/bitmap.h"
21 #include "wx/dcmemory.h"
24 #include "wx/msgdlg.h"
25 #include "wx/dcprint.h"
26 #include "wx/statusbr.h"
27 #include "wx/module.h"
32 #include "wx/os2/dc.h"
33 #include "wx/os2/dcclient.h"
34 #include "wx/os2/private.h"
36 IMPLEMENT_ABSTRACT_CLASS(wxPMDCImpl
, wxDCImpl
)
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:
44 // Parent object height: POBJHEIGHT
45 // Desried origin: WXORIGINY
46 // Object to place's height: OBJHEIGHT
48 // To get the OS2 position from the wxWidgets one:
50 // OS2Y = POBJHEIGHT - (WXORIGINY + OBJHEIGHT)
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.
57 #define OS2Y(y, objy) ((m_vRclPaint.yTop - m_vRclPaint.yBottom) - (y + objy))
59 // ---------------------------------------------------------------------------
61 // ---------------------------------------------------------------------------
63 static const int VIEWPORT_EXTENT
= 1000;
65 static const int MM_POINTS
= 9;
66 static const int MM_METRIC
= 10;
68 // ---------------------------------------------------------------------------
70 // ---------------------------------------------------------------------------
72 // convert degrees to radians
73 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
77 , int nForegroundColour
82 vCbnd
.lColor
= nForegroundColour
;
83 ::GpiSetAttrs( hPS
// presentation-space handle
84 ,PRIM_CHAR
// Char primitive.
85 ,CBB_COLOR
// sets color.
87 ,&vCbnd
// buffer for attributes.
98 ::GpiQueryAttrs( hPS
// presentation-space handle
99 ,PRIM_CHAR
// Char primitive.
100 ,CBB_BACK_COLOR
// Background color.
101 ,&vCbnd
// buffer for attributes.
103 return vCbnd
.lBackColor
;
109 , int nBackgroundColour
115 rc
= QueryTextBkColor(hPS
);
117 vCbnd
.lBackColor
= nBackgroundColour
;
118 ::GpiSetAttrs(hPS
, // presentation-space handle
119 PRIM_CHAR
, // Char primitive.
120 CBB_BACK_COLOR
, // sets color.
122 &vCbnd
// buffer for attributes.
129 , int nBackgroundMode
132 if(nBackgroundMode
== wxTRANSPARENT
)
137 // the background of the primitive takes over whatever is underneath.
144 // ===========================================================================
146 // ===========================================================================
148 #if wxUSE_DC_CACHEING
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
156 // ---------------------------------------------------------------------------
158 // ---------------------------------------------------------------------------
160 wxList
wxPMDCImpl::m_svBitmapCache
;
161 wxList
wxPMDCImpl::m_svDCCache
;
163 wxDCCacheEntry::wxDCCacheEntry(
175 } // end of wxDCCacheEntry::wxDCCacheEntry
177 wxDCCacheEntry::wxDCCacheEntry(
182 m_hBitmap
= NULLHANDLE
;
187 } // end of wxDCCacheEntry::wxDCCacheEntry
189 wxDCCacheEntry::~wxDCCacheEntry()
192 ::GpiDeleteBitmap(m_hBitmap
);
194 ::GpiDestroyPS(m_hPS
);
195 } // end of wxDCCacheEntry::~wxDCCacheEntry
197 wxDCCacheEntry
* wxPMDCImpl::FindBitmapInCache(
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
;
209 wxDCCacheEntry
* pEntry
= (wxDCCacheEntry
*)pNode
->Data();
211 if (pEntry
->m_nDepth
== nDepth
)
213 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
215 if (pEntry
->m_nWidth
< nWidth
|| pEntry
->m_nHeight
< nHeight
)
217 ::GpiDeleteBitmap((HBITMAP
)pEntry
->m_hBitmap
);
218 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
220 vBmpHdr
.cy
= nHeight
;
222 vBmpHdr
.cBitCount
= (USHORT
)nDepth
;
224 pEntry
->m_hBitmap
= (WXHBITMAP
) ::GpiCreateBitmap( hPS
228 if (!pEntry
->m_hBitmap
)
230 wxLogLastError(wxT("CreateCompatibleBitmap"));
232 pEntry
->m_nWidth
= nWidth
;
233 pEntry
->m_nHeight
= nHeight
;
238 pNode
= pNode
->Next();
240 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
241 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
243 vBmpHdr
.cy
= nHeight
;
245 vBmpHdr
.cBitCount
= (USHORT
)nDepth
;
247 WXHBITMAP hBitmap
= (WXHBITMAP
) ::GpiCreateBitmap( hPS
253 wxLogLastError(wxT("CreateCompatibleBitmap"));
255 wxDCCacheEntry
* pEntry
= new wxDCCacheEntry( hBitmap
260 AddToBitmapCache(pEntry
);
262 } // end of FindBitmapInCache
264 wxDCCacheEntry
* wxPMDCImpl::FindDCInCache(
265 wxDCCacheEntry
* pNotThis
269 int nDepth
= 24; // we'll fix this up later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
270 wxNode
* pNode
= m_svDCCache
.First();
274 wxDCCacheEntry
* pEntry
= (wxDCCacheEntry
*)pNode
->Data();
277 // Don't return the same one as we already have
279 if (!pNotThis
|| (pNotThis
!= pEntry
))
281 if (pEntry
->m_nDepth
== nDepth
)
286 pNode
= pNode
->Next();
288 wxDCCacheEntry
* pEntry
= new wxDCCacheEntry( hPS
291 AddToDCCache(pEntry
);
293 } // end of wxPMDCImpl::FindDCInCache
295 void wxPMDCImpl::AddToBitmapCache(
296 wxDCCacheEntry
* pEntry
299 m_svBitmapCache
.Append(pEntry
);
300 } // end of wxPMDCImpl::AddToBitmapCache
302 void wxPMDCImpl::AddToDCCache(
303 wxDCCacheEntry
* pEntry
306 m_svDCCache
.Append(pEntry
);
307 } // end of wxPMDCImpl::AddToDCCache
309 void wxPMDCImpl::ClearCache()
311 m_svBitmapCache
.DeleteContents(true);
312 m_svBitmapCache
.Clear();
313 m_svBitmapCache
.DeleteContents(false);
314 m_svDCCache
.DeleteContents(true);
316 m_svDCCache
.DeleteContents(false);
317 } // end of wxPMDCImpl::ClearCache
319 // Clean up cache at app exit
320 class wxDCModule
: public wxModule
323 virtual bool OnInit() { return true; }
324 virtual void OnExit() { wxPMDCImpl::ClearCache(); }
327 DECLARE_DYNAMIC_CLASS(wxDCModule
)
328 }; // end of CLASS wxDCModule
330 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
332 #endif // ndef for wxUSE_DC_CACHEING
334 // ---------------------------------------------------------------------------
336 // ---------------------------------------------------------------------------
338 wxPMDCImpl::wxPMDCImpl( wxDC
*owner
, WXHDC hDC
) :
343 } // end of wxPMDCImpl::wxPMDCImpl
345 wxPMDCImpl::~wxPMDCImpl()
349 SelectOldObjects(m_hDC
);
351 // if we own the HDC, we delete it, otherwise we just release it
357 ::GpiAssociate(m_hPS
, NULLHANDLE
);
358 ::GpiDestroyPS(m_hPS
);
361 ::DevCloseDC((HDC
)m_hDC
);
366 // Just Dissacociate, not destroy if we don't own the DC
370 ::GpiAssociate(m_hPS
, NULLHANDLE
);
374 } // end of wxPMDCImpl::~wxDC
376 // This will select current objects out of the DC,
377 // which is what you have to do before deleting the
379 void wxPMDCImpl::SelectOldObjects(
387 ::GpiSetBitmap(hPS
, (HBITMAP
) m_hOldBitmap
);
388 if (m_vSelectedBitmap
.IsOk())
390 m_vSelectedBitmap
.SetSelectedInto(NULL
);
395 // OS/2 has no other native GDI objects to set in a PS/DC like windows
403 m_brush
= wxNullBrush
;
405 m_palette
= wxNullPalette
;
407 m_backgroundBrush
= wxNullBrush
;
408 m_vSelectedBitmap
= wxNullBitmap
;
409 } // end of wxPMDCImpl::SelectOldObjects
411 // ---------------------------------------------------------------------------
413 // ---------------------------------------------------------------------------
415 #define DO_SET_CLIPPING_BOX() \
419 ::GpiQueryClipBox(m_hPS, &rect); \
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); \
427 void wxPMDCImpl::DoSetClippingRegion(
436 vY
= OS2Y(vY
,vHeight
);
439 vRect
.yTop
= vY
+ vHeight
;
440 vRect
.xRight
= vX
+ vWidth
;
442 ::GpiIntersectClipRectangle(m_hPS
, &vRect
);
443 DO_SET_CLIPPING_BOX()
444 } // end of wxPMDCImpl::DoSetClippingRegion
446 void wxPMDCImpl::DoSetDeviceClippingRegion(
447 const wxRegion
& rRegion
450 wxCHECK_RET(rRegion
.GetHRGN(), wxT("invalid clipping region"));
454 ::GpiSetClipRegion( m_hPS
455 ,(HRGN
)rRegion
.GetHRGN()
458 DO_SET_CLIPPING_BOX()
459 } // end of wxPMDCImpl::DoSetDeviceClippingRegion
461 void wxPMDCImpl::DestroyClippingRegion()
463 if (m_clipping
&& m_hPS
)
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);
477 HRGN hRgn
= ::GpiCreateRegion(m_hPS
, 1, &vRect
);
479 ::GpiSetClipRegion(m_hPS
, hRgn
, &hRgnOld
);
482 } // end of wxPMDCImpl::DestroyClippingRegion
484 // ---------------------------------------------------------------------------
485 // query capabilities
486 // ---------------------------------------------------------------------------
488 bool wxPMDCImpl::CanDrawBitmap() const
493 bool wxPMDCImpl::CanGetTextExtent() const
495 LONG lTechnology
= 0L;
497 ::DevQueryCaps(GetHDC(), CAPS_TECHNOLOGY
, 1L, &lTechnology
);
498 return (lTechnology
== CAPS_TECH_RASTER_DISPLAY
) || (lTechnology
== CAPS_TECH_RASTER_PRINTER
);
499 } // end of wxPMDCImpl::CanGetTextExtent
501 int wxPMDCImpl::GetDepth() const
503 LONG lCapsColorBitcount
;
504 int nBitsPerPixel
= 0;
506 if(::DevQueryCaps( GetHDC()
512 nBitsPerPixel
= (int)lCapsColorBitcount
;
514 return nBitsPerPixel
;
515 } // end of wxPMDCImpl::GetDepth
517 // ---------------------------------------------------------------------------
519 // ---------------------------------------------------------------------------
521 void wxPMDCImpl::Clear()
524 // If this is a canvas DC then just fill with the background color
525 // Otherwise purge the whole thing
531 ::GpiQueryClipBox(m_hPS
, &vRect
);
532 ::WinFillRect(m_hPS
, &vRect
, ::GpiQueryBackColor(m_hPS
));
536 } // end of wxPMDCImpl::Clear
538 bool wxPMDCImpl::DoFloodFill(
541 , const wxColour
& rCol
542 , wxFloodFillStyle nStyle
549 bool bSuccess
= false;
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
;
559 if ((lHits
= ::GpiFloodFill(m_hPS
, lOptions
, lColor
)) != GPI_ERROR
)
563 } // end of wxPMDCImpl::DoFloodFill
565 bool wxPMDCImpl::DoGetPixel(
575 vPoint
.y
= OS2Y(vY
,0);
576 lColor
= ::GpiQueryPel(m_hPS
, &vPoint
);
579 // return the color of the pixel
582 pCol
->Set( GetRValue(lColor
)
587 } // end of wxPMDCImpl::DoGetPixel
589 void wxPMDCImpl::DoCrossHair(
596 wxCoord vX1
= vX
- VIEWPORT_EXTENT
;
597 wxCoord vY1
= vY
- VIEWPORT_EXTENT
;
598 wxCoord vX2
= vX
+ VIEWPORT_EXTENT
;
599 wxCoord vY2
= vY
+ VIEWPORT_EXTENT
;
608 ::GpiMove(m_hPS
, &vPoint
[0]);
609 ::GpiLine(m_hPS
, &vPoint
[1]);
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
623 void wxPMDCImpl::DoDrawLine(
631 COLORREF vColor
= 0x00ffffff;
634 // Might be a memory DC with no Paint rect.
636 if (!(m_vRclPaint
.yTop
== 0 &&
637 m_vRclPaint
.yBottom
== 0 &&
638 m_vRclPaint
.xRight
== 0 &&
639 m_vRclPaint
.xLeft
== 0))
646 if (m_vSelectedBitmap
.IsOk())
648 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
649 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
660 vColor
= m_pen
.GetColour().GetPixel();
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
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 //////////////////////////////////////////////////////////////////////////////
675 void wxPMDCImpl::DoDrawArc(
685 POINTL vPtlArc
[2]; // Structure for current position
692 ARCPARAMS vArcp
; // Structure for arc parameters
694 if((vX1
== vXc
&& vY1
== vXc
) || (vX2
== vXc
&& vY2
== vXc
))
695 return; // Draw point ??
696 dRadius
= 0.5 * ( hypot( (double)(vY1
- vYc
)
699 hypot( (double)(vY2
- vYc
)
704 dAngl1
= atan2( (double)(vY1
- vYc
)
707 dAngl2
= atan2( (double)(vY2
- vYc
)
714 // GpiPointArc can't draw full arc
716 if(dAngl2
== dAngl1
|| (vX1
== vX2
&& vY1
== vY2
) )
721 dAnglmid
= (dAngl1
+ dAngl2
)/2. + M_PI
;
722 vXm
= (wxCoord
)(vXc
+ dRadius
* cos(dAnglmid
));
723 vYm
= (wxCoord
)(vYc
+ dRadius
* sin(dAnglmid
));
738 dAnglmid
= (dAngl1
+ dAngl2
)/2.;
739 vXm
= (wxCoord
)(vXc
+ dRadius
* cos(dAnglmid
));
740 vYm
= (wxCoord
)(vYc
+ dRadius
* sin(dAnglmid
));
743 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
749 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
751 vPtlPos
.x
= vX1
; // Loads x-coordinate
752 vPtlPos
.y
= vY1
; // Loads y-coordinate
753 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
758 ::GpiPointArc(m_hPS
, vPtlArc
); // Draws the arc
759 CalcBoundingBox( (wxCoord
)(vXc
- dRadius
)
760 ,(wxCoord
)(vYc
- dRadius
)
762 CalcBoundingBox( (wxCoord
)(vXc
+ dRadius
)
763 ,(wxCoord
)(vYc
+ dRadius
)
765 } // end of wxPMDCImpl::DoDrawArc
767 void wxPMDCImpl::DoDrawCheckMark(
776 vY1
= OS2Y(vY1
,vHeight
);
780 vPoint
[1].x
= vX1
+ vWidth
;
781 vPoint
[1].y
= vY1
+ vHeight
;
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
790 if(vWidth
> 4 && vHeight
> 4)
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]);
799 vPoint
[0].x
= vPoint
[1].x
;
801 ::GpiMove(m_hPS
, &vPoint
[0]);
802 ::GpiLine(m_hPS
, &vPoint
[1]);
808 wxCoord vX2
= vX1
+ vWidth
;
809 wxCoord vY2
= vY1
+ vHeight
;
814 } // end of wxPMDCImpl::DoDrawCheckMark
816 void wxPMDCImpl::DoDrawPoint(
822 COLORREF vColor
= 0x00ffffff;
826 vColor
= m_pen
.GetColour().GetPixel();
828 ::GpiSetColor(m_hPS
, vColor
);
830 vPoint
.y
= OS2Y(vY
,0);
831 ::GpiSetPel(m_hPS
, &vPoint
);
835 } // end of wxPMDCImpl::DoDrawPoint
837 void wxPMDCImpl::DoDrawPolygon( int n
,
838 const wxPoint vPoints
[],
841 wxPolygonFillMode nFillStyle
)
843 ULONG ulCount
= 1; // Number of polygons.
844 POLYGON vPlgn
; // polygon.
845 ULONG flOptions
= 0L; // Drawing options.
847 //////////////////////////////////////////////////////////////////////////////
848 // This contains fields of option bits... to draw boundary lines as well as
849 // the area interior.
851 // Drawing boundary lines:
852 // POLYGON_NOBOUNDARY Does not draw boundary lines.
853 // POLYGON_BOUNDARY Draws boundary lines (the default).
855 // Construction of the area interior:
856 // POLYGON_ALTERNATE Constructs interior in alternate mode
858 // POLYGON_WINDING Constructs interior in winding mode.
859 //////////////////////////////////////////////////////////////////////////////
861 ULONG flModel
= POLYGON_INCL
; // Drawing model.
863 //////////////////////////////////////////////////////////////////////////////
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 //////////////////////////////////////////////////////////////////////////////
870 LONG lHits
= 0L; // Correlation/error indicator.
872 int nIsTRANSPARENT
= 0;
873 LONG lBorderColor
= 0L;
876 lBorderColor
= m_pen
.GetColour().GetPixel();
877 lColor
= m_brush
.GetColour().GetPixel();
878 if(m_brush
.GetStyle() == wxTRANSPARENT
)
882 vPlgn
.aPointl
= (POINTL
*) calloc( n
+ 1
884 ); // well, new will call malloc
886 for(i
= 0; i
< n
; i
++)
888 vPlgn
.aPointl
[i
].x
= vPoints
[i
].x
+vXoffset
;
889 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
+vYoffset
,0);
891 flOptions
= POLYGON_BOUNDARY
;
892 if(nFillStyle
== wxWINDING_RULE
)
893 flOptions
|= POLYGON_WINDING
;
895 flOptions
|= POLYGON_ALTERNATE
;
897 ::GpiSetColor(m_hPS
, lBorderColor
);
898 ::GpiMove(m_hPS
, &vPlgn
.aPointl
[0]);
899 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
901 } // end of wxPMDCImpl::DoDrawPolygon
903 void wxPMDCImpl::DoDrawLines(
905 , const wxPoint vPoints
[]
912 if (vXoffset
!= 0L || vYoffset
!= 0L)
916 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
917 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
918 ::GpiMove(m_hPS
, &vPoint
);
920 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
922 ::GpiSetColor(m_hPS
, lBorderColor
);
923 for(i
= 1; i
< n
; i
++)
925 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
926 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
927 ::GpiLine(m_hPS
, &vPoint
);
934 CalcBoundingBox( vPoints
[0].x
937 vPoint
.x
= vPoints
[0].x
;
938 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
939 ::GpiMove(m_hPS
, &vPoint
);
941 for (i
= 0; i
< n
; i
++)
943 CalcBoundingBox( vPoints
[i
].x
946 vPoint
.x
= vPoints
[i
].x
;
947 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
948 ::GpiLine(m_hPS
, &vPoint
);
951 } // end of wxPMDCImpl::DoDrawLines
953 void wxPMDCImpl::DoDrawRectangle(
964 int nIsTRANSPARENT
= 0;
967 // Might be a memory DC with no Paint rect.
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
);
976 if (m_vSelectedBitmap
.IsOk())
978 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
979 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
980 vY
= OS2Y(vY
,vHeight
);
984 wxCoord vX2
= vX
+ vWidth
;
985 wxCoord vY2
= vY
+ vHeight
;
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
)
996 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
998 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
999 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1000 lControl
= DRO_OUTLINE
;
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
1012 lControl
= DRO_OUTLINE
;
1013 ::GpiSetColor( m_hPS
1022 lControl
= DRO_FILL
;
1023 ::GpiSetColor( m_hPS
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]);
1038 CalcBoundingBox(vX
, vY
);
1039 CalcBoundingBox(vX2
, vY2
);
1040 } // end of wxPMDCImpl::DoDrawRectangle
1042 void wxPMDCImpl::DoDrawRoundedRectangle(
1054 int nIsTRANSPARENT
= 0;
1057 // Might be a memory DC with no Paint rect.
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
);
1066 if (m_vSelectedBitmap
.IsOk())
1068 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1069 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1070 vY
= OS2Y(vY
,vHeight
);
1074 wxCoord vX2
= (vX
+ vWidth
);
1075 wxCoord vY2
= (vY
+ vHeight
);
1079 vPoint
[1].x
= vX
+ vWidth
- 1;
1080 vPoint
[1].y
= vY
+ vHeight
- 1;
1081 ::GpiMove(m_hPS
, &vPoint
[0]);
1083 lColor
= m_brush
.GetColour().GetPixel();
1084 lBorderColor
= m_pen
.GetColour().GetPixel();
1085 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1086 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1088 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1090 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1091 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1092 lControl
= DRO_OUTLINE
;
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
1104 lControl
= DRO_OUTLINE
;
1105 ::GpiSetColor( m_hPS
1114 lControl
= DRO_FILL
;
1115 ::GpiSetColor( m_hPS
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]);
1131 CalcBoundingBox(vX
, vY
);
1132 CalcBoundingBox(vX2
, vY2
);
1133 } // end of wxPMDCImpl::DoDrawRoundedRectangle
1135 // Draw Ellipse within box (x,y) - (x+width, y+height)
1136 void wxPMDCImpl::DoDrawEllipse(
1143 POINTL vPtlPos
; // Structure for current position
1144 FIXED vFxMult
; // Multiplier for ellipse
1145 ARCPARAMS vArcp
; // Structure for arc parameters
1147 vY
= OS2Y(vY
,vHeight
);
1150 vArcp
.lQ
= vHeight
/2;
1151 vArcp
.lP
= vWidth
/2;
1153 ::GpiSetArcParams( m_hPS
1155 ); // Sets parameters to default
1156 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
1157 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1160 ); // Sets current position
1161 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
1164 // DRO_FILL, DRO_OTLINEFILL - where to get
1169 ); // Draws full arc with center at current position
1171 wxCoord vX2
= (vX
+ vWidth
);
1172 wxCoord vY2
= (vY
+ vHeight
);
1174 CalcBoundingBox(vX
, vY
);
1175 CalcBoundingBox(vX2
, vY2
);
1176 } // end of wxPMDCImpl::DoDrawEllipse
1178 void wxPMDCImpl::DoDrawEllipticArc(
1187 POINTL vPtlPos
; // Structure for current position
1188 FIXED vFxMult
; // Multiplier for ellipse
1189 ARCPARAMS vArcp
; // Structure for arc parameters
1191 FIXED vFSweepa
; // Start angle, sweep angle
1195 vY
= OS2Y(vY
,vHeight
);
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) );
1203 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1206 vArcp
.lQ
= vHeight
/2;
1207 vArcp
.lP
= vWidth
/2;
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
1215 // May be not to the center ?
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
1222 // DRO_FILL, DRO_OTLINEFILL - where to get
1224 ::GpiPartialArc( m_hPS
1230 wxCoord vX2
= (vX
+ vWidth
);
1231 wxCoord vY2
= (vY
+ vHeight
);
1233 CalcBoundingBox(vX
, vY
);
1234 CalcBoundingBox(vX2
, vY2
);
1235 } // end of wxPMDCImpl::DoDrawEllipticArc
1237 void wxPMDCImpl::DoDrawIcon(
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
1250 DoDrawBitmap(rIcon
.GetXpmSrc(), vX
, vY
, true);
1254 wxBitmap
vBitmap(rIcon
);
1256 DoDrawBitmap(vBitmap
, vX
, vY
, false);
1258 CalcBoundingBox(vX
, vY
);
1259 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
1260 } // end of wxPMDCImpl::DoDrawIcon
1262 void wxPMDCImpl::DoDrawBitmap(
1263 const wxBitmap
& rBmp
1269 #if wxUSE_PRINTING_ARCHITECTURE
1270 if (!IsKindOf(CLASSINFO(wxPrinterDC
)))
1273 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
1274 HBITMAP hBitmapOld
= NULLHANDLE
;
1277 vY
= OS2Y(vY
,rBmp
.GetHeight());
1280 vPoint
[0].y
= vY
+ rBmp
.GetHeight();
1281 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1285 vPoint
[3].x
= rBmp
.GetWidth();
1286 vPoint
[3].y
= rBmp
.GetHeight();
1289 wxMask
* pMask
= rBmp
.GetMask();
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
1301 // 4) Create a new bitmap and set its bits to the above result
1302 // 5) Blit this to the screen PS
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
1317 // The usual Memory context creation stuff
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
);
1325 // The usual bitmap header stuff
1327 BITMAPINFOHEADER2 vHeader
;
1330 memset(&vHeader
, '\0', 16);
1333 memset(&vInfo
, '\0', 16);
1335 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1336 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1338 vInfo
.cBitCount
= 24; // Set to desired count going in
1341 // Create the buffers for data....all wxBitmaps are 24 bit internally
1343 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1344 int nSizeDWORD
= sizeof(DWORD
);
1345 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
1353 // Need to get a background color for mask blitting
1355 if (IsKindOf(CLASSINFO(wxWindowDCImpl
)))
1357 wxWindowDCImpl
* pWindowDC
= wxDynamicCast(this, wxWindowDCImpl
);
1359 lColor
= pWindowDC
->m_pCanvas
->GetBackgroundColour().GetPixel();
1361 else if (GetBrush().IsOk())
1362 lColor
= GetBrush().GetColour().GetPixel();
1364 lColor
= m_textBackgroundColour
.GetPixel();
1367 // Bitmap must be in a double-word aligned address so we may
1368 // have some padding to worry about
1370 if (nLineBoundary
> 0)
1372 nPadding
= nSizeDWORD
- nLineBoundary
;
1373 nBytesPerLine
+= nPadding
;
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()));
1381 // Extract the bitmap and mask data
1383 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1385 vError
= ::WinGetLastError(vHabmain
);
1386 sError
= wxPMErrorToStr(vError
);
1388 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
1389 vInfo
.cBitCount
= 24;
1390 if ((lScans
= ::GpiQueryBitmapBits( hPS
1392 ,(LONG
)rBmp
.GetHeight()
1397 vError
= ::WinGetLastError(vHabmain
);
1398 sError
= wxPMErrorToStr(vError
);
1400 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
1402 vError
= ::WinGetLastError(vHabmain
);
1403 sError
= wxPMErrorToStr(vError
);
1405 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
1406 vInfo
.cBitCount
= 24;
1407 if ((lScans
= ::GpiQueryBitmapBits( hPS
1409 ,(LONG
)rBmp
.GetHeight()
1414 vError
= ::WinGetLastError(vHabmain
);
1415 sError
= wxPMErrorToStr(vError
);
1417 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
1419 vError
= ::WinGetLastError(vHabmain
);
1420 sError
= wxPMErrorToStr(vError
);
1424 // Now set the bytes(bits) according to the mask values
1425 // 3 bytes per pel...must handle one at a time
1428 pucDataMask
= pucBitsMask
;
1431 // 16 bit kludge really only kinda works. The mask gets applied
1432 // where needed but the original bitmap bits are dorked sometimes
1434 bool bpp16
= (wxDisplayDepth() == 16);
1436 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1438 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1441 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1443 else if (*pucDataMask
== 0xFF) // leave bitmap byte alone
1447 *pucData
= ((unsigned char)(lColor
>> 16));
1451 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1453 else if (*(pucDataMask
+ 1) == 0xFF) // leave bitmap byte alone
1457 *pucData
= ((unsigned char)(lColor
>> 8));
1462 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1464 else if (*(pucDataMask
+ 2) == 0xFF) // leave bitmap byte alone
1468 *pucData
= ((unsigned char)lColor
);
1473 for (j
= 0; j
< nPadding
; j
++)
1480 // Create a new bitmap
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
1493 vError
= ::WinGetLastError(vHabmain
);
1494 sError
= wxPMErrorToStr(vError
);
1498 // Now blit it to the screen PS
1500 if ((lHits
= ::GpiWCBitBlt( (HPS
)GetHPS()
1508 vError
= ::WinGetLastError(vHabmain
);
1509 sError
= wxPMErrorToStr(vError
);
1517 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1518 ::GpiDeleteBitmap(hNewBitmap
);
1519 ::GpiDestroyPS(hPS
);
1525 ULONG lOldForeGround
= ::GpiQueryColor((HPS
)GetHPS());
1526 ULONG lOldBackGround
= ::GpiQueryBackColor((HPS
)GetHPS());
1528 if (m_textForegroundColour
.IsOk())
1530 ::GpiSetColor( (HPS
)GetHPS()
1531 ,m_textForegroundColour
.GetPixel()
1534 if (m_textBackgroundColour
.IsOk())
1536 ::GpiSetBackColor( (HPS
)GetHPS()
1537 ,m_textBackgroundColour
.GetPixel()
1541 // Need to alter bits in a mono bitmap to match the new
1542 // background-foreground if it is different.
1544 if (rBmp
.IsMono() &&
1545 ((m_textForegroundColour
.GetPixel() != lOldForeGround
) ||
1546 (m_textBackgroundColour
.GetPixel() != lOldBackGround
)))
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
);
1553 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1555 LONG lForeGround
= m_textForegroundColour
.GetPixel();
1556 LONG lBackGround
= m_textBackgroundColour
.GetPixel();
1558 HBITMAP hOldBitmap
= NULLHANDLE
;
1564 memset(&vInfo
, '\0', 16);
1566 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1567 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1569 vInfo
.cBitCount
= 24;
1571 unsigned char* pucBits
; // buffer that will contain the bitmap data
1572 unsigned char* pucData
; // pointer to use to traverse bitmap data
1574 pucBits
= new unsigned char[nBytesPerLine
* rBmp
.GetHeight()];
1575 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1577 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1579 vError
= ::WinGetLastError(vHabmain
);
1580 sError
= wxPMErrorToStr(vError
);
1584 if ((lScans
= ::GpiQueryBitmapBits( hPS
1586 ,(LONG
)rBmp
.GetHeight()
1591 vError
= ::WinGetLastError(vHabmain
);
1592 sError
= wxPMErrorToStr(vError
);
1596 unsigned char cOldRedFore
= (unsigned char)(lOldForeGround
>> 16);
1597 unsigned char cOldGreenFore
= (unsigned char)(lOldForeGround
>> 8);
1598 unsigned char cOldBlueFore
= (unsigned char)lOldForeGround
;
1600 unsigned char cRedFore
= (unsigned char)(lForeGround
>> 16);
1601 unsigned char cGreenFore
= (unsigned char)(lForeGround
>> 8);
1602 unsigned char cBlueFore
= (unsigned char)lForeGround
;
1604 unsigned char cRedBack
= (unsigned char)(lBackGround
>> 16);
1605 unsigned char cGreenBack
= (unsigned char)(lBackGround
>> 8);
1606 unsigned char cBlueBack
= (unsigned char)lBackGround
;
1609 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1611 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1613 unsigned char cBmpRed
= *pucData
;
1614 unsigned char cBmpGreen
= *(pucData
+ 1);
1615 unsigned char cBmpBlue
= *(pucData
+ 2);
1617 if ((cBmpRed
== cOldRedFore
) &&
1618 (cBmpGreen
== cOldGreenFore
) &&
1619 (cBmpBlue
== cOldBlueFore
))
1621 *pucData
= cBlueFore
;
1623 *pucData
= cGreenFore
;
1625 *pucData
= cRedFore
;
1630 *pucData
= cBlueBack
;
1632 *pucData
= cGreenBack
;
1634 *pucData
= cRedBack
;
1639 if ((lScans
= ::GpiSetBitmapBits( hPS
1641 ,(LONG
)rBmp
.GetHeight()
1646 vError
= ::WinGetLastError(vHabmain
);
1647 sError
= wxPMErrorToStr(vError
);
1651 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1652 ::GpiDestroyPS(hPS
);
1655 ::GpiWCBitBlt( (HPS
)GetHPS()
1662 ::GpiSetBitmap((HPS
)GetHPS(), hBitmapOld
);
1663 ::GpiSetColor((HPS
)GetHPS(), lOldForeGround
);
1664 ::GpiSetBackColor((HPS
)GetHPS(), lOldBackGround
);
1667 } // end of wxPMDCImpl::DoDrawBitmap
1669 void wxPMDCImpl::DoDrawText(
1670 const wxString
& rsText
1683 CalcBoundingBox(vX
, vY
);
1684 GetOwner()->GetTextExtent(rsText
, &vWidth
, &vHeight
);
1685 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1686 } // end of wxPMDCImpl::DoDrawText
1688 void wxPMDCImpl::DrawAnyText( const wxString
& rsText
,
1692 int nOldBackground
= 0;
1699 // prepare for drawing the text
1703 // Set text color attributes
1705 if (m_textForegroundColour
.IsOk())
1708 ,(int)m_textForegroundColour
.GetPixel()
1712 if (m_textBackgroundColour
.IsOk())
1714 nOldBackground
= SetTextBkColor( m_hPS
1715 ,(int)m_textBackgroundColour
.GetPixel()
1721 GetOwner()->GetTextExtent( rsText
1726 if (!(m_vRclPaint
.yTop
== 0 &&
1727 m_vRclPaint
.yBottom
== 0 &&
1728 m_vRclPaint
.xRight
== 0 &&
1729 m_vRclPaint
.xLeft
== 0))
1731 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1735 if (m_vSelectedBitmap
.IsOk())
1737 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1738 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1739 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1745 ::GpiMove(m_hPS
, &vPtlStart
);
1746 lHits
= ::GpiCharString( m_hPS
1750 if (lHits
!= GPI_OK
)
1752 wxLogLastError(wxT("TextOut"));
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)
1760 if (m_textBackgroundColour
.IsOk())
1761 SetTextBkColor( m_hPS
1769 void wxPMDCImpl::DoDrawRotatedText(
1770 const wxString
& rsText
1788 DoDrawText(text, x, y);
1793 wxFillLogFont(&lf, &m_font);
1795 // GDI wants the angle in tenth of degree
1796 long angle10 = (long)(angle * 10);
1797 lf.lfEscapement = angle10;
1798 lf. lfOrientation = angle10;
1800 HFONT hfont = ::CreateFontIndirect(&lf);
1803 wxLogLastError("CreateFont");
1807 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1809 DrawAnyText(text, x, y);
1811 (void)::SelectObject(GetHdc(), hfontOld);
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/...)
1818 GetTextExtent(text, &w, &h);
1820 double rad = DegToRad(angle);
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));
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));
1836 // ---------------------------------------------------------------------------
1838 // ---------------------------------------------------------------------------
1840 void wxPMDCImpl::DoSelectPalette( bool WXUNUSED(bRealize
) )
1843 // Set the old object temporarily, in case the assignment deletes an object
1844 // that's not yet selected out.
1851 if (m_palette
.IsOk())
1855 hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1857 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1859 } // end of wxPMDCImpl::DoSelectPalette
1861 void wxPMDCImpl::InitializePalette()
1863 if (wxDisplayDepth() <= 8 )
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
1869 wxWindow
* pWin
= m_pCanvas
->GetAncestorWithCustomPalette();
1871 m_hasCustomPalette
= pWin
&& pWin
->HasCustomPalette();
1872 if (m_hasCustomPalette
)
1874 m_palette
= pWin
->GetPalette();
1877 // turn on PM translation for this palette
1882 } // end of wxPMDCImpl::InitializePalette
1884 void wxPMDCImpl::SetPalette(
1885 const wxPalette
& rPalette
1892 m_palette
= rPalette
;
1893 if (!rPalette
.IsOk())
1900 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1902 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1903 } // end of wxPMDCImpl::SetPalette
1905 void wxPMDCImpl::SetFont(
1910 // Set the old object temporarily, in case the assignment deletes an object
1911 // that's not yet selected out.
1923 m_font
.SetPS(m_hPS
); // this will realize the font
1927 HFONT hFont
= m_font
.GetResourceHandle();
1928 if (hFont
== (HFONT
) NULL
)
1930 wxLogDebug(wxT("::SelectObject failed in wxPMDCImpl::SetFont."));
1933 m_hOldFont
= (WXHFONT
) hFont
;
1935 } // end of wxPMDCImpl::SetFont
1937 void wxPMDCImpl::SetPen(
1955 m_pen
.SetPS((HPS
)m_hOldPen
);
1962 if (m_pen
.GetResourceHandle())
1966 m_hOldPen
= m_pen
.GetPS();
1968 ::GpiSetColor(m_hPS
, m_pen
.GetColour().GetPixel());
1972 void wxPMDCImpl::SetBrush(
1973 const wxBrush
& rBrush
1979 if (!m_brush
.IsOk())
1980 if (m_brush
== rBrush
)
1982 if (!m_brush
.IsOk())
1986 if (!m_brush
.IsOk())
1990 m_brush
.SetPS((HPS
)m_hOldBrush
);
1997 if (m_brush
.GetResourceHandle())
1999 m_brush
.SetPS(m_hPS
);
2001 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
2004 } // end of wxPMDCImpl::SetBrush
2006 void wxPMDCImpl::SetBackground(const wxBrush
& rBrush
)
2008 m_backgroundBrush
= rBrush
;
2010 if (m_backgroundBrush
.IsOk())
2012 (void)::GpiSetBackColor((HPS
)m_hPS
, m_backgroundBrush
.GetColour().GetPixel());
2014 } // end of wxPMDCImpl::SetBackground
2016 void wxPMDCImpl::SetBackgroundMode(int nMode
)
2018 m_backgroundMode
= nMode
;
2019 } // end of wxPMDCImpl::SetBackgroundMode
2021 void wxPMDCImpl::SetLogicalFunction(wxRasterOperationMode nFunction
)
2023 m_logicalFunction
= nFunction
;
2024 SetRop((WXHDC
)m_hDC
);
2025 } // wxPMDCImpl::SetLogicalFunction
2027 void wxPMDCImpl::SetRop(WXHDC hDC
)
2029 if (!hDC
|| m_logicalFunction
< 0)
2033 switch (m_logicalFunction
)
2044 lCRop
= FM_MERGESRCNOT
;
2048 lCRop
= FM_NOTMASKSRC
;
2060 lCRop
= FM_MERGENOTSRC
;
2064 lCRop
= FM_MERGESRCNOT
;
2076 lCRop
= FM_SUBTRACT
;
2083 lCRop
= FM_OVERPAINT
;
2086 ::GpiSetMix((HPS
)hDC
, lCRop
);
2087 } // end of wxPMDCImpl::SetRop
2089 bool wxPMDCImpl::StartDoc( const wxString
& WXUNUSED(rsMessage
) )
2091 // We might be previewing, so return true to let it continue.
2093 } // end of wxPMDCImpl::StartDoc
2095 void wxPMDCImpl::EndDoc()
2097 } // end of wxPMDCImpl::EndDoc
2099 void wxPMDCImpl::StartPage()
2101 } // end of wxPMDCImpl::StartPage
2103 void wxPMDCImpl::EndPage()
2105 } // end of wxPMDCImpl::EndPage
2107 // ---------------------------------------------------------------------------
2109 // ---------------------------------------------------------------------------
2111 wxCoord
wxPMDCImpl::GetCharHeight() const
2113 FONTMETRICS vFM
; // metrics structure
2115 ::GpiQueryFontMetrics( m_hPS
2116 ,sizeof(FONTMETRICS
)
2119 return YDEV2LOGREL(vFM
.lXHeight
);
2122 wxCoord
wxPMDCImpl::GetCharWidth() const
2124 FONTMETRICS vFM
; // metrics structure
2126 ::GpiQueryFontMetrics( m_hPS
2127 ,sizeof(FONTMETRICS
)
2130 return XDEV2LOGREL(vFM
.lAveCharWidth
);
2133 void wxPMDCImpl::DoGetTextExtent(
2134 const wxString
& rsString
2137 , wxCoord
* pvDescent
2138 , wxCoord
* pvExternalLeading
2139 , const wxFont
* pTheFont
2142 POINTL avPoint
[TXTBOX_COUNT
];
2147 FONTMETRICS vFM
; // metrics structure
2149 ERRORID vErrorCode
; // last error id code
2150 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
2152 wxChar zMsg
[128]; // DEBUG
2156 pFontToUse
= (wxFont
*)&m_font
;
2157 l
= rsString
.length();
2160 // In world coordinates.
2164 (void)wxMessageBox( wxT("wxWidgets core library")
2165 ,"Using uninitialized DC for measuring text!\n"
2170 bRc
= ::GpiQueryTextBox( m_hPS
2172 ,rsString
.char_str()
2173 ,TXTBOX_COUNT
// return maximum information
2174 ,avPoint
// array of coordinates points
2178 vErrorCode
= ::WinGetLastError(wxGetInstance());
2179 sError
= wxPMErrorToStr(vErrorCode
);
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")
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
++)
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
;
2199 ::GpiQueryFontMetrics( m_hPS
2200 ,sizeof(FONTMETRICS
)
2205 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
2207 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
2209 *pvDescent
= vFM
.lMaxDescender
;
2210 if (pvExternalLeading
)
2211 *pvExternalLeading
= vFM
.lExternalLeading
;
2214 void wxPMDCImpl::SetMapMode(
2218 int nPixelWidth
= 0;
2219 int nPixelHeight
= 0;
2222 LONG lArray
[CAPS_VERTICAL_RESOLUTION
+1];
2224 m_mappingMode
= nMode
;
2226 if(::DevQueryCaps( m_hDC
2227 ,CAPS_FAMILY
// id of first item
2228 ,CAPS_VERTICAL_RESOLUTION
+1 // number of items wanted
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
;
2242 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
2247 double dMm2pixelsX
= nPixelWidth
/(double)nMmWidth
;
2248 double dMm2pixelsY
= nPixelHeight
/(double)nMmHeight
;
2253 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
2254 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
2258 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
2259 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
2263 m_logicalScaleX
= dMm2pixelsX
;
2264 m_logicalScaleY
= dMm2pixelsY
;
2268 m_logicalScaleX
= (dMm2pixelsX
/10.0);
2269 m_logicalScaleY
= (dMm2pixelsY
/10.0);
2274 m_logicalScaleX
= 1.0;
2275 m_logicalScaleY
= 1.0;
2282 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
2283 if (!ulOptions
& PU_ARBITRARY
)
2285 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
2286 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
2288 ComputeScaleAndOrigin();
2290 }; // end of wxPMDCImpl::SetMapMode
2292 void wxPMDCImpl::SetUserScale( double dX
,
2298 SetMapMode(m_mappingMode
);
2299 } // end of wxPMDCImpl::SetUserScale
2301 void wxPMDCImpl::SetAxisOrientation( bool bXLeftRight
,
2304 m_signX
= bXLeftRight
? 1 : -1;
2305 m_signY
= bYBottomUp
? -1 : 1;
2307 SetMapMode(m_mappingMode
);
2308 } // end of wxPMDCImpl::SetAxisOrientation
2310 void wxPMDCImpl::SetLogicalOrigin(
2317 ::GpiQueryPageViewport( m_hPS
2324 ::GpiSetPageViewport( m_hPS
2327 }; // end of wxPMDCImpl::SetLogicalOrigin
2329 void wxPMDCImpl::SetDeviceOrigin(
2336 m_deviceOriginX
= vX
;
2337 m_deviceOriginY
= vY
;
2338 ::GpiQueryPageViewport( m_hPS
2343 vRect
.yBottom
-= vY
;
2345 ::GpiSetPageViewport( m_hPS
2348 }; // end of wxPMDCImpl::SetDeviceOrigin
2350 // ---------------------------------------------------------------------------
2352 // ---------------------------------------------------------------------------
2354 bool wxPMDCImpl::DoBlit( wxCoord vXdest
,
2361 wxRasterOperationMode nRop
,
2363 wxCoord
WXUNUSED(vXsrcMask
),
2364 wxCoord
WXUNUSED(vYsrcMask
) )
2366 wxMask
* pMask
= NULL
;
2368 COLORREF vOldTextColor
;
2369 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
2371 wxDCImpl
*impl
= pSource
->GetImpl();
2372 wxPMDCImpl
*pm_impl
= wxDynamicCast( impl
, wxPMDCImpl
);
2375 // TODO: Do we want to be able to blit
2376 // from other DCs too?
2382 const wxBitmap
& rBmp
= pm_impl
->GetSelectedBitmap();
2384 pMask
= rBmp
.GetMask();
2385 if (!(rBmp
.IsOk() && pMask
&& pMask
->GetMaskBitmap()))
2391 ::GpiQueryAttrs( m_hPS
2396 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
2398 if (m_textForegroundColour
.IsOk())
2400 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
2401 ::GpiSetAttrs( m_hPS
// presentation-space handle
2402 ,PRIM_CHAR
// Char primitive.
2403 ,CBB_COLOR
// sets color.
2405 ,&vCbnd
// buffer for attributes.
2408 if (m_textBackgroundColour
.IsOk())
2410 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
2413 LONG lRop
= ROP_SRCCOPY
;
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;
2434 wxFAIL_MSG( wxT("unsupported logical function") );
2443 // Blit bitmap with mask
2447 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2453 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
2454 BITMAPINFOHEADER2 vBmpHdr
;
2456 SIZEL vSize
= {0, 0};
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;
2466 #if wxUSE_DC_CACHEING
2469 // create a temp buffer bitmap and DCs to access it and the mask
2471 wxDCCacheEntry
* pDCCacheEntry1
= FindDCInCache( NULL
2474 wxDCCacheEntry
* pDCCacheEntry2
= FindDCInCache( pDCCacheEntry1
2477 wxDCCacheEntry
* pBitmapCacheEntry
= FindBitmapInCache( GetHPS()
2482 hPSMask
= pDCCacheEntry1
->m_hPS
;
2483 hDCBuffer
= (HDC
)pDCCacheEntry2
->m_hPS
;
2484 hBufBitmap
= (HBITMAP
)pBitmapCacheEntry
->m_hBitmap
;
2485 wxUnusedVar(hDCMask
);
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
);
2497 POINTL aPoint1
[4] = { {0, 0}
2500 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2502 POINTL aPoint2
[4] = { {0, 0}
2505 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2507 POINTL aPoint3
[4] = { {vXdest
, vYdest
}
2508 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2510 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2512 POINTL aPoint4
[4] = { {vXdest
, vYdest
}
2513 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2517 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
2518 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
2521 // Copy dest to buffer
2523 rc
= ::GpiBitBlt( hPSBuffer
2530 if (rc
== GPI_ERROR
)
2532 wxLogLastError(wxT("BitBlt"));
2536 // Copy src to buffer using selected raster op
2538 rc
= ::GpiBitBlt( hPSBuffer
2545 if (rc
== GPI_ERROR
)
2547 wxLogLastError(wxT("BitBlt"));
2551 // Set masked area in buffer to BLACK (pixel value 0)
2553 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
2554 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
2556 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2557 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2559 rc
= ::GpiBitBlt( hPSBuffer
2566 if (rc
== GPI_ERROR
)
2568 wxLogLastError(wxT("BitBlt"));
2572 // Set unmasked area in dest to BLACK
2574 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2575 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2576 rc
= ::GpiBitBlt( GetHPS()
2583 if (rc
== GPI_ERROR
)
2585 wxLogLastError(wxT("BitBlt"));
2589 // Restore colours to original values
2591 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
2592 ::GpiSetColor(GetHPS(), vPrevCol
);
2595 // OR buffer to dest
2597 rc
= ::GpiBitBlt( GetHPS()
2604 if (rc
== GPI_ERROR
)
2607 wxLogLastError(wxT("BitBlt"));
2611 // Tidy up temporary DCs and bitmap
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
);
2624 else // no mask, just BitBlt() it
2626 POINTL aPoint
[4] = { {vXdest
, vYdest
}
2627 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2629 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2632 bSuccess
= (::GpiBitBlt( m_hPS
2641 wxLogLastError(wxT("BitBlt"));
2644 vCbnd
.lColor
= (LONG
)vOldTextColor
;
2645 ::GpiSetAttrs( m_hPS
// presentation-space handle
2646 ,PRIM_CHAR
// Char primitive.
2647 ,CBB_COLOR
// sets color.
2649 ,&vCbnd
// buffer for attributes.
2651 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
2655 void wxPMDCImpl::DoGetSize( int* pnWidth
,
2656 int* pnHeight
) const
2658 LONG lArray
[CAPS_HEIGHT
+1];
2660 if(::DevQueryCaps( m_hDC
2667 *pnWidth
= lArray
[CAPS_WIDTH
];
2669 *pnHeight
= lArray
[CAPS_HEIGHT
];
2671 }; // end of wxPMDCImpl::DoGetSize(
2673 void wxPMDCImpl::DoGetSizeMM( int* pnWidth
,
2674 int* pnHeight
) const
2676 LONG lArray
[CAPS_VERTICAL_RESOLUTION
+1];
2678 if(::DevQueryCaps( m_hDC
2680 ,CAPS_VERTICAL_RESOLUTION
+1
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
);
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
);
2700 }; // end of wxPMDCImpl::DoGetSizeMM
2702 wxSize
wxPMDCImpl::GetPPI() const
2704 LONG lArray
[CAPS_VERTICAL_RESOLUTION
+1];
2708 if(::DevQueryCaps( m_hDC
2710 ,CAPS_VERTICAL_RESOLUTION
+1
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
);
2726 wxSize
ppisize(nWidth
, nHeight
);
2728 } // end of wxPMDCImpl::GetPPI
2730 void wxPMDCImpl::SetLogicalScale( double dX
, double dY
)
2732 m_logicalScaleX
= dX
;
2733 m_logicalScaleY
= dY
;
2734 }; // end of wxPMDCImpl::SetLogicalScale