[Commits] r1857 - in sandbox/ahocevar/playground/geoext.ux: examples tests ux ux/PrintPreview ux/PrintPreview/examples ux/PrintPreview/lib ux/PrintPreview/lib/GeoExt.ux ux/PrintPreview/resources ux/PrintPreview/resources/css ux/PrintPreview/resources/images ux/PrintPreview/resources/images/silk ux/PrintPreview/tests ux/PrintPreview/tests/lib ux/PrintPreview/tests/lib/GeoExt.ux ux/SimplePrint ux/SimplePrint/examples ux/SimplePrint/lib ux/SimplePrint/lib/GeoExt.ux ux/SimplePrint/tests ux/SimplePrint/tests/lib ux/SimplePrint/tests/lib/GeoExt.ux
commits at geoext.org
commits at geoext.org
Mon Feb 1 19:08:37 CET 2010
Author: ahocevar
Date: 2010-02-01 19:08:36 +0100 (Mon, 01 Feb 2010)
New Revision: 1857
Added:
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.html
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.js
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/PrintPreview.js
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/loader.js
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/css/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/css/printpreview.css
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/north_arrow.png
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/silk/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/silk/printer.png
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/silk/readme.txt
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/index.html
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/lib/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/lib/GeoExt.ux/
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/lib/GeoExt.ux/PrintPreview.html
sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/list-tests.html
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.html
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.js
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/GeoExt.ux/
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/GeoExt.ux/SimplePrint.js
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/loader.js
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/index.html
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/lib/
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/lib/GeoExt.ux/
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/lib/GeoExt.ux/SimplePrint.html
sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/list-tests.html
Modified:
sandbox/ahocevar/playground/geoext.ux/examples/index.html
sandbox/ahocevar/playground/geoext.ux/tests/list-tests.html
Log:
commit to sandbox what was submitted as #112 and #113
Modified: sandbox/ahocevar/playground/geoext.ux/examples/index.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/examples/index.html 2010-02-01 09:54:17 UTC (rev 1856)
+++ sandbox/ahocevar/playground/geoext.ux/examples/index.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -6,6 +6,8 @@
<h2>GeoExt.ux examples</h2>
<ul>
<li><a href="../ux/GeoNamesSearchCombo/examples/GeoNamesSearchComboExample.html">GeoNames search combobox</a></li>
+ <li><a href="../ux/PrintPreview/examples/PrintPreview.html">PrintPreview using GeoExt.data.PrintProvider</a></li>
+ <li><a href="../ux/SimplePrint/examples/SimplePrint.html">SimplePrint Form using GeoExt.data.PrintProvider</a></li>
</ul>
</body>
</html>
Modified: sandbox/ahocevar/playground/geoext.ux/tests/list-tests.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/tests/list-tests.html 2010-02-01 09:54:17 UTC (rev 1856)
+++ sandbox/ahocevar/playground/geoext.ux/tests/list-tests.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -1,3 +1,5 @@
<ul id="testlist">
<li>../../geoext.ux/ux/GeoNamesSearchCombo/tests/lib/GeoExt.ux.geonames/GeoNamesSearchCombo.html</li>
+ <li>../../geoext.ux/ux/PrintPreview/tests/lib/GeoExt.ux/PrintPreview.html</li>
+ <li>../../geoext.ux/ux/SimplePrint/tests/lib/GeoExt.ux/SimplePrint.html</li>
</ul>
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.html (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,42 @@
+<html>
+ <head>
+ <title>Printing ux PrintPreview Example</title>
+
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/adapter/ext/ext-base.js"></script>
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/ext-all.js"></script>
+ <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.0.0/resources/css/ext-all.css" />
+ <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.0.0/examples/shared/examples.css" />
+ <script src="http://www.openlayers.org/api/2.8/OpenLayers.js"></script>
+ <script type="text/javascript" src="../../../../geoext/lib/GeoExt.js"></script>
+
+ <!-- script and css resources for this ux -->
+ <script type="text/javascript" src="../lib/GeoExt.ux/PrintPreview.js"></script>
+ <link rel="stylesheet" type="text/css" href="../resources/css/printpreview.css" />
+
+ <script type="text/javascript" src="PrintPreview.js"></script>
+
+ <script type="text/javascript" src="http://demo.opengeo.org/geoserver/pdf/info.json?var=printCapabilities"></script>
+
+ </head>
+ <body>
+ <h1>PrintPreview using GeoExt.data.PrintProvider</h1>
+
+ <p>This example shows how to use GeoExt.data.PrintProvider to talk
+ to the <a href="http://trac.mapfish.org/trac/mapfish/wiki/PrintModuleInstallation">Mapfish print module</a>,
+ which is also available as
+ <a href="http://geoserver.org/display/GEOS/Printing+2.0+HOWTO">GeoServer print module</a>.</p>
+
+ <p>Use the "Print" button from the bottom toolbar of the map to open
+ the print dialog.</p>
+
+ <p>Note that this example uses GET requests to communicate with the
+ print servlet (provided by the OpenGeo demo server). This saves us a
+ proxy, but has limitations (URL length in Internet Explorer, and
+ character encoding issues). For production use, the POST method is
+ recommended.</p>
+
+ <p>See <a href="PrintPreview.js">PrintPreview.js</a> for the source code.</p>
+
+ <div id="content"></div>
+ </body>
+</html>
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.html
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.js
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.js (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.js 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,67 @@
+var mapPanel, printMapPanel, legendPanel;
+
+Ext.onReady(function() {
+
+ mapPanel = new GeoExt.MapPanel({
+ region: "center",
+ layers: [
+ new OpenLayers.Layer.WMS("Tasmania State Boundaries",
+ "http://demo.opengeo.org/geoserver/wms",
+ {layers: "topp:tasmania_state_boundaries"}, {singleTile: true}),
+ 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,
+ bbar: [{
+ text: "Print...",
+ handler: showPrintWindow
+ }]
+ });
+
+ legendPanel = new GeoExt.LegendPanel({
+ width: 200,
+ region: "west",
+ defaults: {
+ style: "padding:5px",
+ imageFormat: "image/png"
+ }
+ });
+ new Ext.Panel({
+ layout: "border",
+ renderTo: "content",
+ width: 800,
+ height: 350,
+ items: [mapPanel, legendPanel]
+ });
+});
+
+function showPrintWindow() {
+ var printWindow = new Ext.Window({
+ title: "Print",
+ modal: true,
+ border: false,
+ resizable: false,
+ width: 360,
+ items: new GeoExt.ux.PrintPreview({
+ bodyStyle: "padding:5px",
+ printProvider: {
+ // using get for remote service access without same origin
+ // restriction. For async requests, we would set method to "POST".
+ method: "GET",
+ //method: "POST",
+
+ // capabilities from script tag in Printing.html.
+ capabilities: printCapabilities,
+ listeners: {
+ "print": function() {printWindow.close();}
+ }
+ },
+ includeLegend: true,
+ mapTitle: "PrintMapPanel Demo",
+ sourceMap: mapPanel,
+ legend: legendPanel
+ })
+ }).show().center();
+}
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/examples/PrintPreview.js
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/PrintPreview.js
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/PrintPreview.js (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/PrintPreview.js 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,401 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ *
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+Ext.namespace("GeoExt.ux");
+
+/** api: (define)
+ * module = GeoExt.ux
+ * class = PrintPreview
+ * base_link = `Ext.Panel <http://extjs.com/deploy/dev/docs/?class=Ext.Panel>`_
+ */
+
+/** api: constructor
+ * .. class:: PrintPreview
+ *
+ * A print preview with an interactive map. Requires a server-side print
+ * module configuration with two custom fields (by default ``mapTitle`` and
+ * ``comment``).
+ */
+GeoExt.ux.PrintPreview = Ext.extend(Ext.Panel, {
+
+ /* begin i18n */
+ /** api: config[paperSizeText] ``String`` i18n */
+ paperSizeText: "Paper size:",
+ /** api: config[resolutionText] ``String`` i18n */
+ resolutionText: "Resolution:",
+ /** api: config[printText] ``String`` i18n */
+ printText: "Print",
+ /** api: config[emptyTitleText] ``String`` i18n */
+ emptyTitleText: "Enter map title here.",
+ /** api: config[includeLegendText] ``String`` i18n */
+ includeLegendText: "Include legend?",
+ /** api: config[emptyCommentText] ``String`` i18n */
+ emptyCommentText: "Enter comments here.",
+ /** api: config[creatingPdfText] ``String`` i18n */
+ creatingPdfText: "Creating PDF...",
+ /* end i18n */
+
+ /** api: config[printProvider]
+ * :class:`GeoExt.data.PrintProvider`|``Object`` Instance or
+ * configuration for the PrintProvider that this dialog will use. Not
+ * required if provided with the
+ * :ref:`GeoExt.ux.PrintPreview.printMapPanel`.
+ */
+
+ /** private: property[printProvider]
+ * :class:`GeoExt.data.PrintProvider`
+ */
+ printProvider: null,
+
+ /** api: config[sourceMap]
+ * :class:`GeoExt.MapPanel`|``OpenLayers.Map`` The map to copy layers and
+ * extent from for printing. Not required if provided with the
+ * :ref:`GeoExt.ux.PrintPreview.printMapPanel`.
+ */
+
+ /** private: property[sourceMap]
+ * ``OpenLayers.Map`` The map to copy layers and extent from for printing.
+ */
+ sourceMap: null,
+
+ /** api: config[printMapPanel]
+ * :class:`GeoExt.PrintMapPanel`:``Object`` Optional. Useful e.g.
+ * for adding a ZoomSlider (via ``items``) or setting map options (like
+ * configuring custom controls or filtering out unsupported layers with
+ * a preaddlayer listener via ``map``).
+ *
+ * .. note:: If provided as :class:`GeoExt.PrintMapPanel`, this has to be
+ * configured with ``printProvider`` and ``sourceMap``.
+ */
+
+ /** api: property[printMapPanel]
+ * class:`GeoExt.PrintMapPanel` The print preview map. Read-only.
+ */
+ printMapPanel: null,
+
+ /** api: config[mapTitleField]
+ * ``String`` The custom field of the print service for the map title
+ */
+ mapTitleField: "mapTitle",
+
+ /** api: config[commentField]
+ * ``String`` The custom field of the print service for the comment
+ */
+ commentField: "comment",
+
+ /** api: config[legend]
+ * ref:`GeoExt.LegendPanel` The legend to include. If not provided, the
+ * dialog won't have an option to include the legend.
+ */
+ legend: null,
+
+ /** api: config[includeLegend]
+ * ``Boolean`` Initial status of the "Include legend?" checkbox. Will be
+ * ignored if :ref:`GeoExt.ux.PrintPreview.legend` is not provided.
+ */
+ includeLegend: false,
+
+ /** api: config[mapTitle]
+ * ``String`` An optional title to set for the mapTitle field when
+ * creating the dialog.
+ */
+ mapTitle: null,
+
+ /** api: config[comment]
+ * ``String`` An optional comment to set for the comment field when
+ * creating the dialog.
+ */
+ comment: null,
+
+ /** api: config[addMapOverlay]
+ * ``Boolean`` Set to false if no map overlay with scale, scale selector
+ * and north arrow should be added. Default is true.
+ */
+ addMapOverlay: true,
+
+ /** api: config[busyMask]
+ * ``Ext.LoadMask`` A LoadMask to use while the print document is
+ * prepared. Optional, will be auto-created with ``creatingPdfText` if
+ * not provided.
+ */
+
+ /** private: property[busyMask]
+ * ``Ext.LoadMask``
+ */
+ busyMask: null,
+
+ /** private: property[form]
+ * ``Ext.form.FormPanel`` The form for this dialog.
+ */
+ form: null,
+
+ /** private: method[initComponent]
+ */
+ initComponent: function() {
+ this.bodyCfg = Ext.applyIf({
+ tag: "center",
+ cls: "x-panel-body"
+ }, this.bodyCfg);
+
+ var printMapPanelOptions = {
+ sourceMap: this.sourceMap,
+ printProvider: this.printProvider
+ };
+ if(this.printMapPanel) {
+ if(!(this.printMapPanel instanceof GeoExt.PrintMapPanel)) {
+ printMapPanelOptions.xtype = "gx_printmappanel"
+ this.printMapPanel = new GeoExt.PrintMapPanel(
+ Ext.applyIf(this.printMapPanel, printMapPanelOptions));
+ }
+ } else {
+ this.printMapPanel = new GeoExt.PrintMapPanel(
+ printMapPanelOptions);
+ }
+ this.sourceMap = this.printMapPanel.sourceMap;
+ this.printProvider = this.printMapPanel.printProvider;
+
+ this.form = this.createForm();
+ this.tbar = this.createToolbar();
+
+ GeoExt.ux.PrintPreview.superclass.initComponent.call(this);
+
+ this.add(this.form);
+ this.add(this.printMapPanel);
+ this.addMapOverlay && this.printMapPanel.add(this.createMapOverlay());
+
+ this.printMapPanel.on({
+ "resize": this.updateSize,
+ scope: this
+ });
+ this.on({
+ "render": function() {
+ if (!this.busyMask) {
+ this.busyMask = new Ext.LoadMask(this.getEl(), {
+ msg: this.creatingPdfText
+ });
+ }
+ this.printProvider.on({
+ "beforeprint": this.busyMask.show,
+ "print": this.busyMask.hide,
+ scope: this.busyMask
+ });
+ },
+ scope: this
+ });
+ },
+
+ /** private: method[createToolbar]
+ * :return: ``Ext.Toolbar``
+ */
+ createToolbar: function() {
+ var items = [];
+ this.printProvider.layouts.getCount() > 1 && items.push(this.paperSizeText, {
+ xtype: "combo",
+ width: 98,
+ plugins: new GeoExt.plugins.PrintProviderField({
+ printProvider: this.printProvider
+ }),
+ store: this.printProvider.layouts,
+ displayField: "name",
+ typeAhead: true,
+ mode: "local",
+ forceSelection: true,
+ triggerAction: "all",
+ selectOnFocus: true
+ }, " ");
+ this.printProvider.dpis.getCount() > 1 && items.push(this.resolutionText, {
+ xtype: "combo",
+ width: 62,
+ plugins: new GeoExt.plugins.PrintProviderField({
+ printProvider: this.printProvider
+ }),
+ store: this.printProvider.dpis,
+ displayField: "name",
+ tpl: '<tpl for="."><div class="x-combo-list-item">{name} dpi</div></tpl>',
+ typeAhead: true,
+ mode: "local",
+ forceSelection: true,
+ triggerAction: "all",
+ selectOnFocus: true,
+ setValue: function(v){
+ v = parseInt(v) + " dpi";
+ Ext.form.ComboBox.prototype.setValue.apply(this, arguments);
+ }
+ });
+ items.push("->", {
+ text: this.printText,
+ iconCls: "icon-print",
+ handler: function(){
+ this.printMapPanel.print(this.includeLegend &&
+ {legend: this.legend});
+ },
+ scope: this
+ });
+ return new Ext.Toolbar(items);
+ },
+
+ /** private: method[createForm]
+ * :return: ``Ext.form.FormPanel``
+ */
+ createForm: function() {
+ var titleCfg = {
+ xtype: "textfield",
+ name: this.mapTitleField,
+ value: this.mapTitle,
+ emptyText: this.emptyTitleText,
+ anchor: "100%",
+ hideLabel: true,
+ plugins: new GeoExt.plugins.PrintProviderField({
+ printProvider: this.printProvider
+ })
+ };
+
+ if(this.legend) {
+ var legendCheckbox = new Ext.form.Checkbox({
+ name: "legend",
+ checked: this.includeLegend,
+ boxLabel: this.includeLegendText,
+ anchor: "100%",
+ hideLabel: true,
+ handler: function(cb, checked) {
+ this.includeLegend = checked;
+ },
+ scope: this
+ });
+
+ // fix for IE which has ColumnLayout problems when some of the
+ // container's components don't have a size
+ Ext.isIE && this.on("afterlayout", function() {
+ var ct = legendCheckbox.ownerCt;
+ ct.setWidth(Ext.util.TextMetrics.measure(legendCheckbox.getEl(),
+ this.includeLegendText).width + 34);
+ }, this)
+ }
+
+ return new Ext.form.FormPanel({
+ autoHeight: true,
+ border: false,
+ defaults: {
+ anchor: "100%"
+ },
+ items: [
+ this.legend ? {
+ xtype: "container",
+ layout: "column",
+ items: [{
+ xtype: "container",
+ layout: "form",
+ columnWidth: 1,
+ items: titleCfg
+ }, {
+ xtype: "container",
+ layout: "form",
+ style: "padding-left:8px",
+ items: legendCheckbox
+ }]
+ } : titleCfg, {
+ xtype: "textarea",
+ name: this.commentField,
+ value: this.comment,
+ emptyText: this.emptyCommentText,
+ hideLabel: true,
+ plugins: new GeoExt.plugins.PrintProviderField({
+ printProvider: this.printProvider
+ })
+ }
+ ]
+ });
+ },
+
+ /** private: method[createMapOverlay]
+ * :return: ``Ext.Panel``
+ */
+ createMapOverlay: function() {
+ var scaleLine = new OpenLayers.Control.ScaleLine();
+ this.printMapPanel.map.addControl(scaleLine);
+ scaleLine.activate();
+ return new Ext.Panel({
+ cls: "gx-map-overlay",
+ layout: "column",
+ width: 235,
+ bodyStyle: "padding:5px",
+ items: [{
+ xtype: "box",
+ el: scaleLine.div,
+ width: scaleLine.maxWidth
+ }, {
+ xtype: "container",
+ layout: "form",
+ style: "padding: .2em 5px 0 0;",
+ columnWidth: 1,
+ cls: "x-small-editor x-form-item",
+ items: {
+ xtype: "combo",
+ anchor: "100%",
+ hideLabel: true,
+ store: this.printProvider.scales,
+ displayField: "name",
+ typeAhead: true,
+ mode: "local",
+ forceSelection: true,
+ triggerAction: "all",
+ selectOnFocus: true,
+ plugins: new GeoExt.plugins.PrintPageField({
+ printPage: this.printMapPanel.printPage
+ })
+ }
+ }, {
+ xtype: "box",
+ autoEl: {
+ tag: "div",
+ cls: "gx-northarrow"
+ }
+ }],
+ listeners: {
+ "render": function() {
+ function stop(evt){evt.stopPropagation();}
+ this.getEl().on({
+ "click": stop,
+ "dblclick": stop,
+ "mousedown": stop
+ });
+ }
+ }
+ });
+ },
+
+ /** private: method[updateSize]
+ * sync the form's width with the map with, and make sure that the window
+ * shadow is updated if this dialog is added to an ``Ext.Window``
+ */
+ updateSize: function() {
+ this.suspendEvents();
+ var mapWidth = this.printMapPanel.getWidth();
+ // sync form width with map width
+ this.form.setWidth(mapWidth);
+ this.doLayout();
+ // shadow does not sync, so do it manually
+ var parent = this.ownerCt;
+ if (parent && typeof parent.syncShadow == "function") {
+ this.ownerCt.syncShadow();
+ }
+ this.resumeEvents();
+ },
+
+ /** private: method[beforeDestroy]
+ */
+ beforeDestroy: function() {
+ this.printProvider.un("beforeprint", this.busyMask.show, this.busyMask);
+ this.printProvider.un("print", this.busyMask.hide, this.busyMask);
+ this.printMapPanel.un("resize", this.updateSize, this);
+ GeoExt.ux.PrintPreview.superclass.beforeDestroy.apply(this, arguments);
+ }
+
+});
+
+/** api: xtype = gxux_printpreview */
+Ext.reg("gxux_printpreview", GeoExt.ux.PrintPreview);
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/GeoExt.ux/PrintPreview.js
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/loader.js
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/loader.js (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/loader.js 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,80 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ *
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+/*
+ * The code in this file is based on code taken from OpenLayers.
+ *
+ * Copyright (c) 2006-2007 MetaCarta, Inc., published under the Clear BSD
+ * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license.
+ */
+
+(function() {
+
+ /**
+ * The relative path of this script.
+ */
+ var scriptName = "lib/loader.js";
+
+ /**
+ * Function returning the path of this script.
+ */
+ var getScriptLocation = function() {
+ var scriptLocation = "";
+ // If we load other scripts right before GeoExt using the same
+ // mechanism to add script resources dynamically (e.g. OpenLayers),
+ // document.getElementsByTagName will not find the GeoExt script tag
+ // in FF2. Using document.documentElement.getElementsByTagName instead
+ // works around this issue.
+ var scripts = document.documentElement.getElementsByTagName('script');
+ for(var i=0, len=scripts.length; i<len; i++) {
+ var src = scripts[i].getAttribute('src');
+ if(src) {
+ var index = src.lastIndexOf(scriptName);
+ // set path length for src up to a query string
+ var pathLength = src.lastIndexOf('?');
+ if(pathLength < 0) {
+ pathLength = src.length;
+ }
+ // is it found, at the end of the URL?
+ if((index > -1) && (index + scriptName.length == pathLength)) {
+ scriptLocation = src.slice(0, pathLength - scriptName.length);
+ break;
+ }
+ }
+ }
+ return scriptLocation;
+ };
+
+ var jsfiles = new Array(
+ "GeoExt.ux/PrintPreview.js"
+ );
+
+ var agent = navigator.userAgent;
+ var docWrite = (agent.match("MSIE") || agent.match("Safari"));
+ if(docWrite) {
+ var allScriptTags = new Array(jsfiles.length);
+ }
+ var host = getScriptLocation() + "lib/";
+ for (var i=0, len=jsfiles.length; i<len; i++) {
+ if (docWrite) {
+ allScriptTags[i] = "<script src='" + host + jsfiles[i] +
+ "'></script>";
+ } else {
+ var s = document.createElement("script");
+ s.src = host + jsfiles[i];
+ var h = document.getElementsByTagName("head").length ?
+ document.getElementsByTagName("head")[0] :
+ document.body;
+ h.appendChild(s);
+ }
+ }
+ if (docWrite) {
+ document.write(allScriptTags.join(""));
+ }
+})();
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/lib/loader.js
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/css/printpreview.css
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/css/printpreview.css (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/css/printpreview.css 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,29 @@
+.x-btn .icon-print {
+ background-image: url(../images/silk/printer.png);
+}
+
+.gx-map-overlay {
+ z-index: 1000;
+ position: absolute;
+ right: 10px;
+ bottom: 10px;
+ text-align: left;
+}
+
+.gx-map-overlay .x-panel-body {
+ background-color: #D0DEF0;
+}
+
+.gx-map-overlay .olControlScaleLine {
+ bottom: 0;
+ left: 0;
+ position: relative !important;
+}
+
+.gx-northarrow {
+ background: transparent url(../images/north_arrow.png) no-repeat;
+ *-background: none;
+ *-filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../resources/images/north_arrow.png',sizingMethod='crop');
+ height: 24px;
+ width: 24px;
+}
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/css/printpreview.css
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/north_arrow.png
===================================================================
(Binary files differ)
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/north_arrow.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/silk/printer.png
===================================================================
(Binary files differ)
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/silk/printer.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/silk/readme.txt
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/silk/readme.txt (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/silk/readme.txt 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,22 @@
+Silk icon set 1.3
+
+_________________________________________
+Mark James
+http://www.famfamfam.com/lab/icons/silk/
+_________________________________________
+
+This work is licensed under a
+Creative Commons Attribution 2.5 License.
+[ http://creativecommons.org/licenses/by/2.5/ ]
+
+This means you may use it for any purpose,
+and make any changes you like.
+All I ask is that you include a link back
+to this page in your credits.
+
+Are you using this icon set? Send me an email
+(including a link or picture if available) to
+mjames at gmail.com
+
+Any other questions about this icon set please
+contact mjames at gmail.com
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/resources/images/silk/readme.txt
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/index.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/index.html (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/index.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,4 @@
+<html>
+ <head><meta http-equiv="refresh" content="0;url=../../../../geoext/tests/run-tests.html?testlist=../../geoext.ux/ux/PrintPreview/tests/list-tests.html"></head>
+ <body></body>
+</html>
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/index.html
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/lib/GeoExt.ux/PrintPreview.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/lib/GeoExt.ux/PrintPreview.html (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/lib/GeoExt.ux/PrintPreview.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,115 @@
+<!DOCTYPE html>
+<html debug="true">
+ <head>
+ <script type="text/javascript" src="http://www.openlayers.org/api/2.8/OpenLayers.js"></script>
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/adapter/ext/ext-base.js"></script>
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/ext-all.js"></script>
+ <script type="text/javascript" src="../../../../../../geoext/lib/GeoExt.js"></script>
+ <script type="text/javascript" src="../../../lib/GeoExt.ux/PrintPreview.js"></script>
+
+ <script type="text/javascript">
+ var printCapabilities = {"scales":[{"name":"1:25,000","value":"25000"},{"name":"1:50,000","value":"50000"},{"name":"1:100,000","value":"100000"},{"name":"1:200,000","value":"200000"},{"name":"1:500,000","value":"500000"},{"name":"1:1,000,000","value":"1000000"},{"name":"1:2,000,000","value":"2000000"},{"name":"1:4,000,000","value":"4000000"}],"dpis":[{"name":"75","value":"75"},{"name":"150","value":"150"},{"name":"300","value":"300"}],"layouts":[{"name":"A4 portrait","map":{"width":440,"height":483},"rotation":true},{"name":"Legal","map":{"width":440,"height":483},"rotation":false}],"printURL":"http://demo.opengeo.org/geoserver/pdf/print.pdf","createURL":"http://demo.opengeo.org/geoserver/pdf/create.json"};
+
+ function test_initComponent(t) {
+ t.plan(12);
+
+ var mapPanel = new GeoExt.MapPanel({
+ renderTo: "mappanel",
+ width: 256,
+ height: 256,
+ layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries",
+ "http://demo.opengeo.org/geoserver/wms",
+ {layers: "topp:tasmania_state_boundaries"}, {singleTile: true})],
+ center: [146.56, -41.56],
+ zoom: 7
+ });
+
+ var log = {};
+ var printPreview = new GeoExt.ux.PrintPreview({
+ renderTo: "printpreview",
+ printMapPanel: {
+ map: {
+ controls: [new OpenLayers.Control.PanPanel()],
+ eventListeners: {
+ preaddlayer: function() {
+ log.preaddlayer = true;
+ }
+ }
+ },
+ printProvider: {
+ capabilities: printCapabilities
+ },
+ sourceMap: mapPanel,
+ items: [{
+ xtype: "gx_zoomslider"
+ }]
+ }
+ });
+
+ var size = printPreview.printProvider.layout.get("size");
+ var center = mapPanel.map.getCenter();
+
+ t.eq(printPreview.printMapPanel.map.controls.length, printPreview.printMapPanel.map.controls[0].controls.length+2, "Preview map has only the controls we added,");
+ t.ok(printPreview.printMapPanel.map.controls[0] instanceof OpenLayers.Control.PanPanel, "which is a PanPanel");
+ t.ok(log.preaddlayer, "preaddlayer listener registered.");
+ t.eq(printPreview.printMapPanel.items.getCount(), 2, "PrintMapPanel has two items,");
+ t.eq(printPreview.printMapPanel.items.get(0).getXType(), "gx_zoomslider", "a ZoomSlider");
+ t.eq(printPreview.printMapPanel.items.get(1).getXType(), "panel", "and our map overlay with scaleline etc.");
+ t.ok(printPreview.printProvider, "PrintProvider taken from printMapPanel config.");
+ t.ok(printPreview.sourceMap, "sourceMap taken from printMapPanel config.");
+
+ t.eq(printPreview.items.getCount(), 2, "PrintPreview has two items,");
+ t.ok(printPreview.items.get(0) instanceof Ext.form.FormPanel, "a FormPanel");
+ t.ok(printPreview.items.get(1) instanceof GeoExt.PrintMapPanel, "and a PrintMapPanel,");
+ t.eq(printPreview.items.get(0).getWidth(), printPreview.items.get(1).getWidth(), "with the form having the same width as the map.");
+
+ printPreview.destroy();
+ mapPanel.destroy();
+ }
+
+ function test_createForm(t) {
+ t.plan(3);
+
+ var mapPanel = new GeoExt.MapPanel({
+ renderTo: "mappanel",
+ width: 256,
+ height: 256,
+ layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries",
+ "http://demo.opengeo.org/geoserver/wms",
+ {layers: "topp:tasmania_state_boundaries"}, {singleTile: true})],
+ center: [146.56, -41.56],
+ zoom: 7
+ });
+
+ var printPreview = new GeoExt.ux.PrintPreview({
+ renderTo: "printpreview",
+ printProvider: {
+ capabilities: printCapabilities
+ },
+ sourceMap: mapPanel
+ });
+ t.eq(printPreview.items.get(0).items.get(0).getXType(), "textfield", "textfield line created correctly without legend checkbox.");
+ printPreview.destroy();
+
+ var printPreview = new GeoExt.ux.PrintPreview({
+ renderTo: "printpreview",
+ printProvider: {
+ capabilities: printCapabilities
+ },
+ sourceMap: mapPanel,
+ legend: "fake_legend",
+ includeLegend: true
+ });
+ t.eq(printPreview.items.get(0).items.get(0).getXType(), "container", "textfield line created correctly with legend checkbox.");
+ t.eq(printPreview.items.get(0).items.get(0).items.get(1).items.get(0).getValue(), true, "legend checkbox checked when includeLegend is set to true.");
+ printPreview.destroy();
+
+ mapPanel.destroy();
+ }
+
+ </script>
+ <body>
+ <div id="mappanel"></div>
+ <div id="printpreview"></div>
+ </body>
+</html>
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/lib/GeoExt.ux/PrintPreview.html
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/list-tests.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/list-tests.html (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/list-tests.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,3 @@
+<ul id="testlist">
+ <li>../../geoext.ux/ux/PrintPreview/tests/lib/GeoExt.ux/PrintPreview.html</li>
+</ul>
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/PrintPreview/tests/list-tests.html
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.html (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,50 @@
+<html>
+ <head>
+ <title>Printing ux SimplePrint Example</title>
+
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/adapter/ext/ext-base.js"></script>
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/ext-all.js"></script>
+ <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
+ <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css" />
+ <script src="http://dev.openlayers.org/nightly/OpenLayers.js"></script>
+ <script type="text/javascript" src="../../../../geoext/lib/GeoExt.js"></script>
+
+ <!-- script resources for this ux -->
+ <script type="text/javascript" src="../lib/GeoExt.ux/SimplePrint.js"></script>
+
+ <script type="text/javascript" src="SimplePrint.js"></script>
+
+ <!--
+ Using the script tag method to get the print service capabilities and
+ make them available in the printCapabilities variable.
+ The script tag below can be removed when configuring the printProvider
+ with url instead of capabilities
+ -->
+ <script type="text/javascript" src="http://demo.opengeo.org/geoserver/pdf/info.json?var=printCapabilities"></script>
+
+ </head>
+ <body>
+ <h1>SimplePrint Form using GeoExt.data.PrintProvider</h1>
+
+ <p>This example shows how to use GeoExt.ux.SimplePrint to talk
+ to the <a href="http://trac.mapfish.org/trac/mapfish/wiki/PrintModuleInstallation">Mapfish print module</a>,
+ which is also available as
+ <a href="http://geoserver.org/display/GEOS/Printing+2.0+HOWTO">GeoServer print module</a>.</p>
+
+ <p>The rectangle and handles on the map can be used to change center,
+ scale and rotation. Dragging one of the handles will change the scale.
+ Dragging the corner handles on their edges will rotate the extent, if
+ supported by the layout. Holding the SHIFT key will constrain rotation
+ to 45° steps.</p>
+
+ <p>Note that this example uses GET requests to communicate with the
+ print servlet (provided by the OpenGeo demo server). This saves us a
+ proxy, but has limitations (URL length in Internet Explorer, and
+ character encoding issues). For production use, the POST method is
+ recommended.</p>
+
+ <p>See <a href="SimplePrint.js">SimplePrint.js</a> for the source code.</p>
+
+ <div id="content"></div>
+ </body>
+</html>
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.html
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.js
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.js (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.js 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,138 @@
+var printProvider, printForm;
+
+Ext.onReady(function() {
+
+ printProvider = new GeoExt.data.PrintProvider({
+ // using get for remote service access without same origin restriction.
+ // For asynchronous requests, we would set method to "POST".
+ method: "GET",
+ //method: "POST",
+
+ // capabilities from script tag in Printing.html. For asynchonous
+ // loading, we would configure url instead of capabilities.
+ capabilities: printCapabilities
+ //url: "/geoserver/pdf/"
+ });
+
+ var mapPanel = new GeoExt.MapPanel({
+ region: "center",
+ layers: [new OpenLayers.Layer.WMS("Global Imagery",
+ "http://labs.metacarta.com/wms/vmap0",
+ {layers: "basic"})],
+ center: [16,48],
+ zoom: 5
+ });
+
+ // create a vector layer, which will also be printed.
+ var redline = new OpenLayers.Layer.Vector("vector", {
+ styleMap: new OpenLayers.StyleMap({
+ strokeColor: "red",
+ fillColor: "red",
+ fillOpacity: 0.7,
+ strokeWidth: 2,
+ pointRadius: 12,
+ externalGraphic: "http://openlayers.org/dev/img/marker-blue.png"
+ })
+ });
+ var geom = OpenLayers.Geometry.fromWKT, Vec = OpenLayers.Feature.Vector;
+ redline.addFeatures([
+ new Vec(geom("POLYGON(15 47, 15 46, 16 47, 16 48)")),
+ new Vec(geom("LINESTRING(14 48, 14 47, 15 48, 14 49, 16 49)")),
+ new Vec(geom("POINT(16 49)"))
+ ]);
+ mapPanel.map.addLayer(redline);
+
+ // Create a vector layer for the print page extent and handles.
+ // We only do this because we want fancy styles for the handles,
+ // otherwise SimplePrint's PrintExtent would auto-create one for us.
+ var extentLayer = new OpenLayers.Layer.Vector("print", {
+ displayInLayerSwitcher: false,
+ styleMap: new OpenLayers.StyleMap(new OpenLayers.Style(Ext.applyIf({
+ pointRadius: 4,
+ graphicName: "square",
+ rotation: "${getRotation}",
+ strokeColor: "${getStrokeColor}",
+ fillOpacity: "${getFillOpacity}"
+ }, OpenLayers.Feature.Vector.style["default"]), {
+ context: {
+ getRotation: function(feature) {
+ return printForm.printPage.rotation;
+ },
+ getStrokeColor: function(feature) {
+ return feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point" ?
+ "#000" : "#ee9900";
+ },
+ getFillOpacity: function(feature) {
+ return feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point" ?
+ 0 : 0.4;
+ }
+ }
+ })
+ )});
+
+ // a simple print form
+ printForm = new GeoExt.ux.SimplePrint({
+ mapPanel: mapPanel,
+ layer: extentLayer, // optional
+ autoFit: true,
+ printProvider: printProvider,
+ bodyStyle: {padding: "5px"},
+ labelWidth: 65,
+ defaults: {width: 115},
+ region: "east",
+ border: false,
+ width: 200
+ });
+
+ // add custom fields to the form
+ printForm.insert(0, {
+ xtype: "textfield",
+ name: "mapTitle",
+ fieldLabel: "Title",
+ value: "A custom title",
+ plugins: new GeoExt.plugins.PrintPageField({
+ printPage: printForm.printPage
+ })
+ });
+ printForm.insert(1, {
+ xtype: "textarea",
+ fieldLabel: "Comment",
+ name: "comment",
+ value: "A custom comment",
+ plugins: new GeoExt.plugins.PrintPageField({
+ printPage: printForm.printPage
+ })
+ });
+
+ var formCt = new Ext.Panel({
+ layout: "fit",
+ region: "east",
+ width: 200
+ });
+
+ new Ext.Panel({
+ renderTo: "content",
+ layout: "border",
+ width: 800,
+ height: 350,
+ items: [mapPanel, formCt]
+ });
+
+ /* add the print form to its container and make sure that the print page
+ * fits the max extent
+ */
+ formCt.add(printForm);
+ formCt.doLayout();
+
+ /* use this code block instead of the above one if you configured the
+ * printProvider with url instead of capabilities
+ var myMask = new Ext.LoadMask(formCt.body, {msg:"Loading data..."});
+ myMask.show();
+ printProvider.on("loadcapabilities", function() {
+ myMask.hide();
+ formCt.add(printForm);
+ formCt.doLayout();
+ });
+ */
+
+});
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/examples/SimplePrint.js
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/GeoExt.ux/SimplePrint.js
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/GeoExt.ux/SimplePrint.js (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/GeoExt.ux/SimplePrint.js 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,235 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ *
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+Ext.namespace("GeoExt.ux")
+
+/** api: (define)
+ * module = GeoExt.form
+ * class = SimplePrint
+ * base_link = `Ext.form.FormPanel <http://extjs.com/deploy/dev/docs/?class=Ext.form.FormPanel>`_
+ */
+
+/** api: constructor
+ * .. class:: SimplePrint
+ *
+ * An instance of this form creates a single print page. Layout, DPI, scale
+ * and rotation are configurable in the form. A Print button is also added to
+ * the form.
+ */
+GeoExt.ux.SimplePrint = Ext.extend(Ext.form.FormPanel, {
+
+ /* begin i18n */
+ /** api: config[layoutText] ``String`` i18n */
+ layoutText: "Layout",
+ /** api: config[dpiText] ``String`` i18n */
+ dpiText: "DPI",
+ /** api: config[scaleText] ``String`` i18n */
+ scaleText: "Scale",
+ /** api: config[rotationText] ``String`` i18n */
+ rotationText: "Rotation",
+ /** api: config[printText] ``String`` i18n */
+ printText: "Print",
+ /** api: config[creatingPdfText] ``String`` i18n */
+ creatingPdfText: "Creating PDF...",
+ /* end i18n */
+
+ /** api: config[printProvider]
+ * :class:`GeoExt.data.PrintProvider` The print provider this form
+ * is connected to.
+ */
+
+ /** api: config[mapPanel]
+ * :class:`GeoExt.MapPanel` The map panel that this form should be
+ * connected to.
+ */
+
+ /** api: config[layer]
+ * ``OpenLayers.Layer`` Layer to render page extents and handles
+ * to. Useful e.g. for setting a StyleMap. Optional, will be auto-created
+ * if not provided.
+ */
+
+ /** api: config[printOptions]
+ * ``Object`` Optional options for the printProvider's print command.
+ */
+
+ /** api: property[printOptions]
+ * ``Object`` Optional options for the printProvider's print command.
+ */
+ printOptions: null,
+
+ /** api: config[hideUnique]
+ * ``Boolean`` If set to false, combo boxes for stores with just one value
+ * will be rendered. Default is true.
+ */
+
+ /** api: config[hideRotation]
+ * ``Boolean`` If set to true, the Rotation field will not be rendered.
+ * Default is false.
+ */
+
+ /** api: config[busyMask]
+ * ``Ext.LoadMask`` A LoadMask to use while the print document is
+ * prepared. Optional, will be auto-created with ``creatingPdfText` if
+ * not provided.
+ */
+
+ /** private: property[busyMask]
+ * ``Ext.LoadMask``
+ */
+ busyMask: null,
+
+ /** private: property[printExtent]
+ * :class:`GeoExt.PrintExtent`
+ */
+ printExtent: null,
+
+ /** api: property[printPage]
+ * :class:`GeoExt.data.PrintPage` The print page for this form. Useful
+ * e.g. for rotating handles when used in a style map context. Read-only.
+ */
+ printPage: null,
+
+ /** private: method[initComponent]
+ */
+ initComponent: function() {
+ GeoExt.ux.SimplePrint.superclass.initComponent.call(this);
+
+ this.printExtent = new GeoExt.PrintExtent({
+ printProvider: this.initialConfig.printProvider,
+ layer: this.initialConfig.layer
+ });
+ this.printPage = this.printExtent.pages[0];
+
+ this.mapPanel.add(this.printExtent);
+
+ if (!this.busyMask) {
+ this.busyMask = new Ext.LoadMask(Ext.getBody(), {
+ msg: this.creatingPdfText
+ });
+ }
+
+ this.printExtent.printProvider.on({
+ "beforeprint": this.busyMask.show,
+ "print": this.busyMask.hide,
+ scope: this.busyMask
+ });
+
+ if(this.printExtent.printProvider.capabilities) {
+ this.initForm();
+ } else {
+ this.printExtent.printProvider.on({
+ "loadcapabilities": this.initForm,
+ scope: this,
+ single: true
+ });
+ }
+ },
+
+ /** private: method[initForm]
+ * Creates and adds items to the form.
+ */
+ initForm: function() {
+ var p = this.printExtent.printProvider;
+ var hideUnique = this.initialConfig.hideUnique !== false;
+ !(hideUnique && p.layouts.getCount() <= 1) && this.add({
+ xtype: "combo",
+ fieldLabel: this.layoutText,
+ store: p.layouts,
+ displayField: "name",
+ typeAhead: true,
+ mode: "local",
+ forceSelection: true,
+ triggerAction: "all",
+ selectOnFocus: true,
+ plugins: new GeoExt.plugins.PrintProviderField()
+ });
+ !(hideUnique && p.dpis.getCount() <= 1) && this.add({
+ xtype: "combo",
+ fieldLabel: this.dpiText,
+ store: p.dpis,
+ displayField: "name",
+ typeAhead: true,
+ mode: "local",
+ forceSelection: true,
+ triggerAction: "all",
+ selectOnFocus: true,
+ plugins: new GeoExt.plugins.PrintProviderField()
+ });
+ !(hideUnique && p.scales.getCount() <= 1) && this.add({
+ xtype: "combo",
+ fieldLabel: this.scaleText,
+ store: p.scales,
+ displayField: "name",
+ typeAhead: true,
+ mode: "local",
+ forceSelection: true,
+ triggerAction: "all",
+ selectOnFocus: true,
+ plugins: new GeoExt.plugins.PrintPageField({
+ printPage: this.printPage
+ })
+ });
+ this.initialConfig.hideRotation !== true && this.add({
+ xtype: "textfield",
+ fieldLabel: this.rotationText,
+ name: "rotation",
+ enableKeyEvents: true,
+ validator: function(v) {
+ return !isNaN(v)
+ },
+ plugins: new GeoExt.plugins.PrintPageField({
+ printPage: this.printPage
+ })
+ });
+
+ this.addButton({
+ text: this.printText,
+ handler: function() {
+ this.printExtent.print(this.printOptions);
+ },
+ scope: this
+ });
+
+ this.doLayout();
+
+ if(this.autoFit === true) {
+ this.onMoveend();
+ this.mapPanel.map.events.on({
+ "moveend": this.onMoveend,
+ scope: this
+ })
+ }
+ },
+
+ /** private: method[onMoveend]
+ * Handler for the map's moveend event
+ */
+ onMoveend: function() {
+ this.printPage.fit(this.mapPanel.map);
+ },
+
+ /** private: method[beforeDestroy]
+ */
+ beforeDestroy: function() {
+ var p = this.printExtent.printProvider;
+ p.un("beforePrint", this.busyMask.show, this.busyMask);
+ p.un("print", this.busyMask.hide, this.busyMask);
+ if(this.autoFit === true) {
+ this.mapPanel.map.events.un({
+ "moveend": this.onMoveend,
+ scope: this
+ })
+ }
+ GeoExt.ux.SimplePrint.superclass.beforeDestroy.apply(this, arguments);
+ }
+
+});
+
+/** api: xtype = gxux_simpleprint */
+Ext.reg("gxux_simpleprint", GeoExt.ux.SimplePrint);
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/GeoExt.ux/SimplePrint.js
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/loader.js
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/loader.js (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/loader.js 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,80 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ *
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+/*
+ * The code in this file is based on code taken from OpenLayers.
+ *
+ * Copyright (c) 2006-2007 MetaCarta, Inc., published under the Clear BSD
+ * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license.
+ */
+
+(function() {
+
+ /**
+ * The relative path of this script.
+ */
+ var scriptName = "lib/loader.js";
+
+ /**
+ * Function returning the path of this script.
+ */
+ var getScriptLocation = function() {
+ var scriptLocation = "";
+ // If we load other scripts right before GeoExt using the same
+ // mechanism to add script resources dynamically (e.g. OpenLayers),
+ // document.getElementsByTagName will not find the GeoExt script tag
+ // in FF2. Using document.documentElement.getElementsByTagName instead
+ // works around this issue.
+ var scripts = document.documentElement.getElementsByTagName('script');
+ for(var i=0, len=scripts.length; i<len; i++) {
+ var src = scripts[i].getAttribute('src');
+ if(src) {
+ var index = src.lastIndexOf(scriptName);
+ // set path length for src up to a query string
+ var pathLength = src.lastIndexOf('?');
+ if(pathLength < 0) {
+ pathLength = src.length;
+ }
+ // is it found, at the end of the URL?
+ if((index > -1) && (index + scriptName.length == pathLength)) {
+ scriptLocation = src.slice(0, pathLength - scriptName.length);
+ break;
+ }
+ }
+ }
+ return scriptLocation;
+ };
+
+ var jsfiles = new Array(
+ "GeoExt.ux/SimplePrint.js"
+ );
+
+ var agent = navigator.userAgent;
+ var docWrite = (agent.match("MSIE") || agent.match("Safari"));
+ if(docWrite) {
+ var allScriptTags = new Array(jsfiles.length);
+ }
+ var host = getScriptLocation() + "lib/";
+ for (var i=0, len=jsfiles.length; i<len; i++) {
+ if (docWrite) {
+ allScriptTags[i] = "<script src='" + host + jsfiles[i] +
+ "'></script>";
+ } else {
+ var s = document.createElement("script");
+ s.src = host + jsfiles[i];
+ var h = document.getElementsByTagName("head").length ?
+ document.getElementsByTagName("head")[0] :
+ document.body;
+ h.appendChild(s);
+ }
+ }
+ if (docWrite) {
+ document.write(allScriptTags.join(""));
+ }
+})();
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/lib/loader.js
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/index.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/index.html (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/index.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,4 @@
+<html>
+ <head><meta http-equiv="refresh" content="0;url=../../../../geoext/tests/run-tests.html?testlist=../../geoext.ux/ux/SimplePrint/tests/list-tests.html"></head>
+ <body></body>
+</html>
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/index.html
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/lib/GeoExt.ux/SimplePrint.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/lib/GeoExt.ux/SimplePrint.html (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/lib/GeoExt.ux/SimplePrint.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html debug="true">
+ <head>
+ <script type="text/javascript" src="http://dev.openlayers.org/nightly/OpenLayers.js"></script>
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/adapter/ext/ext-base.js"></script>
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/ext-all.js"></script>
+ <script type="text/javascript" src="../../../../../../geoext/lib/GeoExt.js"></script>
+ <script type="text/javascript" src="../../../lib/GeoExt.ux/SimplePrint.js"></script>
+
+ <script type="text/javascript">
+ var printCapabilities = {"scales":[{"name":"1:25,000","value":"25000"},{"name":"1:50,000","value":"50000"},{"name":"1:100,000","value":"100000"},{"name":"1:200,000","value":"200000"},{"name":"1:500,000","value":"500000"},{"name":"1:1,000,000","value":"1000000"},{"name":"1:2,000,000","value":"2000000"},{"name":"1:4,000,000","value":"4000000"}],"dpis":[{"name":"75","value":"75"},{"name":"150","value":"150"},{"name":"300","value":"300"}],"layouts":[{"name":"A4 portrait","map":{"width":440,"height":483},"rotation":true},{"name":"Legal","map":{"width":440,"height":483},"rotation":false}],"printURL":"http://demo.opengeo.org/geoserver/pdf/print.pdf","createURL":"http://demo.opengeo.org/geoserver/pdf/create.json"};
+
+ function test_initComponent(t) {
+ t.plan(5);
+
+ var mapPanel = new GeoExt.MapPanel({
+ renderTo: "mappanel",
+ width: 256,
+ height: 256,
+ layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries",
+ "http://demo.opengeo.org/geoserver/wms",
+ {layers: "topp:tasmania_state_boundaries"}, {singleTile: true})],
+ center: [146.56, -41.56],
+ zoom: 7
+ });
+ var printProvider = new GeoExt.data.PrintProvider({
+ capabilities: printCapabilities
+ });
+ var printForm = new GeoExt.ux.SimplePrint({
+ renderTo: "printform",
+ width: 200,
+ height: 400,
+ mapPanel: mapPanel,
+ printProvider: printProvider
+ });
+
+ t.ok(printForm.printExtent, "PrintExtent created.");
+ t.ok(printForm.printExtent.map == mapPanel.map, "PrintExtent added to map.");
+ t.ok(printForm.printPage, "PrintPage assigned.");
+ t.eq(printForm.items.getCount(), 4, "Form has four items.");
+ t.ok(printForm.busyMask, "busy mask created.");
+
+ printForm.destroy();
+ mapPanel.destroy();
+ }
+
+ </script>
+ <body>
+ <div id="mappanel"></div>
+ <div id="printform"></div>
+ </body>
+</html>
\ No newline at end of file
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/lib/GeoExt.ux/SimplePrint.html
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/list-tests.html
===================================================================
--- sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/list-tests.html (rev 0)
+++ sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/list-tests.html 2010-02-01 18:08:36 UTC (rev 1857)
@@ -0,0 +1,3 @@
+<ul id="testlist">
+ <li>../../geoext.ux/ux/SimplePrint/tests/lib/GeoExt.ux/SimplePrint.html</li>
+</ul>
Property changes on: sandbox/ahocevar/playground/geoext.ux/ux/SimplePrint/tests/list-tests.html
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the Commits
mailing list