Chameleon Application Developer's Guide - version 2.0

Abstract

This document details how to develop Chameleon-based mapping applications.

Last Updated: 2005/03/20

Revision History


Table of Contents

Introduction
Key Concepts
Widget Basics
Building a Template
Step 1 - Where to Begin
Step 2 - Adding a Map Widget
Step 3 - Error Reporting
Step 4 - Running Your Application
Step 5 - Adding Navigation
Step 6 - Adding Other Widgets
Widget Maturity Levels
Available Levels
Controlling Applications
Advanced Customization
Customizing with CSS Files
Customizing Buttons
Customizing Projections
Customizing the WaitImage
Widget Name Deprecation
Widget Names Changed for Chameleon 2.0
For More Information
About this Document
Revision History
Copyright/Licensing Information
Feedback

Chameleon incorporates the ability to set up new applications quickly from a common pool of "widgets" that can be placed in an HTML template file. While these widgets provide fixed pieces of functionality, the representation of the widgets is usually highly configurable.

This guide presents a tutorial approach to building a basic Chameleon Application Template and then describes advanced widget configuration. It assumes that you have access to a properly installed and configured version of Chameleon, version 2.0.

Widgets are represented in an HTML template using familiar HTML-like notation. (Actually, the tags conform to XML specifications, which are a super-set of HTML.) As such, tags are written using the standard HTML opening and closing brackets with the additional requirement that the tags be complete. This means that every tag must have a closing element. There are two valid ways of closing an XML tag. The first is to include a "/" before the closing bracket of the first tag. The second is to include a second tag that uses the same name as the opening tag but starts with a "/". Here are examples of minimal CWC2 tags that are valid:

<CWC2/>
    

and

<CWC2></CWC2>
    

These simple tags don't actually represent any widgets and would be ignored by the Chameleon parser. In order to create a tag that represents a widget, you need to add a TYPE attribute to the tag:

<CWC2 TYPE="WidgetName"/>
    

This tag represents a Widget called WidgetName. There isn't a widget available by that name, so the Chameleon parser would generate an error if you included this in an actual template. The list of available widgets is documented in the Chameleon Widget Document. Your Chameleon administrators may also have created additional widgets.

Most widgets also require some configuration values. These values are normally specified in one of two ways. The first, and most common, way is to specify a value in the CWC2 tag in the same way the TYPE attribute is specified. For example:

<CWC2 TYPE="WidgetName" TEST="false"/>
    

Notes:

This creates a widget of TYPEWidgetName with a TEST attribute that is set to the string false. Some widgets require attributes to be passed as nested tags inside a CWC2 tag. For example:

<CWC2 TYPE="WidgetName">
      <TEST value="1"/>
      <TEST value="2"/>
</CWC2>
    

This creates the same widget but allows for multiple copies of the nested tags. Nested tags have the same formatting restrictions as CWC2 tags in that they must be closed. Widgets that require nested tags will specify the format for the nested tags in their documentation.

The Chameleon Widget Documentation provides sample tags for all the widgets in which the type of value for each attribute is provided. All attributes in a tag are written as string values in the template, but the widget will interpret the values as specified in the documentation. Any errors in interpretation will generate an error message when the template is processed by the Chameleon parser.

In the documentation, you will also see that some attributes are in red. These attributes are mandatory and must be specified in the template. Other attributes are optional and normally have reasonable default values. You will only need to specify optional parameters if you want to modify the "normal" behavior or appearance of a widget.

This section of the guide will step you through the creation of a basic template which, together with some relevant data, can be used to create a simple Web Mapping application . This section assumes that you have access to a properly configured instance of Chameleon 2.0 and a valid mapfile.

The basic element of any mapping application is a map. The Chameleon Widget that represents a map is the MapDHTML widget, which requires the following attributes:

Additional optional attributes are as follows: VISIBLE, ENABLED, MARQUEECOLOR, MARQUEEWIDTH, MARQUEEHEIGHT, MARQUEEVERTICALIMAGE, MARQUEEHORIZONTALIMAGE, MINSCALE, MAXSCALE, WAITIMAGE, WAITIMAGEHEIGHT, WAITIMAGEWIDTH and ALLOWRESIZE. (Detailed information can be found in the Chameleon Widget Documentation.)

