Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


This patch improves appearance of the print dialog a bit. See attached
"before.png" and "after.png" with special attention to preview area.
From 867305ce96b273cc65f0f2df9d1068eba3974dd0 Mon Sep 17 00:00:00 2001
From: Ivan Timofeev <timofeev.i.s@gmail.com>
Date: Tue, 27 Sep 2011 18:52:30 +0400
Subject: [PATCH] Print preview: set frame size to preview size even if there
 is no preview

---
 vcl/source/window/printdlg.cxx |   26 ++++++++++----------------
 1 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 5f01ac2..969030c 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -158,21 +158,17 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& )
 {
     long nTextHeight = maHorzDim.GetTextHeight();
     Size aSize( GetSizePixel() );
-    aSize.Width()  -= nTextHeight;
-    aSize.Height() -= nTextHeight;
+    Point aOffset( (aSize.Width()  - maPreviewSize.Width()  + nTextHeight) / 2 ,
+                   (aSize.Height() - maPreviewSize.Height() + nTextHeight) / 2 );
+
     if( maReplacementString.getLength() != 0 )
     {
         // replacement is active
         Push();
-        Rectangle aTextRect( Point( nTextHeight, nTextHeight ), aSize );
-        DecorationView aVw( this );
-        aVw.DrawFrame( aTextRect, FRAME_DRAW_GROUP );
-        aTextRect.Left()   += 2;
-        aTextRect.Top()    += 2;
-        aTextRect.Right()  -= 2;
-        aTextRect.Bottom() -= 2;
         Font aFont( GetSettings().GetStyleSettings().GetLabelFont() );
         SetZoomedPointFont( aFont );
+        Rectangle aTextRect( aOffset + Point( 2, 2 ),
+            Size( maPreviewSize.Width() - 4, maPreviewSize.Height() - 4 ) );
         DrawText( aTextRect, maReplacementString,
                   TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE
                  );
@@ -182,9 +178,6 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& )
     {
         GDIMetaFile aMtf( maMtf );
 
-        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 ) ) );
         Size aOrigSize( maOrigSize );
@@ -213,11 +206,12 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& )
         maPageVDev.SetMapMode( MAP_PIXEL );
         DrawOutDev( aOffset, maPreviewSize, Point( 0, 0 ), aVDevSize, maPageVDev );
         maPageVDev.SetDrawMode( nOldDrawMode );
-
-        DecorationView aVw( this );
-        Rectangle aFrame( aOffset + Point( -1, -1 ), Size( maPreviewSize.Width() + 2, 
maPreviewSize.Height() + 2 ) );
-        aVw.DrawFrame( aFrame, FRAME_DRAW_GROUP );
     }
+
+    Rectangle aFrameRect( aOffset + Point( -1, -1 ),
+        Size( maPreviewSize.Width() + 2, maPreviewSize.Height() + 2 ) );
+    DecorationView aVw( this );
+    aVw.DrawFrame( aFrameRect, FRAME_DRAW_GROUP );
 }
 
 void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt )
-- 
1.7.6.3

Attachment: before.png
Description: PNG image

Attachment: after.png
Description: PNG image


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.