]>
git.saurik.com Git - wxWidgets.git/blob - src/x11/dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/dc.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
16 #include "wx/dcmemory.h"
18 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
32 m_mm_to_pix_x
= (double)wxGetDisplaySize().GetWidth() /
33 (double)wxGetDisplaySizeMM().GetWidth();
34 m_mm_to_pix_y
= (double)wxGetDisplaySize().GetHeight() /
35 (double)wxGetDisplaySizeMM().GetHeight();
38 m_needComputeScaleX
= false; /* not used yet */
39 m_needComputeScaleY
= false; /* not used yet */
41 m_logicalFunction
= wxCOPY
;
44 m_font
= *wxNORMAL_FONT
;
45 m_brush
= *wxWHITE_BRUSH
;
47 m_backgroundMode
= wxTRANSPARENT
;
49 m_isInteractive
= false; // ???
52 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
58 m_clipY2
= y
+ height
;
61 void wxDC::DoGetSizeMM( int* width
, int* height
) const
67 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
69 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
72 // Resolution in pixels per logical inch
73 wxSize
wxDC::GetPPI() const
75 // TODO (should probably be pure virtual)
79 void wxDC::SetMapMode( int mode
)
84 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
87 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
90 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
93 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
97 SetLogicalScale( 1.0, 1.0 );
100 if (mode
!= wxMM_TEXT
)
102 m_needComputeScaleX
= true;
103 m_needComputeScaleY
= true;
107 void wxDC::SetUserScale( double x
, double y
)
109 // allow negative ? -> no
112 ComputeScaleAndOrigin();
115 void wxDC::SetLogicalScale( double x
, double y
)
120 ComputeScaleAndOrigin();
123 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
125 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
126 m_logicalOriginY
= y
* m_signY
;
127 ComputeScaleAndOrigin();
130 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
132 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
135 ComputeScaleAndOrigin();
138 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
140 m_signX
= xLeftRight
? 1 : -1;
141 m_signY
= yBottomUp
? -1 : 1;
142 ComputeScaleAndOrigin();
145 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
147 return ((wxDC
*)this)->XDEV2LOG(x
);
150 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
152 return ((wxDC
*)this)->YDEV2LOG(y
);
155 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
157 return ((wxDC
*)this)->XDEV2LOGREL(x
);
160 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
162 return ((wxDC
*)this)->YDEV2LOGREL(y
);
165 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
167 return ((wxDC
*)this)->XLOG2DEV(x
);
170 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
172 return ((wxDC
*)this)->YLOG2DEV(y
);
175 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
177 return ((wxDC
*)this)->XLOG2DEVREL(x
);
180 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
182 return ((wxDC
*)this)->YLOG2DEVREL(y
);
185 void wxDC::ComputeScaleAndOrigin()
187 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
188 m_scaleY
= m_logicalScaleY
* m_userScaleY
;