Changeset 2529


Ignore:
Timestamp:
Feb 1, 2012 6:51:14 PM (5 years ago)
Author:
liuar
Message:

Submit on behalf of Mars Wu
Fix ticket: http://trac.osgeo.org/mapguide/ticket/1943 - Quick Plot: Preview layout of portrait map is not proper

The reason for tis is the preview dialog is automatically adjusted to fit the browser window. But it considered only the "width", not the height because Then consider also the height when adjust the size of the preview dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/widgets/QuickPlot/PreviewDialog.js

    r2509 r2529  
    5050            height: 400,
    5151            content: '<table border="0" cellspacing="0" cellpadding="0" id="PreviewContainer">' +
    52                      '  <tr>' +
    53                      '          <td>' +
    54                      '                  <iframe id="PreviewFrame" scrolling="no" frameborder="0" style="border: 0px; width: 400px; height: 300px;" src="about:blank"></iframe>' +
    55                      '          </td>' +
    56                      '  </tr>' +
     52                     '    <tr>' +
     53                     '        <td>' +
     54                     '            <iframe id="PreviewFrame" scrolling="no" frameborder="0" style="border: 0px; width: 400px; height: 300px;" src="about:blank"></iframe>' +
     55                     '        </td>' +
     56                     '    </tr>' +
    5757                     '</table>'
    5858        });
     
    142142            this.previewContainer = $(this.innerDoc.getElementById("PreviewContainer"));
    143143            this.previewContainer.style.width = box.width * factor + "px";
    144             this.pictureContainer = $(this.innerDoc.getElementById("PictureContainer"));
    145             var pcBox = this.pictureContainer.getContentBoxSize();
    146            
    147             this.indicator        = $(this.innerDoc.getElementById("ProgressIndicator"));
    148            
    149             var paperSize  = this.captureInfo.paperSize;
    150             this.paperSize = paperSize;
    151            
    152             var ratio = paperSize.w / paperSize.h;
    153            
    154             // Resize the indicator
    155             this.indicator.style.width  = pcBox.width + "px";
    156             this.indicator.style.height = pcBox.width / ratio + "px";
    157             // Set a explicit size to the container
    158             this.pictureContainer.style.width  = this.indicator.style.width;
    159             this.pictureContainer.style.height = this.indicator.style.height;
     144            this.resizePictureContainer();
     145           
     146            // Verify if the priview container "overflows" the visible screen area
     147            var containerBox = this.previewContainer.getContentBoxSize();
     148            if (containerBox.height > box.height)
     149            {
     150                var overhead = $(this.innerDoc.getElementById("legalNotice")).getMarginBoxSize().height + $(this.innerDoc.getElementById("AnnotationContainer")).getMarginBoxSize().height + 4 * this.previewContainer.cellSpacing;
     151                this.previewContainer.style.width = containerBox.width * box.height / containerBox.height - overhead + "px";
     152                this.resizePictureContainer();
     153            }
     154
    160155            // Get the styles for the print picture
    161156            var rules = this.innerDoc.styleSheets[1].cssRules || this.innerDoc.styleSheets[1].rules;
     
    221216    },
    222217   
     218    resizePictureContainer: function()
     219    {
     220        this.innerDoc         = this.previewFrame.contentWindow.document;
     221
     222        this.indicator        = $(this.innerDoc.getElementById("ProgressIndicator"));
     223        // Reset the size of the indicator first
     224        this.indicator.style.width = "";
     225        this.indicator.style.height = "";
     226        // Reset the size of the picture container
     227        this.pictureContainer = $(this.innerDoc.getElementById("PictureContainer"));
     228        this.pictureContainer.style.width = "";
     229        this.pictureContainer.style.height = "";
     230       
     231        // Resize
     232        var pcBox = this.pictureContainer.getContentBoxSize();
     233        var ratio = this.captureInfo.paperSize.w / this.captureInfo.paperSize.h;
     234
     235        this.indicator.style.width  = pcBox.width + "px";
     236        this.indicator.style.height = pcBox.width / ratio + "px";
     237       
     238        // Set an explicit size to the container
     239        this.pictureContainer.style.width  = this.indicator.style.width;
     240        this.pictureContainer.style.height = this.indicator.style.height;
     241    },
     242   
    223243    previewInnerLoaded: function()
    224244    {
     
    290310        // NOTE: It works only with a 96 dpi device dpi
    291311        var deviceDpi  = 96;
    292         var idealSize  = {width:(this.paperSize.w / 25.4 - 2 * this.printMargin) * deviceDpi, height:(this.paperSize.h / 25.4 - 2 * this.printMargin) * deviceDpi};
     312        var idealSize  = {width:(this.captureInfo.paperSize.w / 25.4 - 2 * this.printMargin) * deviceDpi, height:(this.captureInfo.paperSize.h / 25.4 - 2 * this.printMargin) * deviceDpi};
    293313        // Get the size of the print frame
    294314        var docSize    = $(this.innerDoc.body).getContentBoxSize();
    295315        var realHeight = idealSize.height - (docSize.height - size.height);
    296         var realWidth  = realHeight * this.paperSize.w / this.paperSize.h;
     316        var realWidth  = realHeight * this.captureInfo.paperSize.w / this.captureInfo.paperSize.h;
    297317        if (realWidth > idealSize.width)
    298318        {
    299319            realWidth = idealSize.width;
    300             realHeight = realWidth / (this.paperSize.w / this.paperSize.h);
     320            realHeight = realWidth / (this.captureInfo.paperSize.w / this.captureInfo.paperSize.h);
    301321        }
    302322       
Note: See TracChangeset for help on using the changeset viewer.