]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dc.h"
18 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 #define mm2inches 0.0393700787402
27 #define inches2mm 25.4
28 #define mm2twips 56.6929133859
29 #define twips2mm 0.0176388888889
30 #define mm2pt 2.83464566929
31 #define pt2mm 0.352777777778
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 long wxDCBase::DeviceToLogicalX(long x
) const
39 long new_x
= x
- m_deviceOriginX
;
41 return (long)((double)(new_x
) / m_scaleX
+ 0.5) * m_signX
+ m_logicalOriginX
;
43 return (long)((double)(new_x
) / m_scaleX
- 0.5) * m_signX
+ m_logicalOriginX
;
46 long wxDCBase::DeviceToLogicalY(long y
) const
48 long new_y
= y
- m_deviceOriginY
;
50 return (long)((double)(new_y
) / m_scaleY
+ 0.5) * m_signY
+ m_logicalOriginY
;
52 return (long)((double)(new_y
) / m_scaleY
- 0.5) * m_signY
+ m_logicalOriginY
;
55 long wxDCBase::DeviceToLogicalXRel(long x
) const
58 return (long)((double)(x
) / m_scaleX
+ 0.5);
60 return (long)((double)(x
) / m_scaleX
- 0.5);
63 long wxDCBase::DeviceToLogicalYRel(long y
) const
66 return (long)((double)(y
) / m_scaleY
+ 0.5);
68 return (long)((double)(y
) / m_scaleY
- 0.5);
71 long wxDCBase::LogicalToDeviceX(long x
) const
73 long new_x
= x
- m_logicalOriginX
;
75 return (long)((double)(new_x
) * m_scaleX
+ 0.5) * m_signX
+ m_deviceOriginX
;
77 return (long)((double)(new_x
) * m_scaleX
- 0.5) * m_signX
+ m_deviceOriginX
;
80 long wxDCBase::LogicalToDeviceY(long y
) const
82 long new_y
= y
- m_logicalOriginY
;
84 return (long)((double)(new_y
) * m_scaleY
+ 0.5) * m_signY
+ m_deviceOriginY
;
86 return (long)((double)(new_y
) * m_scaleY
- 0.5) * m_signY
+ m_deviceOriginY
;
89 long wxDCBase::LogicalToDeviceXRel(long x
) const
92 return (long)((double)(x
) * m_scaleX
+ 0.5);
94 return (long)((double)(x
) * m_scaleX
- 0.5);
97 long wxDCBase::LogicalToDeviceYRel(long y
) const
100 return (long)((double)(y
) * m_scaleY
+ 0.5);
102 return (long)((double)(y
) * m_scaleY
- 0.5);
105 //-----------------------------------------------------------------------------
107 //-----------------------------------------------------------------------------
129 void wxDC::DestroyClippingRegion(void)
134 void wxDC::DoGetSize( int* width
, int* height
) const
139 void wxDC::DoGetSizeMM( int* width
, int* height
) const
144 void wxDC::SetMapMode( int mode
)
149 void wxDC::SetUserScale( double x
, double y
)
154 SetMapMode(m_mappingMode
);
157 void wxDC::SetLogicalScale( double x
, double y
)
162 void wxDC::SetLogicalOrigin( long x
, long y
)
167 void wxDC::SetDeviceOrigin( long x
, long y
)
172 void wxDC::SetInternalDeviceOrigin( long x
, long y
)
177 void wxDC::GetInternalDeviceOrigin( long *x
, long *y
)
182 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
188 int wxDC::GetDepth() const
194 wxSize
wxDC::GetPPI() const
199 return (wxSize(x
,y
));
201 void wxDC::GetTextExtent( const wxString
& string
205 ,long* externalLeading
212 long wxDC::GetCharWidth() const
218 long wxDC::GetCharHeight() const
229 void wxDC::SetFont(const wxFont
& font
)
234 void wxDC::SetPen(const wxPen
& pen
)
238 void wxDC::SetBrush(const wxBrush
& brush
)
243 void wxDC::SetBackground(const wxBrush
& brush
)
248 void wxDC::SetLogicalFunction(int function
)
253 void wxDC::SetBackgroundMode(int mode
)
258 void wxDC::SetPalette(const wxPalette
& palette
)
263 void wxDC::DoFloodFill( long x
272 bool wxDC::DoGetPixel(long x
, long y
, wxColour
*col
) const
278 void wxDC::DoDrawPoint(long x
, long y
)
283 void wxDC::DoDrawLine(long x1
, long y1
, long x2
, long y2
)
288 void wxDC::DoDrawArc( long x1
, long y1
296 void wxDC::DoDrawEllipticArc( long x
307 void wxDC::DoDrawRectangle(long x
, long y
, long width
, long height
)
312 void wxDC::DoDrawRoundedRectangle( long x
, long y
313 ,long width
, long height
320 void wxDC::DoDrawEllipse(long x
, long y
, long width
, long height
)
325 void wxDC::DoCrossHair(long x
, long y
)
330 void wxDC::DoDrawIcon(const wxIcon
& icon
, long x
, long y
)
335 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
343 void wxDC::DoDrawText(const wxString
& text
, long x
, long y
)
348 bool wxDC::DoBlit( long xdest
363 void wxDC::DoDrawLines( int n
, wxPoint points
[]
364 ,long xoffset
, long yoffset
370 void wxDC::DoDrawPolygon(int n
, wxPoint points
[]
371 ,long xoffset
, long yoffset
378 void wxDC::DoSetClippingRegionAsRegion(const wxRegion
& region
)
383 void wxDC::DoSetClippingRegion( long x
, long y
384 ,long width
, long height
391 void wxDC::DoDrawSpline(wxList
*points
)
397 void wxDC::SetRop(WXHDC dc
)
399 if (!dc
|| m_logicalFunction
< 0)
403 // These may be wrong
404 switch (m_logicalFunction
)
406 // TODO: Figure this stuff out
407 // case wxXOR: c_rop = R2_XORPEN; break;
408 // case wxXOR: c_rop = R2_NOTXORPEN; break;
409 // case wxINVERT: c_rop = R2_NOT; break;
410 // case wxOR_REVERSE: c_rop = R2_MERGEPENNOT; break;
411 // case wxAND_REVERSE: c_rop = R2_MASKPENNOT; break;
412 // case wxCLEAR: c_rop = R2_WHITE; break;
413 // case wxSET: c_rop = R2_BLACK; break;
414 // case wxSRC_INVERT: c_rop = R2_NOTCOPYPEN; break;
415 // case wxOR_INVERT: c_rop = R2_MERGENOTPEN; break;
416 // case wxAND: c_rop = R2_MASKPEN; break;
417 // case wxOR: c_rop = R2_MERGEPEN; break;
418 // case wxAND_INVERT: c_rop = R2_MASKNOTPEN; break;
423 // c_rop = R2_COPYPEN;
426 // SetROP2((HDC) dc, c_rop);
429 void wxDC::DoClipping(WXHDC dc
)
431 if (m_clipping
&& dc
)
434 // IntersectClipRect((HDC) dc, XLOG2DEV(m_clipX1), YLOG2DEV(m_clipY1),
435 // XLOG2DEV(m_clipX2), YLOG2DEV(m_clipY2));
439 // This will select current objects out of the DC,
440 // which is what you have to do before deleting the
442 void wxDC::SelectOldObjects(WXHDC dc
)
448 // ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap);
449 if (m_selectedBitmap
.Ok())
451 m_selectedBitmap
.SetSelectedInto(NULL
);
457 // ::SelectObject((HDC) dc, (HPEN) m_oldPen);
462 // ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush);
467 // ::SelectObject((HDC) dc, (HFONT) m_oldFont);
472 // ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
477 m_brush
= wxNullBrush
;
479 m_palette
= wxNullPalette
;
481 m_backgroundBrush
= wxNullBrush
;
482 m_selectedBitmap
= wxNullBitmap
;