]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dc.h"
17 #include "wx/dcmemory.h"
20 #if !USE_SHARED_LIBRARY
21 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 #define mm2inches 0.0393700787402
29 #define inches2mm 25.4
30 #define mm2twips 56.6929133859
31 #define twips2mm 0.0176388888889
32 #define mm2pt 2.83464566929
33 #define pt2mm 0.352777777778
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
46 m_backgroundMode
= wxTRANSPARENT
;
48 m_isInteractive
= FALSE
;
51 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
53 wxCHECK_RET( Ok(), "invalid dc" );
54 wxCHECK_RET( icon
.Ok(), "invalid icon" );
56 DoDrawBitmap(icon
, x
, y
, TRUE
);
59 void wxDC::DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
)
61 wxCHECK_RET( bitmap
.Ok(), "invalid bitmap" );
64 memDC
.SelectObject(bitmap
);
67 // Not sure if we need this. The mask should leave the masked areas as per
68 // the original background of this DC.
71 // There might be transparent areas, so make these the same colour as this
73 memDC
.SetBackground(* GetBackground());
78 Blit(x
, y
, bitmap
.GetWidth(), bitmap
.GetHeight(), &memDC
, 0, 0, wxCOPY
, useMask
);
80 memDC
.SelectObject(wxNullBitmap
);
83 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
89 m_clipY2
= y
+ height
;
92 void wxDC::DestroyClippingRegion()
97 void wxDC::DoGetSize( int* width
, int* height
) const
100 *width
= m_maxX
- m_minX
;
102 *height
= m_maxY
- m_minY
;
105 void wxDC::DoGetSizeMM( int* width
, int* height
) const
111 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
113 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
116 // Resolution in pixels per logical inch
117 wxSize
wxDC::GetPPI() const
119 // TODO (should probably be pure virtual)
123 void wxDC::SetMapMode( int mode
)
128 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
131 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
134 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
137 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
141 SetLogicalScale( 1.0, 1.0 );
144 if (mode
!= wxMM_TEXT
)
146 m_needComputeScaleX
= TRUE
;
147 m_needComputeScaleY
= TRUE
;
151 void wxDC::SetUserScale( double x
, double y
)
153 // allow negative ? -> no
156 ComputeScaleAndOrigin();
159 void wxDC::SetLogicalScale( double x
, double y
)
164 ComputeScaleAndOrigin();
167 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
169 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
170 m_logicalOriginY
= y
* m_signY
;
171 ComputeScaleAndOrigin();
174 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
176 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
179 ComputeScaleAndOrigin();
182 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
184 m_signX
= xLeftRight
? 1 : -1;
185 m_signY
= yBottomUp
? -1 : 1;
186 ComputeScaleAndOrigin();
189 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
191 return ((wxDC
*)this)->XDEV2LOG(x
);
194 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
196 return ((wxDC
*)this)->YDEV2LOG(y
);
199 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
201 return ((wxDC
*)this)->XDEV2LOGREL(x
);
204 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
206 return ((wxDC
*)this)->YDEV2LOGREL(y
);
209 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
211 return ((wxDC
*)this)->XLOG2DEV(x
);
214 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
216 return ((wxDC
*)this)->YLOG2DEV(y
);
219 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
221 return ((wxDC
*)this)->XLOG2DEVREL(x
);
224 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
226 return ((wxDC
*)this)->YLOG2DEVREL(y
);
229 void wxDC::ComputeScaleAndOrigin()
231 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
232 m_scaleY
= m_logicalScaleY
* m_userScaleY
;