]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/cmndata.cpp
Corrected some wxAccessible mistakes
[wxWidgets.git] / src / common / cmndata.cpp
index 9080a155e9af89c51a1d6edb05111ffb2539aaac..d4e48ea153b52f118ffa31b295ac5d6b48aafd30 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by:
 // Created:     01/02/97
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
+// Copyright:   (c) Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
     #include "wx/fontdlg.h"
 #endif // wxUSE_FONTDLG
 
-// For compatibility
-#if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXX11__)|| defined(__WXPM__) || defined(__WXMAC__)) && wxUSE_POSTSCRIPT
-    #define wxCOMPATIBILITY_WITH_PRINTSETUPDATA 1
-#endif
-
 #if wxUSE_PRINTING_ARCHITECTURE
     #include "wx/paper.h"
-
-    #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
-        #include "wx/generic/dcpsg.h"
-    #endif
 #endif // wxUSE_PRINTING_ARCHITECTURE
 
 #ifdef __WXMSW__
         #include <commdlg.h>
     #endif // Win16
 
-    #ifdef __WXWINE__
-        #include <cderr.h>
-        #include <commdlg.h>
-    #endif
-
-    #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
+    #if defined(__WATCOMC__) || defined(__SYMANTEC__) || defined(__SALFORDC__)
         #include <windowsx.h>
         #include <commdlg.h>
     #endif
@@ -167,7 +153,7 @@ void wxColourData::operator=(const wxColourData& data)
 wxFontData::wxFontData()
 {
     // Intialize colour to black.
-    fontColour.Set(0, 0, 0);
+    fontColour = wxNullColour;
 
     showHelp = FALSE;
     allowSymbols = TRUE;
@@ -204,38 +190,8 @@ wxPrintData::wxPrintData()
 #if TARGET_CARBON
     m_macPageFormat = kPMNoPageFormat;
     m_macPrintSettings = kPMNoPrintSettings;
-
-  #if PM_USE_SESSION_APIS
-    PMPrintSession macPrintSession = kPMNoReference;
-    OSStatus       err;
-
-    err = ::UMAPrOpen(&macPrintSession) ;
-    if ( err == noErr )
-    {
-        err = PMCreatePageFormat((PMPageFormat *)&m_macPageFormat);
-
-        //  Note that PMPageFormat is not session-specific, but calling
-        //  PMSessionDefaultPageFormat assigns values specific to the printer
-        //  associated with the current printing session.
-        if ((err == noErr) && (m_macPageFormat != kPMNoPageFormat))
-        {
-            err = PMSessionDefaultPageFormat((PMPrintSession)macPrintSession,
-                                             (PMPageFormat)m_macPageFormat);
-        }
-
-        err = PMCreatePrintSettings((PMPrintSettings *)&m_macPrintSettings);
-
-        //  Note that PMPrintSettings is not session-specific, but calling
-        //  PMSessionDefaultPrintSettings assigns values specific to the printer
-        //  associated with the current printing session.
-        if ((err == noErr) && (m_macPrintSettings != kPMNoPrintSettings))
-        {
-            err = PMSessionDefaultPrintSettings((PMPrintSession)macPrintSession,
-                                                (PMPrintSettings)m_macPrintSettings);
-        }
-    }
-    ::UMAPrClose(&macPrintSession) ;
-  #endif
+    m_macPrintSession = kPMNoReference ;
+    ValidateOrCreateNative() ;
 #else
     m_macPrintSettings = (THPrint) NewHandleClear( sizeof( TPrint ) );
     (**(THPrint)m_macPrintSettings).iPrVersion = 0;                    // something invalid
@@ -256,7 +212,7 @@ wxPrintData::wxPrintData()
     m_printCollate = FALSE;
 
     // New, 24/3/99
-    m_printerName = "";
+    m_printerName = wxT("");
     m_colour = TRUE;
     m_duplexMode = wxDUPLEX_SIMPLEX;
     m_printQuality = wxPRINT_QUALITY_HIGH;
@@ -264,11 +220,26 @@ wxPrintData::wxPrintData()
     m_paperSize = wxSize(210, 297);
 
     // PostScript-specific data
-    m_printerCommand = "";
-    m_previewCommand = "";
-    m_printerOptions = "";
-    m_filename = "";
-    m_afmPath = "";
+    m_previewCommand = wxT("");
+    m_filename = wxT("");
+#ifdef __VMS__
+    m_printerCommand = wxT("print");
+    m_printerOptions = wxT("/nonotify/queue=psqueue");
+    m_afmPath = wxT("sys$ps_font_metrics:");
+#endif
+
+#ifdef __WXMSW__
+    m_printerCommand = wxT("print");
+    m_printerOptions = wxT("");
+    m_afmPath = wxT("c:\\windows\\system\\");
+#endif
+
+#if !defined(__VMS__) && !defined(__WXMSW__)
+    m_printerCommand = wxT("lpr");
+    m_printerOptions = wxT("");
+    m_afmPath = wxT("");
+#endif
+
     m_printerScaleX = 1.0;
     m_printerScaleY = 1.0;
     m_printerTranslateX = 0;
@@ -286,6 +257,7 @@ wxPrintData::wxPrintData(const wxPrintData& printData)
 #if TARGET_CARBON
     m_macPageFormat    = kPMNoPageFormat;
     m_macPrintSettings = kPMNoPrintSettings;
+    m_macPrintSession = kPMNoReference ;
 #else
     m_macPrintSettings = NULL;
 #endif
@@ -323,7 +295,16 @@ wxPrintData::~wxPrintData()
   #endif
         m_macPrintSettings = kPMNoPrintSettings;
     }
