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"
37 #include "wx/os2/private.h"
39 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
42 // wxWindows uses the Microsoft convention that the origin is the UPPER left.
43 // Native OS/2 however in the GPI and PM define the origin as the LOWER left.
44 // In order to map OS/2 GPI/PM y coordinates to wxWindows coordinates we must
45 // perform the following transformation:
47 // Parent object height: POBJHEIGHT
48 // Desried origin: WXORIGINY
49 // Object to place's height: OBJHEIGHT
51 // To get the OS2 position from the wxWindows one:
53 // OS2Y = POBJHEIGHT - (WXORIGINY + OBJHEIGHT)
55 // For OS/2 wxDC's we will always determine m_vRclPaint as the size of the
56 // OS/2 Presentation Space associated with the device context. y is the
57 // desired application's y coordinate of the origin in wxWindows space.
58 // objy is the height of the object we are going to draw.
60 #define OS2Y(y, objy) ((m_vRclPaint.yTop - m_vRclPaint.yBottom) - (y + objy))
62 // ---------------------------------------------------------------------------
64 // ---------------------------------------------------------------------------
66 static const int VIEWPORT_EXTENT
= 1000;
68 static const int MM_POINTS
= 9;
69 static const int MM_METRIC
= 10;
71 // usually this is defined in math.h
73 static const double M_PI
= 3.14159265358979323846;
76 // ---------------------------------------------------------------------------
78 // ---------------------------------------------------------------------------
80 // convert degrees to radians
81 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
85 , int nForegroundColour
90 vCbnd
.lColor
= nForegroundColour
;
91 ::GpiSetAttrs( hPS
// presentation-space handle
92 ,PRIM_CHAR
// Char primitive.
93 ,CBB_COLOR
// sets color.
95 ,&vCbnd
// buffer for attributes.
100 int QueryTextBkColor(
106 ::GpiQueryAttrs( hPS
// presentation-space handle
107 ,PRIM_CHAR
// Char primitive.
108 ,CBB_BACK_COLOR
// Background color.
109 ,&vCbnd
// buffer for attributes.
111 return vCbnd
.lBackColor
;
117 , int nBackgroundColour
123 rc
= QueryTextBkColor(hPS
);
125 vCbnd
.lBackColor
= nBackgroundColour
;
126 ::GpiSetAttrs(hPS
, // presentation-space handle
127 PRIM_CHAR
, // Char primitive.
128 CBB_BACK_COLOR
, // sets color.
130 &vCbnd
// buffer for attributes.
137 , int nBackgroundMode
140 if(nBackgroundMode
== wxTRANSPARENT
)
145 // the background of the primitive takes over whatever is underneath.
152 // ===========================================================================
154 // ===========================================================================
156 #if wxUSE_DC_CACHEING
159 * This implementation is a bit ugly and uses the old-fashioned wxList class, so I will
160 * improve it in due course, either using arrays, or simply storing pointers to one
161 * entry for the bitmap, and two for the DCs. -- JACS
164 // ---------------------------------------------------------------------------
166 // ---------------------------------------------------------------------------
168 wxList
wxDC::m_svBitmapCache
;
169 wxList
wxDC::m_svDCCache
;
171 wxDCCacheEntry::wxDCCacheEntry(
183 } // end of wxDCCacheEntry::wxDCCacheEntry
185 wxDCCacheEntry::wxDCCacheEntry(
190 m_hBitmap
= NULLHANDLE
;
195 } // end of wxDCCacheEntry::wxDCCacheEntry
197 wxDCCacheEntry::~wxDCCacheEntry()
200 ::GpiDeleteBitmap(m_hBitmap
);
202 ::GpiDestroyPS(m_hPS
);
203 } // end of wxDCCacheEntry::~wxDCCacheEntry
205 wxDCCacheEntry
* wxDC::FindBitmapInCache(
211 int nDepth
= 24; // we'll fix this later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
212 wxNode
* pNode
= m_svBitmapCache
.First();
213 BITMAPINFOHEADER2 vBmpHdr
;
217 wxDCCacheEntry
* pEntry
= (wxDCCacheEntry
*)pNode
->Data();
219 if (pEntry
->m_nDepth
== nDepth
)
221 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
223 if (pEntry
->m_nWidth
< nWidth
|| pEntry
->m_nHeight
< nHeight
)
225 ::GpiDeleteBitmap((HBITMAP
)pEntry
->m_hBitmap
);
226 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
228 vBmpHdr
.cy
= nHeight
;
230 vBmpHdr
.cBitCount
= nDepth
;
232 pEntry
->m_hBitmap
= (WXHBITMAP
) ::GpiCreateBitmap( hPS
236 if (!pEntry
->m_hBitmap
)
238 wxLogLastError(wxT("CreateCompatibleBitmap"));
240 pEntry
->m_nWidth
= nWidth
;
241 pEntry
->m_nHeight
= nHeight
;
246 pNode
= pNode
->Next();
248 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
249 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
251 vBmpHdr
.cy
= nHeight
;
253 vBmpHdr
.cBitCount
= nDepth
;
255 WXHBITMAP hBitmap
= (WXHBITMAP
) ::GpiCreateBitmap( hPS
261 wxLogLastError(wxT("CreateCompatibleBitmap"));
263 wxDCCacheEntry
* pEntry
= new wxDCCacheEntry( hBitmap
268 AddToBitmapCache(pEntry
);
270 } // end of FindBitmapInCache
272 wxDCCacheEntry
* wxDC::FindDCInCache(
273 wxDCCacheEntry
* pNotThis
277 int nDepth
= 24; // we'll fix this up later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
278 wxNode
* pNode
= m_svDCCache
.First();
282 wxDCCacheEntry
* pEntry
= (wxDCCacheEntry
*)pNode
->Data();
285 // Don't return the same one as we already have
287 if (!pNotThis
|| (pNotThis
!= pEntry
))
289 if (pEntry
->m_nDepth
== nDepth
)
294 pNode
= pNode
->Next();
296 wxDCCacheEntry
* pEntry
= new wxDCCacheEntry( hPS
299 AddToDCCache(pEntry
);
301 } // end of wxDC::FindDCInCache
303 void wxDC::AddToBitmapCache(
304 wxDCCacheEntry
* pEntry
307 m_svBitmapCache
.Append(pEntry
);
308 } // end of wxDC::AddToBitmapCache
310 void wxDC::AddToDCCache(
311 wxDCCacheEntry
* pEntry
314 m_svDCCache
.Append(pEntry
);
315 } // end of wxDC::AddToDCCache
317 void wxDC::ClearCache()
319 m_svBitmapCache
.DeleteContents(true);
320 m_svBitmapCache
.Clear();
321 m_svBitmapCache
.DeleteContents(false);
322 m_svDCCache
.DeleteContents(true);
324 m_svDCCache
.DeleteContents(false);
325 } // end of wxDC::ClearCache
327 // Clean up cache at app exit
328 class wxDCModule
: public wxModule
331 virtual bool OnInit() { return true; }
332 virtual void OnExit() { wxDC::ClearCache(); }
335 DECLARE_DYNAMIC_CLASS(wxDCModule
)
336 }; // end of CLASS wxDCModule
338 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
340 #endif // ndef for wxUSE_DC_CACHEING
342 // ---------------------------------------------------------------------------
344 // ---------------------------------------------------------------------------
360 m_bIsPaintTime
= false; // True at Paint Time
362 wxColour
vColor( wxT("BLACK") );
363 m_pen
.SetColour(vColor
);
365 vColor
.Set( wxT("WHITE") );
366 m_brush
.SetColour(vColor
);
368 } // end of wxDC::wxDC
374 SelectOldObjects(m_hDC
);
376 // if we own the HDC, we delete it, otherwise we just release it
382 ::GpiAssociate(m_hPS
, NULLHANDLE
);
383 ::GpiDestroyPS(m_hPS
);
386 ::DevCloseDC((HDC
)m_hDC
);
391 // Just Dissacociate, not destroy if we don't own the DC
395 ::GpiAssociate(m_hPS
, NULLHANDLE
);
399 } // end of wxDC::~wxDC
401 // This will select current objects out of the DC,
402 // which is what you have to do before deleting the
404 void wxDC::SelectOldObjects(
412 ::GpiSetBitmap(hPS
, (HBITMAP
) m_hOldBitmap
);
413 if (m_vSelectedBitmap
.Ok())
415 m_vSelectedBitmap
.SetSelectedInto(NULL
);
420 // OS/2 has no other native GDI objects to set in a PS/DC like windows
428 m_brush
= wxNullBrush
;
430 m_palette
= wxNullPalette
;
432 m_backgroundBrush
= wxNullBrush
;
433 m_vSelectedBitmap
= wxNullBitmap
;
434 } // end of wxDC::SelectOldObjects
436 // ---------------------------------------------------------------------------
438 // ---------------------------------------------------------------------------
440 #define DO_SET_CLIPPING_BOX() \
444 ::GpiQueryClipBox(m_hPS, &rect); \
446 m_clipX1 = (wxCoord) XDEV2LOG(rect.xLeft); \
447 m_clipY1 = (wxCoord) YDEV2LOG(rect.yTop); \
448 m_clipX2 = (wxCoord) XDEV2LOG(rect.xRight); \
449 m_clipY2 = (wxCoord) YDEV2LOG(rect.yBottom); \
452 void wxDC::DoSetClippingRegion(
461 vY
= OS2Y(vY
,vHeight
);
464 vRect
.yTop
= vY
+ vHeight
;
465 vRect
.xRight
= vX
+ vWidth
;
467 ::GpiIntersectClipRectangle(m_hPS
, &vRect
);
468 DO_SET_CLIPPING_BOX()
469 } // end of wxDC::DoSetClippingRegion
471 void wxDC::DoSetClippingRegionAsRegion(
472 const wxRegion
& rRegion
475 wxCHECK_RET(rRegion
.GetHRGN(), wxT("invalid clipping region"));
479 ::GpiSetClipRegion( m_hPS
480 ,(HRGN
)rRegion
.GetHRGN()
483 DO_SET_CLIPPING_BOX()
484 } // end of wxDC::DoSetClippingRegionAsRegion
486 void wxDC::DestroyClippingRegion(void)
488 if (m_clipping
&& m_hPS
)
493 // TODO: this should restore the previous clipped region
494 // so that OnPaint processing works correctly, and
495 // the update doesn't get destroyed after the first
496 // DestroyClippingRegion
497 vRect
.xLeft
= XLOG2DEV(0);
498 vRect
.yTop
= YLOG2DEV(32000);
499 vRect
.xRight
= XLOG2DEV(32000);
500 vRect
.yBottom
= YLOG2DEV(0);
502 HRGN hRgn
= ::GpiCreateRegion(m_hPS
, 1, &vRect
);
504 ::GpiSetClipRegion(m_hPS
, hRgn
, &hRgnOld
);
507 } // end of wxDC::DestroyClippingRegion
509 // ---------------------------------------------------------------------------
510 // query capabilities
511 // ---------------------------------------------------------------------------
513 bool wxDC::CanDrawBitmap() const
518 bool wxDC::CanGetTextExtent() const
520 LONG lTechnology
= 0L;
522 ::DevQueryCaps(GetHDC(), CAPS_TECHNOLOGY
, 1L, &lTechnology
);
523 return (lTechnology
== CAPS_TECH_RASTER_DISPLAY
) || (lTechnology
== CAPS_TECH_RASTER_PRINTER
);
524 } // end of wxDC::CanGetTextExtent
526 int wxDC::GetDepth() const
528 LONG lArray
[CAPS_COLOR_BITCOUNT
];
531 if(::DevQueryCaps( GetHDC()
537 nBitsPerPixel
= (int)lArray
[CAPS_COLOR_BITCOUNT
];
539 return nBitsPerPixel
;
540 } // end of wxDC::GetDepth
542 // ---------------------------------------------------------------------------
544 // ---------------------------------------------------------------------------
549 // If this is a canvas DC then just fill with the background color
550 // Otherwise purge the whole thing
556 ::GpiQueryClipBox(m_hPS
, &vRect
);
557 ::WinFillRect(m_hPS
, &vRect
, ::GpiQueryBackColor(m_hPS
));
561 } // end of wxDC::Clear
563 bool wxDC::DoFloodFill(
566 , const wxColour
& rCol
574 bool bSuccess
= false;
576 vPtlPos
.x
= vX
; // Loads x-coordinate
577 vPtlPos
.y
= OS2Y(vY
,0); // Loads y-coordinate
578 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
579 lColor
= rCol
.GetPixel();
580 lOptions
= FF_BOUNDARY
;
581 if(wxFLOOD_SURFACE
== nStyle
)
582 lOptions
= FF_SURFACE
;
584 if ((lHits
= ::GpiFloodFill(m_hPS
, lOptions
, lColor
)) != GPI_ERROR
)
588 } // end of wxDC::DoFloodFill
590 bool wxDC::DoGetPixel(
600 vPoint
.y
= OS2Y(vY
,0);
601 lColor
= ::GpiSetPel(m_hPS
, &vPoint
);
604 // Get the color of the pen
606 LONG lPencolor
= 0x00ffffff;
610 lPencolor
= m_pen
.GetColour().GetPixel();
614 // return the color of the pixel
617 pCol
->Set( GetRValue(lColor
)
621 return(lColor
== lPencolor
);
622 } // end of wxDC::DoGetPixel
624 void wxDC::DoCrossHair(
631 wxCoord vX1
= vX
- VIEWPORT_EXTENT
;
632 wxCoord vY1
= vY
- VIEWPORT_EXTENT
;
633 wxCoord vX2
= vX
+ VIEWPORT_EXTENT
;
634 wxCoord vY2
= vY
+ VIEWPORT_EXTENT
;
643 ::GpiMove(m_hPS
, &vPoint
[0]);
644 ::GpiLine(m_hPS
, &vPoint
[1]);
652 ::GpiMove(m_hPS
, &vPoint
[2]);
653 ::GpiLine(m_hPS
, &vPoint
[3]);
654 CalcBoundingBox(vX1
, vY1
);
655 CalcBoundingBox(vX2
, vY2
);
656 } // end of wxDC::DoCrossHair
658 void wxDC::DoDrawLine(
666 COLORREF vColor
= 0x00ffffff;
669 // Might be a memory DC with no Paint rect.
671 if (!(m_vRclPaint
.yTop
== 0 &&
672 m_vRclPaint
.yBottom
== 0 &&
673 m_vRclPaint
.xRight
== 0 &&
674 m_vRclPaint
.xLeft
== 0))
681 if (m_vSelectedBitmap
!= wxNullBitmap
)
683 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
684 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
695 vColor
= m_pen
.GetColour().GetPixel();
697 ::GpiSetColor(m_hPS
, vColor
);
698 ::GpiMove(m_hPS
, &vPoint
[0]);
699 ::GpiLine(m_hPS
, &vPoint
[1]);
700 CalcBoundingBox(vX1
, vY1
);
701 CalcBoundingBox(vX2
, vY2
);
702 } // end of wxDC::DoDrawLine
704 //////////////////////////////////////////////////////////////////////////////
705 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
706 // and ending at (x2, y2). The current pen is used for the outline and the
707 // current brush for filling the shape. The arc is drawn in an anticlockwise
708 // direction from the start point to the end point.
709 //////////////////////////////////////////////////////////////////////////////
710 void wxDC::DoDrawArc(
720 POINTL vPtlArc
[2]; // Structure for current position
729 ARCPARAMS vArcp
; // Structure for arc parameters
731 if((vX1
== vXc
&& vY1
== vXc
) || (vX2
== vXc
&& vY2
== vXc
))
732 return; // Draw point ??
733 dRadius
= 0.5 * ( hypot( (double)(vY1
- vYc
)
736 hypot( (double)(vY2
- vYc
)
741 dAngl1
= atan2( (double)(vY1
- vYc
)
744 dAngl2
= atan2( (double)(vY2
- vYc
)
751 // GpiPointArc can't draw full arc
753 if(dAngl2
== dAngl1
|| (vX1
== vX2
&& vY1
== vY2
) )
758 dAnglmid
= (dAngl1
+ dAngl2
)/2. + M_PI
;
759 vXm
= vXc
+ dRadius
* cos(dAnglmid
);
760 vYm
= vYc
+ dRadius
* sin(dAnglmid
);
775 dAnglmid
= (dAngl1
+ dAngl2
)/2.;
776 vXm
= vXc
+ dRadius
* cos(dAnglmid
);
777 vYm
= vYc
+ dRadius
* sin(dAnglmid
);
780 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
786 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
788 vPtlPos
.x
= vX1
; // Loads x-coordinate
789 vPtlPos
.y
= vY1
; // Loads y-coordinate
790 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
795 ::GpiPointArc(m_hPS
, vPtlArc
); // Draws the arc
796 CalcBoundingBox( (vXc
- dRadius
)
799 CalcBoundingBox( (vXc
+ dRadius
)
802 } // end of wxDC::DoDrawArc
804 void wxDC::DoDrawCheckMark(
813 vY1
= OS2Y(vY1
,vHeight
);
817 vPoint
[1].x
= vX1
+ vWidth
;
818 vPoint
[1].y
= vY1
+ vHeight
;
820 ::GpiMove(m_hPS
, &vPoint
[0]);
821 ::GpiBox( m_hPS
// handle to a presentation space
822 ,DRO_OUTLINE
// draw the box outline ? or ?
823 ,&vPoint
[1] // address of the corner
824 ,0L // horizontal corner radius
825 ,0L // vertical corner radius
827 if(vWidth
> 4 && vHeight
> 4)
831 vPoint
[0].x
+= 2; vPoint
[0].y
+= 2;
832 vPoint
[1].x
-= 2; vPoint
[1].y
-= 2;
833 ::GpiMove(m_hPS
, &vPoint
[0]);
834 ::GpiLine(m_hPS
, &vPoint
[1]);
836 vPoint
[0].x
= vPoint
[1].x
;
838 ::GpiMove(m_hPS
, &vPoint
[0]);
839 ::GpiLine(m_hPS
, &vPoint
[1]);
845 wxCoord vX2
= vX1
+ vWidth
;
846 wxCoord vY2
= vY1
+ vHeight
;
851 } // end of wxDC::DoDrawCheckMark
853 void wxDC::DoDrawPoint(
859 COLORREF vColor
= 0x00ffffff;
863 vColor
= m_pen
.GetColour().GetPixel();
865 ::GpiSetColor(m_hPS
, vColor
);
867 vPoint
.y
= OS2Y(vY
,0);
868 ::GpiSetPel(m_hPS
, &vPoint
);
872 } // end of wxDC::DoDrawPoint
874 void wxDC::DoDrawPolygon(
882 ULONG ulCount
= 1; // Number of polygons.
883 POLYGON vPlgn
; // polygon.
884 ULONG flOptions
= 0L; // Drawing options.
886 //////////////////////////////////////////////////////////////////////////////
887 // This contains fields of option bits... to draw boundary lines as well as
888 // the area interior.
890 // Drawing boundary lines:
891 // POLYGON_NOBOUNDARY Does not draw boundary lines.
892 // POLYGON_BOUNDARY Draws boundary lines (the default).
894 // Construction of the area interior:
895 // POLYGON_ALTERNATE Constructs interior in alternate mode
897 // POLYGON_WINDING Constructs interior in winding mode.
898 //////////////////////////////////////////////////////////////////////////////
900 ULONG flModel
= 0L; // Drawing model.
902 //////////////////////////////////////////////////////////////////////////////
904 // POLYGON_INCL Fill is inclusive of bottom right (the default).
905 // POLYGON_EXCL Fill is exclusive of bottom right.
906 // This is provided to aid migration from other graphics models.
907 //////////////////////////////////////////////////////////////////////////////
909 LONG lHits
= 0L; // Correlation/error indicator.
912 int nIsTRANSPARENT
= 0;
913 LONG lBorderColor
= 0L;
916 lBorderColor
= m_pen
.GetColour().GetPixel();
917 lColor
= m_brush
.GetColour().GetPixel();
918 if(m_brush
.GetStyle() == wxTRANSPARENT
)
922 vPlgn
.aPointl
= (POINTL
*) calloc( n
+ 1
924 ); // well, new will call malloc
926 for(i
= 0; i
< n
; i
++)
928 vPlgn
.aPointl
[i
].x
= vPoints
[i
].x
; // +xoffset;
929 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
,0); // +yoffset;
931 flModel
= POLYGON_BOUNDARY
;
932 if(nFillStyle
== wxWINDING_RULE
)
933 flModel
|= POLYGON_WINDING
;
935 flModel
|= POLYGON_ALTERNATE
;
938 vPoint
.y
= OS2Y(vYoffset
,0);
940 ::GpiSetColor(m_hPS
, lBorderColor
);
941 ::GpiMove(m_hPS
, &vPoint
);
942 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
944 } // end of wxDC::DoDrawPolygon
946 void wxDC::DoDrawLines(
955 if (vXoffset
!= 0L || vXoffset
!= 0L)
959 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
960 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
961 ::GpiMove(m_hPS
, &vPoint
);
963 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
965 ::GpiSetColor(m_hPS
, lBorderColor
);
966 for(i
= 1; i
< n
; i
++)
968 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
969 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
970 ::GpiLine(m_hPS
, &vPoint
);
977 CalcBoundingBox( vPoints
[i
].x
980 vPoint
.x
= vPoints
[0].x
;
981 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
982 ::GpiMove(m_hPS
, &vPoint
);
984 for (i
= 0; i
< n
; i
++)
986 CalcBoundingBox( vPoints
[i
].x
989 vPoint
.x
= vPoints
[i
].x
;
990 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
991 ::GpiLine(m_hPS
, &vPoint
);
994 } // end of wxDC::DoDrawLines
996 void wxDC::DoDrawRectangle(
1007 int nIsTRANSPARENT
= 0;
1010 // Might be a memory DC with no Paint rect.
1012 if (!(m_vRclPaint
.yTop
== 0 &&
1013 m_vRclPaint
.yBottom
== 0 &&
1014 m_vRclPaint
.xRight
== 0 &&
1015 m_vRclPaint
.xLeft
== 0))
1016 vY
= OS2Y(vY
,vHeight
);
1019 if (m_vSelectedBitmap
!= wxNullBitmap
)
1021 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1022 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1023 vY
= OS2Y(vY
,vHeight
);
1027 wxCoord vX2
= vX
+ vWidth
;
1028 wxCoord vY2
= vY
+ vHeight
;
1032 vPoint
[1].x
= vX
+ vWidth
- 1;
1033 vPoint
[1].y
= vY
+ vHeight
- 1;
1034 ::GpiMove(m_hPS
, &vPoint
[0]);
1035 lColor
= m_brush
.GetColour().GetPixel();
1036 lBorderColor
= m_pen
.GetColour().GetPixel();
1037 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1039 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1041 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1042 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1043 lControl
= DRO_OUTLINE
;
1045 ::GpiSetColor(m_hPS
, lBorderColor
);
1046 ::GpiBox( m_hPS
// handle to a presentation space
1047 ,lControl
// draw the box outline ? or ?
1048 ,&vPoint
[1] // address of the corner
1049 ,0L // horizontal corner radius
1050 ,0L // vertical corner radius
1055 lControl
= DRO_OUTLINE
;
1056 ::GpiSetColor( m_hPS
1065 lControl
= DRO_FILL
;
1066 ::GpiSetColor( m_hPS
1069 vPoint
[0].x
= vX
+ 1;
1070 vPoint
[0].y
= vY
+ 1;
1071 vPoint
[1].x
= vX
+ vWidth
- 2;
1072 vPoint
[1].y
= vY
+ vHeight
- 2;
1073 ::GpiMove(m_hPS
, &vPoint
[0]);
1081 CalcBoundingBox(vX
, vY
);
1082 CalcBoundingBox(vX2
, vY2
);
1083 } // end of wxDC::DoDrawRectangle
1085 void wxDC::DoDrawRoundedRectangle(
1097 int nIsTRANSPARENT
= 0;
1100 // Might be a memory DC with no Paint rect.
1102 if (!(m_vRclPaint
.yTop
== 0 &&
1103 m_vRclPaint
.yBottom
== 0 &&
1104 m_vRclPaint
.xRight
== 0 &&
1105 m_vRclPaint
.xLeft
== 0))
1106 vY
= OS2Y(vY
,vHeight
);
1109 if (m_vSelectedBitmap
!= wxNullBitmap
)
1111 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1112 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1113 vY
= OS2Y(vY
,vHeight
);
1117 wxCoord vX2
= (vX
+ vWidth
);
1118 wxCoord vY2
= (vY
+ vHeight
);
1122 vPoint
[1].x
= vX
+ vWidth
- 1;
1123 vPoint
[1].y
= vY
+ vHeight
- 1;
1124 ::GpiMove(m_hPS
, &vPoint
[0]);
1126 lColor
= m_brush
.GetColour().GetPixel();
1127 lBorderColor
= m_pen
.GetColour().GetPixel();
1128 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1129 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1131 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1133 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1134 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1135 lControl
= DRO_OUTLINE
;
1137 ::GpiSetColor(m_hPS
, lColor
);
1138 ::GpiBox( m_hPS
// handle to a presentation space
1139 ,lControl
// draw the box outline ? or ?
1140 ,&vPoint
[1] // address of the corner
1141 ,(LONG
)dRadius
// horizontal corner radius
1142 ,(LONG
)dRadius
// vertical corner radius
1147 lControl
= DRO_OUTLINE
;
1148 ::GpiSetColor( m_hPS
1157 lControl
= DRO_FILL
;
1158 ::GpiSetColor( m_hPS
1161 vPoint
[0].x
= vX
+ 1;
1162 vPoint
[0].y
= vY
+ 1;
1163 vPoint
[1].x
= vX
+ vWidth
- 2;
1164 vPoint
[1].y
= vY
+ vHeight
- 2;
1165 ::GpiMove(m_hPS
, &vPoint
[0]);
1174 CalcBoundingBox(vX
, vY
);
1175 CalcBoundingBox(vX2
, vY2
);
1176 } // end of wxDC::DoDrawRoundedRectangle
1178 // Draw Ellipse within box (x,y) - (x+width, y+height)
1179 void wxDC::DoDrawEllipse(
1186 POINTL vPtlPos
; // Structure for current position
1187 FIXED vFxMult
; // Multiplier for ellipse
1188 ARCPARAMS vArcp
; // Structure for arc parameters
1190 vY
= OS2Y(vY
,vHeight
);
1193 vArcp
.lQ
= vHeight
/2;
1194 vArcp
.lP
= vWidth
/2;
1196 ::GpiSetArcParams( m_hPS
1198 ); // Sets parameters to default
1199 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
1200 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1203 ); // Sets current position
1204 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
1207 // DRO_FILL, DRO_OTLINEFILL - where to get
1212 ); // Draws full arc with center at current position
1214 wxCoord vX2
= (vX
+ vWidth
);
1215 wxCoord vY2
= (vY
+ vHeight
);
1217 CalcBoundingBox(vX
, vY
);
1218 CalcBoundingBox(vX2
, vY2
);
1219 } // end of wxDC::DoDrawEllipse
1221 void wxDC::DoDrawEllipticArc(
1230 POINTL vPtlPos
; // Structure for current position
1231 FIXED vFxMult
; // Multiplier for ellipse
1232 ARCPARAMS vArcp
; // Structure for arc parameters
1234 FIXED vFSweepa
; // Start angle, sweep angle
1239 vY
= OS2Y(vY
,vHeight
);
1241 dFractPart
= modf(dSa
,&dIntPart
);
1242 vFSa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1243 dFractPart
= modf(dEa
- dSa
, &dIntPart
);
1244 vFSweepa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1247 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1250 vArcp
.lQ
= vHeight
/2;
1251 vArcp
.lP
= vWidth
/2;
1253 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
1254 vPtlPos
.x
= vX
+ vWidth
/2 * (1. + cos(DegToRad(dSa
))); // Loads x-coordinate
1255 vPtlPos
.y
= vY
+ vHeight
/2 * (1. + sin(DegToRad(dSa
))); // Loads y-coordinate
1256 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
1259 // May be not to the center ?
1261 vPtlPos
.x
= vX
+ vWidth
/2 ; // Loads x-coordinate
1262 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1263 vFxMult
= MAKEFIXED(1, 0); // Sets multiplier
1266 // DRO_FILL, DRO_OTLINEFILL - where to get
1268 ::GpiPartialArc( m_hPS
1274 wxCoord vX2
= (vX
+ vWidth
);
1275 wxCoord vY2
= (vY
+ vHeight
);
1277 CalcBoundingBox(vX
, vY
);
1278 CalcBoundingBox(vX2
, vY2
);
1279 } // end of wxDC::DoDrawEllipticArc
1281 void wxDC::DoDrawIcon(
1288 // Need to copy back into a bitmap. ::WinDrawPointer uses device coords
1289 // and I don't feel like figuring those out for scrollable windows so
1290 // just convert to a bitmap then let the DoDrawBitmap routing display it
1294 DoDrawBitmap(rIcon
.GetXpmSrc(), vX
, vY
, true);
1298 wxBitmap
vBitmap(rIcon
);
1300 DoDrawBitmap(vBitmap
, vX
, vY
, false);
1302 CalcBoundingBox(vX
, vY
);
1303 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
1304 } // end of wxDC::DoDrawIcon
1306 void wxDC::DoDrawBitmap(
1307 const wxBitmap
& rBmp
1313 if (!IsKindOf(CLASSINFO(wxPrinterDC
)))
1315 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
1319 vY
= OS2Y(vY
,rBmp
.GetHeight());
1322 vPoint
[0].y
= vY
+ rBmp
.GetHeight();
1323 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1327 vPoint
[3].x
= rBmp
.GetWidth();
1328 vPoint
[3].y
= rBmp
.GetHeight();
1331 wxMask
* pMask
= rBmp
.GetMask();
1336 // Need to imitate ::MaskBlt in windows.
1337 // 1) Extract the bits from from the bitmap.
1338 // 2) Extract the bits from the mask
1339 // 3) Using the mask bits do the following:
1340 // A) If the mask byte is 00 leave the bitmap byte alone
1341 // B) If the mask byte is FF copy the screen color into
1343 // 4) Create a new bitmap and set its bits to the above result
1344 // 5) Blit this to the screen PS
1346 HBITMAP hMask
= (HBITMAP
)pMask
->GetMaskBitmap();
1347 HBITMAP hOldMask
= NULLHANDLE
;
1348 HBITMAP hOldBitmap
= NULLHANDLE
;
1349 HBITMAP hNewBitmap
= NULLHANDLE
;
1350 unsigned char* pucBits
; // buffer that will contain the bitmap data
1351 unsigned char* pucBitsMask
; // buffer that will contain the mask data
1352 unsigned char* pucData
; // pointer to use to traverse bitmap data
1353 unsigned char* pucDataMask
; // pointer to use to traverse mask data
1359 // The usual Memory context creation stuff
1361 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1362 SIZEL vSize
= {0, 0};
1363 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1364 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1367 // The usual bitmap header stuff
1369 BITMAPINFOHEADER2 vHeader
;
1372 memset(&vHeader
, '\0', 16);
1375 memset(&vInfo
, '\0', 16);
1377 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1378 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1380 vInfo
.cBitCount
= 24; // Set to desired count going in
1383 // Create the buffers for data....all wxBitmaps are 24 bit internally
1385 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1386 int nSizeDWORD
= sizeof(DWORD
);
1387 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
1395 // Need to get a background color for mask blitting
1397 if (IsKindOf(CLASSINFO(wxWindowDC
)))
1399 wxWindowDC
* pWindowDC
= wxDynamicCast(this, wxWindowDC
);
1401 lColor
= pWindowDC
->m_pCanvas
->GetBackgroundColour().GetPixel();
1403 else if (GetBrush() != wxNullBrush
)
1404 lColor
= GetBrush().GetColour().GetPixel();
1406 lColor
= m_textBackgroundColour
.GetPixel();
1409 // Bitmap must be ina double-word alligned address so we may
1410 // have some padding to worry about
1412 if (nLineBoundary
> 0)
1414 nPadding
= nSizeDWORD
- nLineBoundary
;
1415 nBytesPerLine
+= nPadding
;
1417 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1418 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1419 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1420 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1423 // Extract the bitmap and mask data
1425 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1427 vError
= ::WinGetLastError(vHabmain
);
1428 sError
= wxPMErrorToStr(vError
);
1430 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
1431 vInfo
.cBitCount
= 24;
1432 if ((lScans
= ::GpiQueryBitmapBits( hPS
1434 ,(LONG
)rBmp
.GetHeight()
1439 vError
= ::WinGetLastError(vHabmain
);
1440 sError
= wxPMErrorToStr(vError
);
1442 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
1444 vError
= ::WinGetLastError(vHabmain
);
1445 sError
= wxPMErrorToStr(vError
);
1447 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
1448 vInfo
.cBitCount
= 24;
1449 if ((lScans
= ::GpiQueryBitmapBits( hPS
1451 ,(LONG
)rBmp
.GetHeight()
1456 vError
= ::WinGetLastError(vHabmain
);
1457 sError
= wxPMErrorToStr(vError
);
1459 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
1461 vError
= ::WinGetLastError(vHabmain
);
1462 sError
= wxPMErrorToStr(vError
);
1466 // Now set the bytes(bits) according to the mask values
1467 // 3 bytes per pel...must handle one at a time
1470 pucDataMask
= pucBitsMask
;
1473 // 16 bit kludge really only kinda works. The mask gets applied
1474 // where needed but the original bitmap bits are dorked sometimes
1476 bool bpp16
= (wxDisplayDepth() == 16);
1478 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1480 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1483 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1485 else if (*pucDataMask
== 0xFF) // leave bitmap byte alone
1489 *pucData
= ((unsigned char)(lColor
>> 16));
1493 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1495 else if (*(pucDataMask
+ 1) == 0xFF) // leave bitmap byte alone
1499 *pucData
= ((unsigned char)(lColor
>> 8));
1504 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1506 else if (*(pucDataMask
+ 2) == 0xFF) // leave bitmap byte alone
1510 *pucData
= ((unsigned char)lColor
);
1515 for (j
= 0; j
< nPadding
; j
++)
1522 // Create a new bitmap
1524 vHeader
.cx
= (ULONG
)rBmp
.GetWidth();
1525 vHeader
.cy
= (ULONG
)rBmp
.GetHeight();
1526 vHeader
.cPlanes
= 1L;
1527 vHeader
.cBitCount
= 24;
1528 if ((hNewBitmap
= ::GpiCreateBitmap( hPS
1535 vError
= ::WinGetLastError(vHabmain
);
1536 sError
= wxPMErrorToStr(vError
);
1540 // Now blit it to the screen PS
1542 if ((lHits
= ::GpiWCBitBlt( (HPS
)GetHPS()
1550 vError
= ::WinGetLastError(vHabmain
);
1551 sError
= wxPMErrorToStr(vError
);
1559 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1560 ::GpiDeleteBitmap(hNewBitmap
);
1561 ::GpiDestroyPS(hPS
);
1567 LONG lOldForeGround
= ::GpiQueryColor((HPS
)GetHPS());
1568 LONG lOldBackGround
= ::GpiQueryBackColor((HPS
)GetHPS());
1570 if (m_textForegroundColour
.Ok())
1572 ::GpiSetColor( (HPS
)GetHPS()
1573 ,m_textForegroundColour
.GetPixel()
1576 if (m_textBackgroundColour
.Ok())
1578 ::GpiSetBackColor( (HPS
)GetHPS()
1579 ,m_textBackgroundColour
.GetPixel()
1583 // Need to alter bits in a mono bitmap to match the new
1584 // background-foreground if it is different.
1586 if (rBmp
.IsMono() &&
1587 ((m_textForegroundColour
.GetPixel() != lOldForeGround
) ||
1588 (m_textBackgroundColour
.GetPixel() != lOldBackGround
)))
1590 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1591 SIZEL vSize
= {0, 0};
1592 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1593 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1595 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1597 LONG lForeGround
= m_textForegroundColour
.GetPixel();
1598 LONG lBackGround
= m_textBackgroundColour
.GetPixel();
1600 HBITMAP hOldBitmap
= NULLHANDLE
;
1606 memset(&vInfo
, '\0', 16);
1608 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1609 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1611 vInfo
.cBitCount
= 24;
1613 unsigned char* pucBits
; // buffer that will contain the bitmap data
1614 unsigned char* pucData
; // pointer to use to traverse bitmap data
1616 pucBits
= new unsigned char[nBytesPerLine
* rBmp
.GetHeight()];
1617 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1619 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1621 vError
= ::WinGetLastError(vHabmain
);
1622 sError
= wxPMErrorToStr(vError
);
1625 if ((lScans
= ::GpiQueryBitmapBits( hPS
1627 ,(LONG
)rBmp
.GetHeight()
1632 vError
= ::WinGetLastError(vHabmain
);
1633 sError
= wxPMErrorToStr(vError
);
1636 unsigned char cOldRedFore
= (unsigned char)(lOldForeGround
>> 16);
1637 unsigned char cOldGreenFore
= (unsigned char)(lOldForeGround
>> 8);
1638 unsigned char cOldBlueFore
= (unsigned char)lOldForeGround
;
1640 unsigned char cOldRedBack
= (unsigned char)(lOldBackGround
>> 16);
1641 unsigned char cOldGreenBack
= (unsigned char)(lOldBackGround
>> 8);
1642 unsigned char cOldBlueBack
= (unsigned char)lOldBackGround
;
1644 unsigned char cRedFore
= (unsigned char)(lForeGround
>> 16);
1645 unsigned char cGreenFore
= (unsigned char)(lForeGround
>> 8);
1646 unsigned char cBlueFore
= (unsigned char)lForeGround
;
1648 unsigned char cRedBack
= (unsigned char)(lBackGround
>> 16);
1649 unsigned char cGreenBack
= (unsigned char)(lBackGround
>> 8);
1650 unsigned char cBlueBack
= (unsigned char)lBackGround
;
1653 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1655 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1657 unsigned char cBmpRed
= *pucData
;
1658 unsigned char cBmpGreen
= *(pucData
+ 1);
1659 unsigned char cBmpBlue
= *(pucData
+ 2);
1661 if ((cBmpRed
== cOldRedFore
) &&
1662 (cBmpGreen
== cOldGreenFore
) &&
1663 (cBmpBlue
== cOldBlueFore
))
1665 *pucData
= cBlueFore
;
1667 *pucData
= cGreenFore
;
1669 *pucData
= cRedFore
;
1674 *pucData
= cBlueBack
;
1676 *pucData
= cGreenBack
;
1678 *pucData
= cRedBack
;
1683 if ((lScans
= ::GpiSetBitmapBits( hPS
1685 ,(LONG
)rBmp
.GetHeight()
1690 vError
= ::WinGetLastError(vHabmain
);
1691 sError
= wxPMErrorToStr(vError
);
1695 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1696 ::GpiDestroyPS(hPS
);
1699 ::GpiWCBitBlt( (HPS
)GetHPS()
1706 ::GpiSetBitmap((HPS
)GetHPS(), hBitmapOld
);
1707 ::GpiSetColor((HPS
)GetHPS(), lOldForeGround
);
1708 ::GpiSetBackColor((HPS
)GetHPS(), lOldBackGround
);
1711 } // end of wxDC::DoDrawBitmap
1713 void wxDC::DoDrawText(
1714 const wxString
& rsText
1727 CalcBoundingBox(vX
, vY
);
1728 GetTextExtent(rsText
, &vWidth
, &vHeight
);
1729 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1730 } // end of wxDC::DoDrawText
1732 void wxDC::DrawAnyText(
1733 const wxString
& rsText
1738 int nOldBackground
= 0;
1745 // prepare for drawing the text
1749 // Set text color attributes
1751 if (m_textForegroundColour
.Ok())
1754 ,(int)m_textForegroundColour
.GetPixel()
1758 if (m_textBackgroundColour
.Ok())
1760 nOldBackground
= SetTextBkColor( m_hPS
1761 ,(int)m_textBackgroundColour
.GetPixel()
1767 GetTextExtent( rsText
1772 if (!(m_vRclPaint
.yTop
== 0 &&
1773 m_vRclPaint
.yBottom
== 0 &&
1774 m_vRclPaint
.xRight
== 0 &&
1775 m_vRclPaint
.xLeft
== 0))
1778 // Position Text a little differently in the Statusbar from other panels
1780 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1781 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1783 vPtlStart
.y
= OS2Y(vY
,vTextY
/1.5); // Full extent is a bit much
1787 if (m_vSelectedBitmap
!= wxNullBitmap
)
1789 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1790 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1791 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1792 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1794 vPtlStart
.y
= OS2Y(vY
,vTextY
/1.5);
1800 PCH pzStr
= (PCH
)rsText
.c_str();
1802 ::GpiMove(m_hPS
, &vPtlStart
);
1803 lHits
= ::GpiCharString( m_hPS
1807 if (lHits
!= GPI_OK
)
1809 wxLogLastError(wxT("TextOut"));
1813 // Restore the old parameters (text foreground colour may be left because
1814 // it never is set to anything else, but background should remain
1815 // transparent even if we just drew an opaque string)
1817 if (m_textBackgroundColour
.Ok())
1818 SetTextBkColor( m_hPS
1826 void wxDC::DoDrawRotatedText(
1827 const wxString
& rsText
1845 DoDrawText(text, x, y);
1850 wxFillLogFont(&lf, &m_font);
1852 // GDI wants the angle in tenth of degree
1853 long angle10 = (long)(angle * 10);
1854 lf.lfEscapement = angle10;
1855 lf. lfOrientation = angle10;
1857 HFONT hfont = ::CreateFontIndirect(&lf);
1860 wxLogLastError("CreateFont");
1864 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1866 DrawAnyText(text, x, y);
1868 (void)::SelectObject(GetHdc(), hfontOld);
1871 // call the bounding box by adding all four vertices of the rectangle
1872 // containing the text to it (simpler and probably not slower than
1873 // determining which of them is really topmost/leftmost/...)
1875 GetTextExtent(text, &w, &h);
1877 double rad = DegToRad(angle);
1879 // "upper left" and "upper right"
1880 CalcBoundingBox(x, y);
1881 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1882 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1884 // "bottom left" and "bottom right"
1885 x += (wxCoord)(h*sin(rad));
1886 y += (wxCoord)(h*cos(rad));
1887 CalcBoundingBox(x, y);
1888 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1893 // ---------------------------------------------------------------------------
1895 // ---------------------------------------------------------------------------
1897 void wxDC::DoSelectPalette(
1902 // Set the old object temporarily, in case the assignment deletes an object
1903 // that's not yet selected out.
1914 hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1916 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1918 } // end of wxDC::DoSelectPalette
1920 void wxDC::InitializePalette()
1922 if (wxDisplayDepth() <= 8 )
1925 // Look for any window or parent that has a custom palette. If any has
1926 // one then we need to use it in drawing operations
1928 wxWindow
* pWin
= m_pCanvas
->GetAncestorWithCustomPalette();
1930 m_hasCustomPalette
= pWin
&& pWin
->HasCustomPalette();
1931 if (m_hasCustomPalette
)
1933 m_palette
= pWin
->GetPalette();
1936 // turn on PM translation for this palette
1941 } // end of wxDC::InitializePalette
1943 void wxDC::SetPalette(
1944 const wxPalette
& rPalette
1951 m_palette
= rPalette
;
1959 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1961 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1962 } // end of wxDC::SetPalette
1969 // Set the old object temporarily, in case the assignment deletes an object
1970 // that's not yet selected out.
1982 m_font
.SetPS(m_hPS
); // this will realize the font
1986 HFONT hFont
= m_font
.GetResourceHandle();
1987 if (hFont
== (HFONT
) NULL
)
1989 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
1992 m_hOldFont
= (WXHFONT
) hFont
;
1994 } // end of wxDC::SetFont
2000 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2016 m_pen
.SetPS((HPS
)m_hOldPen
);
2023 if (m_pen
.GetResourceHandle())
2027 m_hOldPen
= m_pen
.GetPS();
2029 ::GpiSetColor(m_hPS
, m_pen
.GetColour().GetPixel());
2033 void wxDC::SetBrush(
2034 const wxBrush
& rBrush
2037 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2043 if (m_brush
== rBrush
)
2053 m_brush
.SetPS((HPS
)m_hOldBrush
);
2060 if (m_brush
.GetResourceHandle())
2062 m_brush
.SetPS(m_hPS
);
2064 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
2067 } // end of wxDC::SetBrush
2069 void wxDC::SetBackground(
2070 const wxBrush
& rBrush
2073 m_backgroundBrush
= rBrush
;
2074 if (!m_backgroundBrush
.Ok())
2078 bool bCustomColours
= true;
2081 // If we haven't specified wxUSER_COLOURS, don't allow the panel/dialog box to
2082 // change background colours from the control-panel specified colours.
2084 if (m_pCanvas
->IsKindOf(CLASSINFO(wxWindow
)) &&
2085 ((m_pCanvas
->GetWindowStyleFlag() & wxUSER_COLOURS
) != wxUSER_COLOURS
))
2086 bCustomColours
= false;
2089 if (m_backgroundBrush
.GetStyle()==wxTRANSPARENT
)
2091 m_pCanvas
->SetTransparent(true);
2096 // Setting the background brush of a DC
2097 // doesn't affect the window background colour. However,
2098 // I'm leaving in the transparency setting because it's needed by
2099 // various controls (e.g. wxStaticText) to determine whether to draw
2100 // transparently or not. TODO: maybe this should be a new function
2101 // wxWindow::SetTransparency(). Should that apply to the child itself, or the
2103 // m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
2105 m_pCanvas
->SetTransparent(false);
2109 COLORREF vNewColor
= m_backgroundBrush
.GetColour().GetPixel();
2110 (void)::GpiSetBackColor((HPS
)m_hPS
, (LONG
)vNewColor
);
2111 } // end of wxDC::SetBackground
2113 void wxDC::SetBackgroundMode(
2117 m_backgroundMode
= nMode
;
2118 } // end of wxDC::SetBackgroundMode
2120 void wxDC::SetLogicalFunction(
2124 m_logicalFunction
= nFunction
;
2125 SetRop((WXHDC
)m_hDC
);
2126 } // wxDC::SetLogicalFunction
2132 if (!hDC
|| m_logicalFunction
< 0)
2136 switch (m_logicalFunction
)
2147 lCRop
= FM_MERGESRCNOT
;
2151 lCRop
= FM_NOTMASKSRC
;
2163 lCRop
= FM_MERGENOTSRC
;
2167 lCRop
= FM_MERGESRCNOT
;
2179 lCRop
= FM_SUBTRACT
;
2186 lCRop
= FM_OVERPAINT
;
2189 ::GpiSetMix((HPS
)hDC
, lCRop
);
2190 } // end of wxDC::SetRop
2192 bool wxDC::StartDoc(
2193 const wxString
& rsMessage
2196 // We might be previewing, so return true to let it continue.
2198 } // end of wxDC::StartDoc
2202 } // end of wxDC::EndDoc
2204 void wxDC::StartPage()
2206 } // end of wxDC::StartPage
2208 void wxDC::EndPage()
2210 } // end of wxDC::EndPage
2212 // ---------------------------------------------------------------------------
2214 // ---------------------------------------------------------------------------
2216 wxCoord
wxDC::GetCharHeight() const
2218 FONTMETRICS vFM
; // metrics structure
2220 ::GpiQueryFontMetrics( m_hPS
2221 ,sizeof(FONTMETRICS
)
2224 return YDEV2LOGREL(vFM
.lXHeight
);
2227 wxCoord
wxDC::GetCharWidth() const
2229 FONTMETRICS vFM
; // metrics structure
2231 ::GpiQueryFontMetrics( m_hPS
2232 ,sizeof(FONTMETRICS
)
2235 return XDEV2LOGREL(vFM
.lAveCharWidth
);
2238 void wxDC::DoGetTextExtent(
2239 const wxString
& rsString
2242 , wxCoord
* pvDescent
2243 , wxCoord
* pvExternalLeading
2247 POINTL avPoint
[TXTBOX_COUNT
];
2252 FONTMETRICS vFM
; // metrics structure
2255 ERRORID vErrorCode
; // last error id code
2256 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
2258 char zMsg
[128]; // DEBUG
2262 pFontToUse
= (wxFont
*)&m_font
;
2263 l
= rsString
.length();
2264 pStr
= (PCH
) rsString
.c_str();
2267 // In world coordinates.
2269 bRc
= ::GpiQueryTextBox( m_hPS
2272 ,TXTBOX_COUNT
// return maximum information
2273 ,avPoint
// array of coordinates points
2277 vErrorCode
= ::WinGetLastError(wxGetInstance());
2278 sError
= wxPMErrorToStr(vErrorCode
);
2280 sprintf(zMsg
, "GpiQueryTextBox for %s: failed with Error: %x - %s", pStr
, vErrorCode
, sError
.c_str());
2281 (void)wxMessageBox( "wxWindows Menu sample"
2287 vPtMin
.x
= avPoint
[0].x
;
2288 vPtMax
.x
= avPoint
[0].x
;
2289 vPtMin
.y
= avPoint
[0].y
;
2290 vPtMax
.y
= avPoint
[0].y
;
2291 for (i
= 1; i
< 4; i
++)
2293 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
2294 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
2295 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
2296 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
2298 ::GpiQueryFontMetrics( m_hPS
2299 ,sizeof(FONTMETRICS
)
2304 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
2306 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
2308 *pvDescent
= vFM
.lMaxDescender
;
2309 if (pvExternalLeading
)
2310 *pvExternalLeading
= vFM
.lExternalLeading
;
2313 void wxDC::SetMapMode(
2317 int nPixelWidth
= 0;
2318 int nPixelHeight
= 0;
2321 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2323 m_mappingMode
= nMode
;
2325 if(::DevQueryCaps( m_hDC
2327 ,CAPS_VERTICAL_RESOLUTION
2334 nPixelWidth
= lArray
[CAPS_WIDTH
];
2335 nPixelHeight
= lArray
[CAPS_HEIGHT
];
2336 lHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2337 lVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2338 nMmWidth
= (lHorzRes
/1000) * nPixelWidth
;
2339 nMmWidth
= (lVertRes
/1000) * nPixelHeight
;
2341 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
2346 double dMm2pixelsX
= nPixelWidth
/nMmWidth
;
2347 double dMm2pixelsY
= nPixelHeight
/nMmHeight
;
2352 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
2353 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
2357 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
2358 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
2362 m_logicalScaleX
= dMm2pixelsX
;
2363 m_logicalScaleY
= dMm2pixelsY
;
2367 m_logicalScaleX
= (dMm2pixelsX
/10.0);
2368 m_logicalScaleY
= (dMm2pixelsY
/10.0);
2373 m_logicalScaleX
= 1.0;
2374 m_logicalScaleY
= 1.0;
2380 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
2381 if (!ulOptions
& PU_ARBITRARY
)
2383 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
2384 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
2386 m_nWindowExtX
= (int)MS_XDEV2LOG(VIEWPORT_EXTENT
);
2387 m_nWindowExtY
= (int)MS_YDEV2LOG(VIEWPORT_EXTENT
);
2389 }; // end of wxDC::SetMapMode
2391 void wxDC::SetUserScale(
2399 SetMapMode(m_mappingMode
);
2400 } // end of wxDC::SetUserScale
2402 void wxDC::SetAxisOrientation(
2407 m_signX
= bXLeftRight
? 1 : -1;
2408 m_signY
= bYBottomUp
? -1 : 1;
2410 SetMapMode(m_mappingMode
);
2411 } // end of wxDC::SetAxisOrientation
2413 void wxDC::SetSystemScale(
2421 SetMapMode(m_mappingMode
);
2422 } // end of wxDC::SetSystemScale
2424 void wxDC::SetLogicalOrigin(
2431 ::GpiQueryPageViewport( m_hPS
2438 ::GpiSetPageViewport( m_hPS
2441 }; // end of wxDC::SetLogicalOrigin
2443 void wxDC::SetDeviceOrigin(
2450 m_deviceOriginX
= vX
;
2451 m_deviceOriginY
= vY
;
2452 ::GpiQueryPageViewport( m_hPS
2457 vRect
.yBottom
-= vY
;
2459 ::GpiSetPageViewport( m_hPS
2462 }; // end of wxDC::SetDeviceOrigin
2464 // ---------------------------------------------------------------------------
2465 // coordinates transformations
2466 // ---------------------------------------------------------------------------
2468 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2470 return (wxCoord
) (((x
) - m_deviceOriginX
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
) - m_logicalOriginX
);
2473 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2475 // axis orientation is not taken into account for conversion of a distance
2476 return (wxCoord
) ((x
)/(m_logicalScaleX
*m_userScaleX
*m_scaleX
));
2479 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2481 return (wxCoord
) (((y
) - m_deviceOriginY
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
) - m_logicalOriginY
);
2484 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2486 // axis orientation is not taken into account for conversion of a distance
2487 return (wxCoord
) ((y
)/(m_logicalScaleY
*m_userScaleY
*m_scaleY
));
2490 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2492 return (wxCoord
) ((x
- m_logicalOriginX
)*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
+ m_deviceOriginX
);
2495 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2497 // axis orientation is not taken into account for conversion of a distance
2498 return (wxCoord
) (x
*m_logicalScaleX
*m_userScaleX
*m_scaleX
);
2501 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2503 return (wxCoord
) ((y
- m_logicalOriginY
)*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
+ m_deviceOriginY
);
2506 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2508 // axis orientation is not taken into account for conversion of a distance
2509 return (wxCoord
) (y
*m_logicalScaleY
*m_userScaleY
*m_scaleY
);
2512 // ---------------------------------------------------------------------------
2514 // ---------------------------------------------------------------------------
2530 wxMask
* pMask
= NULL
;
2532 COLORREF vOldTextColor
;
2533 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
2537 const wxBitmap
& rBmp
= pSource
->m_vSelectedBitmap
;
2539 pMask
= rBmp
.GetMask();
2540 if (!(rBmp
.Ok() && pMask
&& pMask
->GetMaskBitmap()))
2546 ::GpiQueryAttrs( m_hPS
2551 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
2553 if (m_textForegroundColour
.Ok())
2555 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
2556 ::GpiSetAttrs( m_hPS
// presentation-space handle
2557 ,PRIM_CHAR
// Char primitive.
2558 ,CBB_COLOR
// sets color.
2560 ,&vCbnd
// buffer for attributes.
2563 if (m_textBackgroundColour
.Ok())
2565 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
2568 LONG lRop
= ROP_SRCCOPY
;
2572 case wxXOR
: lRop
= ROP_SRCINVERT
; break;
2573 case wxINVERT
: lRop
= ROP_DSTINVERT
; break;
2574 case wxOR_REVERSE
: lRop
= 0x00DD0228; break;
2575 case wxAND_REVERSE
: lRop
= ROP_SRCERASE
; break;
2576 case wxCLEAR
: lRop
= ROP_ZERO
; break;
2577 case wxSET
: lRop
= ROP_ONE
; break;
2578 case wxOR_INVERT
: lRop
= ROP_MERGEPAINT
; break;
2579 case wxAND
: lRop
= ROP_SRCAND
; break;
2580 case wxOR
: lRop
= ROP_SRCPAINT
; break;
2581 case wxEQUIV
: lRop
= 0x00990066; break;
2582 case wxNAND
: lRop
= 0x007700E6; break;
2583 case wxAND_INVERT
: lRop
= 0x00220326; break;
2584 case wxCOPY
: lRop
= ROP_SRCCOPY
; break;
2585 case wxNO_OP
: lRop
= ROP_NOTSRCERASE
; break;
2586 case wxSRC_INVERT
: lRop
= ROP_SRCINVERT
; break;
2587 case wxNOR
: lRop
= ROP_NOTSRCCOPY
; break;
2589 wxFAIL_MSG( wxT("unsupported logical function") );
2598 // Blit bitmap with mask
2602 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2608 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
2609 BITMAPINFOHEADER2 vBmpHdr
;
2611 SIZEL vSize
= {0, 0};
2614 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
2615 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
2616 vBmpHdr
.cx
= vWidth
;
2617 vBmpHdr
.cy
= vHeight
;
2618 vBmpHdr
.cPlanes
= 1;
2619 vBmpHdr
.cBitCount
= 24;
2621 #if wxUSE_DC_CACHEING
2625 // create a temp buffer bitmap and DCs to access it and the mask
2627 wxDCCacheEntry
* pDCCacheEntry1
= FindDCInCache( NULL
2630 wxDCCacheEntry
* pDCCacheEntry2
= FindDCInCache( pDCCacheEntry1
2633 wxDCCacheEntry
* pBitmapCacheEntry
= FindBitmapInCache( GetHPS()
2638 hPSMask
= pDCCacheEntry1
->m_hPS
;
2639 hDCBuffer
= (HDC
)pDCCacheEntry2
->m_hPS
;
2640 hBufBitmap
= (HBITMAP
)pBitmapCacheEntry
->m_hBitmap
;
2645 hDCMask
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2646 hDCBuffer
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2647 hPSMask
= ::GpiCreatePS(vHabmain
, hDCMask
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2648 hPSBuffer
= ::GpiCreatePS(vHabmain
, hDCBuffer
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2649 hBufBitmap
= ::GpiCreateBitmap(GetHPS(), &vBmpHdr
, 0L, NULL
, NULL
);
2652 POINTL aPoint1
[4] = { {0, 0}
2655 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2657 POINTL aPoint2
[4] = { {0, 0}
2660 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2662 POINTL aPoint3
[4] = { {vXdest
, vYdest
}
2663 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2665 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2667 POINTL aPoint4
[4] = { {vXdest
, vYdest
}
2668 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2672 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
2673 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
2676 // Copy dest to buffer
2678 rc
= ::GpiBitBlt( hPSBuffer
2685 if (rc
== GPI_ERROR
)
2687 wxLogLastError(wxT("BitBlt"));
2691 // Copy src to buffer using selected raster op
2693 rc
= ::GpiBitBlt( hPSBuffer
2700 if (rc
== GPI_ERROR
)
2702 wxLogLastError(wxT("BitBlt"));
2706 // Set masked area in buffer to BLACK (pixel value 0)
2708 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
2709 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
2711 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2712 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2714 rc
= ::GpiBitBlt( hPSBuffer
2721 if (rc
== GPI_ERROR
)
2723 wxLogLastError(wxT("BitBlt"));
2727 // Set unmasked area in dest to BLACK
2729 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2730 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2731 rc
= ::GpiBitBlt( GetHPS()
2738 if (rc
== GPI_ERROR
)
2740 wxLogLastError(wxT("BitBlt"));
2744 // Restore colours to original values
2746 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
2747 ::GpiSetColor(GetHPS(), vPrevCol
);
2750 // OR buffer to dest
2752 rc
= ::GpiBitBlt( GetHPS()
2759 if (rc
== GPI_ERROR
)
2762 wxLogLastError(wxT("BitBlt"));
2766 // Tidy up temporary DCs and bitmap
2768 ::GpiSetBitmap(hPSMask
, NULLHANDLE
);
2769 ::GpiSetBitmap(hPSBuffer
, NULLHANDLE
);
2770 #if !wxUSE_DC_CACHEING
2771 ::GpiDestroyPS(hPSMask
);
2772 ::GpiDestroyPS(hPSBuffer
);
2773 ::DevCloseDC(hDCMask
);
2774 ::DevCloseDC(hDCBuffer
);
2775 ::GpiDeleteBitmap(hBufBitmap
);
2779 else // no mask, just BitBlt() it
2781 POINTL aPoint
[4] = { {vXdest
, vYdest
}
2782 ,{vXdest
+ vWidth
, vYdest
+ vHeight
}
2784 ,{vXsrc
+ vWidth
, vYsrc
+ vHeight
}
2787 bSuccess
= (::GpiBitBlt( m_hPS
2796 wxLogLastError(wxT("BitBlt"));
2799 vCbnd
.lColor
= (LONG
)vOldTextColor
;
2800 ::GpiSetAttrs( m_hPS
// presentation-space handle
2801 ,PRIM_CHAR
// Char primitive.
2802 ,CBB_COLOR
// sets color.
2804 ,&vCbnd
// buffer for attributes.
2806 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
2810 void wxDC::DoGetSize(
2815 LONG lArray
[CAPS_HEIGHT
];
2817 if(::DevQueryCaps( m_hDC
2823 *pnWidth
= lArray
[CAPS_WIDTH
];
2824 *pnHeight
= lArray
[CAPS_HEIGHT
];
2826 }; // end of wxDC::DoGetSize(
2828 void wxDC::DoGetSizeMM(
2833 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2835 if(::DevQueryCaps( m_hDC
2837 ,CAPS_VERTICAL_RESOLUTION
2846 nWidth
= lArray
[CAPS_WIDTH
];
2847 nHeight
= lArray
[CAPS_HEIGHT
];
2848 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2849 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2850 nWidth
= (nHorzRes
/1000) * nWidth
;
2851 nHeight
= (nVertRes
/1000) * nHeight
;
2853 }; // end of wxDC::DoGetSizeMM
2855 wxSize
wxDC::GetPPI() const
2857 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2861 if(::DevQueryCaps( m_hDC
2863 ,CAPS_VERTICAL_RESOLUTION
2872 nPelWidth
= lArray
[CAPS_WIDTH
];
2873 nPelHeight
= lArray
[CAPS_HEIGHT
];
2874 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2875 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2876 nWidth
= (nHorzRes
/39.3) * nPelWidth
;
2877 nHeight
= (nVertRes
/39.3) * nPelHeight
;
2879 return (wxSize(nWidth
,nHeight
));
2880 } // end of wxDC::GetPPI
2882 void wxDC::SetLogicalScale(
2887 m_logicalScaleX
= dX
;
2888 m_logicalScaleY
= dY
;
2889 }; // end of wxDC::SetLogicalScale