]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/cmndata.cpp
setting up correct port origin as well
[wxWidgets.git] / src / common / cmndata.cpp
index 39e55667e6cc21c6fa3c50a3c16c7535cddbcad7..171f85d13009034170a1148e5b00952f3b524ef7 100644 (file)
@@ -49,7 +49,7 @@
     #include "wx/paper.h"
 #endif // wxUSE_PRINTING_ARCHITECTURE
 
-#if defined(__WXMSW__) && !defined(__PALMOS__)
+#if defined(__WXMSW__)
     #include <windowsx.h>
     #include "wx/msw/private.h"
 
     #endif
 #endif // MSW
 
-#ifdef __WXMAC__
+    #if wxUSE_PRINTING_ARCHITECTURE
+
+#if defined(__WXMAC__)
     #include "wx/mac/private/print.h"
 #endif
 
-    #if wxUSE_PRINTING_ARCHITECTURE
         IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject)
         IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject)
         IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData, wxObject)
@@ -177,7 +178,7 @@ wxPrintData::wxPrintData()
     m_printCollate = false;
 
     // New, 24/3/99
-    m_printerName = wxT("");
+    m_printerName = wxEmptyString;
     m_colour = true;
     m_duplexMode = wxDUPLEX_SIMPLEX;
     m_printQuality = wxPRINT_QUALITY_HIGH;
@@ -190,15 +191,16 @@ wxPrintData::wxPrintData()
 wxPrintData::wxPrintData(const wxPrintData& printData)
     : wxObject()
 {
+    m_nativeData = NULL;
     (*this) = printData;
 }
 
 wxPrintData::~wxPrintData()
 {
     m_nativeData->m_ref--;
-    if (m_nativeData->m_ref == 0) 
+    if (m_nativeData->m_ref == 0)
         delete m_nativeData;
-        
+
 #ifdef __WXMAC__
     delete m_nativePrintData ;
 #endif
@@ -235,16 +237,19 @@ void wxPrintData::operator=(const wxPrintData& data)
     m_paperSize = data.m_paperSize;
     m_bin = data.m_bin;
     m_printMode = data.m_printMode;
-    m_filename = data.m_filename;   
+    m_filename = data.m_filename;
 
-    // UnRef old m_nativeData    
-    m_nativeData->m_ref--;
-    if (m_nativeData->m_ref == 0) 
-        delete m_nativeData;
+    // UnRef old m_nativeData
+    if (m_nativeData)
+    {
+        m_nativeData->m_ref--;
+        if (m_nativeData->m_ref == 0)
+            delete m_nativeData;
+    }
     // Set Ref new one
     m_nativeData = data.GetNativeData();
     m_nativeData->m_ref++;
-    
+
 #ifdef __WXMAC__
     m_nativePrintData->CopyFrom( data.m_nativePrintData ) ;
 #endif
@@ -276,7 +281,7 @@ wxString wxPrintData::GetPrinterCommand() const
     if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
         return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterCommand();
 #endif
-    return wxT("");
+    return wxEmptyString;
 }
 
 wxString wxPrintData::GetPrinterOptions() const
@@ -285,7 +290,7 @@ wxString wxPrintData::GetPrinterOptions() const
     if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
         return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterOptions();
 #endif
-    return wxT("");
+    return wxEmptyString;
 }
 
 wxString wxPrintData::GetPreviewCommand() const
@@ -294,7 +299,7 @@ wxString wxPrintData::GetPreviewCommand() const
     if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
         return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPreviewCommand();
 #endif
-    return wxT("");
+    return wxEmptyString;
 }
 
 wxString wxPrintData::GetFontMetricPath() const
@@ -303,7 +308,7 @@ wxString wxPrintData::GetFontMetricPath() const
     if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
         return ((wxPostScriptPrintNativeData*)m_nativeData)->GetFontMetricPath();
 #endif
-    return wxT("");
+    return wxEmptyString;
 }
 
 double wxPrintData::GetPrinterScaleX() const
@@ -440,10 +445,10 @@ wxPrintDialogData::wxPrintDialogData()
     m_printSelection = false;
     m_printEnableSelection = false;
     m_printEnablePageNumbers = true;
-    
+
     wxPrintFactory* factory = wxPrintFactory::GetFactory();
     m_printEnablePrintToFile = ! factory->HasOwnPrintToFile();
-    
+
     m_printEnableHelp = false;
 #if WXWIN_COMPATIBILITY_2_4
     m_printSetupDialog = false;
@@ -530,14 +535,14 @@ void wxPrintDialogData::operator=(const wxPrintData& data)
 
 wxPageSetupDialogData::wxPageSetupDialogData()
 {
-    m_paperSize = wxSize(0, 0);
+    m_paperSize = wxSize(0,0);
 
     CalculatePaperSizeFromId();
 
-    m_minMarginTopLeft = wxPoint(0, 0);
-    m_minMarginBottomRight = wxPoint(0, 0);
-    m_marginTopLeft = wxPoint(0, 0);
-    m_marginBottomRight = wxPoint(0, 0);
+    m_minMarginTopLeft =
+    m_minMarginBottomRight =
+    m_marginTopLeft =
+    m_marginBottomRight = wxPoint(0,0);
 
     // Flags
     m_defaultMinMargins = false;
@@ -557,11 +562,11 @@ wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialog
 
 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData)
 {
-    m_paperSize = wxSize(0, 0);
-    m_minMarginTopLeft = wxPoint(0, 0);
-    m_minMarginBottomRight = wxPoint(0, 0);
-    m_marginTopLeft = wxPoint(0, 0);
-    m_marginBottomRight = wxPoint(0, 0);
+    m_paperSize = wxSize(0,0);
+    m_minMarginTopLeft =
+    m_minMarginBottomRight =
+    m_marginTopLeft =
+    m_marginBottomRight = wxPoint(0,0);
 
     // Flags
     m_defaultMinMargins = false;
@@ -606,6 +611,7 @@ wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPageSetupDialogD
 wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPrintData& data)
 {
     m_printData = data;
+    CalculatePaperSizeFromId();
 
     return *this;
 }
@@ -657,6 +663,12 @@ void wxPageSetupDialogData::SetPaperSize(wxPaperSize id)
     CalculatePaperSizeFromId();
 }
 
+void wxPageSetupDialogData::SetPrintData(const wxPrintData& printData)
+{
+    m_printData = printData;
+    CalculatePaperSizeFromId();
+}
+
 // Use paper size defined in this object to set the wxPrintData
 // paper id
 void wxPageSetupDialogData::CalculateIdFromPaperSize()