Here is what the tag looks like as implemented in this example:

<CWC2 TYPE="MapDHTML"
      VISIBLE="true"
      WIDTH="400"
      HEIGHT="300"
      ALLOWRESIZE="true"
      MARQUEECOLOR="#FF3333"
      MARQUEEWIDTH="2"
      MINSCALE="1"/>
      

All widgets must be added inside the <form></form> tag on the page, but can be inline with any other HTML formatting such as tables. Here is an example of how the map image widget might be included in the default template from before:

<html>
  <head>
    <title>Widgets</title>
    <link href="cwc2.css" rel="stylesheet" type="text/css">
  </head>
  <body onload="CWC2OnLoadFunction()">
    <form>

      <table border="0" cellspacing="2" cellpadding="0">
        <tr>
          <td colspan="3" align="center">
            <CWC2 TYPE="MapDHTML"
                  VISIBLE="true"
                  WIDTH="400"
                  HEIGHT="300"
                  ALLOWRESIZE="true"
                  MARQUEECOLOR="#FF3333"
                  MARQUEEWIDTH="2"
                  MINSCALE="1"/>
           </td>
        </tr>
      </table>

    </form>
  </body>
</html>
      

Everyone makes occasional mistakes while writing code. While the above template, entered properly, displays a simple map, any error(s) in creating it (e.g., not including a blank space between attribute definitions) only cause the offending <CWC2> tag to be printed out in red type. This is not very helpful in determining what exactly caused the error.

To make your application display more meaningful error messages, include a call to the ErrorReport widget as follows:

<CWC2 TYPE="ErrorReport"
      VISIBLE="false"



      POPUPWIDTH="500"
      POPUPHEIGHT="400"
      TOOLBAR="false"
      STATUS="false"
      MENUBAR="false"



      IMAGE="images/icon_error.png"
      IMAGEWIDTH="18"
      IMAGEHEIGHT="18"
      IMAGETIP="Display Error Report"
      LABEL="Error Report"/>
      

More information on the attributes for the ErrorReport widget can be found in the Chameleon Widget Documentation. Here is how your template looks now:

<html>
  <head>
    <title>Widgets</title>
    <link href="cwc2.css" rel="stylesheet" type="text/css">
  </head>
  <body onload="CWC2OnLoadFunction()">
    <form>

    <table border="0" cellspacing="2" cellpadding="0">
      <tr>
        <td colspan="3" align="center">
          <CWC2 TYPE="MapDHTML"
                VISIBLE="true"
                WIDTH="400"
                HEIGHT="300"
                ALLOWRESIZE="true"
                MARQUEECOLOR="#FF3333"
                MARQUEEWIDTH="2"
                MINSCALE="1"/>
        </td>
      </tr>
    </table>

    <CWC2 TYPE="ErrorReport"
          POPUPWIDTH="500"
          POPUPHEIGHT="400"
          TOOLBAR="false"
          STATUS="false"
          MENUBAR="false"
          VISIBLE="false"
          IMAGE="images/icon_error.png" IMAGEWIDTH="18" IMAGEHEIGHT="18"
          IMAGETIP="Display Error Report" LABEL="Error Report"/>

    </form>
  </body>
</html>
      

Now, if an error is made in the <CWC2> tags, a popup is displayed with the specific error message generated.

Notes:

Your template is now functional and ready to be tested. To create an executable application from your template, you first need to create an initialization file.

In its simplest form, an initialization file:

The following is a typical initialization file. There is a copy of this file in your Chameleon installation under chameleon/samples/htdocs/sample_basic.phtml. In a later section, you will be asked to copy this file (under another name) into your application directory.

1   <?php
2   /*
3   * This is a sample of a minimal application script required to
4   * get a Chameleon application running with a template and a
5   * local map file.  Most applications should actually just
6   * copy this file and modify the template and mapfile
7   * parts and should not need to do a lot more here.
8   */
9   include( "/absolute/or/relative/path/to/chameleon.php" );
10
11  $szTemplate = "./sample_basic.html";
12  $szMapFile = "../map/chameleon.map";
13
14  class SampleApp extends Chameleon
15  {
16    function SampleApp()
17    {
18      parent::Chameleon();
19      $this->moMapSession = new MapSession_RW;
20      $this->moMapSession->setTempDir( getSessionSavePath());
21    }
22  }
23
24  $oApp =  new SampleApp();
25  $oApp->registerSkin( 'skins/sample' );
26  $oApp->CWCInitialize( $szTemplate, $szMapFile  );
27  $oApp->CWCExecute();
28  ?>
        

