]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/dc.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
18 #include "wx/dcmemory.h"
21 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
34 m_backgroundMode
= wxTRANSPARENT
;
36 m_isInteractive
= false;
39 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
41 wxCHECK_RET( Ok(), "invalid dc" );
42 wxCHECK_RET( icon
.Ok(), "invalid icon" );
44 DoDrawBitmap(icon
, x
, y
, true);
47 void wxDC::DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
)
49 wxCHECK_RET( bitmap
.Ok(), "invalid bitmap" );
52 memDC
.SelectObject(bitmap
);
55 // Not sure if we need this. The mask should leave the masked areas as per
56 // the original background of this DC.
59 // There might be transparent areas, so make these the same colour as this
61 memDC
.SetBackground(* GetBackground());
66 Blit(x
, y
, bitmap
.GetWidth(), bitmap
.GetHeight(), &memDC
, 0, 0, wxCOPY
, useMask
);
68 memDC
.SelectObject(wxNullBitmap
);
71 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
77 m_clipY2
= y
+ height
;
80 void wxDC::DoGetSize( int* width
, int* height
) const
83 *width
= m_maxX
- m_minX
;
85 *height
= m_maxY
- m_minY
;
88 void wxDC::DoGetSizeMM( int* width
, int* height
) const
94 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
96 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
99 // Resolution in pixels per logical inch
100 wxSize
wxDC::GetPPI() const
102 // TODO (should probably be pure virtual)
106 void wxDC::SetMapMode( int mode
)
111 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
114 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
117 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
120 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
124 SetLogicalScale( 1.0, 1.0 );
127 if (mode
!= wxMM_TEXT
)
129 m_needComputeScaleX
= true;
130 m_needComputeScaleY
= true;
134 void wxDC::SetUserScale( double x
, double y
)
136 // allow negative ? -> no
139 ComputeScaleAndOrigin();
142 void wxDC::SetLogicalScale( double x
, double y
)
147 ComputeScaleAndOrigin();
150 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
152 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
153 m_logicalOriginY
= y
* m_signY
;
154 ComputeScaleAndOrigin();
157 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
159 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
162 ComputeScaleAndOrigin();
165 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
167 m_signX
= xLeftRight
? 1 : -1;
168 m_signY
= yBottomUp
? -1 : 1;
169 ComputeScaleAndOrigin();
172 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
174 return ((wxDC
*)this)->XDEV2LOG(x
);
177 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
179 return ((wxDC
*)this)->YDEV2LOG(y
);
182 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
184 return ((wxDC
*)this)->XDEV2LOGREL(x
);
187 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
189 return ((wxDC
*)this)->YDEV2LOGREL(y
);
192 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
194 return ((wxDC
*)this)->XLOG2DEV(x
);
197 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
199 return ((wxDC
*)this)->YLOG2DEV(y
);
202 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
204 return ((wxDC
*)this)->XLOG2DEVREL(x
);
207 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
209 return ((wxDC
*)this)->YLOG2DEVREL(y
);
212 void wxDC::ComputeScaleAndOrigin()
214 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
215 m_scaleY
= m_logicalScaleY
* m_userScaleY
;