home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 June / INTERNET92.ISO / pc / software / windows / building / visual_dhtml / visualdhtmlwin2000.exe / OCdgImgS.___ (.txt) < prev    next >
Encoding:
Java Class File  |  2001-10-19  |  6.9 KB  |  336 lines

  1. import java.awt.Color;
  2. import java.awt.Component;
  3. import java.awt.Container;
  4. import java.awt.Dimension;
  5. import java.awt.Event;
  6. import java.awt.Font;
  7. import java.awt.FontMetrics;
  8. import java.awt.Graphics;
  9. import java.awt.Image;
  10. import java.awt.LayoutManager;
  11.  
  12. public class OCdgImgSub extends OCdg {
  13.    Dimension menud;
  14.    private boolean movingImage;
  15.    private boolean movingSub;
  16.    private boolean subOn;
  17.    int oldx;
  18.    int oldy;
  19.    Event the_e;
  20.    Font font;
  21.    // $FF: renamed from: fm java.awt.FontMetrics
  22.    FontMetrics field_0;
  23.    Image suboff;
  24.    Graphics g_suboff;
  25.    int break_hl;
  26.    int break_stand;
  27.    int font_style = 0;
  28.    int menux;
  29.    int menuy;
  30.    int menuwidth;
  31.    int menuheight;
  32.    int bitheight;
  33.    int on_sub_num = 0;
  34.    int last_sub;
  35.    boolean sub_highlighted = false;
  36.    boolean[] hlimg_status;
  37.    boolean[] simg_status;
  38.    private Color m_bgcolor;
  39.    private String[] m_imagefile;
  40.    private String[] m_switchfile;
  41.    private int[] m_pic_xcord;
  42.    private int[] m_pic_ycord;
  43.    private int[] m_menu_xcord;
  44.    private int[] m_menu_ycord;
  45.    private String[][] m_desc;
  46.    private String m_bgimage;
  47.    private int m_bgx;
  48.    private int m_bgy;
  49.    int manip_image;
  50.    int num_images;
  51.    int[] pic_width;
  52.    int[] pic_height;
  53.    int[] max_string_width;
  54.    Image[] s_picture;
  55.    Image[] h_picture;
  56.    Image bg_picture;
  57.    APInfo appinfo;
  58.    OCmsl subs;
  59.  
  60.    private void moveImage(int var1, int var2) {
  61.       this.m_pic_ycord[this.manip_image] -= this.oldy - var2;
  62.       this.m_pic_xcord[this.manip_image] -= this.oldx - var1;
  63.       this.reDraw();
  64.       this.the_e.id = 9301;
  65.       this.the_e.arg = "X: " + (new Integer(this.m_pic_xcord[this.manip_image])).toString() + ", Y: " + (new Integer(this.m_pic_ycord[this.manip_image])).toString();
  66.       super.postEvent(this.the_e);
  67.       ((OCdg)this).drawAppOff();
  68.       ((OCdg)this).paintIt();
  69.    }
  70.  
  71.    private void moveSub(int var1, int var2) {
  72.       this.m_menu_ycord[this.manip_image] -= this.oldy - var2;
  73.       this.m_menu_xcord[this.manip_image] -= this.oldx - var1;
  74.       this.reDraw();
  75.       this.the_e.id = 9301;
  76.       this.the_e.arg = "X: " + (new Integer(this.m_menu_xcord[this.manip_image])).toString() + ", Y: " + (new Integer(this.m_menu_ycord[this.manip_image])).toString();
  77.       super.postEvent(this.the_e);
  78.       ((OCdg)this).drawAppOff();
  79.       ((OCdg)this).paintIt();
  80.    }
  81.  
  82.    public void reDraw() {
  83.       super.g_off.setColor(this.m_bgcolor);
  84.       super.g_off.fillRect(0, 0, super.appWidth, super.appHeight);
  85.       if (this.bg_picture != null) {
  86.          super.g_off.drawImage(this.bg_picture, this.m_bgx, this.m_bgy, this);
  87.       }
  88.  
  89.       for(int var1 = 0; var1 < this.num_images; ++var1) {
  90.          if (this.simg_status[var1]) {
  91.             super.g_off.drawImage(this.s_picture[var1], this.m_pic_xcord[var1], this.m_pic_ycord[var1], this);
  92.          }
  93.       }
  94.  
  95.       if (this.manip_image > -1) {
  96.          super.g_off.setColor(ACutil.invertColor(this.m_bgcolor));
  97.          super.g_off.drawRect(this.m_pic_xcord[this.manip_image] - 2, this.m_pic_ycord[this.manip_image] - 2, this.pic_width[this.manip_image] + 3, this.pic_height[this.manip_image] + 3);
  98.       }
  99.  
  100.       if (this.subOn) {
  101.          this.drawSub();
  102.       }
  103.  
  104.    }
  105.  
  106.    OCdgImgSub(APInfo var1) {
  107.       this.m_bgcolor = Color.black;
  108.       this.manip_image = -1;
  109.       this.num_images = 0;
  110.       this.appinfo = var1;
  111.       this.the_e = new Event(this, 960, this);
  112.       ((Container)this).setLayout((LayoutManager)null);
  113.       this.subs = new OCmsl(true);
  114.    }
  115.  
  116.    public void DrawApplet() {
  117.       this.setUpGraphics();
  118.       ACutil var1 = new ACutil();
  119.       if ((this.bg_picture = var1.getImage(this.m_bgimage)) != null) {
  120.          super.g_off.drawImage(this.bg_picture, this.m_bgx, this.m_bgy, this);
  121.       }
  122.  
  123.       for(int var2 = 0; var2 < this.num_images; ++var2) {
  124.          if ((this.s_picture[var2] = var1.getImage(this.m_imagefile[var2])) != null) {
  125.             this.simg_status[var2] = true;
  126.             super.g_off.drawImage(this.s_picture[var2], this.m_pic_xcord[var2], this.m_pic_ycord[var2], this);
  127.             this.pic_width[var2] = this.s_picture[var2].getWidth(this);
  128.             this.pic_height[var2] = this.s_picture[var2].getHeight(this);
  129.          }
  130.       }
  131.  
  132.    }
  133.  
  134.    public boolean mouseUp(Event var1, int var2, int var3) {
  135.       if (this.movingSub) {
  136.          this.the_e.id = 9211;
  137.          this.the_e.arg = (new Integer(this.m_menu_xcord[this.manip_image])).toString() + "," + (new Integer(this.m_menu_ycord[this.manip_image])).toString();
  138.          super.postEvent(this.the_e);
  139.          this.movingSub = false;
  140.       }
  141.  
  142.       if (this.manip_image > -1) {
  143.          this.the_e.id = 9201;
  144.          this.the_e.arg = (new Integer(this.m_pic_xcord[this.manip_image])).toString() + "," + (new Integer(this.m_pic_ycord[this.manip_image])).toString();
  145.          super.postEvent(this.the_e);
  146.          this.movingImage = false;
  147.       }
  148.  
  149.       return true;
  150.    }
  151.  
  152.    public void initDefault() {
  153.       String var1 = ((OCdg)this).getParameterDefault("bgcolor");
  154.       if (var1 != null) {
  155.          this.m_bgcolor = occcolor.ConvertColor(var1);
  156.       }
  157.  
  158.       var1 = ((OCdg)this).getParameterDefault("bgimagefile");
  159.       if (var1 != null) {
  160.          this.m_bgimage = var1;
  161.       }
  162.  
  163.       var1 = ((OCdg)this).getParameterDefault("bgxy");
  164.       if (var1 != null) {
  165.          int[] var2 = occcord.getIntValues(var1, ",", 2);
  166.          if (var2 != null) {
  167.             this.m_bgx = var2[0];
  168.             this.m_bgy = var2[1];
  169.          }
  170.       }
  171.  
  172.    }
  173.  
  174.    public void initSpecifics() {
  175.       boolean var2 = false;
  176.       this.num_images = super.spe_pv.size();
  177.       this.m_imagefile = new String[this.num_images];
  178.       this.m_switchfile = new String[this.num_images];
  179.       this.m_pic_xcord = new int[this.num_images];
  180.       this.m_pic_ycord = new int[this.num_images];
  181.       this.pic_width = new int[this.num_images];
  182.       this.pic_height = new int[this.num_images];
  183.       this.s_picture = new Image[this.num_images];
  184.       this.h_picture = new Image[this.num_images];
  185.       this.hlimg_status = new boolean[this.num_images];
  186.       this.simg_status = new boolean[this.num_images];
  187.       this.m_menu_xcord = new int[this.num_images];
  188.       this.m_menu_ycord = new int[this.num_images];
  189.  
  190.       for(int var7 = 0; var7 < this.num_images; ++var7) {
  191.          String var1 = ((OCdg)this).getParameterSpecific("imagefile", var7);
  192.          if (var1 != null) {
  193.             this.m_imagefile[var7] = new String(var1);
  194.          } else {
  195.             this.m_imagefile[var7] = new String("-1");
  196.          }
  197.  
  198.          var1 = ((OCdg)this).getParameterSpecific("switchfile", var7);
  199.          if (var1 != null) {
  200.             this.m_switchfile[var7] = new String(var1);
  201.          } else {
  202.             this.m_switchfile[var7] = new String("-1");
  203.          }
  204.  
  205.          var1 = ((OCdg)this).getParameterSpecific("imagexy", var7);
  206.          if (var1 != null) {
  207.             int[] var3 = occcord.getIntValues(var1, ",", 2);
  208.             if (var3 != null) {
  209.                this.m_pic_xcord[var7] = var3[0];
  210.                this.m_pic_ycord[var7] = var3[1];
  211.             }
  212.          }
  213.  
  214.          var1 = ((OCdg)this).getParameterSpecific("subxy", var7);
  215.          if (var1 != null) {
  216.             int[] var8 = occcord.getIntValues(var1, ",", 2);
  217.             if (var8 != null) {
  218.                this.m_menu_xcord[var7] = var8[0];
  219.                this.m_menu_ycord[var7] = var8[1];
  220.             }
  221.          }
  222.       }
  223.  
  224.    }
  225.  
  226.    public void setUpGraphics() {
  227.       super.off = ((Component)this).createImage(super.appWidth, super.appHeight);
  228.       super.g_off = super.off.getGraphics();
  229.       super.g_off.setColor(this.m_bgcolor);
  230.       super.g_off.fillRect(0, 0, super.appWidth, super.appHeight);
  231.    }
  232.  
  233.    public boolean mouseDown(Event var1, int var2, int var3) {
  234.       ((Component)this).requestFocus();
  235.       this.oldx = var2;
  236.       this.oldy = var3;
  237.  
  238.       for(int var4 = 0; var4 < this.num_images; ++var4) {
  239.          if (this.subOn && this.manip_image == var4) {
  240.             int var5 = this.m_pic_xcord[var4] + super.scroll_x + this.m_menu_xcord[var4] + super.offimgx;
  241.             int var6 = this.m_pic_ycord[var4] + super.scroll_y + this.m_menu_ycord[var4] + super.offimgy;
  242.             int var7 = var5 + this.menud.width;
  243.             int var8 = var6 + this.menud.height;
  244.             if (var3 > var6 && var3 < var8 && var2 > var5 && var2 < var7) {
  245.                this.movingSub = true;
  246.                return true;
  247.             }
  248.          }
  249.       }
  250.  
  251.       for(int var9 = 0; var9 < this.num_images; ++var9) {
  252.          if (var3 > this.m_pic_ycord[var9] + super.scroll_y + super.offimgy && var3 < this.m_pic_ycord[var9] + this.pic_height[var9] + super.scroll_y + super.offimgy && var2 > this.m_pic_xcord[var9] + super.scroll_x + super.offimgx && var2 < this.m_pic_xcord[var9] + this.pic_width[var9] + super.scroll_x + super.offimgx) {
  253.             if (this.manip_image != var9) {
  254.                this.manip_image = var9;
  255.                this.the_e.id = 9202;
  256.                this.the_e.arg = new Integer(this.manip_image);
  257.                super.postEvent(this.the_e);
  258.                this.setUpSub();
  259.                this.reDraw();
  260.                ((OCdg)this).drawAppOff();
  261.                ((OCdg)this).paintIt();
  262.             }
  263.  
  264.             this.movingImage = true;
  265.             return true;
  266.          }
  267.       }
  268.  
  269.       this.movingSub = false;
  270.       this.movingImage = false;
  271.       this.subOn = false;
  272.       this.manip_image = -1;
  273.       this.reDraw();
  274.       ((OCdg)this).drawAppOff();
  275.       ((OCdg)this).paintIt();
  276.       return true;
  277.    }
  278.  
  279.    public void updateDisplay(int var1) {
  280.       if (!super.first_run) {
  281.          if (this.simg_status[var1]) {
  282.             this.manip_image = var1;
  283.          } else {
  284.             this.manip_image = -1;
  285.             this.subOn = false;
  286.             this.movingSub = false;
  287.             this.movingImage = false;
  288.          }
  289.  
  290.          this.setUpSub();
  291.          this.reDraw();
  292.          ((OCdg)this).drawAppOff();
  293.          ((OCdg)this).paintIt();
  294.       }
  295.  
  296.    }
  297.  
  298.    public void setUpSub() {
  299.       if (this.appinfo.getSpecMLValues().isItem(this.manip_image + "-0")) {
  300.          this.subs.addDefaults(this.appinfo.getDefParamDescs(), this.appinfo.getDefValues());
  301.          this.subs.addSpecifics(this.appinfo.getSpecMLParamDescs(), this.appinfo.getSpecMLValues().valuesAtLevel(this.manip_image + "-0"));
  302.          this.subs.setAppDimensions(new Integer(this.appinfo.getDefValues()[0]), new Integer(this.appinfo.getDefValues()[1]));
  303.          this.subs.getMenuImageSize();
  304.          this.menud = this.subs.getMenuImageSize();
  305.          this.suboff = ((Component)this).createImage(this.menud.width, this.menud.height);
  306.          this.g_suboff = this.suboff.getGraphics();
  307.          this.suboff = this.subs.getMenuImage(this.suboff, this.g_suboff);
  308.          this.subOn = true;
  309.       } else {
  310.          this.subOn = false;
  311.       }
  312.    }
  313.  
  314.    private void drawSub() {
  315.       if (this.manip_image > -1) {
  316.          super.g_off.drawImage(this.suboff, this.m_pic_xcord[this.manip_image] + this.m_menu_xcord[this.manip_image], this.m_pic_ycord[this.manip_image] + this.m_menu_ycord[this.manip_image], this);
  317.       }
  318.  
  319.    }
  320.  
  321.    public boolean mouseDrag(Event var1, int var2, int var3) {
  322.       if (this.manip_image > -1) {
  323.          if (this.movingSub) {
  324.             this.moveSub(var2, var3);
  325.          } else if (this.movingImage) {
  326.             this.moveImage(var2, var3);
  327.          }
  328.  
  329.          this.oldx = var2;
  330.          this.oldy = var3;
  331.       }
  332.  
  333.       return true;
  334.    }
  335. }
  336.