]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dcbase.cpp
interpret ~ specially only when it is the first character of the path (closes #10948...
[wxWidgets.git] / src / common / dcbase.cpp
index 1d0505599a89bd0d79b33fa16c36f60d63a70a28..3427fe362ea357a1bb2591ffdea01de541eeb3ab 100644 (file)
@@ -131,34 +131,25 @@ IMPLEMENT_DYNAMIC_CLASS(wxDCFactoryCleanupModule, wxModule)
 // wxNativeDCFactory
 //-----------------------------------------------------------------------------
 
-wxDCImpl* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner )
-{
-    return new wxWindowDCImpl( owner );
-}
-
 wxDCImpl* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner, wxWindow *window )
 {
-    return new wxWindowDCImpl( owner, window );
-}
-
-wxDCImpl* wxNativeDCFactory::CreateClientDC( wxClientDC *owner )
-{
-    return new wxClientDCImpl( owner );
+    wxDCImpl * const impl = new wxWindowDCImpl( owner, window );
+    impl->InheritAttributes(window);
+    return impl;
 }
 
 wxDCImpl* wxNativeDCFactory::CreateClientDC( wxClientDC *owner, wxWindow *window )
 {
-    return new wxClientDCImpl( owner, window );
-}
-
-wxDCImpl* wxNativeDCFactory::CreatePaintDC( wxPaintDC *owner )
-{
-    return new wxPaintDCImpl( owner );
+    wxDCImpl * const impl = new wxClientDCImpl( owner, window );
+    impl->InheritAttributes(window);
+    return impl;
 }
 
 wxDCImpl* wxNativeDCFactory::CreatePaintDC( wxPaintDC *owner, wxWindow *window )
 {
-    return new wxPaintDCImpl( owner, window );
+    wxDCImpl * const impl = new wxPaintDCImpl( owner, window );
+    impl->InheritAttributes(window);
+    return impl;
 }
 
 wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner )
@@ -166,9 +157,19 @@ wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner )
     return new wxMemoryDCImpl( owner );
 }
 
-wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap )
+wxDCImpl* wxNativeDCFactory::CreateMemoryDC(wxMemoryDC *owner, wxBitmap& bitmap)
 {
-    return new wxMemoryDCImpl( owner, bitmap );
+    // the bitmap may be modified when it's selected into a memory DC so make
+    // sure changing this bitmap doesn't affect any other shallow copies of it
+    // (see wxMemoryDC::SelectObject())
+    //
+    // notice that we don't provide any ctor equivalent to SelectObjectAsSource
+    // method because this should be rarely needed and easy to work around by
+    // using the default ctor and calling SelectObjectAsSource itself
+    if ( bitmap.IsOk() )
+        bitmap.UnShare();
+
+    return new wxMemoryDCImpl(owner, bitmap);
 }
 
 wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxDC *dc )
@@ -299,12 +300,12 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& data)
 {
 }
 
-wxRect wxPrinterDC::GetPaperRect()
+wxRect wxPrinterDC::GetPaperRect() const
 {
     return GetImpl()->GetPaperRect();
 }
 
-int wxPrinterDC::GetResolution()
+int wxPrinterDC::GetResolution() const
 {
     return GetImpl()->GetResolution();
 }
@@ -412,7 +413,7 @@ void wxDCImpl::ComputeScaleAndOrigin()
     m_scaleY = m_logicalScaleY * m_userScaleY;
 }
 
-void wxDCImpl::SetMapMode( int mode )
+void wxDCImpl::SetMapMode( wxMappingMode mode )
 {
     switch (mode)
     {
@@ -649,7 +650,7 @@ wxDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest,
                         wxDC *source,
                         wxCoord xsrc, wxCoord ysrc,
                         wxCoord srcWidth, wxCoord srcHeight,
-                        int rop,
+                        wxRasterOperationMode rop,
                         bool useMask,
                         wxCoord xsrcMask,
                         wxCoord ysrcMask)
@@ -695,7 +696,7 @@ void wxDCImpl::DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffs
 
 void wxDCImpl::DrawPolygon(const wxPointList *list,
                            wxCoord xoffset, wxCoord yoffset,
-                           int fillStyle)
+                           wxPolygonFillMode fillStyle)
 {
     int n = list->GetCount();
     wxPoint *points = new wxPoint[n];
@@ -718,7 +719,7 @@ wxDCImpl::DoDrawPolyPolygon(int n,
                             int count[],
                             wxPoint points[],
                             wxCoord xoffset, wxCoord yoffset,
-                            int fillStyle)
+                            wxPolygonFillMode fillStyle)
 {
     if ( n == 1 )
     {
@@ -787,7 +788,7 @@ void wx_spline_push(double x1, double y1, double x2, double y2, double x3, doubl
 static bool wx_spline_add_point(double x, double y);
 static void wx_spline_draw_point_array(wxDC *dc);
 
-wxPointList wx_spline_point_list;
+static wxPointList wx_spline_point_list;
 
 #define                half(z1, z2)        ((z1+z2)/2.0)
 #define                THRESHOLD        5
@@ -1107,12 +1108,32 @@ void wxDCImpl::DoGradientFillConcentric(const wxRect& rect,
     m_pen.SetColour(oldPenColour);
 }
 
+void wxDCImpl::InheritAttributes(wxWindow *win)
+{
+    wxCHECK_RET( win, "window can't be NULL" );
+
+    SetFont(win->GetFont());
+    SetTextForeground(win->GetForegroundColour());
+    SetTextBackground(win->GetBackgroundColour());
+    SetBackground(win->GetBackgroundColour());
+    SetLayoutDirection(win->GetLayoutDirection());
+}
+
 //-----------------------------------------------------------------------------
 // wxDC
 //-----------------------------------------------------------------------------
 
 IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
 
+void wxDC::CopyAttributes(const wxDC& dc)
+{
+    SetFont(dc.GetFont());
+    SetTextForeground(dc.GetTextForeground());
+    SetTextBackground(dc.GetTextBackground());
+    SetBackground(dc.GetBackground());
+    SetLayoutDirection(dc.GetLayoutDirection());
+}
+
 void wxDC::DrawLabel(const wxString& text,
                          const wxBitmap& bitmap,
                          const wxRect& rect,
@@ -1321,6 +1342,13 @@ void wxDC::GetClippingBox(long *x, long *y, long *w, long *h) const
         if (h) *h = hh;
     }
 
+void wxDC::DrawObject(wxDrawObject* drawobject)
+{
+    drawobject->Draw(*this);
+    CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
+    CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
+}
+
 #endif  // WXWIN_COMPATIBILITY_2_8
 
 /*
@@ -1637,3 +1665,15 @@ void wxDCImpl::CalculateEllipticPoints( wxPointList* points,
 } // CalculateEllipticPoints
 
 #endif // __WXWINCE__
+
+float wxDCImpl::GetFontPointSizeAdjustment(float dpi)
+{
+    // wxMSW has long-standing bug where wxFont point size is interpreted as
+    // "pixel size corresponding to given point size *on screen*". In other
+    // words, on a typical 600dpi printer and a typical 96dpi screen, fonts
+    // are ~6 times smaller when printing. Unfortunately, this bug is so severe
+    // that *all* printing code has to account for it and consequently, other
+    // ports need to emulate this bug too:
+    const wxSize screenPPI = wxGetDisplayPPI();
+    return float(screenPPI.y) / dpi;
+}