The following are explanations of what some of the more important parts of this initialization file are doing:

For most purposes, you can use the above code for your application (replacing, of course, the Chameleon template and mapfile paths with your own).

Notes:

Building a Chameleon Application is a relatively straightforward process. The first set of instructions are for setting up your application. These instructions assume that you:

Complete the following steps, in order:

  1. Create the following suggested application directory structure:

    -- myApp
       -- data
       -- etc
       -- htdocs
          -- images
       -- map
                

    The above illustration depicts a root directory, myApp, with four subdirectories: data, etc, htdocs, and map.

    We shall assume that your data, etc, and map directories have the necessary files. For simplicity's sake, copy the directories' contents straight from Chameleon's samples directory (chameleon/samples/data, chameleon/samples/etc, chameleon/samples/map).

    If you are using the MS4W version of Chameleon, you would create the myApp directory under your apps folder:

    -- ms4w
       -- apps
          -- myApp
             -- data
             -- etc
             -- htdocs
                -- images
             -- map
                
  2. Copy the chameleon/samples/htdocs/sample_basic.phtml initialization file to your htdocs (i.e., myApp/htdocs/) directory. Rename it to index.phtml.

    Note: This file can be named anything you wish. Generally speaking, index.* is the de facto standard for the main page of a directory for the Internet.

  3. If you haven't already (in the above sections), create a file called template.html. Open this file in a text editor (e.g., NotePad, WordPad, TextPad, etc.) and paste in the following:

    <html>
      <head>
        <title>Widgets</title>
        <link href="cwc2.css" rel="stylesheet" type="text/css">
      </head>
      <body onload="CWC2OnLoadFunction()">
        <form>
    
          <table border="0" cellspacing="2" cellpadding="0">
            <tr>
            <td colspan="3" align="center">
              <CWC2 TYPE="MapDHTML"
                    VISIBLE="true"
                    WIDTH="400"
                    HEIGHT="300"
                    ALLOWRESIZE="true"
                    MARQUEECOLOR="#FF3333"
                    MARQUEEWIDTH="2"
                    MINSCALE="1"/>
              </td>
            </tr>
          </table>
    
          <CWC2 TYPE="ErrorReport"
                POPUPWIDTH="500"
                POPUPHEIGHT="400"
                TOOLBAR="false"
                STATUS="false"
                MENUBAR="false"
                VISIBLE="false"
                IMAGE="images/icon_error.png"
                IMAGEWIDTH="18"
                IMAGEHEIGHT="18"
                IMAGETIP="Display Error Report"
                LABEL="Error Report"/>
    
        </form>
      </body>
    </html>
                

    Save (or move) this file to the htdocs directory of your application.

  4. Open your index.phtml file and make the following modifications:

    include( "/absolute/or/relative/path/to/htdocs/chameleon.php" );
    
    $szTemplate = "./template.html";
    $szMapFile = "../map/chameleon.map";
                
  5. Configure your Web Server to map to your htdocs directory.

  6. Go to your favourite browser and launch the following address:

    http://localhost/myapp/index.phtml

    If your application is working properly, you should see a map on the resulting page with an image of the data in the default mapfile. This forms the basis of any mapping application, but isn't very useful yet.

    If you don't see a map on the resulting page, please go through the instructions in this step again and make sure you did everything correctly. If that doesn't help, please refer to the For More Information section.

    In the next step you will add other widgets to improve the application's usefulness.

    Note: If you want to test the ErrorReport widget that you added in Step 3, temporarily introduce a typing error in the MapDHTML widget and refresh the above URL. Make sure that you then fix the error before proceeding with the next step.

Notes:

  • If you are not using MS4W, you will have to change the IMAGEPATH to a folder on your file system and the value in IMAGEURL will have to be a Web-accessible URL that points to the IMAGEPATH.

    IMAGEPATH "/path/to/tmp/ms_tmp/"
    IMAGEURL "/ms_tmp/"
                
  • Although not suggested for production Chameleon installations, MS4W is an invaluable tool for getting your application up and running quickly in a development environment.

