home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 127 / dpcs0998.iso / Internet / netobs / Install.exe / t2.z / Rollover.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-06  |  7.1 KB  |  254 lines

  1. public class Rollover extends ComponentApp {
  2.    // $FF: renamed from: d DMessageBox
  3.    DMessageBox field_0 = new DMessageBox();
  4.    DDrawPicture cdp;
  5.    String codebase;
  6.    DAssetManager assetMan;
  7.    DImage imageSizer;
  8.    int linkURL;
  9.    String setval;
  10.    String theURL;
  11.    int Gcontext;
  12.    int ImageOver;
  13.    int ImageOut;
  14.    String sepChar;
  15.    int asset1;
  16.    int f_asset1;
  17.    int asset2;
  18.    int f_asset2;
  19.    int asset3;
  20.    int f_asset3;
  21.  
  22.    public String PropertyListener(String Event, String Value, int Get, int propIndex, IDInspector insp) {
  23.       if (Get == 1) {
  24.          if (Event.compareTo("Initial image") == 0) {
  25.             return Integer.toString(this.asset1);
  26.          }
  27.  
  28.          if (Event.compareTo("   Mouse over image") == 0) {
  29.             return Integer.toString(this.asset2);
  30.          }
  31.  
  32.          if (Event.compareTo("   Mouse out image") == 0) {
  33.             return Integer.toString(this.asset3);
  34.          }
  35.  
  36.          if (Event.compareTo("Link URL") == 0) {
  37.             return Integer.toString(this.linkURL);
  38.          }
  39.       } else {
  40.          if (Event.compareTo("Link URL") == 0) {
  41.             this.linkURL = Integer.parseInt(Value, 10);
  42.          }
  43.  
  44.          if (Event.compareTo("Initial image") == 0) {
  45.             if (this.asset1 != 0) {
  46.                this.assetMan.RemoveAsset(this.asset1);
  47.             }
  48.  
  49.             if (this.f_asset1 != 0) {
  50.                this.assetMan.RemoveAsset(this.f_asset1);
  51.             }
  52.  
  53.             int temp_int = Integer.parseInt(Value, 10);
  54.             this.f_asset1 = temp_int;
  55.             this.imageSizer = new DImage();
  56.             this.imageSizer.setImageFile(this.assetMan.GetAssetLocation(temp_int, -1, 1));
  57.             IDSize currentImageSize = this.imageSizer.getSize();
  58.             this.cdp.SetSize(currentImageSize.getWidth(), currentImageSize.getHeight());
  59.             this.asset1 = this.assetMan.AddAsset(this.assetMan.GetAssetLocation(temp_int, 1, 1), "Image\u0000", "/");
  60.             this.changeimage(temp_int);
  61.          }
  62.  
  63.          if (Event.compareTo("   Mouse over image") == 0) {
  64.             if (this.asset2 != 0) {
  65.                this.assetMan.RemoveAsset(this.asset2);
  66.             }
  67.  
  68.             if (this.f_asset2 != 0) {
  69.                this.assetMan.RemoveAsset(this.f_asset2);
  70.             }
  71.  
  72.             int temp_int = Integer.parseInt(Value, 10);
  73.             this.f_asset2 = temp_int;
  74.             this.asset2 = this.assetMan.AddAsset(this.assetMan.GetAssetLocation(temp_int, 1, 1), "Image\u0000", "/");
  75.             this.changeimage(temp_int);
  76.          }
  77.  
  78.          if (Event.compareTo("   Mouse out image") == 0) {
  79.             if (this.asset3 != 0) {
  80.                this.assetMan.RemoveAsset(this.asset3);
  81.             }
  82.  
  83.             if (this.f_asset3 != 0) {
  84.                this.assetMan.RemoveAsset(this.f_asset3);
  85.             }
  86.  
  87.             int temp_int = Integer.parseInt(Value, 10);
  88.             this.f_asset3 = temp_int;
  89.             this.asset3 = this.assetMan.AddAsset(this.assetMan.GetAssetLocation(temp_int, 1, 1), "Image\u0000", "/");
  90.             this.changeimage(temp_int);
  91.          }
  92.  
  93.          this.cdp.Invalidate(true);
  94.       }
  95.  
  96.       if (insp != null) {
  97.          insp.OnPropertyChanged(-1);
  98.       }
  99.  
  100.       return "";
  101.    }
  102.  
  103.    public String getName(DDrawPicture cdp) {
  104.       IDRect rect = cdp.getObjectRect();
  105.       int top = rect.getTop();
  106.       int left = rect.getLeft();
  107.       String val = "A" + top + left;
  108.       return val;
  109.    }
  110.  
  111.    public void changeimage(int image) {
  112.       this.cdp.setImageFile(this.assetMan.GetAssetLocation(image, -1, 1));
  113.    }
  114.  
  115.    public String onInstall(DAssetManager cam, String codebase) {
  116.       this.assetMan = cam;
  117.       this.codebase = codebase;
  118.       return "Picture Rollover";
  119.    }
  120.  
  121.    protected void finalize() {
  122.       this.assetMan.RemoveAsset(this.linkURL);
  123.       this.assetMan.RemoveAsset(this.asset1);
  124.       this.assetMan.RemoveAsset(this.asset2);
  125.       this.assetMan.RemoveAsset(this.asset3);
  126.       this.assetMan.RemoveAsset(this.f_asset1);
  127.       this.assetMan.RemoveAsset(this.f_asset2);
  128.       this.assetMan.RemoveAsset(this.f_asset3);
  129.    }
  130.  
  131.    public int getHeight(DDrawPicture cdp) {
  132.       IDRect rect = cdp.getObjectRect();
  133.       int top = rect.getTop();
  134.       int bottom = rect.getBottom();
  135.       int height = bottom - top;
  136.       return height;
  137.    }
  138.  
  139.    public void onPublish(DAssetManager asm, int context) {
  140.       if (this.asset1 != 0) {
  141.          this.changeimage(this.asset1);
  142.          this.Gcontext = context;
  143.          String imageName = this.getName(this.cdp);
  144.          if (this.asset3 != 0) {
  145.             this.ImageOut = this.asset3;
  146.          } else {
  147.             this.ImageOut = this.asset1;
  148.          }
  149.  
  150.          if (this.asset2 != 0) {
  151.             this.ImageOver = this.asset2;
  152.          } else {
  153.             this.ImageOver = this.asset1;
  154.          }
  155.  
  156.          if (this.linkURL != -1) {
  157.             this.theURL = this.assetMan.GetAssetRelativeLocation(this.linkURL, this.Gcontext, 1);
  158.          } else {
  159.             this.theURL = "";
  160.          }
  161.  
  162.          String script = "\n<script language=\"JavaScript\"><!--\n";
  163.          script = script + "function on" + imageName + "Over() {}\n";
  164.          script = script + "function on" + imageName + "Out() {}\n";
  165.          script = script + "//--></script>\n";
  166.          script = script + "<script language=\"JavaScript1.1\">";
  167.          script = script + "<!--\n";
  168.          script = script + "graphic1" + imageName + " = new Image()\n";
  169.          script = script + "graphic1" + imageName + ".src = '" + this.getLocation(this.ImageOut) + "';\n";
  170.          script = script + "graphic2" + imageName + " = new Image()\n";
  171.          script = script + "graphic2" + imageName + ".src = '" + this.getLocation(this.ImageOver) + "';\n";
  172.          script = script + "function on" + imageName + "Over() {\n";
  173.          script = script + "document." + imageName + ".src=graphic2" + imageName + ".src;\n";
  174.          script = script + "}\n";
  175.          script = script + "function on" + imageName + "Out() {\n";
  176.          script = script + "document." + imageName + ".src=graphic1" + imageName + ".src;\n";
  177.          script = script + "}\n";
  178.          script = script + "//-->";
  179.          script = script + "</script>\n";
  180.          script = script + "<a href=\"";
  181.          if (this.linkURL != 0) {
  182.             script = script + this.theURL + "\"";
  183.          } else {
  184.             script = script + "javascript:on" + imageName + "Over()\" onClick=\"return false\"";
  185.          }
  186.  
  187.          script = script + " target=\"_self\" onMouseOver=\"on" + imageName + "Over(this)\"";
  188.          script = script + " onMouseOut=\"on" + imageName + "Out(this)\">";
  189.          this.cdp.setHTMLBefore(script);
  190.          this.cdp.setHTMLBetween("name=" + imageName);
  191.          this.cdp.setHTMLAfter("</a>");
  192.       }
  193.  
  194.    }
  195.  
  196.    public int getWidth(DDrawPicture cdp) {
  197.       IDRect rect = cdp.getObjectRect();
  198.       int left = rect.getLeft();
  199.       int right = rect.getRight();
  200.       int width = right - left;
  201.       return width;
  202.    }
  203.  
  204.    public void onDrop(IDLayout layout, IDRect r, int fDrop) {
  205.       if (fDrop == 1) {
  206.          this.cdp = new DDrawPicture();
  207.          this.codebase = this.cdp.getCodeBase();
  208.          this.cdp.setImageFile(this.codebase + "rollover.gif");
  209.          this.cdp.SetPositionRect(r.getLeft(), r.getTop(), r.getRight(), r.getBottom());
  210.          this.imageSizer = new DImage();
  211.          this.imageSizer.setImageFile(this.codebase + "rollover.gif");
  212.          IDSize currentImageSize = this.imageSizer.getSize();
  213.          this.cdp.SetSize(currentImageSize.getWidth(), currentImageSize.getHeight());
  214.          this.cdp.SetStyle(1, 1);
  215.          this.cdp.setStretch(2);
  216.          this.cdp.setUsePictureText(false);
  217.          layout.AddObject(this.cdp);
  218.          DFile tempfile = new DFile();
  219.          this.sepChar = tempfile.GetPathChar();
  220.       }
  221.    }
  222.  
  223.    public void onInspect(CStringArray Names, CStringArray Types) {
  224.       Names.Set("Initial image");
  225.       Types.Set("Image\u0000");
  226.       if (this.asset1 != 0) {
  227.          Names.Set("   Mouse over image");
  228.          Types.Set("Image\u0000");
  229.          Names.Set("   Mouse out image");
  230.          Types.Set("Image\u0000");
  231.       }
  232.  
  233.       Names.Set("Link URL");
  234.       Types.Set("Link\u0000");
  235.    }
  236.  
  237.    public String getLocation(int image) {
  238.       String imageURL = this.assetMan.GetAssetLocation(image, this.Gcontext, 1);
  239.       imageURL.replace(' ', '_');
  240.       imageURL.replace('\\', '/');
  241.       if (imageURL.indexOf(":/") > 0) {
  242.          imageURL.replace(':', '|');
  243.       }
  244.  
  245.       if (imageURL.indexOf(".//") == 0) {
  246.          imageURL = "./" + imageURL.substring(3);
  247.       } else {
  248.          imageURL.replace(':', '/');
  249.       }
  250.  
  251.       return imageURL;
  252.    }
  253. }
  254.