1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/dc.cpp
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
16 #include "wx/window.h"
19 #include "wx/dialog.h"
21 #include "wx/bitmap.h"
22 #include "wx/dcmemory.h"
25 #include "wx/msgdlg.h"
26 #include "wx/dcprint.h"
27 #include "wx/statusbr.h"
30 #include "wx/module.h"
34 #include "wx/os2/private.h"
36 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
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
wxDC::m_svBitmapCache
;
161 wxList
wxDC::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
* wxDC::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
* wxDC::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 wxDC::FindDCInCache
295 void wxDC::AddToBitmapCache(
296 wxDCCacheEntry
* pEntry
299 m_svBitmapCache
.Append(pEntry
);
300 } // end of wxDC::AddToBitmapCache
302 void wxDC::AddToDCCache(
303 wxDCCacheEntry
* pEntry
306 m_svDCCache
.Append(pEntry
);
307 } // end of wxDC::AddToDCCache
309 void wxDC::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 wxDC::ClearCache
319 // Clean up cache at app exit
320 class wxDCModule
: public wxModule
323 virtual bool OnInit() { return true; }
324 virtual void OnExit() { wxDC::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 // ---------------------------------------------------------------------------
352 m_bIsPaintTime
= false; // True at Paint Time
354 m_pen
.SetColour(*wxBLACK
);
355 m_brush
.SetColour(*wxWHITE
);
357 } // end of wxDC::wxDC
363 SelectOldObjects(m_hDC
);
365 // if we own the HDC, we delete it, otherwise we just release it
371 ::GpiAssociate(m_hPS
, NULLHANDLE
);
372 ::GpiDestroyPS(m_hPS
);
375 ::DevCloseDC((HDC
)m_hDC
);
380 // Just Dissacociate, not destroy if we don't own the DC
384 ::GpiAssociate(m_hPS
, NULLHANDLE
);
388 } // end of wxDC::~wxDC
390 // This will select current objects out of the DC,
391 // which is what you have to do before deleting the
393 void wxDC::SelectOldObjects(
401 ::GpiSetBitmap(hPS
, (HBITMAP
) m_hOldBitmap
);
402 if (m_vSelectedBitmap
.Ok())
404 m_vSelectedBitmap
.SetSelectedInto(NULL
);
409 // OS/2 has no other native GDI objects to set in a PS/DC like windows
417 m_brush
= wxNullBrush
;
419 m_palette
= wxNullPalette
;
421 m_backgroundBrush
= wxNullBrush
;
422 m_vSelectedBitmap
= wxNullBitmap
;
423 } // end of wxDC::SelectOldObjects
425 // ---------------------------------------------------------------------------
427 // ---------------------------------------------------------------------------
429 #define DO_SET_CLIPPING_BOX() \
433 ::GpiQueryClipBox(m_hPS, &rect); \
435 m_clipX1 = (wxCoord) XDEV2LOG(rect.xLeft); \
436 m_clipY1 = (wxCoord) YDEV2LOG(rect.yTop); \
437 m_clipX2 = (wxCoord) XDEV2LOG(rect.xRight); \
438 m_clipY2 = (wxCoord) YDEV2LOG(rect.yBottom); \
441 void wxDC::DoSetClippingRegion(
450 vY
= OS2Y(vY
,vHeight
);
453 vRect
.yTop
= vY
+ vHeight
;
454 vRect
.xRight
= vX
+ vWidth
;
456 ::GpiIntersectClipRectangle(m_hPS
, &vRect
);
457 DO_SET_CLIPPING_BOX()
458 } // end of wxDC::DoSetClippingRegion
460 void wxDC::DoSetClippingRegionAsRegion(
461 const wxRegion
& rRegion
464 wxCHECK_RET(rRegion
.GetHRGN(), wxT("invalid clipping region"));
468 ::GpiSetClipRegion( m_hPS
469 ,(HRGN
)rRegion
.GetHRGN()
472 DO_SET_CLIPPING_BOX()
473 } // end of wxDC::DoSetClippingRegionAsRegion
475 void wxDC::DestroyClippingRegion(void)
477 if (m_clipping
&& m_hPS
)
482 // TODO: this should restore the previous clipped region
483 // so that OnPaint processing works correctly, and
484 // the update doesn't get destroyed after the first
485 // DestroyClippingRegion
486 vRect
.xLeft
= XLOG2DEV(0);
487 vRect
.yTop
= YLOG2DEV(32000);
488 vRect
.xRight
= XLOG2DEV(32000);
489 vRect
.yBottom
= YLOG2DEV(0);
491 HRGN hRgn
= ::GpiCreateRegion(m_hPS
, 1, &vRect
);
493 ::GpiSetClipRegion(m_hPS
, hRgn
, &hRgnOld
);
496 } // end of wxDC::DestroyClippingRegion
498 // ---------------------------------------------------------------------------
499 // query capabilities
500 // ---------------------------------------------------------------------------
502 bool wxDC::CanDrawBitmap() const
507 bool wxDC::CanGetTextExtent() const
509 LONG lTechnology
= 0L;
511 ::DevQueryCaps(GetHDC(), CAPS_TECHNOLOGY
, 1L, &lTechnology
);
512 return (lTechnology
== CAPS_TECH_RASTER_DISPLAY
) || (lTechnology
== CAPS_TECH_RASTER_PRINTER
);
513 } // end of wxDC::CanGetTextExtent
515 int wxDC::GetDepth() const
517 LONG lArray
[CAPS_COLOR_BITCOUNT
];
518 int nBitsPerPixel
= 0;
520 if(::DevQueryCaps( GetHDC()
526 nBitsPerPixel
= (int)lArray
[CAPS_COLOR_BITCOUNT
];
528 return nBitsPerPixel
;
529 } // end of wxDC::GetDepth
531 // ---------------------------------------------------------------------------
533 // ---------------------------------------------------------------------------
538 // If this is a canvas DC then just fill with the background color
539 // Otherwise purge the whole thing
545 ::GpiQueryClipBox(m_hPS
, &vRect
);
546 ::WinFillRect(m_hPS
, &vRect
, ::GpiQueryBackColor(m_hPS
));
550 } // end of wxDC::Clear
552 bool wxDC::DoFloodFill(
555 , const wxColour
& rCol
563 bool bSuccess
= false;
565 vPtlPos
.x
= vX
; // Loads x-coordinate
566 vPtlPos
.y
= OS2Y(vY
,0); // Loads y-coordinate
567 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
568 lColor
= rCol
.GetPixel();
569 lOptions
= FF_BOUNDARY
;
570 if(wxFLOOD_SURFACE
== nStyle
)
571 lOptions
= FF_SURFACE
;
573 if ((lHits
= ::GpiFloodFill(m_hPS
, lOptions
, lColor
)) != GPI_ERROR
)
577 } // end of wxDC::DoFloodFill
579 bool wxDC::DoGetPixel(
589 vPoint
.y
= OS2Y(vY
,0);
590 lColor
= ::GpiQueryPel(m_hPS
, &vPoint
);
593 // return the color of the pixel
596 pCol
->Set( GetRValue(lColor
)
601 } // end of wxDC::DoGetPixel
603 void wxDC::DoCrossHair(
610 wxCoord vX1
= vX
- VIEWPORT_EXTENT
;
611 wxCoord vY1
= vY
- VIEWPORT_EXTENT
;
612 wxCoord vX2
= vX
+ VIEWPORT_EXTENT
;
613 wxCoord vY2
= vY
+ VIEWPORT_EXTENT
;
622 ::GpiMove(m_hPS
, &vPoint
[0]);
623 ::GpiLine(m_hPS
, &vPoint
[1]);
631 ::GpiMove(m_hPS
, &vPoint
[2]);
632 ::GpiLine(m_hPS
, &vPoint
[3]);
633 CalcBoundingBox(vX1
, vY1
);
634 CalcBoundingBox(vX2
, vY2
);
635 } // end of wxDC::DoCrossHair
637 void wxDC::DoDrawLine(
645 COLORREF vColor
= 0x00ffffff;
648 // Might be a memory DC with no Paint rect.
650 if (!(m_vRclPaint
.yTop
== 0 &&
651 m_vRclPaint
.yBottom
== 0 &&
652 m_vRclPaint
.xRight
== 0 &&
653 m_vRclPaint
.xLeft
== 0))
660 if (m_vSelectedBitmap
!= wxNullBitmap
)
662 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
663 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
674 vColor
= m_pen
.GetColour().GetPixel();
676 ::GpiSetColor(m_hPS
, vColor
);
677 ::GpiMove(m_hPS
, &vPoint
[0]);
678 ::GpiLine(m_hPS
, &vPoint
[1]);
679 CalcBoundingBox(vX1
, vY1
);
680 CalcBoundingBox(vX2
, vY2
);
681 } // end of wxDC::DoDrawLine
683 //////////////////////////////////////////////////////////////////////////////
684 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
685 // and ending at (x2, y2). The current pen is used for the outline and the
686 // current brush for filling the shape. The arc is drawn in an anticlockwise
687 // direction from the start point to the end point.
688 //////////////////////////////////////////////////////////////////////////////
689 void wxDC::DoDrawArc(
699 POINTL vPtlArc
[2]; // Structure for current position
706 ARCPARAMS vArcp
; // Structure for arc parameters
708 if((vX1
== vXc
&& vY1
== vXc
) || (vX2
== vXc
&& vY2
== vXc
))
709 return; // Draw point ??
710 dRadius
= 0.5 * ( hypot( (double)(vY1
- vYc
)
713 hypot( (double)(vY2
- vYc
)
718 dAngl1
= atan2( (double)(vY1
- vYc
)
721 dAngl2
= atan2( (double)(vY2
- vYc
)
728 // GpiPointArc can't draw full arc
730 if(dAngl2
== dAngl1
|| (vX1
== vX2
&& vY1
== vY2
) )
735 dAnglmid
= (dAngl1
+ dAngl2
)/2. + M_PI
;
736 vXm
= (wxCoord
)(vXc
+ dRadius
* cos(dAnglmid
));
737 vYm
= (wxCoord
)(vYc
+ dRadius
* sin(dAnglmid
));
752 dAnglmid
= (dAngl1
+ dAngl2
)/2.;
753 vXm
= (wxCoord
)(vXc
+ dRadius
* cos(dAnglmid
));
754 vYm
= (wxCoord
)(vYc
+ dRadius
* sin(dAnglmid
));
757 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
763 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
765 vPtlPos
.x
= vX1
; // Loads x-coordinate
766 vPtlPos
.y
= vY1
; // Loads y-coordinate
767 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
772 ::GpiPointArc(m_hPS
, vPtlArc
); // Draws the arc
773 CalcBoundingBox( (wxCoord
)(vXc
- dRadius
)
774 ,(wxCoord
)(vYc
- dRadius
)
776 CalcBoundingBox( (wxCoord
)(vXc
+ dRadius
)
777 ,(wxCoord
)(vYc
+ dRadius
)
779 } // end of wxDC::DoDrawArc
781 void wxDC::DoDrawCheckMark(
790 vY1
= OS2Y(vY1
,vHeight
);
794 vPoint
[1].x
= vX1
+ vWidth
;
795 vPoint
[1].y
= vY1
+ vHeight
;
797 ::GpiMove(m_hPS
, &vPoint
[0]);
798 ::GpiBox( m_hPS
// handle to a presentation space
799 ,DRO_OUTLINE
// draw the box outline ? or ?
800 ,&vPoint
[1] // address of the corner
801 ,0L // horizontal corner radius
802 ,0L // vertical corner radius
804 if(vWidth
> 4 && vHeight
> 4)
808 vPoint
[0].x
+= 2; vPoint
[0].y
+= 2;
809 vPoint
[1].x
-= 2; vPoint
[1].y
-= 2;
810 ::GpiMove(m_hPS
, &vPoint
[0]);
811 ::GpiLine(m_hPS
, &vPoint
[1]);
813 vPoint
[0].x
= vPoint
[1].x
;
815 ::GpiMove(m_hPS
, &vPoint
[0]);
816 ::GpiLine(m_hPS
, &vPoint
[1]);
822 wxCoord vX2
= vX1
+ vWidth
;
823 wxCoord vY2
= vY1
+ vHeight
;
828 } // end of wxDC::DoDrawCheckMark
830 void wxDC::DoDrawPoint(
836 COLORREF vColor
= 0x00ffffff;
840 vColor
= m_pen
.GetColour().GetPixel();
842 ::GpiSetColor(m_hPS
, vColor
);
844 vPoint
.y
= OS2Y(vY
,0);
845 ::GpiSetPel(m_hPS
, &vPoint
);
849 } // end of wxDC::DoDrawPoint
851 void wxDC::DoDrawPolygon(
859 ULONG ulCount
= 1; // Number of polygons.
860 POLYGON vPlgn
; // polygon.
861 ULONG flOptions
= 0L; // Drawing options.
863 //////////////////////////////////////////////////////////////////////////////
864 // This contains fields of option bits... to draw boundary lines as well as
865 // the area interior.
867 // Drawing boundary lines:
868 // POLYGON_NOBOUNDARY Does not draw boundary lines.
869 // POLYGON_BOUNDARY Draws boundary lines (the default).
871 // Construction of the area interior:
872 // POLYGON_ALTERNATE Constructs interior in alternate mode
874 // POLYGON_WINDING Constructs interior in winding mode.
875 //////////////////////////////////////////////////////////////////////////////
877 ULONG flModel
= POLYGON_INCL
; // Drawing model.
879 //////////////////////////////////////////////////////////////////////////////
881 // POLYGON_INCL Fill is inclusive of bottom right (the default).
882 // POLYGON_EXCL Fill is exclusive of bottom right.
883 // This is provided to aid migration from other graphics models.
884 //////////////////////////////////////////////////////////////////////////////
886 LONG lHits
= 0L; // Correlation/error indicator.
889 int nIsTRANSPARENT
= 0;
890 LONG lBorderColor
= 0L;
893 lBorderColor
= m_pen
.GetColour().GetPixel();
894 lColor
= m_brush
.GetColour().GetPixel();
895 if(m_brush
.GetStyle() == wxTRANSPARENT
)
899 vPlgn
.aPointl
= (POINTL
*) calloc( n
+ 1
901 ); // well, new will call malloc
903 for(i
= 0; i
< n
; i
++)
905 vPlgn
.aPointl
[i
].x
= vPoints
[i
].x
+vXoffset
;
906 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
+vYoffset
,0);
908 flOptions
= POLYGON_BOUNDARY
;
909 if(nFillStyle
== wxWINDING_RULE
)
910 flOptions
|= POLYGON_WINDING
;
912 flOptions
|= POLYGON_ALTERNATE
;
914 ::GpiSetColor(m_hPS
, lBorderColor
);
915 ::GpiMove(m_hPS
, &vPlgn
.aPointl
[0]);
916 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
918 } // end of wxDC::DoDrawPolygon
920 void wxDC::DoDrawLines(
929 if (vXoffset
!= 0L || vXoffset
!= 0L)
933 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
934 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
935 ::GpiMove(m_hPS
, &vPoint
);
937 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
939 ::GpiSetColor(m_hPS
, lBorderColor
);
940 for(i
= 1; i
< n
; i
++)
942 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
943 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
944 ::GpiLine(m_hPS
, &vPoint
);
951 CalcBoundingBox( vPoints
[0].x
954 vPoint
.x
= vPoints
[0].x
;
955 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
956 ::GpiMove(m_hPS
, &vPoint
);
958 for (i
= 0; i
< n
; i
++)
960 CalcBoundingBox( vPoints
[i
].x
963 vPoint
.x
= vPoints
[i
].x
;
964 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
965 ::GpiLine(m_hPS
, &vPoint
);
968 } // end of wxDC::DoDrawLines
970 void wxDC::DoDrawRectangle(
981 int nIsTRANSPARENT
= 0;
984 // Might be a memory DC with no Paint rect.
986 if (!(m_vRclPaint
.yTop
== 0 &&
987 m_vRclPaint
.yBottom
== 0 &&
988 m_vRclPaint
.xRight
== 0 &&
989 m_vRclPaint
.xLeft
== 0))
990 vY
= OS2Y(vY
,vHeight
);
993 if (m_vSelectedBitmap
!= wxNullBitmap
)
995 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
996 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
997 vY
= OS2Y(vY
,vHeight
);
1001 wxCoord vX2
= vX
+ vWidth
;
1002 wxCoord vY2
= vY
+ vHeight
;
1006 vPoint
[1].x
= vX
+ vWidth
- 1;
1007 vPoint
[1].y
= vY
+ vHeight
- 1;
1008 ::GpiMove(m_hPS
, &vPoint
[0]);
1009 lColor
= m_brush
.GetColour().GetPixel();
1010 lBorderColor
= m_pen
.GetColour().GetPixel();
1011 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1013 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1015 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1016 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1017 lControl
= DRO_OUTLINE
;
1019 ::GpiSetColor(m_hPS
, lBorderColor
);
1020 ::GpiBox( m_hPS
// handle to a presentation space
1021 ,lControl
// draw the box outline ? or ?
1022 ,&vPoint
[1] // address of the corner
1023 ,0L // horizontal corner radius
1024 ,0L // vertical corner radius
1029 lControl
= DRO_OUTLINE
;
1030 ::GpiSetColor( m_hPS
1039 lControl
= DRO_FILL
;
1040 ::GpiSetColor( m_hPS
1043 vPoint
[0].x
= vX
+ 1;
1044 vPoint
[0].y
= vY
+ 1;
1045 vPoint
[1].x
= vX
+ vWidth
- 2;
1046 vPoint
[1].y
= vY
+ vHeight
- 2;
1047 ::GpiMove(m_hPS
, &vPoint
[0]);
1055 CalcBoundingBox(vX
, vY
);
1056 CalcBoundingBox(vX2
, vY2
);
1057 } // end of wxDC::DoDrawRectangle
1059 void wxDC::DoDrawRoundedRectangle(
1071 int nIsTRANSPARENT
= 0;
1074 // Might be a memory DC with no Paint rect.
1076 if (!(m_vRclPaint
.yTop
== 0 &&
1077 m_vRclPaint
.yBottom
== 0 &&
1078 m_vRclPaint
.xRight
== 0 &&
1079 m_vRclPaint
.xLeft
== 0))
1080 vY
= OS2Y(vY
,vHeight
);
1083 if (m_vSelectedBitmap
!= wxNullBitmap
)
1085 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1086 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1087 vY
= OS2Y(vY
,vHeight
);
1091 wxCoord vX2
= (vX
+ vWidth
);
1092 wxCoord vY2
= (vY
+ vHeight
);
1096 vPoint
[1].x
= vX
+ vWidth
- 1;
1097 vPoint
[1].y
= vY
+ vHeight
- 1;
1098 ::GpiMove(m_hPS
, &vPoint
[0]);
1100 lColor
= m_brush
.GetColour().GetPixel();
1101 lBorderColor
= m_pen
.GetColour().GetPixel();
1102 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1103 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1105 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1107 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1108 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1109 lControl
= DRO_OUTLINE
;
1111 ::GpiSetColor(m_hPS
, lColor
);
1112 ::GpiBox( m_hPS
// handle to a presentation space
1113 ,lControl
// draw the box outline ? or ?
1114 ,&vPoint
[1] // address of the corner
1115 ,(LONG
)dRadius
// horizontal corner radius
1116 ,(LONG
)dRadius
// vertical corner radius
1121 lControl
= DRO_OUTLINE
;
1122 ::GpiSetColor( m_hPS
1131 lControl
= DRO_FILL
;
1132 ::GpiSetColor( m_hPS
1135 vPoint
[0].x
= vX
+ 1;
1136 vPoint
[0].y
= vY
+ 1;
1137 vPoint
[1].x
= vX
+ vWidth
- 2;
1138 vPoint
[1].y
= vY
+ vHeight
- 2;
1139 ::GpiMove(m_hPS
, &vPoint
[0]);
1148 CalcBoundingBox(vX
, vY
);
1149 CalcBoundingBox(vX2
, vY2
);
1150 } // end of wxDC::DoDrawRoundedRectangle
1152 // Draw Ellipse within box (x,y) - (x+width, y+height)
1153 void wxDC::DoDrawEllipse(
1160 POINTL vPtlPos
; // Structure for current position
1161 FIXED vFxMult
; // Multiplier for ellipse
1162 ARCPARAMS vArcp
; // Structure for arc parameters
1164 vY
= OS2Y(vY
,vHeight
);
1167 vArcp
.lQ
= vHeight
/2;
1168 vArcp
.lP
= vWidth
/2;
1170 ::GpiSetArcParams( m_hPS
1172 ); // Sets parameters to default
1173 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
1174 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1177 ); // Sets current position
1178 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
1181 // DRO_FILL, DRO_OTLINEFILL - where to get
1186 ); // Draws full arc with center at current position
1188 wxCoord vX2
= (vX
+ vWidth
);
1189 wxCoord vY2
= (vY
+ vHeight
);
1191 CalcBoundingBox(vX
, vY
);
1192 CalcBoundingBox(vX2
, vY2
);
1193 } // end of wxDC::DoDrawEllipse
1195 void wxDC::DoDrawEllipticArc(
1204 POINTL vPtlPos
; // Structure for current position
1205 FIXED vFxMult
; // Multiplier for ellipse
1206 ARCPARAMS vArcp
; // Structure for arc parameters
1208 FIXED vFSweepa
; // Start angle, sweep angle
1212 vY
= OS2Y(vY
,vHeight
);
1214 dFractPart
= modf(dSa
,&dIntPart
);
1215 vFSa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1216 dFractPart
= modf(dEa
- dSa
, &dIntPart
);
1217 vFSweepa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1220 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1223 vArcp
.lQ
= vHeight
/2;
1224 vArcp
.lP
= vWidth
/2;
1226 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
1227 vPtlPos
.x
= (wxCoord
)(vX
+ vWidth
/2 * (1. + cos(DegToRad(dSa
)))); // Loads x-coordinate
1228 vPtlPos
.y
= (wxCoord
)(vY
+ vHeight
/2 * (1. + sin(DegToRad(dSa
)))); // Loads y-coordinate
1229 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
1232 // May be not to the center ?
1234 vPtlPos
.x
= vX
+ vWidth
/2 ; // Loads x-coordinate
1235 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1236 vFxMult
= MAKEFIXED(1, 0); // Sets multiplier
1239 // DRO_FILL, DRO_OTLINEFILL - where to get
1241 ::GpiPartialArc( m_hPS
1247 wxCoord vX2
= (vX
+ vWidth
);
1248 wxCoord vY2
= (vY
+ vHeight
);
1250 CalcBoundingBox(vX
, vY
);
1251 CalcBoundingBox(vX2
, vY2
);
1252 } // end of wxDC::DoDrawEllipticArc
1254 void wxDC::DoDrawIcon(
1261 // Need to copy back into a bitmap. ::WinDrawPointer uses device coords
1262 // and I don't feel like figuring those out for scrollable windows so
1263 // just convert to a bitmap then let the DoDrawBitmap routine display it
1267 DoDrawBitmap(rIcon
.GetXpmSrc(), vX
, vY
, true);
1271 wxBitmap
vBitmap(rIcon
);
1273 DoDrawBitmap(vBitmap
, vX
, vY
, false);
1275 CalcBoundingBox(vX
, vY
);
1276 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
1277 } // end of wxDC::DoDrawIcon
1279 void wxDC::DoDrawBitmap(
1280 const wxBitmap
& rBmp
1286 #if wxUSE_PRINTING_ARCHITECTURE
1287 if (!IsKindOf(CLASSINFO(wxPrinterDC
)))
1290 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
1291 HBITMAP hBitmapOld
= NULLHANDLE
;
1294 vY
= OS2Y(vY
,rBmp
.GetHeight());
1297 vPoint
[0].y
= vY
+ rBmp
.GetHeight();
1298 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1302 vPoint
[3].x
= rBmp
.GetWidth();
1303 vPoint
[3].y
= rBmp
.GetHeight();
1306 wxMask
* pMask
= rBmp
.GetMask();
1311 // Need to imitate ::MaskBlt in windows.
1312 // 1) Extract the bits from from the bitmap.
1313 // 2) Extract the bits from the mask
1314 // 3) Using the mask bits do the following:
1315 // A) If the mask byte is 00 leave the bitmap byte alone
1316 // B) If the mask byte is FF copy the screen color into
1318 // 4) Create a new bitmap and set its bits to the above result
1319 // 5) Blit this to the screen PS
1321 HBITMAP hMask
= (HBITMAP
)pMask
->GetMaskBitmap();
1322 HBITMAP hOldMask
= NULLHANDLE
;
1323 HBITMAP hOldBitmap
= NULLHANDLE
;
1324 HBITMAP hNewBitmap
= NULLHANDLE
;
1325 unsigned char* pucBits
; // buffer that will contain the bitmap data
1326 unsigned char* pucBitsMask
; // buffer that will contain the mask data
1327 unsigned char* pucData
; // pointer to use to traverse bitmap data
1328 unsigned char* pucDataMask
; // pointer to use to traverse mask data
1334 // The usual Memory context creation stuff
1336 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1337 SIZEL vSize
= {0, 0};
1338 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1339 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1342 // The usual bitmap header stuff
1344 BITMAPINFOHEADER2 vHeader
;
1347 memset(&vHeader
, '\0', 16);
1350 memset(&vInfo
, '\0', 16);
1352 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1353 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1355 vInfo
.cBitCount
= 24; // Set to desired count going in
1358 // Create the buffers for data....all wxBitmaps are 24 bit internally
1360 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1361 int nSizeDWORD
= sizeof(DWORD
);
1362 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
1370 // Need to get a background color for mask blitting
1372 if (IsKindOf(CLASSINFO(wxWindowDC
)))
1374 wxWindowDC
* pWindowDC
= wxDynamicCast(this, wxWindowDC
);
1376 lColor
= pWindowDC
->m_pCanvas
->GetBackgroundColour().GetPixel();
1378 else if (GetBrush().Ok())
1379 lColor
= GetBrush().GetColour().GetPixel();
1381 lColor
= m_textBackgroundColour
.GetPixel();
1384 // Bitmap must be in a double-word aligned address so we may
1385 // have some padding to worry about
1387 if (nLineBoundary
> 0)
1389 nPadding
= nSizeDWORD
- nLineBoundary
;
1390 nBytesPerLine
+= nPadding
;
1392 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1393 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1394 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1395 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1398 // Extract the bitmap and mask data
1400 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1402 vError
= ::WinGetLastError(vHabmain
);
1403 sError
= wxPMErrorToStr(vError
);
1405 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
1406 vInfo
.cBitCount
= 24;
1407 if ((lScans
= ::GpiQueryBitmapBits( hPS
1409 ,(LONG
)rBmp
.GetHeight()
1414 vError
= ::WinGetLastError(vHabmain
);
1415 sError
= wxPMErrorToStr(vError
);
1417 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
1419 vError
= ::WinGetLastError(vHabmain
);
1420 sError
= wxPMErrorToStr(vError
);
1422 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
1423 vInfo
.cBitCount
= 24;
1424 if ((lScans
= ::GpiQueryBitmapBits( hPS
1426 ,(LONG
)rBmp
.GetHeight()
1431 vError
= ::WinGetLastError(vHabmain
);
1432 sError
= wxPMErrorToStr(vError
);
1434 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
1436 vError
= ::WinGetLastError(vHabmain
);
1437 sError
= wxPMErrorToStr(vError
);
1441 // Now set the bytes(bits) according to the mask values
1442 // 3 bytes per pel...must handle one at a time
1445 pucDataMask
= pucBitsMask
;
1448 // 16 bit kludge really only kinda works. The mask gets applied
1449 // where needed but the original bitmap bits are dorked sometimes
1451 bool bpp16
= (wxDisplayDepth() == 16);
1453 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1455 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1458 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1460 else if (*pucDataMask
== 0xFF) // leave bitmap byte alone
1464 *pucData
= ((unsigned char)(lColor
>> 16));
1468 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1470 else if (*(pucDataMask
+ 1) == 0xFF) // leave bitmap byte alone
1474 *pucData
= ((unsigned char)(lColor
>> 8));
1479 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1481 else if (*(pucDataMask
+ 2) == 0xFF) // leave bitmap byte alone
1485 *pucData
= ((unsigned char)lColor
);
1490 for (j
= 0; j
< nPadding
; j
++)
1497 // Create a new bitmap
1499 vHeader
.cx
= (ULONG
)rBmp
.GetWidth();
1500 vHeader
.cy
= (ULONG
)rBmp
.GetHeight();
1501 vHeader
.cPlanes
= 1L;
1502 vHeader
.cBitCount
= 24;
1503 if ((hNewBitmap
= ::GpiCreateBitmap( hPS
1510 vError
= ::WinGetLastError(vHabmain
);
1511 sError
= wxPMErrorToStr(vError
);
1515 // Now blit it to the screen PS
1517 if ((lHits
= ::GpiWCBitBlt( (HPS
)GetHPS()
1525 vError
= ::WinGetLastError(vHabmain
);
1526 sError
= wxPMErrorToStr(vError
);
1534 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1535 ::GpiDeleteBitmap(hNewBitmap
);
1536 ::GpiDestroyPS(hPS
);
1542 ULONG lOldForeGround
= ::GpiQueryColor((HPS
)GetHPS());
1543 ULONG lOldBackGround
= ::GpiQueryBackColor((HPS
)GetHPS());
1545 if (m_textForegroundColour
.Ok())
1547 ::GpiSetColor( (HPS
)GetHPS()
1548 ,m_textForegroundColour
.GetPixel()
1551 if (m_textBackgroundColour
.Ok())
1553 ::GpiSetBackColor( (HPS
)GetHPS()
1554 ,m_textBackgroundColour
.GetPixel()
1558 // Need to alter bits in a mono bitmap to match the new
1559 // background-foreground if it is different.
1561 if (rBmp
.IsMono() &&
1562 ((m_textForegroundColour
.GetPixel() != lOldForeGround
) ||
1563 (m_textBackgroundColour
.GetPixel() != lOldBackGround
)))
1565 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1566 SIZEL vSize
= {0, 0};
1567 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1568 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1570 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1572 LONG lForeGround
= m_textForegroundColour
.GetPixel();
1573 LONG lBackGround
= m_textBackgroundColour
.GetPixel();
1575 HBITMAP hOldBitmap
= NULLHANDLE
;
1581 memset(&vInfo
, '\0', 16);
1583 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1584 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1586 vInfo
.cBitCount
= 24;
1588 unsigned char* pucBits
; // buffer that will contain the bitmap data
1589 unsigned char* pucData
; // pointer to use to traverse bitmap data
1591 pucBits
= new unsigned char[nBytesPerLine
* rBmp
.GetHeight()];
1592 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1594 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1596 vError
= ::WinGetLastError(vHabmain
);
1597 sError
= wxPMErrorToStr(vError
);
1600 if ((lScans
= ::GpiQueryBitmapBits( hPS
1602 ,(LONG
)rBmp
.GetHeight()
1607 vError
= ::WinGetLastError(vHabmain
);
1608 sError
= wxPMErrorToStr(vError
);
1611 unsigned char cOldRedFore
= (unsigned char)(lOldForeGround
>> 16);
1612 unsigned char cOldGreenFore
= (unsigned char)(lOldForeGround
>> 8);
1613 unsigned char cOldBlueFore
= (unsigned char)lOldForeGround
;
1615 unsigned char cRedFore
= (unsigned char)(lForeGround
>> 16);
1616 unsigned char cGreenFore
= (unsigned char)(lForeGround
>> 8);
1617 unsigned char cBlueFore
= (unsigned char)lForeGround
;
1619 unsigned char cRedBack
= (unsigned char)(lBackGround
>> 16);
1620 unsigned char cGreenBack
= (unsigned char)(lBackGround
>> 8);
1621 unsigned char cBlueBack
= (unsigned char)lBackGround
;
1624 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1626 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1628 unsigned char cBmpRed
= *pucData
;
1629 unsigned char cBmpGreen
= *(pucData
+ 1);
1630 unsigned char cBmpBlue
= *(pucData
+ 2);
1632 if ((cBmpRed
== cOldRedFore
) &&
1633 (cBmpGreen
== cOldGreenFore
) &&
1634 (cBmpBlue
== cOldBlueFore
))
1636 *pucData
= cBlueFore
;
1638 *pucData
= cGreenFore
;
1640 *pucData
= cRedFore
;
1645 *pucData
= cBlueBack
;
1647 *pucData
= cGreenBack
;
1649 *pucData
= cRedBack
;
1654 if ((lScans
= ::GpiSetBitmapBits( hPS
1656 ,(LONG
)rBmp
.GetHeight()
1661 vError
= ::WinGetLastError(vHabmain
);
1662 sError
= wxPMErrorToStr(vError
);
1666 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1667 ::GpiDestroyPS(hPS
);
1670 ::GpiWCBitBlt( (HPS
)GetHPS()
1677 ::GpiSetBitmap((HPS
)GetHPS(), hBitmapOld
);
1678 ::GpiSetColor((HPS
)GetHPS(), lOldForeGround
);
1679 ::GpiSetBackColor((HPS
)GetHPS(), lOldBackGround
);
1682 } // end of wxDC::DoDrawBitmap
1684 void wxDC::DoDrawText(
1685 const wxString
& rsText
1698 CalcBoundingBox(vX
, vY
);
1699 GetTextExtent(rsText
, &vWidth
, &vHeight
);
1700 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1701 } // end of wxDC::DoDrawText
1703 void wxDC::DrawAnyText( const wxString
& rsText
,
1707 int nOldBackground
= 0;
1714 // prepare for drawing the text
1718 // Set text color attributes
1720 if (m_textForegroundColour
.Ok())
1723 ,(int)m_textForegroundColour
.GetPixel()
1727 if (m_textBackgroundColour
.Ok())
1729 nOldBackground
= SetTextBkColor( m_hPS
1730 ,(int)m_textBackgroundColour
.GetPixel()
1736 GetTextExtent( rsText
1741 if (!(m_vRclPaint
.yTop
== 0 &&
1742 m_vRclPaint
.yBottom
== 0 &&
1743 m_vRclPaint
.xRight
== 0 &&
1744 m_vRclPaint
.xLeft
== 0))
1746 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1750 if (m_vSelectedBitmap
!= wxNullBitmap
)
1752 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1753 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1754 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1760 PCH pzStr
= (PCH
)rsText
.c_str();
1762 ::GpiMove(m_hPS
, &vPtlStart
);
1763 lHits
= ::GpiCharString( m_hPS
1767 if (lHits
!= GPI_OK
)
1769 wxLogLastError(wxT("TextOut"));
1773 // Restore the old parameters (text foreground colour may be left because
1774 // it never is set to anything else, but background should remain
1775 // transparent even if we just drew an opaque string)
1777 if (m_textBackgroundColour
.Ok())
1778 SetTextBkColor( m_hPS
1786 void wxDC::DoDrawRotatedText(
1787 const wxString
& rsText
1805 DoDrawText(text, x, y);
1810 wxFillLogFont(&lf, &m_font);
1812 // GDI wants the angle in tenth of degree
1813 long angle10 = (long)(angle * 10);
1814 lf.lfEscapement = angle10;
1815 lf. lfOrientation = angle10;
1817 HFONT hfont = ::CreateFontIndirect(&lf);
1820 wxLogLastError("CreateFont");
1824 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1826 DrawAnyText(text, x, y);
1828 (void)::SelectObject(GetHdc(), hfontOld);
1831 // call the bounding box by adding all four vertices of the rectangle
1832 // containing the text to it (simpler and probably not slower than
1833 // determining which of them is really topmost/leftmost/...)
1835 GetTextExtent(text, &w, &h);
1837 double rad = DegToRad(angle);
1839 // "upper left" and "upper right"
1840 CalcBoundingBox(x, y);
1841 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1842 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1844 // "bottom left" and "bottom right"
1845 x += (wxCoord)(h*sin(rad));
1846 y += (wxCoord)(h*cos(rad));
1847 CalcBoundingBox(x, y);
1848 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1853 // ---------------------------------------------------------------------------
1855 // ---------------------------------------------------------------------------
1857 void wxDC::DoSelectPalette( bool WXUNUSED(bRealize
) )
1860 // Set the old object temporarily, in case the assignment deletes an object
1861 // that's not yet selected out.
1872 hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1874 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1876 } // end of wxDC::DoSelectPalette
1878 void wxDC::InitializePalette()
1880 if (wxDisplayDepth() <= 8 )
1883 // Look for any window or parent that has a custom palette. If any has
1884 // one then we need to use it in drawing operations
1886 wxWindow
* pWin
= m_pCanvas
->GetAncestorWithCustomPalette();
1888 m_hasCustomPalette
= pWin
&& pWin
->HasCustomPalette();
1889 if (m_hasCustomPalette
)
1891 m_palette
= pWin
->GetPalette();
1894 // turn on PM translation for this palette
1899 } // end of wxDC::InitializePalette
1901 void wxDC::SetPalette(
1902 const wxPalette
& rPalette
1909 m_palette
= rPalette
;
1917 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1919 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1920 } // end of wxDC::SetPalette
1927 // Set the old object temporarily, in case the assignment deletes an object
1928 // that's not yet selected out.
1940 m_font
.SetPS(m_hPS
); // this will realize the font
1944 HFONT hFont
= m_font
.GetResourceHandle();
1945 if (hFont
== (HFONT
) NULL
)
1947 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
1950 m_hOldFont
= (WXHFONT
) hFont
;
1952 } // end of wxDC::SetFont
1958 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1974 m_pen
.SetPS((HPS
)m_hOldPen
);
1981 if (m_pen
.GetResourceHandle())
1985 m_hOldPen
= m_pen
.GetPS();
1987 ::GpiSetColor(m_hPS
, m_pen
.GetColour().GetPixel());
1991 void wxDC::SetBrush(
1992 const wxBrush
& rBrush
1995 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2001 if (m_brush
== rBrush
)
2011 m_brush
.SetPS((HPS
)m_hOldBrush
);
2018 if (m_brush
.GetResourceHandle())
2020 m_brush
.SetPS(m_hPS
);
2022 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
2025 } // end of wxDC::SetBrush
2027 void wxDC::SetBackground(const wxBrush
& rBrush
)
2029 m_backgroundBrush
= rBrush
;
2031 if (m_backgroundBrush
.Ok())
2033 (void)::GpiSetBackColor((HPS
)m_hPS
, m_backgroundBrush
.GetColour().GetPixel());
2035 } // end of wxDC::SetBackground
2037 void wxDC::SetBackgroundMode(int nMode
)
2039 m_backgroundMode
= nMode
;
2040 } // end of wxDC::SetBackgroundMode
2042 void wxDC::SetLogicalFunction(int nFunction
)
2044 m_logicalFunction
= nFunction
;
2045 SetRop((WXHDC
)m_hDC
);
2046 } // wxDC::SetLogicalFunction
2048 void wxDC::SetRop(WXHDC hDC
)
2050 if (!hDC
|| m_logicalFunction
< 0)
2054 switch (m_logicalFunction
)
2065 lCRop
= FM_MERGESRCNOT
;
2069 lCRop
= FM_NOTMASKSRC
;
2081 lCRop
= FM_MERGENOTSRC
;
2085 lCRop
= FM_MERGESRCNOT
;
2097 lCRop
= FM_SUBTRACT
;
2104 lCRop
= FM_OVERPAINT
;
2107 ::GpiSetMix((HPS
)hDC
, lCRop
);
2108 } // end of wxDC::SetRop
2110 bool wxDC::StartDoc( const wxString
& WXUNUSED(rsMessage
) )
2112 // We might be previewing, so return true to let it continue.
2114 } // end of wxDC::StartDoc
2118 } // end of wxDC::EndDoc
2120 void wxDC::StartPage()
2122 } // end of wxDC::StartPage
2124 void wxDC::EndPage()
2126 } // end of wxDC::EndPage
2128 // ---------------------------------------------------------------------------
2130 // ---------------------------------------------------------------------------
2132 wxCoord
wxDC::GetCharHeight() const
2134 FONTMETRICS vFM
; // metrics structure
2136 ::GpiQueryFontMetrics( m_hPS
2137 ,sizeof(FONTMETRICS
)
2140 return YDEV2LOGREL(vFM
.lXHeight
);
2143 wxCoord
wxDC::GetCharWidth() const
2145 FONTMETRICS vFM
; // metrics structure
2147 ::GpiQueryFontMetrics( m_hPS
2148 ,sizeof(FONTMETRICS
)
2151 return XDEV2LOGREL(vFM
.lAveCharWidth
);
2154 void wxDC::DoGetTextExtent(
2155 const wxString
& rsString
2158 , wxCoord
* pvDescent
2159 , wxCoord
* pvExternalLeading
2163 POINTL avPoint
[TXTBOX_COUNT
];
2168 FONTMETRICS vFM
; // metrics structure
2170 ERRORID vErrorCode
; // last error id code
2171 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
2173 wxChar zMsg
[128]; // DEBUG
2177 pFontToUse
= (wxFont
*)&m_font
;
2178 l
= rsString
.length();
2181 // In world coordinates.
2183 bRc
= ::GpiQueryTextBox( m_hPS
2185 ,(PCH
)rsString
.c_str()
2186 ,TXTBOX_COUNT
// return maximum information
2187 ,avPoint
// array of coordinates points
2191 vErrorCode
= ::WinGetLastError(wxGetInstance());
2192 sError
= wxPMErrorToStr(vErrorCode
);
2194 wxSprintf(zMsg
, _T("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString
.c_str(), vErrorCode
, sError
.c_str());
2195 (void)wxMessageBox( _T("wxWidgets Menu sample")
2201 vPtMin
.x
= avPoint
[0].x
;
2202 vPtMax
.x
= avPoint
[0].x
;
2203 vPtMin
.y
= avPoint
[0].y
;
2204 vPtMax
.y
= avPoint
[0].y
;
2205 for (i
= 1; i
< 4; i
++)
2207 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
2208 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
2209 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
2210 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
2212 ::GpiQueryFontMetrics( m_hPS
2213 ,sizeof(FONTMETRICS
)
2218 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
2220 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
2222 *pvDescent
= vFM
.lMaxDescender
;
2223 if (pvExternalLeading
)
2224 *pvExternalLeading
= vFM
.lExternalLeading
;
2227 void wxDC::SetMapMode(
2231 int nPixelWidth
= 0;
2232 int nPixelHeight
= 0;
2235 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2237 m_mappingMode
= nMode
;
2239 if(::DevQueryCaps( m_hDC
2241 ,CAPS_VERTICAL_RESOLUTION
2248 nPixelWidth
= lArray
[CAPS_WIDTH
];
2249 nPixelHeight
= lArray
[CAPS_HEIGHT
];
2250 lHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2251 lVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2252 nMmWidth
= (lHorzRes
/1000) * nPixelWidth
;
2253 nMmWidth
= (lVertRes
/1000) * nPixelHeight
;
2255 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
2260 double dMm2pixelsX
= nPixelWidth
/nMmWidth
;
2261 double dMm2pixelsY
= nPixelHeight
/nMmHeight
;
2266 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
2267 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
2271 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
2272 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
2276 m_logicalScaleX
= dMm2pixelsX
;
2277 m_logicalScaleY
= dMm2pixelsY
;
2281 m_logicalScaleX
= (dMm2pixelsX
/10.0);
2282 m_logicalScaleY
= (dMm2pixelsY
/10.0);
2287 m_logicalScaleX
= 1.0;
2288 m_logicalScaleY
= 1.0;
2294 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
2295 if (!ulOptions
& PU_ARBITRARY
)
2297 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
2298 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
2300 m_nWindowExtX
= (int)MS_XDEV2LOG(VIEWPORT_EXTENT
);
2301 m_nWindowExtY
= (int)MS_YDEV2LOG(VIEWPORT_EXTENT
);
2303 }; // end of wxDC::SetMapMode
2305 void wxDC::SetUserScale( double dX
,
2311 SetMapMode(m_mappingMode
);
2312 } // end of wxDC::SetUserScale
2314 void wxDC::SetAxisOrientation( bool bXLeftRight
,
2317 m_signX
= bXLeftRight
? 1 : -1;
2318 m_signY
= bYBottomUp
? -1 : 1;
2320 SetMapMode(m_mappingMode
);
2321 } // end of wxDC::SetAxisOrientation
2323 void wxDC::SetSystemScale(
2331 SetMapMode(m_mappingMode
);
2332 } // end of wxDC::SetSystemScale
2334 void wxDC::SetLogicalOrigin(
2341 ::GpiQueryPageViewport( m_hPS
2348 ::GpiSetPageViewport( m_hPS
2351 }; // end of wxDC::SetLogicalOrigin
2353 void wxDC::SetDeviceOrigin(
2360 m_deviceOriginX
= vX
;
2361 m_deviceOriginY
= vY
;
2362 ::GpiQueryPageViewport( m_hPS
2367 vRect
.yBottom
-= vY
;
2369 ::GpiSetPageViewport( m_hPS
2372 }; // end of wxDC::SetDeviceOrigin
2374 // ---------------------------------------------------------------------------
2375 // coordinates transformations
2376 // ---------------------------------------------------------------------------
2378 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2380 return (wxCoord
) (((x
) - m_deviceOriginX
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
) - m_logicalOriginX
);
2383 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2385 // axis orientation is not taken into account for conversion of a distance
2386 return (wxCoord
) ((x
)/(m_logicalScaleX
*m_userScaleX
*m_scaleX
));
2389 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2391 return (wxCoord
) (((y
) - m_deviceOriginY
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
) - m_logicalOriginY
);
2394 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2396 // axis orientation is not taken into account for conversion of a distance
2397 return (wxCoord
) ((y
)/(m_logicalScaleY
*m_userScaleY
*m_scaleY
));
2400 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2402 return (wxCoord
) ((x
- m_logicalOriginX
)*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
+ m_deviceOriginX
);
2405 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2407 // axis orientation is not taken into account for conversion of a distance
2408 return (wxCoord
) (x
*m_logicalScaleX
*m_userScaleX
*m_scaleX
);
2411 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2413 return (wxCoord
) ((y
- m_logicalOriginY
)*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
+ m_deviceOriginY
);
2416 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2418 // axis orientation is not taken into account for conversion of a distance
2419 return (wxCoord
) (y
*m_logicalScaleY
*m_userScaleY
*m_scaleY
);
2422 // ---------------------------------------------------------------------------
2424 // ---------------------------------------------------------------------------
2426 bool wxDC::DoBlit( wxCoord vXdest
,
2435 wxCoord
WXUNUSED(vXsrcMask
),
2436 wxCoord
WXUNUSED(vYsrcMask
) )
2438 wxMask
* pMask
= NULL
;
2440 COLORREF vOldTextColor
;
2441 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
2445 const wxBitmap
& rBmp
= pSource
->m_vSelectedBitmap
;
2447 pMask
= rBmp
.GetMask();
2448 if (!(rBmp
.Ok() && pMask
&& pMask
->GetMaskBitmap()))
2454 ::GpiQueryAttrs( m_hPS
2459 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
2461 if (m_textForegroundColour
.Ok())
2463 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
2464 ::GpiSetAttrs( m_hPS
// presentation-space handle
2465 ,PRIM_CHAR
// Char primitive.
2466 ,CBB_COLOR
// sets color.
2468 ,&vCbnd
// buffer for attributes.
2471 if (m_textBackgroundColour
.Ok())
2473 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
2476 LONG lRop
= ROP_SRCCOPY
;
2480 case wxXOR
: lRop
= ROP_SRCINVERT
; break;
2481 case wxINVERT
: lRop
= ROP_DSTINVERT
; break;
2482 case wxOR_REVERSE
: lRop
= 0x00DD0228; break;
2483 case wxAND_REVERSE
: lRop
= ROP_SRCERASE
; break;
2484 case wxCLEAR
: lRop
= ROP_ZERO
; break;
2485 case wxSET
: lRop
= ROP_ONE
; break;
2486 case wxOR_INVERT
: lRop
= ROP_MERGEPAINT
; break;
2487 case wxAND
: lRop
= ROP_SRCAND
; break;
2488 case wxOR
: lRop
= ROP_SRCPAINT
; break;
2489 case wxEQUIV
: lRop
= 0x00990066; break;
2490 case wxNAND
: lRop
= 0x007700E6; break;
2491 case wxAND_INVERT
: lRop
= 0x00220326; break;
2492 case wxCOPY
: lRop
= ROP_SRCCOPY
; break;
2493 case wxNO_OP
: lRop
= ROP_NOTSRCERASE
; break;
2494 case wxSRC_INVERT
: lRop
= ROP_SRCINVERT
; break;
2495 case wxNOR
: lRop
= ROP_NOTSRCCOPY
; break;
2497 wxFAIL_MSG( wxT("unsupported logical function") );
2506 // Blit bitmap with mask
2510 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2516 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
2517 BITMAPINFOHEADER2 vBmpHdr
;
2519 SIZEL vSize
= {0, 0};
2522 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
2523 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
2524 vBmpHdr
.cx
= vWidth
;
2525 vBmpHdr
.cy
= vHeight
;
2526 vBmpHdr
.cPlanes
= 1;
2527 vBmpHdr
.cBitCount
= 24;
2529 #if wxUSE_DC_CACHEING
2532 // create a temp buffer bitmap and DCs to access it and the mask
2534 wxDCCacheEntry
* pDCCacheEntry1
= FindDCInCache( NULL
2537 wxDCCacheEntry
* pDCCacheEntry2
= FindDCInCache( pDCCacheEntry1
2540 wxDCCacheEntry
* pBitmapCacheEntry
= FindBitmapInCache( GetHPS()
2545 hPSMask
= pDCCacheEntry1
->m_hPS
;
2546 hDCBuffer
= (HDC
)pDCCacheEntry2
->m_hPS
;
2547 hBufBitmap
= (HBITMAP
)pBitmapCacheEntry
->m_hBitmap
;
2548 wxUnusedVar(hDCMask
);
2552 hDCMask
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2553 hDCBuffer
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2554 hPSMask
= ::GpiCreatePS(vHabmain
, hDCMask
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2555 hPSBuffer
= ::GpiCreatePS(vHabmain
, hDCBuffer
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2556 hBufBitmap
= ::GpiCreateBitmap(GetHPS(), &vBmpHdr
, 0L, NULL
, NULL
);
2560 POINTL aPoint1
[4] = { {0, 0}
2563 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2565 POINTL aPoint2
[4] = { {0, 0}
2568 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2570 POINTL aPoint3
[4] = { {vXdest
, vYdest
}
2571 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2573 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2575 POINTL aPoint4
[4] = { {vXdest
, vYdest
}
2576 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2580 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
2581 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
2584 // Copy dest to buffer
2586 rc
= ::GpiBitBlt( hPSBuffer
2593 if (rc
== GPI_ERROR
)
2595 wxLogLastError(wxT("BitBlt"));
2599 // Copy src to buffer using selected raster op
2601 rc
= ::GpiBitBlt( hPSBuffer
2608 if (rc
== GPI_ERROR
)
2610 wxLogLastError(wxT("BitBlt"));
2614 // Set masked area in buffer to BLACK (pixel value 0)
2616 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
2617 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
2619 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2620 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2622 rc
= ::GpiBitBlt( hPSBuffer
2629 if (rc
== GPI_ERROR
)
2631 wxLogLastError(wxT("BitBlt"));
2635 // Set unmasked area in dest to BLACK
2637 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2638 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2639 rc
= ::GpiBitBlt( GetHPS()
2646 if (rc
== GPI_ERROR
)
2648 wxLogLastError(wxT("BitBlt"));
2652 // Restore colours to original values
2654 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
2655 ::GpiSetColor(GetHPS(), vPrevCol
);
2658 // OR buffer to dest
2660 rc
= ::GpiBitBlt( GetHPS()
2667 if (rc
== GPI_ERROR
)
2670 wxLogLastError(wxT("BitBlt"));
2674 // Tidy up temporary DCs and bitmap
2676 ::GpiSetBitmap(hPSMask
, NULLHANDLE
);
2677 ::GpiSetBitmap(hPSBuffer
, NULLHANDLE
);
2678 #if !wxUSE_DC_CACHEING
2679 ::GpiDestroyPS(hPSMask
);
2680 ::GpiDestroyPS(hPSBuffer
);
2681 ::DevCloseDC(hDCMask
);
2682 ::DevCloseDC(hDCBuffer
);
2683 ::GpiDeleteBitmap(hBufBitmap
);
2687 else // no mask, just BitBlt() it
2689 POINTL aPoint
[4] = { {vXdest
, vYdest
}
2690 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2692 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2695 bSuccess
= (::GpiBitBlt( m_hPS
2704 wxLogLastError(wxT("BitBlt"));
2707 vCbnd
.lColor
= (LONG
)vOldTextColor
;
2708 ::GpiSetAttrs( m_hPS
// presentation-space handle
2709 ,PRIM_CHAR
// Char primitive.
2710 ,CBB_COLOR
// sets color.
2712 ,&vCbnd
// buffer for attributes.
2714 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
2718 void wxDC::DoGetSize( int* pnWidth
,
2719 int* pnHeight
) const
2721 LONG lArray
[CAPS_HEIGHT
];
2723 if(::DevQueryCaps( m_hDC
2729 *pnWidth
= lArray
[CAPS_WIDTH
];
2730 *pnHeight
= lArray
[CAPS_HEIGHT
];
2732 }; // end of wxDC::DoGetSize(
2734 void wxDC::DoGetSizeMM( int* pnWidth
,
2735 int* pnHeight
) const
2737 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2739 if(::DevQueryCaps( m_hDC
2741 ,CAPS_VERTICAL_RESOLUTION
2747 int nWidth
= lArray
[CAPS_WIDTH
];
2748 int nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2749 *pnWidth
= (nHorzRes
/1000) * nWidth
;
2754 int nHeight
= lArray
[CAPS_HEIGHT
];
2755 int nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2756 *pnHeight
= (nVertRes
/1000) * nHeight
;
2759 }; // end of wxDC::DoGetSizeMM
2761 wxSize
wxDC::GetPPI() const
2763 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2767 if(::DevQueryCaps( m_hDC
2769 ,CAPS_VERTICAL_RESOLUTION
2778 nPelWidth
= lArray
[CAPS_WIDTH
];
2779 nPelHeight
= lArray
[CAPS_HEIGHT
];
2780 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2781 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2782 nWidth
= (int)((nHorzRes
/39.3) * nPelWidth
);
2783 nHeight
= (int)((nVertRes
/39.3) * nPelHeight
);
2785 wxSize
ppisize(nWidth
, nHeight
);
2787 } // end of wxDC::GetPPI
2789 void wxDC::SetLogicalScale( double dX
, double dY
)
2791 m_logicalScaleX
= dX
;
2792 m_logicalScaleY
= dY
;
2793 }; // end of wxDC::SetLogicalScale