]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dc.cpp
d43a7294b4b3723803c66b25eb68f17af335abb7
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Markus Holzem
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "dc.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 #define mm2inches 0.0393700787402
25 #define inches2mm 25.4
26 #define mm2twips 56.6929133859
27 #define twips2mm 0.0176388888889
28 #define mm2pt 2.83464566929
29 #define pt2mm 0.352777777778
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxDCBase
)
42 m_autoSetting
= FALSE
;
47 m_needComputeScaleX
= FALSE
; /* not used yet */
48 m_needComputeScaleY
= FALSE
; /* not used yet */
50 m_logicalFunction
= wxCOPY
;
53 m_font
= *wxNORMAL_FONT
;
54 m_brush
= *wxTRANSPARENT_BRUSH
;
57 void wxDC::DoSetClippingRegion( long x
, long y
, long width
, long height
)
63 m_clipY2
= y
+ height
;
66 void wxDC::DestroyClippingRegion()
71 // ---------------------------------------------------------------------------
72 // get DC capabilities
73 // ---------------------------------------------------------------------------
75 void wxDC::DoGetSize( int* width
, int* height
) const
77 if (width
) *width
= m_maxX
-m_minX
;
78 if (height
) *height
= m_maxY
-m_minY
;
81 void wxDC::DoGetSizeMM( int* width
, int* height
) const
86 if (width
) *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
87 if (height
) *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 // ---------------------------------------------------------------------------
98 // set various DC parameters
99 // ---------------------------------------------------------------------------
101 void wxDC::ComputeScaleAndOrigin()
103 // CMB: copy scale to see if it changes
104 double origScaleX
= m_scaleX
;
105 double origScaleY
= m_scaleY
;
107 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
108 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
110 // CMB: if scale has changed call SetPen to recalulate the line width
111 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
113 // this is a bit artificial, but we need to force wxDC to think
114 // the pen has changed
115 // It gives an Assert, Robert Roebling
124 void wxDC::SetMapMode( int mode
)
129 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
132 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
135 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
138 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
142 SetLogicalScale( 1.0, 1.0 );
145 /* we don't do this mega optimisation
146 if (mode != wxMM_TEXT)
148 m_needComputeScaleX = TRUE;
149 m_needComputeScaleY = TRUE;
154 void wxDC::SetUserScale( double x
, double y
)
156 // allow negative ? -> no
159 ComputeScaleAndOrigin();
162 void wxDC::SetLogicalScale( double x
, double y
)
167 ComputeScaleAndOrigin();
170 void wxDC::SetLogicalOrigin( long x
, long y
)
172 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
173 m_logicalOriginY
= y
* m_signY
;
174 ComputeScaleAndOrigin();
177 void wxDC::SetDeviceOrigin( long x
, long y
)
179 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
182 ComputeScaleAndOrigin();
185 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
187 // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there
188 m_signX
= (xLeftRight
? 1 : -1);
189 m_signY
= (yBottomUp
? -1 : 1);
190 ComputeScaleAndOrigin();
193 // ---------------------------------------------------------------------------
194 // coordinates transformations
195 // ---------------------------------------------------------------------------
197 long wxDCBase::DeviceToLogicalX(long x
) const
202 long wxDCBase::DeviceToLogicalY(long y
) const
207 long wxDCBase::DeviceToLogicalXRel(long x
) const
209 return XDEV2LOGREL(x
);
212 long wxDCBase::DeviceToLogicalYRel(long y
) const
214 return YDEV2LOGREL(y
);
217 long wxDCBase::LogicalToDeviceX(long x
) const
222 long wxDCBase::LogicalToDeviceY(long y
) const
227 long wxDCBase::LogicalToDeviceXRel(long x
) const
229 return XLOG2DEVREL(x
);
232 long wxDCBase::LogicalToDeviceYRel(long y
) const
234 return YLOG2DEVREL(y
);