In the previous step you were able to verify that your template was indeed working. In this step you will add two additional widgets that allow the user of your application to zoom in and out.

To add a zoom in tool to your template, you will need to add a Chameleon widget of TYPEZoomIn. This widget has the following required attributes:

There are many optional attributes here are just a few: VISIBLE, ENABLED, IMAGEWIDTH, IMAGETIP, TOOLSET, and MINIMUMZOOMRECTANGLE. (Detailed information can be found in the Chameleon Widget Documentation.)

Here is what the tag looks like as implemented in this example:

<CWC2 TYPE="ZoomIn"
   VISIBLE="true"
   IMAGETIP="Zoom Into Selected Point or Region"
   TOOLSET="Navigation"
   IMAGEWIDTH="24"
   IMAGEHEIGHT="24">
      <IMAGE STATE="normal"
                IMAGE="buttons/button_zoomin_1.png"/>
      <IMAGE STATE="hover"
                IMAGE="buttons/button_zoomin_2.png"/>
      <IMAGE STATE="selected"
                IMAGE="buttons/button_zoomin_3.png"/>
</CWC2>
      

To add a zoom out tool to your template you will need to add a Chameleon widget of TYPEZoomOut. This widget has the following required attributes:

There are many optional attributes here are just a few: VISIBLE, ENABLED, IMAGEWIDTH, IMAGEHEIGHT, IMAGETIP and TOOLSET. (Detailed information can be found in the Chameleon Widget Documentation.)

Here is what the tag looks like as implemented in this example:

<CWC2 TYPE="ZoomOut"
   VISIBLE="true"
   IMAGETIP="Zoom Away From Selected Point"
   TOOLSET="Navigation"
   IMAGEWIDTH="24"
   IMAGEHEIGHT="24">
      <IMAGE STATE="normal"
                IMAGE="buttons/button_zoomout_1.png"/>
      <IMAGE STATE="hover"
                IMAGE="buttons/button_zoomout_2.png"/>
      <IMAGE STATE="selected"
                IMAGE="buttons/button_zoomout_3.png"/>
</CWC2>
      

Adding these tags to your template should result in something like the following:

<html>
  <head>
    <title>Widgets</title>
    <link href="cwc2.css" rel="stylesheet" type="text/css">
  </head>
  <body onload="CWC2OnLoadFunction()">
    <form>

      <table border="0" cellspacing="2" cellpadding="0">
        <tr>

          <td colspan="3" align="center">
            <CWC2 TYPE="MapDHTML"
                  VISIBLE="true"
                  WIDTH="400"
                  HEIGHT="300"
                  ALLOWRESIZE="true"
                  MARQUEECOLOR="#FF3333"
                  MARQUEEWIDTH="2"
                  MINSCALE="1"/>
          </td>

          <td valign=top>
            <CWC2 TYPE="ZoomIn"
               VISIBLE="true"
               IMAGETIP="Zoom Into Selected Point or Region"
               TOOLSET="Navigation"
               IMAGEWIDTH="24"
               IMAGEHEIGHT="24">
                  <IMAGE STATE="normal"
                            IMAGE="buttons/button_zoomin_1.png"/>
                  <IMAGE STATE="hover"
                            IMAGE="buttons/button_zoomin_2.png"/>
                  <IMAGE STATE="selected" I
                            IMAGE="buttons/button_zoomin_3.png"/>
            </CWC2>

            <br>

            <td valign=top>
              <CWC2 TYPE="ZoomOut"
                 VISIBLE="true"
                 IMAGETIP="Zoom Away From Selected Point"
                 TOOLSET="Navigation"
                 IMAGEWIDTH="24"
                 IMAGEHEIGHT="24">
                    <IMAGE STATE="normal"
                              IMAGE="buttons/button_zoomout_1.png"/>
                    <IMAGE STATE="hover"
                              IMAGE="buttons/button_zoomout_2.png"/>
                    <IMAGE STATE="selected" I
                            IMAGE="buttons/button_zoomout_3.png"/>
              </CWC2>
          </td>

        </tr>
      </table>

      <CWC2 TYPE="ErrorReport"
            POPUPWIDTH="500"
            POPUPHEIGHT="400"
            TOOLBAR="false"
            STATUS="false"
            MENUBAR="false"
            VISIBLE="false"
            IMAGE="images/icon_error.png"
            IMAGEWIDTH="18" IMAGEHEIGHT="18"
            IMAGETIP="Display Error Report"
            LABEL="Error Report"/>

    </form>
  </body>
