]>
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::DestroyClippingRegion()
79 void wxDC::DoGetSizeMM( int* width
, int* height
) const
85 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
87 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
90 // Resolution in pixels per logical inch
91 wxSize
wxDC::GetPPI() const
93 // TODO (should probably be pure virtual)
97 void wxDC::SetMapMode( int mode
)
102 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
105 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
108 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
111 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
115 SetLogicalScale( 1.0, 1.0 );
118 if (mode
!= wxMM_TEXT
)
120 m_needComputeScaleX
= TRUE
;
121 m_needComputeScaleY
= TRUE
;
125 void wxDC::SetUserScale( double x
, double y
)
127 // allow negative ? -> no
130 ComputeScaleAndOrigin();
133 void wxDC::SetLogicalScale( double x
, double y
)
138 ComputeScaleAndOrigin();
141 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
143 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
144 m_logicalOriginY
= y
* m_signY
;
145 ComputeScaleAndOrigin();
148 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
150 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
153 ComputeScaleAndOrigin();
156 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
158 m_signX
= xLeftRight
? 1 : -1;
159 m_signY
= yBottomUp
? -1 : 1;
160 ComputeScaleAndOrigin();
163 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
165 return ((wxDC
*)this)->XDEV2LOG(x
);
168 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
170 return ((wxDC
*)this)->YDEV2LOG(y
);
173 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
175 return ((wxDC
*)this)->XDEV2LOGREL(x
);
178 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
180 return ((wxDC
*)this)->YDEV2LOGREL(y
);
183 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
185 return ((wxDC
*)this)->XLOG2DEV(x
);
188 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
190 return ((wxDC
*)this)->YLOG2DEV(y
);
193 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
195 return ((wxDC
*)this)->XLOG2DEVREL(x
);
198 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
200 return ((wxDC
*)this)->YLOG2DEVREL(y
);
203 void wxDC::ComputeScaleAndOrigin()
205 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
206 m_scaleY
= m_logicalScaleY
* m_userScaleY
;