| 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 | #ifdef __GNUG__ |
| 15 | #pragma interface |
| 16 | #endif |
| 17 | |
| 18 | //----------------------------------------------------------------------------- |
| 19 | // classes |
| 20 | //----------------------------------------------------------------------------- |
| 21 | |
| 22 | class wxDC; |
| 23 | |
| 24 | //----------------------------------------------------------------------------- |
| 25 | // constants |
| 26 | //----------------------------------------------------------------------------- |
| 27 | |
| 28 | #define MM_TEXT 0 |
| 29 | #define MM_ISOTROPIC 1 |
| 30 | #define MM_ANISOTROPIC 2 |
| 31 | #define MM_LOMETRIC 3 |
| 32 | #define MM_HIMETRIC 4 |
| 33 | #define MM_TWIPS 5 |
| 34 | #define MM_POINTS 6 |
| 35 | #define MM_METRIC 7 |
| 36 | |
| 37 | //----------------------------------------------------------------------------- |
| 38 | // wxDC |
| 39 | //----------------------------------------------------------------------------- |
| 40 | |
| 41 | class wxDC : public wxDCBase |
| 42 | { |
| 43 | public: |
| 44 | wxDC(); |
| 45 | ~wxDC() { } |
| 46 | |
| 47 | void SetColourMap( const wxPalette& palette ) { SetPalette(palette); }; |
| 48 | |
| 49 | // the first two must be overridden and called |
| 50 | virtual void DestroyClippingRegion(); |
| 51 | |
| 52 | // Resolution in pixels per logical inch |
| 53 | virtual wxSize GetPPI() const; |
| 54 | |
| 55 | virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; } |
| 56 | virtual void EndDoc() { } |
| 57 | virtual void StartPage() { } |
| 58 | virtual void EndPage() { } |
| 59 | |
| 60 | virtual void SetMapMode( int mode ); |
| 61 | virtual void SetUserScale( double x, double y ); |
| 62 | virtual void SetLogicalScale( double x, double y ); |
| 63 | virtual void SetLogicalOrigin( wxCoord x, wxCoord y ); |
| 64 | virtual void SetDeviceOrigin( wxCoord x, wxCoord y ); |
| 65 | |
| 66 | virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); |
| 67 | |
| 68 | // implementation |
| 69 | // -------------- |
| 70 | |
| 71 | virtual void ComputeScaleAndOrigin(); |
| 72 | |
| 73 | wxCoord XDEV2LOG(wxCoord x) const |
| 74 | { |
| 75 | wxCoord new_x = x - m_deviceOriginX; |
| 76 | if (new_x > 0) |
| 77 | return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; |
| 78 | else |
| 79 | return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; |
| 80 | } |
| 81 | wxCoord XDEV2LOGREL(wxCoord x) const |
| 82 | { |
| 83 | if (x > 0) |
| 84 | return (wxCoord)((double)(x) / m_scaleX + 0.5); |
| 85 | else |
| 86 | return (wxCoord)((double)(x) / m_scaleX - 0.5); |
| 87 | } |
| 88 | wxCoord YDEV2LOG(wxCoord y) const |
| 89 | { |
| 90 | wxCoord new_y = y - m_deviceOriginY; |
| 91 | if (new_y > 0) |
| 92 | return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; |
| 93 | else |
| 94 | return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; |
| 95 | } |
| 96 | wxCoord YDEV2LOGREL(wxCoord y) const |
| 97 | { |
| 98 | if (y > 0) |
| 99 | return (wxCoord)((double)(y) / m_scaleY + 0.5); |
| 100 | else |
| 101 | return (wxCoord)((double)(y) / m_scaleY - 0.5); |
| 102 | } |
| 103 | wxCoord XLOG2DEV(wxCoord x) const |
| 104 | { |
| 105 | wxCoord new_x = x - m_logicalOriginX; |
| 106 | if (new_x > 0) |
| 107 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; |
| 108 | else |
| 109 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; |
| 110 | } |
| 111 | wxCoord XLOG2DEVREL(wxCoord x) const |
| 112 | { |
| 113 | if (x > 0) |
| 114 | return (wxCoord)((double)(x) * m_scaleX + 0.5); |
| 115 | else |
| 116 | return (wxCoord)((double)(x) * m_scaleX - 0.5); |
| 117 | } |
| 118 | wxCoord YLOG2DEV(wxCoord y) const |
| 119 | { |
| 120 | wxCoord new_y = y - m_logicalOriginY; |
| 121 | if (new_y > 0) |
| 122 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; |
| 123 | else |
| 124 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; |
| 125 | } |
| 126 | wxCoord YLOG2DEVREL(wxCoord y) const |
| 127 | { |
| 128 | if (y > 0) |
| 129 | return (wxCoord)((double)(y) * m_scaleY + 0.5); |
| 130 | else |
| 131 | return (wxCoord)((double)(y) * m_scaleY - 0.5); |
| 132 | } |
| 133 | |
| 134 | protected: |
| 135 | // base class pure virtuals implemented here |
| 136 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
| 137 | virtual void DoGetSizeMM(int* width, int* height) const; |
| 138 | |
| 139 | public: |
| 140 | // GTK-specific member variables |
| 141 | |
| 142 | // not sure what for, but what is a mm on a screen you don't know the size |
| 143 | // of? |
| 144 | double m_mm_to_pix_x, |
| 145 | m_mm_to_pix_y; |
| 146 | |
| 147 | bool m_needComputeScaleX, |
| 148 | m_needComputeScaleY; // not yet used |
| 149 | |
| 150 | |
| 151 | private: |
| 152 | DECLARE_ABSTRACT_CLASS(wxDC) |
| 153 | }; |
| 154 | |
| 155 | #endif // __GTKDCH__ |