]>
git.saurik.com Git - wxWidgets.git/blob - src/cocoa/dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dc.h"
17 #include "wx/bitmap.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 //-----------------------------------------------------------------------------
50 m_logicalScaleX
= 1.0;
51 m_logicalScaleY
= 1.0;
57 m_mappingMode
= wxMM_TEXT
;
59 m_signX
= 1; // default x-axis left to right
60 m_signY
= 1; // default y-axis top down
62 m_maxX
= m_maxY
= -100000;
63 m_minY
= m_minY
= 100000;
65 m_logicalFunction
= wxCOPY
;
66 // m_textAlignment = wxALIGN_TOP_LEFT;
67 m_backgroundMode
= wxTRANSPARENT
;
69 m_textForegroundColour
= *wxBLACK
;
70 m_textBackgroundColour
= *wxWHITE
;
72 m_font
= *wxNORMAL_FONT
;
73 m_brush
= *wxTRANSPARENT_BRUSH
;
74 m_backgroundBrush
= *wxWHITE_BRUSH
;
76 // m_palette = wxAPP_COLOURMAP;
83 void wxDC::DoDrawIcon( const wxIcon
&WXUNUSED(icon
), int WXUNUSED(x
), int WXUNUSED(y
) )
87 void wxDC::DoDrawPoint( int x
, int y
)
91 void wxDC::DoDrawPolygon( int, wxPoint
*, int, int, int)
95 void wxDC::DoDrawLines( int, wxPoint
*, int, int )
99 void wxDC::DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
103 int wxDC::GetDepth() const
108 wxSize
wxDC::GetPPI() const
113 bool wxDC::CanGetTextExtent() const
118 void wxDC::DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
, wxCoord
*descent
, wxCoord
*externalLeading
, wxFont
*theFont
) const
120 wxLogDebug("wxDC::DoGetTextExtent(%s)",string
.c_str());
131 wxCoord
wxDC::GetCharHeight() const
136 wxCoord
wxDC::GetCharWidth() const
141 bool wxDC::CanDrawBitmap() const
146 bool wxDC::DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
151 void wxDC::DoDrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord xc
, wxCoord yc
)
155 void wxDC::SetPen(const wxPen
& pen
)
159 void wxDC::SetBrush(const wxBrush
& brush
)
163 void wxDC::DoSetClippingRegionAsRegion(const wxRegion
& region
)
167 void wxDC::DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
171 void wxDC::DestroyClippingRegion()
175 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
179 void wxDC::DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
183 void wxDC::DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
, double sa
, double ea
)
187 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
191 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
195 void wxDC::DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
199 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
, int style
)
204 void wxDC::DoCrossHair(wxCoord x
, wxCoord y
)
208 void wxDC::DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
213 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
, wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
, bool useMask
, wxCoord xsrcMask
, wxCoord ysrcMask
)
218 void wxDC::DoGetSize( int* width
, int* height
) const
220 *width
= m_maxX
-m_minX
;
221 *height
= m_maxY
-m_minY
;
224 void wxDC::DoGetSizeMM( int* width
, int* height
) const
231 void wxDC::SetTextForeground( const wxColour
&col
)
234 m_textForegroundColour
= col
;
237 void wxDC::SetTextBackground( const wxColour
&col
)
240 m_textBackgroundColour
= col
;
247 void wxDC::SetBackground(const wxBrush
&)
251 void wxDC::SetPalette(const wxPalette
&)
255 void wxDC::SetLogicalFunction(int)
260 void wxDC::SetMapMode( int mode
)
274 SetLogicalScale( 1.0, 1.0 );
277 if (mode
!= wxMM_TEXT
)
282 void wxDC::SetUserScale( double x
, double y
)
284 // allow negative ? -> no
287 ComputeScaleAndOrigin();
290 void wxDC::SetLogicalScale( double x
, double y
)
295 ComputeScaleAndOrigin();
298 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
300 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
301 m_logicalOriginY
= y
* m_signY
;
302 ComputeScaleAndOrigin();
305 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
307 ComputeScaleAndOrigin();
310 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
312 m_signX
= (xLeftRight
? 1 : -1);
313 m_signY
= (yBottomUp
? -1 : 1);
314 ComputeScaleAndOrigin();
317 void wxDC::ComputeScaleAndOrigin(void)
319 // CMB: copy scale to see if it changes
320 double origScaleX
= m_scaleX
;
321 double origScaleY
= m_scaleY
;
323 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
324 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
326 // CMB: if scale has changed call SetPen to recalulate the line width
327 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
329 // this is a bit artificial, but we need to force wxDC to think
330 // the pen has changed
331 wxPen
* pen
= & GetPen();
338 int wxDCBase::DeviceToLogicalX(int x
) const
343 int wxDCBase::DeviceToLogicalY(int y
) const