]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/dc.cpp
00b3fafcb5816656ab2f8e01acd73b040d62e60b
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
12 #pragma implementation "dc.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxDCBase
)
33 m_mm_to_pix_x
= (double)wxGetDisplaySize().GetWidth() /
34 (double)wxGetDisplaySizeMM().GetWidth();
35 m_mm_to_pix_y
= (double)wxGetDisplaySize().GetHeight() /
36 (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
;
48 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
54 m_clipY2
= y
+ height
;
57 // ---------------------------------------------------------------------------
58 // get DC capabilities
59 // ---------------------------------------------------------------------------
61 void wxDC::DoGetSizeMM( int* width
, int* height
) const
66 if (width
) *width
= int( double(w
) / (m_userScaleX
*m_mm_to_pix_x
) );
67 if (height
) *height
= int( double(h
) / (m_userScaleY
*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 // ---------------------------------------------------------------------------
78 // set various DC parameters
79 // ---------------------------------------------------------------------------
81 void wxDC::ComputeScaleAndOrigin()
83 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
84 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
87 void wxDC::SetMapMode( int mode
)
92 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
95 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
98 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
101 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
105 SetLogicalScale( 1.0, 1.0 );
108 m_mappingMode
= mode
;
110 /* we don't do this mega optimisation
111 if (mode != wxMM_TEXT)
113 m_needComputeScaleX = TRUE;
114 m_needComputeScaleY = TRUE;
119 void wxDC::SetUserScale( double x
, double y
)
121 // allow negative ? -> no
124 ComputeScaleAndOrigin();
127 void wxDC::SetLogicalScale( double x
, double y
)
132 ComputeScaleAndOrigin();
135 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
137 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
138 m_logicalOriginY
= y
* m_signY
;
139 ComputeScaleAndOrigin();
142 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
144 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
147 ComputeScaleAndOrigin();
150 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
152 // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there
153 m_signX
= (xLeftRight
? 1 : -1);
154 m_signY
= (yBottomUp
? -1 : 1);
155 ComputeScaleAndOrigin();
158 // ---------------------------------------------------------------------------
159 // coordinates transformations
160 // ---------------------------------------------------------------------------
162 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
164 return ((wxDC
*)this)->XDEV2LOG(x
);
167 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
169 return ((wxDC
*)this)->YDEV2LOG(y
);
172 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
174 return ((wxDC
*)this)->XDEV2LOGREL(x
);
177 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
179 return ((wxDC
*)this)->YDEV2LOGREL(y
);
182 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
184 return ((wxDC
*)this)->XLOG2DEV(x
);
187 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
189 return ((wxDC
*)this)->YLOG2DEV(y
);
192 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
194 return ((wxDC
*)this)->XLOG2DEVREL(x
);
197 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
199 return ((wxDC
*)this)->YLOG2DEVREL(y
);