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( int n
,
857 ULONG ulCount
= 1; // Number of polygons.
858 POLYGON vPlgn
; // polygon.
859 ULONG flOptions
= 0L; // Drawing options.
861 //////////////////////////////////////////////////////////////////////////////
862 // This contains fields of option bits... to draw boundary lines as well as
863 // the area interior.
865 // Drawing boundary lines:
866 // POLYGON_NOBOUNDARY Does not draw boundary lines.
867 // POLYGON_BOUNDARY Draws boundary lines (the default).
869 // Construction of the area interior:
870 // POLYGON_ALTERNATE Constructs interior in alternate mode
872 // POLYGON_WINDING Constructs interior in winding mode.
873 //////////////////////////////////////////////////////////////////////////////
875 ULONG flModel
= POLYGON_INCL
; // Drawing model.
877 //////////////////////////////////////////////////////////////////////////////
879 // POLYGON_INCL Fill is inclusive of bottom right (the default).
880 // POLYGON_EXCL Fill is exclusive of bottom right.
881 // This is provided to aid migration from other graphics models.
882 //////////////////////////////////////////////////////////////////////////////
884 LONG lHits
= 0L; // Correlation/error indicator.
886 int nIsTRANSPARENT
= 0;
887 LONG lBorderColor
= 0L;
890 lBorderColor
= m_pen
.GetColour().GetPixel();
891 lColor
= m_brush
.GetColour().GetPixel();
892 if(m_brush
.GetStyle() == wxTRANSPARENT
)
896 vPlgn
.aPointl
= (POINTL
*) calloc( n
+ 1
898 ); // well, new will call malloc
900 for(i
= 0; i
< n
; i
++)
902 vPlgn
.aPointl
[i
].x
= vPoints
[i
].x
+vXoffset
;
903 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
+vYoffset
,0);
905 flOptions
= POLYGON_BOUNDARY
;
906 if(nFillStyle
== wxWINDING_RULE
)
907 flOptions
|= POLYGON_WINDING
;
909 flOptions
|= POLYGON_ALTERNATE
;
911 ::GpiSetColor(m_hPS
, lBorderColor
);
912 ::GpiMove(m_hPS
, &vPlgn
.aPointl
[0]);
913 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
915 } // end of wxDC::DoDrawPolygon
917 void wxDC::DoDrawLines(
926 if (vXoffset
!= 0L || vXoffset
!= 0L)
930 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
931 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
932 ::GpiMove(m_hPS
, &vPoint
);
934 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
936 ::GpiSetColor(m_hPS
, lBorderColor
);
937 for(i
= 1; i
< n
; i
++)
939 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
940 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
941 ::GpiLine(m_hPS
, &vPoint
);
948 CalcBoundingBox( vPoints
[0].x
951 vPoint
.x
= vPoints
[0].x
;
952 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
953 ::GpiMove(m_hPS
, &vPoint
);
955 for (i
= 0; i
< n
; i
++)
957 CalcBoundingBox( vPoints
[i
].x
960 vPoint
.x
= vPoints
[i
].x
;
961 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
962 ::GpiLine(m_hPS
, &vPoint
);
965 } // end of wxDC::DoDrawLines
967 void wxDC::DoDrawRectangle(
978 int nIsTRANSPARENT
= 0;
981 // Might be a memory DC with no Paint rect.
983 if (!(m_vRclPaint
.yTop
== 0 &&
984 m_vRclPaint
.yBottom
== 0 &&
985 m_vRclPaint
.xRight
== 0 &&
986 m_vRclPaint
.xLeft
== 0))
987 vY
= OS2Y(vY
,vHeight
);
990 if (m_vSelectedBitmap
!= wxNullBitmap
)
992 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
993 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
994 vY
= OS2Y(vY
,vHeight
);
998 wxCoord vX2
= vX
+ vWidth
;
999 wxCoord vY2
= vY
+ vHeight
;
1003 vPoint
[1].x
= vX
+ vWidth
- 1;
1004 vPoint
[1].y
= vY
+ vHeight
- 1;
1005 ::GpiMove(m_hPS
, &vPoint
[0]);
1006 lColor
= m_brush
.GetColour().GetPixel();
1007 lBorderColor
= m_pen
.GetColour().GetPixel();
1008 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1010 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1012 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1013 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1014 lControl
= DRO_OUTLINE
;
1016 ::GpiSetColor(m_hPS
, lBorderColor
);
1017 ::GpiBox( m_hPS
// handle to a presentation space
1018 ,lControl
// draw the box outline ? or ?
1019 ,&vPoint
[1] // address of the corner
1020 ,0L // horizontal corner radius
1021 ,0L // vertical corner radius
1026 lControl
= DRO_OUTLINE
;
1027 ::GpiSetColor( m_hPS
1036 lControl
= DRO_FILL
;
1037 ::GpiSetColor( m_hPS
1040 vPoint
[0].x
= vX
+ 1;
1041 vPoint
[0].y
= vY
+ 1;
1042 vPoint
[1].x
= vX
+ vWidth
- 2;
1043 vPoint
[1].y
= vY
+ vHeight
- 2;
1044 ::GpiMove(m_hPS
, &vPoint
[0]);
1052 CalcBoundingBox(vX
, vY
);
1053 CalcBoundingBox(vX2
, vY2
);
1054 } // end of wxDC::DoDrawRectangle
1056 void wxDC::DoDrawRoundedRectangle(
1068 int nIsTRANSPARENT
= 0;
1071 // Might be a memory DC with no Paint rect.
1073 if (!(m_vRclPaint
.yTop
== 0 &&
1074 m_vRclPaint
.yBottom
== 0 &&
1075 m_vRclPaint
.xRight
== 0 &&
1076 m_vRclPaint
.xLeft
== 0))
1077 vY
= OS2Y(vY
,vHeight
);
1080 if (m_vSelectedBitmap
!= wxNullBitmap
)
1082 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1083 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1084 vY
= OS2Y(vY
,vHeight
);
1088 wxCoord vX2
= (vX
+ vWidth
);
1089 wxCoord vY2
= (vY
+ vHeight
);
1093 vPoint
[1].x
= vX
+ vWidth
- 1;
1094 vPoint
[1].y
= vY
+ vHeight
- 1;
1095 ::GpiMove(m_hPS
, &vPoint
[0]);
1097 lColor
= m_brush
.GetColour().GetPixel();
1098 lBorderColor
= m_pen
.GetColour().GetPixel();
1099 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1100 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1102 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1104 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1105 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1106 lControl
= DRO_OUTLINE
;
1108 ::GpiSetColor(m_hPS
, lColor
);
1109 ::GpiBox( m_hPS
// handle to a presentation space
1110 ,lControl
// draw the box outline ? or ?
1111 ,&vPoint
[1] // address of the corner
1112 ,(LONG
)dRadius
// horizontal corner radius
1113 ,(LONG
)dRadius
// vertical corner radius
1118 lControl
= DRO_OUTLINE
;
1119 ::GpiSetColor( m_hPS
1128 lControl
= DRO_FILL
;
1129 ::GpiSetColor( m_hPS
1132 vPoint
[0].x
= vX
+ 1;
1133 vPoint
[0].y
= vY
+ 1;
1134 vPoint
[1].x
= vX
+ vWidth
- 2;
1135 vPoint
[1].y
= vY
+ vHeight
- 2;
1136 ::GpiMove(m_hPS
, &vPoint
[0]);
1145 CalcBoundingBox(vX
, vY
);
1146 CalcBoundingBox(vX2
, vY2
);
1147 } // end of wxDC::DoDrawRoundedRectangle
1149 // Draw Ellipse within box (x,y) - (x+width, y+height)
1150 void wxDC::DoDrawEllipse(
1157 POINTL vPtlPos
; // Structure for current position
1158 FIXED vFxMult
; // Multiplier for ellipse
1159 ARCPARAMS vArcp
; // Structure for arc parameters
1161 vY
= OS2Y(vY
,vHeight
);
1164 vArcp
.lQ
= vHeight
/2;
1165 vArcp
.lP
= vWidth
/2;
1167 ::GpiSetArcParams( m_hPS
1169 ); // Sets parameters to default
1170 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
1171 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1174 ); // Sets current position
1175 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
1178 // DRO_FILL, DRO_OTLINEFILL - where to get
1183 ); // Draws full arc with center at current position
1185 wxCoord vX2
= (vX
+ vWidth
);
1186 wxCoord vY2
= (vY
+ vHeight
);
1188 CalcBoundingBox(vX
, vY
);
1189 CalcBoundingBox(vX2
, vY2
);
1190 } // end of wxDC::DoDrawEllipse
1192 void wxDC::DoDrawEllipticArc(
1201 POINTL vPtlPos
; // Structure for current position
1202 FIXED vFxMult
; // Multiplier for ellipse
1203 ARCPARAMS vArcp
; // Structure for arc parameters
1205 FIXED vFSweepa
; // Start angle, sweep angle
1209 vY
= OS2Y(vY
,vHeight
);
1211 dFractPart
= modf(dSa
,&dIntPart
);
1212 vFSa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1213 dFractPart
= modf(dEa
- dSa
, &dIntPart
);
1214 vFSweepa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1217 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1220 vArcp
.lQ
= vHeight
/2;
1221 vArcp
.lP
= vWidth
/2;
1223 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
1224 vPtlPos
.x
= (wxCoord
)(vX
+ vWidth
/2 * (1. + cos(DegToRad(dSa
)))); // Loads x-coordinate
1225 vPtlPos
.y
= (wxCoord
)(vY
+ vHeight
/2 * (1. + sin(DegToRad(dSa
)))); // Loads y-coordinate
1226 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
1229 // May be not to the center ?
1231 vPtlPos
.x
= vX
+ vWidth
/2 ; // Loads x-coordinate
1232 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1233 vFxMult
= MAKEFIXED(1, 0); // Sets multiplier
1236 // DRO_FILL, DRO_OTLINEFILL - where to get
1238 ::GpiPartialArc( m_hPS
1244 wxCoord vX2
= (vX
+ vWidth
);
1245 wxCoord vY2
= (vY
+ vHeight
);
1247 CalcBoundingBox(vX
, vY
);
1248 CalcBoundingBox(vX2
, vY2
);
1249 } // end of wxDC::DoDrawEllipticArc
1251 void wxDC::DoDrawIcon(
1258 // Need to copy back into a bitmap. ::WinDrawPointer uses device coords
1259 // and I don't feel like figuring those out for scrollable windows so
1260 // just convert to a bitmap then let the DoDrawBitmap routine display it
1264 DoDrawBitmap(rIcon
.GetXpmSrc(), vX
, vY
, true);
1268 wxBitmap
vBitmap(rIcon
);
1270 DoDrawBitmap(vBitmap
, vX
, vY
, false);
1272 CalcBoundingBox(vX
, vY
);
1273 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
1274 } // end of wxDC::DoDrawIcon
1276 void wxDC::DoDrawBitmap(
1277 const wxBitmap
& rBmp
1283 #if wxUSE_PRINTING_ARCHITECTURE
1284 if (!IsKindOf(CLASSINFO(wxPrinterDC
)))
1287 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
1288 HBITMAP hBitmapOld
= NULLHANDLE
;
1291 vY
= OS2Y(vY
,rBmp
.GetHeight());
1294 vPoint
[0].y
= vY
+ rBmp
.GetHeight();
1295 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1299 vPoint
[3].x
= rBmp
.GetWidth();
1300 vPoint
[3].y
= rBmp
.GetHeight();
1303 wxMask
* pMask
= rBmp
.GetMask();
1308 // Need to imitate ::MaskBlt in windows.
1309 // 1) Extract the bits from from the bitmap.
1310 // 2) Extract the bits from the mask
1311 // 3) Using the mask bits do the following:
1312 // A) If the mask byte is 00 leave the bitmap byte alone
1313 // B) If the mask byte is FF copy the screen color into
1315 // 4) Create a new bitmap and set its bits to the above result
1316 // 5) Blit this to the screen PS
1318 HBITMAP hMask
= (HBITMAP
)pMask
->GetMaskBitmap();
1319 HBITMAP hOldMask
= NULLHANDLE
;
1320 HBITMAP hOldBitmap
= NULLHANDLE
;
1321 HBITMAP hNewBitmap
= NULLHANDLE
;
1322 unsigned char* pucBits
; // buffer that will contain the bitmap data
1323 unsigned char* pucBitsMask
; // buffer that will contain the mask data
1324 unsigned char* pucData
; // pointer to use to traverse bitmap data
1325 unsigned char* pucDataMask
; // pointer to use to traverse mask data
1331 // The usual Memory context creation stuff
1333 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1334 SIZEL vSize
= {0, 0};
1335 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1336 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1339 // The usual bitmap header stuff
1341 BITMAPINFOHEADER2 vHeader
;
1344 memset(&vHeader
, '\0', 16);
1347 memset(&vInfo
, '\0', 16);
1349 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1350 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1352 vInfo
.cBitCount
= 24; // Set to desired count going in
1355 // Create the buffers for data....all wxBitmaps are 24 bit internally
1357 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1358 int nSizeDWORD
= sizeof(DWORD
);
1359 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
1367 // Need to get a background color for mask blitting
1369 if (IsKindOf(CLASSINFO(wxWindowDC
)))
1371 wxWindowDC
* pWindowDC
= wxDynamicCast(this, wxWindowDC
);
1373 lColor
= pWindowDC
->m_pCanvas
->GetBackgroundColour().GetPixel();
1375 else if (GetBrush().Ok())
1376 lColor
= GetBrush().GetColour().GetPixel();
1378 lColor
= m_textBackgroundColour
.GetPixel();
1381 // Bitmap must be in a double-word aligned address so we may
1382 // have some padding to worry about
1384 if (nLineBoundary
> 0)
1386 nPadding
= nSizeDWORD
- nLineBoundary
;
1387 nBytesPerLine
+= nPadding
;
1389 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1390 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1391 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1392 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1395 // Extract the bitmap and mask data
1397 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1399 vError
= ::WinGetLastError(vHabmain
);
1400 sError
= wxPMErrorToStr(vError
);
1402 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
1403 vInfo
.cBitCount
= 24;
1404 if ((lScans
= ::GpiQueryBitmapBits( hPS
1406 ,(LONG
)rBmp
.GetHeight()
1411 vError
= ::WinGetLastError(vHabmain
);
1412 sError
= wxPMErrorToStr(vError
);
1414 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
1416 vError
= ::WinGetLastError(vHabmain
);
1417 sError
= wxPMErrorToStr(vError
);
1419 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
1420 vInfo
.cBitCount
= 24;
1421 if ((lScans
= ::GpiQueryBitmapBits( hPS
1423 ,(LONG
)rBmp
.GetHeight()
1428 vError
= ::WinGetLastError(vHabmain
);
1429 sError
= wxPMErrorToStr(vError
);
1431 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
1433 vError
= ::WinGetLastError(vHabmain
);
1434 sError
= wxPMErrorToStr(vError
);
1438 // Now set the bytes(bits) according to the mask values
1439 // 3 bytes per pel...must handle one at a time
1442 pucDataMask
= pucBitsMask
;
1445 // 16 bit kludge really only kinda works. The mask gets applied
1446 // where needed but the original bitmap bits are dorked sometimes
1448 bool bpp16
= (wxDisplayDepth() == 16);
1450 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1452 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1455 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1457 else if (*pucDataMask
== 0xFF) // leave bitmap byte alone
1461 *pucData
= ((unsigned char)(lColor
>> 16));
1465 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1467 else if (*(pucDataMask
+ 1) == 0xFF) // leave bitmap byte alone
1471 *pucData
= ((unsigned char)(lColor
>> 8));
1476 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1478 else if (*(pucDataMask
+ 2) == 0xFF) // leave bitmap byte alone
1482 *pucData
= ((unsigned char)lColor
);
1487 for (j
= 0; j
< nPadding
; j
++)
1494 // Create a new bitmap
1496 vHeader
.cx
= (ULONG
)rBmp
.GetWidth();
1497 vHeader
.cy
= (ULONG
)rBmp
.GetHeight();
1498 vHeader
.cPlanes
= 1L;
1499 vHeader
.cBitCount
= 24;
1500 if ((hNewBitmap
= ::GpiCreateBitmap( hPS
1507 vError
= ::WinGetLastError(vHabmain
);
1508 sError
= wxPMErrorToStr(vError
);
1512 // Now blit it to the screen PS
1514 if ((lHits
= ::GpiWCBitBlt( (HPS
)GetHPS()
1522 vError
= ::WinGetLastError(vHabmain
);
1523 sError
= wxPMErrorToStr(vError
);
1531 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1532 ::GpiDeleteBitmap(hNewBitmap
);
1533 ::GpiDestroyPS(hPS
);
1539 ULONG lOldForeGround
= ::GpiQueryColor((HPS
)GetHPS());
1540 ULONG lOldBackGround
= ::GpiQueryBackColor((HPS
)GetHPS());
1542 if (m_textForegroundColour
.Ok())
1544 ::GpiSetColor( (HPS
)GetHPS()
1545 ,m_textForegroundColour
.GetPixel()
1548 if (m_textBackgroundColour
.Ok())
1550 ::GpiSetBackColor( (HPS
)GetHPS()
1551 ,m_textBackgroundColour
.GetPixel()
1555 // Need to alter bits in a mono bitmap to match the new
1556 // background-foreground if it is different.
1558 if (rBmp
.IsMono() &&
1559 ((m_textForegroundColour
.GetPixel() != lOldForeGround
) ||
1560 (m_textBackgroundColour
.GetPixel() != lOldBackGround
)))
1562 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1563 SIZEL vSize
= {0, 0};
1564 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1565 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1567 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1569 LONG lForeGround
= m_textForegroundColour
.GetPixel();
1570 LONG lBackGround
= m_textBackgroundColour
.GetPixel();
1572 HBITMAP hOldBitmap
= NULLHANDLE
;
1578 memset(&vInfo
, '\0', 16);
1580 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1581 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1583 vInfo
.cBitCount
= 24;
1585 unsigned char* pucBits
; // buffer that will contain the bitmap data
1586 unsigned char* pucData
; // pointer to use to traverse bitmap data
1588 pucBits
= new unsigned char[nBytesPerLine
* rBmp
.GetHeight()];
1589 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1591 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1593 vError
= ::WinGetLastError(vHabmain
);
1594 sError
= wxPMErrorToStr(vError
);
1597 if ((lScans
= ::GpiQueryBitmapBits( hPS
1599 ,(LONG
)rBmp
.GetHeight()
1604 vError
= ::WinGetLastError(vHabmain
);
1605 sError
= wxPMErrorToStr(vError
);
1608 unsigned char cOldRedFore
= (unsigned char)(lOldForeGround
>> 16);
1609 unsigned char cOldGreenFore
= (unsigned char)(lOldForeGround
>> 8);
1610 unsigned char cOldBlueFore
= (unsigned char)lOldForeGround
;
1612 unsigned char cRedFore
= (unsigned char)(lForeGround
>> 16);
1613 unsigned char cGreenFore
= (unsigned char)(lForeGround
>> 8);
1614 unsigned char cBlueFore
= (unsigned char)lForeGround
;
1616 unsigned char cRedBack
= (unsigned char)(lBackGround
>> 16);
1617 unsigned char cGreenBack
= (unsigned char)(lBackGround
>> 8);
1618 unsigned char cBlueBack
= (unsigned char)lBackGround
;
1621 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1623 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1625 unsigned char cBmpRed
= *pucData
;
1626 unsigned char cBmpGreen
= *(pucData
+ 1);
1627 unsigned char cBmpBlue
= *(pucData
+ 2);
1629 if ((cBmpRed
== cOldRedFore
) &&
1630 (cBmpGreen
== cOldGreenFore
) &&
1631 (cBmpBlue
== cOldBlueFore
))
1633 *pucData
= cBlueFore
;
1635 *pucData
= cGreenFore
;
1637 *pucData
= cRedFore
;
1642 *pucData
= cBlueBack
;
1644 *pucData
= cGreenBack
;
1646 *pucData
= cRedBack
;
1651 if ((lScans
= ::GpiSetBitmapBits( hPS
1653 ,(LONG
)rBmp
.GetHeight()
1658 vError
= ::WinGetLastError(vHabmain
);
1659 sError
= wxPMErrorToStr(vError
);
1663 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1664 ::GpiDestroyPS(hPS
);
1667 ::GpiWCBitBlt( (HPS
)GetHPS()
1674 ::GpiSetBitmap((HPS
)GetHPS(), hBitmapOld
);
1675 ::GpiSetColor((HPS
)GetHPS(), lOldForeGround
);
1676 ::GpiSetBackColor((HPS
)GetHPS(), lOldBackGround
);
1679 } // end of wxDC::DoDrawBitmap
1681 void wxDC::DoDrawText(
1682 const wxString
& rsText
1695 CalcBoundingBox(vX
, vY
);
1696 GetTextExtent(rsText
, &vWidth
, &vHeight
);
1697 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1698 } // end of wxDC::DoDrawText
1700 void wxDC::DrawAnyText( const wxString
& rsText
,
1704 int nOldBackground
= 0;
1711 // prepare for drawing the text
1715 // Set text color attributes
1717 if (m_textForegroundColour
.Ok())
1720 ,(int)m_textForegroundColour
.GetPixel()
1724 if (m_textBackgroundColour
.Ok())
1726 nOldBackground
= SetTextBkColor( m_hPS
1727 ,(int)m_textBackgroundColour
.GetPixel()
1733 GetTextExtent( rsText
1738 if (!(m_vRclPaint
.yTop
== 0 &&
1739 m_vRclPaint
.yBottom
== 0 &&
1740 m_vRclPaint
.xRight
== 0 &&
1741 m_vRclPaint
.xLeft
== 0))
1743 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1747 if (m_vSelectedBitmap
!= wxNullBitmap
)
1749 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1750 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1751 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1757 PCH pzStr
= (PCH
)rsText
.c_str();
1759 ::GpiMove(m_hPS
, &vPtlStart
);
1760 lHits
= ::GpiCharString( m_hPS
1764 if (lHits
!= GPI_OK
)
1766 wxLogLastError(wxT("TextOut"));
1770 // Restore the old parameters (text foreground colour may be left because
1771 // it never is set to anything else, but background should remain
1772 // transparent even if we just drew an opaque string)
1774 if (m_textBackgroundColour
.Ok())
1775 SetTextBkColor( m_hPS
1783 void wxDC::DoDrawRotatedText(
1784 const wxString
& rsText
1802 DoDrawText(text, x, y);
1807 wxFillLogFont(&lf, &m_font);
1809 // GDI wants the angle in tenth of degree
1810 long angle10 = (long)(angle * 10);
1811 lf.lfEscapement = angle10;
1812 lf. lfOrientation = angle10;
1814 HFONT hfont = ::CreateFontIndirect(&lf);
1817 wxLogLastError("CreateFont");
1821 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1823 DrawAnyText(text, x, y);
1825 (void)::SelectObject(GetHdc(), hfontOld);
1828 // call the bounding box by adding all four vertices of the rectangle
1829 // containing the text to it (simpler and probably not slower than
1830 // determining which of them is really topmost/leftmost/...)
1832 GetTextExtent(text, &w, &h);
1834 double rad = DegToRad(angle);
1836 // "upper left" and "upper right"
1837 CalcBoundingBox(x, y);
1838 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1839 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1841 // "bottom left" and "bottom right"
1842 x += (wxCoord)(h*sin(rad));
1843 y += (wxCoord)(h*cos(rad));
1844 CalcBoundingBox(x, y);
1845 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1850 // ---------------------------------------------------------------------------
1852 // ---------------------------------------------------------------------------
1854 void wxDC::DoSelectPalette( bool WXUNUSED(bRealize
) )
1857 // Set the old object temporarily, in case the assignment deletes an object
1858 // that's not yet selected out.
1869 hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1871 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1873 } // end of wxDC::DoSelectPalette
1875 void wxDC::InitializePalette()
1877 if (wxDisplayDepth() <= 8 )
1880 // Look for any window or parent that has a custom palette. If any has
1881 // one then we need to use it in drawing operations
1883 wxWindow
* pWin
= m_pCanvas
->GetAncestorWithCustomPalette();
1885 m_hasCustomPalette
= pWin
&& pWin
->HasCustomPalette();
1886 if (m_hasCustomPalette
)
1888 m_palette
= pWin
->GetPalette();
1891 // turn on PM translation for this palette
1896 } // end of wxDC::InitializePalette
1898 void wxDC::SetPalette(
1899 const wxPalette
& rPalette
1906 m_palette
= rPalette
;
1914 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1916 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1917 } // end of wxDC::SetPalette
1924 // Set the old object temporarily, in case the assignment deletes an object
1925 // that's not yet selected out.
1937 m_font
.SetPS(m_hPS
); // this will realize the font
1941 HFONT hFont
= m_font
.GetResourceHandle();
1942 if (hFont
== (HFONT
) NULL
)
1944 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
1947 m_hOldFont
= (WXHFONT
) hFont
;
1949 } // end of wxDC::SetFont
1955 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1971 m_pen
.SetPS((HPS
)m_hOldPen
);
1978 if (m_pen
.GetResourceHandle())
1982 m_hOldPen
= m_pen
.GetPS();
1984 ::GpiSetColor(m_hPS
, m_pen
.GetColour().GetPixel());
1988 void wxDC::SetBrush(
1989 const wxBrush
& rBrush
1992 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1998 if (m_brush
== rBrush
)
2008 m_brush
.SetPS((HPS
)m_hOldBrush
);
2015 if (m_brush
.GetResourceHandle())
2017 m_brush
.SetPS(m_hPS
);
2019 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
2022 } // end of wxDC::SetBrush
2024 void wxDC::SetBackground(const wxBrush
& rBrush
)
2026 m_backgroundBrush
= rBrush
;
2028 if (m_backgroundBrush
.Ok())
2030 (void)::GpiSetBackColor((HPS
)m_hPS
, m_backgroundBrush
.GetColour().GetPixel());
2032 } // end of wxDC::SetBackground
2034 void wxDC::SetBackgroundMode(int nMode
)
2036 m_backgroundMode
= nMode
;
2037 } // end of wxDC::SetBackgroundMode
2039 void wxDC::SetLogicalFunction(int nFunction
)
2041 m_logicalFunction
= nFunction
;
2042 SetRop((WXHDC
)m_hDC
);
2043 } // wxDC::SetLogicalFunction
2045 void wxDC::SetRop(WXHDC hDC
)
2047 if (!hDC
|| m_logicalFunction
< 0)
2051 switch (m_logicalFunction
)
2062 lCRop
= FM_MERGESRCNOT
;
2066 lCRop
= FM_NOTMASKSRC
;
2078 lCRop
= FM_MERGENOTSRC
;
2082 lCRop
= FM_MERGESRCNOT
;
2094 lCRop
= FM_SUBTRACT
;
2101 lCRop
= FM_OVERPAINT
;
2104 ::GpiSetMix((HPS
)hDC
, lCRop
);
2105 } // end of wxDC::SetRop
2107 bool wxDC::StartDoc( const wxString
& WXUNUSED(rsMessage
) )
2109 // We might be previewing, so return true to let it continue.
2111 } // end of wxDC::StartDoc
2115 } // end of wxDC::EndDoc
2117 void wxDC::StartPage()
2119 } // end of wxDC::StartPage
2121 void wxDC::EndPage()
2123 } // end of wxDC::EndPage
2125 // ---------------------------------------------------------------------------
2127 // ---------------------------------------------------------------------------
2129 wxCoord
wxDC::GetCharHeight() const
2131 FONTMETRICS vFM
; // metrics structure
2133 ::GpiQueryFontMetrics( m_hPS
2134 ,sizeof(FONTMETRICS
)
2137 return YDEV2LOGREL(vFM
.lXHeight
);
2140 wxCoord
wxDC::GetCharWidth() const
2142 FONTMETRICS vFM
; // metrics structure
2144 ::GpiQueryFontMetrics( m_hPS
2145 ,sizeof(FONTMETRICS
)
2148 return XDEV2LOGREL(vFM
.lAveCharWidth
);
2151 void wxDC::DoGetTextExtent(
2152 const wxString
& rsString
2155 , wxCoord
* pvDescent
2156 , wxCoord
* pvExternalLeading
2160 POINTL avPoint
[TXTBOX_COUNT
];
2165 FONTMETRICS vFM
; // metrics structure
2167 ERRORID vErrorCode
; // last error id code
2168 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
2170 wxChar zMsg
[128]; // DEBUG
2174 pFontToUse
= (wxFont
*)&m_font
;
2175 l
= rsString
.length();
2178 // In world coordinates.
2180 bRc
= ::GpiQueryTextBox( m_hPS
2182 ,(PCH
)rsString
.c_str()
2183 ,TXTBOX_COUNT
// return maximum information
2184 ,avPoint
// array of coordinates points
2188 vErrorCode
= ::WinGetLastError(wxGetInstance());
2189 sError
= wxPMErrorToStr(vErrorCode
);
2191 wxSprintf(zMsg
, _T("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString
.c_str(), vErrorCode
, sError
.c_str());
2192 (void)wxMessageBox( _T("wxWidgets Menu sample")
2198 vPtMin
.x
= avPoint
[0].x
;
2199 vPtMax
.x
= avPoint
[0].x
;
2200 vPtMin
.y
= avPoint
[0].y
;
2201 vPtMax
.y
= avPoint
[0].y
;
2202 for (i
= 1; i
< 4; i
++)
2204 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
2205 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
2206 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
2207 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
2209 ::GpiQueryFontMetrics( m_hPS
2210 ,sizeof(FONTMETRICS
)
2215 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
2217 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
2219 *pvDescent
= vFM
.lMaxDescender
;
2220 if (pvExternalLeading
)
2221 *pvExternalLeading
= vFM
.lExternalLeading
;
2224 void wxDC::SetMapMode(
2228 int nPixelWidth
= 0;
2229 int nPixelHeight
= 0;
2232 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2234 m_mappingMode
= nMode
;
2236 if(::DevQueryCaps( m_hDC
2238 ,CAPS_VERTICAL_RESOLUTION
2245 nPixelWidth
= lArray
[CAPS_WIDTH
];
2246 nPixelHeight
= lArray
[CAPS_HEIGHT
];
2247 lHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2248 lVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2249 nMmWidth
= (lHorzRes
/1000) * nPixelWidth
;
2250 nMmWidth
= (lVertRes
/1000) * nPixelHeight
;
2252 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
2257 double dMm2pixelsX
= nPixelWidth
/nMmWidth
;
2258 double dMm2pixelsY
= nPixelHeight
/nMmHeight
;
2263 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
2264 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
2268 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
2269 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
2273 m_logicalScaleX
= dMm2pixelsX
;
2274 m_logicalScaleY
= dMm2pixelsY
;
2278 m_logicalScaleX
= (dMm2pixelsX
/10.0);
2279 m_logicalScaleY
= (dMm2pixelsY
/10.0);
2284 m_logicalScaleX
= 1.0;
2285 m_logicalScaleY
= 1.0;
2291 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
2292 if (!ulOptions
& PU_ARBITRARY
)
2294 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
2295 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
2297 m_nWindowExtX
= (int)MS_XDEV2LOG(VIEWPORT_EXTENT
);
2298 m_nWindowExtY
= (int)MS_YDEV2LOG(VIEWPORT_EXTENT
);
2300 }; // end of wxDC::SetMapMode
2302 void wxDC::SetUserScale( double dX
,
2308 SetMapMode(m_mappingMode
);
2309 } // end of wxDC::SetUserScale
2311 void wxDC::SetAxisOrientation( bool bXLeftRight
,
2314 m_signX
= bXLeftRight
? 1 : -1;
2315 m_signY
= bYBottomUp
? -1 : 1;
2317 SetMapMode(m_mappingMode
);
2318 } // end of wxDC::SetAxisOrientation
2320 void wxDC::SetSystemScale(
2328 SetMapMode(m_mappingMode
);
2329 } // end of wxDC::SetSystemScale
2331 void wxDC::SetLogicalOrigin(
2338 ::GpiQueryPageViewport( m_hPS
2345 ::GpiSetPageViewport( m_hPS
2348 }; // end of wxDC::SetLogicalOrigin
2350 void wxDC::SetDeviceOrigin(
2357 m_deviceOriginX
= vX
;
2358 m_deviceOriginY
= vY
;
2359 ::GpiQueryPageViewport( m_hPS
2364 vRect
.yBottom
-= vY
;
2366 ::GpiSetPageViewport( m_hPS
2369 }; // end of wxDC::SetDeviceOrigin
2371 // ---------------------------------------------------------------------------
2372 // coordinates transformations
2373 // ---------------------------------------------------------------------------
2375 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2377 return (wxCoord
) (((x
) - m_deviceOriginX
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
) - m_logicalOriginX
);
2380 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2382 // axis orientation is not taken into account for conversion of a distance
2383 return (wxCoord
) ((x
)/(m_logicalScaleX
*m_userScaleX
*m_scaleX
));
2386 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2388 return (wxCoord
) (((y
) - m_deviceOriginY
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
) - m_logicalOriginY
);
2391 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2393 // axis orientation is not taken into account for conversion of a distance
2394 return (wxCoord
) ((y
)/(m_logicalScaleY
*m_userScaleY
*m_scaleY
));
2397 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2399 return (wxCoord
) ((x
- m_logicalOriginX
)*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
+ m_deviceOriginX
);
2402 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2404 // axis orientation is not taken into account for conversion of a distance
2405 return (wxCoord
) (x
*m_logicalScaleX
*m_userScaleX
*m_scaleX
);
2408 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2410 return (wxCoord
) ((y
- m_logicalOriginY
)*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
+ m_deviceOriginY
);
2413 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2415 // axis orientation is not taken into account for conversion of a distance
2416 return (wxCoord
) (y
*m_logicalScaleY
*m_userScaleY
*m_scaleY
);
2419 // ---------------------------------------------------------------------------
2421 // ---------------------------------------------------------------------------
2423 bool wxDC::DoBlit( wxCoord vXdest
,
2432 wxCoord
WXUNUSED(vXsrcMask
),
2433 wxCoord
WXUNUSED(vYsrcMask
) )
2435 wxMask
* pMask
= NULL
;
2437 COLORREF vOldTextColor
;
2438 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
2442 const wxBitmap
& rBmp
= pSource
->m_vSelectedBitmap
;
2444 pMask
= rBmp
.GetMask();
2445 if (!(rBmp
.Ok() && pMask
&& pMask
->GetMaskBitmap()))
2451 ::GpiQueryAttrs( m_hPS
2456 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
2458 if (m_textForegroundColour
.Ok())
2460 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
2461 ::GpiSetAttrs( m_hPS
// presentation-space handle
2462 ,PRIM_CHAR
// Char primitive.
2463 ,CBB_COLOR
// sets color.
2465 ,&vCbnd
// buffer for attributes.
2468 if (m_textBackgroundColour
.Ok())
2470 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
2473 LONG lRop
= ROP_SRCCOPY
;
2477 case wxXOR
: lRop
= ROP_SRCINVERT
; break;
2478 case wxINVERT
: lRop
= ROP_DSTINVERT
; break;
2479 case wxOR_REVERSE
: lRop
= 0x00DD0228; break;
2480 case wxAND_REVERSE
: lRop
= ROP_SRCERASE
; break;
2481 case wxCLEAR
: lRop
= ROP_ZERO
; break;
2482 case wxSET
: lRop
= ROP_ONE
; break;
2483 case wxOR_INVERT
: lRop
= ROP_MERGEPAINT
; break;
2484 case wxAND
: lRop
= ROP_SRCAND
; break;
2485 case wxOR
: lRop
= ROP_SRCPAINT
; break;
2486 case wxEQUIV
: lRop
= 0x00990066; break;
2487 case wxNAND
: lRop
= 0x007700E6; break;
2488 case wxAND_INVERT
: lRop
= 0x00220326; break;
2489 case wxCOPY
: lRop
= ROP_SRCCOPY
; break;
2490 case wxNO_OP
: lRop
= ROP_NOTSRCERASE
; break;
2491 case wxSRC_INVERT
: lRop
= ROP_SRCINVERT
; break;
2492 case wxNOR
: lRop
= ROP_NOTSRCCOPY
; break;
2494 wxFAIL_MSG( wxT("unsupported logical function") );
2503 // Blit bitmap with mask
2507 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2513 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
2514 BITMAPINFOHEADER2 vBmpHdr
;
2516 SIZEL vSize
= {0, 0};
2519 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
2520 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
2521 vBmpHdr
.cx
= vWidth
;
2522 vBmpHdr
.cy
= vHeight
;
2523 vBmpHdr
.cPlanes
= 1;
2524 vBmpHdr
.cBitCount
= 24;
2526 #if wxUSE_DC_CACHEING
2529 // create a temp buffer bitmap and DCs to access it and the mask
2531 wxDCCacheEntry
* pDCCacheEntry1
= FindDCInCache( NULL
2534 wxDCCacheEntry
* pDCCacheEntry2
= FindDCInCache( pDCCacheEntry1
2537 wxDCCacheEntry
* pBitmapCacheEntry
= FindBitmapInCache( GetHPS()
2542 hPSMask
= pDCCacheEntry1
->m_hPS
;
2543 hDCBuffer
= (HDC
)pDCCacheEntry2
->m_hPS
;
2544 hBufBitmap
= (HBITMAP
)pBitmapCacheEntry
->m_hBitmap
;
2545 wxUnusedVar(hDCMask
);
2549 hDCMask
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2550 hDCBuffer
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2551 hPSMask
= ::GpiCreatePS(vHabmain
, hDCMask
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2552 hPSBuffer
= ::GpiCreatePS(vHabmain
, hDCBuffer
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2553 hBufBitmap
= ::GpiCreateBitmap(GetHPS(), &vBmpHdr
, 0L, NULL
, NULL
);
2557 POINTL aPoint1
[4] = { {0, 0}
2560 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2562 POINTL aPoint2
[4] = { {0, 0}
2565 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2567 POINTL aPoint3
[4] = { {vXdest
, vYdest
}
2568 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2570 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2572 POINTL aPoint4
[4] = { {vXdest
, vYdest
}
2573 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2577 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
2578 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
2581 // Copy dest to buffer
2583 rc
= ::GpiBitBlt( hPSBuffer
2590 if (rc
== GPI_ERROR
)
2592 wxLogLastError(wxT("BitBlt"));
2596 // Copy src to buffer using selected raster op
2598 rc
= ::GpiBitBlt( hPSBuffer
2605 if (rc
== GPI_ERROR
)
2607 wxLogLastError(wxT("BitBlt"));
2611 // Set masked area in buffer to BLACK (pixel value 0)
2613 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
2614 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
2616 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2617 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2619 rc
= ::GpiBitBlt( hPSBuffer
2626 if (rc
== GPI_ERROR
)
2628 wxLogLastError(wxT("BitBlt"));
2632 // Set unmasked area in dest to BLACK
2634 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2635 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2636 rc
= ::GpiBitBlt( GetHPS()
2643 if (rc
== GPI_ERROR
)
2645 wxLogLastError(wxT("BitBlt"));
2649 // Restore colours to original values
2651 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
2652 ::GpiSetColor(GetHPS(), vPrevCol
);
2655 // OR buffer to dest
2657 rc
= ::GpiBitBlt( GetHPS()
2664 if (rc
== GPI_ERROR
)
2667 wxLogLastError(wxT("BitBlt"));
2671 // Tidy up temporary DCs and bitmap
2673 ::GpiSetBitmap(hPSMask
, NULLHANDLE
);
2674 ::GpiSetBitmap(hPSBuffer
, NULLHANDLE
);
2675 #if !wxUSE_DC_CACHEING
2676 ::GpiDestroyPS(hPSMask
);
2677 ::GpiDestroyPS(hPSBuffer
);
2678 ::DevCloseDC(hDCMask
);
2679 ::DevCloseDC(hDCBuffer
);
2680 ::GpiDeleteBitmap(hBufBitmap
);
2684 else // no mask, just BitBlt() it
2686 POINTL aPoint
[4] = { {vXdest
, vYdest
}
2687 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2689 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2692 bSuccess
= (::GpiBitBlt( m_hPS
2701 wxLogLastError(wxT("BitBlt"));
2704 vCbnd
.lColor
= (LONG
)vOldTextColor
;
2705 ::GpiSetAttrs( m_hPS
// presentation-space handle
2706 ,PRIM_CHAR
// Char primitive.
2707 ,CBB_COLOR
// sets color.
2709 ,&vCbnd
// buffer for attributes.
2711 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
2715 void wxDC::DoGetSize( int* pnWidth
,
2716 int* pnHeight
) const
2718 LONG lArray
[CAPS_HEIGHT
];
2720 if(::DevQueryCaps( m_hDC
2726 *pnWidth
= lArray
[CAPS_WIDTH
];
2727 *pnHeight
= lArray
[CAPS_HEIGHT
];
2729 }; // end of wxDC::DoGetSize(
2731 void wxDC::DoGetSizeMM( int* pnWidth
,
2732 int* pnHeight
) const
2734 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2736 if(::DevQueryCaps( m_hDC
2738 ,CAPS_VERTICAL_RESOLUTION
2744 int nWidth
= lArray
[CAPS_WIDTH
];
2745 int nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2746 *pnWidth
= (nHorzRes
/1000) * nWidth
;
2751 int nHeight
= lArray
[CAPS_HEIGHT
];
2752 int nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2753 *pnHeight
= (nVertRes
/1000) * nHeight
;
2756 }; // end of wxDC::DoGetSizeMM
2758 wxSize
wxDC::GetPPI() const
2760 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2764 if(::DevQueryCaps( m_hDC
2766 ,CAPS_VERTICAL_RESOLUTION
2775 nPelWidth
= lArray
[CAPS_WIDTH
];
2776 nPelHeight
= lArray
[CAPS_HEIGHT
];
2777 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2778 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2779 nWidth
= (int)((nHorzRes
/39.3) * nPelWidth
);
2780 nHeight
= (int)((nVertRes
/39.3) * nPelHeight
);
2782 wxSize
ppisize(nWidth
, nHeight
);
2784 } // end of wxDC::GetPPI
2786 void wxDC::SetLogicalScale( double dX
, double dY
)
2788 m_logicalScaleX
= dX
;
2789 m_logicalScaleY
= dY
;
2790 }; // end of wxDC::SetLogicalScale