]>
git.saurik.com Git - wxWidgets.git/blob - src/x11/dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "dc.h"
17 #include "wx/dcmemory.h"
20 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 //-----------------------------------------------------------------------------
45 m_mm_to_pix_x
= (double)wxGetDisplaySize().GetWidth() /
46 (double)wxGetDisplaySizeMM().GetWidth();
47 m_mm_to_pix_y
= (double)wxGetDisplaySize().GetHeight() /
48 (double)wxGetDisplaySizeMM().GetHeight();
51 m_needComputeScaleX
= FALSE
; /* not used yet */
52 m_needComputeScaleY
= FALSE
; /* not used yet */
54 m_logicalFunction
= wxCOPY
;
57 m_font
= *wxNORMAL_FONT
;
58 m_brush
= *wxWHITE_BRUSH
;
60 m_backgroundMode
= wxTRANSPARENT
;
62 m_isInteractive
= FALSE
; // ???
65 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
71 m_clipY2
= y
+ height
;
74 void wxDC::DoGetSizeMM( int* width
, int* height
) const
80 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
82 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
85 // Resolution in pixels per logical inch
86 wxSize
wxDC::GetPPI() const
88 // TODO (should probably be pure virtual)
92 void wxDC::SetMapMode( int mode
)
97 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
100 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
103 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
106 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
110 SetLogicalScale( 1.0, 1.0 );
113 if (mode
!= wxMM_TEXT
)
115 m_needComputeScaleX
= TRUE
;
116 m_needComputeScaleY
= TRUE
;
120 void wxDC::SetUserScale( double x
, double y
)
122 // allow negative ? -> no
125 ComputeScaleAndOrigin();
128 void wxDC::SetLogicalScale( double x
, double y
)
133 ComputeScaleAndOrigin();
136 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
138 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
139 m_logicalOriginY
= y
* m_signY
;
140 ComputeScaleAndOrigin();
143 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
145 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
148 ComputeScaleAndOrigin();
151 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
153 m_signX
= xLeftRight
? 1 : -1;
154 m_signY
= yBottomUp
? -1 : 1;
155 ComputeScaleAndOrigin();
158 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
160 return ((wxDC
*)this)->XDEV2LOG(x
);
163 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
165 return ((wxDC
*)this)->YDEV2LOG(y
);
168 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
170 return ((wxDC
*)this)->XDEV2LOGREL(x
);
173 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
175 return ((wxDC
*)this)->YDEV2LOGREL(y
);
178 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
180 return ((wxDC
*)this)->XLOG2DEV(x
);
183 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
185 return ((wxDC
*)this)->YLOG2DEV(y
);
188 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
190 return ((wxDC
*)this)->XLOG2DEVREL(x
);
193 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
195 return ((wxDC
*)this)->YLOG2DEVREL(y
);
198 void wxDC::ComputeScaleAndOrigin()
200 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
201 m_scaleY
= m_logicalScaleY
* m_userScaleY
;