]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/gnome/gprint.cpp
Implemented text wrapping for GTK (1.2 and 2.X).
[wxWidgets.git] / src / gtk1 / gnome / gprint.cpp
index 4bdc4076a0f8bbe7eb7436dd19fe2dedd5512cca..2511848240241ad8b250569591f784e0e61d09fd 100644 (file)
@@ -22,8 +22,7 @@
 
 #if wxUSE_LIBGNOMEPRINT
 
-#include "math.h"
-
+#include "wx/math.h"
 #include "wx/fontutil.h"
 #include "wx/printdlg.h"
 #include "wx/gtk/private.h"
 #include <libgnomeprintui/gnome-print-job-preview.h>
 #include <libgnomeprintui/gnome-print-paper-selector.h>
 
+
+#include "wx/html/forcelnk.h"
+FORCE_LINK_ME(gnome_print)
+
 //----------------------------------------------------------------------------
 // wxGnomePrintLibrary
 //----------------------------------------------------------------------------
@@ -792,7 +795,7 @@ wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
     int ret = dialog.ShowModal();
     if (ret == wxID_CANCEL)
     {
-        sm_lastError = wxPRINTER_ERROR;
+        sm_lastError = wxPRINTER_CANCELLED;
         return NULL;
     }
     
@@ -811,7 +814,7 @@ bool wxGnomePrinter::Setup( wxWindow *parent )
 // wxGnomePrintDC
 //-----------------------------------------------------------------------------
 
-IMPLEMENT_CLASS(wxGnomePrintDC, wxDCBase)
+IMPLEMENT_CLASS(wxGnomePrintDC, wxDC)
 
 wxGnomePrintDC::wxGnomePrintDC( wxGnomePrinter *printer )
 {
@@ -944,6 +947,71 @@ void wxGnomePrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoor
 
 void wxGnomePrintDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
 {
+    wxCoord rad = (wxCoord) radius;
+
+    if (m_brush.GetStyle() != wxTRANSPARENT)
+    {
+        SetBrush(m_brush);
+        gs_lgp->gnome_print_newpath(m_gpc);
+        gs_lgp->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));
+        gs_lgp->gnome_print_curveto(m_gpc,
+                                   XLOG2DEV(x + rad),YLOG2DEV(y),
+                                XLOG2DEV(x),YLOG2DEV(y),
+                                XLOG2DEV(x),YLOG2DEV(y + rad));
+        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad));
+        gs_lgp->gnome_print_curveto(m_gpc,
+                                   XLOG2DEV(x),YLOG2DEV(y + height - rad),
+                                XLOG2DEV(x),YLOG2DEV(y + height),
+                                XLOG2DEV(x + rad),YLOG2DEV(y + height));
+        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width - rad),YLOG2DEV(y + height));
+        gs_lgp->gnome_print_curveto(m_gpc,
+                                   XLOG2DEV(x + width - rad),YLOG2DEV(y + height),
+                                XLOG2DEV(x + width),YLOG2DEV(y + height),
+                                XLOG2DEV(x + width),YLOG2DEV(y + height - rad));
+        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width),YLOG2DEV(y + rad));
+        gs_lgp->gnome_print_curveto(m_gpc,
+                                   XLOG2DEV(x + width),YLOG2DEV(y + rad),
+                                XLOG2DEV(x + width),YLOG2DEV(y),
+                                XLOG2DEV(x + width - rad),YLOG2DEV(y));
+        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));
+        gs_lgp->gnome_print_closepath(m_gpc);
+        gs_lgp->gnome_print_fill(m_gpc);
+       
+        CalcBoundingBox(x,y);
+        CalcBoundingBox(x+width,y+height);
+    }
+    
+    if (m_pen.GetStyle() != wxTRANSPARENT)
+    {
+        SetPen(m_pen);
+        gs_lgp->gnome_print_newpath(m_gpc);
+        gs_lgp->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));
+        gs_lgp->gnome_print_curveto(m_gpc,
+                                   XLOG2DEV(x + rad),YLOG2DEV(y),
+                                   XLOG2DEV(x),YLOG2DEV(y),
+                                   XLOG2DEV(x),YLOG2DEV(y + rad));
+        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad));
+        gs_lgp->gnome_print_curveto(m_gpc,
+                                   XLOG2DEV(x),YLOG2DEV(y + height - rad),
+                                   XLOG2DEV(x),YLOG2DEV(y + height),
+                                   XLOG2DEV(x + rad),YLOG2DEV(y + height));
+        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width - rad),YLOG2DEV(y + height));
+        gs_lgp->gnome_print_curveto(m_gpc,
+                                   XLOG2DEV(x + width - rad),YLOG2DEV(y + height),
+                                   XLOG2DEV(x + width),YLOG2DEV(y + height),
+                                   XLOG2DEV(x + width),YLOG2DEV(y + height - rad));
+        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width),YLOG2DEV(y + rad));
+        gs_lgp->gnome_print_curveto(m_gpc,
+                                   XLOG2DEV(x + width),YLOG2DEV(y + rad),
+                                   XLOG2DEV(x + width),YLOG2DEV(y),
+                                   XLOG2DEV(x + width - rad),YLOG2DEV(y));
+        gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));
+        gs_lgp->gnome_print_closepath(m_gpc);
+        gs_lgp->gnome_print_stroke(m_gpc);
+       
+        CalcBoundingBox(x,y);
+        CalcBoundingBox(x+width,y+height);
+    }
 }
 
 void wxGnomePrintDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
@@ -1412,9 +1480,9 @@ void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxC
     pango_layout_get_pixel_size( m_layout, &w, &h );
     
     if (width)
-        *width = (wxCoord) w
+        *width = (wxCoord)(w / m_scaleX)
     if (height)
-        *height = (wxCoord) h;
+        *height = (wxCoord)(h / m_scaleY);
     if (descent)
     {
         PangoLayoutIter *iter = pango_layout_get_iter(m_layout);