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
= 0L; // 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
; // +xoffset;
906 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
,0); // +yoffset;
908 flModel
= POLYGON_BOUNDARY
;
909 if(nFillStyle
== wxWINDING_RULE
)
910 flModel
|= POLYGON_WINDING
;
912 flModel
|= POLYGON_ALTERNATE
;
915 vPoint
.y
= OS2Y(vYoffset
,0);
917 ::GpiSetColor(m_hPS
, lBorderColor
);
918 ::GpiMove(m_hPS
, &vPoint
);
919 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
921 } // end of wxDC::DoDrawPolygon
923 void wxDC::DoDrawLines(
932 if (vXoffset
!= 0L || vXoffset
!= 0L)
936 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
937 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
938 ::GpiMove(m_hPS
, &vPoint
);
940 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
942 ::GpiSetColor(m_hPS
, lBorderColor
);
943 for(i
= 1; i
< n
; i
++)
945 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
946 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
947 ::GpiLine(m_hPS
, &vPoint
);
954 CalcBoundingBox( vPoints
[0].x
957 vPoint
.x
= vPoints
[0].x
;
958 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
959 ::GpiMove(m_hPS
, &vPoint
);
961 for (i
= 0; i
< n
; i
++)
963 CalcBoundingBox( vPoints
[i
].x
966 vPoint
.x
= vPoints
[i
].x
;
967 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
968 ::GpiLine(m_hPS
, &vPoint
);
971 } // end of wxDC::DoDrawLines
973 void wxDC::DoDrawRectangle(
984 int nIsTRANSPARENT
= 0;
987 // Might be a memory DC with no Paint rect.
989 if (!(m_vRclPaint
.yTop
== 0 &&
990 m_vRclPaint
.yBottom
== 0 &&
991 m_vRclPaint
.xRight
== 0 &&
992 m_vRclPaint
.xLeft
== 0))
993 vY
= OS2Y(vY
,vHeight
);
996 if (m_vSelectedBitmap
!= wxNullBitmap
)
998 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
999 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1000 vY
= OS2Y(vY
,vHeight
);
1004 wxCoord vX2
= vX
+ vWidth
;
1005 wxCoord vY2
= vY
+ vHeight
;
1009 vPoint
[1].x
= vX
+ vWidth
- 1;
1010 vPoint
[1].y
= vY
+ vHeight
- 1;
1011 ::GpiMove(m_hPS
, &vPoint
[0]);
1012 lColor
= m_brush
.GetColour().GetPixel();
1013 lBorderColor
= m_pen
.GetColour().GetPixel();
1014 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1016 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1018 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1019 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1020 lControl
= DRO_OUTLINE
;
1022 ::GpiSetColor(m_hPS
, lBorderColor
);
1023 ::GpiBox( m_hPS
// handle to a presentation space
1024 ,lControl
// draw the box outline ? or ?
1025 ,&vPoint
[1] // address of the corner
1026 ,0L // horizontal corner radius
1027 ,0L // vertical corner radius
1032 lControl
= DRO_OUTLINE
;
1033 ::GpiSetColor( m_hPS
1042 lControl
= DRO_FILL
;
1043 ::GpiSetColor( m_hPS
1046 vPoint
[0].x
= vX
+ 1;
1047 vPoint
[0].y
= vY
+ 1;
1048 vPoint
[1].x
= vX
+ vWidth
- 2;
1049 vPoint
[1].y
= vY
+ vHeight
- 2;
1050 ::GpiMove(m_hPS
, &vPoint
[0]);
1058 CalcBoundingBox(vX
, vY
);
1059 CalcBoundingBox(vX2
, vY2
);
1060 } // end of wxDC::DoDrawRectangle
1062 void wxDC::DoDrawRoundedRectangle(
1074 int nIsTRANSPARENT
= 0;
1077 // Might be a memory DC with no Paint rect.
1079 if (!(m_vRclPaint
.yTop
== 0 &&
1080 m_vRclPaint
.yBottom
== 0 &&
1081 m_vRclPaint
.xRight
== 0 &&
1082 m_vRclPaint
.xLeft
== 0))
1083 vY
= OS2Y(vY
,vHeight
);
1086 if (m_vSelectedBitmap
!= wxNullBitmap
)
1088 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1089 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1090 vY
= OS2Y(vY
,vHeight
);
1094 wxCoord vX2
= (vX
+ vWidth
);
1095 wxCoord vY2
= (vY
+ vHeight
);
1099 vPoint
[1].x
= vX
+ vWidth
- 1;
1100 vPoint
[1].y
= vY
+ vHeight
- 1;
1101 ::GpiMove(m_hPS
, &vPoint
[0]);
1103 lColor
= m_brush
.GetColour().GetPixel();
1104 lBorderColor
= m_pen
.GetColour().GetPixel();
1105 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1106 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1108 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1110 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1111 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1112 lControl
= DRO_OUTLINE
;
1114 ::GpiSetColor(m_hPS
, lColor
);
1115 ::GpiBox( m_hPS
// handle to a presentation space
1116 ,lControl
// draw the box outline ? or ?
1117 ,&vPoint
[1] // address of the corner
1118 ,(LONG
)dRadius
// horizontal corner radius
1119 ,(LONG
)dRadius
// vertical corner radius
1124 lControl
= DRO_OUTLINE
;
1125 ::GpiSetColor( m_hPS
1134 lControl
= DRO_FILL
;
1135 ::GpiSetColor( m_hPS
1138 vPoint
[0].x
= vX
+ 1;
1139 vPoint
[0].y
= vY
+ 1;
1140 vPoint
[1].x
= vX
+ vWidth
- 2;
1141 vPoint
[1].y
= vY
+ vHeight
- 2;
1142 ::GpiMove(m_hPS
, &vPoint
[0]);
1151 CalcBoundingBox(vX
, vY
);
1152 CalcBoundingBox(vX2
, vY2
);
1153 } // end of wxDC::DoDrawRoundedRectangle
1155 // Draw Ellipse within box (x,y) - (x+width, y+height)
1156 void wxDC::DoDrawEllipse(
1163 POINTL vPtlPos
; // Structure for current position
1164 FIXED vFxMult
; // Multiplier for ellipse
1165 ARCPARAMS vArcp
; // Structure for arc parameters
1167 vY
= OS2Y(vY
,vHeight
);
1170 vArcp
.lQ
= vHeight
/2;
1171 vArcp
.lP
= vWidth
/2;
1173 ::GpiSetArcParams( m_hPS
1175 ); // Sets parameters to default
1176 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
1177 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1180 ); // Sets current position
1181 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
1184 // DRO_FILL, DRO_OTLINEFILL - where to get
1189 ); // Draws full arc with center at current position
1191 wxCoord vX2
= (vX
+ vWidth
);
1192 wxCoord vY2
= (vY
+ vHeight
);
1194 CalcBoundingBox(vX
, vY
);
1195 CalcBoundingBox(vX2
, vY2
);
1196 } // end of wxDC::DoDrawEllipse
1198 void wxDC::DoDrawEllipticArc(
1207 POINTL vPtlPos
; // Structure for current position
1208 FIXED vFxMult
; // Multiplier for ellipse
1209 ARCPARAMS vArcp
; // Structure for arc parameters
1211 FIXED vFSweepa
; // Start angle, sweep angle
1215 vY
= OS2Y(vY
,vHeight
);
1217 dFractPart
= modf(dSa
,&dIntPart
);
1218 vFSa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1219 dFractPart
= modf(dEa
- dSa
, &dIntPart
);
1220 vFSweepa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1223 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1226 vArcp
.lQ
= vHeight
/2;
1227 vArcp
.lP
= vWidth
/2;
1229 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
1230 vPtlPos
.x
= (wxCoord
)(vX
+ vWidth
/2 * (1. + cos(DegToRad(dSa
)))); // Loads x-coordinate
1231 vPtlPos
.y
= (wxCoord
)(vY
+ vHeight
/2 * (1. + sin(DegToRad(dSa
)))); // Loads y-coordinate
1232 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
1235 // May be not to the center ?
1237 vPtlPos
.x
= vX
+ vWidth
/2 ; // Loads x-coordinate
1238 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1239 vFxMult
= MAKEFIXED(1, 0); // Sets multiplier
1242 // DRO_FILL, DRO_OTLINEFILL - where to get
1244 ::GpiPartialArc( m_hPS
1250 wxCoord vX2
= (vX
+ vWidth
);
1251 wxCoord vY2
= (vY
+ vHeight
);
1253 CalcBoundingBox(vX
, vY
);
1254 CalcBoundingBox(vX2
, vY2
);
1255 } // end of wxDC::DoDrawEllipticArc
1257 void wxDC::DoDrawIcon(
1264 // Need to copy back into a bitmap. ::WinDrawPointer uses device coords
1265 // and I don't feel like figuring those out for scrollable windows so
1266 // just convert to a bitmap then let the DoDrawBitmap routine display it
1270 DoDrawBitmap(rIcon
.GetXpmSrc(), vX
, vY
, true);
1274 wxBitmap
vBitmap(rIcon
);
1276 DoDrawBitmap(vBitmap
, vX
, vY
, false);
1278 CalcBoundingBox(vX
, vY
);
1279 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
1280 } // end of wxDC::DoDrawIcon
1282 void wxDC::DoDrawBitmap(
1283 const wxBitmap
& rBmp
1289 #if wxUSE_PRINTING_ARCHITECTURE
1290 if (!IsKindOf(CLASSINFO(wxPrinterDC
)))
1293 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
1294 HBITMAP hBitmapOld
= NULLHANDLE
;
1297 vY
= OS2Y(vY
,rBmp
.GetHeight());
1300 vPoint
[0].y
= vY
+ rBmp
.GetHeight();
1301 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1305 vPoint
[3].x
= rBmp
.GetWidth();
1306 vPoint
[3].y
= rBmp
.GetHeight();
1309 wxMask
* pMask
= rBmp
.GetMask();
1314 // Need to imitate ::MaskBlt in windows.
1315 // 1) Extract the bits from from the bitmap.
1316 // 2) Extract the bits from the mask
1317 // 3) Using the mask bits do the following:
1318 // A) If the mask byte is 00 leave the bitmap byte alone
1319 // B) If the mask byte is FF copy the screen color into
1321 // 4) Create a new bitmap and set its bits to the above result
1322 // 5) Blit this to the screen PS
1324 HBITMAP hMask
= (HBITMAP
)pMask
->GetMaskBitmap();
1325 HBITMAP hOldMask
= NULLHANDLE
;
1326 HBITMAP hOldBitmap
= NULLHANDLE
;
1327 HBITMAP hNewBitmap
= NULLHANDLE
;
1328 unsigned char* pucBits
; // buffer that will contain the bitmap data
1329 unsigned char* pucBitsMask
; // buffer that will contain the mask data
1330 unsigned char* pucData
; // pointer to use to traverse bitmap data
1331 unsigned char* pucDataMask
; // pointer to use to traverse mask data
1337 // The usual Memory context creation stuff
1339 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1340 SIZEL vSize
= {0, 0};
1341 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1342 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1345 // The usual bitmap header stuff
1347 BITMAPINFOHEADER2 vHeader
;
1350 memset(&vHeader
, '\0', 16);
1353 memset(&vInfo
, '\0', 16);
1355 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1356 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1358 vInfo
.cBitCount
= 24; // Set to desired count going in
1361 // Create the buffers for data....all wxBitmaps are 24 bit internally
1363 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1364 int nSizeDWORD
= sizeof(DWORD
);
1365 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
1373 // Need to get a background color for mask blitting
1375 if (IsKindOf(CLASSINFO(wxWindowDC
)))
1377 wxWindowDC
* pWindowDC
= wxDynamicCast(this, wxWindowDC
);
1379 lColor
= pWindowDC
->m_pCanvas
->GetBackgroundColour().GetPixel();
1381 else if (GetBrush().Ok())
1382 lColor
= GetBrush().GetColour().GetPixel();
1384 lColor
= m_textBackgroundColour
.GetPixel();
1387 // Bitmap must be in a double-word aligned address so we may
1388 // have some padding to worry about
1390 if (nLineBoundary
> 0)
1392 nPadding
= nSizeDWORD
- nLineBoundary
;
1393 nBytesPerLine
+= nPadding
;
1395 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1396 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1397 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1398 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1401 // Extract the bitmap and mask data
1403 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1405 vError
= ::WinGetLastError(vHabmain
);
1406 sError
= wxPMErrorToStr(vError
);
1408 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
1409 vInfo
.cBitCount
= 24;
1410 if ((lScans
= ::GpiQueryBitmapBits( hPS
1412 ,(LONG
)rBmp
.GetHeight()
1417 vError
= ::WinGetLastError(vHabmain
);
1418 sError
= wxPMErrorToStr(vError
);
1420 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
1422 vError
= ::WinGetLastError(vHabmain
);
1423 sError
= wxPMErrorToStr(vError
);
1425 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
1426 vInfo
.cBitCount
= 24;
1427 if ((lScans
= ::GpiQueryBitmapBits( hPS
1429 ,(LONG
)rBmp
.GetHeight()
1434 vError
= ::WinGetLastError(vHabmain
);
1435 sError
= wxPMErrorToStr(vError
);
1437 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
1439 vError
= ::WinGetLastError(vHabmain
);
1440 sError
= wxPMErrorToStr(vError
);
1444 // Now set the bytes(bits) according to the mask values
1445 // 3 bytes per pel...must handle one at a time
1448 pucDataMask
= pucBitsMask
;
1451 // 16 bit kludge really only kinda works. The mask gets applied
1452 // where needed but the original bitmap bits are dorked sometimes
1454 bool bpp16
= (wxDisplayDepth() == 16);
1456 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1458 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1461 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1463 else if (*pucDataMask
== 0xFF) // leave bitmap byte alone
1467 *pucData
= ((unsigned char)(lColor
>> 16));
1471 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1473 else if (*(pucDataMask
+ 1) == 0xFF) // leave bitmap byte alone
1477 *pucData
= ((unsigned char)(lColor
>> 8));
1482 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1484 else if (*(pucDataMask
+ 2) == 0xFF) // leave bitmap byte alone
1488 *pucData
= ((unsigned char)lColor
);
1493 for (j
= 0; j
< nPadding
; j
++)
1500 // Create a new bitmap
1502 vHeader
.cx
= (ULONG
)rBmp
.GetWidth();
1503 vHeader
.cy
= (ULONG
)rBmp
.GetHeight();
1504 vHeader
.cPlanes
= 1L;
1505 vHeader
.cBitCount
= 24;
1506 if ((hNewBitmap
= ::GpiCreateBitmap( hPS
1513 vError
= ::WinGetLastError(vHabmain
);
1514 sError
= wxPMErrorToStr(vError
);
1518 // Now blit it to the screen PS
1520 if ((lHits
= ::GpiWCBitBlt( (HPS
)GetHPS()
1528 vError
= ::WinGetLastError(vHabmain
);
1529 sError
= wxPMErrorToStr(vError
);
1537 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1538 ::GpiDeleteBitmap(hNewBitmap
);
1539 ::GpiDestroyPS(hPS
);
1545 ULONG lOldForeGround
= ::GpiQueryColor((HPS
)GetHPS());
1546 ULONG lOldBackGround
= ::GpiQueryBackColor((HPS
)GetHPS());
1548 if (m_textForegroundColour
.Ok())
1550 ::GpiSetColor( (HPS
)GetHPS()
1551 ,m_textForegroundColour
.GetPixel()
1554 if (m_textBackgroundColour
.Ok())
1556 ::GpiSetBackColor( (HPS
)GetHPS()
1557 ,m_textBackgroundColour
.GetPixel()
1561 // Need to alter bits in a mono bitmap to match the new
1562 // background-foreground if it is different.
1564 if (rBmp
.IsMono() &&
1565 ((m_textForegroundColour
.GetPixel() != lOldForeGround
) ||
1566 (m_textBackgroundColour
.GetPixel() != lOldBackGround
)))
1568 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1569 SIZEL vSize
= {0, 0};
1570 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1571 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1573 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1575 LONG lForeGround
= m_textForegroundColour
.GetPixel();
1576 LONG lBackGround
= m_textBackgroundColour
.GetPixel();
1578 HBITMAP hOldBitmap
= NULLHANDLE
;
1584 memset(&vInfo
, '\0', 16);
1586 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1587 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1589 vInfo
.cBitCount
= 24;
1591 unsigned char* pucBits
; // buffer that will contain the bitmap data
1592 unsigned char* pucData
; // pointer to use to traverse bitmap data
1594 pucBits
= new unsigned char[nBytesPerLine
* rBmp
.GetHeight()];
1595 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1597 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1599 vError
= ::WinGetLastError(vHabmain
);
1600 sError
= wxPMErrorToStr(vError
);
1603 if ((lScans
= ::GpiQueryBitmapBits( hPS
1605 ,(LONG
)rBmp
.GetHeight()
1610 vError
= ::WinGetLastError(vHabmain
);
1611 sError
= wxPMErrorToStr(vError
);
1614 unsigned char cOldRedFore
= (unsigned char)(lOldForeGround
>> 16);
1615 unsigned char cOldGreenFore
= (unsigned char)(lOldForeGround
>> 8);
1616 unsigned char cOldBlueFore
= (unsigned char)lOldForeGround
;
1618 unsigned char cRedFore
= (unsigned char)(lForeGround
>> 16);
1619 unsigned char cGreenFore
= (unsigned char)(lForeGround
>> 8);
1620 unsigned char cBlueFore
= (unsigned char)lForeGround
;
1622 unsigned char cRedBack
= (unsigned char)(lBackGround
>> 16);
1623 unsigned char cGreenBack
= (unsigned char)(lBackGround
>> 8);
1624 unsigned char cBlueBack
= (unsigned char)lBackGround
;
1627 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1629 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1631 unsigned char cBmpRed
= *pucData
;
1632 unsigned char cBmpGreen
= *(pucData
+ 1);
1633 unsigned char cBmpBlue
= *(pucData
+ 2);
1635 if ((cBmpRed
== cOldRedFore
) &&
1636 (cBmpGreen
== cOldGreenFore
) &&
1637 (cBmpBlue
== cOldBlueFore
))
1639 *pucData
= cBlueFore
;
1641 *pucData
= cGreenFore
;
1643 *pucData
= cRedFore
;
1648 *pucData
= cBlueBack
;
1650 *pucData
= cGreenBack
;
1652 *pucData
= cRedBack
;
1657 if ((lScans
= ::GpiSetBitmapBits( hPS
1659 ,(LONG
)rBmp
.GetHeight()
1664 vError
= ::WinGetLastError(vHabmain
);
1665 sError
= wxPMErrorToStr(vError
);
1669 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1670 ::GpiDestroyPS(hPS
);
1673 ::GpiWCBitBlt( (HPS
)GetHPS()
1680 ::GpiSetBitmap((HPS
)GetHPS(), hBitmapOld
);
1681 ::GpiSetColor((HPS
)GetHPS(), lOldForeGround
);
1682 ::GpiSetBackColor((HPS
)GetHPS(), lOldBackGround
);
1685 } // end of wxDC::DoDrawBitmap
1687 void wxDC::DoDrawText(
1688 const wxString
& rsText
1701 CalcBoundingBox(vX
, vY
);
1702 GetTextExtent(rsText
, &vWidth
, &vHeight
);
1703 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1704 } // end of wxDC::DoDrawText
1706 void wxDC::DrawAnyText( const wxString
& rsText
,
1710 int nOldBackground
= 0;
1717 // prepare for drawing the text
1721 // Set text color attributes
1723 if (m_textForegroundColour
.Ok())
1726 ,(int)m_textForegroundColour
.GetPixel()
1730 if (m_textBackgroundColour
.Ok())
1732 nOldBackground
= SetTextBkColor( m_hPS
1733 ,(int)m_textBackgroundColour
.GetPixel()
1739 GetTextExtent( rsText
1744 if (!(m_vRclPaint
.yTop
== 0 &&
1745 m_vRclPaint
.yBottom
== 0 &&
1746 m_vRclPaint
.xRight
== 0 &&
1747 m_vRclPaint
.xLeft
== 0))
1750 // Position Text a little differently in the Statusbar from other panels
1752 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1753 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1755 vPtlStart
.y
= (wxCoord
)(OS2Y(vY
,vTextY
/1.5)); // Full extent is a bit much
1759 if (m_vSelectedBitmap
!= wxNullBitmap
)
1761 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1762 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1763 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1764 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1766 vPtlStart
.y
= (LONG
)(OS2Y(vY
,vTextY
/1.5));
1772 PCH pzStr
= (PCH
)rsText
.c_str();
1774 ::GpiMove(m_hPS
, &vPtlStart
);
1775 lHits
= ::GpiCharString( m_hPS
1779 if (lHits
!= GPI_OK
)
1781 wxLogLastError(wxT("TextOut"));
1785 // Restore the old parameters (text foreground colour may be left because
1786 // it never is set to anything else, but background should remain
1787 // transparent even if we just drew an opaque string)
1789 if (m_textBackgroundColour
.Ok())
1790 SetTextBkColor( m_hPS
1798 void wxDC::DoDrawRotatedText(
1799 const wxString
& rsText
1817 DoDrawText(text, x, y);
1822 wxFillLogFont(&lf, &m_font);
1824 // GDI wants the angle in tenth of degree
1825 long angle10 = (long)(angle * 10);
1826 lf.lfEscapement = angle10;
1827 lf. lfOrientation = angle10;
1829 HFONT hfont = ::CreateFontIndirect(&lf);
1832 wxLogLastError("CreateFont");
1836 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1838 DrawAnyText(text, x, y);
1840 (void)::SelectObject(GetHdc(), hfontOld);
1843 // call the bounding box by adding all four vertices of the rectangle
1844 // containing the text to it (simpler and probably not slower than
1845 // determining which of them is really topmost/leftmost/...)
1847 GetTextExtent(text, &w, &h);
1849 double rad = DegToRad(angle);
1851 // "upper left" and "upper right"
1852 CalcBoundingBox(x, y);
1853 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1854 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1856 // "bottom left" and "bottom right"
1857 x += (wxCoord)(h*sin(rad));
1858 y += (wxCoord)(h*cos(rad));
1859 CalcBoundingBox(x, y);
1860 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1865 // ---------------------------------------------------------------------------
1867 // ---------------------------------------------------------------------------
1869 void wxDC::DoSelectPalette( bool WXUNUSED(bRealize
) )
1872 // Set the old object temporarily, in case the assignment deletes an object
1873 // that's not yet selected out.
1884 hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1886 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1888 } // end of wxDC::DoSelectPalette
1890 void wxDC::InitializePalette()
1892 if (wxDisplayDepth() <= 8 )
1895 // Look for any window or parent that has a custom palette. If any has
1896 // one then we need to use it in drawing operations
1898 wxWindow
* pWin
= m_pCanvas
->GetAncestorWithCustomPalette();
1900 m_hasCustomPalette
= pWin
&& pWin
->HasCustomPalette();
1901 if (m_hasCustomPalette
)
1903 m_palette
= pWin
->GetPalette();
1906 // turn on PM translation for this palette
1911 } // end of wxDC::InitializePalette
1913 void wxDC::SetPalette(
1914 const wxPalette
& rPalette
1921 m_palette
= rPalette
;
1929 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1931 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1932 } // end of wxDC::SetPalette
1939 // Set the old object temporarily, in case the assignment deletes an object
1940 // that's not yet selected out.
1952 m_font
.SetPS(m_hPS
); // this will realize the font
1956 HFONT hFont
= m_font
.GetResourceHandle();
1957 if (hFont
== (HFONT
) NULL
)
1959 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
1962 m_hOldFont
= (WXHFONT
) hFont
;
1964 } // end of wxDC::SetFont
1970 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1986 m_pen
.SetPS((HPS
)m_hOldPen
);
1993 if (m_pen
.GetResourceHandle())
1997 m_hOldPen
= m_pen
.GetPS();
1999 ::GpiSetColor(m_hPS
, m_pen
.GetColour().GetPixel());
2003 void wxDC::SetBrush(
2004 const wxBrush
& rBrush
2007 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2013 if (m_brush
== rBrush
)
2023 m_brush
.SetPS((HPS
)m_hOldBrush
);
2030 if (m_brush
.GetResourceHandle())
2032 m_brush
.SetPS(m_hPS
);
2034 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
2037 } // end of wxDC::SetBrush
2039 void wxDC::SetBackground(const wxBrush
& rBrush
)
2041 m_backgroundBrush
= rBrush
;
2043 if (m_backgroundBrush
.Ok())
2045 (void)::GpiSetBackColor((HPS
)m_hPS
, m_backgroundBrush
.GetColour().GetPixel());
2047 } // end of wxDC::SetBackground
2049 void wxDC::SetBackgroundMode(int nMode
)
2051 m_backgroundMode
= nMode
;
2052 } // end of wxDC::SetBackgroundMode
2054 void wxDC::SetLogicalFunction(int nFunction
)
2056 m_logicalFunction
= nFunction
;
2057 SetRop((WXHDC
)m_hDC
);
2058 } // wxDC::SetLogicalFunction
2060 void wxDC::SetRop(WXHDC hDC
)
2062 if (!hDC
|| m_logicalFunction
< 0)
2066 switch (m_logicalFunction
)
2077 lCRop
= FM_MERGESRCNOT
;
2081 lCRop
= FM_NOTMASKSRC
;
2093 lCRop
= FM_MERGENOTSRC
;
2097 lCRop
= FM_MERGESRCNOT
;
2109 lCRop
= FM_SUBTRACT
;
2116 lCRop
= FM_OVERPAINT
;
2119 ::GpiSetMix((HPS
)hDC
, lCRop
);
2120 } // end of wxDC::SetRop
2122 bool wxDC::StartDoc( const wxString
& WXUNUSED(rsMessage
) )
2124 // We might be previewing, so return true to let it continue.
2126 } // end of wxDC::StartDoc
2130 } // end of wxDC::EndDoc
2132 void wxDC::StartPage()
2134 } // end of wxDC::StartPage
2136 void wxDC::EndPage()
2138 } // end of wxDC::EndPage
2140 // ---------------------------------------------------------------------------
2142 // ---------------------------------------------------------------------------
2144 wxCoord
wxDC::GetCharHeight() const
2146 FONTMETRICS vFM
; // metrics structure
2148 ::GpiQueryFontMetrics( m_hPS
2149 ,sizeof(FONTMETRICS
)
2152 return YDEV2LOGREL(vFM
.lXHeight
);
2155 wxCoord
wxDC::GetCharWidth() const
2157 FONTMETRICS vFM
; // metrics structure
2159 ::GpiQueryFontMetrics( m_hPS
2160 ,sizeof(FONTMETRICS
)
2163 return XDEV2LOGREL(vFM
.lAveCharWidth
);
2166 void wxDC::DoGetTextExtent(
2167 const wxString
& rsString
2170 , wxCoord
* pvDescent
2171 , wxCoord
* pvExternalLeading
2175 POINTL avPoint
[TXTBOX_COUNT
];
2180 FONTMETRICS vFM
; // metrics structure
2182 ERRORID vErrorCode
; // last error id code
2183 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
2185 wxChar zMsg
[128]; // DEBUG
2189 pFontToUse
= (wxFont
*)&m_font
;
2190 l
= rsString
.length();
2193 // In world coordinates.
2195 bRc
= ::GpiQueryTextBox( m_hPS
2197 ,(PCH
)rsString
.c_str()
2198 ,TXTBOX_COUNT
// return maximum information
2199 ,avPoint
// array of coordinates points
2203 vErrorCode
= ::WinGetLastError(wxGetInstance());
2204 sError
= wxPMErrorToStr(vErrorCode
);
2206 wxSprintf(zMsg
, _T("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString
.c_str(), vErrorCode
, sError
.c_str());
2207 (void)wxMessageBox( _T("wxWidgets Menu sample")
2213 vPtMin
.x
= avPoint
[0].x
;
2214 vPtMax
.x
= avPoint
[0].x
;
2215 vPtMin
.y
= avPoint
[0].y
;
2216 vPtMax
.y
= avPoint
[0].y
;
2217 for (i
= 1; i
< 4; i
++)
2219 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
2220 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
2221 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
2222 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
2224 ::GpiQueryFontMetrics( m_hPS
2225 ,sizeof(FONTMETRICS
)
2230 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
2232 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
2234 *pvDescent
= vFM
.lMaxDescender
;
2235 if (pvExternalLeading
)
2236 *pvExternalLeading
= vFM
.lExternalLeading
;
2239 void wxDC::SetMapMode(
2243 int nPixelWidth
= 0;
2244 int nPixelHeight
= 0;
2247 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2249 m_mappingMode
= nMode
;
2251 if(::DevQueryCaps( m_hDC
2253 ,CAPS_VERTICAL_RESOLUTION
2260 nPixelWidth
= lArray
[CAPS_WIDTH
];
2261 nPixelHeight
= lArray
[CAPS_HEIGHT
];
2262 lHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2263 lVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2264 nMmWidth
= (lHorzRes
/1000) * nPixelWidth
;
2265 nMmWidth
= (lVertRes
/1000) * nPixelHeight
;
2267 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
2272 double dMm2pixelsX
= nPixelWidth
/nMmWidth
;
2273 double dMm2pixelsY
= nPixelHeight
/nMmHeight
;
2278 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
2279 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
2283 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
2284 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
2288 m_logicalScaleX
= dMm2pixelsX
;
2289 m_logicalScaleY
= dMm2pixelsY
;
2293 m_logicalScaleX
= (dMm2pixelsX
/10.0);
2294 m_logicalScaleY
= (dMm2pixelsY
/10.0);
2299 m_logicalScaleX
= 1.0;
2300 m_logicalScaleY
= 1.0;
2306 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
2307 if (!ulOptions
& PU_ARBITRARY
)
2309 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
2310 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
2312 m_nWindowExtX
= (int)MS_XDEV2LOG(VIEWPORT_EXTENT
);
2313 m_nWindowExtY
= (int)MS_YDEV2LOG(VIEWPORT_EXTENT
);
2315 }; // end of wxDC::SetMapMode
2317 void wxDC::SetUserScale( double dX
,
2323 SetMapMode(m_mappingMode
);
2324 } // end of wxDC::SetUserScale
2326 void wxDC::SetAxisOrientation( bool bXLeftRight
,
2329 m_signX
= bXLeftRight
? 1 : -1;
2330 m_signY
= bYBottomUp
? -1 : 1;
2332 SetMapMode(m_mappingMode
);
2333 } // end of wxDC::SetAxisOrientation
2335 void wxDC::SetSystemScale(
2343 SetMapMode(m_mappingMode
);
2344 } // end of wxDC::SetSystemScale
2346 void wxDC::SetLogicalOrigin(
2353 ::GpiQueryPageViewport( m_hPS
2360 ::GpiSetPageViewport( m_hPS
2363 }; // end of wxDC::SetLogicalOrigin
2365 void wxDC::SetDeviceOrigin(
2372 m_deviceOriginX
= vX
;
2373 m_deviceOriginY
= vY
;
2374 ::GpiQueryPageViewport( m_hPS
2379 vRect
.yBottom
-= vY
;
2381 ::GpiSetPageViewport( m_hPS
2384 }; // end of wxDC::SetDeviceOrigin
2386 // ---------------------------------------------------------------------------
2387 // coordinates transformations
2388 // ---------------------------------------------------------------------------
2390 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2392 return (wxCoord
) (((x
) - m_deviceOriginX
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
) - m_logicalOriginX
);
2395 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2397 // axis orientation is not taken into account for conversion of a distance
2398 return (wxCoord
) ((x
)/(m_logicalScaleX
*m_userScaleX
*m_scaleX
));
2401 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2403 return (wxCoord
) (((y
) - m_deviceOriginY
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
) - m_logicalOriginY
);
2406 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2408 // axis orientation is not taken into account for conversion of a distance
2409 return (wxCoord
) ((y
)/(m_logicalScaleY
*m_userScaleY
*m_scaleY
));
2412 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2414 return (wxCoord
) ((x
- m_logicalOriginX
)*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
+ m_deviceOriginX
);
2417 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2419 // axis orientation is not taken into account for conversion of a distance
2420 return (wxCoord
) (x
*m_logicalScaleX
*m_userScaleX
*m_scaleX
);
2423 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2425 return (wxCoord
) ((y
- m_logicalOriginY
)*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
+ m_deviceOriginY
);
2428 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2430 // axis orientation is not taken into account for conversion of a distance
2431 return (wxCoord
) (y
*m_logicalScaleY
*m_userScaleY
*m_scaleY
);
2434 // ---------------------------------------------------------------------------
2436 // ---------------------------------------------------------------------------
2438 bool wxDC::DoBlit( wxCoord vXdest
,
2447 wxCoord
WXUNUSED(vXsrcMask
),
2448 wxCoord
WXUNUSED(vYsrcMask
) )
2450 wxMask
* pMask
= NULL
;
2452 COLORREF vOldTextColor
;
2453 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
2457 const wxBitmap
& rBmp
= pSource
->m_vSelectedBitmap
;
2459 pMask
= rBmp
.GetMask();
2460 if (!(rBmp
.Ok() && pMask
&& pMask
->GetMaskBitmap()))
2466 ::GpiQueryAttrs( m_hPS
2471 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
2473 if (m_textForegroundColour
.Ok())
2475 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
2476 ::GpiSetAttrs( m_hPS
// presentation-space handle
2477 ,PRIM_CHAR
// Char primitive.
2478 ,CBB_COLOR
// sets color.
2480 ,&vCbnd
// buffer for attributes.
2483 if (m_textBackgroundColour
.Ok())
2485 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
2488 LONG lRop
= ROP_SRCCOPY
;
2492 case wxXOR
: lRop
= ROP_SRCINVERT
; break;
2493 case wxINVERT
: lRop
= ROP_DSTINVERT
; break;
2494 case wxOR_REVERSE
: lRop
= 0x00DD0228; break;
2495 case wxAND_REVERSE
: lRop
= ROP_SRCERASE
; break;
2496 case wxCLEAR
: lRop
= ROP_ZERO
; break;
2497 case wxSET
: lRop
= ROP_ONE
; break;
2498 case wxOR_INVERT
: lRop
= ROP_MERGEPAINT
; break;
2499 case wxAND
: lRop
= ROP_SRCAND
; break;
2500 case wxOR
: lRop
= ROP_SRCPAINT
; break;
2501 case wxEQUIV
: lRop
= 0x00990066; break;
2502 case wxNAND
: lRop
= 0x007700E6; break;
2503 case wxAND_INVERT
: lRop
= 0x00220326; break;
2504 case wxCOPY
: lRop
= ROP_SRCCOPY
; break;
2505 case wxNO_OP
: lRop
= ROP_NOTSRCERASE
; break;
2506 case wxSRC_INVERT
: lRop
= ROP_SRCINVERT
; break;
2507 case wxNOR
: lRop
= ROP_NOTSRCCOPY
; break;
2509 wxFAIL_MSG( wxT("unsupported logical function") );
2518 // Blit bitmap with mask
2522 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2528 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
2529 BITMAPINFOHEADER2 vBmpHdr
;
2531 SIZEL vSize
= {0, 0};
2534 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
2535 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
2536 vBmpHdr
.cx
= vWidth
;
2537 vBmpHdr
.cy
= vHeight
;
2538 vBmpHdr
.cPlanes
= 1;
2539 vBmpHdr
.cBitCount
= 24;
2541 #if wxUSE_DC_CACHEING
2544 // create a temp buffer bitmap and DCs to access it and the mask
2546 wxDCCacheEntry
* pDCCacheEntry1
= FindDCInCache( NULL
2549 wxDCCacheEntry
* pDCCacheEntry2
= FindDCInCache( pDCCacheEntry1
2552 wxDCCacheEntry
* pBitmapCacheEntry
= FindBitmapInCache( GetHPS()
2557 hPSMask
= pDCCacheEntry1
->m_hPS
;
2558 hDCBuffer
= (HDC
)pDCCacheEntry2
->m_hPS
;
2559 hBufBitmap
= (HBITMAP
)pBitmapCacheEntry
->m_hBitmap
;
2560 wxUnusedVar(hDCMask
);
2564 hDCMask
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2565 hDCBuffer
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2566 hPSMask
= ::GpiCreatePS(vHabmain
, hDCMask
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2567 hPSBuffer
= ::GpiCreatePS(vHabmain
, hDCBuffer
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2568 hBufBitmap
= ::GpiCreateBitmap(GetHPS(), &vBmpHdr
, 0L, NULL
, NULL
);
2572 POINTL aPoint1
[4] = { {0, 0}
2575 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2577 POINTL aPoint2
[4] = { {0, 0}
2580 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2582 POINTL aPoint3
[4] = { {vXdest
, vYdest
}
2583 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2585 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2587 POINTL aPoint4
[4] = { {vXdest
, vYdest
}
2588 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2592 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
2593 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
2596 // Copy dest to buffer
2598 rc
= ::GpiBitBlt( hPSBuffer
2605 if (rc
== GPI_ERROR
)
2607 wxLogLastError(wxT("BitBlt"));
2611 // Copy src to buffer using selected raster op
2613 rc
= ::GpiBitBlt( hPSBuffer
2620 if (rc
== GPI_ERROR
)
2622 wxLogLastError(wxT("BitBlt"));
2626 // Set masked area in buffer to BLACK (pixel value 0)
2628 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
2629 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
2631 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2632 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2634 rc
= ::GpiBitBlt( hPSBuffer
2641 if (rc
== GPI_ERROR
)
2643 wxLogLastError(wxT("BitBlt"));
2647 // Set unmasked area in dest to BLACK
2649 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2650 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2651 rc
= ::GpiBitBlt( GetHPS()
2658 if (rc
== GPI_ERROR
)
2660 wxLogLastError(wxT("BitBlt"));
2664 // Restore colours to original values
2666 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
2667 ::GpiSetColor(GetHPS(), vPrevCol
);
2670 // OR buffer to dest
2672 rc
= ::GpiBitBlt( GetHPS()
2679 if (rc
== GPI_ERROR
)
2682 wxLogLastError(wxT("BitBlt"));
2686 // Tidy up temporary DCs and bitmap
2688 ::GpiSetBitmap(hPSMask
, NULLHANDLE
);
2689 ::GpiSetBitmap(hPSBuffer
, NULLHANDLE
);
2690 #if !wxUSE_DC_CACHEING
2691 ::GpiDestroyPS(hPSMask
);
2692 ::GpiDestroyPS(hPSBuffer
);
2693 ::DevCloseDC(hDCMask
);
2694 ::DevCloseDC(hDCBuffer
);
2695 ::GpiDeleteBitmap(hBufBitmap
);
2699 else // no mask, just BitBlt() it
2701 POINTL aPoint
[4] = { {vXdest
, vYdest
}
2702 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2704 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2707 bSuccess
= (::GpiBitBlt( m_hPS
2716 wxLogLastError(wxT("BitBlt"));
2719 vCbnd
.lColor
= (LONG
)vOldTextColor
;
2720 ::GpiSetAttrs( m_hPS
// presentation-space handle
2721 ,PRIM_CHAR
// Char primitive.
2722 ,CBB_COLOR
// sets color.
2724 ,&vCbnd
// buffer for attributes.
2726 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
2730 void wxDC::DoGetSize( int* pnWidth
,
2731 int* pnHeight
) const
2733 LONG lArray
[CAPS_HEIGHT
];
2735 if(::DevQueryCaps( m_hDC
2741 *pnWidth
= lArray
[CAPS_WIDTH
];
2742 *pnHeight
= lArray
[CAPS_HEIGHT
];
2744 }; // end of wxDC::DoGetSize(
2746 void wxDC::DoGetSizeMM( int* pnWidth
,
2747 int* pnHeight
) const
2749 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2751 if(::DevQueryCaps( m_hDC
2753 ,CAPS_VERTICAL_RESOLUTION
2759 int nWidth
= lArray
[CAPS_WIDTH
];
2760 int nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2761 *pnWidth
= (nHorzRes
/1000) * nWidth
;
2766 int nHeight
= lArray
[CAPS_HEIGHT
];
2767 int nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2768 *pnHeight
= (nVertRes
/1000) * nHeight
;
2771 }; // end of wxDC::DoGetSizeMM
2773 wxSize
wxDC::GetPPI() const
2775 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2779 if(::DevQueryCaps( m_hDC
2781 ,CAPS_VERTICAL_RESOLUTION
2790 nPelWidth
= lArray
[CAPS_WIDTH
];
2791 nPelHeight
= lArray
[CAPS_HEIGHT
];
2792 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2793 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2794 nWidth
= (int)((nHorzRes
/39.3) * nPelWidth
);
2795 nHeight
= (int)((nVertRes
/39.3) * nPelHeight
);
2797 wxSize
ppisize(nWidth
, nHeight
);
2799 } // end of wxDC::GetPPI
2801 void wxDC::SetLogicalScale( double dX
, double dY
)
2803 m_logicalScaleX
= dX
;
2804 m_logicalScaleY
= dY
;
2805 }; // end of wxDC::SetLogicalScale