]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
15 //-----------------------------------------------------------------------------
17 //-----------------------------------------------------------------------------
19 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxDCBase
)
25 m_mm_to_pix_x
= (double)wxGetDisplaySize().GetWidth() /
26 (double)wxGetDisplaySizeMM().GetWidth();
27 m_mm_to_pix_y
= (double)wxGetDisplaySize().GetHeight() /
28 (double)wxGetDisplaySizeMM().GetHeight();
30 m_needComputeScaleX
= FALSE
; /* not used yet */
31 m_needComputeScaleY
= FALSE
; /* not used yet */
33 m_logicalFunction
= wxCOPY
;
36 m_font
= *wxNORMAL_FONT
;
37 m_brush
= *wxWHITE_BRUSH
;
40 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
46 m_clipY2
= y
+ height
;
49 // ---------------------------------------------------------------------------
50 // get DC capabilities
51 // ---------------------------------------------------------------------------
53 void wxDC::DoGetSizeMM( int* width
, int* height
) const
58 if (width
) *width
= int( double(w
) / (m_userScaleX
*m_mm_to_pix_x
) );
59 if (height
) *height
= int( double(h
) / (m_userScaleY
*m_mm_to_pix_y
) );
62 // Resolution in pixels per logical inch
63 wxSize
wxDC::GetPPI() const
65 // TODO (should probably be pure virtual)
69 // ---------------------------------------------------------------------------
70 // set various DC parameters
71 // ---------------------------------------------------------------------------
73 void wxDC::ComputeScaleAndOrigin()
75 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
76 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
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 m_mappingMode
= mode
;
102 /* we don't do this mega optimisation
103 if (mode != wxMM_TEXT)
105 m_needComputeScaleX = TRUE;
106 m_needComputeScaleY = TRUE;
111 void wxDC::SetUserScale( double x
, double y
)
113 // allow negative ? -> no
116 ComputeScaleAndOrigin();
119 void wxDC::SetLogicalScale( double x
, double y
)
124 ComputeScaleAndOrigin();
127 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
129 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
130 m_logicalOriginY
= y
* m_signY
;
131 ComputeScaleAndOrigin();
134 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
136 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
139 ComputeScaleAndOrigin();
142 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
144 // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there
145 m_signX
= (xLeftRight
? 1 : -1);
146 m_signY
= (yBottomUp
? -1 : 1);
147 ComputeScaleAndOrigin();