]>
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 //-----------------------------------------------------------------------------
34 m_mm_to_pix_x
= (double)wxGetDisplaySize().GetWidth() /
35 (double)wxGetDisplaySizeMM().GetWidth();
36 m_mm_to_pix_y
= (double)wxGetDisplaySize().GetHeight() /
37 (double)wxGetDisplaySizeMM().GetHeight();
40 m_needComputeScaleX
= FALSE
; /* not used yet */
41 m_needComputeScaleY
= FALSE
; /* not used yet */
43 m_logicalFunction
= wxCOPY
;
46 m_font
= *wxNORMAL_FONT
;
47 m_brush
= *wxWHITE_BRUSH
;
49 m_backgroundMode
= wxTRANSPARENT
;
51 m_isInteractive
= FALSE
; // ???
54 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
60 m_clipY2
= y
+ height
;
63 void wxDC::DoGetSizeMM( int* width
, int* height
) const
69 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
71 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
74 // Resolution in pixels per logical inch
75 wxSize
wxDC::GetPPI() const
77 // TODO (should probably be pure virtual)
81 void wxDC::SetMapMode( int mode
)
86 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
89 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
92 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
95 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
99 SetLogicalScale( 1.0, 1.0 );
102 if (mode
!= wxMM_TEXT
)
104 m_needComputeScaleX
= TRUE
;
105 m_needComputeScaleY
= TRUE
;
109 void wxDC::SetUserScale( double x
, double y
)
111 // allow negative ? -> no
114 ComputeScaleAndOrigin();
117 void wxDC::SetLogicalScale( double x
, double y
)
122 ComputeScaleAndOrigin();
125 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
127 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
128 m_logicalOriginY
= y
* m_signY
;
129 ComputeScaleAndOrigin();
132 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
134 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
137 ComputeScaleAndOrigin();
140 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
142 m_signX
= xLeftRight
? 1 : -1;
143 m_signY
= yBottomUp
? -1 : 1;
144 ComputeScaleAndOrigin();
147 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
149 return ((wxDC
*)this)->XDEV2LOG(x
);
152 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
154 return ((wxDC
*)this)->YDEV2LOG(y
);
157 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
159 return ((wxDC
*)this)->XDEV2LOGREL(x
);
162 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
164 return ((wxDC
*)this)->YDEV2LOGREL(y
);
167 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
169 return ((wxDC
*)this)->XLOG2DEV(x
);
172 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
174 return ((wxDC
*)this)->YLOG2DEV(y
);
177 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
179 return ((wxDC
*)this)->XLOG2DEVREL(x
);
182 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
184 return ((wxDC
*)this)->YLOG2DEVREL(y
);
187 void wxDC::ComputeScaleAndOrigin()
189 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
190 m_scaleY
= m_logicalScaleY
* m_userScaleY
;