-
+    
+    if ( m_macPrintSession != kPMNoReference )
+    {
+  #if PM_USE_SESSION_APIS
+        (void)PMRelease(m_macPrintSession);
+  #else
+        (void)PMDisposePrintSession(m_macPrintSession);
+  #endif
+        m_macPrintSession = kPMNoReference;
+    }
 #else
     wxASSERT( m_macPrintSettings );
     // we should perhaps delete
@@ -468,10 +449,7 @@ void wxPrintData::ConvertToNative()
 
         //// Orientation
 
-#ifndef __WXWINE__
         devMode->dmOrientation = m_printOrientation;
-#endif
-        devMode->dmFields = DM_ORIENTATION;
 
         //// Collation
 
@@ -503,7 +481,6 @@ void wxPrintData::ConvertToNative()
 
         devMode->dmFields |= DM_COLOR;
 
-#ifndef __WXWINE__
         //// Paper size
 
         if (m_paperId == wxPAPER_NONE)
@@ -527,7 +504,6 @@ void wxPrintData::ConvertToNative()
                 }
             }
         }
-#endif
 
         //// Duplex
 
@@ -596,12 +572,10 @@ void wxPrintData::ConvertFromNative()
     {
         LPDEVMODE devMode = (LPDEVMODE)GlobalLock(hDevMode);
 
-#ifndef __WXWINE__
         //// Orientation
 
         if (devMode->dmFields & DM_ORIENTATION)
             m_printOrientation = devMode->dmOrientation;
-#endif
 
         //// Collation
 
@@ -626,17 +600,7 @@ void wxPrintData::ConvertFromNative()
 
         if (devMode->dmDeviceName[0] != 0)
         {
-            // TODO: make this Unicode compatible
-            char buf[32];
-            int i = 0;
-            while (devMode->dmDeviceName[i] != 0)
-            {
-                buf[i] = devMode->dmDeviceName[i];
-                i ++;
-            }
-            buf[i] = 0;
-
-            m_printerName = buf;
+            m_printerName = devMode->dmDeviceName;
         }
 
         //// Colour
@@ -651,7 +615,6 @@ void wxPrintData::ConvertFromNative()
         else
             m_colour = TRUE;
 
-#ifndef __WXWINE__
         //// Paper size
 
         // We don't know size of user defined paper and some buggy drivers
@@ -705,7 +668,6 @@ void wxPrintData::ConvertFromNative()
             m_paperSize.y = 0;
             m_paperId = wxPAPER_NONE;
         }
