public SWTSkinObjectSlider(SWTSkin skin, SWTSkinProperties skinProperties,
String sID, String sConfigID, String[] typeParams, SWTSkinObject parent) {
super(skin, skinProperties, sID, sConfigID, "slider", parent);
String sSuffix = ".complete";
final ImageLoader imageLoader = skin.getImageLoader(properties);
String imagePrefix = sConfigID + sSuffix;
Image[] images = imageLoader.getImages(imagePrefix);
imagesToRelease.add(imagePrefix);
if (images.length == 1 && ImageLoader.isRealImage(images[0])) {
imageFG = images[0];
imageFGLeft = imageLoader.getImage(imagePrefix + "-left");
imageFGRight = imageLoader.getImage(imagePrefix + "-right");
imagesToRelease.add(imagePrefix + "-left");
imagesToRelease.add(imagePrefix + "-right");
} else if (images.length == 3 && ImageLoader.isRealImage(images[2])) {
imageFGLeft = images[0];
imageFG = images[1];
imageFGRight = images[2];
}
if (imageFG != null) {
imageFGbounds = imageFG.getBounds();
}
sSuffix = ".incomplete";
imagePrefix = sConfigID + sSuffix;
images = imageLoader.getImages(imagePrefix);
imagesToRelease.add(imagePrefix);
if (images.length == 1 && ImageLoader.isRealImage(images[0])) {
imageBG = images[0];
imageBGLeft = imageLoader.getImage(imagePrefix + "-left");
imageBGRight = imageLoader.getImage(imagePrefix + "-right");
imagesToRelease.add(imagePrefix + "-left");
imagesToRelease.add(imagePrefix + "-right");
} else if (images.length == 3 && ImageLoader.isRealImage(images[2])) {
imageBGLeft = images[0];
imageBG = images[1];
imageBGRight = images[2];
}
if (imageBG != null) {
imageBGbounds = imageBG.getBounds();
}
sSuffix = ".thumb";
imagePrefix = sConfigID + sSuffix;
images = imageLoader.getImages(imagePrefix);
imagesToRelease.add(imagePrefix);
if (images.length == 1) {
imageThumb = images[0];
imageThumbLeft = imageLoader.getImage(imagePrefix + "-left");
imageThumbRight = imageLoader.getImage(imagePrefix + "-right");
imagesToRelease.add(imagePrefix + "-left");
imagesToRelease.add(imagePrefix + "-right");
} else if (images.length == 3 && ImageLoader.isRealImage(images[2])) {
imageThumbLeft = images[0];
imageThumb = images[1];
imageThumbRight = images[2];
}
if (imageThumb != null) {
imageThumbBounds = imageThumb.getBounds();
}
maxSize = buildMaxSize(new Rectangle[] {
imageThumbBounds,
imageBGbounds,
imageFGbounds
});
if (skinProperties.getStringValue(sConfigID + ".width", "").equalsIgnoreCase(
"auto")) {
maxSize.x = 0;
}
int style = SWT.NONE;
if (skinProperties.getIntValue(sConfigID + ".border", 0) == 1) {
style |= SWT.BORDER;
}
Composite createOn;
if (parent == null) {
createOn = skin.getShell();
} else {
createOn = (Composite) parent.getControl();
}
canvas = new Canvas(createOn, style);
canvas.setLayoutData(new FormData(maxSize.x == 0 ? SWT.DEFAULT
: maxSize.x, maxSize.y));
canvas.setSize(SWT.DEFAULT, maxSize.y);
setControl(canvas);
canvas.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
try {
for (String key : imagesToRelease) {
imageLoader.releaseImage(key);
}
} catch (Exception ex) {
Debug.out(ex);
}
}