]>
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 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
16 #include "wx/dcmemory.h"
19 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
32 m_backgroundMode
= wxTRANSPARENT
;
34 m_isInteractive
= false;
37 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
39 wxCHECK_RET( Ok(), "invalid dc" );
40 wxCHECK_RET( icon
.Ok(), "invalid icon" );
42 DoDrawBitmap(icon
, x
, y
, true);
45 void wxDC::DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
)
47 wxCHECK_RET( bitmap
.Ok(), "invalid bitmap" );
50 memDC
.SelectObject(bitmap
);
53 // Not sure if we need this. The mask should leave the masked areas as per
54 // the original background of this DC.
57 // There might be transparent areas, so make these the same colour as this
59 memDC
.SetBackground(* GetBackground());
64 Blit(x
, y
, bitmap
.GetWidth(), bitmap
.GetHeight(), &memDC
, 0, 0, wxCOPY
, useMask
);
66 memDC
.SelectObject(wxNullBitmap
);
69 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
75 m_clipY2
= y
+ height
;
78 void wxDC::DoGetSize( int* width
, int* height
) const
81 *width
= m_maxX
- m_minX
;
83 *height
= m_maxY
- m_minY
;
86 void wxDC::DoGetSizeMM( int* width
, int* height
) const
92 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
94 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
97 // Resolution in pixels per logical inch
98 wxSize
wxDC::GetPPI() const
100 // TODO (should probably be pure virtual)
104 void wxDC::SetMapMode( int mode
)
109 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
112 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
115 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
118 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
122 SetLogicalScale( 1.0, 1.0 );
125 if (mode
!= wxMM_TEXT
)
127 m_needComputeScaleX
= true;
128 m_needComputeScaleY
= true;
132 void wxDC::SetUserScale( double x
, double y
)
134 // allow negative ? -> no
137 ComputeScaleAndOrigin();
140 void wxDC::SetLogicalScale( double x
, double y
)
145 ComputeScaleAndOrigin();
148 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
150 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
151 m_logicalOriginY
= y
* m_signY
;
152 ComputeScaleAndOrigin();
155 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
157 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
160 ComputeScaleAndOrigin();
163 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
165 m_signX
= xLeftRight
? 1 : -1;
166 m_signY
= yBottomUp
? -1 : 1;
167 ComputeScaleAndOrigin();
170 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
172 return ((wxDC
*)this)->XDEV2LOG(x
);
175 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
177 return ((wxDC
*)this)->YDEV2LOG(y
);
180 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
182 return ((wxDC
*)this)->XDEV2LOGREL(x
);
185 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
187 return ((wxDC
*)this)->YDEV2LOGREL(y
);
190 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
192 return ((wxDC
*)this)->XLOG2DEV(x
);
195 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
197 return ((wxDC
*)this)->YLOG2DEV(y
);
200 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
202 return ((wxDC
*)this)->XLOG2DEVREL(x
);
205 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
207 return ((wxDC
*)this)->YLOG2DEVREL(y
);
210 void wxDC::ComputeScaleAndOrigin()
212 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
213 m_scaleY
= m_logicalScaleY
* m_userScaleY
;