home *** CD-ROM | disk | FTP | other *** search
- package netscape.application;
-
- import netscape.util.ClassInfo;
- import netscape.util.Codable;
- import netscape.util.CodingException;
- import netscape.util.Decoder;
- import netscape.util.Encoder;
-
- public class DragWell extends View implements DragSource {
- Image image;
- String dataType;
- Object data;
- Border border;
- boolean enabled;
- static final String IMAGE_KEY = "image";
- static final String DATA_KEY = "data";
- static final String DATATYPE_KEY = "dataType";
- static final String ENABLED_KEY = "enabled";
- static final String BORDER_KEY = "border";
-
- public DragWell() {
- this(0, 0, 0, 0);
- }
-
- public DragWell(Rect var1) {
- this(var1.x, var1.y, var1.width, var1.height);
- }
-
- public DragWell(int var1, int var2, int var3, int var4) {
- super(var1, var2, var3, var4);
- this.border = BezelBorder.loweredBezel();
- this.enabled = true;
- }
-
- public boolean isTransparent() {
- return false;
- }
-
- public void setImage(Image var1) {
- if (this.image != var1) {
- this.image = var1;
- ((View)this).draw();
- }
-
- }
-
- public Image image() {
- return this.image;
- }
-
- public void setDataType(String var1) {
- this.dataType = var1;
- }
-
- public String dataType() {
- return this.dataType;
- }
-
- public void setData(Object var1) {
- this.data = var1;
- }
-
- public Object data() {
- return this.data;
- }
-
- public void setEnabled(boolean var1) {
- if (this.enabled != var1) {
- this.enabled = var1;
- ((View)this).draw();
- }
-
- }
-
- public boolean isEnabled() {
- return this.enabled;
- }
-
- public void setBorder(Border var1) {
- if (var1 == null) {
- var1 = EmptyBorder.emptyBorder();
- }
-
- this.border = var1;
- }
-
- public Border border() {
- return this.border;
- }
-
- public boolean mouseDown(MouseEvent var1) {
- if (!this.enabled) {
- return false;
- } else {
- Image var2 = this.image();
- if (var2 == null) {
- return false;
- } else {
- Rect var3 = new Rect((((View)this).width() - var2.width()) / 2, (((View)this).height() - var2.height()) / 2, var2.width(), var2.height());
- if (!var3.contains(var1.x, var1.y)) {
- return false;
- } else {
- new DragSession(this, var2, var3.x, var3.y, var1.x, var1.y, this.dataType(), this.data);
- return true;
- }
- }
- }
- }
-
- public void drawView(Graphics var1) {
- var1.setColor(Color.lightGray);
- var1.fillRect(0, 0, ((View)this).width(), ((View)this).height());
- Image var2 = this.image();
- if (var2 != null) {
- var2.drawCentered(var1, 0, 0, ((View)this).width(), ((View)this).height());
- }
-
- this.border.drawInRect(var1, 0, 0, ((View)this).width(), ((View)this).height());
- }
-
- public View sourceView(DragSession var1) {
- return this;
- }
-
- public void dragWasAccepted(DragSession var1) {
- }
-
- public boolean dragWasRejected(DragSession var1) {
- return true;
- }
-
- public void describeClassInfo(ClassInfo var1) {
- super.describeClassInfo(var1);
- var1.addClass("netscape.application.DragWell", 1);
- var1.addField("image", (byte)18);
- var1.addField("data", (byte)18);
- var1.addField("dataType", (byte)16);
- var1.addField("enabled", (byte)0);
- var1.addField("border", (byte)18);
- }
-
- public void encode(Encoder var1) throws CodingException {
- super.encode(var1);
- var1.encodeObject("image", this.image);
- var1.encodeObject("data", (Codable)this.data);
- var1.encodeString("dataType", this.dataType);
- var1.encodeBoolean("enabled", this.enabled);
- if (this.border instanceof EmptyBorder) {
- var1.encodeObject("border", (Object)null);
- } else {
- var1.encodeObject("border", this.border);
- }
- }
-
- public void decode(Decoder var1) throws CodingException {
- super.decode(var1);
- this.image = (Image)var1.decodeObject("image");
- this.data = var1.decodeObject("data");
- this.dataType = var1.decodeString("dataType");
- this.enabled = var1.decodeBoolean("enabled");
- this.setBorder((Border)var1.decodeObject("border"));
- }
- }
-