</html>
      

Save your template, load and reload your application. You should have a map and two navigation buttons. The new navigation tools provide you with the ability to zoom into and out of the map view. Try them out by clicking either one and then clicking the map in the desired location.

Chameleon 2.0 provides many more widgets than the ones used in the example above. Because of the nature of Open Source projects, some of the widgets provided have gone through more rigorous testing than others. A set of 26 basic widgets have been considered for the (final) 2.0 release, including all the ones used in examples throughout this document. For more information on how to tell how well a widget's been tested, please refer to the Widget Maturity Levels section.

Add additional widgets to the template and investigate their behavior in the application. Examine (and experiment with) the following template to determine which additional widgets have been added and how they work. If you need more information about any specific widget used below, please refer to the Chameleon Widget Documentation.

<html>
  <head>
    <title>Widgets</title>
    <link href="cwc2.css" rel="stylesheet" type="text/css">
  </head>
  <body onload="CWC2OnLoadFunction()">
    <form>

    <table border="0" cellspacing="2" cellpadding="0">
      <tr>

        <td align=center>
          <CWC2 TYPE="Title"
                VISIBLE="true"
                LABEL="My First CWC2 Map!"
                LABELCLASS="CWCHelpTitle1"/>
        </td>
      </tr>

      <tr>
        <td colspan="3" align="center">
          <CWC2 TYPE="MapDHTML"
                VISIBLE="true"
                WIDTH="400"
                HEIGHT="300"
                ALLOWRESIZE="true"
                MARQUEECOLOR="#FF3333"
                MARQUEEWIDTH="2"
                MINSCALE="1"/>
        </td>

        <td valign=top>
          <CWC2 TYPE="ZoomIn"
             VISIBLE="true"
             IMAGETIP="Zoom Into Selected Point or Region"
             TOOLSET="Navigation"
             IMAGEWIDTH="24"
             IMAGEHEIGHT="24">
                <IMAGE STATE="normal"
                          IMAGE="buttons/button_zoomin_1.png"/>
                <IMAGE STATE="hover"
                          IMAGE="buttons/button_zoomin_2.png"/>
                <IMAGE STATE="selected"
                          MAGE="buttons/button_zoomin_3.png"/>
          </CWC2>

          <br>

          <CWC2 TYPE="ZoomOut"
             VISIBLE="true"
             IMAGETIP="Zoom Away From Selected Point"
             TOOLSET="Navigation"
             IMAGEWIDTH="24"
             IMAGEHEIGHT="24">
                <IMAGE STATE="normal"
                          IMAGE="buttons/button_zoomout_1.png"/>
                <IMAGE STATE="hover"
                          IMAGE="buttons/button_zoomout_2.png"/>
                <IMAGE STATE="selected"
                        MAGE="buttons/button_zoomout_3.png"/>
          </CWC2>

          <br>

          <CWC2 TYPE="Recenter"
                VISIBLE="true"
                IMAGE="images/tool_recentre_off.gif"
                IMAGESELECTED="images/tool_recentre_on.gif"
                IMAGEHOVER="images/tool_recentre_over.gif"
                IMAGETIP="Recenter Map"
                IMAGEWIDTH="24"
                IMAGEHEIGHT="24"
                TOOLSET="Navigation"/>
        </td>
        <td valign=top>
          <CWC2 TYPE="KeyMap"
                IMAGE="images/keymap.png"
                WIDTH="120"
                HEIGHT="90"
                COLOR="-1 -1 -1"
                OUTLINECOLOR="255 0 0"
                MINX="-2200000"
                MINY="-712631"
                MAXX="3072800"
                MAXY="3840000"
                SRS="epsg:42304"/>
        </td>
      </tr>

      <tr>
        <td align=center>
          <CWC2 TYPE="ScaleBar" VISIBLE="true"/>
        </td>
      </tr>

    </table>

    <CWC2 TYPE="ErrorReport"
          POPUPWIDTH="500"
          POPUPHEIGHT="400"
          TOOLBAR="false"
          STATUS="false"
          MENUBAR="false"
          VISIBLE="false"
          IMAGE="images/icon_error.png"
          IMAGEWIDTH="18"
          IMAGEHEIGHT="18"
          IMAGETIP="Display Error Report"
          LABEL="Error Report"/>

    </form>
  </body>
