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"
26 #include "wx/module.h"
29 #include "wx/dcprint.h"
34 #include "wx/os2/private.h"
36 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
39 // wxWindows uses the Microsoft convention that the origin is the UPPER left.
40 // Native OS/2 however in the GPI and PM define the origin as the LOWER left.
41 // In order to map OS/2 GPI/PM y coordinates to wxWindows coordinates we must
42 // perform the following transformation:
44 // Parent object height: POBJHEIGHT
45 // Desried origin: WXORIGINY
46 // Object to place's height: OBJHEIGHT
48 // To get the OS2 position from the wxWindows one:
50 // OS2Y = POBJHEIGHT - (WXORIGINY + OBJHEIGHT)
52 // For OS/2 wxDC's we will always determine m_vRclPaint as the size of the
53 // OS/2 Presentation Space associated with the device context. y is the
54 // desired application's y coordinate of the origin in wxWindows space.
55 // objy is the height of the object we are going to draw.
57 #define OS2Y(y, objy) ((m_vRclPaint.yTop - m_vRclPaint.yBottom) - (y + objy))
59 // ---------------------------------------------------------------------------
61 // ---------------------------------------------------------------------------
63 static const int VIEWPORT_EXTENT
= 1000;
65 static const int MM_POINTS
= 9;
66 static const int MM_METRIC
= 10;
68 // usually this is defined in math.h
70 static const double M_PI
= 3.14159265358979323846;
73 // ---------------------------------------------------------------------------
75 // ---------------------------------------------------------------------------
77 // convert degrees to radians
78 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
82 , int nForegroundColour
87 vCbnd
.lColor
= nForegroundColour
;
88 ::GpiSetAttrs( hPS
// presentation-space handle
89 ,PRIM_CHAR
// Char primitive.
90 ,CBB_COLOR
// sets color.
92 ,&vCbnd
// buffer for attributes.
103 ::GpiQueryAttrs( hPS
// presentation-space handle
104 ,PRIM_CHAR
// Char primitive.
105 ,CBB_BACK_COLOR
// Background color.
106 ,&vCbnd
// buffer for attributes.
108 return vCbnd
.lBackColor
;
114 , int nBackgroundColour
120 rc
= QueryTextBkColor(hPS
);
122 vCbnd
.lBackColor
= nBackgroundColour
;
123 ::GpiSetAttrs(hPS
, // presentation-space handle
124 PRIM_CHAR
, // Char primitive.
125 CBB_BACK_COLOR
, // sets color.
127 &vCbnd
// buffer for attributes.
134 , int nBackgroundMode
137 if(nBackgroundMode
== wxTRANSPARENT
)
142 // the background of the primitive takes over whatever is underneath.
149 // ===========================================================================
151 // ===========================================================================
153 #if wxUSE_DC_CACHEING
156 * This implementation is a bit ugly and uses the old-fashioned wxList class, so I will
157 * improve it in due course, either using arrays, or simply storing pointers to one
158 * entry for the bitmap, and two for the DCs. -- JACS
161 // ---------------------------------------------------------------------------
163 // ---------------------------------------------------------------------------
165 wxList
wxDC::m_svBitmapCache
;
166 wxList
wxDC::m_svDCCache
;
168 wxDCCacheEntry::wxDCCacheEntry(
180 } // end of wxDCCacheEntry::wxDCCacheEntry
182 wxDCCacheEntry::wxDCCacheEntry(
187 m_hBitmap
= NULLHANDLE
;
192 } // end of wxDCCacheEntry::wxDCCacheEntry
194 wxDCCacheEntry::~wxDCCacheEntry()
197 ::GpiDeleteBitmap(m_hBitmap
);
199 ::GpiDestroyPS(m_hPS
);
200 } // end of wxDCCacheEntry::~wxDCCacheEntry
202 wxDCCacheEntry
* wxDC::FindBitmapInCache(
208 int nDepth
= 24; // we'll fix this later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
209 wxNode
* pNode
= m_svBitmapCache
.First();
210 BITMAPINFOHEADER2 vBmpHdr
;
214 wxDCCacheEntry
* pEntry
= (wxDCCacheEntry
*)pNode
->Data();
216 if (pEntry
->m_nDepth
== nDepth
)
218 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
220 if (pEntry
->m_nWidth
< nWidth
|| pEntry
->m_nHeight
< nHeight
)
222 ::GpiDeleteBitmap((HBITMAP
)pEntry
->m_hBitmap
);
223 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
225 vBmpHdr
.cy
= nHeight
;
227 vBmpHdr
.cBitCount
= nDepth
;
229 pEntry
->m_hBitmap
= (WXHBITMAP
) ::GpiCreateBitmap( hPS
233 if (!pEntry
->m_hBitmap
)
235 wxLogLastError(wxT("CreateCompatibleBitmap"));
237 pEntry
->m_nWidth
= nWidth
;
238 pEntry
->m_nHeight
= nHeight
;
243 pNode
= pNode
->Next();
245 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
246 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
248 vBmpHdr
.cy
= nHeight
;
250 vBmpHdr
.cBitCount
= nDepth
;
252 WXHBITMAP hBitmap
= (WXHBITMAP
) ::GpiCreateBitmap( hPS
258 wxLogLastError(wxT("CreateCompatibleBitmap"));
260 wxDCCacheEntry
* pEntry
= new wxDCCacheEntry( hBitmap
265 AddToBitmapCache(pEntry
);
267 } // end of FindBitmapInCache
269 wxDCCacheEntry
* wxDC::FindDCInCache(
270 wxDCCacheEntry
* pNotThis
274 int nDepth
= 24; // we'll fix this up later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
275 wxNode
* pNode
= m_svDCCache
.First();
279 wxDCCacheEntry
* pEntry
= (wxDCCacheEntry
*)pNode
->Data();
282 // Don't return the same one as we already have
284 if (!pNotThis
|| (pNotThis
!= pEntry
))
286 if (pEntry
->m_nDepth
== nDepth
)
291 pNode
= pNode
->Next();
293 wxDCCacheEntry
* pEntry
= new wxDCCacheEntry( hPS
296 AddToDCCache(pEntry
);
298 } // end of wxDC::FindDCInCache
300 void wxDC::AddToBitmapCache(
301 wxDCCacheEntry
* pEntry
304 m_svBitmapCache
.Append(pEntry
);
305 } // end of wxDC::AddToBitmapCache
307 void wxDC::AddToDCCache(
308 wxDCCacheEntry
* pEntry
311 m_svDCCache
.Append(pEntry
);
312 } // end of wxDC::AddToDCCache
314 void wxDC::ClearCache()
316 m_svBitmapCache
.DeleteContents(TRUE
);
317 m_svBitmapCache
.Clear();
318 m_svBitmapCache
.DeleteContents(FALSE
);
319 m_svDCCache
.DeleteContents(TRUE
);
321 m_svDCCache
.DeleteContents(FALSE
);
322 } // end of wxDC::ClearCache
324 // Clean up cache at app exit
325 class wxDCModule
: public wxModule
328 virtual bool OnInit() { return TRUE
; }
329 virtual void OnExit() { wxDC::ClearCache(); }
332 DECLARE_DYNAMIC_CLASS(wxDCModule
)
333 }; // end of CLASS wxDCModule
335 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
337 #endif // ndef for wxUSE_DC_CACHEING
339 // ---------------------------------------------------------------------------
341 // ---------------------------------------------------------------------------
359 m_bIsPaintTime
= FALSE
; // True at Paint Time
361 vColor
.InitFromName("BLACK");
362 m_pen
.SetColour(vColor
);
364 m_brush
.SetColour(vColor
);
365 } // end of wxDC::wxDC
371 SelectOldObjects(m_hDC
);
373 // if we own the HDC, we delete it, otherwise we just release it
379 ::GpiAssociate(m_hPS
, NULLHANDLE
);
380 ::GpiDestroyPS(m_hPS
);
383 ::DevCloseDC((HDC
)m_hDC
);
388 // Just Dissacociate, not destroy if we don't own the DC
392 ::GpiAssociate(m_hPS
, NULLHANDLE
);
396 } // end of wxDC::~wxDC
398 // This will select current objects out of the DC,
399 // which is what you have to do before deleting the
401 void wxDC::SelectOldObjects(
409 ::GpiSetBitmap(hPS
, (HBITMAP
) m_hOldBitmap
);
410 if (m_vSelectedBitmap
.Ok())
412 m_vSelectedBitmap
.SetSelectedInto(NULL
);
417 // OS/2 has no other native GDI objects to set in a PS/DC like windows
425 m_brush
= wxNullBrush
;
427 m_palette
= wxNullPalette
;
429 m_backgroundBrush
= wxNullBrush
;
430 m_vSelectedBitmap
= wxNullBitmap
;
431 } // end of wxDC::SelectOldObjects
433 // ---------------------------------------------------------------------------
435 // ---------------------------------------------------------------------------
437 #define DO_SET_CLIPPING_BOX() \
441 ::GpiQueryClipBox(m_hPS, &rect); \
443 m_clipX1 = (wxCoord) XDEV2LOG(rect.xLeft); \
444 m_clipY1 = (wxCoord) YDEV2LOG(rect.yTop); \
445 m_clipX2 = (wxCoord) XDEV2LOG(rect.xRight); \
446 m_clipY2 = (wxCoord) YDEV2LOG(rect.yBottom); \
449 void wxDC::DoSetClippingRegion(
458 vY
= OS2Y(vY
,vHeight
);
461 vRect
.yTop
= vY
+ vHeight
;
462 vRect
.xRight
= vX
+ vWidth
;
464 ::GpiIntersectClipRectangle(m_hPS
, &vRect
);
465 DO_SET_CLIPPING_BOX()
466 } // end of wxDC::DoSetClippingRegion
468 void wxDC::DoSetClippingRegionAsRegion(
469 const wxRegion
& rRegion
472 wxCHECK_RET(rRegion
.GetHRGN(), wxT("invalid clipping region"));
476 ::GpiSetClipRegion( m_hPS
477 ,(HRGN
)rRegion
.GetHRGN()
480 DO_SET_CLIPPING_BOX()
481 } // end of wxDC::DoSetClippingRegionAsRegion
483 void wxDC::DestroyClippingRegion(void)
485 if (m_clipping
&& m_hPS
)
490 // TODO: this should restore the previous clipped region
491 // so that OnPaint processing works correctly, and
492 // the update doesn't get destroyed after the first
493 // DestroyClippingRegion
494 vRect
.xLeft
= XLOG2DEV(0);
495 vRect
.yTop
= YLOG2DEV(32000);
496 vRect
.xRight
= XLOG2DEV(32000);
497 vRect
.yBottom
= YLOG2DEV(0);
499 HRGN hRgn
= ::GpiCreateRegion(m_hPS
, 1, &vRect
);
501 ::GpiSetClipRegion(m_hPS
, hRgn
, &hRgnOld
);
504 } // end of wxDC::DestroyClippingRegion
506 // ---------------------------------------------------------------------------
507 // query capabilities
508 // ---------------------------------------------------------------------------
510 bool wxDC::CanDrawBitmap() const
515 bool wxDC::CanGetTextExtent() const
517 LONG lTechnology
= 0L;
519 ::DevQueryCaps(GetHDC(), CAPS_TECHNOLOGY
, 1L, &lTechnology
);
520 return (lTechnology
== CAPS_TECH_RASTER_DISPLAY
) || (lTechnology
== CAPS_TECH_RASTER_PRINTER
);
521 } // end of wxDC::CanGetTextExtent
523 int wxDC::GetDepth() const
525 LONG lArray
[CAPS_COLOR_BITCOUNT
];
528 if(::DevQueryCaps( GetHDC()
534 nBitsPerPixel
= (int)lArray
[CAPS_COLOR_BITCOUNT
];
536 return nBitsPerPixel
;
537 } // end of wxDC::GetDepth
539 // ---------------------------------------------------------------------------
541 // ---------------------------------------------------------------------------
546 // If this is a canvas DC then just fill with the background color
547 // Otherwise purge the whole thing
553 ::GpiQueryClipBox(m_hPS
, &vRect
);
554 ::WinFillRect(m_hPS
, &vRect
, ::GpiQueryBackColor(m_hPS
));
558 } // end of wxDC::Clear
560 bool wxDC::DoFloodFill(
563 , const wxColour
& rCol
571 bool bSuccess
= FALSE
;
573 vPtlPos
.x
= vX
; // Loads x-coordinate
574 vPtlPos
.y
= OS2Y(vY
,0); // Loads y-coordinate
575 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
576 lColor
= rCol
.GetPixel();
577 lOptions
= FF_BOUNDARY
;
578 if(wxFLOOD_SURFACE
== nStyle
)
579 lOptions
= FF_SURFACE
;
581 if ((lHits
= ::GpiFloodFill(m_hPS
, lOptions
, lColor
)) != GPI_ERROR
)
584 } // end of wxDC::DoFloodFill
586 bool wxDC::DoGetPixel(
596 vPoint
.y
= OS2Y(vY
,0);
597 lColor
= ::GpiSetPel(m_hPS
, &vPoint
);
600 // Get the color of the pen
602 LONG lPencolor
= 0x00ffffff;
606 lPencolor
= m_pen
.GetColour().GetPixel();
610 // return the color of the pixel
613 pCol
->Set( GetRValue(lColor
)
617 return(lColor
== lPencolor
);
618 } // end of wxDC::DoGetPixel
620 void wxDC::DoCrossHair(
627 wxCoord vX1
= vX
- VIEWPORT_EXTENT
;
628 wxCoord vY1
= vY
- VIEWPORT_EXTENT
;
629 wxCoord vX2
= vX
+ VIEWPORT_EXTENT
;
630 wxCoord vY2
= vY
+ VIEWPORT_EXTENT
;
639 ::GpiMove(m_hPS
, &vPoint
[0]);
640 ::GpiLine(m_hPS
, &vPoint
[1]);
648 ::GpiMove(m_hPS
, &vPoint
[2]);
649 ::GpiLine(m_hPS
, &vPoint
[3]);
650 CalcBoundingBox(vX1
, vY1
);
651 CalcBoundingBox(vX2
, vY2
);
652 } // end of wxDC::DoCrossHair
654 void wxDC::DoDrawLine(
662 COLORREF vColor
= 0x00ffffff;
665 // Might be a memory DC with no Paint rect.
667 if (!(m_vRclPaint
.yTop
== 0 &&
668 m_vRclPaint
.yBottom
== 0 &&
669 m_vRclPaint
.xRight
== 0 &&
670 m_vRclPaint
.xLeft
== 0))
677 if (m_vSelectedBitmap
!= wxNullBitmap
)
679 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
680 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
691 vColor
= m_pen
.GetColour().GetPixel();
693 ::GpiSetColor(m_hPS
, vColor
);
694 ::GpiMove(m_hPS
, &vPoint
[0]);
695 ::GpiLine(m_hPS
, &vPoint
[1]);
696 CalcBoundingBox(vX1
, vY1
);
697 CalcBoundingBox(vX2
, vY2
);
698 } // end of wxDC::DoDrawLine
700 //////////////////////////////////////////////////////////////////////////////
701 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
702 // and ending at (x2, y2). The current pen is used for the outline and the
703 // current brush for filling the shape. The arc is drawn in an anticlockwise
704 // direction from the start point to the end point.
705 //////////////////////////////////////////////////////////////////////////////
706 void wxDC::DoDrawArc(
716 POINTL vPtlArc
[2]; // Structure for current position
725 ARCPARAMS vArcp
; // Structure for arc parameters
727 if((vX1
== vXc
&& vY1
== vXc
) || (vX2
== vXc
&& vY2
== vXc
))
728 return; // Draw point ??
729 dRadius
= 0.5 * ( hypot( (double)(vY1
- vYc
)
732 hypot( (double)(vY2
- vYc
)
737 dAngl1
= atan2( (double)(vY1
- vYc
)
740 dAngl2
= atan2( (double)(vY2
- vYc
)
747 // GpiPointArc can't draw full arc
749 if(dAngl2
== dAngl1
|| (vX1
== vX2
&& vY1
== vY2
) )
754 dAnglmid
= (dAngl1
+ dAngl2
)/2. + M_PI
;
755 vXm
= vXc
+ dRadius
* cos(dAnglmid
);
756 vYm
= vYc
+ dRadius
* sin(dAnglmid
);
771 dAnglmid
= (dAngl1
+ dAngl2
)/2.;
772 vXm
= vXc
+ dRadius
* cos(dAnglmid
);
773 vYm
= vYc
+ dRadius
* sin(dAnglmid
);
776 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
782 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
784 vPtlPos
.x
= vX1
; // Loads x-coordinate
785 vPtlPos
.y
= vY1
; // Loads y-coordinate
786 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
791 ::GpiPointArc(m_hPS
, vPtlArc
); // Draws the arc
792 CalcBoundingBox( (vXc
- dRadius
)
795 CalcBoundingBox( (vXc
+ dRadius
)
798 } // end of wxDC::DoDrawArc
800 void wxDC::DoDrawCheckMark(
809 vY1
= OS2Y(vY1
,vHeight
);
813 vPoint
[1].x
= vX1
+ vWidth
;
814 vPoint
[1].y
= vY1
+ vHeight
;
816 ::GpiMove(m_hPS
, &vPoint
[0]);
817 ::GpiBox( m_hPS
// handle to a presentation space
818 ,DRO_OUTLINE
// draw the box outline ? or ?
819 ,&vPoint
[1] // address of the corner
820 ,0L // horizontal corner radius
821 ,0L // vertical corner radius
823 if(vWidth
> 4 && vHeight
> 4)
827 vPoint
[0].x
+= 2; vPoint
[0].y
+= 2;
828 vPoint
[1].x
-= 2; vPoint
[1].y
-= 2;
829 ::GpiMove(m_hPS
, &vPoint
[0]);
830 ::GpiLine(m_hPS
, &vPoint
[1]);
832 vPoint
[0].x
= vPoint
[1].x
;
834 ::GpiMove(m_hPS
, &vPoint
[0]);
835 ::GpiLine(m_hPS
, &vPoint
[1]);
841 wxCoord vX2
= vX1
+ vWidth
;
842 wxCoord vY2
= vY1
+ vHeight
;
847 } // end of wxDC::DoDrawCheckMark
849 void wxDC::DoDrawPoint(
855 COLORREF vColor
= 0x00ffffff;
859 vColor
= m_pen
.GetColour().GetPixel();
861 ::GpiSetColor(m_hPS
, vColor
);
863 vPoint
.y
= OS2Y(vY
,0);
864 ::GpiSetPel(m_hPS
, &vPoint
);
868 } // end of wxDC::DoDrawPoint
870 void wxDC::DoDrawPolygon(
878 ULONG ulCount
= 1; // Number of polygons.
879 POLYGON vPlgn
; // polygon.
880 ULONG flOptions
= 0L; // Drawing options.
882 //////////////////////////////////////////////////////////////////////////////
883 // This contains fields of option bits... to draw boundary lines as well as
884 // the area interior.
886 // Drawing boundary lines:
887 // POLYGON_NOBOUNDARY Does not draw boundary lines.
888 // POLYGON_BOUNDARY Draws boundary lines (the default).
890 // Construction of the area interior:
891 // POLYGON_ALTERNATE Constructs interior in alternate mode
893 // POLYGON_WINDING Constructs interior in winding mode.
894 //////////////////////////////////////////////////////////////////////////////
896 ULONG flModel
= 0L; // Drawing model.
898 //////////////////////////////////////////////////////////////////////////////
900 // POLYGON_INCL Fill is inclusive of bottom right (the default).
901 // POLYGON_EXCL Fill is exclusive of bottom right.
902 // This is provided to aid migration from other graphics models.
903 //////////////////////////////////////////////////////////////////////////////
905 LONG lHits
= 0L; // Correlation/error indicator.
908 int nIsTRANSPARENT
= 0;
909 LONG lBorderColor
= 0L;
912 lBorderColor
= m_pen
.GetColour().GetPixel();
913 lColor
= m_brush
.GetColour().GetPixel();
914 if(m_brush
.GetStyle() == wxTRANSPARENT
)
918 vPlgn
.aPointl
= (POINTL
*) calloc( n
+ 1
920 ); // well, new will call malloc
922 for(i
= 0; i
< n
; i
++)
924 vPlgn
.aPointl
[i
].x
= vPoints
[i
].x
; // +xoffset;
925 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
,0); // +yoffset;
927 flModel
= POLYGON_BOUNDARY
;
928 if(nFillStyle
== wxWINDING_RULE
)
929 flModel
|= POLYGON_WINDING
;
931 flModel
|= POLYGON_ALTERNATE
;
934 vPoint
.y
= OS2Y(vYoffset
,0);
936 ::GpiSetColor(m_hPS
, lBorderColor
);
937 ::GpiMove(m_hPS
, &vPoint
);
938 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
940 } // end of wxDC::DoDrawPolygon
942 void wxDC::DoDrawLines(
951 if (vXoffset
!= 0L || vXoffset
!= 0L)
955 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
956 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
957 ::GpiMove(m_hPS
, &vPoint
);
959 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
961 ::GpiSetColor(m_hPS
, lBorderColor
);
962 for(i
= 1; i
< n
; i
++)
964 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
965 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
966 ::GpiLine(m_hPS
, &vPoint
);
973 CalcBoundingBox( vPoints
[i
].x
976 vPoint
.x
= vPoints
[0].x
;
977 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
978 ::GpiMove(m_hPS
, &vPoint
);
980 for (i
= 0; i
< n
; i
++)
982 CalcBoundingBox( vPoints
[i
].x
985 vPoint
.x
= vPoints
[i
].x
;
986 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
987 ::GpiLine(m_hPS
, &vPoint
);
990 } // end of wxDC::DoDrawLines
992 void wxDC::DoDrawRectangle(
1003 int nIsTRANSPARENT
= 0;
1006 // Might be a memory DC with no Paint rect.
1008 if (!(m_vRclPaint
.yTop
== 0 &&
1009 m_vRclPaint
.yBottom
== 0 &&
1010 m_vRclPaint
.xRight
== 0 &&
1011 m_vRclPaint
.xLeft
== 0))
1012 vY
= OS2Y(vY
,vHeight
);
1015 if (m_vSelectedBitmap
!= wxNullBitmap
)
1017 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1018 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1019 vY
= OS2Y(vY
,vHeight
);
1023 wxCoord vX2
= vX
+ vWidth
;
1024 wxCoord vY2
= vY
+ vHeight
;
1028 vPoint
[1].x
= vX
+ vWidth
- 1;
1029 vPoint
[1].y
= vY
+ vHeight
- 1;
1030 ::GpiMove(m_hPS
, &vPoint
[0]);
1031 lColor
= m_brush
.GetColour().GetPixel();
1032 lBorderColor
= m_pen
.GetColour().GetPixel();
1033 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1035 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1037 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1038 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1039 lControl
= DRO_OUTLINE
;
1041 ::GpiSetColor(m_hPS
, lColor
);
1042 ::GpiBox( m_hPS
// handle to a presentation space
1043 ,lControl
// draw the box outline ? or ?
1044 ,&vPoint
[1] // address of the corner
1045 ,0L // horizontal corner radius
1046 ,0L // vertical corner radius
1051 lControl
= DRO_OUTLINE
;
1052 ::GpiSetColor( m_hPS
1061 lControl
= DRO_FILL
;
1062 ::GpiSetColor( m_hPS
1065 vPoint
[0].x
= vX
+ 1;
1066 vPoint
[0].y
= vY
+ 1;
1067 vPoint
[1].x
= vX
+ vWidth
- 2;
1068 vPoint
[1].y
= vY
+ vHeight
- 2;
1069 ::GpiMove(m_hPS
, &vPoint
[0]);
1077 CalcBoundingBox(vX
, vY
);
1078 CalcBoundingBox(vX2
, vY2
);
1079 } // end of wxDC::DoDrawRectangle
1081 void wxDC::DoDrawRoundedRectangle(
1093 int nIsTRANSPARENT
= 0;
1096 // Might be a memory DC with no Paint rect.
1098 if (!(m_vRclPaint
.yTop
== 0 &&
1099 m_vRclPaint
.yBottom
== 0 &&
1100 m_vRclPaint
.xRight
== 0 &&
1101 m_vRclPaint
.xLeft
== 0))
1102 vY
= OS2Y(vY
,vHeight
);
1105 if (m_vSelectedBitmap
!= wxNullBitmap
)
1107 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1108 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1109 vY
= OS2Y(vY
,vHeight
);
1113 wxCoord vX2
= (vX
+ vWidth
);
1114 wxCoord vY2
= (vY
+ vHeight
);
1118 vPoint
[1].x
= vX
+ vWidth
- 1;
1119 vPoint
[1].y
= vY
+ vHeight
- 1;
1120 ::GpiMove(m_hPS
, &vPoint
[0]);
1122 lColor
= m_brush
.GetColour().GetPixel();
1123 lBorderColor
= m_pen
.GetColour().GetPixel();
1124 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1125 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1127 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1129 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1130 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1131 lControl
= DRO_OUTLINE
;
1133 ::GpiSetColor(m_hPS
, lColor
);
1134 ::GpiBox( m_hPS
// handle to a presentation space
1135 ,lControl
// draw the box outline ? or ?
1136 ,&vPoint
[1] // address of the corner
1137 ,(LONG
)dRadius
// horizontal corner radius
1138 ,(LONG
)dRadius
// vertical corner radius
1143 lControl
= DRO_OUTLINE
;
1144 ::GpiSetColor( m_hPS
1153 lControl
= DRO_FILL
;
1154 ::GpiSetColor( m_hPS
1157 vPoint
[0].x
= vX
+ 1;
1158 vPoint
[0].y
= vY
+ 1;
1159 vPoint
[1].x
= vX
+ vWidth
- 2;
1160 vPoint
[1].y
= vY
+ vHeight
- 2;
1161 ::GpiMove(m_hPS
, &vPoint
[0]);
1170 CalcBoundingBox(vX
, vY
);
1171 CalcBoundingBox(vX2
, vY2
);
1172 } // end of wxDC::DoDrawRoundedRectangle
1174 // Draw Ellipse within box (x,y) - (x+width, y+height)
1175 void wxDC::DoDrawEllipse(
1182 POINTL vPtlPos
; // Structure for current position
1183 FIXED vFxMult
; // Multiplier for ellipse
1184 ARCPARAMS vArcp
; // Structure for arc parameters
1186 vY
= OS2Y(vY
,vHeight
);
1189 vArcp
.lQ
= vHeight
/2;
1190 vArcp
.lP
= vWidth
/2;
1192 ::GpiSetArcParams( m_hPS
1194 ); // Sets parameters to default
1195 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
1196 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1199 ); // Sets current position
1200 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
1203 // DRO_FILL, DRO_OTLINEFILL - where to get
1208 ); // Draws full arc with center at current position
1210 wxCoord vX2
= (vX
+ vWidth
);
1211 wxCoord vY2
= (vY
+ vHeight
);
1213 CalcBoundingBox(vX
, vY
);
1214 CalcBoundingBox(vX2
, vY2
);
1215 } // end of wxDC::DoDrawEllipse
1217 void wxDC::DoDrawEllipticArc(
1226 POINTL vPtlPos
; // Structure for current position
1227 FIXED vFxMult
; // Multiplier for ellipse
1228 ARCPARAMS vArcp
; // Structure for arc parameters
1230 FIXED vFSweepa
; // Start angle, sweep angle
1235 vY
= OS2Y(vY
,vHeight
);
1237 dFractPart
= modf(dSa
,&dIntPart
);
1238 vFSa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1239 dFractPart
= modf(dEa
- dSa
, &dIntPart
);
1240 vFSweepa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1243 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1246 vArcp
.lQ
= vHeight
/2;
1247 vArcp
.lP
= vWidth
/2;
1249 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
1250 vPtlPos
.x
= vX
+ vWidth
/2 * (1. + cos(DegToRad(dSa
))); // Loads x-coordinate
1251 vPtlPos
.y
= vY
+ vHeight
/2 * (1. + sin(DegToRad(dSa
))); // Loads y-coordinate
1252 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
1255 // May be not to the center ?
1257 vPtlPos
.x
= vX
+ vWidth
/2 ; // Loads x-coordinate
1258 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1259 vFxMult
= MAKEFIXED(1, 0); // Sets multiplier
1262 // DRO_FILL, DRO_OTLINEFILL - where to get
1264 ::GpiPartialArc( m_hPS
1270 wxCoord vX2
= (vX
+ vWidth
);
1271 wxCoord vY2
= (vY
+ vHeight
);
1273 CalcBoundingBox(vX
, vY
);
1274 CalcBoundingBox(vX2
, vY2
);
1275 } // end of wxDC::DoDrawEllipticArc
1277 void wxDC::DoDrawIcon(
1284 // Need to copy back into a bitmap. ::WinDrawPointer uses device coords
1285 // and I don't feel like figuring those out for scrollable windows so
1286 // just convert to a bitmap then let the DoDrawBitmap routing display it
1290 DoDrawBitmap(rIcon
.GetXpmSrc(), vX
, vY
, TRUE
);
1294 wxBitmap
vBitmap(rIcon
);
1296 DoDrawBitmap(vBitmap
, vX
, vY
, FALSE
);
1298 CalcBoundingBox(vX
, vY
);
1299 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
1300 } // end of wxDC::DoDrawIcon
1302 void wxDC::DoDrawBitmap(
1303 const wxBitmap
& rBmp
1309 if (!IsKindOf(CLASSINFO(wxPrinterDC
)))
1311 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
1315 vY
= OS2Y(vY
,rBmp
.GetHeight());
1318 // Flip the picture as OS/2 is upside-down
1323 vPoint
[0].y
= vY
+ rBmp
.GetHeight();
1324 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1328 vPoint
[3].x
= rBmp
.GetWidth();
1329 vPoint
[3].y
= rBmp
.GetHeight();
1335 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1336 vPoint
[1].y
= vY
+ rBmp
.GetHeight();
1339 vPoint
[3].x
= rBmp
.GetWidth();
1340 vPoint
[3].y
= rBmp
.GetHeight();
1344 wxMask
* pMask
= rBmp
.GetMask();
1349 // Need to imitate ::MaskBlt in windows.
1350 // 1) Extract the bits from from the bitmap.
1351 // 2) Extract the bits from the mask
1352 // 3) Using the mask bits do the following:
1353 // A) If the mask byte is 00 leave the bitmap byte alone
1354 // B) If the mask byte is FF copy the screen color into
1356 // 4) Create a new bitmap and set its bits to the above result
1357 // 5) Blit this to the screen PS
1359 HBITMAP hMask
= (HBITMAP
)pMask
->GetMaskBitmap();
1360 HBITMAP hOldMask
= NULLHANDLE
;
1361 HBITMAP hOldBitmap
= NULLHANDLE
;
1362 HBITMAP hNewBitmap
= NULLHANDLE
;
1363 unsigned char* pucBits
; // buffer that will contain the bitmap data
1364 unsigned char* pucBitsMask
; // buffer that will contain the mask data
1365 unsigned char* pucData
; // pointer to use to traverse bitmap data
1366 unsigned char* pucDataMask
; // pointer to use to traverse mask data
1372 // The usual Memory context creation stuff
1374 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1375 SIZEL vSize
= {0, 0};
1376 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1377 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1380 // The usual bitmap header stuff
1382 BITMAPINFOHEADER2 vHeader
;
1385 memset(&vHeader
, '\0', 16);
1388 memset(&vInfo
, '\0', 16);
1390 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1391 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1393 vInfo
.cBitCount
= 24; // Set to desired count going in
1396 // Create the buffers for data....all wxBitmaps are 24 bit internally
1398 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1399 int nSizeDWORD
= sizeof(DWORD
);
1400 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
1408 // Need to get a background color for mask blitting
1410 if (IsKindOf(CLASSINFO(wxPaintDC
)))
1412 wxPaintDC
* pPaintDC
= wxDynamicCast(this, wxPaintDC
);
1414 lColor
= pPaintDC
->m_pCanvas
->GetBackgroundColour().GetPixel();
1416 else if (GetBrush() != wxNullBrush
)
1417 lColor
= GetBrush().GetColour().GetPixel();
1419 lColor
= m_textBackgroundColour
.GetPixel();
1422 // Bitmap must be ina double-word alligned address so we may
1423 // have some padding to worry about
1425 if (nLineBoundary
> 0)
1427 nPadding
= nSizeDWORD
- nLineBoundary
;
1428 nBytesPerLine
+= nPadding
;
1430 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1431 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1432 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1433 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1436 // Extract the bitmap and mask data
1438 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1440 vError
= ::WinGetLastError(vHabmain
);
1441 sError
= wxPMErrorToStr(vError
);
1443 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
1444 vInfo
.cBitCount
= 24;
1445 if ((lScans
= ::GpiQueryBitmapBits( hPS
1447 ,(LONG
)rBmp
.GetHeight()
1452 vError
= ::WinGetLastError(vHabmain
);
1453 sError
= wxPMErrorToStr(vError
);
1455 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
1457 vError
= ::WinGetLastError(vHabmain
);
1458 sError
= wxPMErrorToStr(vError
);
1460 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
1461 vInfo
.cBitCount
= 24;
1462 if ((lScans
= ::GpiQueryBitmapBits( hPS
1464 ,(LONG
)rBmp
.GetHeight()
1469 vError
= ::WinGetLastError(vHabmain
);
1470 sError
= wxPMErrorToStr(vError
);
1472 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
1474 vError
= ::WinGetLastError(vHabmain
);
1475 sError
= wxPMErrorToStr(vError
);
1479 // Now set the bytes(bits) according to the mask values
1480 // 3 bytes per pel...must handle one at a time
1483 pucDataMask
= pucBitsMask
;
1486 // 16 bit kludge really only kinda works. The mask gets applied
1487 // where needed but the original bitmap bits are dorked sometimes
1489 bool bpp16
= (wxDisplayDepth() == 16);
1491 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1493 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1496 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1498 else if (*pucDataMask
== 0xFF) // leave bitmap byte alone
1502 *pucData
= ((unsigned char)(lColor
>> 16));
1506 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1508 else if (*(pucDataMask
+ 1) == 0xFF) // leave bitmap byte alone
1512 *pucData
= ((unsigned char)(lColor
>> 8));
1517 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1519 else if (*(pucDataMask
+ 2) == 0xFF) // leave bitmap byte alone
1523 *pucData
= ((unsigned char)lColor
);
1528 for (j
= 0; j
< nPadding
; j
++)
1535 // Create a new bitmap
1537 vHeader
.cx
= (ULONG
)rBmp
.GetWidth();
1538 vHeader
.cy
= (ULONG
)rBmp
.GetHeight();
1539 vHeader
.cPlanes
= 1L;
1540 vHeader
.cBitCount
= 24;
1541 if ((hNewBitmap
= ::GpiCreateBitmap( hPS
1548 vError
= ::WinGetLastError(vHabmain
);
1549 sError
= wxPMErrorToStr(vError
);
1553 // Now blit it to the screen PS
1555 if ((lHits
= ::GpiWCBitBlt( (HPS
)GetHPS()
1563 vError
= ::WinGetLastError(vHabmain
);
1564 sError
= wxPMErrorToStr(vError
);
1572 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1573 ::GpiDeleteBitmap(hNewBitmap
);
1574 ::GpiDestroyPS(hPS
);
1580 LONG lOldForeGround
= ::GpiQueryColor((HPS
)GetHPS());
1581 LONG lOldBackGround
= ::GpiQueryBackColor((HPS
)GetHPS());
1583 if (m_textForegroundColour
.Ok())
1585 ::GpiSetColor( (HPS
)GetHPS()
1586 ,m_textForegroundColour
.GetPixel()
1589 if (m_textBackgroundColour
.Ok())
1591 ::GpiSetBackColor( (HPS
)GetHPS()
1592 ,m_textBackgroundColour
.GetPixel()
1596 // Need to alter bits in a mono bitmap to match the new
1597 // background-foreground if it is different.
1599 if (rBmp
.IsMono() &&
1600 ((m_textForegroundColour
.GetPixel() != lOldForeGround
) ||
1601 (m_textBackgroundColour
.GetPixel() != lOldBackGround
)))
1603 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1604 SIZEL vSize
= {0, 0};
1605 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1606 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1608 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1610 LONG lForeGround
= m_textForegroundColour
.GetPixel();
1611 LONG lBackGround
= m_textBackgroundColour
.GetPixel();
1613 HBITMAP hOldBitmap
= NULLHANDLE
;
1619 memset(&vInfo
, '\0', 16);
1621 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1622 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1624 vInfo
.cBitCount
= 24;
1626 unsigned char* pucBits
; // buffer that will contain the bitmap data
1627 unsigned char* pucData
; // pointer to use to traverse bitmap data
1629 pucBits
= new unsigned char[nBytesPerLine
* rBmp
.GetHeight()];
1630 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1632 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1634 vError
= ::WinGetLastError(vHabmain
);
1635 sError
= wxPMErrorToStr(vError
);
1638 if ((lScans
= ::GpiQueryBitmapBits( hPS
1640 ,(LONG
)rBmp
.GetHeight()
1645 vError
= ::WinGetLastError(vHabmain
);
1646 sError
= wxPMErrorToStr(vError
);
1649 unsigned char cOldRedFore
= (unsigned char)(lOldForeGround
>> 16);
1650 unsigned char cOldGreenFore
= (unsigned char)(lOldForeGround
>> 8);
1651 unsigned char cOldBlueFore
= (unsigned char)lOldForeGround
;
1653 unsigned char cOldRedBack
= (unsigned char)(lOldBackGround
>> 16);
1654 unsigned char cOldGreenBack
= (unsigned char)(lOldBackGround
>> 8);
1655 unsigned char cOldBlueBack
= (unsigned char)lOldBackGround
;
1657 unsigned char cRedFore
= (unsigned char)(lForeGround
>> 16);
1658 unsigned char cGreenFore
= (unsigned char)(lForeGround
>> 8);
1659 unsigned char cBlueFore
= (unsigned char)lForeGround
;
1661 unsigned char cRedBack
= (unsigned char)(lBackGround
>> 16);
1662 unsigned char cGreenBack
= (unsigned char)(lBackGround
>> 8);
1663 unsigned char cBlueBack
= (unsigned char)lBackGround
;
1666 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1668 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1670 unsigned char cBmpRed
= *pucData
;
1671 unsigned char cBmpGreen
= *(pucData
+ 1);
1672 unsigned char cBmpBlue
= *(pucData
+ 2);
1674 if ((cBmpRed
== cOldRedFore
) &&
1675 (cBmpGreen
== cOldGreenFore
) &&
1676 (cBmpBlue
== cOldBlueFore
))
1678 *pucData
= cBlueFore
;
1680 *pucData
= cGreenFore
;
1682 *pucData
= cRedFore
;
1687 *pucData
= cBlueBack
;
1689 *pucData
= cGreenBack
;
1691 *pucData
= cRedBack
;
1696 if ((lScans
= ::GpiSetBitmapBits( hPS
1698 ,(LONG
)rBmp
.GetHeight()
1703 vError
= ::WinGetLastError(vHabmain
);
1704 sError
= wxPMErrorToStr(vError
);
1708 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1709 ::GpiDestroyPS(hPS
);
1712 ::GpiWCBitBlt( (HPS
)GetHPS()
1719 ::GpiSetBitmap((HPS
)GetHPS(), hBitmapOld
);
1720 ::GpiSetColor((HPS
)GetHPS(), lOldForeGround
);
1721 ::GpiSetBackColor((HPS
)GetHPS(), lOldBackGround
);
1724 } // end of wxDC::DoDrawBitmap
1726 void wxDC::DoDrawText(
1727 const wxString
& rsText
1740 CalcBoundingBox(vX
, vY
);
1741 GetTextExtent(rsText
, &vWidth
, &vHeight
);
1742 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1743 } // end of wxDC::DoDrawText
1745 void wxDC::DrawAnyText(
1746 const wxString
& rsText
1751 int nOldBackground
= 0;
1758 // prepare for drawing the text
1762 // Set text color attributes
1764 if (m_textForegroundColour
.Ok())
1767 ,(int)m_textForegroundColour
.GetPixel()
1771 if (m_textBackgroundColour
.Ok())
1773 nOldBackground
= SetTextBkColor( m_hPS
1774 ,(int)m_textBackgroundColour
.GetPixel()
1780 GetTextExtent( rsText
1785 if (!(m_vRclPaint
.yTop
== 0 &&
1786 m_vRclPaint
.yBottom
== 0 &&
1787 m_vRclPaint
.xRight
== 0 &&
1788 m_vRclPaint
.xLeft
== 0))
1789 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1792 if (m_vSelectedBitmap
!= wxNullBitmap
)
1794 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1795 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1796 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1802 PCH pzStr
= (PCH
)rsText
.c_str();
1804 ::GpiMove(m_hPS
, &vPtlStart
);
1805 lHits
= ::GpiCharString( m_hPS
1809 if (lHits
!= GPI_OK
)
1811 wxLogLastError(wxT("TextOut"));
1815 // Restore the old parameters (text foreground colour may be left because
1816 // it never is set to anything else, but background should remain
1817 // transparent even if we just drew an opaque string)
1819 if (m_textBackgroundColour
.Ok())
1820 SetTextBkColor( m_hPS
1828 void wxDC::DoDrawRotatedText(
1829 const wxString
& rsText
1847 DoDrawText(text, x, y);
1852 wxFillLogFont(&lf, &m_font);
1854 // GDI wants the angle in tenth of degree
1855 long angle10 = (long)(angle * 10);
1856 lf.lfEscapement = angle10;
1857 lf. lfOrientation = angle10;
1859 HFONT hfont = ::CreateFontIndirect(&lf);
1862 wxLogLastError("CreateFont");
1866 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1868 DrawAnyText(text, x, y);
1870 (void)::SelectObject(GetHdc(), hfontOld);
1873 // call the bounding box by adding all four vertices of the rectangle
1874 // containing the text to it (simpler and probably not slower than
1875 // determining which of them is really topmost/leftmost/...)
1877 GetTextExtent(text, &w, &h);
1879 double rad = DegToRad(angle);
1881 // "upper left" and "upper right"
1882 CalcBoundingBox(x, y);
1883 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1884 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1886 // "bottom left" and "bottom right"
1887 x += (wxCoord)(h*sin(rad));
1888 y += (wxCoord)(h*cos(rad));
1889 CalcBoundingBox(x, y);
1890 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1895 // ---------------------------------------------------------------------------
1897 // ---------------------------------------------------------------------------
1899 void wxDC::DoSelectPalette(
1904 // Set the old object temporarily, in case the assignment deletes an object
1905 // that's not yet selected out.
1916 hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1918 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1920 } // end of wxDC::DoSelectPalette
1922 void wxDC::InitializePalette()
1924 if (wxDisplayDepth() <= 8 )
1927 // Look for any window or parent that has a custom palette. If any has
1928 // one then we need to use it in drawing operations
1930 wxWindow
* pWin
= m_pCanvas
->GetAncestorWithCustomPalette();
1932 m_hasCustomPalette
= pWin
&& pWin
->HasCustomPalette();
1933 if (m_hasCustomPalette
)
1935 m_palette
= pWin
->GetPalette();
1938 // turn on PM translation for this palette
1943 } // end of wxDC::InitializePalette
1945 void wxDC::SetPalette(
1946 const wxPalette
& rPalette
1953 m_palette
= rPalette
;
1961 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1963 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1964 } // end of wxDC::SetPalette
1971 // Set the old object temporarily, in case the assignment deletes an object
1972 // that's not yet selected out.
1984 m_font
.SetPS(m_hPS
); // this will realize the font
1988 HFONT hFont
= m_font
.GetResourceHandle();
1989 if (hFont
== (HFONT
) NULL
)
1991 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
1994 m_hOldFont
= (WXHFONT
) hFont
;
1996 } // end of wxDC::SetFont
2002 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2018 m_pen
.SetPS((HPS
)m_hOldPen
);
2025 if (m_pen
.GetResourceHandle())
2029 m_hOldPen
= m_pen
.GetPS();
2031 ::GpiSetColor(m_hPS
, m_pen
.GetColour().GetPixel());
2035 void wxDC::SetBrush(
2036 const wxBrush
& rBrush
2039 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2045 if (m_brush
== rBrush
)
2055 m_brush
.SetPS((HPS
)m_hOldBrush
);
2062 if (m_brush
.GetResourceHandle())
2064 m_brush
.SetPS(m_hPS
);
2066 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
2069 } // end of wxDC::SetBrush
2071 void wxDC::SetBackground(
2072 const wxBrush
& rBrush
2075 m_backgroundBrush
= rBrush
;
2076 if (!m_backgroundBrush
.Ok())
2080 bool bCustomColours
= TRUE
;
2083 // If we haven't specified wxUSER_COLOURS, don't allow the panel/dialog box to
2084 // change background colours from the control-panel specified colours.
2086 if (m_pCanvas
->IsKindOf(CLASSINFO(wxWindow
)) &&
2087 ((m_pCanvas
->GetWindowStyleFlag() & wxUSER_COLOURS
) != wxUSER_COLOURS
))
2088 bCustomColours
= FALSE
;
2091 if (m_backgroundBrush
.GetStyle()==wxTRANSPARENT
)
2093 m_pCanvas
->SetTransparent(TRUE
);
2098 // Setting the background brush of a DC
2099 // doesn't affect the window background colour. However,
2100 // I'm leaving in the transparency setting because it's needed by
2101 // various controls (e.g. wxStaticText) to determine whether to draw
2102 // transparently or not. TODO: maybe this should be a new function
2103 // wxWindow::SetTransparency(). Should that apply to the child itself, or the
2105 // m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
2107 m_pCanvas
->SetTransparent(FALSE
);
2111 COLORREF vNewColor
= m_backgroundBrush
.GetColour().GetPixel();
2112 (void)::GpiSetBackColor((HPS
)m_hPS
, (LONG
)vNewColor
);
2113 } // end of wxDC::SetBackground
2115 void wxDC::SetBackgroundMode(
2119 m_backgroundMode
= nMode
;
2120 } // end of wxDC::SetBackgroundMode
2122 void wxDC::SetLogicalFunction(
2126 m_logicalFunction
= nFunction
;
2127 SetRop((WXHDC
)m_hDC
);
2128 } // wxDC::SetLogicalFunction
2134 if (!hDC
|| m_logicalFunction
< 0)
2138 switch (m_logicalFunction
)
2149 lCRop
= FM_MERGESRCNOT
;
2153 lCRop
= FM_NOTMASKSRC
;
2165 lCRop
= FM_MERGENOTSRC
;
2169 lCRop
= FM_MERGESRCNOT
;
2181 lCRop
= FM_SUBTRACT
;
2188 lCRop
= FM_OVERPAINT
;
2191 ::GpiSetMix((HPS
)hDC
, lCRop
);
2192 } // end of wxDC::SetRop
2194 bool wxDC::StartDoc(
2195 const wxString
& rsMessage
2198 // We might be previewing, so return TRUE to let it continue.
2200 } // end of wxDC::StartDoc
2204 } // end of wxDC::EndDoc
2206 void wxDC::StartPage()
2208 } // end of wxDC::StartPage
2210 void wxDC::EndPage()
2212 } // end of wxDC::EndPage
2214 // ---------------------------------------------------------------------------
2216 // ---------------------------------------------------------------------------
2218 wxCoord
wxDC::GetCharHeight() const
2220 FONTMETRICS vFM
; // metrics structure
2222 ::GpiQueryFontMetrics( m_hPS
2223 ,sizeof(FONTMETRICS
)
2226 return YDEV2LOGREL(vFM
.lXHeight
);
2229 wxCoord
wxDC::GetCharWidth() const
2231 FONTMETRICS vFM
; // metrics structure
2233 ::GpiQueryFontMetrics( m_hPS
2234 ,sizeof(FONTMETRICS
)
2237 return XDEV2LOGREL(vFM
.lAveCharWidth
);
2240 void wxDC::DoGetTextExtent(
2241 const wxString
& rsString
2244 , wxCoord
* pvDescent
2245 , wxCoord
* pvExternalLeading
2249 POINTL avPoint
[TXTBOX_COUNT
];
2254 FONTMETRICS vFM
; // metrics structure
2257 ERRORID vErrorCode
; // last error id code
2258 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
2260 char zMsg
[128]; // DEBUG
2264 pFontToUse
= (wxFont
*)&m_font
;
2265 l
= rsString
.length();
2266 pStr
= (PCH
) rsString
.c_str();
2269 // In world coordinates.
2271 bRc
= ::GpiQueryTextBox( m_hPS
2274 ,TXTBOX_COUNT
// return maximum information
2275 ,avPoint
// array of coordinates points
2279 vErrorCode
= ::WinGetLastError(wxGetInstance());
2280 sError
= wxPMErrorToStr(vErrorCode
);
2282 sprintf(zMsg
, "GpiQueryTextBox for %s: failed with Error: %x - %s", pStr
, vErrorCode
, sError
.c_str());
2283 (void)wxMessageBox( "wxWindows Menu sample"
2289 vPtMin
.x
= avPoint
[0].x
;
2290 vPtMax
.x
= avPoint
[0].x
;
2291 vPtMin
.y
= avPoint
[0].y
;
2292 vPtMax
.y
= avPoint
[0].y
;
2293 for (i
= 1; i
< 4; i
++)
2295 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
2296 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
2297 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
2298 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
2300 ::GpiQueryFontMetrics( m_hPS
2301 ,sizeof(FONTMETRICS
)
2306 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
2308 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
2310 *pvDescent
= vFM
.lMaxDescender
;
2311 if (pvExternalLeading
)
2312 *pvExternalLeading
= vFM
.lExternalLeading
;
2315 void wxDC::SetMapMode(
2319 int nPixelWidth
= 0;
2320 int nPixelHeight
= 0;
2323 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2325 m_mappingMode
= nMode
;
2327 if(::DevQueryCaps( m_hDC
2329 ,CAPS_VERTICAL_RESOLUTION
2336 nPixelWidth
= lArray
[CAPS_WIDTH
];
2337 nPixelHeight
= lArray
[CAPS_HEIGHT
];
2338 lHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2339 lVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2340 nMmWidth
= (lHorzRes
/1000) * nPixelWidth
;
2341 nMmWidth
= (lVertRes
/1000) * nPixelHeight
;
2343 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
2348 double dMm2pixelsX
= nPixelWidth
/nMmWidth
;
2349 double dMm2pixelsY
= nPixelHeight
/nMmHeight
;
2354 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
2355 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
2359 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
2360 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
2364 m_logicalScaleX
= dMm2pixelsX
;
2365 m_logicalScaleY
= dMm2pixelsY
;
2369 m_logicalScaleX
= (dMm2pixelsX
/10.0);
2370 m_logicalScaleY
= (dMm2pixelsY
/10.0);
2375 m_logicalScaleX
= 1.0;
2376 m_logicalScaleY
= 1.0;
2382 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
2383 if (!ulOptions
& PU_ARBITRARY
)
2385 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
2386 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
2388 m_nWindowExtX
= (int)MS_XDEV2LOG(VIEWPORT_EXTENT
);
2389 m_nWindowExtY
= (int)MS_YDEV2LOG(VIEWPORT_EXTENT
);
2391 }; // end of wxDC::SetMapMode
2393 void wxDC::SetUserScale(
2401 SetMapMode(m_mappingMode
);
2402 } // end of wxDC::SetUserScale
2404 void wxDC::SetAxisOrientation(
2409 m_signX
= bXLeftRight
? 1 : -1;
2410 m_signY
= bYBottomUp
? -1 : 1;
2412 SetMapMode(m_mappingMode
);
2413 } // end of wxDC::SetAxisOrientation
2415 void wxDC::SetSystemScale(
2423 SetMapMode(m_mappingMode
);
2424 } // end of wxDC::SetSystemScale
2426 void wxDC::SetLogicalOrigin(
2433 ::GpiQueryPageViewport( m_hPS
2440 ::GpiSetPageViewport( m_hPS
2443 }; // end of wxDC::SetLogicalOrigin
2445 void wxDC::SetDeviceOrigin(
2452 m_deviceOriginX
= vX
;
2453 m_deviceOriginY
= vY
;
2454 ::GpiQueryPageViewport( m_hPS
2459 vRect
.yBottom
-= vY
;
2461 ::GpiSetPageViewport( m_hPS
2464 }; // end of wxDC::SetDeviceOrigin
2466 // ---------------------------------------------------------------------------
2467 // coordinates transformations
2468 // ---------------------------------------------------------------------------
2470 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2472 return (wxCoord
) (((x
) - m_deviceOriginX
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
) - m_logicalOriginX
);
2475 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2477 // axis orientation is not taken into account for conversion of a distance
2478 return (wxCoord
) ((x
)/(m_logicalScaleX
*m_userScaleX
*m_scaleX
));
2481 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2483 return (wxCoord
) (((y
) - m_deviceOriginY
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
) - m_logicalOriginY
);
2486 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2488 // axis orientation is not taken into account for conversion of a distance
2489 return (wxCoord
) ((y
)/(m_logicalScaleY
*m_userScaleY
*m_scaleY
));
2492 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2494 return (wxCoord
) ((x
- m_logicalOriginX
)*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
+ m_deviceOriginX
);
2497 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2499 // axis orientation is not taken into account for conversion of a distance
2500 return (wxCoord
) (x
*m_logicalScaleX
*m_userScaleX
*m_scaleX
);
2503 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2505 return (wxCoord
) ((y
- m_logicalOriginY
)*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
+ m_deviceOriginY
);
2508 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2510 // axis orientation is not taken into account for conversion of a distance
2511 return (wxCoord
) (y
*m_logicalScaleY
*m_userScaleY
*m_scaleY
);
2514 // ---------------------------------------------------------------------------
2516 // ---------------------------------------------------------------------------
2532 wxMask
* pMask
= NULL
;
2534 COLORREF vOldTextColor
;
2535 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
2539 const wxBitmap
& rBmp
= pSource
->m_vSelectedBitmap
;
2541 pMask
= rBmp
.GetMask();
2542 if (!(rBmp
.Ok() && pMask
&& pMask
->GetMaskBitmap()))
2548 ::GpiQueryAttrs( m_hPS
2553 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
2555 if (m_textForegroundColour
.Ok())
2557 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
2558 ::GpiSetAttrs( m_hPS
// presentation-space handle
2559 ,PRIM_CHAR
// Char primitive.
2560 ,CBB_COLOR
// sets color.
2562 ,&vCbnd
// buffer for attributes.
2565 if (m_textBackgroundColour
.Ok())
2567 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
2570 LONG lRop
= ROP_SRCCOPY
;
2574 case wxXOR
: lRop
= ROP_SRCINVERT
; break;
2575 case wxINVERT
: lRop
= ROP_DSTINVERT
; break;
2576 case wxOR_REVERSE
: lRop
= 0x00DD0228; break;
2577 case wxAND_REVERSE
: lRop
= ROP_SRCERASE
; break;
2578 case wxCLEAR
: lRop
= ROP_ZERO
; break;
2579 case wxSET
: lRop
= ROP_ONE
; break;
2580 case wxOR_INVERT
: lRop
= ROP_MERGEPAINT
; break;
2581 case wxAND
: lRop
= ROP_SRCAND
; break;
2582 case wxOR
: lRop
= ROP_SRCPAINT
; break;
2583 case wxEQUIV
: lRop
= 0x00990066; break;
2584 case wxNAND
: lRop
= 0x007700E6; break;
2585 case wxAND_INVERT
: lRop
= 0x00220326; break;
2586 case wxCOPY
: lRop
= ROP_SRCCOPY
; break;
2587 case wxNO_OP
: lRop
= ROP_NOTSRCERASE
; break;
2588 case wxSRC_INVERT
: lRop
= ROP_SRCINVERT
; break;
2589 case wxNOR
: lRop
= ROP_NOTSRCCOPY
; break;
2591 wxFAIL_MSG( wxT("unsupported logical function") );
2600 // Blit bitmap with mask
2604 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2610 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
2611 BITMAPINFOHEADER2 vBmpHdr
;
2613 SIZEL vSize
= {0, 0};
2616 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
2617 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
2618 vBmpHdr
.cx
= vWidth
;
2619 vBmpHdr
.cy
= vHeight
;
2620 vBmpHdr
.cPlanes
= 1;
2621 vBmpHdr
.cBitCount
= 24;
2623 #if wxUSE_DC_CACHEING
2627 // create a temp buffer bitmap and DCs to access it and the mask
2629 wxDCCacheEntry
* pDCCacheEntry1
= FindDCInCache( NULL
2632 wxDCCacheEntry
* pDCCacheEntry2
= FindDCInCache( pDCCacheEntry1
2635 wxDCCacheEntry
* pBitmapCacheEntry
= FindBitmapInCache( GetHPS()
2640 hPSMask
= pDCCacheEntry1
->m_hPS
;
2641 hDCBuffer
= (HDC
)pDCCacheEntry2
->m_hPS
;
2642 hBufBitmap
= (HBITMAP
)pBitmapCacheEntry
->m_hBitmap
;
2647 hDCMask
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2648 hDCBuffer
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2649 hPSMask
= ::GpiCreatePS(vHabmain
, hDCMask
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2650 hPSBuffer
= ::GpiCreatePS(vHabmain
, hDCBuffer
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2651 hBufBitmap
= ::GpiCreateBitmap(GetHPS(), &vBmpHdr
, 0L, NULL
, NULL
);
2654 POINTL aPoint1
[4] = { 0, 0
2657 ,vXdest
+ vWidth
, vYdest
+ vHeight
2659 POINTL aPoint2
[4] = { 0, 0
2662 ,vXsrc
+ vWidth
, vYsrc
+ vHeight
2664 POINTL aPoint3
[4] = { vXdest
, vYdest
2665 ,vXdest
+ vWidth
, vYdest
+ vHeight
2667 ,vXsrc
+ vWidth
, vYsrc
+ vHeight
2669 POINTL aPoint4
[4] = { vXdest
, vYdest
2670 ,vXdest
+ vWidth
, vYdest
+ vHeight
2674 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
2675 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
2678 // Copy dest to buffer
2680 rc
= ::GpiBitBlt( hPSBuffer
2687 if (rc
== GPI_ERROR
)
2689 wxLogLastError(wxT("BitBlt"));
2693 // Copy src to buffer using selected raster op
2695 rc
= ::GpiBitBlt( hPSBuffer
2702 if (rc
== GPI_ERROR
)
2704 wxLogLastError(wxT("BitBlt"));
2708 // Set masked area in buffer to BLACK (pixel value 0)
2710 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
2711 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
2713 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2714 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2716 rc
= ::GpiBitBlt( hPSBuffer
2723 if (rc
== GPI_ERROR
)
2725 wxLogLastError(wxT("BitBlt"));
2729 // Set unmasked area in dest to BLACK
2731 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2732 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2733 rc
= ::GpiBitBlt( GetHPS()
2740 if (rc
== GPI_ERROR
)
2742 wxLogLastError(wxT("BitBlt"));
2746 // Restore colours to original values
2748 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
2749 ::GpiSetColor(GetHPS(), vPrevCol
);
2752 // OR buffer to dest
2754 rc
= ::GpiBitBlt( GetHPS()
2761 if (rc
== GPI_ERROR
)
2764 wxLogLastError(wxT("BitBlt"));
2768 // Tidy up temporary DCs and bitmap
2770 ::GpiSetBitmap(hPSMask
, NULLHANDLE
);
2771 ::GpiSetBitmap(hPSBuffer
, NULLHANDLE
);
2772 #if !wxUSE_DC_CACHEING
2773 ::GpiDestroyPS(hPSMask
);
2774 ::GpiDestroyPS(hPSBuffer
);
2775 ::DevCloseDC(hDCMask
);
2776 ::DevCloseDC(hDCBuffer
);
2777 ::GpiDeleteBitmap(hBufBitmap
);
2781 else // no mask, just BitBlt() it
2783 POINTL aPoint
[4] = { vXdest
, vYdest
2784 ,vXdest
+ vWidth
, vYdest
+ vHeight
2786 ,vXsrc
+ vWidth
, vYsrc
+ vHeight
2789 bSuccess
= (::GpiBitBlt( m_hPS
2798 wxLogLastError(wxT("BitBlt"));
2801 vCbnd
.lColor
= (LONG
)vOldTextColor
;
2802 ::GpiSetAttrs( m_hPS
// presentation-space handle
2803 ,PRIM_CHAR
// Char primitive.
2804 ,CBB_COLOR
// sets color.
2806 ,&vCbnd
// buffer for attributes.
2808 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
2812 void wxDC::DoGetSize(
2817 LONG lArray
[CAPS_HEIGHT
];
2819 if(::DevQueryCaps( m_hDC
2825 *pnWidth
= lArray
[CAPS_WIDTH
];
2826 *pnHeight
= lArray
[CAPS_HEIGHT
];
2828 }; // end of wxDC::DoGetSize(
2830 void wxDC::DoGetSizeMM(
2835 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2837 if(::DevQueryCaps( m_hDC
2839 ,CAPS_VERTICAL_RESOLUTION
2848 nWidth
= lArray
[CAPS_WIDTH
];
2849 nHeight
= lArray
[CAPS_HEIGHT
];
2850 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2851 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2852 nWidth
= (nHorzRes
/1000) * nWidth
;
2853 nHeight
= (nVertRes
/1000) * nHeight
;
2855 }; // end of wxDC::DoGetSizeMM
2857 wxSize
wxDC::GetPPI() const
2859 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2863 if(::DevQueryCaps( m_hDC
2865 ,CAPS_VERTICAL_RESOLUTION
2874 nPelWidth
= lArray
[CAPS_WIDTH
];
2875 nPelHeight
= lArray
[CAPS_HEIGHT
];
2876 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2877 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2878 nWidth
= (nHorzRes
/39.3) * nPelWidth
;
2879 nHeight
= (nVertRes
/39.3) * nPelHeight
;
2881 return (wxSize(nWidth
,nHeight
));
2882 } // end of wxDC::GetPPI
2884 void wxDC::SetLogicalScale(
2889 m_logicalScaleX
= dX
;
2890 m_logicalScaleY
= dY
;
2891 }; // end of wxDC::SetLogicalScale
2893 #if WXWIN_COMPATIBILITY
2894 void wxDC::DoGetTextExtent(const wxString
& string
, float *x
, float *y
,
2895 float *descent
, float *externalLeading
,
2896 wxFont
*theFont
, bool use16bit
) const
2898 wxCoord x1
, y1
, descent1
, externalLeading1
;
2899 GetTextExtent(string
, & x1
, & y1
, & descent1
, & externalLeading1
, theFont
, use16bit
);
2902 *descent
= descent1
;
2903 if (externalLeading
)
2904 *externalLeading
= externalLeading1
;