Changeset 344


Ignore:
Timestamp:
04/03/09 17:05:44 (9 years ago)
Author:
dwins
Message:

Add ND for the map tool controls

Location:
apps/opengeo/geoexplorer/trunk/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js

    r339 r344  
    33 */
    44
     5/**
     6 * About: Examples
     7 *
     8 * This example uses default names and icons for the menu entries.
     9 * : var measure, select, zoomBox, draw; // OpenLayers Controls
     10 * > var menu = new MapToolMenu({tools: [measure, select, zoomBox, draw]});
     11 *
     12 * This one provides a custom name and icon for one of the entries.
     13 * : var measure, select, zoomBox, draw; // OpenLayers Controls
     14 * > var menu = new MapToolMenu({tools: [{
     15 * >         text: 'Find a distance',
     16 * >         tool: measure,
     17 * >         iconCls: 'x-icon-distance-finder'
     18 * >     },
     19 * >     select,
     20 * >     zoomBox,
     21 * >     draw
     22 * > ]});
     23 */
     24
     25/*
     26 * Constructor: MapToolMenu
     27 * Simply create a menu that manipulates OpenLayers map controls
     28 *
     29 * Parameters:
     30 * config - {Object} Various options, see {Ext.menu.Menu}
     31 *
     32 * In addition to the normal [items] array, MapToolMenu recognizes a [tools] array.
     33 * This can be an array of OpenLayers Control objects, or of simple configuration
     34 * objects analogous to Ext Map entries.
     35 */
    536var MapToolMenu = function(options) {
    637    options.items = options.items || [];
  • apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js

    r339 r344  
    44 */
    55
     6/**
     7 * About: Examples
     8 *
     9 * This example uses default names and icons for the button and menu entries.
     10 * : var measure, select, zoomBox, draw; // OpenLayers Controls
     11 * : var menu = new MapToolSplitToggle({defaultTool: select, tools: [measure, select, zoomBox, draw]});
     12 *
     13 * This one provides a custom name and icon for one of the entries.
     14 * : var measure, select, zoomBox, draw; // OpenLayers Controls
     15 * : var menu = new MapToolSplitToggle({
     16 * >     defaultTool: zoomBox,
     17 * >     tools: [{
     18 * >         text: 'Find a distance',
     19 * >         tool: measure,
     20 * >         iconCls: 'x-icon-distance-finder'
     21 * >     },
     22 * >     select,
     23 * >     zoomBox,
     24 * >     draw
     25 * > ]});
     26 */
     27
     28/**
     29 * Constructor: MapToolSplitToggle
     30 * Creates an Ext SplitButton suited to switching between multiple related OpenLayers Controls.
     31 * The MapToolSplitToggle accepts an array of controls, which can be activated from the dropdown menu.
     32 * The main button simply toggles the most recently used control.
     33 *
     34 * Parameters:
     35 * config - {Object} the configuration options for this split toggle, see {Ext.SplitButton}.
     36 *
     37 * In addition to the options accepted by Ext.SplitButton, the MapToolSplitToggle accepts:
     38 * defaultTool - {OpenLayers.Control} the control which is to be activated if the button is toggled
     39 * before the user selects one from the drop-down menu.
     40 * tools - {Array} the controls to display in the drop-down menu.  These may be simple Control objects,
     41 * or Ext menu specifications with a tool parameter containing the control.  (see MapToolMenu)
     42 */
    643var MapToolSplitToggle = function(options) {
    7     this.lastActiveTool = options.defaultTool;
     44    this.lastActiveTool = options.defaultTool || options.tools[0];
    845    this.tools = options.tools;
    946
     
    3471    lastActiveTool: null,
    3572
     73    /**
     74     * Property: tools
     75     * {Array} the OpenLayers tools from this component's configuration.
     76     */
     77    tools: null,
     78   
     79    /**
     80     * Method: handleEvent
     81     * Called when the main button is toggled, handled the (de)activation of the last active tool.
     82     *
     83     * Parameters:
     84     * item - the component that triggered the event (ie, this SplitButton)
     85     */
    3686    handleEvent: function(item) {
    3787        if (item.pressed) {
     
    4292    },
    4393
     94    /**
     95     * Method: handleMenu
     96     * Called when an item in the menu is selected.  All this does is update lastActiveTool;
     97     * the menu should be a {MapToolMenu} to handle the control (de)activation.
     98     *
     99     * Parameters:
     100     * item - the component that triggered the event (ie, the Menu item)
     101     * evt  - the Ext selection event
     102     */
    44103    handleMenu: function(item, evt) {
    45104        for (var i = 0, len = this.tools.length; i < len; i++) {
     
    52111    },
    53112   
     113    /**
     114     * Method: findIconCls
     115     * Determine the icon class for this split button, based on the {OpenLayers.Control} the
     116     * button has been configured with.
     117     */
    54118    findIconCls: function() {
    55119        return this.lastActiveTool.CLASS_NAME;
    56120    },
    57121
     122    /**
     123     * Method: findLabel
     124     * Determine the text label for this split button, based on the {OpenLayers.Control} the
     125     * button has been configured with.
     126     */
    58127    findLabel: function() {
    59128        return this.lastActiveTool.CLASS_NAME;
  • apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js

    r339 r344  
    33 */
    44
     5/**
     6 * About: Examples
     7 *
     8 * This example uses default names and icons for the button.
     9 * : var measure = new OpenLayers.Control.Measure(OpenLayers.Handler.Path);
     10 * : var btn = new MapToolToggle({tool: measure});
     11 *
     12 * This one provides a custom name and icon.
     13 * : var measure = new OpenLayers.Control.Measure(OpenLayers.Handler.Path);
     14 * : var btn = new MapToolToggle({
     15 * >         text: 'Find a distance',
     16 * >         tool: measure,
     17 * >         iconCls: 'x-icon-distance-finder'
     18 * >     });
     19 */
     20
     21/**
     22 * Constructor: MapToolToggle
     23 * Creates an Ext Button suited to activating and deactivating an {OpenLayers.Control}.
     24 * The MapToolToggle accepts a control as part of its configuration.
     25 *
     26 * Parameters:
     27 * config - {Object} the configuration options for this split toggle, see {Ext.Button}.
     28 *
     29 * In addition to the options accepted by Ext.Button, the MapToolToggle accepts:
     30 * tool - {OpenLayers.Control} the control which is to be manipulated by the button
     31 */
    532var MapToolToggle = function(options) {
    633    this.mapTool = options.tool;
     
    2249    mapTool: null,
    2350
     51    /**
     52     * Method: handleEvent
     53     * Called when the main button is toggled, handled the (de)activation of the last active tool.
     54     *
     55     * Parameters:
     56     * item - the component that triggered the event (ie, this SplitButton)
     57     */
    2458    handleEvent: function(item) {
    2559        if (item.pressed) {
     
    3064    },
    3165   
     66    /**
     67     * Method: findIconCls
     68     * Determine the icon class for this split button, based on the {OpenLayers.Control} the
     69     * button has been configured with.
     70     */
    3271    findIconCls: function() {
    3372        return this.mapTool.CLASS_NAME;
    3473    },
    3574
     75    /**
     76     * Method: findLabel
     77     * Determine the text label for this split button, based on the {OpenLayers.Control} the
     78     * button has been configured with.
     79     */
    3680    findLabel: function() {
    3781        return this.mapTool.CLASS_NAME;
Note: See TracChangeset for help on using the changeset viewer.