</html>
      

There are many aspects of configuring widgets that are not addressed in this document, so experimentation is encouraged. Try the parameters of each Chameleon widget to discover how flexible they are and how easily you can generate fully customized Web mapping applications without writing any code.

There are approximately 100 widgets available for Chameleon 2.0. Since some of these were submitted by Chameleon users external to DM Solutions Group and many others were created for various specialized projects, the level of reliability (i.e., completeness of development, thoroughness of testing, documentation status, etc.) can vary greatly between widgets.

In order to reflect the differing levels of widget development, the concept of a "maturity level" for each widget has been introduced. Setting this level is done separately for each widget that is provided with Chameleon 2.0.

The available maturity levels (ordered from least mature to most mature) and their definitions are:

To see what level of maturity a specific widget is at, please refer to the Widget Documentation for that widget. For the final release of Chameleon 2.0, the following 26 basic widgets have been released at TECHNICALRELEASE level:

All other widgets released with Chameleon 2.0 are set at a lower level of maturity. (Typically, BETA or ALPHA.)

In order to help application developers control whether they use only thoroughly tested widgets or not, the Chameleon configuration file has been expanded to include a 'maturity_level' parameter, which can be set to any of the above defined maturity levels. Setting this parameter prevents applications on that server from being able to access widgets below the provided maturity level.

Applications can also override this to set a lower or higher minimum maturity level for that application alone. The net effect of this will be that application developers will have to knowingly make a choice to use widgets which may not be fully tested or even stable.

It is quite likely that, when you install this version of chameleon, you will run into issues related to this maturity level change. Some widgets may not appear in your application, especially custom widgets. This is normal. To correct this, do one of the following. (Please keep in mind that the maturity level descriptors are case sensitive.)

In addition to the basic customization provided for every widget through its attributes, there are several additional ways of achieving a high level of customization. These are:

All core widgets provided with the Chameleon are designed to allow application developers to configure an application's appearance using CSS files. Chameleon provides default CSS files that define all the classes and styles used in the default appearance of Chameleon applications.

It is assumed that developers wishing to control the appearance of applications using CSS files are already familiar with CSS.

The first CSS stylesheet that can be modified is cwc2.css, which defines the styles used by the widgets in the main application template. The default cwc2.css file is available at the URL that Chameleon is available at, for example http://my.server.com/chameleon/cwc2.css.

The developer can include this file in an application by including the following HTML link tag in the HEAD section of the application template:

<link href="cwc2.css" rel="stylesheet" type="text/css">
        

Note: Naming the stylesheet cwc2.css is not necessary; the file can be copied, renamed, and modified - and then the new file can referred to in the link tag.

The following classes are defined in the default cwc2.css file:

The second CSS stylesheet that can be modified is the popup.css stylesheet. This stylesheet controls the appearance of popup dialog boxes generated by some widgets. The default popup.css file is available at the URL that Chameleon is available at, for example http://my.server.com/chameleon/popup.css. Unfortunately, it is not possible to replace the stylesheet directly in popup dialogs, but it is possible to specify a new CSS stylesheet for all popup dialogs to use in the main application template, by using a SharedResource widget. The format of this widget is as follows:

<SharedResource NAME="PopupCSS" VALUE="<url-to-custom-stylesheet>"/>
        

Note: Naming the stylesheet popup.css is not necessary; the file can be copied, renamed, and modified - and then the new file can referred to in the SharedResource tag.

By placing this tag anywhere in the application template, all popup dialogs will use the custom stylesheet rather than the default one provided.

The following classes should be defined in a custom popup stylesheet:

