]>
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 /////////////////////////////////////////////////////////////////////////////
13 #include "wx/dcmemory.h"
16 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
30 m_mm_to_pix_x
= (double)wxGetDisplaySize().GetWidth() /
31 (double)wxGetDisplaySizeMM().GetWidth();
32 m_mm_to_pix_y
= (double)wxGetDisplaySize().GetHeight() /
33 (double)wxGetDisplaySizeMM().GetHeight();
36 m_needComputeScaleX
= FALSE
; /* not used yet */
37 m_needComputeScaleY
= FALSE
; /* not used yet */
39 m_logicalFunction
= wxCOPY
;
42 m_font
= *wxNORMAL_FONT
;
43 m_brush
= *wxWHITE_BRUSH
;
45 m_backgroundMode
= wxTRANSPARENT
;
47 m_isInteractive
= FALSE
; // ???
50 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
56 m_clipY2
= y
+ height
;
59 void wxDC::DoGetSizeMM( int* width
, int* height
) const
65 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
67 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
70 // Resolution in pixels per logical inch
71 wxSize
wxDC::GetPPI() const
73 // TODO (should probably be pure virtual)
77 void wxDC::SetMapMode( int mode
)
82 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
85 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
88 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
91 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
95 SetLogicalScale( 1.0, 1.0 );
98 if (mode
!= wxMM_TEXT
)
100 m_needComputeScaleX
= TRUE
;
101 m_needComputeScaleY
= TRUE
;
105 void wxDC::SetUserScale( double x
, double y
)
107 // allow negative ? -> no
110 ComputeScaleAndOrigin();
113 void wxDC::SetLogicalScale( double x
, double y
)
118 ComputeScaleAndOrigin();
121 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
123 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
124 m_logicalOriginY
= y
* m_signY
;
125 ComputeScaleAndOrigin();
128 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
130 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
133 ComputeScaleAndOrigin();
136 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
138 m_signX
= xLeftRight
? 1 : -1;
139 m_signY
= yBottomUp
? -1 : 1;
140 ComputeScaleAndOrigin();
143 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
145 return ((wxDC
*)this)->XDEV2LOG(x
);
148 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
150 return ((wxDC
*)this)->YDEV2LOG(y
);
153 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
155 return ((wxDC
*)this)->XDEV2LOGREL(x
);
158 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
160 return ((wxDC
*)this)->YDEV2LOGREL(y
);
163 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
165 return ((wxDC
*)this)->XLOG2DEV(x
);
168 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
170 return ((wxDC
*)this)->YLOG2DEV(y
);
173 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
175 return ((wxDC
*)this)->XLOG2DEVREL(x
);
178 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
180 return ((wxDC
*)this)->YLOG2DEVREL(y
);
183 void wxDC::ComputeScaleAndOrigin()
185 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
186 m_scaleY
= m_logicalScaleY
* m_userScaleY
;