]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxGetDisplayPPI() convenience function and wxPrintout::SetPPI*() overloads...
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 21 Sep 2008 09:35:49 +0000 (09:35 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 21 Sep 2008 09:35:49 +0000 (09:35 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gdicmn.h
include/wx/prntbase.h
interface/wx/gdicmn.h
src/common/gdicmn.cpp
src/gtk/gnome/gprint.cpp
src/gtk/print.cpp

index fc3b0796587ba1331f7b50d64f0fa6f7c9ea3214..59c52cd1bb29e2dd3abddf7f75de3c35846fa359 100644 (file)
@@ -819,6 +819,7 @@ extern void WXDLLIMPEXP_CORE wxDisplaySize(int *width, int *height);
 extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySize();
 extern void WXDLLIMPEXP_CORE wxDisplaySizeMM(int *width, int *height);
 extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySizeMM();
+extern wxSize WXDLLIMPEXP_CORE wxGetDisplayPPI();
 
 // Get position and size of the display workarea
 extern void WXDLLIMPEXP_CORE wxClientDisplayRect(int *x, int *y, int *width, int *height);
index 81e32415b57bb17332df1f271abd8133dfbd36ba..a613f6cdef664630b4bd1a38e12565fb604b0c43 100644 (file)
@@ -284,8 +284,10 @@ public:
     void GetPageSizeMM(int *w, int  *h) const { *w = m_pageWidthMM; *h = m_pageHeightMM; }
 
     void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; }
+    void SetPPIScreen(const wxSize& ppi) { SetPPIScreen(ppi.x, ppi.y); }
     void GetPPIScreen(int *x, int *y) const { *x = m_PPIScreenX; *y = m_PPIScreenY; }
     void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; }
+    void SetPPIPrinter(const wxSize& ppi) { SetPPIPrinter(ppi.x, ppi.y); }
     void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; }
 
     void SetPaperRectPixels(const wxRect& paperRectPixels) { m_paperRectPixels = paperRectPixels; }
index b5fb341b214f18ecfc8b066e218e34820a414e8f..fb9d647fab321829000938a5c3d0214f04ba6c18 100644 (file)
@@ -852,6 +852,18 @@ void wxClientDisplayRect(int* x, int* y, int* width, int* height);
 wxRect wxGetClientDisplayRect();
 //@}
 
+/** @ingroup group_funcmacro_gdi */
+//@{
+/**
+    Returns the display resolution in pixels per inch.
+
+    @header{wx/gdicmn.h}
+
+    @since 2.9.0
+*/
+wxSize wxGetDisplayPPI();
+//@}
+
 /** @ingroup group_funcmacro_gdi */
 //@{
 /**
index a79f31aa2cfd1bb9687f903f65bd23ebf9ab28cb..f56aad7d4c3417aeae429e757de1c9e0ce715aeb 100644 (file)
@@ -880,6 +880,15 @@ wxSize wxGetDisplaySizeMM()
     return wxSize(x, y);
 }
 
+wxSize wxGetDisplayPPI()
+{
+    const wxSize pixels = wxGetDisplaySize();
+    const wxSize mm = wxGetDisplaySizeMM();
+
+    return wxSize((pixels.x * 25.4) / mm.x,
+                  (pixels.y * 25.4) / mm.y);
+}
+
 wxResourceCache::~wxResourceCache ()
 {
     wxList::compatibility_iterator node = GetFirst ();
index aa93c96e64d29bd6b82c55f36172f40d1213da6a..b8b8086cb9053662ef9a27771b4788505b074cb4 100644 (file)
@@ -872,11 +872,7 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
         return false;
     }
 
-    wxSize ScreenPixels = wxGetDisplaySize();
-    wxSize ScreenMM = wxGetDisplaySizeMM();
-
-    printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
-                            (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
+    printout->SetPPIScreen(wxGetDisplayPPI());
     printout->SetPPIPrinter( dc->GetResolution(),
                              dc->GetResolution() );
 
@@ -2099,12 +2095,8 @@ void wxGnomePrintPreview::DetermineScaling()
 
     if (paper)
     {
-        wxSize ScreenPixels = wxGetDisplaySize();
-        wxSize ScreenMM = wxGetDisplaySizeMM();
+        m_previewPrintout->SetPPIScreen(wxGetDisplayPPI());
 
-        m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
-                                         (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
-                                         
         int resolution = DPI;
         m_previewPrintout->SetPPIPrinter( resolution, resolution );
 
index c275c56e09c26457f8e19c0b58a063fbc30bb739..62c47203f50c78b61b2d434c55cc2bb64e4d25ef 100644 (file)
@@ -926,11 +926,8 @@ void wxGtkPrinter::BeginPrint(wxPrintout *printout, GtkPrintOperation *operation
         }
         return;
     }
-    wxSize ScreenPixels = wxGetDisplaySize();
-    wxSize ScreenMM = wxGetDisplaySizeMM();
 
-    printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
-                            (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
+    printout->SetPPIScreen(wxGetDisplayPPI());
     printout->SetPPIPrinter( printDC->GetResolution(),
                              printDC->GetResolution() );
 
@@ -2366,12 +2363,7 @@ void wxGtkPrintPreview::DetermineScaling()
 
     if (paper)
     {
-        wxSize ScreenPixels = wxGetDisplaySize();
-        wxSize ScreenMM = wxGetDisplaySizeMM();
-
-        m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
-                                         (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
-
+        m_previewPrintout->SetPPIScreen(wxGetDisplayPPI());
         m_previewPrintout->SetPPIPrinter( m_resolution, m_resolution );
 
         // Get width and height in points (1/72th of an inch)