Buttons are dynamically generated images that are formatted in a specific way. Prior to Chameleon 2.0, text buttons and navigation buttons were created and treated differently, with different capabilities, advantages, and drawback. Now, in Chameleon 2.0, all buttons are created using the same technology.

Text buttons are used as the interface for many widgets. They were originally developed to allow for simple translation of buttons in the application template (simple in that only having to provide translated text, not generate a set of new buttons). Text buttons are very flexible elements and, because of this, they can seem quite complex. However, with only a few simple changes in this area, the appearance of an application can be dramatically altered.

Navigation buttons are similar to text buttons, with the exception that they don't typically include translatable text elements - they simply rely on images to get across their message.

Before describing how to customize buttons in an application, it is necessary to define what a button is and how it is dynamically built. A button is a single graphic image that is composed of several components:

The two components of a button are its border and its center. The border is composed of eight (8) separate graphic images that can be individually specified to allow for the creation of complex buttons.

The center portion is the rectangular area outlined by the border and its size is determined by the overall size specified less the border widths/heights. The center is filled with a background color. An optional background graphic is aligned centrally within the center area if it doesn't fill it, or is cropped if it is too large. The button graphic is placed at the left edge of the center portion and is vertically centered in the area. The label is drawn and aligned horizontally in the remaining horizontal area between the right edge of the graphic and the right edge of the center portion.

The following figure demonstrates the layout of a full (text) button:

Any widget that uses a button as its graphical representation has all the attributes of the Button group. (See Chameleon Widget Documentation.) Because the number of attributes is quite large, it is inefficient for an application developer to repeat them for every widget, especially since most buttons will share many of the same values. It is also difficult to modify the style of all buttons (e.g., changing a background color), since every widget must be changed individually. Finally, popups created by widgets also use text buttons and these popups are not generally modifiable by the application developer. To solve these problems, the button will take its values from the following places, in order of appearance:

It is not necessary to name the TextButton SharedResource TextButton. Every widget refers to a SharedResource by name, so different buttons can easily use different TextButton SharedResources. The structure of a TextButton SharedResource looks like:

<cwc2 type="SharedResource" name="TextButton">  <!-- note this doesn't have to be called TextButton -->
    <backgroundimage value=""/> <!-- this section is the same -->
    <imagewidth value="100"/>
    <imageheight value="24"/>
    <textbuttonpadding value="2"/>
    <textbuttonnudge value="0"/>
    <labelcolor value="111111"/>
    <labelfont value="../etc/fritqat.ttf"/>
    <labelalign value="left"/>
    <labelfontsize value="8"/>
    <labelantialias value="true"/>
    <usetextbuttoncache value="true"/>
    <state value="normal"> <!-- this is new -->
        <textbuttoncolor value="CCCCCC"/>
        <textbuttonborder_topleft_image value="images/tl_1.png"/>
        <textbuttonborder_top_image value="images/t_1.png"/>
        <textbuttonborder_topright_image value="images/tr_1.png"/>
        <textbuttonborder_right_image value="images/r_1.png"/>
        <textbuttonborder_bottomright_image value="images/br_1.png"/>
        <textbuttonborder_bottom_image value="images/b_1.png"/>
        <textbuttonborder_bottomleft_image value="images/bl_1.png"/>
        <textbuttonborder_left_image value="images/l_1.png"/>
    </state>
    <state value="hover">
        <textbuttoncolor value="EEEEEE"/>
        <textbuttonborder_topleft_image value="images/tl_2.png"/>
        <textbuttonborder_top_image value="images/t_2.png"/>
        <textbuttonborder_topright_image value="images/tr_2.png"/>
        <textbuttonborder_right_image value="images/r_2.png"/>
        <textbuttonborder_bottomright_image value="images/br_2.png"/>
        <textbuttonborder_bottom_image value="images/b_2.png"/>
        <textbuttonborder_bottomleft_image value="images/bl_2.png"/>
        <textbuttonborder_left_image value="images/l_2.png"/>
    </state>
    <state value="selected">
        <textbuttoncolor value="AAAAAA"/>
        <textbuttonborder_topleft_image value="images/tl_3.png"/>
        <textbuttonborder_top_image value="images/t_3.png"/>
        <textbuttonborder_topright_image value="images/tr_3.png"/>
        <textbuttonborder_right_image value="images/r_3.png"/>
        <textbuttonborder_bottomright_image value="images/br_3.png"/>
        <textbuttonborder_bottom_image value="images/b_3.png"/>
        <textbuttonborder_bottomleft_image value="images/bl_3.png"/>
        <textbuttonborder_left_image value="images/l_3.png"/>
    </state>
    <state value="disabled">
        <textbuttoncolor value="CCCCCC"/>
        <textbuttonborder_topleft_image value="images/tl_1.png"/>
        <textbuttonborder_top_image value="images/t_1.png"/>
        <textbuttonborder_topright_image value="images/tr_1.png"/>
        <textbuttonborder_right_image value="images/r_1.png"/>
        <textbuttonborder_bottomright_image value="images/br_1.png"/>
        <textbuttonborder_bottom_image value="images/b_1.png"/>
        <textbuttonborder_bottomleft_image value="images/bl_1.png"/>
        <textbuttonborder_left_image value="images/l_1.png"/>
    </state>
