home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / CFJava.cab / CFJavaRuntime.cab / netscape / application / DragWell.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-10-01  |  4.7 KB  |  164 lines

  1. package netscape.application;
  2.  
  3. import netscape.util.ClassInfo;
  4. import netscape.util.Codable;
  5. import netscape.util.CodingException;
  6. import netscape.util.Decoder;
  7. import netscape.util.Encoder;
  8.  
  9. public class DragWell extends View implements DragSource {
  10.    Image image;
  11.    String dataType;
  12.    Object data;
  13.    Border border;
  14.    boolean enabled;
  15.    static final String IMAGE_KEY = "image";
  16.    static final String DATA_KEY = "data";
  17.    static final String DATATYPE_KEY = "dataType";
  18.    static final String ENABLED_KEY = "enabled";
  19.    static final String BORDER_KEY = "border";
  20.  
  21.    public DragWell() {
  22.       this(0, 0, 0, 0);
  23.    }
  24.  
  25.    public DragWell(Rect var1) {
  26.       this(var1.x, var1.y, var1.width, var1.height);
  27.    }
  28.  
  29.    public DragWell(int var1, int var2, int var3, int var4) {
  30.       super(var1, var2, var3, var4);
  31.       this.border = BezelBorder.loweredBezel();
  32.       this.enabled = true;
  33.    }
  34.  
  35.    public boolean isTransparent() {
  36.       return false;
  37.    }
  38.  
  39.    public void setImage(Image var1) {
  40.       if (this.image != var1) {
  41.          this.image = var1;
  42.          ((View)this).draw();
  43.       }
  44.  
  45.    }
  46.  
  47.    public Image image() {
  48.       return this.image;
  49.    }
  50.  
  51.    public void setDataType(String var1) {
  52.       this.dataType = var1;
  53.    }
  54.  
  55.    public String dataType() {
  56.       return this.dataType;
  57.    }
  58.  
  59.    public void setData(Object var1) {
  60.       this.data = var1;
  61.    }
  62.  
  63.    public Object data() {
  64.       return this.data;
  65.    }
  66.  
  67.    public void setEnabled(boolean var1) {
  68.       if (this.enabled != var1) {
  69.          this.enabled = var1;
  70.          ((View)this).draw();
  71.       }
  72.  
  73.    }
  74.  
  75.    public boolean isEnabled() {
  76.       return this.enabled;
  77.    }
  78.  
  79.    public void setBorder(Border var1) {
  80.       if (var1 == null) {
  81.          var1 = EmptyBorder.emptyBorder();
  82.       }
  83.  
  84.       this.border = var1;
  85.    }
  86.  
  87.    public Border border() {
  88.       return this.border;
  89.    }
  90.  
  91.    public boolean mouseDown(MouseEvent var1) {
  92.       if (!this.enabled) {
  93.          return false;
  94.       } else {
  95.          Image var2 = this.image();
  96.          if (var2 == null) {
  97.             return false;
  98.          } else {
  99.             Rect var3 = new Rect((((View)this).width() - var2.width()) / 2, (((View)this).height() - var2.height()) / 2, var2.width(), var2.height());
  100.             if (!var3.contains(var1.x, var1.y)) {
  101.                return false;
  102.             } else {
  103.                new DragSession(this, var2, var3.x, var3.y, var1.x, var1.y, this.dataType(), this.data);
  104.                return true;
  105.             }
  106.          }
  107.       }
  108.    }
  109.  
  110.    public void drawView(Graphics var1) {
  111.       var1.setColor(Color.lightGray);
  112.       var1.fillRect(0, 0, ((View)this).width(), ((View)this).height());
  113.       Image var2 = this.image();
  114.       if (var2 != null) {
  115.          var2.drawCentered(var1, 0, 0, ((View)this).width(), ((View)this).height());
  116.       }
  117.  
  118.       this.border.drawInRect(var1, 0, 0, ((View)this).width(), ((View)this).height());
  119.    }
  120.  
  121.    public View sourceView(DragSession var1) {
  122.       return this;
  123.    }
  124.  
  125.    public void dragWasAccepted(DragSession var1) {
  126.    }
  127.  
  128.    public boolean dragWasRejected(DragSession var1) {
  129.       return true;
  130.    }
  131.  
  132.    public void describeClassInfo(ClassInfo var1) {
  133.       super.describeClassInfo(var1);
  134.       var1.addClass("netscape.application.DragWell", 1);
  135.       var1.addField("image", (byte)18);
  136.       var1.addField("data", (byte)18);
  137.       var1.addField("dataType", (byte)16);
  138.       var1.addField("enabled", (byte)0);
  139.       var1.addField("border", (byte)18);
  140.    }
  141.  
  142.    public void encode(Encoder var1) throws CodingException {
  143.       super.encode(var1);
  144.       var1.encodeObject("image", this.image);
  145.       var1.encodeObject("data", (Codable)this.data);
  146.       var1.encodeString("dataType", this.dataType);
  147.       var1.encodeBoolean("enabled", this.enabled);
  148.       if (this.border instanceof EmptyBorder) {
  149.          var1.encodeObject("border", (Object)null);
  150.       } else {
  151.          var1.encodeObject("border", this.border);
  152.       }
  153.    }
  154.  
  155.    public void decode(Decoder var1) throws CodingException {
  156.       super.decode(var1);
  157.       this.image = (Image)var1.decodeObject("image");
  158.       this.data = var1.decodeObject("data");
  159.       this.dataType = var1.decodeString("dataType");
  160.       this.enabled = var1.decodeBoolean("enabled");
  161.       this.setBorder((Border)var1.decodeObject("border"));
  162.    }
  163. }
  164.