01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.ui.client.widget.impl;
09:
10: import net.mygwt.ui.client.widget.PNGImage;
11:
12: import com.google.gwt.user.client.DOM;
13: import com.google.gwt.user.client.Element;
14:
15: /**
16: * PNG support.
17: * <p>
18: * Implementation adapted from GWT Widget Library
19: * (http://gwt-widget.sourceforge.net/).
20: * </p>
21: *
22: */
23: public class PNGImageImplIE6 extends PNGImageImpl {
24: private String url;
25: private boolean isPng;
26:
27: public Element createElement(String url, int width, int height) {
28: this .url = url;
29:
30: if (url.endsWith(".png") || url.endsWith(".PNG")) {
31: isPng = true;
32: } else {
33: isPng = false;
34: }
35:
36: if (isPng) {
37: Element div = DOM.createDiv();
38: DOM
39: .setInnerHTML(
40: div,
41: "<div id='d' style=\"position: relative;width:"
42: + width
43: + "px;height:"
44: + height
45: + "px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
46: + url
47: + "', sizingMethod='scale')\"></div>");
48:
49: return DOM.getFirstChild(div);
50: } else {
51: return super .createElement(url, width, height);
52: }
53: }
54:
55: public String getUrl(PNGImage image) {
56: if (isPng) {
57: return url;
58: } else {
59: return super.getUrl(image);
60: }
61: }
62:
63: }
|