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