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