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"
28 #include "wx/statusbr.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 // ---------------------------------------------------------------------------
362 m_bIsPaintTime
= FALSE
; // True at Paint Time
364 vColor
.InitFromName("BLACK");
365 m_pen
.SetColour(vColor
);
367 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
)
587 } // end of wxDC::DoFloodFill
589 bool wxDC::DoGetPixel(
599 vPoint
.y
= OS2Y(vY
,0);
600 lColor
= ::GpiSetPel(m_hPS
, &vPoint
);
603 // Get the color of the pen
605 LONG lPencolor
= 0x00ffffff;
609 lPencolor
= m_pen
.GetColour().GetPixel();
613 // return the color of the pixel
616 pCol
->Set( GetRValue(lColor
)
620 return(lColor
== lPencolor
);
621 } // end of wxDC::DoGetPixel
623 void wxDC::DoCrossHair(
630 wxCoord vX1
= vX
- VIEWPORT_EXTENT
;
631 wxCoord vY1
= vY
- VIEWPORT_EXTENT
;
632 wxCoord vX2
= vX
+ VIEWPORT_EXTENT
;
633 wxCoord vY2
= vY
+ VIEWPORT_EXTENT
;
642 ::GpiMove(m_hPS
, &vPoint
[0]);
643 ::GpiLine(m_hPS
, &vPoint
[1]);
651 ::GpiMove(m_hPS
, &vPoint
[2]);
652 ::GpiLine(m_hPS
, &vPoint
[3]);
653 CalcBoundingBox(vX1
, vY1
);
654 CalcBoundingBox(vX2
, vY2
);
655 } // end of wxDC::DoCrossHair
657 void wxDC::DoDrawLine(
665 COLORREF vColor
= 0x00ffffff;
668 // Might be a memory DC with no Paint rect.
670 if (!(m_vRclPaint
.yTop
== 0 &&
671 m_vRclPaint
.yBottom
== 0 &&
672 m_vRclPaint
.xRight
== 0 &&
673 m_vRclPaint
.xLeft
== 0))
680 if (m_vSelectedBitmap
!= wxNullBitmap
)
682 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
683 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
694 vColor
= m_pen
.GetColour().GetPixel();
696 ::GpiSetColor(m_hPS
, vColor
);
697 ::GpiMove(m_hPS
, &vPoint
[0]);
698 ::GpiLine(m_hPS
, &vPoint
[1]);
699 CalcBoundingBox(vX1
, vY1
);
700 CalcBoundingBox(vX2
, vY2
);
701 } // end of wxDC::DoDrawLine
703 //////////////////////////////////////////////////////////////////////////////
704 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
705 // and ending at (x2, y2). The current pen is used for the outline and the
706 // current brush for filling the shape. The arc is drawn in an anticlockwise
707 // direction from the start point to the end point.
708 //////////////////////////////////////////////////////////////////////////////
709 void wxDC::DoDrawArc(
719 POINTL vPtlArc
[2]; // Structure for current position
728 ARCPARAMS vArcp
; // Structure for arc parameters
730 if((vX1
== vXc
&& vY1
== vXc
) || (vX2
== vXc
&& vY2
== vXc
))
731 return; // Draw point ??
732 dRadius
= 0.5 * ( hypot( (double)(vY1
- vYc
)
735 hypot( (double)(vY2
- vYc
)
740 dAngl1
= atan2( (double)(vY1
- vYc
)
743 dAngl2
= atan2( (double)(vY2
- vYc
)
750 // GpiPointArc can't draw full arc
752 if(dAngl2
== dAngl1
|| (vX1
== vX2
&& vY1
== vY2
) )
757 dAnglmid
= (dAngl1
+ dAngl2
)/2. + M_PI
;
758 vXm
= vXc
+ dRadius
* cos(dAnglmid
);
759 vYm
= vYc
+ dRadius
* sin(dAnglmid
);
774 dAnglmid
= (dAngl1
+ dAngl2
)/2.;
775 vXm
= vXc
+ dRadius
* cos(dAnglmid
);
776 vYm
= vYc
+ dRadius
* sin(dAnglmid
);
779 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
785 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
787 vPtlPos
.x
= vX1
; // Loads x-coordinate
788 vPtlPos
.y
= vY1
; // Loads y-coordinate
789 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
794 ::GpiPointArc(m_hPS
, vPtlArc
); // Draws the arc
795 CalcBoundingBox( (vXc
- dRadius
)
798 CalcBoundingBox( (vXc
+ dRadius
)
801 } // end of wxDC::DoDrawArc
803 void wxDC::DoDrawCheckMark(
812 vY1
= OS2Y(vY1
,vHeight
);
816 vPoint
[1].x
= vX1
+ vWidth
;
817 vPoint
[1].y
= vY1
+ vHeight
;
819 ::GpiMove(m_hPS
, &vPoint
[0]);
820 ::GpiBox( m_hPS
// handle to a presentation space
821 ,DRO_OUTLINE
// draw the box outline ? or ?
822 ,&vPoint
[1] // address of the corner
823 ,0L // horizontal corner radius
824 ,0L // vertical corner radius
826 if(vWidth
> 4 && vHeight
> 4)
830 vPoint
[0].x
+= 2; vPoint
[0].y
+= 2;
831 vPoint
[1].x
-= 2; vPoint
[1].y
-= 2;
832 ::GpiMove(m_hPS
, &vPoint
[0]);
833 ::GpiLine(m_hPS
, &vPoint
[1]);
835 vPoint
[0].x
= vPoint
[1].x
;
837 ::GpiMove(m_hPS
, &vPoint
[0]);
838 ::GpiLine(m_hPS
, &vPoint
[1]);
844 wxCoord vX2
= vX1
+ vWidth
;
845 wxCoord vY2
= vY1
+ vHeight
;
850 } // end of wxDC::DoDrawCheckMark
852 void wxDC::DoDrawPoint(
858 COLORREF vColor
= 0x00ffffff;
862 vColor
= m_pen
.GetColour().GetPixel();
864 ::GpiSetColor(m_hPS
, vColor
);
866 vPoint
.y
= OS2Y(vY
,0);
867 ::GpiSetPel(m_hPS
, &vPoint
);
871 } // end of wxDC::DoDrawPoint
873 void wxDC::DoDrawPolygon(
881 ULONG ulCount
= 1; // Number of polygons.
882 POLYGON vPlgn
; // polygon.
883 ULONG flOptions
= 0L; // Drawing options.
885 //////////////////////////////////////////////////////////////////////////////
886 // This contains fields of option bits... to draw boundary lines as well as
887 // the area interior.
889 // Drawing boundary lines:
890 // POLYGON_NOBOUNDARY Does not draw boundary lines.
891 // POLYGON_BOUNDARY Draws boundary lines (the default).
893 // Construction of the area interior:
894 // POLYGON_ALTERNATE Constructs interior in alternate mode
896 // POLYGON_WINDING Constructs interior in winding mode.
897 //////////////////////////////////////////////////////////////////////////////
899 ULONG flModel
= 0L; // Drawing model.
901 //////////////////////////////////////////////////////////////////////////////
903 // POLYGON_INCL Fill is inclusive of bottom right (the default).
904 // POLYGON_EXCL Fill is exclusive of bottom right.
905 // This is provided to aid migration from other graphics models.
906 //////////////////////////////////////////////////////////////////////////////
908 LONG lHits
= 0L; // Correlation/error indicator.
911 int nIsTRANSPARENT
= 0;
912 LONG lBorderColor
= 0L;
915 lBorderColor
= m_pen
.GetColour().GetPixel();
916 lColor
= m_brush
.GetColour().GetPixel();
917 if(m_brush
.GetStyle() == wxTRANSPARENT
)
921 vPlgn
.aPointl
= (POINTL
*) calloc( n
+ 1
923 ); // well, new will call malloc
925 for(i
= 0; i
< n
; i
++)
927 vPlgn
.aPointl
[i
].x
= vPoints
[i
].x
; // +xoffset;
928 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
,0); // +yoffset;
930 flModel
= POLYGON_BOUNDARY
;
931 if(nFillStyle
== wxWINDING_RULE
)
932 flModel
|= POLYGON_WINDING
;
934 flModel
|= POLYGON_ALTERNATE
;
937 vPoint
.y
= OS2Y(vYoffset
,0);
939 ::GpiSetColor(m_hPS
, lBorderColor
);
940 ::GpiMove(m_hPS
, &vPoint
);
941 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
943 } // end of wxDC::DoDrawPolygon
945 void wxDC::DoDrawLines(
954 if (vXoffset
!= 0L || vXoffset
!= 0L)
958 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
959 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
960 ::GpiMove(m_hPS
, &vPoint
);
962 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
964 ::GpiSetColor(m_hPS
, lBorderColor
);
965 for(i
= 1; i
< n
; i
++)
967 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
968 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
969 ::GpiLine(m_hPS
, &vPoint
);
976 CalcBoundingBox( vPoints
[i
].x
979 vPoint
.x
= vPoints
[0].x
;
980 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
981 ::GpiMove(m_hPS
, &vPoint
);
983 for (i
= 0; i
< n
; i
++)
985 CalcBoundingBox( vPoints
[i
].x
988 vPoint
.x
= vPoints
[i
].x
;
989 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
990 ::GpiLine(m_hPS
, &vPoint
);
993 } // end of wxDC::DoDrawLines
995 void wxDC::DoDrawRectangle(
1006 int nIsTRANSPARENT
= 0;
1009 // Might be a memory DC with no Paint rect.
1011 if (!(m_vRclPaint
.yTop
== 0 &&
1012 m_vRclPaint
.yBottom
== 0 &&
1013 m_vRclPaint
.xRight
== 0 &&
1014 m_vRclPaint
.xLeft
== 0))
1015 vY
= OS2Y(vY
,vHeight
);
1018 if (m_vSelectedBitmap
!= wxNullBitmap
)
1020 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1021 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1022 vY
= OS2Y(vY
,vHeight
);
1026 wxCoord vX2
= vX
+ vWidth
;
1027 wxCoord vY2
= vY
+ vHeight
;
1031 vPoint
[1].x
= vX
+ vWidth
- 1;
1032 vPoint
[1].y
= vY
+ vHeight
- 1;
1033 ::GpiMove(m_hPS
, &vPoint
[0]);
1034 lColor
= m_brush
.GetColour().GetPixel();
1035 lBorderColor
= m_pen
.GetColour().GetPixel();
1036 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1038 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1040 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1041 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1042 lControl
= DRO_OUTLINE
;
1044 ::GpiSetColor(m_hPS
, lBorderColor
);
1045 ::GpiBox( m_hPS
// handle to a presentation space
1046 ,lControl
// draw the box outline ? or ?
1047 ,&vPoint
[1] // address of the corner
1048 ,0L // horizontal corner radius
1049 ,0L // vertical corner radius
1054 lControl
= DRO_OUTLINE
;
1055 ::GpiSetColor( m_hPS
1064 lControl
= DRO_FILL
;
1065 ::GpiSetColor( m_hPS
1068 vPoint
[0].x
= vX
+ 1;
1069 vPoint
[0].y
= vY
+ 1;
1070 vPoint
[1].x
= vX
+ vWidth
- 2;
1071 vPoint
[1].y
= vY
+ vHeight
- 2;
1072 ::GpiMove(m_hPS
, &vPoint
[0]);
1080 CalcBoundingBox(vX
, vY
);
1081 CalcBoundingBox(vX2
, vY2
);
1082 } // end of wxDC::DoDrawRectangle
1084 void wxDC::DoDrawRoundedRectangle(
1096 int nIsTRANSPARENT
= 0;
1099 // Might be a memory DC with no Paint rect.
1101 if (!(m_vRclPaint
.yTop
== 0 &&
1102 m_vRclPaint
.yBottom
== 0 &&
1103 m_vRclPaint
.xRight
== 0 &&
1104 m_vRclPaint
.xLeft
== 0))
1105 vY
= OS2Y(vY
,vHeight
);
1108 if (m_vSelectedBitmap
!= wxNullBitmap
)
1110 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1111 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1112 vY
= OS2Y(vY
,vHeight
);
1116 wxCoord vX2
= (vX
+ vWidth
);
1117 wxCoord vY2
= (vY
+ vHeight
);
1121 vPoint
[1].x
= vX
+ vWidth
- 1;
1122 vPoint
[1].y
= vY
+ vHeight
- 1;
1123 ::GpiMove(m_hPS
, &vPoint
[0]);
1125 lColor
= m_brush
.GetColour().GetPixel();
1126 lBorderColor
= m_pen
.GetColour().GetPixel();
1127 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1128 if (m_brush
.GetStyle() == wxTRANSPARENT
)
1130 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
1132 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
1133 if(m_brush
.GetStyle() == wxTRANSPARENT
)
1134 lControl
= DRO_OUTLINE
;
1136 ::GpiSetColor(m_hPS
, lColor
);
1137 ::GpiBox( m_hPS
// handle to a presentation space
1138 ,lControl
// draw the box outline ? or ?
1139 ,&vPoint
[1] // address of the corner
1140 ,(LONG
)dRadius
// horizontal corner radius
1141 ,(LONG
)dRadius
// vertical corner radius
1146 lControl
= DRO_OUTLINE
;
1147 ::GpiSetColor( m_hPS
1156 lControl
= DRO_FILL
;
1157 ::GpiSetColor( m_hPS
1160 vPoint
[0].x
= vX
+ 1;
1161 vPoint
[0].y
= vY
+ 1;
1162 vPoint
[1].x
= vX
+ vWidth
- 2;
1163 vPoint
[1].y
= vY
+ vHeight
- 2;
1164 ::GpiMove(m_hPS
, &vPoint
[0]);
1173 CalcBoundingBox(vX
, vY
);
1174 CalcBoundingBox(vX2
, vY2
);
1175 } // end of wxDC::DoDrawRoundedRectangle
1177 // Draw Ellipse within box (x,y) - (x+width, y+height)
1178 void wxDC::DoDrawEllipse(
1185 POINTL vPtlPos
; // Structure for current position
1186 FIXED vFxMult
; // Multiplier for ellipse
1187 ARCPARAMS vArcp
; // Structure for arc parameters
1189 vY
= OS2Y(vY
,vHeight
);
1192 vArcp
.lQ
= vHeight
/2;
1193 vArcp
.lP
= vWidth
/2;
1195 ::GpiSetArcParams( m_hPS
1197 ); // Sets parameters to default
1198 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
1199 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1202 ); // Sets current position
1203 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
1206 // DRO_FILL, DRO_OTLINEFILL - where to get
1211 ); // Draws full arc with center at current position
1213 wxCoord vX2
= (vX
+ vWidth
);
1214 wxCoord vY2
= (vY
+ vHeight
);
1216 CalcBoundingBox(vX
, vY
);
1217 CalcBoundingBox(vX2
, vY2
);
1218 } // end of wxDC::DoDrawEllipse
1220 void wxDC::DoDrawEllipticArc(
1229 POINTL vPtlPos
; // Structure for current position
1230 FIXED vFxMult
; // Multiplier for ellipse
1231 ARCPARAMS vArcp
; // Structure for arc parameters
1233 FIXED vFSweepa
; // Start angle, sweep angle
1238 vY
= OS2Y(vY
,vHeight
);
1240 dFractPart
= modf(dSa
,&dIntPart
);
1241 vFSa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1242 dFractPart
= modf(dEa
- dSa
, &dIntPart
);
1243 vFSweepa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
1246 // Ellipse main axis (r,q), (p,s) with center at (0,0)
1249 vArcp
.lQ
= vHeight
/2;
1250 vArcp
.lP
= vWidth
/2;
1252 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
1253 vPtlPos
.x
= vX
+ vWidth
/2 * (1. + cos(DegToRad(dSa
))); // Loads x-coordinate
1254 vPtlPos
.y
= vY
+ vHeight
/2 * (1. + sin(DegToRad(dSa
))); // Loads y-coordinate
1255 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
1258 // May be not to the center ?
1260 vPtlPos
.x
= vX
+ vWidth
/2 ; // Loads x-coordinate
1261 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
1262 vFxMult
= MAKEFIXED(1, 0); // Sets multiplier
1265 // DRO_FILL, DRO_OTLINEFILL - where to get
1267 ::GpiPartialArc( m_hPS
1273 wxCoord vX2
= (vX
+ vWidth
);
1274 wxCoord vY2
= (vY
+ vHeight
);
1276 CalcBoundingBox(vX
, vY
);
1277 CalcBoundingBox(vX2
, vY2
);
1278 } // end of wxDC::DoDrawEllipticArc
1280 void wxDC::DoDrawIcon(
1287 // Need to copy back into a bitmap. ::WinDrawPointer uses device coords
1288 // and I don't feel like figuring those out for scrollable windows so
1289 // just convert to a bitmap then let the DoDrawBitmap routing display it
1293 DoDrawBitmap(rIcon
.GetXpmSrc(), vX
, vY
, TRUE
);
1297 wxBitmap
vBitmap(rIcon
);
1299 DoDrawBitmap(vBitmap
, vX
, vY
, FALSE
);
1301 CalcBoundingBox(vX
, vY
);
1302 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
1303 } // end of wxDC::DoDrawIcon
1305 void wxDC::DoDrawBitmap(
1306 const wxBitmap
& rBmp
1312 if (!IsKindOf(CLASSINFO(wxPrinterDC
)))
1314 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
1318 vY
= OS2Y(vY
,rBmp
.GetHeight());
1321 vPoint
[0].y
= vY
+ rBmp
.GetHeight();
1322 vPoint
[1].x
= vX
+ rBmp
.GetWidth();
1326 vPoint
[3].x
= rBmp
.GetWidth();
1327 vPoint
[3].y
= rBmp
.GetHeight();
1330 wxMask
* pMask
= rBmp
.GetMask();
1335 // Need to imitate ::MaskBlt in windows.
1336 // 1) Extract the bits from from the bitmap.
1337 // 2) Extract the bits from the mask
1338 // 3) Using the mask bits do the following:
1339 // A) If the mask byte is 00 leave the bitmap byte alone
1340 // B) If the mask byte is FF copy the screen color into
1342 // 4) Create a new bitmap and set its bits to the above result
1343 // 5) Blit this to the screen PS
1345 HBITMAP hMask
= (HBITMAP
)pMask
->GetMaskBitmap();
1346 HBITMAP hOldMask
= NULLHANDLE
;
1347 HBITMAP hOldBitmap
= NULLHANDLE
;
1348 HBITMAP hNewBitmap
= NULLHANDLE
;
1349 unsigned char* pucBits
; // buffer that will contain the bitmap data
1350 unsigned char* pucBitsMask
; // buffer that will contain the mask data
1351 unsigned char* pucData
; // pointer to use to traverse bitmap data
1352 unsigned char* pucDataMask
; // pointer to use to traverse mask data
1358 // The usual Memory context creation stuff
1360 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1361 SIZEL vSize
= {0, 0};
1362 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1363 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1366 // The usual bitmap header stuff
1368 BITMAPINFOHEADER2 vHeader
;
1371 memset(&vHeader
, '\0', 16);
1374 memset(&vInfo
, '\0', 16);
1376 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1377 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1379 vInfo
.cBitCount
= 24; // Set to desired count going in
1382 // Create the buffers for data....all wxBitmaps are 24 bit internally
1384 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1385 int nSizeDWORD
= sizeof(DWORD
);
1386 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
1394 // Need to get a background color for mask blitting
1396 if (IsKindOf(CLASSINFO(wxWindowDC
)))
1398 wxWindowDC
* pWindowDC
= wxDynamicCast(this, wxWindowDC
);
1400 lColor
= pWindowDC
->m_pCanvas
->GetBackgroundColour().GetPixel();
1402 else if (GetBrush() != wxNullBrush
)
1403 lColor
= GetBrush().GetColour().GetPixel();
1405 lColor
= m_textBackgroundColour
.GetPixel();
1408 // Bitmap must be ina double-word alligned address so we may
1409 // have some padding to worry about
1411 if (nLineBoundary
> 0)
1413 nPadding
= nSizeDWORD
- nLineBoundary
;
1414 nBytesPerLine
+= nPadding
;
1416 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1417 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
1418 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1419 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1422 // Extract the bitmap and mask data
1424 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1426 vError
= ::WinGetLastError(vHabmain
);
1427 sError
= wxPMErrorToStr(vError
);
1429 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
1430 vInfo
.cBitCount
= 24;
1431 if ((lScans
= ::GpiQueryBitmapBits( hPS
1433 ,(LONG
)rBmp
.GetHeight()
1438 vError
= ::WinGetLastError(vHabmain
);
1439 sError
= wxPMErrorToStr(vError
);
1441 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
1443 vError
= ::WinGetLastError(vHabmain
);
1444 sError
= wxPMErrorToStr(vError
);
1446 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
1447 vInfo
.cBitCount
= 24;
1448 if ((lScans
= ::GpiQueryBitmapBits( hPS
1450 ,(LONG
)rBmp
.GetHeight()
1455 vError
= ::WinGetLastError(vHabmain
);
1456 sError
= wxPMErrorToStr(vError
);
1458 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
1460 vError
= ::WinGetLastError(vHabmain
);
1461 sError
= wxPMErrorToStr(vError
);
1465 // Now set the bytes(bits) according to the mask values
1466 // 3 bytes per pel...must handle one at a time
1469 pucDataMask
= pucBitsMask
;
1472 // 16 bit kludge really only kinda works. The mask gets applied
1473 // where needed but the original bitmap bits are dorked sometimes
1475 bool bpp16
= (wxDisplayDepth() == 16);
1477 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1479 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1482 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1484 else if (*pucDataMask
== 0xFF) // leave bitmap byte alone
1488 *pucData
= ((unsigned char)(lColor
>> 16));
1492 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1494 else if (*(pucDataMask
+ 1) == 0xFF) // leave bitmap byte alone
1498 *pucData
= ((unsigned char)(lColor
>> 8));
1503 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1505 else if (*(pucDataMask
+ 2) == 0xFF) // leave bitmap byte alone
1509 *pucData
= ((unsigned char)lColor
);
1514 for (j
= 0; j
< nPadding
; j
++)
1521 // Create a new bitmap
1523 vHeader
.cx
= (ULONG
)rBmp
.GetWidth();
1524 vHeader
.cy
= (ULONG
)rBmp
.GetHeight();
1525 vHeader
.cPlanes
= 1L;
1526 vHeader
.cBitCount
= 24;
1527 if ((hNewBitmap
= ::GpiCreateBitmap( hPS
1534 vError
= ::WinGetLastError(vHabmain
);
1535 sError
= wxPMErrorToStr(vError
);
1539 // Now blit it to the screen PS
1541 if ((lHits
= ::GpiWCBitBlt( (HPS
)GetHPS()
1549 vError
= ::WinGetLastError(vHabmain
);
1550 sError
= wxPMErrorToStr(vError
);
1558 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1559 ::GpiDeleteBitmap(hNewBitmap
);
1560 ::GpiDestroyPS(hPS
);
1566 LONG lOldForeGround
= ::GpiQueryColor((HPS
)GetHPS());
1567 LONG lOldBackGround
= ::GpiQueryBackColor((HPS
)GetHPS());
1569 if (m_textForegroundColour
.Ok())
1571 ::GpiSetColor( (HPS
)GetHPS()
1572 ,m_textForegroundColour
.GetPixel()
1575 if (m_textBackgroundColour
.Ok())
1577 ::GpiSetBackColor( (HPS
)GetHPS()
1578 ,m_textBackgroundColour
.GetPixel()
1582 // Need to alter bits in a mono bitmap to match the new
1583 // background-foreground if it is different.
1585 if (rBmp
.IsMono() &&
1586 ((m_textForegroundColour
.GetPixel() != lOldForeGround
) ||
1587 (m_textBackgroundColour
.GetPixel() != lOldBackGround
)))
1589 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1590 SIZEL vSize
= {0, 0};
1591 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
1592 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
1594 int nBytesPerLine
= rBmp
.GetWidth() * 3;
1596 LONG lForeGround
= m_textForegroundColour
.GetPixel();
1597 LONG lBackGround
= m_textBackgroundColour
.GetPixel();
1599 HBITMAP hOldBitmap
= NULLHANDLE
;
1605 memset(&vInfo
, '\0', 16);
1607 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
1608 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
1610 vInfo
.cBitCount
= 24;
1612 unsigned char* pucBits
; // buffer that will contain the bitmap data
1613 unsigned char* pucData
; // pointer to use to traverse bitmap data
1615 pucBits
= new unsigned char[nBytesPerLine
* rBmp
.GetHeight()];
1616 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
1618 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
1620 vError
= ::WinGetLastError(vHabmain
);
1621 sError
= wxPMErrorToStr(vError
);
1624 if ((lScans
= ::GpiQueryBitmapBits( hPS
1626 ,(LONG
)rBmp
.GetHeight()
1631 vError
= ::WinGetLastError(vHabmain
);
1632 sError
= wxPMErrorToStr(vError
);
1635 unsigned char cOldRedFore
= (unsigned char)(lOldForeGround
>> 16);
1636 unsigned char cOldGreenFore
= (unsigned char)(lOldForeGround
>> 8);
1637 unsigned char cOldBlueFore
= (unsigned char)lOldForeGround
;
1639 unsigned char cOldRedBack
= (unsigned char)(lOldBackGround
>> 16);
1640 unsigned char cOldGreenBack
= (unsigned char)(lOldBackGround
>> 8);
1641 unsigned char cOldBlueBack
= (unsigned char)lOldBackGround
;
1643 unsigned char cRedFore
= (unsigned char)(lForeGround
>> 16);
1644 unsigned char cGreenFore
= (unsigned char)(lForeGround
>> 8);
1645 unsigned char cBlueFore
= (unsigned char)lForeGround
;
1647 unsigned char cRedBack
= (unsigned char)(lBackGround
>> 16);
1648 unsigned char cGreenBack
= (unsigned char)(lBackGround
>> 8);
1649 unsigned char cBlueBack
= (unsigned char)lBackGround
;
1652 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1654 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1656 unsigned char cBmpRed
= *pucData
;
1657 unsigned char cBmpGreen
= *(pucData
+ 1);
1658 unsigned char cBmpBlue
= *(pucData
+ 2);
1660 if ((cBmpRed
== cOldRedFore
) &&
1661 (cBmpGreen
== cOldGreenFore
) &&
1662 (cBmpBlue
== cOldBlueFore
))
1664 *pucData
= cBlueFore
;
1666 *pucData
= cGreenFore
;
1668 *pucData
= cRedFore
;
1673 *pucData
= cBlueBack
;
1675 *pucData
= cGreenBack
;
1677 *pucData
= cRedBack
;
1682 if ((lScans
= ::GpiSetBitmapBits( hPS
1684 ,(LONG
)rBmp
.GetHeight()
1689 vError
= ::WinGetLastError(vHabmain
);
1690 sError
= wxPMErrorToStr(vError
);
1694 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1695 ::GpiDestroyPS(hPS
);
1698 ::GpiWCBitBlt( (HPS
)GetHPS()
1705 ::GpiSetBitmap((HPS
)GetHPS(), hBitmapOld
);
1706 ::GpiSetColor((HPS
)GetHPS(), lOldForeGround
);
1707 ::GpiSetBackColor((HPS
)GetHPS(), lOldBackGround
);
1710 } // end of wxDC::DoDrawBitmap
1712 void wxDC::DoDrawText(
1713 const wxString
& rsText
1726 CalcBoundingBox(vX
, vY
);
1727 GetTextExtent(rsText
, &vWidth
, &vHeight
);
1728 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1729 } // end of wxDC::DoDrawText
1731 void wxDC::DrawAnyText(
1732 const wxString
& rsText
1737 int nOldBackground
= 0;
1744 // prepare for drawing the text
1748 // Set text color attributes
1750 if (m_textForegroundColour
.Ok())
1753 ,(int)m_textForegroundColour
.GetPixel()
1757 if (m_textBackgroundColour
.Ok())
1759 nOldBackground
= SetTextBkColor( m_hPS
1760 ,(int)m_textBackgroundColour
.GetPixel()
1766 GetTextExtent( rsText
1771 if (!(m_vRclPaint
.yTop
== 0 &&
1772 m_vRclPaint
.yBottom
== 0 &&
1773 m_vRclPaint
.xRight
== 0 &&
1774 m_vRclPaint
.xLeft
== 0))
1777 // Position Text a little differently in the Statusbar from other panels
1779 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1780 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1782 vPtlStart
.y
= OS2Y(vY
,vTextY
/1.5); // Full extent is a bit much
1786 if (m_vSelectedBitmap
!= wxNullBitmap
)
1788 m_vRclPaint
.yTop
= m_vSelectedBitmap
.GetHeight();
1789 m_vRclPaint
.xRight
= m_vSelectedBitmap
.GetWidth();
1790 if (m_pCanvas
&& m_pCanvas
->IsKindOf(CLASSINFO(wxStatusBar
)))
1791 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1793 vPtlStart
.y
= OS2Y(vY
,vTextY
/1.5);
1799 PCH pzStr
= (PCH
)rsText
.c_str();
1801 ::GpiMove(m_hPS
, &vPtlStart
);
1802 lHits
= ::GpiCharString( m_hPS
1806 if (lHits
!= GPI_OK
)
1808 wxLogLastError(wxT("TextOut"));
1812 // Restore the old parameters (text foreground colour may be left because
1813 // it never is set to anything else, but background should remain
1814 // transparent even if we just drew an opaque string)
1816 if (m_textBackgroundColour
.Ok())
1817 SetTextBkColor( m_hPS
1825 void wxDC::DoDrawRotatedText(
1826 const wxString
& rsText
1844 DoDrawText(text, x, y);
1849 wxFillLogFont(&lf, &m_font);
1851 // GDI wants the angle in tenth of degree
1852 long angle10 = (long)(angle * 10);
1853 lf.lfEscapement = angle10;
1854 lf. lfOrientation = angle10;
1856 HFONT hfont = ::CreateFontIndirect(&lf);
1859 wxLogLastError("CreateFont");
1863 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1865 DrawAnyText(text, x, y);
1867 (void)::SelectObject(GetHdc(), hfontOld);
1870 // call the bounding box by adding all four vertices of the rectangle
1871 // containing the text to it (simpler and probably not slower than
1872 // determining which of them is really topmost/leftmost/...)
1874 GetTextExtent(text, &w, &h);
1876 double rad = DegToRad(angle);
1878 // "upper left" and "upper right"
1879 CalcBoundingBox(x, y);
1880 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1881 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1883 // "bottom left" and "bottom right"
1884 x += (wxCoord)(h*sin(rad));
1885 y += (wxCoord)(h*cos(rad));
1886 CalcBoundingBox(x, y);
1887 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1892 // ---------------------------------------------------------------------------
1894 // ---------------------------------------------------------------------------
1896 void wxDC::DoSelectPalette(
1901 // Set the old object temporarily, in case the assignment deletes an object
1902 // that's not yet selected out.
1913 hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1915 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1917 } // end of wxDC::DoSelectPalette
1919 void wxDC::InitializePalette()
1921 if (wxDisplayDepth() <= 8 )
1924 // Look for any window or parent that has a custom palette. If any has
1925 // one then we need to use it in drawing operations
1927 wxWindow
* pWin
= m_pCanvas
->GetAncestorWithCustomPalette();
1929 m_hasCustomPalette
= pWin
&& pWin
->HasCustomPalette();
1930 if (m_hasCustomPalette
)
1932 m_palette
= pWin
->GetPalette();
1935 // turn on PM translation for this palette
1940 } // end of wxDC::InitializePalette
1942 void wxDC::SetPalette(
1943 const wxPalette
& rPalette
1950 m_palette
= rPalette
;
1958 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1960 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1961 } // end of wxDC::SetPalette
1968 // Set the old object temporarily, in case the assignment deletes an object
1969 // that's not yet selected out.
1981 m_font
.SetPS(m_hPS
); // this will realize the font
1985 HFONT hFont
= m_font
.GetResourceHandle();
1986 if (hFont
== (HFONT
) NULL
)
1988 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
1991 m_hOldFont
= (WXHFONT
) hFont
;
1993 } // end of wxDC::SetFont
1999 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2015 m_pen
.SetPS((HPS
)m_hOldPen
);
2022 if (m_pen
.GetResourceHandle())
2026 m_hOldPen
= m_pen
.GetPS();
2028 ::GpiSetColor(m_hPS
, m_pen
.GetColour().GetPixel());
2032 void wxDC::SetBrush(
2033 const wxBrush
& rBrush
2036 wxCHECK_RET( Ok(), wxT("invalid window dc") );
2042 if (m_brush
== rBrush
)
2052 m_brush
.SetPS((HPS
)m_hOldBrush
);
2059 if (m_brush
.GetResourceHandle())
2061 m_brush
.SetPS(m_hPS
);
2063 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
2066 } // end of wxDC::SetBrush
2068 void wxDC::SetBackground(
2069 const wxBrush
& rBrush
2072 m_backgroundBrush
= rBrush
;
2073 if (!m_backgroundBrush
.Ok())
2077 bool bCustomColours
= TRUE
;
2080 // If we haven't specified wxUSER_COLOURS, don't allow the panel/dialog box to
2081 // change background colours from the control-panel specified colours.
2083 if (m_pCanvas
->IsKindOf(CLASSINFO(wxWindow
)) &&
2084 ((m_pCanvas
->GetWindowStyleFlag() & wxUSER_COLOURS
) != wxUSER_COLOURS
))
2085 bCustomColours
= FALSE
;
2088 if (m_backgroundBrush
.GetStyle()==wxTRANSPARENT
)
2090 m_pCanvas
->SetTransparent(TRUE
);
2095 // Setting the background brush of a DC
2096 // doesn't affect the window background colour. However,
2097 // I'm leaving in the transparency setting because it's needed by
2098 // various controls (e.g. wxStaticText) to determine whether to draw
2099 // transparently or not. TODO: maybe this should be a new function
2100 // wxWindow::SetTransparency(). Should that apply to the child itself, or the
2102 // m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
2104 m_pCanvas
->SetTransparent(FALSE
);
2108 COLORREF vNewColor
= m_backgroundBrush
.GetColour().GetPixel();
2109 (void)::GpiSetBackColor((HPS
)m_hPS
, (LONG
)vNewColor
);
2110 } // end of wxDC::SetBackground
2112 void wxDC::SetBackgroundMode(
2116 m_backgroundMode
= nMode
;
2117 } // end of wxDC::SetBackgroundMode
2119 void wxDC::SetLogicalFunction(
2123 m_logicalFunction
= nFunction
;
2124 SetRop((WXHDC
)m_hDC
);
2125 } // wxDC::SetLogicalFunction
2131 if (!hDC
|| m_logicalFunction
< 0)
2135 switch (m_logicalFunction
)
2146 lCRop
= FM_MERGESRCNOT
;
2150 lCRop
= FM_NOTMASKSRC
;
2162 lCRop
= FM_MERGENOTSRC
;
2166 lCRop
= FM_MERGESRCNOT
;
2178 lCRop
= FM_SUBTRACT
;
2185 lCRop
= FM_OVERPAINT
;
2188 ::GpiSetMix((HPS
)hDC
, lCRop
);
2189 } // end of wxDC::SetRop
2191 bool wxDC::StartDoc(
2192 const wxString
& rsMessage
2195 // We might be previewing, so return TRUE to let it continue.
2197 } // end of wxDC::StartDoc
2201 } // end of wxDC::EndDoc
2203 void wxDC::StartPage()
2205 } // end of wxDC::StartPage
2207 void wxDC::EndPage()
2209 } // end of wxDC::EndPage
2211 // ---------------------------------------------------------------------------
2213 // ---------------------------------------------------------------------------
2215 wxCoord
wxDC::GetCharHeight() const
2217 FONTMETRICS vFM
; // metrics structure
2219 ::GpiQueryFontMetrics( m_hPS
2220 ,sizeof(FONTMETRICS
)
2223 return YDEV2LOGREL(vFM
.lXHeight
);
2226 wxCoord
wxDC::GetCharWidth() const
2228 FONTMETRICS vFM
; // metrics structure
2230 ::GpiQueryFontMetrics( m_hPS
2231 ,sizeof(FONTMETRICS
)
2234 return XDEV2LOGREL(vFM
.lAveCharWidth
);
2237 void wxDC::DoGetTextExtent(
2238 const wxString
& rsString
2241 , wxCoord
* pvDescent
2242 , wxCoord
* pvExternalLeading
2246 POINTL avPoint
[TXTBOX_COUNT
];
2251 FONTMETRICS vFM
; // metrics structure
2254 ERRORID vErrorCode
; // last error id code
2255 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
2257 char zMsg
[128]; // DEBUG
2261 pFontToUse
= (wxFont
*)&m_font
;
2262 l
= rsString
.length();
2263 pStr
= (PCH
) rsString
.c_str();
2266 // In world coordinates.
2268 bRc
= ::GpiQueryTextBox( m_hPS
2271 ,TXTBOX_COUNT
// return maximum information
2272 ,avPoint
// array of coordinates points
2276 vErrorCode
= ::WinGetLastError(wxGetInstance());
2277 sError
= wxPMErrorToStr(vErrorCode
);
2279 sprintf(zMsg
, "GpiQueryTextBox for %s: failed with Error: %x - %s", pStr
, vErrorCode
, sError
.c_str());
2280 (void)wxMessageBox( "wxWindows Menu sample"
2286 vPtMin
.x
= avPoint
[0].x
;
2287 vPtMax
.x
= avPoint
[0].x
;
2288 vPtMin
.y
= avPoint
[0].y
;
2289 vPtMax
.y
= avPoint
[0].y
;
2290 for (i
= 1; i
< 4; i
++)
2292 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
2293 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
2294 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
2295 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
2297 ::GpiQueryFontMetrics( m_hPS
2298 ,sizeof(FONTMETRICS
)
2303 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
2305 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
2307 *pvDescent
= vFM
.lMaxDescender
;
2308 if (pvExternalLeading
)
2309 *pvExternalLeading
= vFM
.lExternalLeading
;
2312 void wxDC::SetMapMode(
2316 int nPixelWidth
= 0;
2317 int nPixelHeight
= 0;
2320 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2322 m_mappingMode
= nMode
;
2324 if(::DevQueryCaps( m_hDC
2326 ,CAPS_VERTICAL_RESOLUTION
2333 nPixelWidth
= lArray
[CAPS_WIDTH
];
2334 nPixelHeight
= lArray
[CAPS_HEIGHT
];
2335 lHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2336 lVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2337 nMmWidth
= (lHorzRes
/1000) * nPixelWidth
;
2338 nMmWidth
= (lVertRes
/1000) * nPixelHeight
;
2340 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
2345 double dMm2pixelsX
= nPixelWidth
/nMmWidth
;
2346 double dMm2pixelsY
= nPixelHeight
/nMmHeight
;
2351 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
2352 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
2356 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
2357 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
2361 m_logicalScaleX
= dMm2pixelsX
;
2362 m_logicalScaleY
= dMm2pixelsY
;
2366 m_logicalScaleX
= (dMm2pixelsX
/10.0);
2367 m_logicalScaleY
= (dMm2pixelsY
/10.0);
2372 m_logicalScaleX
= 1.0;
2373 m_logicalScaleY
= 1.0;
2379 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
2380 if (!ulOptions
& PU_ARBITRARY
)
2382 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
2383 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
2385 m_nWindowExtX
= (int)MS_XDEV2LOG(VIEWPORT_EXTENT
);
2386 m_nWindowExtY
= (int)MS_YDEV2LOG(VIEWPORT_EXTENT
);
2388 }; // end of wxDC::SetMapMode
2390 void wxDC::SetUserScale(
2398 SetMapMode(m_mappingMode
);
2399 } // end of wxDC::SetUserScale
2401 void wxDC::SetAxisOrientation(
2406 m_signX
= bXLeftRight
? 1 : -1;
2407 m_signY
= bYBottomUp
? -1 : 1;
2409 SetMapMode(m_mappingMode
);
2410 } // end of wxDC::SetAxisOrientation
2412 void wxDC::SetSystemScale(
2420 SetMapMode(m_mappingMode
);
2421 } // end of wxDC::SetSystemScale
2423 void wxDC::SetLogicalOrigin(
2430 ::GpiQueryPageViewport( m_hPS
2437 ::GpiSetPageViewport( m_hPS
2440 }; // end of wxDC::SetLogicalOrigin
2442 void wxDC::SetDeviceOrigin(
2449 m_deviceOriginX
= vX
;
2450 m_deviceOriginY
= vY
;
2451 ::GpiQueryPageViewport( m_hPS
2456 vRect
.yBottom
-= vY
;
2458 ::GpiSetPageViewport( m_hPS
2461 }; // end of wxDC::SetDeviceOrigin
2463 // ---------------------------------------------------------------------------
2464 // coordinates transformations
2465 // ---------------------------------------------------------------------------
2467 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2469 return (wxCoord
) (((x
) - m_deviceOriginX
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
) - m_logicalOriginX
);
2472 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2474 // axis orientation is not taken into account for conversion of a distance
2475 return (wxCoord
) ((x
)/(m_logicalScaleX
*m_userScaleX
*m_scaleX
));
2478 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2480 return (wxCoord
) (((y
) - m_deviceOriginY
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
) - m_logicalOriginY
);
2483 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2485 // axis orientation is not taken into account for conversion of a distance
2486 return (wxCoord
) ((y
)/(m_logicalScaleY
*m_userScaleY
*m_scaleY
));
2489 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2491 return (wxCoord
) ((x
- m_logicalOriginX
)*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
+ m_deviceOriginX
);
2494 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2496 // axis orientation is not taken into account for conversion of a distance
2497 return (wxCoord
) (x
*m_logicalScaleX
*m_userScaleX
*m_scaleX
);
2500 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2502 return (wxCoord
) ((y
- m_logicalOriginY
)*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
+ m_deviceOriginY
);
2505 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2507 // axis orientation is not taken into account for conversion of a distance
2508 return (wxCoord
) (y
*m_logicalScaleY
*m_userScaleY
*m_scaleY
);
2511 // ---------------------------------------------------------------------------
2513 // ---------------------------------------------------------------------------
2529 wxMask
* pMask
= NULL
;
2531 COLORREF vOldTextColor
;
2532 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
2536 const wxBitmap
& rBmp
= pSource
->m_vSelectedBitmap
;
2538 pMask
= rBmp
.GetMask();
2539 if (!(rBmp
.Ok() && pMask
&& pMask
->GetMaskBitmap()))
2545 ::GpiQueryAttrs( m_hPS
2550 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
2552 if (m_textForegroundColour
.Ok())
2554 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
2555 ::GpiSetAttrs( m_hPS
// presentation-space handle
2556 ,PRIM_CHAR
// Char primitive.
2557 ,CBB_COLOR
// sets color.
2559 ,&vCbnd
// buffer for attributes.
2562 if (m_textBackgroundColour
.Ok())
2564 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
2567 LONG lRop
= ROP_SRCCOPY
;
2571 case wxXOR
: lRop
= ROP_SRCINVERT
; break;
2572 case wxINVERT
: lRop
= ROP_DSTINVERT
; break;
2573 case wxOR_REVERSE
: lRop
= 0x00DD0228; break;
2574 case wxAND_REVERSE
: lRop
= ROP_SRCERASE
; break;
2575 case wxCLEAR
: lRop
= ROP_ZERO
; break;
2576 case wxSET
: lRop
= ROP_ONE
; break;
2577 case wxOR_INVERT
: lRop
= ROP_MERGEPAINT
; break;
2578 case wxAND
: lRop
= ROP_SRCAND
; break;
2579 case wxOR
: lRop
= ROP_SRCPAINT
; break;
2580 case wxEQUIV
: lRop
= 0x00990066; break;
2581 case wxNAND
: lRop
= 0x007700E6; break;
2582 case wxAND_INVERT
: lRop
= 0x00220326; break;
2583 case wxCOPY
: lRop
= ROP_SRCCOPY
; break;
2584 case wxNO_OP
: lRop
= ROP_NOTSRCERASE
; break;
2585 case wxSRC_INVERT
: lRop
= ROP_SRCINVERT
; break;
2586 case wxNOR
: lRop
= ROP_NOTSRCCOPY
; break;
2588 wxFAIL_MSG( wxT("unsupported logical function") );
2597 // Blit bitmap with mask
2601 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
2607 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
2608 BITMAPINFOHEADER2 vBmpHdr
;
2610 SIZEL vSize
= {0, 0};
2613 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
2614 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
2615 vBmpHdr
.cx
= vWidth
;
2616 vBmpHdr
.cy
= vHeight
;
2617 vBmpHdr
.cPlanes
= 1;
2618 vBmpHdr
.cBitCount
= 24;
2620 #if wxUSE_DC_CACHEING
2624 // create a temp buffer bitmap and DCs to access it and the mask
2626 wxDCCacheEntry
* pDCCacheEntry1
= FindDCInCache( NULL
2629 wxDCCacheEntry
* pDCCacheEntry2
= FindDCInCache( pDCCacheEntry1
2632 wxDCCacheEntry
* pBitmapCacheEntry
= FindBitmapInCache( GetHPS()
2637 hPSMask
= pDCCacheEntry1
->m_hPS
;
2638 hDCBuffer
= (HDC
)pDCCacheEntry2
->m_hPS
;
2639 hBufBitmap
= (HBITMAP
)pBitmapCacheEntry
->m_hBitmap
;
2644 hDCMask
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2645 hDCBuffer
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
2646 hPSMask
= ::GpiCreatePS(vHabmain
, hDCMask
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2647 hPSBuffer
= ::GpiCreatePS(vHabmain
, hDCBuffer
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
2648 hBufBitmap
= ::GpiCreateBitmap(GetHPS(), &vBmpHdr
, 0L, NULL
, NULL
);
2651 POINTL aPoint1
[4] = { 0, 0
2654 ,vXdest
+ vWidth
, vYdest
+ vHeight
2656 POINTL aPoint2
[4] = { 0, 0
2659 ,vXsrc
+ vWidth
, vYsrc
+ vHeight
2661 POINTL aPoint3
[4] = { vXdest
, vYdest
2662 ,vXdest
+ vWidth
, vYdest
+ vHeight
2664 ,vXsrc
+ vWidth
, vYsrc
+ vHeight
2666 POINTL aPoint4
[4] = { vXdest
, vYdest
2667 ,vXdest
+ vWidth
, vYdest
+ vHeight
2671 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
2672 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
2675 // Copy dest to buffer
2677 rc
= ::GpiBitBlt( hPSBuffer
2684 if (rc
== GPI_ERROR
)
2686 wxLogLastError(wxT("BitBlt"));
2690 // Copy src to buffer using selected raster op
2692 rc
= ::GpiBitBlt( hPSBuffer
2699 if (rc
== GPI_ERROR
)
2701 wxLogLastError(wxT("BitBlt"));
2705 // Set masked area in buffer to BLACK (pixel value 0)
2707 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
2708 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
2710 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
2711 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
2713 rc
= ::GpiBitBlt( hPSBuffer
2720 if (rc
== GPI_ERROR
)
2722 wxLogLastError(wxT("BitBlt"));
2726 // Set unmasked area in dest to BLACK
2728 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
2729 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
2730 rc
= ::GpiBitBlt( GetHPS()
2737 if (rc
== GPI_ERROR
)
2739 wxLogLastError(wxT("BitBlt"));
2743 // Restore colours to original values
2745 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
2746 ::GpiSetColor(GetHPS(), vPrevCol
);
2749 // OR buffer to dest
2751 rc
= ::GpiBitBlt( GetHPS()
2758 if (rc
== GPI_ERROR
)
2761 wxLogLastError(wxT("BitBlt"));
2765 // Tidy up temporary DCs and bitmap
2767 ::GpiSetBitmap(hPSMask
, NULLHANDLE
);
2768 ::GpiSetBitmap(hPSBuffer
, NULLHANDLE
);
2769 #if !wxUSE_DC_CACHEING
2770 ::GpiDestroyPS(hPSMask
);
2771 ::GpiDestroyPS(hPSBuffer
);
2772 ::DevCloseDC(hDCMask
);
2773 ::DevCloseDC(hDCBuffer
);
2774 ::GpiDeleteBitmap(hBufBitmap
);
2778 else // no mask, just BitBlt() it
2780 POINTL aPoint
[4] = { vXdest
, vYdest
2781 ,vXdest
+ vWidth
, vYdest
+ vHeight
2783 ,vXsrc
+ vWidth
, vYsrc
+ vHeight
2786 bSuccess
= (::GpiBitBlt( m_hPS
2795 wxLogLastError(wxT("BitBlt"));
2798 vCbnd
.lColor
= (LONG
)vOldTextColor
;
2799 ::GpiSetAttrs( m_hPS
// presentation-space handle
2800 ,PRIM_CHAR
// Char primitive.
2801 ,CBB_COLOR
// sets color.
2803 ,&vCbnd
// buffer for attributes.
2805 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
2809 void wxDC::DoGetSize(
2814 LONG lArray
[CAPS_HEIGHT
];
2816 if(::DevQueryCaps( m_hDC
2822 *pnWidth
= lArray
[CAPS_WIDTH
];
2823 *pnHeight
= lArray
[CAPS_HEIGHT
];
2825 }; // end of wxDC::DoGetSize(
2827 void wxDC::DoGetSizeMM(
2832 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2834 if(::DevQueryCaps( m_hDC
2836 ,CAPS_VERTICAL_RESOLUTION
2845 nWidth
= lArray
[CAPS_WIDTH
];
2846 nHeight
= lArray
[CAPS_HEIGHT
];
2847 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2848 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2849 nWidth
= (nHorzRes
/1000) * nWidth
;
2850 nHeight
= (nVertRes
/1000) * nHeight
;
2852 }; // end of wxDC::DoGetSizeMM
2854 wxSize
wxDC::GetPPI() const
2856 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2860 if(::DevQueryCaps( m_hDC
2862 ,CAPS_VERTICAL_RESOLUTION
2871 nPelWidth
= lArray
[CAPS_WIDTH
];
2872 nPelHeight
= lArray
[CAPS_HEIGHT
];
2873 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2874 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2875 nWidth
= (nHorzRes
/39.3) * nPelWidth
;
2876 nHeight
= (nVertRes
/39.3) * nPelHeight
;
2878 return (wxSize(nWidth
,nHeight
));
2879 } // end of wxDC::GetPPI
2881 void wxDC::SetLogicalScale(
2886 m_logicalScaleX
= dX
;
2887 m_logicalScaleY
= dY
;
2888 }; // end of wxDC::SetLogicalScale