[Chameleon] Creating Widgets

Paul Spencer pagameba at magma.ca
Thu Aug 5 09:41:27 EDT 2004


Ken ...

Ken Sanderson wrote:

> Hello all. I took a first stab at creating a widget, actually it was
> more editing of other widgets, but I did get it working and I had a
> couple general questions.
> 
> In order to get it to work in the end I needed to manually add my widget
> tool name to several parts of MapDHTMLWidget.widget.php. Is there a way
> to make this get automatically added from your specific widget php file?
> 
> For example, I changed the following in the MapWchkMouseUp function:
> 
>     if((window.gMapDHTMLForm != null) && 
>        (gMapDHTMLForm.NAV_CMD != null) &&
>        (gMapDHTMLForm.NAV_CMD.value == "PAN_MAP" ||
>         gMapDHTMLForm.NAV_CMD.value == "RULER" ||
>         gMapDHTMLForm.NAV_CMD.value == "QUERY" ||
>         gMapDHTMLForm.NAV_CMD.value == "GetPoint"))
>         return true;
> 
> My change is the GetPoint portion line which I needed added. Basically I
> am wondering if I can invoke that change, which was also added to the
> MapWgetMouse and MapWmapTool functions, at my widget rather then in the
> MapDHTMLWidget itself, which means I wont need to go back and change
> that file every time I upgrade Chameleon.

yuck ... the support for tools like this is something that I have been 
meaning to address, the architecture of this part of chameleon is very 
limiting and I have some ideas on how to fix it, but no time to do it. 
For now, you will have to make this change every time you update 
chameleon I guess.  I would expect that this will be one of the first 
things I will look at post 2.0 release.

> 
> My other question is in regards to functions. Is there any check for
> adding duplicate functions from different widgets? Basically I use a
> function from the CursorPos widget in my widget. Can I add the exact
> same function to my widget in case CursorPos isnt loaded or will that
> cause two functions of the same name to be outputted to the HTML file?
> 

yes, this sort of redundancy is accounted for.  The mechanism that 
chameleon uses is to return an array of functions from each widget, with 
the keys to the array being unique names.  If the same function is 
required by multiple widgets, they should return the same function with 
the same key and the function will only be output once.  This means that 
you can make your widget such that it won't rely on other widgets 
needing to be in the page.

Cheers,

Paul

> Thanks,
> 
> Ken
> 
> 
> 
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 

-- 
  -----------------------------------------------------------------
|Paul Spencer                           pspencer at dmsolutions.ca   |
|-----------------------------------------------------------------|
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
  -----------------------------------------------------------------




More information about the Chameleon mailing list