Patch #2369 2008-02-10 11:53

jenslody

Patch for bug #13054
Download
2369-Patch_for_bug.patch (1.3 KB)
Category
 
Status
Closed
Close date
2008-02-11 10:17
Assigned to
 
--- codeblocks-1.0svn.orig/src/sdk/cbeditorprintout.cpp    2008-02-02 14:40:49.000000000 +0100
+++ codeblocks-1.0svn.work/src/sdk/cbeditorprintout.cpp    2008-02-10 12:21:26.000000000 +0100
@@ -21,6 +21,7 @@
 
 #include "cbeditorprintout.h"
 #include "printing_types.h"
+#include <wx/paper.h>
 
 cbEditorPrintout::cbEditorPrintout(const wxString& title, cbStyledTextCtrl* control, bool selectionOnly)
         : wxPrintout(title),
@@ -93,7 +94,10 @@
     }
 
     wxPrintData* ppd = &(g_printer->GetPrintDialogData().GetPrintData());
-    wxSize page = ppd->GetPaperSize();
+    // We cannot use GetSize from wxPrintData, because it always returns -1 for page.x and page.y,
+    wxPrintPaperDatabase paperDB;
+    paperDB.CreateDatabase();
+    wxSize page=paperDB.GetSize(ppd->GetPaperId());
     if(ppd->GetOrientation() == wxLANDSCAPE )
     {
         int temp = page.x;
@@ -101,8 +105,9 @@
         page.y = temp;
     }
 
-    page.x = static_cast<int> (page.x * ppiScr.x / 25.4);
-    page.y = static_cast<int> (page.y * ppiScr.y / 25.4);
+    // We have to divide through 254 instead of 25.4, because GetSize() of paperDB returns tenth of millimeters
+    page.x = static_cast<int> (page.x * ppiScr.x / 254);
+    page.y = static_cast<int> (page.y * ppiScr.y / 254);
     m_pageRect = wxRect (0,
                          0,
                          page.x,
killerbot 2008-02-11 10:17

applied. Thanks !!!