]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dc.cpp
c6bd10e42507e314a96d920912236ca32dd9a3e0
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"
16 #include "wx/dcmemory.h"
18 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
31 m_backgroundMode
= wxTRANSPARENT
;
33 m_isInteractive
= false;
36 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
38 wxCHECK_RET( Ok(), "invalid dc" );
39 wxCHECK_RET( icon
.Ok(), "invalid icon" );
41 DoDrawBitmap(icon
, x
, y
, true);
44 void wxDC::DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
)
46 wxCHECK_RET( bitmap
.Ok(), "invalid bitmap" );
49 memDC
.SelectObject(bitmap
);
52 // Not sure if we need this. The mask should leave the masked areas as per
53 // the original background of this DC.
56 // There might be transparent areas, so make these the same colour as this
58 memDC
.SetBackground(* GetBackground());
63 Blit(x
, y
, bitmap
.GetWidth(), bitmap
.GetHeight(), &memDC
, 0, 0, wxCOPY
, useMask
);
65 memDC
.SelectObject(wxNullBitmap
);
68 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
74 m_clipY2
= y
+ height
;
77 void wxDC::DoGetSize( int* width
, int* height
) const
80 *width
= m_maxX
- m_minX
;
82 *height
= m_maxY
- m_minY
;
85 void wxDC::DoGetSizeMM( int* width
, int* height
) const
91 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
93 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
96 // Resolution in pixels per logical inch
97 wxSize
wxDC::GetPPI() const
99 // TODO (should probably be pure virtual)
103 void wxDC::SetMapMode( int mode
)
108 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
111 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
114 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
117 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
121 SetLogicalScale( 1.0, 1.0 );
124 if (mode
!= wxMM_TEXT
)
126 m_needComputeScaleX
= true;
127 m_needComputeScaleY
= true;
131 void wxDC::SetUserScale( double x
, double y
)
133 // allow negative ? -> no
136 ComputeScaleAndOrigin();
139 void wxDC::SetLogicalScale( double x
, double y
)
144 ComputeScaleAndOrigin();
147 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
149 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
150 m_logicalOriginY
= y
* m_signY
;
151 ComputeScaleAndOrigin();
154 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
156 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
159 ComputeScaleAndOrigin();
162 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
164 m_signX
= xLeftRight
? 1 : -1;
165 m_signY
= yBottomUp
? -1 : 1;
166 ComputeScaleAndOrigin();
169 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
171 return ((wxDC
*)this)->XDEV2LOG(x
);
174 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
176 return ((wxDC
*)this)->YDEV2LOG(y
);
179 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
181 return ((wxDC
*)this)->XDEV2LOGREL(x
);
184 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
186 return ((wxDC
*)this)->YDEV2LOGREL(y
);
189 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
191 return ((wxDC
*)this)->XLOG2DEV(x
);
194 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
196 return ((wxDC
*)this)->YLOG2DEV(y
);
199 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
201 return ((wxDC
*)this)->XLOG2DEVREL(x
);
204 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
206 return ((wxDC
*)this)->YLOG2DEVREL(y
);
209 void wxDC::ComputeScaleAndOrigin()
211 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
212 m_scaleY
= m_logicalScaleY
* m_userScaleY
;