]> git.saurik.com Git - wxWidgets.git/commitdiff
don't set A4 paper size, use the system default instead
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 17 Nov 2006 01:54:48 +0000 (01:54 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 17 Nov 2006 01:54:48 +0000 (01:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43456 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
samples/printing/printing.cpp
src/common/cmndata.cpp
src/msw/printdlg.cpp

index b1fd11f2ddf0cae7909b5ac4f43d1af1ccec0e22..b4b7bae080c6aa674ea6730203fd2a68e5fe4dca 100644 (file)
@@ -95,6 +95,7 @@ All:
 wxMSW:
 
 - Fixed version script problems when using configure with cygwin/mingw32.
+- Use system default paper size for printing instead of A4
 
 2.7.2
 -----
index bfe2f16192f4f2713a69dc1cba2f7d79d763e481..9701b90f631bb78ca476edfaa02ff6180988eeb8 100644 (file)
@@ -82,9 +82,9 @@ bool MyApp::OnInit(void)
     m_testFont.Create(10, wxSWISS, wxNORMAL, wxNORMAL);
 
     g_printData = new wxPrintData;
-    // Set an initial paper size
+    // You could set an initial paper size here
 //    g_printData->SetPaperId(wxPAPER_LETTER); // for Americans
-    g_printData->SetPaperId(wxPAPER_A4);    // for everyone else    
+//    g_printData->SetPaperId(wxPAPER_A4);    // for everyone else    
 
     g_pageSetupData = new wxPageSetupDialogData;
     // copy over initial paper size from print record
index 2ab2f2a670fb30e17f6fe27e251692025d23fce5..11f936d5815c83396c7bc0c1134a3ce9abc895c9 100644 (file)
@@ -161,8 +161,11 @@ wxPrintData::wxPrintData()
     m_colour = true;
     m_duplexMode = wxDUPLEX_SIMPLEX;
     m_printQuality = wxPRINT_QUALITY_HIGH;
-    m_paperId = wxPAPER_A4;
-    m_paperSize = wxSize(210, 297);
+
+    // we intentionally don't initialize paper id and size at all, like this
+    // the default system settings will be used for them
+    m_paperId = wxPAPER_NONE;
+    m_paperSize = wxDefaultSize;
 
     m_privData = NULL;
     m_privDataLen = 0;
index d88ae7e859e912599e92aad7029e26a86cf5989b..c8586ab3e0469c9fb3c3b7ce927caddd43572e99 100644 (file)
@@ -444,38 +444,40 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
         devMode->dmFields |= DM_COLOR;
 
         //// Paper size
-        if (data.GetPaperId() == wxPAPER_NONE)
+
+        // Paper id has priority over paper size. If id is specified, then size
+        // is ignored (as it can be filled in even for standard paper sizes)
+
+        wxPrintPaperType *paperType = NULL;
+
+        const wxPaperSize paperId = data.GetPaperId();
+        if ( paperId != wxPAPER_NONE && wxThePrintPaperDatabase )
         {
-            // DEVMODE is in tenths of a milimeter
-            devMode->dmPaperWidth = (short)(data.GetPaperSize().x * 10);
-            devMode->dmPaperLength = (short)(data.GetPaperSize().y * 10);
-            if(m_customWindowsPaperId != 0)
-                devMode->dmPaperSize = m_customWindowsPaperId;
-            else
-                devMode->dmPaperSize = DMPAPER_USER;
-            devMode->dmFields |= DM_PAPERWIDTH;
-            devMode->dmFields |= DM_PAPERLENGTH;
+            paperType = wxThePrintPaperDatabase->FindPaperType(paperId);
         }
-        else
+
+        if ( paperType )
         {
-            if (wxThePrintPaperDatabase)
+            devMode->dmPaperSize = (short)paperType->GetPlatformId();
+            devMode->dmFields |= DM_PAPERSIZE;
+        }
+        else // custom (or no) paper size
+        {
+            const wxSize paperSize = data.GetPaperSize();
+            if ( paperSize != wxDefaultSize )
             {
-                wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType( data.GetPaperId() );
-                if (paper)
-                {
-                    devMode->dmPaperSize = (short)paper->GetPlatformId();
-                    devMode->dmFields |= DM_PAPERSIZE;
-                }
+                // Fall back on specifying the paper size explicitly
+                if(m_customWindowsPaperId != 0)
+                    devMode->dmPaperSize = m_customWindowsPaperId;
                 else
-                {
-                    // Fall back on specifying the paper size explicitly
-                    devMode->dmPaperWidth = (short)(data.GetPaperSize().x * 10);
-                    devMode->dmPaperLength = (short)(data.GetPaperSize().y * 10);
                     devMode->dmPaperSize = DMPAPER_USER;
-                    devMode->dmFields |= DM_PAPERWIDTH;
-                    devMode->dmFields |= DM_PAPERLENGTH;
-                }
+                devMode->dmPaperWidth = (short)(paperSize.x * 10);
+                devMode->dmPaperLength = (short)(paperSize.y * 10);
+                devMode->dmFields |= DM_PAPERWIDTH;
+                devMode->dmFields |= DM_PAPERLENGTH;
             }
+            //else: neither paper type nor size specified, don't fill DEVMODE
+            //      at all so that the system defaults are used
         }
 
         //// Duplex