-#endif
 
         //// Duplex
 
@@ -790,27 +752,196 @@ void wxPrintData::ConvertFromNative()
 #endif
 
 #ifdef __WXMAC__
+
 void wxPrintData::ConvertToNative()
 {
+    ValidateOrCreateNative() ;
 #if TARGET_CARBON
+    PMSetCopies( (PMPrintSettings) m_macPrintSettings , m_printNoCopies , false ) ;
+    PMSetOrientation( (PMPageFormat) m_macPageFormat , ( m_printOrientation == wxLANDSCAPE ) ?
+        kPMLandscape : kPMPortrait , false ) ;
+    // collate cannot be set
+#if 0 // not yet tested
+    if ( m_printerName.Length() > 0 )
+        PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxMacCFStringHolder( m_printerName ) ) ;
+#endif
+    PMColorMode color ;
+    PMGetColorMode(  (PMPrintSettings) m_macPrintSettings, &color ) ;
+    if (m_colour)
+    {
+        if ( color == kPMBlackAndWhite )
+            PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMColor ) ;
+    }
+    else
+        PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ;
+    
+    // PMDuplexMode not yet accessible via API
+    // PMQualityMode not yet accessible via API
+    // todo paperSize
 #else
+    // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
     (**(THPrint)m_macPrintSettings).prJob.iCopies = m_printNoCopies;
