Commits

Philipp Lohmann [pl]  committed 9ac2c00

vcl116: #i107331# show papersize in print preview

  • Participants
  • Parent commits c59e889

Comments (0)

Files changed (2)

File vcl/inc/vcl/prndlg.hxx

             VirtualDevice       maPageVDev;
             rtl::OUString       maReplacementString;
             rtl::OUString       maToolTipString;
+            FixedLine           maHorzDim;
+            FixedLine           maVertDim;
             
             bool useHCColorReplacement() const;
         public:

File vcl/source/window/printdlg.cxx

     , maOrigSize( 10, 10 )
     , maPageVDev( *this )
     , maToolTipString( String( VclResId( SV_PRINT_PRINTPREVIEW_TXT ) ) )
+    , maHorzDim( this, WB_HORZ | WB_CENTER  )
+    , maVertDim( this, WB_VERT | WB_VCENTER )
 {
     SetPaintTransparent( TRUE );
     SetBackground();
         maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() );
     else
         maPageVDev.SetBackground( Color( COL_WHITE ) );
+    maHorzDim.Show();
+    maVertDim.Show();
+    
+    maHorzDim.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "2.0in" ) ) );
+    maVertDim.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "2.0in" ) ) );
 }
 
 PrintDialog::PrintPreviewWindow::~PrintPreviewWindow()
 void PrintDialog::PrintPreviewWindow::Resize()
 {
     Size aNewSize( GetSizePixel() );
+    long nTextHeight = maHorzDim.GetTextHeight();
     // leave small space for decoration
-    aNewSize.Width() -= 2;
-    aNewSize.Height() -= 2;
+    aNewSize.Width() -= nTextHeight + 2;
+    aNewSize.Height() -= nTextHeight + 2;
     Size aScaledSize;
     double fScale = 1.0;
     
     }
     
     maPageVDev.SetOutputSizePixel( aScaledSize, FALSE );
+
+    // position dimension lines
+    Point aRef( nTextHeight + (aNewSize.Width() - maPreviewSize.Width())/2,
+                nTextHeight + (aNewSize.Height() - maPreviewSize.Height())/2 );
+    maHorzDim.SetPosSizePixel( Point( aRef.X(), aRef.Y() - nTextHeight ),
+                               Size( maPreviewSize.Width(), nTextHeight ) );
+    maVertDim.SetPosSizePixel( Point( aRef.X() - nTextHeight, aRef.Y() ),
+                               Size( nTextHeight, maPreviewSize.Height() ) );
+    
 }
 
 void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& )
 {
+    long nTextHeight = maHorzDim.GetTextHeight(); 
     Size aSize( GetSizePixel() );
+    aSize.Width()  -= nTextHeight;
+    aSize.Height() -= nTextHeight;
     if( maReplacementString.getLength() != 0 )
     {
         // replacement is active
         Push();
-        Rectangle aTextRect( Point( 0, 0 ), aSize );
+        Rectangle aTextRect( Point( nTextHeight, nTextHeight ), aSize );
         DecorationView aVw( this );
         aVw.DrawFrame( aTextRect, FRAME_DRAW_GROUP );
         aTextRect.Left()   += 2;
     {
         GDIMetaFile aMtf( maMtf );
     
-        Point aOffset( (aSize.Width() - maPreviewSize.Width()) / 2,
-                       (aSize.Height() - maPreviewSize.Height()) / 2 );
+        Point aOffset( (aSize.Width() - maPreviewSize.Width()) / 2 + nTextHeight,
+                       (aSize.Height() - maPreviewSize.Height()) / 2 + nTextHeight );
     
         Size aVDevSize( maPageVDev.GetOutputSizePixel() );
         const Size aLogicSize( maPageVDev.PixelToLogic( aVDevSize, MapMode( MAP_100TH_MM ) ) );
 {
     rtl::OUStringBuffer aBuf( 256 );
     aBuf.append( maToolTipString );
-    #if OSL_DEBUG_LEVEL > 0
-    aBuf.appendAscii( "\n---\nPageSize: " );
-    aBuf.append( sal_Int32( i_rOrigSize.Width()/100) );
-    aBuf.appendAscii( "mm x " );
-    aBuf.append( sal_Int32( i_rOrigSize.Height()/100) );
-    aBuf.appendAscii( "mm" );
-    #endif
     SetQuickHelpText( aBuf.makeStringAndClear() );
     maMtf = i_rNewPreview;
     if( useHCColorReplacement() )
     maReplacementString = i_rReplacement;
     maPageVDev.SetReferenceDevice( i_nDPIX, i_nDPIY );
     maPageVDev.EnableOutput( TRUE );
+
+    // use correct measurements
+    const LocaleDataWrapper& rLocWrap( GetSettings().GetLocaleDataWrapper() );
+    MapUnit eUnit = MAP_MM;
+    int nDigits = 0;
+    if( rLocWrap.getMeasurementSystemEnum() == MEASURE_US )
+    {
+        eUnit = MAP_100TH_INCH;
+        nDigits = 2;
+    }
+    Size aLogicPaperSize( LogicToLogic( i_rOrigSize, MapMode( MAP_100TH_MM ), MapMode( eUnit ) ) );
+    String aNumText( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) );
+    aBuf.append( aNumText );
+    aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" );
+    maHorzDim.SetText( aBuf.makeStringAndClear() );
+    
+    aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits );
+    aBuf.append( aNumText );
+    aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" );
+    maVertDim.SetText( aBuf.makeStringAndClear() );
+
     Resize();
     Invalidate();
 }