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"
28 #include "wx/dcprint.h"
33 #include "wx/os2/private.h"
35 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
38 // wxWindows uses the Microsoft convention that the origin is the UPPER left.
39 // Native OS/2 however in the GPI and PM define the origin as the LOWER left.
40 // In order to map OS/2 GPI/PM y coordinates to wxWindows coordinates we must
41 // perform the following transformation:
43 // Parent object height: POBJHEIGHT
44 // Desried origin: WXORIGINY
45 // Object to place's height: OBJHEIGHT
47 // To get the OS2 position from the wxWindows one:
49 // OS2Y = POBJHEIGHT - (WXORIGINY + OBJHEIGHT)
51 // For OS/2 wxDC's we will always determine m_vRclPaint as the size of the
52 // OS/2 Presentation Space associated with the device context. y is the
53 // desired application's y coordinate of the origin in wxWindows space.
54 // objy is the height of the object we are going to draw.
56 #define OS2Y(y, objy) ((m_vRclPaint.yTop - m_vRclPaint.yBottom) - (y + objy))
58 // ---------------------------------------------------------------------------
60 // ---------------------------------------------------------------------------
62 static const int VIEWPORT_EXTENT
= 1000;
64 static const int MM_POINTS
= 9;
65 static const int MM_METRIC
= 10;
67 // usually this is defined in math.h
69 static const double M_PI
= 3.14159265358979323846;
72 // ---------------------------------------------------------------------------
74 // ---------------------------------------------------------------------------
76 // convert degrees to radians
77 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
81 , int nForegroundColour
86 vCbnd
.lColor
= nForegroundColour
;
87 ::GpiSetAttrs( hPS
// presentation-space handle
88 ,PRIM_CHAR
// Char primitive.
89 ,CBB_COLOR
// sets color.
91 ,&vCbnd
// buffer for attributes.
102 ::GpiQueryAttrs( hPS
// presentation-space handle
103 ,PRIM_CHAR
// Char primitive.
104 ,CBB_BACK_COLOR
// Background color.
105 ,&vCbnd
// buffer for attributes.
107 return vCbnd
.lBackColor
;
113 , int nBackgroundColour
119 rc
= QueryTextBkColor(hPS
);
121 vCbnd
.lBackColor
= nBackgroundColour
;
122 ::GpiSetAttrs(hPS
, // presentation-space handle
123 PRIM_CHAR
, // Char primitive.
124 CBB_BACK_COLOR
, // sets color.
126 &vCbnd
// buffer for attributes.
133 , int nBackgroundMode
136 if(nBackgroundMode
== wxTRANSPARENT
)
141 // the background of the primitive takes over whatever is underneath.
148 // ===========================================================================
150 // ===========================================================================
152 // ---------------------------------------------------------------------------
154 // ---------------------------------------------------------------------------
170 m_bIsPaintTime
= FALSE
; // True at Paint Time
171 m_brush
.GetColour().Set("WHITE");
172 } // end of wxDC::wxDC
178 SelectOldObjects(m_hDC
);
180 // if we own the HDC, we delete it, otherwise we just release it
186 ::GpiAssociate(m_hPS
, NULLHANDLE
);
187 ::GpiDestroyPS(m_hPS
);
190 ::DevCloseDC((HDC
)m_hDC
);
195 // Just Dissacociate, not destroy if we don't own the DC
199 ::GpiAssociate(m_hPS
, NULLHANDLE
);
203 } // end of wxDC::~wxDC
205 // This will select current objects out of the DC,
206 // which is what you have to do before deleting the
208 void wxDC::SelectOldObjects(
216 ::GpiSetBitmap(hPS
, (HBITMAP
) m_hOldBitmap
);
217 if (m_vSelectedBitmap
.Ok())
219 m_vSelectedBitmap
.SetSelectedInto(NULL
);
224 // OS/2 has no other native GDI objects to set in a PS/DC like windows
232 m_brush
= wxNullBrush
;
234 m_palette
= wxNullPalette
;
236 m_backgroundBrush
= wxNullBrush
;
237 m_vSelectedBitmap
= wxNullBitmap
;
238 } // end of wxDC::SelectOldObjects
240 // ---------------------------------------------------------------------------
242 // ---------------------------------------------------------------------------
244 #define DO_SET_CLIPPING_BOX() \
248 ::GpiQueryClipBox(m_hPS, &rect); \
250 m_clipX1 = (wxCoord) XDEV2LOG(rect.xLeft); \
251 m_clipY1 = (wxCoord) YDEV2LOG(rect.yTop); \
252 m_clipX2 = (wxCoord) XDEV2LOG(rect.xRight); \
253 m_clipY2 = (wxCoord) YDEV2LOG(rect.yBottom); \
256 void wxDC::DoSetClippingRegion(
265 vY
= OS2Y(vY
,vHeight
);
268 vRect
.yTop
= vY
+ vHeight
;
269 vRect
.xRight
= vX
+ vWidth
;
271 ::GpiIntersectClipRectangle(m_hPS
, &vRect
);
272 DO_SET_CLIPPING_BOX()
273 } // end of wxDC::DoSetClippingRegion
275 void wxDC::DoSetClippingRegionAsRegion(
276 const wxRegion
& rRegion
279 wxCHECK_RET(rRegion
.GetHRGN(), wxT("invalid clipping region"));
283 ::GpiSetClipRegion( m_hPS
284 ,(HRGN
)rRegion
.GetHRGN()
287 DO_SET_CLIPPING_BOX()
288 } // end of wxDC::DoSetClippingRegionAsRegion
290 void wxDC::DestroyClippingRegion(void)
292 if (m_clipping
&& m_hPS
)
297 // TODO: this should restore the previous clipped region
298 // so that OnPaint processing works correctly, and
299 // the update doesn't get destroyed after the first
300 // DestroyClippingRegion
301 vRect
.xLeft
= XLOG2DEV(0);
302 vRect
.yTop
= YLOG2DEV(32000);
303 vRect
.xRight
= XLOG2DEV(32000);
304 vRect
.yBottom
= YLOG2DEV(0);
306 HRGN hRgn
= ::GpiCreateRegion(m_hPS
, 1, &vRect
);
308 ::GpiSetClipRegion(m_hPS
, hRgn
, &hRgnOld
);
311 } // end of wxDC::DestroyClippingRegion
313 // ---------------------------------------------------------------------------
314 // query capabilities
315 // ---------------------------------------------------------------------------
317 bool wxDC::CanDrawBitmap() const
322 bool wxDC::CanGetTextExtent() const
324 LONG lTechnology
= 0L;
326 ::DevQueryCaps(GetHDC(), CAPS_TECHNOLOGY
, 1L, &lTechnology
);
327 return (lTechnology
== CAPS_TECH_RASTER_DISPLAY
) || (lTechnology
== CAPS_TECH_RASTER_PRINTER
);
328 } // end of wxDC::CanGetTextExtent
330 int wxDC::GetDepth() const
332 LONG lArray
[CAPS_COLOR_BITCOUNT
];
335 if(::DevQueryCaps( GetHDC()
341 nBitsPerPixel
= (int)lArray
[CAPS_COLOR_BITCOUNT
];
343 return nBitsPerPixel
;
344 } // end of wxDC::GetDepth
346 // ---------------------------------------------------------------------------
348 // ---------------------------------------------------------------------------
353 } // end of wxDC::Clear
355 void wxDC::DoFloodFill(
358 , const wxColour
& rCol
366 vPtlPos
.x
= vX
; // Loads x-coordinate
367 vPtlPos
.y
= OS2Y(vY
,0); // Loads y-coordinate
368 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
369 lColor
= rCol
.GetPixel();
370 lOptions
= FF_BOUNDARY
;
371 if(wxFLOOD_SURFACE
== nStyle
)
372 lOptions
= FF_SURFACE
;
374 ::GpiFloodFill(m_hPS
, lOptions
, lColor
);
375 } // end of wxDC::DoFloodFill
377 bool wxDC::DoGetPixel(
387 vPoint
.y
= OS2Y(vY
,0);
388 lColor
= ::GpiSetPel(m_hPS
, &vPoint
);
391 // Get the color of the pen
393 LONG lPencolor
= 0x00ffffff;
397 lPencolor
= m_pen
.GetColour().GetPixel();
401 // return the color of the pixel
404 pCol
->Set( GetRValue(lColor
)
408 return(lColor
== lPencolor
);
409 } // end of wxDC::DoGetPixel
411 void wxDC::DoCrossHair(
418 wxCoord vX1
= vX
- VIEWPORT_EXTENT
;
419 wxCoord vY1
= vY
- VIEWPORT_EXTENT
;
420 wxCoord vX2
= vX
+ VIEWPORT_EXTENT
;
421 wxCoord vY2
= vY
+ VIEWPORT_EXTENT
;
430 ::GpiMove(m_hPS
, &vPoint
[0]);
431 ::GpiLine(m_hPS
, &vPoint
[1]);
439 ::GpiMove(m_hPS
, &vPoint
[2]);
440 ::GpiLine(m_hPS
, &vPoint
[3]);
441 CalcBoundingBox(vX1
, vY1
);
442 CalcBoundingBox(vX2
, vY2
);
443 } // end of wxDC::DoCrossHair
445 void wxDC::DoDrawLine(
461 ::GpiMove(m_hPS
, &vPoint
[0]);
462 ::GpiLine(m_hPS
, &vPoint
[1]);
463 CalcBoundingBox(vX1
, vY1
);
464 CalcBoundingBox(vX2
, vY2
);
465 } // end of wxDC::DoDrawLine
467 //////////////////////////////////////////////////////////////////////////////
468 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
469 // and ending at (x2, y2). The current pen is used for the outline and the
470 // current brush for filling the shape. The arc is drawn in an anticlockwise
471 // direction from the start point to the end point.
472 //////////////////////////////////////////////////////////////////////////////
473 void wxDC::DoDrawArc(
483 POINTL vPtlArc
[2]; // Structure for current position
492 ARCPARAMS vArcp
; // Structure for arc parameters
494 if((vX1
== vXc
&& vY1
== vXc
) || (vX2
== vXc
&& vY2
== vXc
))
495 return; // Draw point ??
496 dRadius
= 0.5 * ( hypot( (double)(vY1
- vYc
)
499 hypot( (double)(vY2
- vYc
)
504 dAngl1
= atan2( (double)(vY1
- vYc
)
507 dAngl2
= atan2( (double)(vY2
- vYc
)
514 // GpiPointArc can't draw full arc
516 if(dAngl2
== dAngl1
|| (vX1
== vX2
&& vY1
== vY2
) )
521 dAnglmid
= (dAngl1
+ dAngl2
)/2. + M_PI
;
522 vXm
= vXc
+ dRadius
* cos(dAnglmid
);
523 vYm
= vYc
+ dRadius
* sin(dAnglmid
);
538 dAnglmid
= (dAngl1
+ dAngl2
)/2.;
539 vXm
= vXc
+ dRadius
* cos(dAnglmid
);
540 vYm
= vYc
+ dRadius
* sin(dAnglmid
);
543 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
549 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
551 vPtlPos
.x
= vX1
; // Loads x-coordinate
552 vPtlPos
.y
= vY1
; // Loads y-coordinate
553 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
558 ::GpiPointArc(m_hPS
, vPtlArc
); // Draws the arc
559 CalcBoundingBox( (vXc
- dRadius
)
562 CalcBoundingBox( (vXc
+ dRadius
)
565 } // end of wxDC::DoDrawArc
567 void wxDC::DoDrawCheckMark(
576 vY1
= OS2Y(vY1
,vHeight
);
580 vPoint
[1].x
= vX1
+ vWidth
;
581 vPoint
[1].y
= vY1
+ vHeight
;
583 ::GpiMove(m_hPS
, &vPoint
[0]);
584 ::GpiBox( m_hPS
// handle to a presentation space
585 ,DRO_OUTLINE
// draw the box outline ? or ?
586 ,&vPoint
[1] // address of the corner
587 ,0L // horizontal corner radius
588 ,0L // vertical corner radius
590 if(vWidth
> 4 && vHeight
> 4)
594 vPoint
[0].x
+= 2; vPoint
[0].y
+= 2;
595 vPoint
[1].x
-= 2; vPoint
[1].y
-= 2;
596 ::GpiMove(m_hPS
, &vPoint
[0]);
597 ::GpiLine(m_hPS
, &vPoint
[1]);
599 vPoint
[0].x
= vPoint
[1].x
;
601 ::GpiMove(m_hPS
, &vPoint
[0]);
602 ::GpiLine(m_hPS
, &vPoint
[1]);
608 wxCoord vX2
= vX1
+ vWidth
;
609 wxCoord vY2
= vY1
+ vHeight
;
614 } // end of wxDC::DoDrawCheckMark
616 void wxDC::DoDrawPoint(
622 COLORREF vColor
= 0x00ffffff;
626 vColor
= m_pen
.GetColour().GetPixel();
628 ::GpiSetColor(m_hPS
, vColor
);
630 vPoint
.y
= OS2Y(vY
,0);
631 ::GpiSetPel(m_hPS
, &vPoint
);
635 } // end of wxDC::DoDrawPoint
637 void wxDC::DoDrawPolygon(
645 ULONG ulCount
= 1; // Number of polygons.
646 POLYGON vPlgn
; // polygon.
647 ULONG flOptions
= 0L; // Drawing options.
649 //////////////////////////////////////////////////////////////////////////////
650 // This contains fields of option bits... to draw boundary lines as well as
651 // the area interior.
653 // Drawing boundary lines:
654 // POLYGON_NOBOUNDARY Does not draw boundary lines.
655 // POLYGON_BOUNDARY Draws boundary lines (the default).
657 // Construction of the area interior:
658 // POLYGON_ALTERNATE Constructs interior in alternate mode
660 // POLYGON_WINDING Constructs interior in winding mode.
661 //////////////////////////////////////////////////////////////////////////////
663 ULONG flModel
= 0L; // Drawing model.
665 //////////////////////////////////////////////////////////////////////////////
667 // POLYGON_INCL Fill is inclusive of bottom right (the default).
668 // POLYGON_EXCL Fill is exclusive of bottom right.
669 // This is provided to aid migration from other graphics models.
670 //////////////////////////////////////////////////////////////////////////////
672 LONG lHits
= 0L; // Correlation/error indicator.
675 int nIsTRANSPARENT
= 0;
676 LONG lBorderColor
= 0L;
679 lBorderColor
= m_pen
.GetColour().GetPixel();
680 lColor
= m_brush
.GetColour().GetPixel();
681 if(m_brush
.GetStyle() == wxTRANSPARENT
)
685 vPlgn
.aPointl
= (POINTL
*) calloc( n
+ 1
687 ); // well, new will call malloc
689 for(i
= 0; i
< n
; i
++)
691 vPlgn
.aPointl
[i
].x
= vPoints
[i
].x
; // +xoffset;
692 vPlgn
.aPointl
[i
].y
= OS2Y(vPoints
[i
].y
,0); // +yoffset;
694 flModel
= POLYGON_BOUNDARY
;
695 if(nFillStyle
== wxWINDING_RULE
)
696 flModel
|= POLYGON_WINDING
;
698 flModel
|= POLYGON_ALTERNATE
;
701 vPoint
.y
= OS2Y(vYoffset
,0);
703 ::GpiSetColor(m_hPS
, lBorderColor
);
704 ::GpiMove(m_hPS
, &vPoint
);
705 lHits
= ::GpiPolygons(m_hPS
, ulCount
, &vPlgn
, flOptions
, flModel
);
707 } // end of wxDC::DoDrawPolygon
709 void wxDC::DoDrawLines(
718 if (vXoffset
!= 0L || vXoffset
!= 0L)
722 vPoint
.x
= vPoints
[0].x
+ vXoffset
;
723 vPoint
.y
= OS2Y(vPoints
[0].y
+ vYoffset
,0);
724 ::GpiMove(m_hPS
, &vPoint
);
726 LONG lBorderColor
= m_pen
.GetColour().GetPixel();
728 ::GpiSetColor(m_hPS
, lBorderColor
);
729 for(i
= 1; i
< n
; i
++)
731 vPoint
.x
= vPoints
[i
].x
+ vXoffset
;
732 vPoint
.y
= OS2Y(vPoints
[i
].y
+ vYoffset
,0);
733 ::GpiLine(m_hPS
, &vPoint
);
740 CalcBoundingBox( vPoints
[i
].x
743 vPoint
.x
= vPoints
[0].x
;
744 vPoint
.y
= OS2Y(vPoints
[0].y
,0);
745 ::GpiMove(m_hPS
, &vPoint
);
747 for (i
= 0; i
< n
; i
++)
749 CalcBoundingBox( vPoints
[i
].x
752 vPoint
.x
= vPoints
[i
].x
;
753 vPoint
.y
= OS2Y(vPoints
[i
].y
,0);
754 ::GpiLine(m_hPS
, &vPoint
);
757 } // end of wxDC::DoDrawLines
759 void wxDC::DoDrawRectangle(
770 int nIsTRANSPARENT
= 0;
772 vY
= OS2Y(vY
,vHeight
);
774 wxCoord vX2
= vX
+ vWidth
;
775 wxCoord vY2
= vY
+ vHeight
;
779 vPoint
[1].x
= vX
+ vWidth
;
780 vPoint
[1].y
= vY
+ vHeight
;
781 ::GpiMove(m_hPS
, &vPoint
[0]);
782 lColor
= m_brush
.GetColour().GetPixel();
783 lBorderColor
= m_pen
.GetColour().GetPixel();
784 if (m_brush
.GetStyle() == wxTRANSPARENT
)
786 if(lColor
== lBorderColor
|| nIsTRANSPARENT
)
788 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
789 if(m_brush
.GetStyle() == wxTRANSPARENT
)
790 lControl
= DRO_OUTLINE
;
792 ::GpiSetColor(m_hPS
, lColor
);
793 ::GpiBox( m_hPS
// handle to a presentation space
794 ,lControl
// draw the box outline ? or ?
795 ,&vPoint
[1] // address of the corner
796 ,0L // horizontal corner radius
797 ,0L // vertical corner radius
802 lControl
= DRO_OUTLINE
;
816 vPoint
[0].x
= vX
+ 1;
817 vPoint
[0].y
= vY
+ 1;
818 vPoint
[1].x
= vX
+ vWidth
- 2;
819 vPoint
[1].y
= vY
+ vHeight
+ 2;
820 ::GpiMove(m_hPS
, &vPoint
[0]);
828 CalcBoundingBox(vX
, vY
);
829 CalcBoundingBox(vX2
, vY2
);
830 } // end of wxDC::DoDrawRectangle
832 void wxDC::DoDrawRoundedRectangle(
843 vY
= OS2Y(vY
,vHeight
);
845 wxCoord vX2
= (vX
+ vWidth
);
846 wxCoord vY2
= (vY
+ vHeight
);
849 vPoint
[0].y
= YLOG2DEV(vY
) - vHeight
;
850 vPoint
[1].x
= vX
+ vWidth
;
852 ::GpiMove(m_hPS
, &vPoint
[0]);
854 lControl
= DRO_OUTLINEFILL
; //DRO_FILL;
855 if (m_brush
.GetStyle() == wxTRANSPARENT
)
856 lControl
= DRO_OUTLINE
;
857 ::GpiBox( m_hPS
// handle to a presentation space
858 ,DRO_OUTLINE
// draw the box outline ? or ?
859 ,&vPoint
[1] // address of the corner
860 ,(LONG
)dRadius
// horizontal corner radius
861 ,(LONG
)dRadius
// vertical corner radius
863 CalcBoundingBox(vX
, vY
);
864 CalcBoundingBox(vX2
, vY2
);
865 } // end of wxDC::DoDrawRoundedRectangle
867 // Draw Ellipse within box (x,y) - (x+width, y+height)
868 void wxDC::DoDrawEllipse(
875 POINTL vPtlPos
; // Structure for current position
876 FIXED vFxMult
; // Multiplier for ellipse
877 ARCPARAMS vArcp
; // Structure for arc parameters
879 vY
= OS2Y(vY
,vHeight
);
882 vArcp
.lQ
= vHeight
/2;
885 ::GpiSetArcParams( m_hPS
887 ); // Sets parameters to default
888 vPtlPos
.x
= vX
+ vWidth
/2; // Loads x-coordinate
889 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
892 ); // Sets current position
893 vFxMult
= MAKEFIXED(1, 0); /* Sets multiplier */
896 // DRO_FILL, DRO_OTLINEFILL - where to get
901 ); // Draws full arc with center at current position
903 wxCoord vX2
= (vX
+ vWidth
);
904 wxCoord vY2
= (vY
+ vHeight
);
906 CalcBoundingBox(vX
, vY
);
907 CalcBoundingBox(vX2
, vY2
);
908 } // end of wxDC::DoDrawEllipse
910 void wxDC::DoDrawEllipticArc(
919 POINTL vPtlPos
; // Structure for current position
920 FIXED vFxMult
; // Multiplier for ellipse
921 ARCPARAMS vArcp
; // Structure for arc parameters
923 FIXED vFSweepa
; // Start angle, sweep angle
928 vY
= OS2Y(vY
,vHeight
);
930 dFractPart
= modf(dSa
,&dIntPart
);
931 vFSa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
932 dFractPart
= modf(dEa
- dSa
, &dIntPart
);
933 vFSweepa
= MAKEFIXED((int)dIntPart
, (int)(dFractPart
* 0xffff) );
936 // Ellipse main axis (r,q), (p,s) with center at (0,0)
939 vArcp
.lQ
= vHeight
/2;
942 ::GpiSetArcParams(m_hPS
, &vArcp
); // Sets parameters to default
943 vPtlPos
.x
= vX
+ vWidth
/2 * (1. + cos(DegToRad(dSa
))); // Loads x-coordinate
944 vPtlPos
.y
= vY
+ vHeight
/2 * (1. + sin(DegToRad(dSa
))); // Loads y-coordinate
945 ::GpiMove(m_hPS
, &vPtlPos
); // Sets current position
948 // May be not to the center ?
950 vPtlPos
.x
= vX
+ vWidth
/2 ; // Loads x-coordinate
951 vPtlPos
.y
= vY
+ vHeight
/2; // Loads y-coordinate
952 vFxMult
= MAKEFIXED(1, 0); // Sets multiplier
955 // DRO_FILL, DRO_OTLINEFILL - where to get
957 ::GpiPartialArc( m_hPS
963 wxCoord vX2
= (vX
+ vWidth
);
964 wxCoord vY2
= (vY
+ vHeight
);
966 CalcBoundingBox(vX
, vY
);
967 CalcBoundingBox(vX2
, vY2
);
968 } // end of wxDC::DoDrawEllipticArc
970 void wxDC::DoDrawIcon(
976 vY
= OS2Y(vY
,rIcon
.GetHeight());
977 wxCHECK_RET( rIcon
.Ok(), wxT("invalid icon in DrawIcon") );
979 ::WinDrawPointer( GetHPS()
982 ,(HPOINTER
)GetHiconOf(rIcon
)
985 CalcBoundingBox(vX
, vY
);
986 CalcBoundingBox(vX
+ rIcon
.GetWidth(), vY
+ rIcon
.GetHeight());
987 } // end of wxDC::DoDrawIcon
989 void wxDC::DoDrawBitmap(
996 POINTL vPoint
= {vX
, vY
};
998 ::WinDrawBitmap( GetHPS()
999 ,(HBITMAP
)GetHbitmapOf(rBmp
)
1006 } // end of wxDC::DoDrawBitmap
1008 void wxDC::DoDrawText(
1009 const wxString
& rsText
1022 CalcBoundingBox(vX
, vY
);
1023 GetTextExtent(rsText
, &vWidth
, &vHeight
);
1024 CalcBoundingBox((vX
+ vWidth
), (vY
+ vHeight
));
1025 } // end of wxDC::DoDrawText
1027 void wxDC::DrawAnyText(
1028 const wxString
& rsText
1033 int nOldBackground
= 0;
1040 // prepare for drawing the text
1044 // Set text color attributes
1046 if (m_textForegroundColour
.Ok())
1049 ,(int)m_textForegroundColour
.GetPixel()
1053 if (m_textBackgroundColour
.Ok())
1055 nOldBackground
= SetTextBkColor( m_hPS
1056 ,(int)m_textBackgroundColour
.GetPixel()
1062 GetTextExtent( rsText
1067 vPtlStart
.y
= OS2Y(vY
,vTextY
);
1069 lHits
= ::GpiCharStringAt( m_hPS
1072 ,(PCH
)rsText
.c_str()
1074 if (lHits
!= GPI_OK
)
1076 wxLogLastError(wxT("TextOut"));
1080 // Restore the old parameters (text foreground colour may be left because
1081 // it never is set to anything else, but background should remain
1082 // transparent even if we just drew an opaque string)
1084 if (m_textBackgroundColour
.Ok())
1085 SetTextBkColor( m_hPS
1093 void wxDC::DoDrawRotatedText(
1094 const wxString
& rsText
1112 DoDrawText(text, x, y);
1117 wxFillLogFont(&lf, &m_font);
1119 // GDI wants the angle in tenth of degree
1120 long angle10 = (long)(angle * 10);
1121 lf.lfEscapement = angle10;
1122 lf. lfOrientation = angle10;
1124 HFONT hfont = ::CreateFontIndirect(&lf);
1127 wxLogLastError("CreateFont");
1131 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
1133 DrawAnyText(text, x, y);
1135 (void)::SelectObject(GetHdc(), hfontOld);
1138 // call the bounding box by adding all four vertices of the rectangle
1139 // containing the text to it (simpler and probably not slower than
1140 // determining which of them is really topmost/leftmost/...)
1142 GetTextExtent(text, &w, &h);
1144 double rad = DegToRad(angle);
1146 // "upper left" and "upper right"
1147 CalcBoundingBox(x, y);
1148 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
1149 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1151 // "bottom left" and "bottom right"
1152 x += (wxCoord)(h*sin(rad));
1153 y += (wxCoord)(h*cos(rad));
1154 CalcBoundingBox(x, y);
1155 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
1160 // ---------------------------------------------------------------------------
1162 // ---------------------------------------------------------------------------
1164 void wxDC::SetPalette(
1165 const wxPalette
& rPalette
1172 m_palette
= rPalette
;
1180 HPALETTE hOldPal
= ::GpiSelectPalette((HDC
) m_hPS
, (HPALETTE
) m_palette
.GetHPALETTE());
1182 m_hOldPalette
= (WXHPALETTE
)hOldPal
;
1183 } // end of wxDC::SetPalette
1190 // Set the old object temporarily, in case the assignment deletes an object
1191 // that's not yet selected out.
1203 m_font
.SetPS(m_hPS
); // this will realize the font
1207 HFONT hFont
= m_font
.GetResourceHandle();
1208 if (hFont
== (HFONT
) NULL
)
1210 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
1213 m_hOldFont
= (WXHFONT
) hFont
;
1215 } // end of wxDC::SetFont
1221 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1237 m_pen
.SetPS((HPS
)m_hOldPen
);
1244 if (m_pen
.GetResourceHandle())
1248 m_hOldPen
= m_pen
.GetPS();
1253 void wxDC::SetBrush(
1254 const wxBrush
& rBrush
1257 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1263 if (m_brush
== rBrush
)
1273 m_brush
.SetPS((HPS
)m_hOldBrush
);
1280 if (m_brush
.GetResourceHandle())
1282 m_brush
.SetPS(m_hPS
);
1284 m_hOldBrush
= (WXHWND
)m_brush
.GetPS();
1287 } // end of wxDC::SetBrush
1289 void wxDC::SetBackground(
1290 const wxBrush
& rBrush
1293 m_backgroundBrush
= rBrush
;
1294 if (!m_backgroundBrush
.Ok())
1298 bool bCustomColours
= TRUE
;
1301 // If we haven't specified wxUSER_COLOURS, don't allow the panel/dialog box to
1302 // change background colours from the control-panel specified colours.
1304 if (m_pCanvas
->IsKindOf(CLASSINFO(wxWindow
)) &&
1305 ((m_pCanvas
->GetWindowStyleFlag() & wxUSER_COLOURS
) != wxUSER_COLOURS
))
1306 bCustomColours
= FALSE
;
1309 if (m_backgroundBrush
.GetStyle()==wxTRANSPARENT
)
1311 m_pCanvas
->SetTransparent(TRUE
);
1316 // Setting the background brush of a DC
1317 // doesn't affect the window background colour. However,
1318 // I'm leaving in the transparency setting because it's needed by
1319 // various controls (e.g. wxStaticText) to determine whether to draw
1320 // transparently or not. TODO: maybe this should be a new function
1321 // wxWindow::SetTransparency(). Should that apply to the child itself, or the
1323 // m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
1325 m_pCanvas
->SetTransparent(FALSE
);
1329 COLORREF vNewColor
= m_backgroundBrush
.GetColour().GetPixel();
1330 (void)::GpiSetBackColor((HPS
)m_hPS
, (LONG
)vNewColor
);
1331 } // end of wxDC::SetBackground
1333 void wxDC::SetBackgroundMode(
1337 m_backgroundMode
= nMode
;
1338 } // end of wxDC::SetBackgroundMode
1340 void wxDC::SetLogicalFunction(
1344 m_logicalFunction
= nFunction
;
1345 SetRop((WXHDC
)m_hDC
);
1346 } // wxDC::SetLogicalFunction
1352 if (!hDC
|| m_logicalFunction
< 0)
1356 switch (m_logicalFunction
)
1367 lCRop
= FM_MERGESRCNOT
;
1371 lCRop
= FM_NOTMASKSRC
;
1383 lCRop
= FM_MERGENOTSRC
;
1387 lCRop
= FM_MERGESRCNOT
;
1399 lCRop
= FM_SUBTRACT
;
1406 lCRop
= FM_OVERPAINT
;
1409 ::GpiSetMix((HPS
)hDC
, lCRop
);
1410 } // end of wxDC::SetRop
1412 bool wxDC::StartDoc(
1413 const wxString
& rsMessage
1416 // We might be previewing, so return TRUE to let it continue.
1418 } // end of wxDC::StartDoc
1422 } // end of wxDC::EndDoc
1424 void wxDC::StartPage()
1426 } // end of wxDC::StartPage
1428 void wxDC::EndPage()
1430 } // end of wxDC::EndPage
1432 // ---------------------------------------------------------------------------
1434 // ---------------------------------------------------------------------------
1436 wxCoord
wxDC::GetCharHeight() const
1438 FONTMETRICS vFM
; // metrics structure
1440 ::GpiQueryFontMetrics( m_hPS
1441 ,sizeof(FONTMETRICS
)
1444 return YDEV2LOGREL(vFM
.lXHeight
);
1447 wxCoord
wxDC::GetCharWidth() const
1449 FONTMETRICS vFM
; // metrics structure
1451 ::GpiQueryFontMetrics( m_hPS
1452 ,sizeof(FONTMETRICS
)
1455 return XDEV2LOGREL(vFM
.lAveCharWidth
);
1458 void wxDC::DoGetTextExtent(
1459 const wxString
& rsString
1462 , wxCoord
* pvDescent
1463 , wxCoord
* pvExternalLeading
1467 POINTL avPoint
[TXTBOX_COUNT
];
1472 FONTMETRICS vFM
; // metrics structure
1475 ERRORID vErrorCode
; // last error id code
1476 wxFont
* pFontToUse
= (wxFont
*)pTheFont
;
1478 char zMsg
[128]; // DEBUG
1482 pFontToUse
= (wxFont
*)&m_font
;
1483 l
= rsString
.length();
1484 pStr
= (PCH
) rsString
.c_str();
1487 // In world coordinates.
1489 bRc
= ::GpiQueryTextBox( m_hPS
1492 ,TXTBOX_COUNT
// return maximum information
1493 ,avPoint
// array of coordinates points
1497 vErrorCode
= ::WinGetLastError(wxGetInstance());
1498 sError
= wxPMErrorToStr(vErrorCode
);
1500 sprintf(zMsg
, "GpiQueryTextBox for %s: failed with Error: %x - %s", pStr
, vErrorCode
, sError
.c_str());
1501 (void)wxMessageBox( "wxWindows Menu sample"
1507 vPtMin
.x
= avPoint
[0].x
;
1508 vPtMax
.x
= avPoint
[0].x
;
1509 vPtMin
.y
= avPoint
[0].y
;
1510 vPtMax
.y
= avPoint
[0].y
;
1511 for (i
= 1; i
< 4; i
++)
1513 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
1514 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
1515 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
1516 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
1518 ::GpiQueryFontMetrics( m_hPS
1519 ,sizeof(FONTMETRICS
)
1524 *pvX
= (wxCoord
)(vPtMax
.x
- vPtMin
.x
+ 1);
1526 *pvY
= (wxCoord
)(vPtMax
.y
- vPtMin
.y
+ 1);
1528 *pvDescent
= vFM
.lMaxDescender
;
1529 if (pvExternalLeading
)
1530 *pvExternalLeading
= vFM
.lExternalLeading
;
1533 void wxDC::SetMapMode(
1537 int nPixelWidth
= 0;
1538 int nPixelHeight
= 0;
1541 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
1543 m_mappingMode
= nMode
;
1545 if(::DevQueryCaps( m_hDC
1547 ,CAPS_VERTICAL_RESOLUTION
1554 nPixelWidth
= lArray
[CAPS_WIDTH
];
1555 nPixelHeight
= lArray
[CAPS_HEIGHT
];
1556 lHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
1557 lVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
1558 nMmWidth
= (lHorzRes
/1000) * nPixelWidth
;
1559 nMmWidth
= (lVertRes
/1000) * nPixelHeight
;
1561 if ((nPixelWidth
== 0) || (nPixelHeight
== 0) || (nMmWidth
== 0) || (nMmHeight
== 0))
1566 double dMm2pixelsX
= nPixelWidth
/nMmWidth
;
1567 double dMm2pixelsY
= nPixelHeight
/nMmHeight
;
1572 m_logicalScaleX
= (twips2mm
* dMm2pixelsX
);
1573 m_logicalScaleY
= (twips2mm
* dMm2pixelsY
);
1577 m_logicalScaleX
= (pt2mm
* dMm2pixelsX
);
1578 m_logicalScaleY
= (pt2mm
* dMm2pixelsY
);
1582 m_logicalScaleX
= dMm2pixelsX
;
1583 m_logicalScaleY
= dMm2pixelsY
;
1587 m_logicalScaleX
= (dMm2pixelsX
/10.0);
1588 m_logicalScaleY
= (dMm2pixelsY
/10.0);
1593 m_logicalScaleX
= 1.0;
1594 m_logicalScaleY
= 1.0;
1600 ulOptions
= ::GpiQueryPS(m_hPS
, &vSize
);
1601 if (!ulOptions
& PU_ARBITRARY
)
1603 ulOptions
= PU_ARBITRARY
| GPIF_DEFAULT
;
1604 ::GpiSetPS(m_hPS
, &vSize
, ulOptions
);
1606 m_nWindowExtX
= (int)MS_XDEV2LOGREL(VIEWPORT_EXTENT
);
1607 m_nWindowExtY
= (int)MS_YDEV2LOGREL(VIEWPORT_EXTENT
);
1609 }; // end of wxDC::SetMapMode
1611 void wxDC::SetUserScale(
1619 SetMapMode(m_mappingMode
);
1620 } // end of wxDC::SetUserScale
1622 void wxDC::SetAxisOrientation(
1627 m_signX
= bXLeftRight
? 1 : -1;
1628 m_signY
= bYBottomUp
? -1 : 1;
1630 SetMapMode(m_mappingMode
);
1631 } // end of wxDC::SetAxisOrientation
1633 void wxDC::SetSystemScale(
1641 SetMapMode(m_mappingMode
);
1642 } // end of wxDC::SetSystemScale
1644 void wxDC::SetLogicalOrigin(
1651 ::GpiQueryPageViewport( m_hPS
1658 ::GpiSetPageViewport( m_hPS
1661 }; // end of wxDC::SetLogicalOrigin
1663 void wxDC::SetDeviceOrigin(
1670 m_deviceOriginX
= vX
;
1671 m_deviceOriginY
= vY
;
1672 ::GpiQueryPageViewport( m_hPS
1677 vRect
.yBottom
-= vY
;
1679 ::GpiSetPageViewport( m_hPS
1682 }; // end of wxDC::SetDeviceOrigin
1684 // ---------------------------------------------------------------------------
1685 // coordinates transformations
1686 // ---------------------------------------------------------------------------
1688 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
1690 return (wxCoord
) (((x
) - m_deviceOriginX
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
) - m_logicalOriginX
);
1693 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
1695 return (wxCoord
) ((x
)/(m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
));
1698 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
1700 return (wxCoord
) (((y
) - m_deviceOriginY
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
) - m_logicalOriginY
);
1703 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
1705 return (wxCoord
) ((y
)/(m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
));
1708 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
1710 return (wxCoord
) ((x
- m_logicalOriginX
)*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
+ m_deviceOriginX
);
1713 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
1715 return (wxCoord
) (x
*m_logicalScaleX
*m_userScaleX
*m_signX
*m_scaleX
);
1718 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
1720 return (wxCoord
) ((y
- m_logicalOriginY
)*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
+ m_deviceOriginY
);
1723 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
1725 return (wxCoord
) (y
*m_logicalScaleY
*m_userScaleY
*m_signY
*m_scaleY
);
1728 // ---------------------------------------------------------------------------
1730 // ---------------------------------------------------------------------------
1744 wxMask
* pMask
= NULL
;
1746 COLORREF vOldTextColor
;
1747 COLORREF vOldBackground
= ::GpiQueryBackColor(m_hPS
);
1751 const wxBitmap
& rBmp
= pSource
->m_vSelectedBitmap
;
1753 pMask
= rBmp
.GetMask();
1754 if (!(rBmp
.Ok() && pMask
&& pMask
->GetMaskBitmap()))
1760 ::GpiQueryAttrs( m_hPS
1765 vOldTextColor
= (COLORREF
)vCbnd
.lColor
;
1767 if (m_textForegroundColour
.Ok())
1769 vCbnd
.lColor
= (LONG
)m_textForegroundColour
.GetPixel();
1770 ::GpiSetAttrs( m_hPS
// presentation-space handle
1771 ,PRIM_CHAR
// Char primitive.
1772 ,CBB_COLOR
// sets color.
1774 ,&vCbnd
// buffer for attributes.
1777 if (m_textBackgroundColour
.Ok())
1779 ::GpiSetBackColor(m_hPS
, (LONG
)m_textBackgroundColour
.GetPixel());
1782 LONG lRop
= ROP_SRCCOPY
;
1786 case wxXOR
: lRop
= ROP_SRCINVERT
; break;
1787 case wxINVERT
: lRop
= ROP_DSTINVERT
; break;
1788 case wxOR_REVERSE
: lRop
= 0x00DD0228; break;
1789 case wxAND_REVERSE
: lRop
= ROP_SRCERASE
; break;
1790 case wxCLEAR
: lRop
= ROP_ZERO
; break;
1791 case wxSET
: lRop
= ROP_ONE
; break;
1792 case wxOR_INVERT
: lRop
= ROP_MERGEPAINT
; break;
1793 case wxAND
: lRop
= ROP_SRCAND
; break;
1794 case wxOR
: lRop
= ROP_SRCPAINT
; break;
1795 case wxEQUIV
: lRop
= 0x00990066; break;
1796 case wxNAND
: lRop
= 0x007700E6; break;
1797 case wxAND_INVERT
: lRop
= 0x00220326; break;
1798 case wxCOPY
: lRop
= ROP_SRCCOPY
; break;
1799 case wxNO_OP
: lRop
= ROP_NOTSRCERASE
; break;
1800 case wxSRC_INVERT
: lRop
= ROP_SRCINVERT
; break;
1801 case wxNOR
: lRop
= ROP_NOTSRCCOPY
; break;
1803 wxFAIL_MSG( wxT("unsupported logical function") );
1812 // Blit bitmap with mask
1816 // Create a temp buffer bitmap and DCs/PSs to access it and the mask
1822 DEVOPENSTRUC vDOP
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
1823 BITMAPINFOHEADER2 vBmpHdr
;
1824 SIZEL vSize
= {0, 0};
1827 hDCMask
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
1828 hDCBuffer
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDOP
, NULLHANDLE
);
1829 hPSMask
= ::GpiCreatePS(vHabmain
, hDCMask
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
1830 hPSBuffer
= ::GpiCreatePS(vHabmain
, hDCBuffer
, &vSize
, PU_PELS
| GPIT_MICRO
| GPIA_ASSOC
);
1832 memset(&vBmpHdr
, 0, sizeof(BITMAPINFOHEADER2
));
1833 vBmpHdr
.cbFix
= sizeof(BITMAPINFOHEADER2
);
1834 vBmpHdr
.cx
= vWidth
;
1835 vBmpHdr
.cy
= vHeight
;
1836 vBmpHdr
.cPlanes
= 1;
1837 vBmpHdr
.cBitCount
= 24;
1839 HBITMAP hBufBitmap
= ::GpiCreateBitmap(GetHPS(), &vBmpHdr
, 0L, NULL
, NULL
);
1840 POINTL aPoint1
[4] = { 0, 0
1843 ,vXdest
+ vWidth
, vYdest
+ vHeight
1845 POINTL aPoint2
[4] = { 0, 0
1848 ,vXsrc
+ vWidth
, vYsrc
+ vHeight
1850 POINTL aPoint3
[4] = { vXdest
, vYdest
1851 ,vXdest
+ vWidth
, vYdest
+ vHeight
1853 ,vXsrc
+ vWidth
, vYsrc
+ vHeight
1855 POINTL aPoint4
[4] = { vXdest
, vYdest
1856 ,vXdest
+ vWidth
, vYdest
+ vHeight
1860 ::GpiSetBitmap(hPSMask
, (HBITMAP
) pMask
->GetMaskBitmap());
1861 ::GpiSetBitmap(hPSBuffer
, (HBITMAP
) hBufBitmap
);
1864 // Copy dest to buffer
1866 rc
= ::GpiBitBlt( hPSBuffer
1873 if (rc
== GPI_ERROR
)
1875 wxLogLastError(wxT("BitBlt"));
1879 // Copy src to buffer using selected raster op
1881 rc
= ::GpiBitBlt( hPSBuffer
1888 if (rc
== GPI_ERROR
)
1890 wxLogLastError(wxT("BitBlt"));
1894 // Set masked area in buffer to BLACK (pixel value 0)
1896 COLORREF vPrevBkCol
= ::GpiQueryBackColor(GetHPS());
1897 COLORREF vPrevCol
= ::GpiQueryColor(GetHPS());
1899 ::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
1900 ::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
1902 rc
= ::GpiBitBlt( hPSBuffer
1909 if (rc
== GPI_ERROR
)
1911 wxLogLastError(wxT("BitBlt"));
1915 // Set unmasked area in dest to BLACK
1917 ::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
1918 ::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
1919 rc
= ::GpiBitBlt( GetHPS()
1926 if (rc
== GPI_ERROR
)
1928 wxLogLastError(wxT("BitBlt"));
1932 // Restore colours to original values
1934 ::GpiSetBackColor(GetHPS(), vPrevBkCol
);
1935 ::GpiSetColor(GetHPS(), vPrevCol
);
1938 // OR buffer to dest
1940 rc
= ::GpiBitBlt( GetHPS()
1947 if (rc
== GPI_ERROR
)
1950 wxLogLastError(wxT("BitBlt"));
1954 // Tidy up temporary DCs and bitmap
1956 ::GpiSetBitmap(hPSMask
, NULLHANDLE
);
1957 ::GpiSetBitmap(hPSBuffer
, NULLHANDLE
);
1958 ::GpiDestroyPS(hPSMask
);
1959 ::GpiDestroyPS(hPSBuffer
);
1960 ::DevCloseDC(hDCMask
);
1961 ::DevCloseDC(hDCBuffer
);
1962 ::GpiDeleteBitmap(hBufBitmap
);
1965 else // no mask, just BitBlt() it
1967 POINTL aPoint
[4] = { vXdest
, vYdest
1968 ,vXdest
+ vWidth
, vYdest
+ vHeight
1970 ,vXsrc
+ vWidth
, vYsrc
+ vHeight
1973 bSuccess
= (::GpiBitBlt( m_hPS
1982 wxLogLastError(wxT("BitBlt"));
1985 vCbnd
.lColor
= (LONG
)vOldTextColor
;
1986 ::GpiSetAttrs( m_hPS
// presentation-space handle
1987 ,PRIM_CHAR
// Char primitive.
1988 ,CBB_COLOR
// sets color.
1990 ,&vCbnd
// buffer for attributes.
1992 ::GpiSetBackColor(m_hPS
, (LONG
)vOldBackground
);
1996 void wxDC::DoGetSize(
2001 LONG lArray
[CAPS_HEIGHT
];
2003 if(::DevQueryCaps( m_hDC
2009 *pnWidth
= lArray
[CAPS_WIDTH
];
2010 *pnHeight
= lArray
[CAPS_HEIGHT
];
2012 }; // end of wxDC::DoGetSize(
2014 void wxDC::DoGetSizeMM(
2019 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2021 if(::DevQueryCaps( m_hDC
2023 ,CAPS_VERTICAL_RESOLUTION
2032 nWidth
= lArray
[CAPS_WIDTH
];
2033 nHeight
= lArray
[CAPS_HEIGHT
];
2034 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2035 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2036 nWidth
= (nHorzRes
/1000) * nWidth
;
2037 nHeight
= (nVertRes
/1000) * nHeight
;
2039 }; // end of wxDC::DoGetSizeMM
2041 wxSize
wxDC::GetPPI() const
2043 LONG lArray
[CAPS_VERTICAL_RESOLUTION
];
2047 if(::DevQueryCaps( m_hDC
2049 ,CAPS_VERTICAL_RESOLUTION
2058 nPelWidth
= lArray
[CAPS_WIDTH
];
2059 nPelHeight
= lArray
[CAPS_HEIGHT
];
2060 nHorzRes
= lArray
[CAPS_HORIZONTAL_RESOLUTION
]; // returns pel/meter
2061 nVertRes
= lArray
[CAPS_VERTICAL_RESOLUTION
]; // returns pel/meter
2062 nWidth
= (nHorzRes
/39.3) * nPelWidth
;
2063 nHeight
= (nVertRes
/39.3) * nPelHeight
;
2065 return (wxSize(nWidth
,nHeight
));
2066 } // end of wxDC::GetPPI
2068 void wxDC::SetLogicalScale(
2073 m_logicalScaleX
= dX
;
2074 m_logicalScaleY
= dY
;
2075 }; // end of wxDC::SetLogicalScale
2077 #if WXWIN_COMPATIBILITY
2078 void wxDC::DoGetTextExtent(const wxString
& string
, float *x
, float *y
,
2079 float *descent
, float *externalLeading
,
2080 wxFont
*theFont
, bool use16bit
) const
2082 wxCoord x1
, y1
, descent1
, externalLeading1
;
2083 GetTextExtent(string
, & x1
, & y1
, & descent1
, & externalLeading1
, theFont
, use16bit
);
2086 *descent
= descent1
;
2087 if (externalLeading
)
2088 *externalLeading
= externalLeading1
;