]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dc.h
Added C/wxString array constructors to wxArrayString
[wxWidgets.git] / include / wx / gtk / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dc.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10
11 #ifndef __GTKDCH__
12 #define __GTKDCH__
13
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 #pragma interface
16 #endif
17
18 //-----------------------------------------------------------------------------
19 // classes
20 //-----------------------------------------------------------------------------
21
22 class wxDC;
23
24 //-----------------------------------------------------------------------------
25 // constants
26 //-----------------------------------------------------------------------------
27
28 #ifndef MM_TEXT
29 #define MM_TEXT 0
30 #define MM_ISOTROPIC 1
31 #define MM_ANISOTROPIC 2
32 #define MM_LOMETRIC 3
33 #define MM_HIMETRIC 4
34 #define MM_TWIPS 5
35 #define MM_POINTS 6
36 #define MM_METRIC 7
37 #endif
38
39 //-----------------------------------------------------------------------------
40 // wxDC
41 //-----------------------------------------------------------------------------
42
43 class wxDC : public wxDCBase
44 {
45 public:
46 wxDC();
47 ~wxDC() { }
48
49 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); };
50
51 // Resolution in pixels per logical inch
52 virtual wxSize GetPPI() const;
53
54 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
55 virtual void EndDoc() { }
56 virtual void StartPage() { }
57 virtual void EndPage() { }
58
59 virtual void SetMapMode( int mode );
60 virtual void SetUserScale( double x, double y );
61 virtual void SetLogicalScale( double x, double y );
62 virtual void SetLogicalOrigin( wxCoord x, wxCoord y );
63 virtual void SetDeviceOrigin( wxCoord x, wxCoord y );
64
65 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
66
67 // implementation
68 // --------------
69
70 virtual void ComputeScaleAndOrigin();
71
72 wxCoord XDEV2LOG(wxCoord x) const
73 {
74 wxCoord new_x = x - m_deviceOriginX;
75 if (new_x > 0)
76 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
77 else
78 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
79 }
80 wxCoord XDEV2LOGREL(wxCoord x) const
81 {
82 if (x > 0)
83 return (wxCoord)((double)(x) / m_scaleX + 0.5);
84 else
85 return (wxCoord)((double)(x) / m_scaleX - 0.5);
86 }
87 wxCoord YDEV2LOG(wxCoord y) const
88 {
89 wxCoord new_y = y - m_deviceOriginY;
90 if (new_y > 0)
91 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
92 else
93 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
94 }
95 wxCoord YDEV2LOGREL(wxCoord y) const
96 {
97 if (y > 0)
98 return (wxCoord)((double)(y) / m_scaleY + 0.5);
99 else
100 return (wxCoord)((double)(y) / m_scaleY - 0.5);
101 }
102 wxCoord XLOG2DEV(wxCoord x) const
103 {
104 wxCoord new_x = x - m_logicalOriginX;
105 if (new_x > 0)
106 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
107 else
108 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
109 }
110 wxCoord XLOG2DEVREL(wxCoord x) const
111 {
112 if (x > 0)
113 return (wxCoord)((double)(x) * m_scaleX + 0.5);
114 else
115 return (wxCoord)((double)(x) * m_scaleX - 0.5);
116 }
117 wxCoord YLOG2DEV(wxCoord y) const
118 {
119 wxCoord new_y = y - m_logicalOriginY;
120 if (new_y > 0)
121 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
122 else
123 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
124 }
125 wxCoord YLOG2DEVREL(wxCoord y) const
126 {
127 if (y > 0)
128 return (wxCoord)((double)(y) * m_scaleY + 0.5);
129 else
130 return (wxCoord)((double)(y) * m_scaleY - 0.5);
131 }
132
133 protected:
134 // base class pure virtuals implemented here
135 virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
136 virtual void DoGetSizeMM(int* width, int* height) const;
137
138 public:
139 // GTK-specific member variables
140
141 // not sure what for, but what is a mm on a screen you don't know the size
142 // of?
143 double m_mm_to_pix_x,
144 m_mm_to_pix_y;
145
146 bool m_needComputeScaleX,
147 m_needComputeScaleY; // not yet used
148
149
150 private:
151 DECLARE_ABSTRACT_CLASS(wxDC)
152 };
153
154 // this must be defined when wxDC::Blit() honours the DC origian and needed to
155 // allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK
156 // 2.3.[23]
157 #ifndef wxHAS_WORKING_GTK_DC_BLIT
158 #define wxHAS_WORKING_GTK_DC_BLIT
159 #endif
160
161 #endif // __GTKDCH__