</cwc2>
        

The values from the main block of the SharedResource form the default values for all states. If no <state> tags are included, then a default normal state is created from the default values. Otherwise, states are created from each <state> tag and initialized using the defaults, then overloaded using the state-specific settings. Any tag can go in either.

All attributes which can go directly within widgets that relate to button resources are provided by Button.php (with one exception, for popups, described below). The attributes are:

There is one additional attribute that applies to widgets with Popup windows. This is:

The ProjectionSelector and ProjectionLabel widgets provide a convenient mechanism for choosing the projection in which to display a map and for the user to see what that projection is. Chameleon currently supports only projections that are defined in European Petroleum Survey Group (EPSG) code format, such as EPSG:42304 (NRCan LCC for Canada). Unfortunately, these codes have very little meaning to most users.

In order to provide a portable mechanism for users to select and view projection information, the ProjectionSharedResource was added to Chameleon. Any widgets that need to be aware of the current projection (and either allow changing it or displaying it) access the information from the ProjectionSharedResource, if possible. The structure of the Projection SharedResource is as follows:

<CWC2 TYPE="SharedResource" NAME="Projection">
  <PROJECTION NAME="NAD 83 / Geographic" SRS="epsg:4269"/>
  <PROJECTION NAME="WGS 84 / Geographic" SRS="epsg:4326"/>
  <PROJECTION NAME="WGS 84 / Auto UTM" SRS="AUTO:42001"/>
  <PROJECTION NAME="WGS 84 / Auto Tr. Mercator" SRS="AUTO:42002"/>
  <PROJECTION NAME="WGS 84 / Auto Orthographic" SRS="AUTO:42003"/>
  <PROJECTION NAME="WGS 84 / Auto Equirectangular" SRS="AUTO:42004"/>
  <PROJECTION NAME="WGS 84 / LCC Canada" SRS="epsg:42101"/>
  <PROJECTION NAME="NAD 83 / NRCan LCC Canada" SRS="epsg:42304" DEFAULT="true"/>
</CWC2>
      

It is the responsibility of the application developer to understand the meaning of projections and to determine exactly how to use this SharedResource. Each <PROJECTION> element of the SharedResouce requires a name (which is actually displayed to the user) and an SRS (which is the EPSG code).

As Chameleon evolves, there will occasionally be need to change the name of widgets that have been released in past versions. In these cases, a widget deprecation process has been put in place to ensure that your existing Chameleon applications continue to function while you switch over to the new widget names.

Basically, the way this deprecation process works is:

If you were unable to answer all the questions you had about the subject of this document, other possible methods of obtaining information include:

The numbering is in parallel with the revision control system. Missing numbers indicate minor maintenance revision updates.

Revision History
Revision 1.12003/06/29Paul Spencer
original HTML version
Revision 1.22003/10/08Darren Redfern
initial translation from HTML to DocBook
Revision 1.32004/12/02Darren Redfern
first draft updated for 2.0
Revision 1.42004/12/08Chris Thorne
coding format changes, tag definitions
Revision 1.52004/12/08Darren Redfern
editing changes
Revision 1.62005/01/11Jeff McKenna
added comments from PS, and image from FW
Revision 1.82005/03/20Jeff McKenna
corrected httpd.d instructions