]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dc.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  10 // For compilers that support precompilation, includes "wx.h". 
  11 #include "wx/wxprec.h" 
  18 //----------------------------------------------------------------------------- 
  20 //----------------------------------------------------------------------------- 
  22 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxDCBase
) 
  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(); 
  33     m_needComputeScaleX 
= FALSE
; /* not used yet */ 
  34     m_needComputeScaleY 
= FALSE
; /* not used yet */ 
  36     m_logicalFunction 
= wxCOPY
; 
  39     m_font 
= *wxNORMAL_FONT
; 
  40     m_brush 
= *wxWHITE_BRUSH
; 
  43 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height 
) 
  49     m_clipY2 
= y 
+ height
; 
  52 // --------------------------------------------------------------------------- 
  53 // get DC capabilities 
  54 // --------------------------------------------------------------------------- 
  56 void wxDC::DoGetSizeMM( int* width
, int* height 
) const 
  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
) ); 
  65 // Resolution in pixels per logical inch 
  66 wxSize 
wxDC::GetPPI() const 
  68     // TODO (should probably be pure virtual) 
  72 // --------------------------------------------------------------------------- 
  73 // set various DC parameters 
  74 // --------------------------------------------------------------------------- 
  76 void wxDC::ComputeScaleAndOrigin() 
  78     m_scaleX 
= m_logicalScaleX 
* m_userScaleX
; 
  79     m_scaleY 
= m_logicalScaleY 
* m_userScaleY
; 
  82 void wxDC::SetMapMode( int mode 
) 
  87           SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y 
); 
  90           SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y 
); 
  93           SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y 
); 
  96           SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 ); 
 100           SetLogicalScale( 1.0, 1.0 ); 
 103     m_mappingMode 
= mode
; 
 105 /*  we don't do this mega optimisation 
 106     if (mode != wxMM_TEXT) 
 108         m_needComputeScaleX = TRUE; 
 109         m_needComputeScaleY = TRUE; 
 114 void wxDC::SetUserScale( double x
, double y 
) 
 116     // allow negative ? -> no 
 119     ComputeScaleAndOrigin(); 
 122 void wxDC::SetLogicalScale( double x
, double y 
) 
 127     ComputeScaleAndOrigin(); 
 130 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y 
) 
 132     m_logicalOriginX 
= x 
* m_signX
;   // is this still correct ? 
 133     m_logicalOriginY 
= y 
* m_signY
; 
 134     ComputeScaleAndOrigin(); 
 137 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y 
) 
 139     // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there 
 142     ComputeScaleAndOrigin(); 
 145 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp 
) 
 147     // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there 
 148     m_signX 
= (xLeftRight 
?  1 : -1); 
 149     m_signY 
= (yBottomUp  
? -1 :  1); 
 150     ComputeScaleAndOrigin(); 
 153 // --------------------------------------------------------------------------- 
 154 // coordinates transformations 
 155 // --------------------------------------------------------------------------- 
 157 wxCoord 
wxDCBase::DeviceToLogicalX(wxCoord x
) const 
 159     return ((wxDC 
*)this)->XDEV2LOG(x
); 
 162 wxCoord 
wxDCBase::DeviceToLogicalY(wxCoord y
) const 
 164     return ((wxDC 
*)this)->YDEV2LOG(y
); 
 167 wxCoord 
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const 
 169     return ((wxDC 
*)this)->XDEV2LOGREL(x
); 
 172 wxCoord 
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const 
 174     return ((wxDC 
*)this)->YDEV2LOGREL(y
); 
 177 wxCoord 
wxDCBase::LogicalToDeviceX(wxCoord x
) const 
 179     return ((wxDC 
*)this)->XLOG2DEV(x
); 
 182 wxCoord 
wxDCBase::LogicalToDeviceY(wxCoord y
) const 
 184     return ((wxDC 
*)this)->YLOG2DEV(y
); 
 187 wxCoord 
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const 
 189     return ((wxDC 
*)this)->XLOG2DEVREL(x
); 
 192 wxCoord 
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const 
 194     return ((wxDC 
*)this)->YLOG2DEVREL(y
);