]> git.saurik.com Git - wxWidgets.git/blame - src/x11/dc.cpp
added explicit casts for (varagr) TIFFSetField() parameters
[wxWidgets.git] / src / x11 / dc.cpp
CommitLineData
83df96d6
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.cpp
3// Purpose: wxDC class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
83df96d6
JS
10/////////////////////////////////////////////////////////////////////////////
11
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
83df96d6
JS
13 #pragma implementation "dc.h"
14#endif
15
16#include "wx/dc.h"
17#include "wx/dcmemory.h"
18#include "wx/defs.h"
19
bc797f4c 20IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
83df96d6 21
83df96d6
JS
22//-----------------------------------------------------------------------------
23// wxDC
24//-----------------------------------------------------------------------------
25
26wxDC::wxDC()
27{
28 m_ok = FALSE;
29
3cd0b8c5 30#if 1
83df96d6
JS
31 m_mm_to_pix_x = 1.0;
32 m_mm_to_pix_y = 1.0;
3cd0b8c5
RR
33#else
34 m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() /
35 (double)wxGetDisplaySizeMM().GetWidth();
36 m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
37 (double)wxGetDisplaySizeMM().GetHeight();
38#endif
83df96d6 39
3cd0b8c5
RR
40 m_needComputeScaleX = FALSE; /* not used yet */
41 m_needComputeScaleY = FALSE; /* not used yet */
83df96d6 42
3cd0b8c5 43 m_logicalFunction = wxCOPY;
83df96d6 44
3cd0b8c5
RR
45 m_pen = *wxBLACK_PEN;
46 m_font = *wxNORMAL_FONT;
47 m_brush = *wxWHITE_BRUSH;
83df96d6 48
3cd0b8c5 49 m_backgroundMode = wxTRANSPARENT;
83df96d6 50
3cd0b8c5 51 m_isInteractive = FALSE; // ???
83df96d6
JS
52}
53
54void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
55{
56 m_clipping = TRUE;
57 m_clipX1 = x;
58 m_clipY1 = y;
59 m_clipX2 = x + width;
60 m_clipY2 = y + height;
61}
62
83df96d6
JS
63void wxDC::DoGetSizeMM( int* width, int* height ) const
64{
65 int w, h;
66 GetSize( &w, &h );
67
68 if ( width )
69 *width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
70 if ( height )
71 *height = int( double(h) / (m_scaleY*m_mm_to_pix_y) );
72}
73
74// Resolution in pixels per logical inch
75wxSize wxDC::GetPPI() const
76{
77 // TODO (should probably be pure virtual)
78 return wxSize(0, 0);
79}
80
81void wxDC::SetMapMode( int mode )
82{
83 switch (mode)
84 {
85 case wxMM_TWIPS:
86 SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
87 break;
88 case wxMM_POINTS:
89 SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
90 break;
91 case wxMM_METRIC:
92 SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
93 break;
94 case wxMM_LOMETRIC:
95 SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
96 break;
97 default:
98 case wxMM_TEXT:
99 SetLogicalScale( 1.0, 1.0 );
100 break;
101 }
102 if (mode != wxMM_TEXT)
103 {
104 m_needComputeScaleX = TRUE;
105 m_needComputeScaleY = TRUE;
106 }
107}
108
109void wxDC::SetUserScale( double x, double y )
110{
111 // allow negative ? -> no
112 m_userScaleX = x;
113 m_userScaleY = y;
114 ComputeScaleAndOrigin();
115}
116
117void wxDC::SetLogicalScale( double x, double y )
118{
119 // allow negative ?
120 m_logicalScaleX = x;
121 m_logicalScaleY = y;
122 ComputeScaleAndOrigin();
123}
124
125void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
126{
127 m_logicalOriginX = x * m_signX; // is this still correct ?
128 m_logicalOriginY = y * m_signY;
129 ComputeScaleAndOrigin();
130}
131
132void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
133{
134 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
135 m_deviceOriginX = x;
136 m_deviceOriginY = y;
137 ComputeScaleAndOrigin();
138}
139
140void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
141{
142 m_signX = xLeftRight ? 1 : -1;
143 m_signY = yBottomUp ? -1 : 1;
144 ComputeScaleAndOrigin();
145}
146
147wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
148{
149 return ((wxDC *)this)->XDEV2LOG(x);
150}
151
152wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
153{
154 return ((wxDC *)this)->YDEV2LOG(y);
155}
156
157wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
158{
159 return ((wxDC *)this)->XDEV2LOGREL(x);
160}
161
162wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
163{
164 return ((wxDC *)this)->YDEV2LOGREL(y);
165}
166
167wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
168{
169 return ((wxDC *)this)->XLOG2DEV(x);
170}
171
172wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
173{
174 return ((wxDC *)this)->YLOG2DEV(y);
175}
176
177wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
178{
179 return ((wxDC *)this)->XLOG2DEVREL(x);
180}
181
182wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
183{
184 return ((wxDC *)this)->YLOG2DEVREL(y);
185}
186
187void wxDC::ComputeScaleAndOrigin()
188{
189 m_scaleX = m_logicalScaleX * m_userScaleX;
190 m_scaleY = m_logicalScaleY * m_userScaleY;
191}
192