Changeset 2530


Ignore:
Timestamp:
Feb 27, 2012 11:49: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

Location:
sandbox/adsk/2.3r/widgets/QuickPlot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sandbox/adsk/2.3r/widgets/QuickPlot/PreviewDialog.js

    r2234 r2530  
    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        });
     
    131131            this.previewContainer = $(this.innerDoc.getElementById("PreviewContainer"));
    132132            this.previewContainer.style.width = box.width * factor + "px";
    133             this.pictureContainer = $(this.innerDoc.getElementById("PictureContainer"));
    134             var pcBox = this.pictureContainer.getContentBoxSize();
    135            
    136             this.indicator        = $(this.innerDoc.getElementById("ProgressIndicator"));
    137            
    138             var paperSize  = this.captureInfo.paperSize;
    139             this.paperSize = paperSize;
    140            
    141             var ratio = paperSize.w / paperSize.h;
    142            
    143             // Resize the indicator
    144             this.indicator.style.width  = pcBox.width + "px";
    145             this.indicator.style.height = pcBox.width / ratio + "px";
    146             // Set a explicit size to the container
    147             this.pictureContainer.style.width  = this.indicator.style.width;
    148             this.pictureContainer.style.height = this.indicator.style.height;
     133            this.resizePictureContainer();
     134           
     135            // Verify if the priview container "overflows" the visible screen area
     136            var containerBox = this.previewContainer.getContentBoxSize();
     137            if (containerBox.height > box.height)
     138            {
     139                var overhead = $(this.innerDoc.getElementById("legalNotice")).getMarginBoxSize().height + $(this.innerDoc.getElementById("AnnotationContainer")).getMarginBoxSize().height + 4 * this.previewContainer.cellSpacing;
     140                this.previewContainer.style.width = containerBox.width * box.height / containerBox.height - overhead + "px";
     141                this.resizePictureContainer();
     142            }
     143
    149144            // Get the styles for the print picture
    150145            var rules = this.innerDoc.styleSheets[1].cssRules || this.innerDoc.styleSheets[1].rules;
     
    167162                  "&normalized_box=" + this.captureInfo.params2 +
    168163                  "&scale_denominator=" + this.captureInfo.scaleDenominator +
    169                   "&rotation=" + this.captureInfo.rotation;
     164                  "&rotation=" + this.captureInfo.rotation +
     165                  "&timestamp=" + (new Date()).getTime();
    170166               
    171167            this.printPicture       = $(this.innerDoc.getElementById("PrintPicture"));
    172             this.printPicture.src   = src;
    173168           
    174169            // Listen to print picture onload vent
    175170            this.printPicture.addEvent("load", this.printPictureLoaded.bind(this));
    176171            this.printPicture.addEvent("error", this.printPictureLoadError.bind(this));
     172            this.printPicture.src   = src;
    177173           
    178174            var innerBox  = this.previewContainer.getMarginBoxSize();
     
    209205            this.resizeIsPending = true;
    210206        }
     207    },
     208   
     209    resizePictureContainer: function()
     210    {
     211        this.innerDoc         = this.previewFrame.contentWindow.document;
     212
     213        this.indicator        = $(this.innerDoc.getElementById("ProgressIndicator"));
     214        // Reset the size of the indicator first
     215        this.indicator.style.width = "";
     216        this.indicator.style.height = "";
     217        // Reset the size of the picture container
     218        this.pictureContainer = $(this.innerDoc.getElementById("PictureContainer"));
     219        this.pictureContainer.style.width = "";
     220        this.pictureContainer.style.height = "";
     221       
     222        // Resize
     223        var pcBox = this.pictureContainer.getContentBoxSize();
     224        var ratio = this.captureInfo.paperSize.w / this.captureInfo.paperSize.h;
     225
     226        this.indicator.style.width  = pcBox.width + "px";
     227        this.indicator.style.height = pcBox.width / ratio + "px";
     228       
     229        // Set an explicit size to the container
     230        this.pictureContainer.style.width  = this.indicator.style.width;
     231        this.pictureContainer.style.height = this.indicator.style.height;
    211232    },
    212233   
     
    247268        // NOTE: It works only with a 96 dpi device dpi
    248269        var deviceDpi  = 96;
    249         var idealSize  = {width:(this.paperSize.w / 25.4 - 2 * this.printMargin) * deviceDpi, height:(this.paperSize.h / 25.4 - 2 * this.printMargin) * deviceDpi};
     270        var idealSize  = {width:(this.captureInfo.paperSize.w / 25.4 - 2 * this.printMargin) * deviceDpi, height:(this.captureInfo.paperSize.h / 25.4 - 2 * this.printMargin) * deviceDpi};
    250271        // Get the size of the print frame
    251272        var docSize    = $(this.innerDoc.body).getContentBoxSize();
    252273        var realHeight = idealSize.height - (docSize.height - size.height);
    253         var realWidth  = realHeight * this.paperSize.w / this.paperSize.h;
     274        var realWidth  = realHeight * this.captureInfo.paperSize.w / this.captureInfo.paperSize.h;
    254275        if (realWidth > idealSize.width)
    255276        {
    256277            realWidth = idealSize.width;
    257             realHeight = realWidth / (this.paperSize.w / this.paperSize.h);
     278            realHeight = realWidth / (this.captureInfo.paperSize.w / this.captureInfo.paperSize.h);
    258279        }
    259280       
  • sandbox/adsk/2.3r/widgets/QuickPlot/QuickPlotPreviewInner.templ

    r2234 r2530  
    7575        <tr>
    7676          <!-- Legal notice. Just replace it with the necessary statement -->
    77           <td style="width:100%%" class="LegalNotice">The materials available at this web site are for informational purposes only and do not constitute a legal document.</td>
     77          <td style="width:100%%" class="LegalNotice" id="legalNotice">The materials available at this web site are for informational purposes only and do not constitute a legal document.</td>
    7878          <td style="white-space:nowrap"><input type="button" id="PrintButton" class="Button" onClick="printIt()" value="__#QUICKPLOT_PRINT#__" /><input type="button" id="CancelButton" class="Button" onClick="cancelPreview()" value="__#QUICKPLOT_CANCEL#__" />
    7979          </td>
Note: See TracChangeset for help on using the changeset viewer.