]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "dc.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
20 #include "wx/dcmemory.h"
23 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
36 m_backgroundMode
= wxTRANSPARENT
;
38 m_isInteractive
= FALSE
;
41 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
43 wxCHECK_RET( Ok(), "invalid dc" );
44 wxCHECK_RET( icon
.Ok(), "invalid icon" );
46 DoDrawBitmap(icon
, x
, y
, TRUE
);
49 void wxDC::DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
)
51 wxCHECK_RET( bitmap
.Ok(), "invalid bitmap" );
54 memDC
.SelectObject(bitmap
);
57 // Not sure if we need this. The mask should leave the masked areas as per
58 // the original background of this DC.
61 // There might be transparent areas, so make these the same colour as this
63 memDC
.SetBackground(* GetBackground());
68 Blit(x
, y
, bitmap
.GetWidth(), bitmap
.GetHeight(), &memDC
, 0, 0, wxCOPY
, useMask
);
70 memDC
.SelectObject(wxNullBitmap
);
73 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
79 m_clipY2
= y
+ height
;
82 void wxDC::DoGetSize( int* width
, int* height
) const
85 *width
= m_maxX
- m_minX
;
87 *height
= m_maxY
- m_minY
;
90 void wxDC::DoGetSizeMM( int* width
, int* height
) const
96 *width
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
98 *height
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
101 // Resolution in pixels per logical inch
102 wxSize
wxDC::GetPPI() const
104 // TODO (should probably be pure virtual)
108 void wxDC::SetMapMode( int mode
)
113 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
116 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
119 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
122 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
126 SetLogicalScale( 1.0, 1.0 );
129 if (mode
!= wxMM_TEXT
)
131 m_needComputeScaleX
= TRUE
;
132 m_needComputeScaleY
= TRUE
;
136 void wxDC::SetUserScale( double x
, double y
)
138 // allow negative ? -> no
141 ComputeScaleAndOrigin();
144 void wxDC::SetLogicalScale( double x
, double y
)
149 ComputeScaleAndOrigin();
152 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
154 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
155 m_logicalOriginY
= y
* m_signY
;
156 ComputeScaleAndOrigin();
159 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
161 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
164 ComputeScaleAndOrigin();
167 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
169 m_signX
= xLeftRight
? 1 : -1;
170 m_signY
= yBottomUp
? -1 : 1;
171 ComputeScaleAndOrigin();
174 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
176 return ((wxDC
*)this)->XDEV2LOG(x
);
179 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
181 return ((wxDC
*)this)->YDEV2LOG(y
);
184 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
186 return ((wxDC
*)this)->XDEV2LOGREL(x
);
189 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
191 return ((wxDC
*)this)->YDEV2LOGREL(y
);
194 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
196 return ((wxDC
*)this)->XLOG2DEV(x
);
199 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
201 return ((wxDC
*)this)->YLOG2DEV(y
);
204 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
206 return ((wxDC
*)this)->XLOG2DEVREL(x
);
209 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
211 return ((wxDC
*)this)->YLOG2DEVREL(y
);
214 void wxDC::ComputeScaleAndOrigin()
216 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
217 m_scaleY
= m_logicalScaleY
* m_userScaleY
;