[Commits] r2269 - in extensions/geoext.ux/ux/PrintPreview: examples lib/GeoExt.ux resources/css

commits at geoext.org commits at geoext.org
Thu Aug 12 11:00:30 CEST 2010


Author: ahocevar
Date: 2010-08-12 11:00:30 +0200 (Thu, 12 Aug 2010)
New Revision: 2269

Modified:
   extensions/geoext.ux/ux/PrintPreview/examples/PrintPreview.js
   extensions/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/PrintPreview.js
   extensions/geoext.ux/ux/PrintPreview/resources/css/printpreview.css
Log:
Use the PrintMapPanel's previewScales store and the limitScales option. Don't let the user zoom in the preview by other means than choosing a print scale from the scales combo. r=tschaub (closes #310)


Modified: extensions/geoext.ux/ux/PrintPreview/examples/PrintPreview.js
===================================================================
--- extensions/geoext.ux/ux/PrintPreview/examples/PrintPreview.js	2010-08-12 08:58:07 UTC (rev 2268)
+++ extensions/geoext.ux/ux/PrintPreview/examples/PrintPreview.js	2010-08-12 09:00:30 UTC (rev 2269)
@@ -2,18 +2,28 @@
 
 Ext.onReady(function() {
 
+    var bounds = new OpenLayers.Bounds(
+        143.835, -43.648,
+        148.479, -39.574
+    );
     mapPanel = new GeoExt.MapPanel({
         region: "center",
+        map: {
+            maxExtent: bounds,
+            maxResolution: 0.018140625,
+            projection: "EPSG:4326",
+            units: 'degrees'
+        },
         layers: [
             new OpenLayers.Layer.WMS("Tasmania State Boundaries",
                 "http://demo.opengeo.org/geoserver/wms",
-                {layers: "topp:tasmania_state_boundaries"}, {singleTile: true}),
+                {layers: "topp:tasmania_state_boundaries"},
+                {singleTile: true, numZoomLevels: 8}),
             new OpenLayers.Layer.WMS("Tasmania Water Bodies",
                 "http://demo.opengeo.org/geoserver/wms",
                 {layers: "topp:tasmania_water_bodies", transparent: true},
                 {buffer: 0})],
-        center: [146.56, -41.7],
-        zoom: 6,
+        extent: bounds,
         bbar: [{
             text: "Print...",
             handler: showPrintWindow
@@ -44,7 +54,21 @@
         border: false,
         resizable: false,
         width: 360,
+        autoHeight: true,
         items: new GeoExt.ux.PrintPreview({
+            autoHeight: true,
+            printMapPanel: {
+                // limit scales to those that can be previewed
+                limitScales: true,
+                // no zooming on the map
+                map: {controls: [
+                    new OpenLayers.Control.Navigation({
+                        zoomBoxEnabled: false,
+                        zoomWheelEnabled: false,
+                    }),
+                    new OpenLayers.Control.PanPanel()
+                ]}
+            },
             printProvider: {
                 // using get for remote service access without same origin
                 // restriction. For async requests, we would set method to "POST".

Modified: extensions/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/PrintPreview.js
===================================================================
--- extensions/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/PrintPreview.js	2010-08-12 08:58:07 UTC (rev 2268)
+++ extensions/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/PrintPreview.js	2010-08-12 09:00:30 UTC (rev 2269)
@@ -165,17 +165,22 @@
         
         this.form = this.createForm();
 
-        GeoExt.ux.PrintPreview.superclass.initComponent.call(this);
-        
-        this.add(this.createToolbar());
-        this.add({
+        if (!this.items) {
+            this.items = [];
+        }
+        this.items.push(this.createToolbar(), {
             xtype: "container",
             cls: "gx-printpreview",
+            autoHeight: this.autoHeight,
+            autoWidth: this.autoWidth,
             items: [
                 this.form,
                 this.printMapPanel
             ]
         });
+
+        GeoExt.ux.PrintPreview.superclass.initComponent.call(this);
+        
         this.addMapOverlay && this.printMapPanel.add(this.createMapOverlay());
 
         this.printMapPanel.on({
@@ -337,9 +342,10 @@
                 cls: "x-small-editor x-form-item",
                 items: {
                     xtype: "combo",
+                    name: "scale",
                     anchor: "100%",
                     hideLabel: true,
-                    store: this.printProvider.scales,
+                    store: this.printMapPanel.previewScales,
                     displayField: "name",
                     typeAhead: true,
                     mode: "local",
@@ -377,8 +383,11 @@
     updateSize: function() {
         this.suspendEvents();
         var mapWidth = this.printMapPanel.getWidth();
-        // sync form width with map width
+        // sync form and toolbar width with map width
         this.form.setWidth(mapWidth);
+        this.items.get(0).setWidth(
+            this.form.ownerCt.el.getPadding("lr") + mapWidth
+        );
         this.doLayout();
         // shadow does not sync, so do it manually
         var parent = this.ownerCt;

Modified: extensions/geoext.ux/ux/PrintPreview/resources/css/printpreview.css
===================================================================
--- extensions/geoext.ux/ux/PrintPreview/resources/css/printpreview.css	2010-08-12 08:58:07 UTC (rev 2268)
+++ extensions/geoext.ux/ux/PrintPreview/resources/css/printpreview.css	2010-08-12 09:00:30 UTC (rev 2269)
@@ -3,7 +3,7 @@
 }
 
 .gx-printpreview {
-    padding: 5px 0 5px 0;
+    padding: 5px;
 }
 
 /* fixes textarea scrollbar issue in FF on OSX */



More information about the Commits mailing list