Moved all the coordinate system calculation to wxDCBase
[wxWidgets.git] / src / gtk1 / dc.cpp
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 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #include "wx/dc.h"
14
15 #include <gdk/gdk.h>
16 #include <gtk/gtk.h>
17
18 //-----------------------------------------------------------------------------
19 // wxDC
20 //-----------------------------------------------------------------------------
21
22 IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase)
23
24 wxDC::wxDC()
25 {
26 m_ok = FALSE;
27
28 m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() /
29 (double)wxGetDisplaySizeMM().GetWidth();
30 m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
31 (double)wxGetDisplaySizeMM().GetHeight();
32
33 m_needComputeScaleX = FALSE; /* not used yet */
34 m_needComputeScaleY = FALSE; /* not used yet */
35
36 m_logicalFunction = wxCOPY;
37
38 m_pen = *wxBLACK_PEN;
39 m_font = *wxNORMAL_FONT;
40 m_brush = *wxWHITE_BRUSH;
41 }
42
43 void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
44 {
45 m_clipping = TRUE;
46 m_clipX1 = x;
47 m_clipY1 = y;
48 m_clipX2 = x + width;
49 m_clipY2 = y + height;
50 }
51
52 // ---------------------------------------------------------------------------
53 // get DC capabilities
54 // ---------------------------------------------------------------------------
55
56 void wxDC::DoGetSizeMM( int* width, int* height ) const
57 {
58 int w = 0;
59 int h = 0;
60 GetSize( &w, &h );
61 if (width) *width = int( double(w) / (m_userScaleX*m_mm_to_pix_x) );
62 if (height) *height = int( double(h) / (m_userScaleY*m_mm_to_pix_y) );
63 }
64
65 // Resolution in pixels per logical inch
66 wxSize wxDC::GetPPI() const
67 {
68 // TODO (should probably be pure virtual)
69 return wxSize(0, 0);
70 }
71