use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class SWTSkinObjectImage method createImageWidget.
private Canvas createImageWidget(String sConfigID) {
String propImageID = properties.getStringValue(sConfigID + ".imageid");
if (propImageID != null) {
currentImageID = customImageID = propImageID;
}
int style = SWT.WRAP | SWT.DOUBLE_BUFFERED;
String sAlign = properties.getStringValue(sConfigID + ".align");
if (sAlign != null && !Constants.isUnix) {
h_align = SWTSkinUtils.getAlignment(sAlign, SWT.NONE);
if (h_align != SWT.NONE) {
style |= h_align;
}
}
if (properties.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.setData("SkinObject", this);
// {
// public Point computeSize(int wHint, int hHint) {
// Object image = canvas.getData("image");
// Object imageID = canvas.getData("ImageID");
// if (image == null
// && (imageID == null || ((String) imageID).length() == 0)) {
// return new Point(0, 0);
// }
// return super.computeSize(wHint, hHint);
// };
//
// public Point computeSize(int wHint, int hHint, boolean changed) {
// Object image = canvas.getData("image");
// Object imageID = canvas.getData("ImageID");
// if (image == null
// && (imageID == null || ((String) imageID).length() == 0)) {
// return new Point(0, 0);
// }
// return super.computeSize(wHint, hHint, changed);
// };
// };
Color color = properties.getColor(sConfigID + ".color");
if (color != null) {
canvas.setBackground(color);
}
final String sURL = properties.getStringValue(sConfigID + ".url");
if (sURL != null && sURL.length() > 0) {
Utils.setTT(canvas, sURL);
canvas.addListener(SWT.MouseUp, new Listener() {
@Override
public void handleEvent(Event arg0) {
Utils.launch(UrlUtils.encode(sURL));
}
});
}
String sCursor = properties.getStringValue(sConfigID + ".cursor");
if (sCursor != null && sCursor.length() > 0) {
if (sCursor.equalsIgnoreCase("hand")) {
canvas.addListener(SWT.MouseEnter, skin.getHandCursorListener(canvas.getDisplay()));
canvas.addListener(SWT.MouseExit, skin.getHandCursorListener(canvas.getDisplay()));
}
}
// SWTBGImagePainter painter = (SWTBGImagePainter) parent.getData("BGPainter");
// if (painter != null) {
// canvas.addListener(SWT.Paint, painter);
// }
canvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
String oldImageID = (String) canvas.getData("ImageID");
if (oldImageID != null && canvas.getData("image") != null) {
ImageLoader imageLoader = skin.getImageLoader(properties);
imageLoader.releaseImage(oldImageID);
}
}
});
// needed to set paint listener and canvas size
swt_reallySetImage();
return canvas;
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class SWTSkinObjectImage method swt_reallySetImage.
protected void swt_reallySetImage() {
if (currentImageID == null || customImage) {
drawAlpha = 255;
return;
}
boolean removedDisabled = false;
ImageLoader imageLoader = skin.getImageLoader(properties);
boolean imageExists = imageLoader.imageExists(currentImageID);
if (!imageExists && imageLoader.imageExists(currentImageID + ".image")) {
currentImageID = sConfigID + ".image";
imageExists = true;
}
if (!imageExists && suffixes != null) {
for (int i = suffixes.length - 1; i >= 0; i--) {
String suffixToRemove = suffixes[i];
if (suffixToRemove != null) {
if (suffixToRemove.equals("-disabled")) {
removedDisabled = true;
}
currentImageID = currentImageID.substring(0, currentImageID.length() - suffixToRemove.length());
if (imageLoader.imageExists(currentImageID)) {
imageExists = true;
break;
}
}
}
}
if (imageExists) {
drawAlpha = removedDisabled ? 64 : 255;
setCanvasImage(currentImageID, null);
} else {
drawAlpha = 255;
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
FormData fd = (FormData) canvas.getLayoutData();
if (fd == null) {
fd = new FormData(0, 0);
} else {
fd.width = 0;
fd.height = 0;
}
canvas.setLayoutData(fd);
if (initialized) {
Utils.relayout(canvas);
}
}
});
}
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class SWTSkinObjectImage2 method createImageWidget.
private Canvas createImageWidget(String sConfigID) {
String propImageID = properties.getStringValue(sConfigID + ".imageid");
if (propImageID != null) {
currentImageID = customImageID = propImageID;
} else {
currentImageID = sConfigID;
}
int style = SWT.WRAP | SWT.DOUBLE_BUFFERED;
String sAlign = properties.getStringValue(sConfigID + ".align");
if (sAlign != null && !Constants.isUnix) {
h_align = SWTSkinUtils.getAlignment(sAlign, SWT.NONE);
if (h_align != SWT.NONE) {
style |= h_align;
}
}
if (properties.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.setData("SkinObject", this);
// {
// public Point computeSize(int wHint, int hHint) {
// Object image = canvas.getData("image");
// Object imageID = canvas.getData("ImageID");
// if (image == null
// && (imageID == null || ((String) imageID).length() == 0)) {
// return new Point(0, 0);
// }
// return super.computeSize(wHint, hHint);
// };
//
// public Point computeSize(int wHint, int hHint, boolean changed) {
// Object image = canvas.getData("image");
// Object imageID = canvas.getData("ImageID");
// if (image == null
// && (imageID == null || ((String) imageID).length() == 0)) {
// return new Point(0, 0);
// }
// return super.computeSize(wHint, hHint, changed);
// };
// };
Color color = properties.getColor(sConfigID + ".color");
if (color != null) {
canvas.setBackground(color);
}
final String sURL = properties.getStringValue(sConfigID + ".url");
if (sURL != null && sURL.length() > 0) {
Utils.setTT(canvas, sURL);
canvas.addListener(SWT.MouseUp, new Listener() {
@Override
public void handleEvent(Event arg0) {
Utils.launch(UrlUtils.encode(sURL));
}
});
}
String sCursor = properties.getStringValue(sConfigID + ".cursor");
if (sCursor != null && sCursor.length() > 0) {
if (sCursor.equalsIgnoreCase("hand")) {
canvas.addListener(SWT.MouseEnter, skin.getHandCursorListener(canvas.getDisplay()));
canvas.addListener(SWT.MouseExit, skin.getHandCursorListener(canvas.getDisplay()));
}
}
// SWTBGImagePainter painter = (SWTBGImagePainter) parent.getData("BGPainter");
// if (painter != null) {
// canvas.addListener(SWT.Paint, painter);
// }
canvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
String oldImageID = (String) canvas.getData("ImageID");
if (oldImageID != null && canvas.getData("image") != null) {
ImageLoader imageLoader = skin.getImageLoader(properties);
imageLoader.releaseImage(oldImageID);
}
}
});
// needed to set paint listener and canvas size
swt_reallySetImage();
return canvas;
}
Aggregations