public interface SCImgURL
Img.src
and Button.icon
, are specially interpreted in Smart GWT to allow for simpler and
more uniform image URLs, and to allow applications to be restructured more easily. the application image directory
When specifying URLs to image files via Smart GWT component properties such as StretchImg.src
, any relative path is assumed to be relative to the
"application image directory" (appImgDir
). The application image directory can be set via Page.setAppImgDir()
, and defaults to "images/", representing the typical
practice of placing images in a subdirectory relative to the URL at which the application is accessed.
For
applications that may be launched from multiple URLs, the appImgDir
can be set to the correct relative path
to the image directory by calling Page.setAppImgDir()
before any
Smart GWT components are created. This enables applications or components of an application to be launched from
multiple locations, or to be relocated, without changing any image URLs supplied to Smart GWT components.
the "[SKIN]" URL prefix
The special prefix "[SKIN]" can be used to refer to images within the skin folder whenever image URLs are supplied to Smart GWT components.
The value of "[SKIN]" is the combination of:
load_skin.js
via Page.setSkinDir()
, plus.. skinImgDir
on
the component where you set an image URL property skinImgDir
defaults to "images/", so creating an
Img
component with Img.src
set to
"[SKIN]myButton/button.gif" will expand to Page.getSkinDir() + "/images/myButton/button.gif"
. Some
components that use a large number of images use skinImgDir
to group them together and make it possible to
relocate all the media for the component with a single setting. For example, the TreeGrid
class sets skinImgDir
to "images/TreeGrid/". This allows TreeGrid.folderIcon
to be set to just "[SKIN]folder.gif" but
refer to Page.getSkinDir() + "/images/TreeGrid/folder.gif"
.
A custom subclass of TreeGrid can set
skinImgDir
to a different path, such as "/images/MyTreeGrid", to source all media from a different
location.
TIPS:
Window.minimizeButton
has the default setting for
"skinImgDir" ("images/"), so the src
property used with this component is
set to "[SKIN]/Window/minimize.png" (in the "Smart GWT" sample skin). Page.getSkinDir()
+ "/images"
regardless of the setting for skinImgDir
Many image
URLs in Smart GWT are "stateful", meaning that the actual URL used to fetch an image will vary according to the
component's state (eg, "Disabled"), generally, by adding a suffix to the image URL. See the Skinning Overview
for more information on statefulness and the Img.src
documentation for information on how stateful image URLs are formed.