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"
28 #include "wx/statusbr.h"
32 #include "wx/module.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
= (USHORT
)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
= (USHORT
)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 m_pen
.SetColour(*wxBLACK
);
357 m_brush
.SetColour(*wxWHITE
);
359 } // end of wxDC::wxDC
365 SelectOldObjects(m_hDC
);
367 // if we own the HDC, we delete it, otherwise we just release it
373 ::GpiAssociate(m_hPS
, NULLHANDLE
);
374 ::GpiDestroyPS(m_hPS
);
377 ::DevCloseDC((HDC
)m_hDC
);
382 // Just Dissacociate, not destroy if we don't own the DC
386 ::GpiAssociate(m_hPS
, NULLHANDLE
);
390 } // end of wxDC::~wxDC
392 // This will select current objects out of the DC,
393 // which is what you have to do before deleting the
395 void wxDC::SelectOldObjects(
403 ::GpiSetBitmap(hPS
, (HBITMAP
) m_hOldBitmap
);
404 if (m_vSelectedBitmap
.Ok())
406 m_vSelectedBitmap
.SetSelectedInto(NULL
);
411 // OS/2 has no other native GDI objects to set in a PS/DC like windows
419 m_brush
= wxNullBrush
;
421 m_palette
= wxNullPalette
;
423 m_backgroundBrush
= wxNullBrush
;
424 m_vSelectedBitmap
= wxNullBitmap
;
425 } // end of wxDC::SelectOldObjects
427 // ---------------------------------------------------------------------------
429 // ---------------------------------------------------------------------------
431 #define DO_SET_CLIPPING_BOX() \
435 ::GpiQueryClipBox(m_hPS, &rect); \
437 m_clipX1 = (wxCoord) XDEV2LOG(rect.xLeft); \
438 m_clipY1 = (wxCoord) YDEV2LOG(rect.yTop); \
439 m_clipX2 = (wxCoord) XDEV2LOG(rect.xRight); \
440 m_clipY2 = (wxCoord) YDEV2LOG(rect.yBottom); \
443 void wxDC::DoSetClippingRegion(
452 vY
= OS2Y(vY
,vHeight
);
455 vRect
.yTop
= vY
+ vHeight
;
456 vRect
.xRight
= vX
+ vWidth
;
458 ::GpiIntersectClipRectangle(m_hPS
, &vRect
);
459 DO_SET_CLIPPING_BOX()
460 } // end of wxDC::DoSetClippingRegion
462 void wxDC::DoSetClippingRegionAsRegion(
463 const wxRegion
& rRegion
466 wxCHECK_RET(rRegion
.GetHRGN(), wxT("invalid clipping region"));
470 ::GpiSetClipRegion( m_hPS
471 ,(HRGN
)rRegion
.GetHRGN()
474 DO_SET_CLIPPING_BOX()
475 } // end of wxDC::DoSetClippingRegionAsRegion
477 void wxDC::DestroyClippingRegion(void)
479 if (m_clipping
&& m_hPS
)
484 // TODO: this should restore the previous clipped region
485 // so that OnPaint processing works correctly, and
486 // the update doesn't get destroyed after the first
487 // DestroyClippingRegion
488 vRect
.xLeft
= XLOG2DEV(0);
489 vRect
.yTop
= YLOG2DEV(32000);
490 vRect
.xRight
= XLOG2DEV(32000);
491 vRect
.yBottom
= YLOG2DEV(0);
493 HRGN hRgn
= ::GpiCreateRegion(m_hPS
, 1, &vRect
);
495 ::GpiSetClipRegion(m_hPS
, hRgn
, &hRgnOld
);
498 } // end of wxDC::DestroyClippingRegion
500 // ---------------------------------------------------------------------------
501 // query capabilities
502 // ---------------------------------------------------------------------------
504 bool wxDC::CanDrawBitmap() const
509 bool wxDC::CanGetTextExtent() const
511 LONG lTechnology
= 0L;
513 ::DevQueryCaps(GetHDC(), CAPS_TECHNOLOGY
, 1L, &lTechnology
);
514 return (lTechnology
== CAPS_TECH_RASTER_DISPLAY
) || (lTechnology
== CAPS_TECH_RASTER_PRINTER
);
515 } // end of wxDC::CanGetTextExtent
517 int wxDC::GetDepth() const
519 LONG lArray
[CAPS_COLOR_BITCOUNT
];
520 int nBitsPerPixel
= 0;
522 if(::DevQueryCaps( GetHDC()
528 nBitsPerPixel
= (int)lArray
[CAPS_COLOR_BITCOUNT
];
530 return nBitsPerPixel
;
531 } // end of wxDC::GetDepth
533 // ---------------------------------------------------------------------------
535 // ---------------------------------------------------------------------------
540 // If this is a canvas DC then just fill with the background color
541 // Otherwise purge the whole thing
547 ::GpiQueryClipBox(m_hPS
, &vRect
);
548 ::WinFillRect(m_hPS
, &vRect
, ::GpiQueryBackColor(m_hPS
));
552 } // end of wxDC::Clear
554 bool wxDC::DoFloodFill(
557 , const wxColour
& rCol
565 bool bSuccess
= false;
567 vPtlPos
.x
= vX
; // Loads x-coordinate
568 vPtlPos
.y
= OS2Y(vY
,0); // Loads y-coordinate
569 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
570 lColor
= rCol
.GetPixel();
571 lOptions
= FF_BOUNDARY
;
572 if(wxFLOOD_SURFACE
== nStyle
)
573 lOptions
= FF_SURFACE
;
575 if ((lHits
= ::GpiFloodFill(m_hPS
, lOptions
, lColor
)) != GPI_ERROR
)
579 } // end of wxDC::DoFloodFill
581 bool wxDC::DoGetPixel(
591 vPoint
.y
= OS2Y(vY
,0);
592 lColor
= ::GpiQueryPel(m_hPS
, &vPoint
);
595 // return the color of the pixel
598 pCol
->Set( GetRValue(lColor
)
603 } // end of wxDC::DoGetPixel
605 void wxDC::DoCrossHair(
612 wxCoord vX1
= vX
- VIEWPORT_EXTENT
;
613 wxCoord vY1
= vY
- VIEWPORT_EXTENT
;
614 wxCoord vX2
= vX
+ VIEWPORT_EXTENT
;
615 wxCoord vY2
= vY
+ VIEWPORT_EXTENT
;
624 ::GpiMove(m_hPS
, &vPoint
[0]);
625 ::GpiLine(m_hPS
, &vPoint
[1]);
633 ::GpiMove(m_hPS
, &vPoint
[2]);
634 ::GpiLine(m_hPS
, &vPoint
[3]);
635 CalcBoundingBox(vX1
, vY1
);
636 CalcBoundingBox(vX2
, vY2
);
637 } // end of wxDC::DoCrossHair
639 void wxDC::DoDrawLine(
647 COLORREF vColor
= 0x00ffffff;
650 // Might be a memory DC with no Paint rect.
652 if (!(m_vRclPaint
.yTop
== 0 &&
653 m_vRclPaint
.yBottom
== 0 &&
654 m_vRclPaint
.xRight
== 0 &&
655 m_vRclPaint
.xLeft
== 0))
662 if (m_vSelectedBitmap
!= wxNullBitmap
)
664 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
665 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
676 vColor
= m_pen
.GetColour().GetPixel();
678 ::GpiSetColor(m_hPS
, vColor
);
679 ::GpiMove(m_hPS
, &vPoint
[0]);
680 ::GpiLine(m_hPS
, &vPoint
[1]);
681 CalcBoundingBox(vX1
, vY1
);
682 CalcBoundingBox(vX2
, vY2
);
683 } // end of wxDC::DoDrawLine
685 //////////////////////////////////////////////////////////////////////////////
686 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
687 // and ending at (x2, y2). The current pen is used for the outline and the
688 // current brush for filling the shape. The arc is drawn in an anticlockwise
689 // direction from the start point to the end point.
690 //////////////////////////////////////////////////////////////////////////////
691 void wxDC::DoDrawArc(
701 POINTL vPtlArc
[2]; // Structure for current position
708 ARCPARAMS vArcp
; // Structure for arc parameters
710 if((vX1
== vXc
&& vY1
== vXc
) || (vX2
== vXc
&& vY2
== vXc
))
711 return; // Draw point ??
712 dRadius
= 0.5 * ( hypot( (double)(vY1
- vYc
)
715 hypot( (double)(vY2
- vYc
)
720 dAngl1
= atan2( (double)(vY1
- vYc
)
723 dAngl2
= atan2( (double)(vY2
- vYc
)
730 // GpiPointArc can't draw full arc
732 if(dAngl2
== dAngl1
|| (vX1
== vX2
&& vY1
== vY2
) )
737 dAnglmid
= (dAngl1
+ dAngl2
)/2. + M_PI
;
738 vXm
= (wxCoord
)(vXc
+ dRadius
* cos(dAnglmid
));
739 vYm
= (wxCoord
)(vYc
+ dRadius
* sin(dAnglmid
));
754 dAnglmid
= (dAngl1
+ dAngl2
)/2.;
755 vXm
= (wxCoord
)(vXc
+ dRadius
* cos(dAnglmid
));
756 vYm
= (wxCoord
)(vYc
+ dRadius
* sin(dAnglmid
));
759 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
765 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
767 vPtlPos
.x
= vX1
; // Loads x-coordinate
768 vPtlPos
.y
= vY1
; // Loads y-coordinate
769 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
774 ::GpiPointArc(m_hPS
, vPtlArc
); // Draws the arc
775 CalcBoundingBox( (wxCoord
)(vXc
- dRadius
)
776 ,(wxCoord
)(vYc
- dRadius
)
778 CalcBoundingBox( (wxCoord
)(vXc
+ dRadius
)
779 ,(wxCoord
)(vYc
+ dRadius
)
781 } // end of wxDC::DoDrawArc
783 void wxDC::DoDrawCheckMark(
792 vY1
= OS2Y(vY1
,vHeight
);
796 vPoint
[1].x
= vX1
+ vWidth
;
797 vPoint
[1].y
= vY1
+ vHeight
;
799 ::GpiMove(m_hPS
, &vPoint
[0]);
800 ::GpiBox( m_hPS
// handle to a presentation space
801 ,DRO_OUTLINE
// draw the box outline ? or ?
802 ,&vPoint
[1] // address of the corner
803 ,0L // horizontal corner radius
804 ,0L // vertical corner radius
806 if(vWidth
> 4 && vHeight
> 4)
810 vPoint
[0].x
+= 2; vPoint
[0].y
+= 2;
811 vPoint
[1].x
-= 2; vPoint
[1].y
-= 2;
812 ::GpiMove(m_hPS
, &vPoint
[0]);
813 ::GpiLine(m_hPS
, &vPoint
[1]);
815 vPoint
[0].x
= vPoint
[1].x
;
817 ::GpiMove(m_hPS
, &vPoint
[0]);
818 ::GpiLine(m_hPS
, &vPoint
[1]);
824 wxCoord vX2
= vX1
+ vWidth
;
825 wxCoord vY2
= vY1
+ vHeight
;
830 } // end of wxDC::DoDrawCheckMark
832 void wxDC::DoDrawPoint(
838 COLORREF vColor
= 0x00ffffff;
842 vColor
= m_pen
.GetColour().GetPixel();
844 ::GpiSetColor(m_hPS
, vColor
);
846 vPoint
.y
= OS2Y(vY
,0);
847 ::GpiSetPel(m_hPS
, &vPoint
);
851 } // end of wxDC::DoDrawPoint
853 void wxDC::DoDrawPolygon(
861 ULONG ulCount
= 1; // Number of polygons.
862 POLYGON vPlgn
; // polygon.
863 ULONG flOptions
= 0L; // Drawing options.
865 //////////////////////////////////////////////////////////////////////////////
866 // This contains fields of option bits... to draw boundary lines as well as
867 // the area interior.
869 // Drawing boundary lines:
870 // POLYGON_NOBOUNDARY Does not draw boundary lines.
871 // POLYGON_BOUNDARY Draws boundary lines (the default).
873 // Construction of the area interior:
874 // POLYGON_ALTERNATE Constructs interior in alternate mode
876 // POLYGON_WINDING Constructs interior in winding mode.
877 //////////////////////////////////////////////////////////////////////////////
879 ULONG flModel
= 0L; // Drawing model.
881 //////////////////////////////////////////////////////////////////////////////
883 // POLYGON_INCL Fill is inclusive of bottom right (the default).
884 // POLYGON_EXCL Fill is exclusive of bottom right.
885 // This is provided to aid migration from other graphics models.
886 //////////////////////////////////////////////////////////////////////////////
888 LONG lHits
= 0L; // Correlation/error indicator.
891 int nIsTRANSPARENT
= 0;
892 LONG lBorderColor
= 0L;
895 lBorderColor
= m_pen
.GetColour().GetPixel();
896 lColor
= m_brush
.GetColour().GetPixel();
897 if(m_brush
.GetStyle() == wxTRANSPARENT
)
901 vPlgn
.aPointl
= (POINTL
*) calloc( n
+ 1
903 ); // well, new will call malloc
905 for(i
= 0; i
< n
; i
++)
907 vPlgn
.aPointl
[i
].x
= vPoints
[i
].x
; // +xoffset;
908 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
,0); // +yoffset;
910 flModel
= POLYGON_BOUNDARY
;
911 if(nFillStyle
== wxWINDING_RULE
)
912 flModel
|= POLYGON_WINDING
;
914 flModel
|= POLYGON_ALTERNATE
;
917 vPoint
.y
= OS2Y(vYoffset
,0);
919 ::GpiSetColor(m_hPS
, lBorderColor
);
920 ::GpiMove(m_hPS
, &vPoint
);
921 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
923 } // end of wxDC::DoDrawPolygon
925 void wxDC::DoDrawLines(
934 if (vXoffset
!= 0L || vXoffset
!= 0L)
938 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
939 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
940 ::GpiMove(m_hPS
, &vPoint
);
942 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
944 ::GpiSetColor(m_hPS
, lBorderColor
);
945 for(i
= 1; i
< n
; i
++)
947 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
948 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
949 ::GpiLine(m_hPS
, &vPoint
);
956 CalcBoundingBox( vPoints
[0].x
959 vPoint
.x
= vPoints
[0].x
;
960 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
961 ::GpiMove(m_hPS
, &vPoint
);
963 for (i
= 0; i
< n
; i
++)
965 CalcBoundingBox( vPoints
[i
].x
968 vPoint
.x
= vPoints
[i
].x
;
969 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
970 ::GpiLine(m_hPS
, &vPoint
);
973 } // end of wxDC::DoDrawLines
975 void wxDC::DoDrawRectangle(
986 int nIsTRANSPARENT
= 0;
989 // Might be a memory DC with no Paint rect.
991 if (!(m_vRclPaint
.yTop
== 0 &&
992 m_vRclPaint
.yBottom
== 0 &&
993 m_vRclPaint
.xRight
== 0 &&
994 m_vRclPaint
.xLeft
== 0))
995 vY
= OS2Y(vY
,vHeight
);
998 if (m_vSelectedBitmap
!= wxNullBitmap
)
1000 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1001 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1002 vY
= OS2Y(vY
,vHeight
);
1006 wxCoord vX2
= vX
+ vWidth
;
1007 wxCoord vY2
= vY
+ vHeight
;
1011 vPoint
[1].x
= vX
+ vWidth
- 1;
1012 vPoint
[1].y
= vY
+ vHeight
- 1;
1013 ::GpiMove(m_hPS
, &vPoint
[0]);
1014 lColor
= m_brush
.GetColour().GetPixel();
1015 lBorderColor
= m_pen
.GetColour().GetPixel();
1016 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1018 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1020 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1021 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1022 lControl
= DRO_OUTLINE
;
1024 ::GpiSetColor(m_hPS
, lBorderColor
);
1025 ::GpiBox( m_hPS
// handle to a presentation space
1026 ,lControl
// draw the box outline ? or ?
1027 ,&vPoint
[1] // address of the corner
1028 ,0L // horizontal corner radius
1029 ,0L // vertical corner radius
1034 lControl
= DRO_OUTLINE
;
1035 ::GpiSetColor( m_hPS
1044 lControl
= DRO_FILL
;
1045 ::GpiSetColor( m_hPS
1048 vPoint
[0].x
= vX
+ 1;
1049 vPoint
[0].y
= vY
+ 1;
1050 vPoint
[1].x
= vX
+ vWidth
- 2;
1051 vPoint
[1].y
= vY
+ vHeight
- 2;
1052 ::GpiMove(m_hPS
, &vPoint
[0]);
1060 CalcBoundingBox(vX
, vY
);
1061 CalcBoundingBox(vX2
, vY2
);
1062 } // end of wxDC::DoDrawRectangle
1064 void wxDC::DoDrawRoundedRectangle(
1076 int nIsTRANSPARENT
= 0;
1079 // Might be a memory DC with no Paint rect.
1081 if (!(m_vRclPaint
.yTop
== 0 &&
1082 m_vRclPaint
.yBottom
== 0 &&
1083 m_vRclPaint
.xRight
== 0 &&
1084 m_vRclPaint
.xLeft
== 0))
1085 vY
= OS2Y(vY
,vHeight
);
1088 if (m_vSelectedBitmap
!= wxNullBitmap
)
1090 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1091 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1092 vY
= OS2Y(vY
,vHeight
);
1096 wxCoord vX2
= (vX
+ vWidth
);
1097 wxCoord vY2
= (vY
+ vHeight
);
1101 vPoint
[1].x
= vX
+ vWidth
- 1;
1102 vPoint
[1].y
= vY
+ vHeight
- 1;
1103 ::GpiMove(m_hPS
, &vPoint
[0]);
1105 lColor
= m_brush
.GetColour().GetPixel();
1106 lBorderColor
= m_pen
.GetColour().GetPixel();
1107 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1108 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1110 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1112 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1113 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1114 lControl
= DRO_OUTLINE
;
1116 ::GpiSetColor(m_hPS
, lColor
);
1117 ::GpiBox( m_hPS
// handle to a presentation space
1118 ,lControl
// draw the box outline ? or ?
1119 ,&vPoint
[1] // address of the corner
1120 ,(LONG
)dRadius
// horizontal corner radius
1121 ,(LONG
)dRadius
// vertical corner radius
1126 lControl
= DRO_OUTLINE
;
1127 ::GpiSetColor( m_hPS
1136 lControl
= DRO_FILL
;
1137 ::GpiSetColor( m_hPS
1140 vPoint
[0].x
= vX
+ 1;
1141 vPoint
[0].y
= vY
+ 1;
1142 vPoint
[1].x
= vX
+ vWidth
- 2;
1143 vPoint
[1].y
= vY
+ vHeight
- 2;
1144 ::GpiMove(m_hPS
, &vPoint
[0]);
1153 CalcBoundingBox(vX
, vY
);
1154 CalcBoundingBox(vX2
, vY2
);
1155 } // end of wxDC::DoDrawRoundedRectangle
1157 // Draw Ellipse within box (x,y) - (x+width, y+height)
1158 void wxDC::DoDrawEllipse(
1165 POINTL vPtlPos
; // Structure for current position
1166 FIXED vFxMult
; // Multiplier for ellipse
1167 ARCPARAMS vArcp
; // Structure for arc parameters
1169 vY
= OS2Y(vY
,vHeight
);
1172 vArcp
.lQ
= vHeight
/2;
1173 vArcp
.lP
= vWidth
/2;
1175 ::GpiSetArcParams( m_hPS
1177 ); // Sets parameters to default
1178 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
1179 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1182 ); // Sets current position
1183 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
1186 // DRO_FILL, DRO_OTLINEFILL - where to get
1191 ); // Draws full arc with center at current position
1193 wxCoord vX2
= (vX
+ vWidth
);
1194 wxCoord vY2
= (vY
+ vHeight
);
1196 CalcBoundingBox(vX
, vY
);
1197 CalcBoundingBox(vX2
, vY2
);
1198 } // end of wxDC::DoDrawEllipse
1200 void wxDC::DoDrawEllipticArc(
1209 POINTL vPtlPos
; // Structure for current position
1210 FIXED vFxMult
; // Multiplier for ellipse
1211 ARCPARAMS vArcp
; // Structure for arc parameters
1213 FIXED vFSweepa
; // Start angle, sweep angle
1217 vY
= OS2Y(vY
,vHeight
);
1219 dFractPart
= modf(dSa
,&dIntPart
);
1220 vFSa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1221 dFractPart
= modf(dEa
- dSa
, &dIntPart
);
1222 vFSweepa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1225 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1228 vArcp
.lQ
= vHeight
/2;
1229 vArcp
.lP
= vWidth
/2;
1231 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
1232 vPtlPos
.x
= (wxCoord
)(vX
+ vWidth
/2 * (1. + cos(DegToRad(dSa
)))); // Loads x-coordinate
1233 vPtlPos
.y
= (wxCoord
)(vY
+ vHeight
/2 * (1. + sin(DegToRad(dSa
)))); // Loads y-coordinate
1234 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
1237 // May be not to the center ?
1239 vPtlPos
.x
= vX
+ vWidth
/2 ; // Loads x-coordinate
1240 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1241 vFxMult
= MAKEFIXED(1, 0); // Sets multiplier
1244 // DRO_FILL, DRO_OTLINEFILL - where to get
1246 ::GpiPartialArc( m_hPS
1252 wxCoord vX2
= (vX
+ vWidth
);
1253 wxCoord vY2
= (vY
+ vHeight
);
1255 CalcBoundingBox(vX
, vY
);
1256 CalcBoundingBox(vX2
, vY2
);
1257 } // end of wxDC::DoDrawEllipticArc
1259 void wxDC::DoDrawIcon(
1266 // Need to copy back into a bitmap. ::WinDrawPointer uses device coords
1267 // and I don't feel like figuring those out for scrollable windows so
1268 // just convert to a bitmap then let the DoDrawBitmap routine display it
1272 DoDrawBitmap(rIcon
.GetXpmSrc(), vX
, vY
, true);
1276 wxBitmap
vBitmap(rIcon
);
1278 DoDrawBitmap(vBitmap
, vX
, vY
, false);
1280 CalcBoundingBox(vX
, vY
);
1281 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
1282 } // end of wxDC::DoDrawIcon
1284 void wxDC::DoDrawBitmap(
1285 const wxBitmap
& rBmp
1291 #if wxUSE_PRINTING_ARCHITECTURE
1292 if (!IsKindOf(CLASSINFO(wxPrinterDC
)))
1295 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
1296 HBITMAP hBitmapOld
= NULLHANDLE
;
1299 vY
= OS2Y(vY
,rBmp
.GetHeight());
1302 vPoint
[0].y
= vY
+ rBmp
.GetHeight();
1303 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1307 vPoint
[3].x
= rBmp
.GetWidth();
1308 vPoint
[3].y
= rBmp
.GetHeight();
1311 wxMask
* pMask
= rBmp
.GetMask();
1316 // Need to imitate ::MaskBlt in windows.
1317 // 1) Extract the bits from from the bitmap.
1318 // 2) Extract the bits from the mask
1319 // 3) Using the mask bits do the following:
1320 // A) If the mask byte is 00 leave the bitmap byte alone
1321 // B) If the mask byte is FF copy the screen color into
1323 // 4) Create a new bitmap and set its bits to the above result
1324 // 5) Blit this to the screen PS
1326 HBITMAP hMask
= (HBITMAP
)pMask
->GetMaskBitmap();
1327 HBITMAP hOldMask
= NULLHANDLE
;
1328 HBITMAP hOldBitmap
= NULLHANDLE
;
1329 HBITMAP hNewBitmap
= NULLHANDLE
;
1330 unsigned char* pucBits
; // buffer that will contain the bitmap data
1331 unsigned char* pucBitsMask
; // buffer that will contain the mask data
1332 unsigned char* pucData
; // pointer to use to traverse bitmap data
1333 unsigned char* pucDataMask
; // pointer to use to traverse mask data
1339 // The usual Memory context creation stuff
1341 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1342 SIZEL vSize
= {0, 0};
1343 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1344 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1347 // The usual bitmap header stuff
1349 BITMAPINFOHEADER2 vHeader
;
1352 memset(&vHeader
, '\0', 16);
1355 memset(&vInfo
, '\0', 16);
1357 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1358 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1360 vInfo
.cBitCount
= 24; // Set to desired count going in
1363 // Create the buffers for data....all wxBitmaps are 24 bit internally
1365 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1366 int nSizeDWORD
= sizeof(DWORD
);
1367 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
1375 // Need to get a background color for mask blitting
1377 if (IsKindOf(CLASSINFO(wxWindowDC
)))
1379 wxWindowDC
* pWindowDC
= wxDynamicCast(this, wxWindowDC
);
1381 lColor
= pWindowDC
->m_pCanvas
->GetBackgroundColour().GetPixel();
1383 else if (GetBrush().Ok())
1384 lColor
= GetBrush().GetColour().GetPixel();
1386 lColor
= m_textBackgroundColour
.GetPixel();
1389 // Bitmap must be in a double-word aligned address so we may
1390 // have some padding to worry about
1392 if (nLineBoundary
> 0)
1394 nPadding
= nSizeDWORD
- nLineBoundary
;
1395 nBytesPerLine
+= nPadding
;
1397 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1398 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1399 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1400 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1403 // Extract the bitmap and mask data
1405 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1407 vError
= ::WinGetLastError(vHabmain
);
1408 sError
= wxPMErrorToStr(vError
);
1410 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
1411 vInfo
.cBitCount
= 24;
1412 if ((lScans
= ::GpiQueryBitmapBits( hPS
1414 ,(LONG
)rBmp
.GetHeight()
1419 vError
= ::WinGetLastError(vHabmain
);
1420 sError
= wxPMErrorToStr(vError
);
1422 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
1424 vError
= ::WinGetLastError(vHabmain
);
1425 sError
= wxPMErrorToStr(vError
);
1427 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
1428 vInfo
.cBitCount
= 24;
1429 if ((lScans
= ::GpiQueryBitmapBits( hPS
1431 ,(LONG
)rBmp
.GetHeight()
1436 vError
= ::WinGetLastError(vHabmain
);
1437 sError
= wxPMErrorToStr(vError
);
1439 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
1441 vError
= ::WinGetLastError(vHabmain
);
1442 sError
= wxPMErrorToStr(vError
);
1446 // Now set the bytes(bits) according to the mask values
1447 // 3 bytes per pel...must handle one at a time
1450 pucDataMask
= pucBitsMask
;
1453 // 16 bit kludge really only kinda works. The mask gets applied
1454 // where needed but the original bitmap bits are dorked sometimes
1456 bool bpp16
= (wxDisplayDepth() == 16);
1458 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1460 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1463 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1465 else if (*pucDataMask
== 0xFF) // leave bitmap byte alone
1469 *pucData
= ((unsigned char)(lColor
>> 16));
1473 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1475 else if (*(pucDataMask
+ 1) == 0xFF) // leave bitmap byte alone
1479 *pucData
= ((unsigned char)(lColor
>> 8));
1484 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1486 else if (*(pucDataMask
+ 2) == 0xFF) // leave bitmap byte alone
1490 *pucData
= ((unsigned char)lColor
);
1495 for (j
= 0; j
< nPadding
; j
++)
1502 // Create a new bitmap
1504 vHeader
.cx
= (ULONG
)rBmp
.GetWidth();
1505 vHeader
.cy
= (ULONG
)rBmp
.GetHeight();
1506 vHeader
.cPlanes
= 1L;
1507 vHeader
.cBitCount
= 24;
1508 if ((hNewBitmap
= ::GpiCreateBitmap( hPS
1515 vError
= ::WinGetLastError(vHabmain
);
1516 sError
= wxPMErrorToStr(vError
);
1520 // Now blit it to the screen PS
1522 if ((lHits
= ::GpiWCBitBlt( (HPS
)GetHPS()
1530 vError
= ::WinGetLastError(vHabmain
);
1531 sError
= wxPMErrorToStr(vError
);
1539 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1540 ::GpiDeleteBitmap(hNewBitmap
);
1541 ::GpiDestroyPS(hPS
);
1547 ULONG lOldForeGround
= ::GpiQueryColor((HPS
)GetHPS());
1548 ULONG lOldBackGround
= ::GpiQueryBackColor((HPS
)GetHPS());
1550 if (m_textForegroundColour
.Ok())
1552 ::GpiSetColor( (HPS
)GetHPS()
1553 ,m_textForegroundColour
.GetPixel()
1556 if (m_textBackgroundColour
.Ok())
1558 ::GpiSetBackColor( (HPS
)GetHPS()
1559 ,m_textBackgroundColour
.GetPixel()
1563 // Need to alter bits in a mono bitmap to match the new
1564 // background-foreground if it is different.
1566 if (rBmp
.IsMono() &&
1567 ((m_textForegroundColour
.GetPixel() != lOldForeGround
) ||
1568 (m_textBackgroundColour
.GetPixel() != lOldBackGround
)))
1570 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1571 SIZEL vSize
= {0, 0};
1572 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1573 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1575 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1577 LONG lForeGround
= m_textForegroundColour
.GetPixel();
1578 LONG lBackGround
= m_textBackgroundColour
.GetPixel();
1580 HBITMAP hOldBitmap
= NULLHANDLE
;
1586 memset(&vInfo
, '\0', 16);
1588 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1589 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1591 vInfo
.cBitCount
= 24;
1593 unsigned char* pucBits
; // buffer that will contain the bitmap data
1594 unsigned char* pucData
; // pointer to use to traverse bitmap data
1596 pucBits
= new unsigned char[nBytesPerLine
* rBmp
.GetHeight()];
1597 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1599 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1601 vError
= ::WinGetLastError(vHabmain
);
1602 sError
= wxPMErrorToStr(vError
);
1605 if ((lScans
= ::GpiQueryBitmapBits( hPS
1607 ,(LONG
)rBmp
.GetHeight()
1612 vError
= ::WinGetLastError(vHabmain
);
1613 sError
= wxPMErrorToStr(vError
);
1616 unsigned char cOldRedFore
= (unsigned char)(lOldForeGround
>> 16);
1617 unsigned char cOldGreenFore
= (unsigned char)(lOldForeGround
>> 8);
1618 unsigned char cOldBlueFore
= (unsigned char)lOldForeGround
;
1620 unsigned char cRedFore
= (unsigned char)(lForeGround
>> 16);
1621 unsigned char cGreenFore
= (unsigned char)(lForeGround
>> 8);
1622 unsigned char cBlueFore
= (unsigned char)lForeGround
;
1624 unsigned char cRedBack
= (unsigned char)(lBackGround
>> 16);
1625 unsigned char cGreenBack
= (unsigned char)(lBackGround
>> 8);
1626 unsigned char cBlueBack
= (unsigned char)lBackGround
;
1629 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1631 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1633 unsigned char cBmpRed
= *pucData
;
1634 unsigned char cBmpGreen
= *(pucData
+ 1);
1635 unsigned char cBmpBlue
= *(pucData
+ 2);
1637 if ((cBmpRed
== cOldRedFore
) &&
1638 (cBmpGreen
== cOldGreenFore
) &&
1639 (cBmpBlue
== cOldBlueFore
))
1641 *pucData
= cBlueFore
;
1643 *pucData
= cGreenFore
;
1645 *pucData
= cRedFore
;
1650 *pucData
= cBlueBack
;
1652 *pucData
= cGreenBack
;
1654 *pucData
= cRedBack
;
1659 if ((lScans
= ::GpiSetBitmapBits( hPS
1661 ,(LONG
)rBmp
.GetHeight()
1666 vError
= ::WinGetLastError(vHabmain
);
1667 sError
= wxPMErrorToStr(vError
);
1671 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1672 ::GpiDestroyPS(hPS
);
1675 ::GpiWCBitBlt( (HPS
)GetHPS()
1682 ::GpiSetBitmap((HPS
)GetHPS(), hBitmapOld
);
1683 ::GpiSetColor((HPS
)GetHPS(), lOldForeGround
);
1684 ::GpiSetBackColor((HPS
)GetHPS(), lOldBackGround
);
1687 } // end of wxDC::DoDrawBitmap
1689 void wxDC::DoDrawText(
1690 const wxString
& rsText
1703 CalcBoundingBox(vX
, vY
);
1704 GetTextExtent(rsText
, &vWidth
, &vHeight
);
1705 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1706 } // end of wxDC::DoDrawText
1708 void wxDC::DrawAnyText( const wxString
& rsText
,
1712 int nOldBackground
= 0;
1719 // prepare for drawing the text
1723 // Set text color attributes
1725 if (m_textForegroundColour
.Ok())
1728 ,(int)m_textForegroundColour
.GetPixel()
1732 if (m_textBackgroundColour
.Ok())
1734 nOldBackground
= SetTextBkColor( m_hPS
1735 ,(int)m_textBackgroundColour
.GetPixel()
1741 GetTextExtent( rsText
1746 if (!(m_vRclPaint
.yTop
== 0 &&
1747 m_vRclPaint
.yBottom
== 0 &&
1748 m_vRclPaint
.xRight
== 0 &&
1749 m_vRclPaint
.xLeft
== 0))
1752 // Position Text a little differently in the Statusbar from other panels
1754 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1755 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1757 vPtlStart
.y
= (wxCoord
)(OS2Y(vY
,vTextY
/1.5)); // Full extent is a bit much
1761 if (m_vSelectedBitmap
!= wxNullBitmap
)
1763 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1764 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1765 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1766 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1768 vPtlStart
.y
= (LONG
)(OS2Y(vY
,vTextY
/1.5));
1774 PCH pzStr
= (PCH
)rsText
.c_str();
1776 ::GpiMove(m_hPS
, &vPtlStart
);
1777 lHits
= ::GpiCharString( m_hPS
1781 if (lHits
!= GPI_OK
)
1783 wxLogLastError(wxT("TextOut"));
1787 // Restore the old parameters (text foreground colour may be left because
1788 // it never is set to anything else, but background should remain
1789 // transparent even if we just drew an opaque string)
1791 if (m_textBackgroundColour
.Ok())
1792 SetTextBkColor( m_hPS
1800 void wxDC::DoDrawRotatedText(
1801 const wxString
& rsText
1819 DoDrawText(text, x, y);
1824 wxFillLogFont(&lf, &m_font);
1826 // GDI wants the angle in tenth of degree
1827 long angle10 = (long)(angle * 10);
1828 lf.lfEscapement = angle10;
1829 lf. lfOrientation = angle10;
1831 HFONT hfont = ::CreateFontIndirect(&lf);
1834 wxLogLastError("CreateFont");
1838 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1840 DrawAnyText(text, x, y);
1842 (void)::SelectObject(GetHdc(), hfontOld);
1845 // call the bounding box by adding all four vertices of the rectangle
1846 // containing the text to it (simpler and probably not slower than
1847 // determining which of them is really topmost/leftmost/...)
1849 GetTextExtent(text, &w, &h);
1851 double rad = DegToRad(angle);
1853 // "upper left" and "upper right"
1854 CalcBoundingBox(x, y);
1855 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1856 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1858 // "bottom left" and "bottom right"
1859 x += (wxCoord)(h*sin(rad));
1860 y += (wxCoord)(h*cos(rad));
1861 CalcBoundingBox(x, y);
1862 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1867 // ---------------------------------------------------------------------------
1869 // ---------------------------------------------------------------------------
1871 void wxDC::DoSelectPalette( bool WXUNUSED(bRealize
) )
1874 // Set the old object temporarily, in case the assignment deletes an object
1875 // that's not yet selected out.
1886 hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1888 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1890 } // end of wxDC::DoSelectPalette
1892 void wxDC::InitializePalette()
1894 if (wxDisplayDepth() <= 8 )
1897 // Look for any window or parent that has a custom palette. If any has
1898 // one then we need to use it in drawing operations
1900 wxWindow
* pWin
= m_pCanvas
->GetAncestorWithCustomPalette();
1902 m_hasCustomPalette
= pWin
&& pWin
->HasCustomPalette();
1903 if (m_hasCustomPalette
)
1905 m_palette
= pWin
->GetPalette();
1908 // turn on PM translation for this palette
1913 } // end of wxDC::InitializePalette
1915 void wxDC::SetPalette(
1916 const wxPalette
& rPalette
1923 m_palette
= rPalette
;
1931 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1933 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1934 } // end of wxDC::SetPalette
1941 // Set the old object temporarily, in case the assignment deletes an object
1942 // that's not yet selected out.
1954 m_font
.SetPS(m_hPS
); // this will realize the font
1958 HFONT hFont
= m_font
.GetResourceHandle();
1959 if (hFont
== (HFONT
) NULL
)
1961 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
1964 m_hOldFont
= (WXHFONT
) hFont
;
1966 } // end of wxDC::SetFont
1972 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1988 m_pen
.SetPS((HPS
)m_hOldPen
);
1995 if (m_pen
.GetResourceHandle())
1999 m_hOldPen
= m_pen
.GetPS();
2001 ::GpiSetColor(m_hPS
, m_pen
.GetColour().GetPixel());
2005 void wxDC::SetBrush(
2006 const wxBrush
& rBrush
2009 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2015 if (m_brush
== rBrush
)
2025 m_brush
.SetPS((HPS
)m_hOldBrush
);
2032 if (m_brush
.GetResourceHandle())
2034 m_brush
.SetPS(m_hPS
);
2036 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
2039 } // end of wxDC::SetBrush
2041 void wxDC::SetBackground(const wxBrush
& rBrush
)
2043 m_backgroundBrush
= rBrush
;
2045 if (m_backgroundBrush
.Ok())
2047 (void)::GpiSetBackColor((HPS
)m_hPS
, m_backgroundBrush
.GetColour().GetPixel());
2049 } // end of wxDC::SetBackground
2051 void wxDC::SetBackgroundMode(int nMode
)
2053 m_backgroundMode
= nMode
;
2054 } // end of wxDC::SetBackgroundMode
2056 void wxDC::SetLogicalFunction(int nFunction
)
2058 m_logicalFunction
= nFunction
;
2059 SetRop((WXHDC
)m_hDC
);
2060 } // wxDC::SetLogicalFunction
2062 void wxDC::SetRop(WXHDC hDC
)
2064 if (!hDC
|| m_logicalFunction
< 0)
2068 switch (m_logicalFunction
)
2079 lCRop
= FM_MERGESRCNOT
;
2083 lCRop
= FM_NOTMASKSRC
;
2095 lCRop
= FM_MERGENOTSRC
;
2099 lCRop
= FM_MERGESRCNOT
;
2111 lCRop
= FM_SUBTRACT
;
2118 lCRop
= FM_OVERPAINT
;
2121 ::GpiSetMix((HPS
)hDC
, lCRop
);
2122 } // end of wxDC::SetRop
2124 bool wxDC::StartDoc( const wxString
& WXUNUSED(rsMessage
) )
2126 // We might be previewing, so return true to let it continue.
2128 } // end of wxDC::StartDoc
2132 } // end of wxDC::EndDoc
2134 void wxDC::StartPage()
2136 } // end of wxDC::StartPage
2138 void wxDC::EndPage()
2140 } // end of wxDC::EndPage
2142 // ---------------------------------------------------------------------------
2144 // ---------------------------------------------------------------------------
2146 wxCoord
wxDC::GetCharHeight() const
2148 FONTMETRICS vFM
; // metrics structure
2150 ::GpiQueryFontMetrics( m_hPS
2151 ,sizeof(FONTMETRICS
)
2154 return YDEV2LOGREL(vFM
.lXHeight
);
2157 wxCoord
wxDC::GetCharWidth() const
2159 FONTMETRICS vFM
; // metrics structure
2161 ::GpiQueryFontMetrics( m_hPS
2162 ,sizeof(FONTMETRICS
)
2165 return XDEV2LOGREL(vFM
.lAveCharWidth
);
2168 void wxDC::DoGetTextExtent(
2169 const wxString
& rsString
2172 , wxCoord
* pvDescent
2173 , wxCoord
* pvExternalLeading
2177 POINTL avPoint
[TXTBOX_COUNT
];
2182 FONTMETRICS vFM
; // metrics structure
2184 ERRORID vErrorCode
; // last error id code
2185 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
2187 wxChar zMsg
[128]; // DEBUG
2191 pFontToUse
= (wxFont
*)&m_font
;
2192 l
= rsString
.length();
2195 // In world coordinates.
2197 bRc
= ::GpiQueryTextBox( m_hPS
2199 ,(PCH
)rsString
.c_str()
2200 ,TXTBOX_COUNT
// return maximum information
2201 ,avPoint
// array of coordinates points
2205 vErrorCode
= ::WinGetLastError(wxGetInstance());
2206 sError
= wxPMErrorToStr(vErrorCode
);
2208 wxSprintf(zMsg
, _T("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString
.c_str(), vErrorCode
, sError
.c_str());
2209 (void)wxMessageBox( _T("wxWidgets Menu sample")
2215 vPtMin
.x
= avPoint
[0].x
;
2216 vPtMax
.x
= avPoint
[0].x
;
2217 vPtMin
.y
= avPoint
[0].y
;
2218 vPtMax
.y
= avPoint
[0].y
;
2219 for (i
= 1; i
< 4; i
++)
2221 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
2222 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
2223 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
2224 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
2226 ::GpiQueryFontMetrics( m_hPS
2227 ,sizeof(FONTMETRICS
)
2232 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
2234 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
2236 *pvDescent
= vFM
.lMaxDescender
;
2237 if (pvExternalLeading
)
2238 *pvExternalLeading
= vFM
.lExternalLeading
;
2241 void wxDC::SetMapMode(
2245 int nPixelWidth
= 0;
2246 int nPixelHeight
= 0;
2249 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2251 m_mappingMode
= nMode
;
2253 if(::DevQueryCaps( m_hDC
2255 ,CAPS_VERTICAL_RESOLUTION
2262 nPixelWidth
= lArray
[CAPS_WIDTH
];
2263 nPixelHeight
= lArray
[CAPS_HEIGHT
];
2264 lHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2265 lVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2266 nMmWidth
= (lHorzRes
/1000) * nPixelWidth
;
2267 nMmWidth
= (lVertRes
/1000) * nPixelHeight
;
2269 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
2274 double dMm2pixelsX
= nPixelWidth
/nMmWidth
;
2275 double dMm2pixelsY
= nPixelHeight
/nMmHeight
;
2280 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
2281 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
2285 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
2286 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
2290 m_logicalScaleX
= dMm2pixelsX
;
2291 m_logicalScaleY
= dMm2pixelsY
;
2295 m_logicalScaleX
= (dMm2pixelsX
/10.0);
2296 m_logicalScaleY
= (dMm2pixelsY
/10.0);
2301 m_logicalScaleX
= 1.0;
2302 m_logicalScaleY
= 1.0;
2308 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
2309 if (!ulOptions
& PU_ARBITRARY
)
2311 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
2312 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
2314 m_nWindowExtX
= (int)MS_XDEV2LOG(VIEWPORT_EXTENT
);
2315 m_nWindowExtY
= (int)MS_YDEV2LOG(VIEWPORT_EXTENT
);
2317 }; // end of wxDC::SetMapMode
2319 void wxDC::SetUserScale( double dX
,
2325 SetMapMode(m_mappingMode
);
2326 } // end of wxDC::SetUserScale
2328 void wxDC::SetAxisOrientation( bool bXLeftRight
,
2331 m_signX
= bXLeftRight
? 1 : -1;
2332 m_signY
= bYBottomUp
? -1 : 1;
2334 SetMapMode(m_mappingMode
);
2335 } // end of wxDC::SetAxisOrientation
2337 void wxDC::SetSystemScale(
2345 SetMapMode(m_mappingMode
);
2346 } // end of wxDC::SetSystemScale
2348 void wxDC::SetLogicalOrigin(
2355 ::GpiQueryPageViewport( m_hPS
2362 ::GpiSetPageViewport( m_hPS
2365 }; // end of wxDC::SetLogicalOrigin
2367 void wxDC::SetDeviceOrigin(
2374 m_deviceOriginX
= vX
;
2375 m_deviceOriginY
= vY
;
2376 ::GpiQueryPageViewport( m_hPS
2381 vRect
.yBottom
-= vY
;
2383 ::GpiSetPageViewport( m_hPS
2386 }; // end of wxDC::SetDeviceOrigin
2388 // ---------------------------------------------------------------------------
2389 // coordinates transformations
2390 // ---------------------------------------------------------------------------
2392 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2394 return (wxCoord
) (((x
) - m_deviceOriginX
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
) - m_logicalOriginX
);
2397 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2399 // axis orientation is not taken into account for conversion of a distance
2400 return (wxCoord
) ((x
)/(m_logicalScaleX
*m_userScaleX
*m_scaleX
));
2403 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2405 return (wxCoord
) (((y
) - m_deviceOriginY
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
) - m_logicalOriginY
);
2408 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2410 // axis orientation is not taken into account for conversion of a distance
2411 return (wxCoord
) ((y
)/(m_logicalScaleY
*m_userScaleY
*m_scaleY
));
2414 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2416 return (wxCoord
) ((x
- m_logicalOriginX
)*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
+ m_deviceOriginX
);
2419 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2421 // axis orientation is not taken into account for conversion of a distance
2422 return (wxCoord
) (x
*m_logicalScaleX
*m_userScaleX
*m_scaleX
);
2425 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2427 return (wxCoord
) ((y
- m_logicalOriginY
)*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
+ m_deviceOriginY
);
2430 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2432 // axis orientation is not taken into account for conversion of a distance
2433 return (wxCoord
) (y
*m_logicalScaleY
*m_userScaleY
*m_scaleY
);
2436 // ---------------------------------------------------------------------------
2438 // ---------------------------------------------------------------------------
2440 bool wxDC::DoBlit( wxCoord vXdest
,
2449 wxCoord
WXUNUSED(vXsrcMask
),
2450 wxCoord
WXUNUSED(vYsrcMask
) )
2452 wxMask
* pMask
= NULL
;
2454 COLORREF vOldTextColor
;
2455 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
2459 const wxBitmap
& rBmp
= pSource
->m_vSelectedBitmap
;
2461 pMask
= rBmp
.GetMask();
2462 if (!(rBmp
.Ok() && pMask
&& pMask
->GetMaskBitmap()))
2468 ::GpiQueryAttrs( m_hPS
2473 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
2475 if (m_textForegroundColour
.Ok())
2477 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
2478 ::GpiSetAttrs( m_hPS
// presentation-space handle
2479 ,PRIM_CHAR
// Char primitive.
2480 ,CBB_COLOR
// sets color.
2482 ,&vCbnd
// buffer for attributes.
2485 if (m_textBackgroundColour
.Ok())
2487 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
2490 LONG lRop
= ROP_SRCCOPY
;
2494 case wxXOR
: lRop
= ROP_SRCINVERT
; break;
2495 case wxINVERT
: lRop
= ROP_DSTINVERT
; break;
2496 case wxOR_REVERSE
: lRop
= 0x00DD0228; break;
2497 case wxAND_REVERSE
: lRop
= ROP_SRCERASE
; break;
2498 case wxCLEAR
: lRop
= ROP_ZERO
; break;
2499 case wxSET
: lRop
= ROP_ONE
; break;
2500 case wxOR_INVERT
: lRop
= ROP_MERGEPAINT
; break;
2501 case wxAND
: lRop
= ROP_SRCAND
; break;
2502 case wxOR
: lRop
= ROP_SRCPAINT
; break;
2503 case wxEQUIV
: lRop
= 0x00990066; break;
2504 case wxNAND
: lRop
= 0x007700E6; break;
2505 case wxAND_INVERT
: lRop
= 0x00220326; break;
2506 case wxCOPY
: lRop
= ROP_SRCCOPY
; break;
2507 case wxNO_OP
: lRop
= ROP_NOTSRCERASE
; break;
2508 case wxSRC_INVERT
: lRop
= ROP_SRCINVERT
; break;
2509 case wxNOR
: lRop
= ROP_NOTSRCCOPY
; break;
2511 wxFAIL_MSG( wxT("unsupported logical function") );
2520 // Blit bitmap with mask
2524 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2530 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
2531 BITMAPINFOHEADER2 vBmpHdr
;
2533 SIZEL vSize
= {0, 0};
2536 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
2537 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
2538 vBmpHdr
.cx
= vWidth
;
2539 vBmpHdr
.cy
= vHeight
;
2540 vBmpHdr
.cPlanes
= 1;
2541 vBmpHdr
.cBitCount
= 24;
2543 #if wxUSE_DC_CACHEING
2546 // create a temp buffer bitmap and DCs to access it and the mask
2548 wxDCCacheEntry
* pDCCacheEntry1
= FindDCInCache( NULL
2551 wxDCCacheEntry
* pDCCacheEntry2
= FindDCInCache( pDCCacheEntry1
2554 wxDCCacheEntry
* pBitmapCacheEntry
= FindBitmapInCache( GetHPS()
2559 hPSMask
= pDCCacheEntry1
->m_hPS
;
2560 hDCBuffer
= (HDC
)pDCCacheEntry2
->m_hPS
;
2561 hBufBitmap
= (HBITMAP
)pBitmapCacheEntry
->m_hBitmap
;
2562 wxUnusedVar(hDCMask
);
2566 hDCMask
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2567 hDCBuffer
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2568 hPSMask
= ::GpiCreatePS(vHabmain
, hDCMask
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2569 hPSBuffer
= ::GpiCreatePS(vHabmain
, hDCBuffer
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2570 hBufBitmap
= ::GpiCreateBitmap(GetHPS(), &vBmpHdr
, 0L, NULL
, NULL
);
2574 POINTL aPoint1
[4] = { {0, 0}
2577 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2579 POINTL aPoint2
[4] = { {0, 0}
2582 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2584 POINTL aPoint3
[4] = { {vXdest
, vYdest
}
2585 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2587 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2589 POINTL aPoint4
[4] = { {vXdest
, vYdest
}
2590 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2594 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
2595 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
2598 // Copy dest to buffer
2600 rc
= ::GpiBitBlt( hPSBuffer
2607 if (rc
== GPI_ERROR
)
2609 wxLogLastError(wxT("BitBlt"));
2613 // Copy src to buffer using selected raster op
2615 rc
= ::GpiBitBlt( hPSBuffer
2622 if (rc
== GPI_ERROR
)
2624 wxLogLastError(wxT("BitBlt"));
2628 // Set masked area in buffer to BLACK (pixel value 0)
2630 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
2631 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
2633 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2634 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2636 rc
= ::GpiBitBlt( hPSBuffer
2643 if (rc
== GPI_ERROR
)
2645 wxLogLastError(wxT("BitBlt"));
2649 // Set unmasked area in dest to BLACK
2651 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2652 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2653 rc
= ::GpiBitBlt( GetHPS()
2660 if (rc
== GPI_ERROR
)
2662 wxLogLastError(wxT("BitBlt"));
2666 // Restore colours to original values
2668 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
2669 ::GpiSetColor(GetHPS(), vPrevCol
);
2672 // OR buffer to dest
2674 rc
= ::GpiBitBlt( GetHPS()
2681 if (rc
== GPI_ERROR
)
2684 wxLogLastError(wxT("BitBlt"));
2688 // Tidy up temporary DCs and bitmap
2690 ::GpiSetBitmap(hPSMask
, NULLHANDLE
);
2691 ::GpiSetBitmap(hPSBuffer
, NULLHANDLE
);
2692 #if !wxUSE_DC_CACHEING
2693 ::GpiDestroyPS(hPSMask
);
2694 ::GpiDestroyPS(hPSBuffer
);
2695 ::DevCloseDC(hDCMask
);
2696 ::DevCloseDC(hDCBuffer
);
2697 ::GpiDeleteBitmap(hBufBitmap
);
2701 else // no mask, just BitBlt() it
2703 POINTL aPoint
[4] = { {vXdest
, vYdest
}
2704 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2706 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2709 bSuccess
= (::GpiBitBlt( m_hPS
2718 wxLogLastError(wxT("BitBlt"));
2721 vCbnd
.lColor
= (LONG
)vOldTextColor
;
2722 ::GpiSetAttrs( m_hPS
// presentation-space handle
2723 ,PRIM_CHAR
// Char primitive.
2724 ,CBB_COLOR
// sets color.
2726 ,&vCbnd
// buffer for attributes.
2728 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
2732 void wxDC::DoGetSize(
2737 LONG lArray
[CAPS_HEIGHT
];
2739 if(::DevQueryCaps( m_hDC
2745 *pnWidth
= lArray
[CAPS_WIDTH
];
2746 *pnHeight
= lArray
[CAPS_HEIGHT
];
2748 }; // end of wxDC::DoGetSize(
2750 void wxDC::DoGetSizeMM( int* pnWidth
,
2751 int* pnHeight
) const
2753 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2755 if(::DevQueryCaps( m_hDC
2757 ,CAPS_VERTICAL_RESOLUTION
2763 int nWidth
= lArray
[CAPS_WIDTH
];
2764 int nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2765 *pnWidth
= (nHorzRes
/1000) * nWidth
;
2770 int nHeight
= lArray
[CAPS_HEIGHT
];
2771 int nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2772 *pnHeight
= (nVertRes
/1000) * nHeight
;
2775 }; // end of wxDC::DoGetSizeMM
2777 wxSize
wxDC::GetPPI() const
2779 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2783 if(::DevQueryCaps( m_hDC
2785 ,CAPS_VERTICAL_RESOLUTION
2794 nPelWidth
= lArray
[CAPS_WIDTH
];
2795 nPelHeight
= lArray
[CAPS_HEIGHT
];
2796 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2797 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2798 nWidth
= (int)((nHorzRes
/39.3) * nPelWidth
);
2799 nHeight
= (int)((nVertRes
/39.3) * nPelHeight
);
2801 wxSize
ppisize(nWidth
, nHeight
);
2803 } // end of wxDC::GetPPI
2805 void wxDC::SetLogicalScale(
2810 m_logicalScaleX
= dX
;
2811 m_logicalScaleY
= dY
;
2812 }; // end of wxDC::SetLogicalScale