]>
git.saurik.com Git - wxWidgets.git/blob - src/x11/dc.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/x11/dc.cpp 
   4 // Author:      Julian Smart 
   8 // Copyright:   (c) Julian Smart 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // for compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  18     #include "wx/dcmemory.h" 
  21 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
) 
  23 //----------------------------------------------------------------------------- 
  25 //----------------------------------------------------------------------------- 
  35     m_mm_to_pix_x 
= (double)wxGetDisplaySize().GetWidth() / 
  36                     (double)wxGetDisplaySizeMM().GetWidth(); 
  37     m_mm_to_pix_y 
= (double)wxGetDisplaySize().GetHeight() / 
  38                     (double)wxGetDisplaySizeMM().GetHeight(); 
  41     m_needComputeScaleX 
= false; /* not used yet */ 
  42     m_needComputeScaleY 
= false; /* not used yet */ 
  44     m_logicalFunction 
= wxCOPY
; 
  47     m_font 
= *wxNORMAL_FONT
; 
  48     m_brush 
= *wxWHITE_BRUSH
; 
  50     m_backgroundMode 
= wxTRANSPARENT
; 
  52     m_isInteractive 
= false;  // ??? 
  55 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height 
) 
  61     m_clipY2 
= y 
+ height
; 
  64 void wxDC::DoGetSizeMM( int* width
, int* height 
) const 
  70         *width 
= int( double(w
) / (m_scaleX
*m_mm_to_pix_x
) ); 
  72         *height 
= int( double(h
) / (m_scaleY
*m_mm_to_pix_y
) ); 
  75 // Resolution in pixels per logical inch 
  76 wxSize 
wxDC::GetPPI() const 
  78     // TODO (should probably be pure virtual) 
  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     if (mode 
!= wxMM_TEXT
) 
 105         m_needComputeScaleX 
= true; 
 106         m_needComputeScaleY 
= true; 
 110 void wxDC::SetUserScale( double x
, double y 
) 
 112     // allow negative ? -> no 
 115     ComputeScaleAndOrigin(); 
 118 void wxDC::SetLogicalScale( double x
, double y 
) 
 123     ComputeScaleAndOrigin(); 
 126 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y 
) 
 128     m_logicalOriginX 
= x 
* m_signX
;   // is this still correct ? 
 129     m_logicalOriginY 
= y 
* m_signY
; 
 130     ComputeScaleAndOrigin(); 
 133 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y 
) 
 135     // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there 
 138     ComputeScaleAndOrigin(); 
 141 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp 
) 
 143     m_signX 
= xLeftRight 
?  1 : -1; 
 144     m_signY 
= yBottomUp  
? -1 :  1; 
 145     ComputeScaleAndOrigin(); 
 148 wxCoord 
wxDCBase::DeviceToLogicalX(wxCoord x
) const 
 150   return ((wxDC 
*)this)->XDEV2LOG(x
); 
 153 wxCoord 
wxDCBase::DeviceToLogicalY(wxCoord y
) const 
 155   return ((wxDC 
*)this)->YDEV2LOG(y
); 
 158 wxCoord 
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const 
 160   return ((wxDC 
*)this)->XDEV2LOGREL(x
); 
 163 wxCoord 
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const 
 165   return ((wxDC 
*)this)->YDEV2LOGREL(y
); 
 168 wxCoord 
wxDCBase::LogicalToDeviceX(wxCoord x
) const 
 170   return ((wxDC 
*)this)->XLOG2DEV(x
); 
 173 wxCoord 
wxDCBase::LogicalToDeviceY(wxCoord y
) const 
 175   return ((wxDC 
*)this)->YLOG2DEV(y
); 
 178 wxCoord 
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const 
 180   return ((wxDC 
*)this)->XLOG2DEVREL(x
); 
 183 wxCoord 
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const 
 185   return ((wxDC 
*)this)->YLOG2DEVREL(y
); 
 188 void wxDC::ComputeScaleAndOrigin() 
 190     m_scaleX 
= m_logicalScaleX 
* m_userScaleX
; 
 191     m_scaleY 
= m_logicalScaleY 
* m_userScaleY
;