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