+    (**(THPrint)m_macPrintSettings).rPaper.left = int( ((double) m_minMarginTopLeft.x)*mm2pt );
+    (**(THPrint)m_macPrintSettings).rPaper.top = int( ((double) m_minMarginTopLeft.y)*mm2pt );
+
+    (**(THPrint)m_macPrintSettings).rPaper.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x)*mm2pt );
+    (**(THPrint)m_macPrintSettings).rPaper.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y)*mm2pt );
+
+    (**(THPrint)m_macPrintSettings).prInfo.rPage.left = 0;
+    (**(THPrint)m_macPrintSettings).prInfo.rPage.top = 0;
+    (**(THPrint)m_macPrintSettings).prInfo.rPage.right =  int( ((double) m_paperSize.x - m_minMarginTopLeft.x - m_minMarginBottomRight.x)*mm2pt );
+    (**(THPrint)m_macPrintSettings).prInfo.rPage.bottom =  int( ((double) m_paperSize.y - m_minMarginTopLeft.y - m_minMarginBottomRight.y)*mm2pt );
 #endif
 }
 
 void wxPrintData::ConvertFromNative()
 {
 #if TARGET_CARBON
+    OSStatus err = noErr ;
+    
+    UInt32 copies ;
+    err = PMGetCopies( (PMPrintSettings) m_macPrintSettings , &copies ) ;
+    if ( err == noErr )
+        m_printNoCopies = copies ; 
+          
+    PMOrientation orientation ;
+    err = PMGetOrientation(  (PMPageFormat) m_macPageFormat , &orientation ) ;
+    if ( err == noErr )
+    {
+        if ( orientation == kPMPortrait || orientation == kPMReversePortrait )
+            m_printOrientation = wxPORTRAIT ;
+        else
+            m_printOrientation = wxLANDSCAPE ;
+    }
+
+    // collate cannot be set
+#if 0
+    {
+        wxMacCFStringHolder name ;
+        PMPrinter printer ;
+        PMSessionGetCurrentPrinter( (PMPrintSession) m_macPrintSession ,
+            &printer ) ;
+        m_printerName = name.AsString() ;
+    }
+#endif
+    
+    PMColorMode color ;
+    err = PMGetColorMode(  (PMPrintSettings) m_macPrintSettings, &color ) ;
+    if ( err == noErr )
+        m_colour = !(color == kPMBlackAndWhite) ;
+        
+    // PMDuplexMode not yet accessible via API
+    // PMQualityMode not yet accessible via API
+    // todo paperSize
+       PMRect rPaper;
+    err = PMGetUnadjustedPaperRect((PMPageFormat) m_macPageFormat, &rPaper);
+    if ( err == noErr )
+    {
+        m_paperSize.x = (int)(( rPaper.right - rPaper.left ) * pt2mm + 0.5 );
+        m_paperSize.y = (int)(( rPaper.bottom - rPaper.top ) * pt2mm + 0.5 );
+    }
 #else
     m_printNoCopies = (**(THPrint)m_macPrintSettings).prJob.iCopies;
+    
+    // paper size
+    m_paperSize.x = ((double) (**(THPrint)m_macPrintSettings).rPaper.right - (**(THPrint)m_macPrintSettings).rPaper.left ) * pt2mm;
+    m_paperSize.y = ((double) (**(THPrint)m_macPrintSettings).rPaper.bottom - (**(THPrint)m_macPrintSettings).rPaper.top ) * pt2mm;
+#endif
+}
+
+void wxPrintData::ValidateOrCreateNative()
+{
+#if TARGET_CARBON
+    OSStatus err = noErr ;
+    if ( m_macPrintSession == kPMNoReference )
+    {
+        err = PMCreateSession( (PMPrintSession *) &m_macPrintSession ) ;
+    }
+    //  Set up a valid PageFormat object.
+    if ( m_macPageFormat == kPMNoPageFormat)
+    {
+        err = PMCreatePageFormat((PMPageFormat *) &m_macPageFormat);
+        
+        //  Note that PMPageFormat is not session-specific, but calling
+        //  PMSessionDefaultPageFormat assigns values specific to the printer
+        //  associated with the current printing session.
+        if ((err == noErr) &&
+            ( m_macPageFormat != kPMNoPageFormat))
+        {
+            err = PMSessionDefaultPageFormat((PMPrintSession) m_macPrintSession,
+                (PMPageFormat) m_macPageFormat);
+        }
+    }
+    else
+    {
+        err = PMSessionValidatePageFormat((PMPrintSession) m_macPrintSession,
+            (PMPageFormat) m_macPageFormat,
+            kPMDontWantBoolean);
+    }
+    
+    //  Set up a valid PrintSettings object.
+    if ( m_macPrintSettings == kPMNoPrintSettings)
+    {
+        err = PMCreatePrintSettings((PMPrintSettings *) &m_macPrintSettings);
+        
+        //  Note that PMPrintSettings is not session-specific, but calling
+        //  PMSessionDefaultPrintSettings assigns values specific to the printer
+        //  associated with the current printing session.
+        if ((err == noErr) &&
+            ( m_macPrintSettings != kPMNoPrintSettings))
+        {
+            err = PMSessionDefaultPrintSettings((PMPrintSession) m_macPrintSession,
+                (PMPrintSettings) m_macPrintSettings);
+        }
+    }
+    else
+    {
+        err = PMSessionValidatePrintSettings((PMPrintSession) m_macPrintSession,
+            (PMPrintSettings) m_macPrintSettings,
+            kPMDontWantBoolean);
+    }
+#else
 #endif
 }
+
 #endif
 
 void wxPrintData::operator=(const wxPrintData& data)
 {
 #ifdef __WXMAC__
 #if TARGET_CARBON
+       if ( m_macPrintSession != kPMNoPrintSettings )
+       {
+               PMRelease( m_macPrintSession ) ;
+               m_macPrintSession = kPMNoPrintSettings ;
+       }
+       if ( data.m_macPrintSession != kPMNoPrintSettings )
+       {
+               m_macPrintSession = data.m_macPrintSession ;
+               PMRetain( m_macPrintSession ) ;
+       }
+
+       if ( m_macPrintSettings != kPMNoPrintSettings )
+       {
+               PMRelease( m_macPrintSettings ) ;
+               m_macPrintSettings = kPMNoPrintSettings ;
+       }
+       if ( data.m_macPrintSettings != kPMNoPrintSettings )
+       {
+               m_macPrintSettings = data.m_macPrintSettings ;
+               PMRetain( m_macPrintSettings ) ;
+       }
+
+       if ( m_macPageFormat != kPMNoPageFormat )
+       {
+               PMRelease( m_macPageFormat ) ;
+               m_macPageFormat = kPMNoPageFormat ;
+       }
+       if ( data.m_macPageFormat != kPMNoPageFormat )
+       {
+               m_macPageFormat = data.m_macPageFormat ;
+               PMRetain( m_macPageFormat ) ;
+       }
 #else
     m_macPrintSettings = data.m_macPrintSettings;
     HandToHand( (Handle*) &m_macPrintSettings );
@@ -839,32 +970,6 @@ void wxPrintData::operator=(const wxPrintData& data)
     m_printMode = data.m_printMode;
 }
 
