1 /////////////////////////////////////////////////////////////////////////////
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"
27 #include "wx/statusbr.h"
31 #include "wx/module.h"
32 #include "wx/dcprint.h"
36 #include "wx/os2/private.h"
38 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
41 // wxWidgets uses the Microsoft convention that the origin is the UPPER left.
42 // Native OS/2 however in the GPI and PM define the origin as the LOWER left.
43 // In order to map OS/2 GPI/PM y coordinates to wxWidgets coordinates we must
44 // perform the following transformation:
46 // Parent object height: POBJHEIGHT
47 // Desried origin: WXORIGINY
48 // Object to place's height: OBJHEIGHT
50 // To get the OS2 position from the wxWidgets one:
52 // OS2Y = POBJHEIGHT - (WXORIGINY + OBJHEIGHT)
54 // For OS/2 wxDC's we will always determine m_vRclPaint as the size of the
55 // OS/2 Presentation Space associated with the device context. y is the
56 // desired application's y coordinate of the origin in wxWidgets space.
57 // objy is the height of the object we are going to draw.
59 #define OS2Y(y, objy) ((m_vRclPaint.yTop - m_vRclPaint.yBottom) - (y + objy))
61 // ---------------------------------------------------------------------------
63 // ---------------------------------------------------------------------------
65 static const int VIEWPORT_EXTENT
= 1000;
67 static const int MM_POINTS
= 9;
68 static const int MM_METRIC
= 10;
70 // ---------------------------------------------------------------------------
72 // ---------------------------------------------------------------------------
74 // convert degrees to radians
75 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
79 , int nForegroundColour
84 vCbnd
.lColor
= nForegroundColour
;
85 ::GpiSetAttrs( hPS
// presentation-space handle
86 ,PRIM_CHAR
// Char primitive.
87 ,CBB_COLOR
// sets color.
89 ,&vCbnd
// buffer for attributes.
100 ::GpiQueryAttrs( hPS
// presentation-space handle
101 ,PRIM_CHAR
// Char primitive.
102 ,CBB_BACK_COLOR
// Background color.
103 ,&vCbnd
// buffer for attributes.
105 return vCbnd
.lBackColor
;
111 , int nBackgroundColour
117 rc
= QueryTextBkColor(hPS
);
119 vCbnd
.lBackColor
= nBackgroundColour
;
120 ::GpiSetAttrs(hPS
, // presentation-space handle
121 PRIM_CHAR
, // Char primitive.
122 CBB_BACK_COLOR
, // sets color.
124 &vCbnd
// buffer for attributes.
131 , int nBackgroundMode
134 if(nBackgroundMode
== wxTRANSPARENT
)
139 // the background of the primitive takes over whatever is underneath.
146 // ===========================================================================
148 // ===========================================================================
150 #if wxUSE_DC_CACHEING
153 * This implementation is a bit ugly and uses the old-fashioned wxList class, so I will
154 * improve it in due course, either using arrays, or simply storing pointers to one
155 * entry for the bitmap, and two for the DCs. -- JACS
158 // ---------------------------------------------------------------------------
160 // ---------------------------------------------------------------------------
162 wxList
wxDC::m_svBitmapCache
;
163 wxList
wxDC::m_svDCCache
;
165 wxDCCacheEntry::wxDCCacheEntry(
177 } // end of wxDCCacheEntry::wxDCCacheEntry
179 wxDCCacheEntry::wxDCCacheEntry(
184 m_hBitmap
= NULLHANDLE
;
189 } // end of wxDCCacheEntry::wxDCCacheEntry
191 wxDCCacheEntry::~wxDCCacheEntry()
194 ::GpiDeleteBitmap(m_hBitmap
);
196 ::GpiDestroyPS(m_hPS
);
197 } // end of wxDCCacheEntry::~wxDCCacheEntry
199 wxDCCacheEntry
* wxDC::FindBitmapInCache(
205 int nDepth
= 24; // we'll fix this later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
206 wxNode
* pNode
= m_svBitmapCache
.First();
207 BITMAPINFOHEADER2 vBmpHdr
;
211 wxDCCacheEntry
* pEntry
= (wxDCCacheEntry
*)pNode
->Data();
213 if (pEntry
->m_nDepth
== nDepth
)
215 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
217 if (pEntry
->m_nWidth
< nWidth
|| pEntry
->m_nHeight
< nHeight
)
219 ::GpiDeleteBitmap((HBITMAP
)pEntry
->m_hBitmap
);
220 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
222 vBmpHdr
.cy
= nHeight
;
224 vBmpHdr
.cBitCount
= nDepth
;
226 pEntry
->m_hBitmap
= (WXHBITMAP
) ::GpiCreateBitmap( hPS
230 if (!pEntry
->m_hBitmap
)
232 wxLogLastError(wxT("CreateCompatibleBitmap"));
234 pEntry
->m_nWidth
= nWidth
;
235 pEntry
->m_nHeight
= nHeight
;
240 pNode
= pNode
->Next();
242 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
243 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
245 vBmpHdr
.cy
= nHeight
;
247 vBmpHdr
.cBitCount
= nDepth
;
249 WXHBITMAP hBitmap
= (WXHBITMAP
) ::GpiCreateBitmap( hPS
255 wxLogLastError(wxT("CreateCompatibleBitmap"));
257 wxDCCacheEntry
* pEntry
= new wxDCCacheEntry( hBitmap
262 AddToBitmapCache(pEntry
);
264 } // end of FindBitmapInCache
266 wxDCCacheEntry
* wxDC::FindDCInCache(
267 wxDCCacheEntry
* pNotThis
271 int nDepth
= 24; // we'll fix this up later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
272 wxNode
* pNode
= m_svDCCache
.First();
276 wxDCCacheEntry
* pEntry
= (wxDCCacheEntry
*)pNode
->Data();
279 // Don't return the same one as we already have
281 if (!pNotThis
|| (pNotThis
!= pEntry
))
283 if (pEntry
->m_nDepth
== nDepth
)
288 pNode
= pNode
->Next();
290 wxDCCacheEntry
* pEntry
= new wxDCCacheEntry( hPS
293 AddToDCCache(pEntry
);
295 } // end of wxDC::FindDCInCache
297 void wxDC::AddToBitmapCache(
298 wxDCCacheEntry
* pEntry
301 m_svBitmapCache
.Append(pEntry
);
302 } // end of wxDC::AddToBitmapCache
304 void wxDC::AddToDCCache(
305 wxDCCacheEntry
* pEntry
308 m_svDCCache
.Append(pEntry
);
309 } // end of wxDC::AddToDCCache
311 void wxDC::ClearCache()
313 m_svBitmapCache
.DeleteContents(true);
314 m_svBitmapCache
.Clear();
315 m_svBitmapCache
.DeleteContents(false);
316 m_svDCCache
.DeleteContents(true);
318 m_svDCCache
.DeleteContents(false);
319 } // end of wxDC::ClearCache
321 // Clean up cache at app exit
322 class wxDCModule
: public wxModule
325 virtual bool OnInit() { return true; }
326 virtual void OnExit() { wxDC::ClearCache(); }
329 DECLARE_DYNAMIC_CLASS(wxDCModule
)
330 }; // end of CLASS wxDCModule
332 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
334 #endif // ndef for wxUSE_DC_CACHEING
336 // ---------------------------------------------------------------------------
338 // ---------------------------------------------------------------------------
354 m_bIsPaintTime
= false; // True at Paint Time
356 wxColour
vColor( wxT("BLACK") );
357 m_pen
.SetColour(vColor
);
359 vColor
.Set( wxT("WHITE") );
360 m_brush
.SetColour(vColor
);
362 } // end of wxDC::wxDC
368 SelectOldObjects(m_hDC
);
370 // if we own the HDC, we delete it, otherwise we just release it
376 ::GpiAssociate(m_hPS
, NULLHANDLE
);
377 ::GpiDestroyPS(m_hPS
);
380 ::DevCloseDC((HDC
)m_hDC
);
385 // Just Dissacociate, not destroy if we don't own the DC
389 ::GpiAssociate(m_hPS
, NULLHANDLE
);
393 } // end of wxDC::~wxDC
395 // This will select current objects out of the DC,
396 // which is what you have to do before deleting the
398 void wxDC::SelectOldObjects(
406 ::GpiSetBitmap(hPS
, (HBITMAP
) m_hOldBitmap
);
407 if (m_vSelectedBitmap
.Ok())
409 m_vSelectedBitmap
.SetSelectedInto(NULL
);
414 // OS/2 has no other native GDI objects to set in a PS/DC like windows
422 m_brush
= wxNullBrush
;
424 m_palette
= wxNullPalette
;
426 m_backgroundBrush
= wxNullBrush
;
427 m_vSelectedBitmap
= wxNullBitmap
;
428 } // end of wxDC::SelectOldObjects
430 // ---------------------------------------------------------------------------
432 // ---------------------------------------------------------------------------
434 #define DO_SET_CLIPPING_BOX() \
438 ::GpiQueryClipBox(m_hPS, &rect); \
440 m_clipX1 = (wxCoord) XDEV2LOG(rect.xLeft); \
441 m_clipY1 = (wxCoord) YDEV2LOG(rect.yTop); \
442 m_clipX2 = (wxCoord) XDEV2LOG(rect.xRight); \
443 m_clipY2 = (wxCoord) YDEV2LOG(rect.yBottom); \
446 void wxDC::DoSetClippingRegion(
455 vY
= OS2Y(vY
,vHeight
);
458 vRect
.yTop
= vY
+ vHeight
;
459 vRect
.xRight
= vX
+ vWidth
;
461 ::GpiIntersectClipRectangle(m_hPS
, &vRect
);
462 DO_SET_CLIPPING_BOX()
463 } // end of wxDC::DoSetClippingRegion
465 void wxDC::DoSetClippingRegionAsRegion(
466 const wxRegion
& rRegion
469 wxCHECK_RET(rRegion
.GetHRGN(), wxT("invalid clipping region"));
473 ::GpiSetClipRegion( m_hPS
474 ,(HRGN
)rRegion
.GetHRGN()
477 DO_SET_CLIPPING_BOX()
478 } // end of wxDC::DoSetClippingRegionAsRegion
480 void wxDC::DestroyClippingRegion(void)
482 if (m_clipping
&& m_hPS
)
487 // TODO: this should restore the previous clipped region
488 // so that OnPaint processing works correctly, and
489 // the update doesn't get destroyed after the first
490 // DestroyClippingRegion
491 vRect
.xLeft
= XLOG2DEV(0);
492 vRect
.yTop
= YLOG2DEV(32000);
493 vRect
.xRight
= XLOG2DEV(32000);
494 vRect
.yBottom
= YLOG2DEV(0);
496 HRGN hRgn
= ::GpiCreateRegion(m_hPS
, 1, &vRect
);
498 ::GpiSetClipRegion(m_hPS
, hRgn
, &hRgnOld
);
501 } // end of wxDC::DestroyClippingRegion
503 // ---------------------------------------------------------------------------
504 // query capabilities
505 // ---------------------------------------------------------------------------
507 bool wxDC::CanDrawBitmap() const
512 bool wxDC::CanGetTextExtent() const
514 LONG lTechnology
= 0L;
516 ::DevQueryCaps(GetHDC(), CAPS_TECHNOLOGY
, 1L, &lTechnology
);
517 return (lTechnology
== CAPS_TECH_RASTER_DISPLAY
) || (lTechnology
== CAPS_TECH_RASTER_PRINTER
);
518 } // end of wxDC::CanGetTextExtent
520 int wxDC::GetDepth() const
522 LONG lArray
[CAPS_COLOR_BITCOUNT
];
523 int nBitsPerPixel
= 0;
525 if(::DevQueryCaps( GetHDC()
531 nBitsPerPixel
= (int)lArray
[CAPS_COLOR_BITCOUNT
];
533 return nBitsPerPixel
;
534 } // end of wxDC::GetDepth
536 // ---------------------------------------------------------------------------
538 // ---------------------------------------------------------------------------
543 // If this is a canvas DC then just fill with the background color
544 // Otherwise purge the whole thing
550 ::GpiQueryClipBox(m_hPS
, &vRect
);
551 ::WinFillRect(m_hPS
, &vRect
, ::GpiQueryBackColor(m_hPS
));
555 } // end of wxDC::Clear
557 bool wxDC::DoFloodFill(
560 , const wxColour
& rCol
568 bool bSuccess
= false;
570 vPtlPos
.x
= vX
; // Loads x-coordinate
571 vPtlPos
.y
= OS2Y(vY
,0); // Loads y-coordinate
572 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
573 lColor
= rCol
.GetPixel();
574 lOptions
= FF_BOUNDARY
;
575 if(wxFLOOD_SURFACE
== nStyle
)
576 lOptions
= FF_SURFACE
;
578 if ((lHits
= ::GpiFloodFill(m_hPS
, lOptions
, lColor
)) != GPI_ERROR
)
582 } // end of wxDC::DoFloodFill
584 bool wxDC::DoGetPixel(
594 vPoint
.y
= OS2Y(vY
,0);
595 lColor
= ::GpiQueryPel(m_hPS
, &vPoint
);
598 // return the color of the pixel
601 pCol
->Set( GetRValue(lColor
)
606 } // end of wxDC::DoGetPixel
608 void wxDC::DoCrossHair(
615 wxCoord vX1
= vX
- VIEWPORT_EXTENT
;
616 wxCoord vY1
= vY
- VIEWPORT_EXTENT
;
617 wxCoord vX2
= vX
+ VIEWPORT_EXTENT
;
618 wxCoord vY2
= vY
+ VIEWPORT_EXTENT
;
627 ::GpiMove(m_hPS
, &vPoint
[0]);
628 ::GpiLine(m_hPS
, &vPoint
[1]);
636 ::GpiMove(m_hPS
, &vPoint
[2]);
637 ::GpiLine(m_hPS
, &vPoint
[3]);
638 CalcBoundingBox(vX1
, vY1
);
639 CalcBoundingBox(vX2
, vY2
);
640 } // end of wxDC::DoCrossHair
642 void wxDC::DoDrawLine(
650 COLORREF vColor
= 0x00ffffff;
653 // Might be a memory DC with no Paint rect.
655 if (!(m_vRclPaint
.yTop
== 0 &&
656 m_vRclPaint
.yBottom
== 0 &&
657 m_vRclPaint
.xRight
== 0 &&
658 m_vRclPaint
.xLeft
== 0))
665 if (m_vSelectedBitmap
!= wxNullBitmap
)
667 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
668 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
679 vColor
= m_pen
.GetColour().GetPixel();
681 ::GpiSetColor(m_hPS
, vColor
);
682 ::GpiMove(m_hPS
, &vPoint
[0]);
683 ::GpiLine(m_hPS
, &vPoint
[1]);
684 CalcBoundingBox(vX1
, vY1
);
685 CalcBoundingBox(vX2
, vY2
);
686 } // end of wxDC::DoDrawLine
688 //////////////////////////////////////////////////////////////////////////////
689 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
690 // and ending at (x2, y2). The current pen is used for the outline and the
691 // current brush for filling the shape. The arc is drawn in an anticlockwise
692 // direction from the start point to the end point.
693 //////////////////////////////////////////////////////////////////////////////
694 void wxDC::DoDrawArc(
704 POINTL vPtlArc
[2]; // Structure for current position
711 ARCPARAMS vArcp
; // Structure for arc parameters
713 if((vX1
== vXc
&& vY1
== vXc
) || (vX2
== vXc
&& vY2
== vXc
))
714 return; // Draw point ??
715 dRadius
= 0.5 * ( hypot( (double)(vY1
- vYc
)
718 hypot( (double)(vY2
- vYc
)
723 dAngl1
= atan2( (double)(vY1
- vYc
)
726 dAngl2
= atan2( (double)(vY2
- vYc
)
733 // GpiPointArc can't draw full arc
735 if(dAngl2
== dAngl1
|| (vX1
== vX2
&& vY1
== vY2
) )
740 dAnglmid
= (dAngl1
+ dAngl2
)/2. + M_PI
;
741 vXm
= (wxCoord
)(vXc
+ dRadius
* cos(dAnglmid
));
742 vYm
= (wxCoord
)(vYc
+ dRadius
* sin(dAnglmid
));
757 dAnglmid
= (dAngl1
+ dAngl2
)/2.;
758 vXm
= (wxCoord
)(vXc
+ dRadius
* cos(dAnglmid
));
759 vYm
= (wxCoord
)(vYc
+ dRadius
* sin(dAnglmid
));
762 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
768 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
770 vPtlPos
.x
= vX1
; // Loads x-coordinate
771 vPtlPos
.y
= vY1
; // Loads y-coordinate
772 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
777 ::GpiPointArc(m_hPS
, vPtlArc
); // Draws the arc
778 CalcBoundingBox( (wxCoord
)(vXc
- dRadius
)
779 ,(wxCoord
)(vYc
- dRadius
)
781 CalcBoundingBox( (wxCoord
)(vXc
+ dRadius
)
782 ,(wxCoord
)(vYc
+ dRadius
)
784 } // end of wxDC::DoDrawArc
786 void wxDC::DoDrawCheckMark(
795 vY1
= OS2Y(vY1
,vHeight
);
799 vPoint
[1].x
= vX1
+ vWidth
;
800 vPoint
[1].y
= vY1
+ vHeight
;
802 ::GpiMove(m_hPS
, &vPoint
[0]);
803 ::GpiBox( m_hPS
// handle to a presentation space
804 ,DRO_OUTLINE
// draw the box outline ? or ?
805 ,&vPoint
[1] // address of the corner
806 ,0L // horizontal corner radius
807 ,0L // vertical corner radius
809 if(vWidth
> 4 && vHeight
> 4)
813 vPoint
[0].x
+= 2; vPoint
[0].y
+= 2;
814 vPoint
[1].x
-= 2; vPoint
[1].y
-= 2;
815 ::GpiMove(m_hPS
, &vPoint
[0]);
816 ::GpiLine(m_hPS
, &vPoint
[1]);
818 vPoint
[0].x
= vPoint
[1].x
;
820 ::GpiMove(m_hPS
, &vPoint
[0]);
821 ::GpiLine(m_hPS
, &vPoint
[1]);
827 wxCoord vX2
= vX1
+ vWidth
;
828 wxCoord vY2
= vY1
+ vHeight
;
833 } // end of wxDC::DoDrawCheckMark
835 void wxDC::DoDrawPoint(
841 COLORREF vColor
= 0x00ffffff;
845 vColor
= m_pen
.GetColour().GetPixel();
847 ::GpiSetColor(m_hPS
, vColor
);
849 vPoint
.y
= OS2Y(vY
,0);
850 ::GpiSetPel(m_hPS
, &vPoint
);
854 } // end of wxDC::DoDrawPoint
856 void wxDC::DoDrawPolygon(
864 ULONG ulCount
= 1; // Number of polygons.
865 POLYGON vPlgn
; // polygon.
866 ULONG flOptions
= 0L; // Drawing options.
868 //////////////////////////////////////////////////////////////////////////////
869 // This contains fields of option bits... to draw boundary lines as well as
870 // the area interior.
872 // Drawing boundary lines:
873 // POLYGON_NOBOUNDARY Does not draw boundary lines.
874 // POLYGON_BOUNDARY Draws boundary lines (the default).
876 // Construction of the area interior:
877 // POLYGON_ALTERNATE Constructs interior in alternate mode
879 // POLYGON_WINDING Constructs interior in winding mode.
880 //////////////////////////////////////////////////////////////////////////////
882 ULONG flModel
= 0L; // Drawing model.
884 //////////////////////////////////////////////////////////////////////////////
886 // POLYGON_INCL Fill is inclusive of bottom right (the default).
887 // POLYGON_EXCL Fill is exclusive of bottom right.
888 // This is provided to aid migration from other graphics models.
889 //////////////////////////////////////////////////////////////////////////////
891 LONG lHits
= 0L; // Correlation/error indicator.
894 int nIsTRANSPARENT
= 0;
895 LONG lBorderColor
= 0L;
898 lBorderColor
= m_pen
.GetColour().GetPixel();
899 lColor
= m_brush
.GetColour().GetPixel();
900 if(m_brush
.GetStyle() == wxTRANSPARENT
)
904 vPlgn
.aPointl
= (POINTL
*) calloc( n
+ 1
906 ); // well, new will call malloc
908 for(i
= 0; i
< n
; i
++)
910 vPlgn
.aPointl
[i
].x
= vPoints
[i
].x
; // +xoffset;
911 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
,0); // +yoffset;
913 flModel
= POLYGON_BOUNDARY
;
914 if(nFillStyle
== wxWINDING_RULE
)
915 flModel
|= POLYGON_WINDING
;
917 flModel
|= POLYGON_ALTERNATE
;
920 vPoint
.y
= OS2Y(vYoffset
,0);
922 ::GpiSetColor(m_hPS
, lBorderColor
);
923 ::GpiMove(m_hPS
, &vPoint
);
924 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
926 } // end of wxDC::DoDrawPolygon
928 void wxDC::DoDrawLines(
937 if (vXoffset
!= 0L || vXoffset
!= 0L)
941 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
942 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
943 ::GpiMove(m_hPS
, &vPoint
);
945 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
947 ::GpiSetColor(m_hPS
, lBorderColor
);
948 for(i
= 1; i
< n
; i
++)
950 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
951 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
952 ::GpiLine(m_hPS
, &vPoint
);
959 CalcBoundingBox( vPoints
[0].x
962 vPoint
.x
= vPoints
[0].x
;
963 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
964 ::GpiMove(m_hPS
, &vPoint
);
966 for (i
= 0; i
< n
; i
++)
968 CalcBoundingBox( vPoints
[i
].x
971 vPoint
.x
= vPoints
[i
].x
;
972 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
973 ::GpiLine(m_hPS
, &vPoint
);
976 } // end of wxDC::DoDrawLines
978 void wxDC::DoDrawRectangle(
989 int nIsTRANSPARENT
= 0;
992 // Might be a memory DC with no Paint rect.
994 if (!(m_vRclPaint
.yTop
== 0 &&
995 m_vRclPaint
.yBottom
== 0 &&
996 m_vRclPaint
.xRight
== 0 &&
997 m_vRclPaint
.xLeft
== 0))
998 vY
= OS2Y(vY
,vHeight
);
1001 if (m_vSelectedBitmap
!= wxNullBitmap
)
1003 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1004 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1005 vY
= OS2Y(vY
,vHeight
);
1009 wxCoord vX2
= vX
+ vWidth
;
1010 wxCoord vY2
= vY
+ vHeight
;
1014 vPoint
[1].x
= vX
+ vWidth
- 1;
1015 vPoint
[1].y
= vY
+ vHeight
- 1;
1016 ::GpiMove(m_hPS
, &vPoint
[0]);
1017 lColor
= m_brush
.GetColour().GetPixel();
1018 lBorderColor
= m_pen
.GetColour().GetPixel();
1019 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1021 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1023 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1024 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1025 lControl
= DRO_OUTLINE
;
1027 ::GpiSetColor(m_hPS
, lBorderColor
);
1028 ::GpiBox( m_hPS
// handle to a presentation space
1029 ,lControl
// draw the box outline ? or ?
1030 ,&vPoint
[1] // address of the corner
1031 ,0L // horizontal corner radius
1032 ,0L // vertical corner radius
1037 lControl
= DRO_OUTLINE
;
1038 ::GpiSetColor( m_hPS
1047 lControl
= DRO_FILL
;
1048 ::GpiSetColor( m_hPS
1051 vPoint
[0].x
= vX
+ 1;
1052 vPoint
[0].y
= vY
+ 1;
1053 vPoint
[1].x
= vX
+ vWidth
- 2;
1054 vPoint
[1].y
= vY
+ vHeight
- 2;
1055 ::GpiMove(m_hPS
, &vPoint
[0]);
1063 CalcBoundingBox(vX
, vY
);
1064 CalcBoundingBox(vX2
, vY2
);
1065 } // end of wxDC::DoDrawRectangle
1067 void wxDC::DoDrawRoundedRectangle(
1079 int nIsTRANSPARENT
= 0;
1082 // Might be a memory DC with no Paint rect.
1084 if (!(m_vRclPaint
.yTop
== 0 &&
1085 m_vRclPaint
.yBottom
== 0 &&
1086 m_vRclPaint
.xRight
== 0 &&
1087 m_vRclPaint
.xLeft
== 0))
1088 vY
= OS2Y(vY
,vHeight
);
1091 if (m_vSelectedBitmap
!= wxNullBitmap
)
1093 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1094 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1095 vY
= OS2Y(vY
,vHeight
);
1099 wxCoord vX2
= (vX
+ vWidth
);
1100 wxCoord vY2
= (vY
+ vHeight
);
1104 vPoint
[1].x
= vX
+ vWidth
- 1;
1105 vPoint
[1].y
= vY
+ vHeight
- 1;
1106 ::GpiMove(m_hPS
, &vPoint
[0]);
1108 lColor
= m_brush
.GetColour().GetPixel();
1109 lBorderColor
= m_pen
.GetColour().GetPixel();
1110 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1111 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1113 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1115 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1116 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1117 lControl
= DRO_OUTLINE
;
1119 ::GpiSetColor(m_hPS
, lColor
);
1120 ::GpiBox( m_hPS
// handle to a presentation space
1121 ,lControl
// draw the box outline ? or ?
1122 ,&vPoint
[1] // address of the corner
1123 ,(LONG
)dRadius
// horizontal corner radius
1124 ,(LONG
)dRadius
// vertical corner radius
1129 lControl
= DRO_OUTLINE
;
1130 ::GpiSetColor( m_hPS
1139 lControl
= DRO_FILL
;
1140 ::GpiSetColor( m_hPS
1143 vPoint
[0].x
= vX
+ 1;
1144 vPoint
[0].y
= vY
+ 1;
1145 vPoint
[1].x
= vX
+ vWidth
- 2;
1146 vPoint
[1].y
= vY
+ vHeight
- 2;
1147 ::GpiMove(m_hPS
, &vPoint
[0]);
1156 CalcBoundingBox(vX
, vY
);
1157 CalcBoundingBox(vX2
, vY2
);
1158 } // end of wxDC::DoDrawRoundedRectangle
1160 // Draw Ellipse within box (x,y) - (x+width, y+height)
1161 void wxDC::DoDrawEllipse(
1168 POINTL vPtlPos
; // Structure for current position
1169 FIXED vFxMult
; // Multiplier for ellipse
1170 ARCPARAMS vArcp
; // Structure for arc parameters
1172 vY
= OS2Y(vY
,vHeight
);
1175 vArcp
.lQ
= vHeight
/2;
1176 vArcp
.lP
= vWidth
/2;
1178 ::GpiSetArcParams( m_hPS
1180 ); // Sets parameters to default
1181 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
1182 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1185 ); // Sets current position
1186 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
1189 // DRO_FILL, DRO_OTLINEFILL - where to get
1194 ); // Draws full arc with center at current position
1196 wxCoord vX2
= (vX
+ vWidth
);
1197 wxCoord vY2
= (vY
+ vHeight
);
1199 CalcBoundingBox(vX
, vY
);
1200 CalcBoundingBox(vX2
, vY2
);
1201 } // end of wxDC::DoDrawEllipse
1203 void wxDC::DoDrawEllipticArc(
1212 POINTL vPtlPos
; // Structure for current position
1213 FIXED vFxMult
; // Multiplier for ellipse
1214 ARCPARAMS vArcp
; // Structure for arc parameters
1216 FIXED vFSweepa
; // Start angle, sweep angle
1220 vY
= OS2Y(vY
,vHeight
);
1222 dFractPart
= modf(dSa
,&dIntPart
);
1223 vFSa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1224 dFractPart
= modf(dEa
- dSa
, &dIntPart
);
1225 vFSweepa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1228 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1231 vArcp
.lQ
= vHeight
/2;
1232 vArcp
.lP
= vWidth
/2;
1234 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
1235 vPtlPos
.x
= (wxCoord
)(vX
+ vWidth
/2 * (1. + cos(DegToRad(dSa
)))); // Loads x-coordinate
1236 vPtlPos
.y
= (wxCoord
)(vY
+ vHeight
/2 * (1. + sin(DegToRad(dSa
)))); // Loads y-coordinate
1237 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
1240 // May be not to the center ?
1242 vPtlPos
.x
= vX
+ vWidth
/2 ; // Loads x-coordinate
1243 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1244 vFxMult
= MAKEFIXED(1, 0); // Sets multiplier
1247 // DRO_FILL, DRO_OTLINEFILL - where to get
1249 ::GpiPartialArc( m_hPS
1255 wxCoord vX2
= (vX
+ vWidth
);
1256 wxCoord vY2
= (vY
+ vHeight
);
1258 CalcBoundingBox(vX
, vY
);
1259 CalcBoundingBox(vX2
, vY2
);
1260 } // end of wxDC::DoDrawEllipticArc
1262 void wxDC::DoDrawIcon(
1269 // Need to copy back into a bitmap. ::WinDrawPointer uses device coords
1270 // and I don't feel like figuring those out for scrollable windows so
1271 // just convert to a bitmap then let the DoDrawBitmap routing display it
1275 DoDrawBitmap(rIcon
.GetXpmSrc(), vX
, vY
, true);
1279 wxBitmap
vBitmap(rIcon
);
1281 DoDrawBitmap(vBitmap
, vX
, vY
, false);
1283 CalcBoundingBox(vX
, vY
);
1284 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
1285 } // end of wxDC::DoDrawIcon
1287 void wxDC::DoDrawBitmap(
1288 const wxBitmap
& rBmp
1294 if (!IsKindOf(CLASSINFO(wxPrinterDC
)))
1296 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
1297 HBITMAP hBitmapOld
= NULLHANDLE
;;
1300 vY
= OS2Y(vY
,rBmp
.GetHeight());
1303 vPoint
[0].y
= vY
+ rBmp
.GetHeight();
1304 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1308 vPoint
[3].x
= rBmp
.GetWidth();
1309 vPoint
[3].y
= rBmp
.GetHeight();
1312 wxMask
* pMask
= rBmp
.GetMask();
1317 // Need to imitate ::MaskBlt in windows.
1318 // 1) Extract the bits from from the bitmap.
1319 // 2) Extract the bits from the mask
1320 // 3) Using the mask bits do the following:
1321 // A) If the mask byte is 00 leave the bitmap byte alone
1322 // B) If the mask byte is FF copy the screen color into
1324 // 4) Create a new bitmap and set its bits to the above result
1325 // 5) Blit this to the screen PS
1327 HBITMAP hMask
= (HBITMAP
)pMask
->GetMaskBitmap();
1328 HBITMAP hOldMask
= NULLHANDLE
;
1329 HBITMAP hOldBitmap
= NULLHANDLE
;
1330 HBITMAP hNewBitmap
= NULLHANDLE
;
1331 unsigned char* pucBits
; // buffer that will contain the bitmap data
1332 unsigned char* pucBitsMask
; // buffer that will contain the mask data
1333 unsigned char* pucData
; // pointer to use to traverse bitmap data
1334 unsigned char* pucDataMask
; // pointer to use to traverse mask data
1340 // The usual Memory context creation stuff
1342 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1343 SIZEL vSize
= {0, 0};
1344 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1345 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1348 // The usual bitmap header stuff
1350 BITMAPINFOHEADER2 vHeader
;
1353 memset(&vHeader
, '\0', 16);
1356 memset(&vInfo
, '\0', 16);
1358 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1359 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1361 vInfo
.cBitCount
= 24; // Set to desired count going in
1364 // Create the buffers for data....all wxBitmaps are 24 bit internally
1366 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1367 int nSizeDWORD
= sizeof(DWORD
);
1368 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
1376 // Need to get a background color for mask blitting
1378 if (IsKindOf(CLASSINFO(wxWindowDC
)))
1380 wxWindowDC
* pWindowDC
= wxDynamicCast(this, wxWindowDC
);
1382 lColor
= pWindowDC
->m_pCanvas
->GetBackgroundColour().GetPixel();
1384 else if (GetBrush().Ok())
1385 lColor
= GetBrush().GetColour().GetPixel();
1387 lColor
= m_textBackgroundColour
.GetPixel();
1390 // Bitmap must be in a double-word aligned address so we may
1391 // have some padding to worry about
1393 if (nLineBoundary
> 0)
1395 nPadding
= nSizeDWORD
- nLineBoundary
;
1396 nBytesPerLine
+= nPadding
;
1398 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1399 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1400 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1401 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1404 // Extract the bitmap and mask data
1406 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1408 vError
= ::WinGetLastError(vHabmain
);
1409 sError
= wxPMErrorToStr(vError
);
1411 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
1412 vInfo
.cBitCount
= 24;
1413 if ((lScans
= ::GpiQueryBitmapBits( hPS
1415 ,(LONG
)rBmp
.GetHeight()
1420 vError
= ::WinGetLastError(vHabmain
);
1421 sError
= wxPMErrorToStr(vError
);
1423 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
1425 vError
= ::WinGetLastError(vHabmain
);
1426 sError
= wxPMErrorToStr(vError
);
1428 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
1429 vInfo
.cBitCount
= 24;
1430 if ((lScans
= ::GpiQueryBitmapBits( hPS
1432 ,(LONG
)rBmp
.GetHeight()
1437 vError
= ::WinGetLastError(vHabmain
);
1438 sError
= wxPMErrorToStr(vError
);
1440 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
1442 vError
= ::WinGetLastError(vHabmain
);
1443 sError
= wxPMErrorToStr(vError
);
1447 // Now set the bytes(bits) according to the mask values
1448 // 3 bytes per pel...must handle one at a time
1451 pucDataMask
= pucBitsMask
;
1454 // 16 bit kludge really only kinda works. The mask gets applied
1455 // where needed but the original bitmap bits are dorked sometimes
1457 bool bpp16
= (wxDisplayDepth() == 16);
1459 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1461 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1464 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1466 else if (*pucDataMask
== 0xFF) // leave bitmap byte alone
1470 *pucData
= ((unsigned char)(lColor
>> 16));
1474 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1476 else if (*(pucDataMask
+ 1) == 0xFF) // leave bitmap byte alone
1480 *pucData
= ((unsigned char)(lColor
>> 8));
1485 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1487 else if (*(pucDataMask
+ 2) == 0xFF) // leave bitmap byte alone
1491 *pucData
= ((unsigned char)lColor
);
1496 for (j
= 0; j
< nPadding
; j
++)
1503 // Create a new bitmap
1505 vHeader
.cx
= (ULONG
)rBmp
.GetWidth();
1506 vHeader
.cy
= (ULONG
)rBmp
.GetHeight();
1507 vHeader
.cPlanes
= 1L;
1508 vHeader
.cBitCount
= 24;
1509 if ((hNewBitmap
= ::GpiCreateBitmap( hPS
1516 vError
= ::WinGetLastError(vHabmain
);
1517 sError
= wxPMErrorToStr(vError
);
1521 // Now blit it to the screen PS
1523 if ((lHits
= ::GpiWCBitBlt( (HPS
)GetHPS()
1531 vError
= ::WinGetLastError(vHabmain
);
1532 sError
= wxPMErrorToStr(vError
);
1540 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1541 ::GpiDeleteBitmap(hNewBitmap
);
1542 ::GpiDestroyPS(hPS
);
1548 ULONG lOldForeGround
= ::GpiQueryColor((HPS
)GetHPS());
1549 ULONG lOldBackGround
= ::GpiQueryBackColor((HPS
)GetHPS());
1551 if (m_textForegroundColour
.Ok())
1553 ::GpiSetColor( (HPS
)GetHPS()
1554 ,m_textForegroundColour
.GetPixel()
1557 if (m_textBackgroundColour
.Ok())
1559 ::GpiSetBackColor( (HPS
)GetHPS()
1560 ,m_textBackgroundColour
.GetPixel()
1564 // Need to alter bits in a mono bitmap to match the new
1565 // background-foreground if it is different.
1567 if (rBmp
.IsMono() &&
1568 ((m_textForegroundColour
.GetPixel() != lOldForeGround
) ||
1569 (m_textBackgroundColour
.GetPixel() != lOldBackGround
)))
1571 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1572 SIZEL vSize
= {0, 0};
1573 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1574 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1576 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1578 LONG lForeGround
= m_textForegroundColour
.GetPixel();
1579 LONG lBackGround
= m_textBackgroundColour
.GetPixel();
1581 HBITMAP hOldBitmap
= NULLHANDLE
;
1587 memset(&vInfo
, '\0', 16);
1589 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1590 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1592 vInfo
.cBitCount
= 24;
1594 unsigned char* pucBits
; // buffer that will contain the bitmap data
1595 unsigned char* pucData
; // pointer to use to traverse bitmap data
1597 pucBits
= new unsigned char[nBytesPerLine
* rBmp
.GetHeight()];
1598 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1600 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1602 vError
= ::WinGetLastError(vHabmain
);
1603 sError
= wxPMErrorToStr(vError
);
1606 if ((lScans
= ::GpiQueryBitmapBits( hPS
1608 ,(LONG
)rBmp
.GetHeight()
1613 vError
= ::WinGetLastError(vHabmain
);
1614 sError
= wxPMErrorToStr(vError
);
1617 unsigned char cOldRedFore
= (unsigned char)(lOldForeGround
>> 16);
1618 unsigned char cOldGreenFore
= (unsigned char)(lOldForeGround
>> 8);
1619 unsigned char cOldBlueFore
= (unsigned char)lOldForeGround
;
1621 unsigned char cRedFore
= (unsigned char)(lForeGround
>> 16);
1622 unsigned char cGreenFore
= (unsigned char)(lForeGround
>> 8);
1623 unsigned char cBlueFore
= (unsigned char)lForeGround
;
1625 unsigned char cRedBack
= (unsigned char)(lBackGround
>> 16);
1626 unsigned char cGreenBack
= (unsigned char)(lBackGround
>> 8);
1627 unsigned char cBlueBack
= (unsigned char)lBackGround
;
1630 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1632 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1634 unsigned char cBmpRed
= *pucData
;
1635 unsigned char cBmpGreen
= *(pucData
+ 1);
1636 unsigned char cBmpBlue
= *(pucData
+ 2);
1638 if ((cBmpRed
== cOldRedFore
) &&
1639 (cBmpGreen
== cOldGreenFore
) &&
1640 (cBmpBlue
== cOldBlueFore
))
1642 *pucData
= cBlueFore
;
1644 *pucData
= cGreenFore
;
1646 *pucData
= cRedFore
;
1651 *pucData
= cBlueBack
;
1653 *pucData
= cGreenBack
;
1655 *pucData
= cRedBack
;
1660 if ((lScans
= ::GpiSetBitmapBits( hPS
1662 ,(LONG
)rBmp
.GetHeight()
1667 vError
= ::WinGetLastError(vHabmain
);
1668 sError
= wxPMErrorToStr(vError
);
1672 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1673 ::GpiDestroyPS(hPS
);
1676 ::GpiWCBitBlt( (HPS
)GetHPS()
1683 ::GpiSetBitmap((HPS
)GetHPS(), hBitmapOld
);
1684 ::GpiSetColor((HPS
)GetHPS(), lOldForeGround
);
1685 ::GpiSetBackColor((HPS
)GetHPS(), lOldBackGround
);
1688 } // end of wxDC::DoDrawBitmap
1690 void wxDC::DoDrawText(
1691 const wxString
& rsText
1704 CalcBoundingBox(vX
, vY
);
1705 GetTextExtent(rsText
, &vWidth
, &vHeight
);
1706 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1707 } // end of wxDC::DoDrawText
1709 void wxDC::DrawAnyText(
1710 const wxString
& rsText
1715 int nOldBackground
= 0;
1722 // prepare for drawing the text
1726 // Set text color attributes
1728 if (m_textForegroundColour
.Ok())
1731 ,(int)m_textForegroundColour
.GetPixel()
1735 if (m_textBackgroundColour
.Ok())
1737 nOldBackground
= SetTextBkColor( m_hPS
1738 ,(int)m_textBackgroundColour
.GetPixel()
1744 GetTextExtent( rsText
1749 if (!(m_vRclPaint
.yTop
== 0 &&
1750 m_vRclPaint
.yBottom
== 0 &&
1751 m_vRclPaint
.xRight
== 0 &&
1752 m_vRclPaint
.xLeft
== 0))
1755 // Position Text a little differently in the Statusbar from other panels
1757 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1758 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1760 vPtlStart
.y
= (wxCoord
)(OS2Y(vY
,vTextY
/1.5)); // Full extent is a bit much
1764 if (m_vSelectedBitmap
!= wxNullBitmap
)
1766 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1767 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1768 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1769 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1771 vPtlStart
.y
= (LONG
)(OS2Y(vY
,vTextY
/1.5));
1777 PCH pzStr
= (PCH
)rsText
.c_str();
1779 ::GpiMove(m_hPS
, &vPtlStart
);
1780 lHits
= ::GpiCharString( m_hPS
1784 if (lHits
!= GPI_OK
)
1786 wxLogLastError(wxT("TextOut"));
1790 // Restore the old parameters (text foreground colour may be left because
1791 // it never is set to anything else, but background should remain
1792 // transparent even if we just drew an opaque string)
1794 if (m_textBackgroundColour
.Ok())
1795 SetTextBkColor( m_hPS
1803 void wxDC::DoDrawRotatedText(
1804 const wxString
& rsText
1822 DoDrawText(text, x, y);
1827 wxFillLogFont(&lf, &m_font);
1829 // GDI wants the angle in tenth of degree
1830 long angle10 = (long)(angle * 10);
1831 lf.lfEscapement = angle10;
1832 lf. lfOrientation = angle10;
1834 HFONT hfont = ::CreateFontIndirect(&lf);
1837 wxLogLastError("CreateFont");
1841 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1843 DrawAnyText(text, x, y);
1845 (void)::SelectObject(GetHdc(), hfontOld);
1848 // call the bounding box by adding all four vertices of the rectangle
1849 // containing the text to it (simpler and probably not slower than
1850 // determining which of them is really topmost/leftmost/...)
1852 GetTextExtent(text, &w, &h);
1854 double rad = DegToRad(angle);
1856 // "upper left" and "upper right"
1857 CalcBoundingBox(x, y);
1858 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1859 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1861 // "bottom left" and "bottom right"
1862 x += (wxCoord)(h*sin(rad));
1863 y += (wxCoord)(h*cos(rad));
1864 CalcBoundingBox(x, y);
1865 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1870 // ---------------------------------------------------------------------------
1872 // ---------------------------------------------------------------------------
1874 void wxDC::DoSelectPalette(
1879 // Set the old object temporarily, in case the assignment deletes an object
1880 // that's not yet selected out.
1891 hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1893 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1895 } // end of wxDC::DoSelectPalette
1897 void wxDC::InitializePalette()
1899 if (wxDisplayDepth() <= 8 )
1902 // Look for any window or parent that has a custom palette. If any has
1903 // one then we need to use it in drawing operations
1905 wxWindow
* pWin
= m_pCanvas
->GetAncestorWithCustomPalette();
1907 m_hasCustomPalette
= pWin
&& pWin
->HasCustomPalette();
1908 if (m_hasCustomPalette
)
1910 m_palette
= pWin
->GetPalette();
1913 // turn on PM translation for this palette
1918 } // end of wxDC::InitializePalette
1920 void wxDC::SetPalette(
1921 const wxPalette
& rPalette
1928 m_palette
= rPalette
;
1936 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1938 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1939 } // end of wxDC::SetPalette
1946 // Set the old object temporarily, in case the assignment deletes an object
1947 // that's not yet selected out.
1959 m_font
.SetPS(m_hPS
); // this will realize the font
1963 HFONT hFont
= m_font
.GetResourceHandle();
1964 if (hFont
== (HFONT
) NULL
)
1966 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
1969 m_hOldFont
= (WXHFONT
) hFont
;
1971 } // end of wxDC::SetFont
1977 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1993 m_pen
.SetPS((HPS
)m_hOldPen
);
2000 if (m_pen
.GetResourceHandle())
2004 m_hOldPen
= m_pen
.GetPS();
2006 ::GpiSetColor(m_hPS
, m_pen
.GetColour().GetPixel());
2010 void wxDC::SetBrush(
2011 const wxBrush
& rBrush
2014 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2020 if (m_brush
== rBrush
)
2030 m_brush
.SetPS((HPS
)m_hOldBrush
);
2037 if (m_brush
.GetResourceHandle())
2039 m_brush
.SetPS(m_hPS
);
2041 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
2044 } // end of wxDC::SetBrush
2046 void wxDC::SetBackground(
2047 const wxBrush
& rBrush
2050 m_backgroundBrush
= rBrush
;
2051 if (!m_backgroundBrush
.Ok())
2055 bool bCustomColours
= true;
2058 // If we haven't specified wxUSER_COLOURS, don't allow the panel/dialog box to
2059 // change background colours from the control-panel specified colours.
2061 if (m_pCanvas
->IsKindOf(CLASSINFO(wxWindow
)) &&
2062 ((m_pCanvas
->GetWindowStyleFlag() & wxUSER_COLOURS
) != wxUSER_COLOURS
))
2063 bCustomColours
= false;
2066 if (m_backgroundBrush
.GetStyle()==wxTRANSPARENT
)
2068 m_pCanvas
->SetTransparent(true);
2073 // Setting the background brush of a DC
2074 // doesn't affect the window background colour. However,
2075 // I'm leaving in the transparency setting because it's needed by
2076 // various controls (e.g. wxStaticText) to determine whether to draw
2077 // transparently or not. TODO: maybe this should be a new function
2078 // wxWindow::SetTransparency(). Should that apply to the child itself, or the
2080 // m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
2082 m_pCanvas
->SetTransparent(false);
2086 COLORREF vNewColor
= m_backgroundBrush
.GetColour().GetPixel();
2087 (void)::GpiSetBackColor((HPS
)m_hPS
, (LONG
)vNewColor
);
2088 } // end of wxDC::SetBackground
2090 void wxDC::SetBackgroundMode(
2094 m_backgroundMode
= nMode
;
2095 } // end of wxDC::SetBackgroundMode
2097 void wxDC::SetLogicalFunction(
2101 m_logicalFunction
= nFunction
;
2102 SetRop((WXHDC
)m_hDC
);
2103 } // wxDC::SetLogicalFunction
2109 if (!hDC
|| m_logicalFunction
< 0)
2113 switch (m_logicalFunction
)
2124 lCRop
= FM_MERGESRCNOT
;
2128 lCRop
= FM_NOTMASKSRC
;
2140 lCRop
= FM_MERGENOTSRC
;
2144 lCRop
= FM_MERGESRCNOT
;
2156 lCRop
= FM_SUBTRACT
;
2163 lCRop
= FM_OVERPAINT
;
2166 ::GpiSetMix((HPS
)hDC
, lCRop
);
2167 } // end of wxDC::SetRop
2169 bool wxDC::StartDoc(
2170 const wxString
& rsMessage
2173 // We might be previewing, so return true to let it continue.
2175 } // end of wxDC::StartDoc
2179 } // end of wxDC::EndDoc
2181 void wxDC::StartPage()
2183 } // end of wxDC::StartPage
2185 void wxDC::EndPage()
2187 } // end of wxDC::EndPage
2189 // ---------------------------------------------------------------------------
2191 // ---------------------------------------------------------------------------
2193 wxCoord
wxDC::GetCharHeight() const
2195 FONTMETRICS vFM
; // metrics structure
2197 ::GpiQueryFontMetrics( m_hPS
2198 ,sizeof(FONTMETRICS
)
2201 return YDEV2LOGREL(vFM
.lXHeight
);
2204 wxCoord
wxDC::GetCharWidth() const
2206 FONTMETRICS vFM
; // metrics structure
2208 ::GpiQueryFontMetrics( m_hPS
2209 ,sizeof(FONTMETRICS
)
2212 return XDEV2LOGREL(vFM
.lAveCharWidth
);
2215 void wxDC::DoGetTextExtent(
2216 const wxString
& rsString
2219 , wxCoord
* pvDescent
2220 , wxCoord
* pvExternalLeading
2224 POINTL avPoint
[TXTBOX_COUNT
];
2229 FONTMETRICS vFM
; // metrics structure
2231 ERRORID vErrorCode
; // last error id code
2232 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
2234 wxChar zMsg
[128]; // DEBUG
2238 pFontToUse
= (wxFont
*)&m_font
;
2239 l
= rsString
.length();
2242 // In world coordinates.
2244 bRc
= ::GpiQueryTextBox( m_hPS
2246 ,(PCH
)rsString
.c_str()
2247 ,TXTBOX_COUNT
// return maximum information
2248 ,avPoint
// array of coordinates points
2252 vErrorCode
= ::WinGetLastError(wxGetInstance());
2253 sError
= wxPMErrorToStr(vErrorCode
);
2255 wxSprintf(zMsg
, _T("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString
.c_str(), vErrorCode
, sError
.c_str());
2256 (void)wxMessageBox( _T("wxWidgets Menu sample")
2262 vPtMin
.x
= avPoint
[0].x
;
2263 vPtMax
.x
= avPoint
[0].x
;
2264 vPtMin
.y
= avPoint
[0].y
;
2265 vPtMax
.y
= avPoint
[0].y
;
2266 for (i
= 1; i
< 4; i
++)
2268 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
2269 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
2270 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
2271 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
2273 ::GpiQueryFontMetrics( m_hPS
2274 ,sizeof(FONTMETRICS
)
2279 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
2281 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
2283 *pvDescent
= vFM
.lMaxDescender
;
2284 if (pvExternalLeading
)
2285 *pvExternalLeading
= vFM
.lExternalLeading
;
2288 void wxDC::SetMapMode(
2292 int nPixelWidth
= 0;
2293 int nPixelHeight
= 0;
2296 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2298 m_mappingMode
= nMode
;
2300 if(::DevQueryCaps( m_hDC
2302 ,CAPS_VERTICAL_RESOLUTION
2309 nPixelWidth
= lArray
[CAPS_WIDTH
];
2310 nPixelHeight
= lArray
[CAPS_HEIGHT
];
2311 lHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2312 lVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2313 nMmWidth
= (lHorzRes
/1000) * nPixelWidth
;
2314 nMmWidth
= (lVertRes
/1000) * nPixelHeight
;
2316 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
2321 double dMm2pixelsX
= nPixelWidth
/nMmWidth
;
2322 double dMm2pixelsY
= nPixelHeight
/nMmHeight
;
2327 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
2328 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
2332 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
2333 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
2337 m_logicalScaleX
= dMm2pixelsX
;
2338 m_logicalScaleY
= dMm2pixelsY
;
2342 m_logicalScaleX
= (dMm2pixelsX
/10.0);
2343 m_logicalScaleY
= (dMm2pixelsY
/10.0);
2348 m_logicalScaleX
= 1.0;
2349 m_logicalScaleY
= 1.0;
2355 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
2356 if (!ulOptions
& PU_ARBITRARY
)
2358 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
2359 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
2361 m_nWindowExtX
= (int)MS_XDEV2LOG(VIEWPORT_EXTENT
);
2362 m_nWindowExtY
= (int)MS_YDEV2LOG(VIEWPORT_EXTENT
);
2364 }; // end of wxDC::SetMapMode
2366 void wxDC::SetUserScale(
2374 SetMapMode(m_mappingMode
);
2375 } // end of wxDC::SetUserScale
2377 void wxDC::SetAxisOrientation(
2382 m_signX
= bXLeftRight
? 1 : -1;
2383 m_signY
= bYBottomUp
? -1 : 1;
2385 SetMapMode(m_mappingMode
);
2386 } // end of wxDC::SetAxisOrientation
2388 void wxDC::SetSystemScale(
2396 SetMapMode(m_mappingMode
);
2397 } // end of wxDC::SetSystemScale
2399 void wxDC::SetLogicalOrigin(
2406 ::GpiQueryPageViewport( m_hPS
2413 ::GpiSetPageViewport( m_hPS
2416 }; // end of wxDC::SetLogicalOrigin
2418 void wxDC::SetDeviceOrigin(
2425 m_deviceOriginX
= vX
;
2426 m_deviceOriginY
= vY
;
2427 ::GpiQueryPageViewport( m_hPS
2432 vRect
.yBottom
-= vY
;
2434 ::GpiSetPageViewport( m_hPS
2437 }; // end of wxDC::SetDeviceOrigin
2439 // ---------------------------------------------------------------------------
2440 // coordinates transformations
2441 // ---------------------------------------------------------------------------
2443 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2445 return (wxCoord
) (((x
) - m_deviceOriginX
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
) - m_logicalOriginX
);
2448 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2450 // axis orientation is not taken into account for conversion of a distance
2451 return (wxCoord
) ((x
)/(m_logicalScaleX
*m_userScaleX
*m_scaleX
));
2454 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2456 return (wxCoord
) (((y
) - m_deviceOriginY
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
) - m_logicalOriginY
);
2459 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2461 // axis orientation is not taken into account for conversion of a distance
2462 return (wxCoord
) ((y
)/(m_logicalScaleY
*m_userScaleY
*m_scaleY
));
2465 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2467 return (wxCoord
) ((x
- m_logicalOriginX
)*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
+ m_deviceOriginX
);
2470 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2472 // axis orientation is not taken into account for conversion of a distance
2473 return (wxCoord
) (x
*m_logicalScaleX
*m_userScaleX
*m_scaleX
);
2476 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2478 return (wxCoord
) ((y
- m_logicalOriginY
)*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
+ m_deviceOriginY
);
2481 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2483 // axis orientation is not taken into account for conversion of a distance
2484 return (wxCoord
) (y
*m_logicalScaleY
*m_userScaleY
*m_scaleY
);
2487 // ---------------------------------------------------------------------------
2489 // ---------------------------------------------------------------------------
2505 wxMask
* pMask
= NULL
;
2507 COLORREF vOldTextColor
;
2508 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
2512 const wxBitmap
& rBmp
= pSource
->m_vSelectedBitmap
;
2514 pMask
= rBmp
.GetMask();
2515 if (!(rBmp
.Ok() && pMask
&& pMask
->GetMaskBitmap()))
2521 ::GpiQueryAttrs( m_hPS
2526 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
2528 if (m_textForegroundColour
.Ok())
2530 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
2531 ::GpiSetAttrs( m_hPS
// presentation-space handle
2532 ,PRIM_CHAR
// Char primitive.
2533 ,CBB_COLOR
// sets color.
2535 ,&vCbnd
// buffer for attributes.
2538 if (m_textBackgroundColour
.Ok())
2540 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
2543 LONG lRop
= ROP_SRCCOPY
;
2547 case wxXOR
: lRop
= ROP_SRCINVERT
; break;
2548 case wxINVERT
: lRop
= ROP_DSTINVERT
; break;
2549 case wxOR_REVERSE
: lRop
= 0x00DD0228; break;
2550 case wxAND_REVERSE
: lRop
= ROP_SRCERASE
; break;
2551 case wxCLEAR
: lRop
= ROP_ZERO
; break;
2552 case wxSET
: lRop
= ROP_ONE
; break;
2553 case wxOR_INVERT
: lRop
= ROP_MERGEPAINT
; break;
2554 case wxAND
: lRop
= ROP_SRCAND
; break;
2555 case wxOR
: lRop
= ROP_SRCPAINT
; break;
2556 case wxEQUIV
: lRop
= 0x00990066; break;
2557 case wxNAND
: lRop
= 0x007700E6; break;
2558 case wxAND_INVERT
: lRop
= 0x00220326; break;
2559 case wxCOPY
: lRop
= ROP_SRCCOPY
; break;
2560 case wxNO_OP
: lRop
= ROP_NOTSRCERASE
; break;
2561 case wxSRC_INVERT
: lRop
= ROP_SRCINVERT
; break;
2562 case wxNOR
: lRop
= ROP_NOTSRCCOPY
; break;
2564 wxFAIL_MSG( wxT("unsupported logical function") );
2573 // Blit bitmap with mask
2577 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2583 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
2584 BITMAPINFOHEADER2 vBmpHdr
;
2586 SIZEL vSize
= {0, 0};
2589 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
2590 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
2591 vBmpHdr
.cx
= vWidth
;
2592 vBmpHdr
.cy
= vHeight
;
2593 vBmpHdr
.cPlanes
= 1;
2594 vBmpHdr
.cBitCount
= 24;
2596 #if wxUSE_DC_CACHEING
2600 // create a temp buffer bitmap and DCs to access it and the mask
2602 wxDCCacheEntry
* pDCCacheEntry1
= FindDCInCache( NULL
2605 wxDCCacheEntry
* pDCCacheEntry2
= FindDCInCache( pDCCacheEntry1
2608 wxDCCacheEntry
* pBitmapCacheEntry
= FindBitmapInCache( GetHPS()
2613 hPSMask
= pDCCacheEntry1
->m_hPS
;
2614 hDCBuffer
= (HDC
)pDCCacheEntry2
->m_hPS
;
2615 hBufBitmap
= (HBITMAP
)pBitmapCacheEntry
->m_hBitmap
;
2620 hDCMask
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2621 hDCBuffer
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2622 hPSMask
= ::GpiCreatePS(vHabmain
, hDCMask
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2623 hPSBuffer
= ::GpiCreatePS(vHabmain
, hDCBuffer
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2624 hBufBitmap
= ::GpiCreateBitmap(GetHPS(), &vBmpHdr
, 0L, NULL
, NULL
);
2627 POINTL aPoint1
[4] = { {0, 0}
2630 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2632 POINTL aPoint2
[4] = { {0, 0}
2635 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2637 POINTL aPoint3
[4] = { {vXdest
, vYdest
}
2638 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2640 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2642 POINTL aPoint4
[4] = { {vXdest
, vYdest
}
2643 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2647 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
2648 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
2651 // Copy dest to buffer
2653 rc
= ::GpiBitBlt( hPSBuffer
2660 if (rc
== GPI_ERROR
)
2662 wxLogLastError(wxT("BitBlt"));
2666 // Copy src to buffer using selected raster op
2668 rc
= ::GpiBitBlt( hPSBuffer
2675 if (rc
== GPI_ERROR
)
2677 wxLogLastError(wxT("BitBlt"));
2681 // Set masked area in buffer to BLACK (pixel value 0)
2683 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
2684 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
2686 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2687 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2689 rc
= ::GpiBitBlt( hPSBuffer
2696 if (rc
== GPI_ERROR
)
2698 wxLogLastError(wxT("BitBlt"));
2702 // Set unmasked area in dest to BLACK
2704 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2705 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2706 rc
= ::GpiBitBlt( GetHPS()
2713 if (rc
== GPI_ERROR
)
2715 wxLogLastError(wxT("BitBlt"));
2719 // Restore colours to original values
2721 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
2722 ::GpiSetColor(GetHPS(), vPrevCol
);
2725 // OR buffer to dest
2727 rc
= ::GpiBitBlt( GetHPS()
2734 if (rc
== GPI_ERROR
)
2737 wxLogLastError(wxT("BitBlt"));
2741 // Tidy up temporary DCs and bitmap
2743 ::GpiSetBitmap(hPSMask
, NULLHANDLE
);
2744 ::GpiSetBitmap(hPSBuffer
, NULLHANDLE
);
2745 #if !wxUSE_DC_CACHEING
2746 ::GpiDestroyPS(hPSMask
);
2747 ::GpiDestroyPS(hPSBuffer
);
2748 ::DevCloseDC(hDCMask
);
2749 ::DevCloseDC(hDCBuffer
);
2750 ::GpiDeleteBitmap(hBufBitmap
);
2754 else // no mask, just BitBlt() it
2756 POINTL aPoint
[4] = { {vXdest
, vYdest
}
2757 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2759 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2762 bSuccess
= (::GpiBitBlt( m_hPS
2771 wxLogLastError(wxT("BitBlt"));
2774 vCbnd
.lColor
= (LONG
)vOldTextColor
;
2775 ::GpiSetAttrs( m_hPS
// presentation-space handle
2776 ,PRIM_CHAR
// Char primitive.
2777 ,CBB_COLOR
// sets color.
2779 ,&vCbnd
// buffer for attributes.
2781 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
2785 void wxDC::DoGetSize(
2790 LONG lArray
[CAPS_HEIGHT
];
2792 if(::DevQueryCaps( m_hDC
2798 *pnWidth
= lArray
[CAPS_WIDTH
];
2799 *pnHeight
= lArray
[CAPS_HEIGHT
];
2801 }; // end of wxDC::DoGetSize(
2803 void wxDC::DoGetSizeMM(
2808 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2810 if(::DevQueryCaps( m_hDC
2812 ,CAPS_VERTICAL_RESOLUTION
2821 nWidth
= lArray
[CAPS_WIDTH
];
2822 nHeight
= lArray
[CAPS_HEIGHT
];
2823 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2824 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2825 nWidth
= (nHorzRes
/1000) * nWidth
;
2826 nHeight
= (nVertRes
/1000) * nHeight
;
2828 }; // end of wxDC::DoGetSizeMM
2830 wxSize
wxDC::GetPPI() const
2832 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2836 if(::DevQueryCaps( m_hDC
2838 ,CAPS_VERTICAL_RESOLUTION
2847 nPelWidth
= lArray
[CAPS_WIDTH
];
2848 nPelHeight
= lArray
[CAPS_HEIGHT
];
2849 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2850 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2851 nWidth
= (int)((nHorzRes
/39.3) * nPelWidth
);
2852 nHeight
= (int)((nVertRes
/39.3) * nPelHeight
);
2854 return (wxSize(nWidth
,nHeight
));
2855 } // end of wxDC::GetPPI
2857 void wxDC::SetLogicalScale(
2862 m_logicalScaleX
= dX
;
2863 m_logicalScaleY
= dY
;
2864 }; // end of wxDC::SetLogicalScale