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