-// For compatibility
-#if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
-void wxPrintData::operator=(const wxPrintSetupData& setupData)
-{
-    SetPrinterCommand(setupData.GetPrinterCommand());
-    SetPreviewCommand(setupData.GetPrintPreviewCommand());
-    SetPrinterOptions(setupData.GetPrinterOptions());
-
-    long xt, yt;
-    setupData.GetPrinterTranslation(& xt, & yt);
-    SetPrinterTranslation(xt, yt);
-
-    double xs, ys;
-    setupData.GetPrinterScaling(& xs, & ys);
-    SetPrinterScaling(xs, ys);
-
-    SetOrientation(setupData.GetPrinterOrientation());
-    SetPrintMode((wxPrintMode) setupData.GetPrinterMode());
-    SetFontMetricPath(setupData.GetAFMPath());
-    if (setupData.GetPaperName() != "")
-        SetPaperId(wxThePrintPaperDatabase->ConvertNameToId(setupData.GetPaperName()));
-    SetColour(setupData.GetColour());
-    SetFilename(setupData.GetPrinterFile());
-}
-#endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
-
 // Is this data OK for showing the print dialog?
 bool wxPrintData::Ok() const
 {
@@ -1122,25 +1227,43 @@ void wxPrintDialogData::SetOwnerWindow(wxWindow* win)
 #endif // MSW
 
 #ifdef __WXMAC__
+
 void wxPrintDialogData::ConvertToNative()
 {
+    m_printData.ConvertToNative();
 #if TARGET_CARBON
+    PMSetPageRange( (PMPrintSettings) m_printData.m_macPrintSettings , m_printMinPage , m_printMaxPage ) ;
+    PMSetCopies( (PMPrintSettings) m_printData.m_macPrintSettings , m_printNoCopies , false ) ;
+    PMSetFirstPage( (PMPrintSettings) m_printData.m_macPrintSettings , m_printFromPage , false ) ;
+    PMSetLastPage( (PMPrintSettings) m_printData.m_macPrintSettings , m_printToPage , false ) ;
 #else
     (**(THPrint)m_printData.m_macPrintSettings).prJob.iFstPage = m_printFromPage;
     (**(THPrint)m_printData.m_macPrintSettings).prJob.iLstPage = m_printToPage;
-    m_printData.ConvertToNative();
 #endif
 }
 
 void wxPrintDialogData::ConvertFromNative()
 {
+    m_printData.ConvertFromNative();
 #if TARGET_CARBON
+    UInt32 minPage , maxPage ;
+    PMGetPageRange( (PMPrintSettings) m_printData.m_macPrintSettings , &minPage , &maxPage ) ;
+    m_printMinPage = minPage ;
+    m_printMaxPage = maxPage ;
+    UInt32 copies ;
+    PMGetCopies( (PMPrintSettings) m_printData.m_macPrintSettings , &copies ) ;
+    m_printNoCopies = copies ;
+    UInt32 from , to ;
+    PMGetFirstPage((PMPrintSettings) m_printData.m_macPrintSettings , &from ) ;
+    PMGetLastPage((PMPrintSettings) m_printData.m_macPrintSettings , &to ) ;
+    m_printFromPage = from ;
+    m_printToPage = to ;
 #else
-    m_printData.ConvertFromNative();
     m_printFromPage = (**(THPrint)m_printData.m_macPrintSettings).prJob.iFstPage;
     m_printToPage = (**(THPrint)m_printData.m_macPrintSettings).prJob.iLstPage;
 #endif
 }
+
 #endif
 
 
@@ -1454,39 +1577,41 @@ void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win)
 void wxPageSetupDialogData::ConvertToNative()
 {
     m_printData.ConvertToNative();
-    // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
+    // should we setup the page rect here ?
+    // since MacOS sometimes has two same paper rects with different
+    // page rects we could make it roundtrip safe perhaps
 #if TARGET_CARBON
 #else
-    (**(THPrint)m_printData.m_macPrintSettings).rPaper.left = int( ((double) m_minMarginTopLeft.x)*mm2pt );
-    (**(THPrint)m_printData.m_macPrintSettings).rPaper.top = int( ((double) m_minMarginTopLeft.y)*mm2pt );
-
-    (**(THPrint)m_printData.m_macPrintSettings).rPaper.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x)*mm2pt );
-    (**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y)*mm2pt );
-
-    (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.left = 0;
-    (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.top = 0;
-    (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.right =  int( ((double) m_paperSize.x - m_minMarginTopLeft.x - m_minMarginBottomRight.x)*mm2pt );
-    (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.bottom =  int( ((double) m_paperSize.y - m_minMarginTopLeft.y - m_minMarginBottomRight.y)*mm2pt );
 #endif
 }
 
 void wxPageSetupDialogData::ConvertFromNative()
 {
     m_printData.ConvertFromNative ();
-
+    m_paperSize = m_printData.GetPaperSize() ;
+    CalculateIdFromPaperSize();
 #if TARGET_CARBON
+       PMRect rPaper;
+    OSStatus err = PMGetUnadjustedPaperRect((PMPageFormat) m_printData.m_macPageFormat, &rPaper);
+    if ( err == noErr )
+    {
+        PMRect rPage ;
+        err = PMGetUnadjustedPageRect((PMPageFormat) m_printData.m_macPageFormat , &rPage ) ;
+        if ( err == noErr )
+        {
+               m_minMarginTopLeft.x = (int)(((double) rPage.left - rPaper.left ) * pt2mm);
+               m_minMarginTopLeft.y = (int)(((double) rPage.top - rPaper.top ) * pt2mm);
+            m_minMarginBottomRight.x = ((double) rPaper.right - rPage.right ) * pt2mm;
+            m_minMarginBottomRight.y = ((double) rPaper.bottom - rPage.bottom ) * pt2mm;
+           }
+       }
 #else
-    m_paperSize.x = ((double) (**(THPrint)m_printData.m_macPrintSettings).rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ) * pt2mm;
-    m_paperSize.y = ((double) (**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ) * pt2mm;
-
-    m_minMarginTopLeft.x = ((double) -(**(THPrint)m_printData.m_macPrintSettings).rPaper.left ) * pt2mm;
-    m_minMarginTopLeft.y = ((double) -(**(THPrint)m_printData.m_macPrintSettings).rPaper.top ) * pt2mm;
-
-    m_minMarginBottomRight.x = ((double) (**(THPrint)m_printData.m_macPrintSettings).rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.right ) * pt2mm;
-    m_minMarginBottomRight.y = ((double)(**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.bottom ) * pt2mm;
+    m_minMarginTopLeft.x = ((double) (**(THPrint)m_macPrintSettings).prInfo.rPage.left )-(**(THPrint)m_macPrintSettings).rPaper.left ) * pt2mm;
+    m_minMarginTopLeft.y = ((double) (**(THPrint)m_macPrintSettings).prInfo.rPage.top )-(**(THPrint)m_macPrintSettings).rPaper.top ) * pt2mm;
+    m_minMarginBottomRight.x = ((double) (**(THPrint)m_macPrintSettings).rPaper.right - (**(THPrint)m_macPrintSettings).prInfo.rPage.right ) * pt2mm;
+    m_minMarginBottomRight.y = ((double)(**(THPrint)m_macPrintSettings).rPaper.bottom - (**(THPrint)m_macPrintSettings).prInfo.rPage.bottom ) * pt2mm;
 #endif
     // adjust minimal values
-    //TODO add custom fields in dialog for margins
 
     if ( m_marginTopLeft.x < m_minMarginTopLeft.x )
         m_marginTopLeft.x = m_minMarginTopLeft.x;