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

  1. import java.awt.Color;
  2. import java.awt.Component;
  3. import java.awt.Event;
  4. import java.awt.Font;
  5. import java.awt.FontMetrics;
  6. import java.awt.Graphics;
  7. import java.awt.Image;
  8.  
  9. public class OCdgSlideM extends OCdg {
  10.    Event the_e;
  11.    Image mainoff;
  12.    Graphics g_mainoff;
  13.    int num_desc = 0;
  14.    int num_icons = 0;
  15.    private Color m_bgcolor;
  16.    private int[] m_mainicon;
  17.    private Image[] i_pic;
  18.    private int[] m_main_icon;
  19.    private String[] m_maindesc;
  20.    private String[] m_iconfile;
  21.    private int m_top_offset;
  22.    private boolean m_tile_bg;
  23.    private String m_main_bgfile;
  24.    private Image m_main_bgimage;
  25.    private Color m_main_ocolor;
  26.    private Color m_main_textcolor;
  27.    private int m_main_height;
  28.    private int m_main_indent;
  29.    private boolean m_tile_menus_only;
  30.    private int m_main_icon_indent;
  31.    Font main_font;
  32.    FontMetrics fm_main_font;
  33.  
  34.    public void initIcon(String[] var1) {
  35.       this.m_iconfile = var1;
  36.       this.num_icons = this.m_iconfile.length;
  37.       this.i_pic = new Image[this.num_icons];
  38.    }
  39.  
  40.    private void reDraw() {
  41.       boolean var1 = false;
  42.       this.mainoff = ((Component)this).createImage(super.appWidth, this.m_main_height + 1);
  43.       this.g_mainoff = this.mainoff.getGraphics();
  44.       this.g_mainoff.setFont(this.main_font);
  45.       super.g_off.setFont(this.main_font);
  46.       if (this.m_tile_menus_only) {
  47.          super.g_off.clipRect(0, 0, super.appWidth, this.m_main_height * this.m_maindesc.length + this.m_top_offset + 1);
  48.       }
  49.  
  50.       if (this.m_bgcolor != null) {
  51.          super.g_off.setColor(this.m_bgcolor);
  52.          super.g_off.fillRect(0, 0, super.appWidth, super.appHeight);
  53.       }
  54.  
  55.       if (this.m_main_bgimage != null) {
  56.          if (this.m_tile_bg) {
  57.             int var2 = 0;
  58.             int var3 = 0;
  59.             int var4 = this.m_main_bgimage.getWidth(this);
  60.             int var5 = this.m_main_bgimage.getHeight(this);
  61.  
  62.             while(true) {
  63.                super.g_off.drawImage(this.m_main_bgimage, var2, var3, this);
  64.                var2 += var4;
  65.                if (var2 > super.appWidth) {
  66.                   var2 = 0;
  67.                   var3 += var5;
  68.                   if (this.m_tile_menus_only) {
  69.                      if (var3 > this.m_main_height * this.m_maindesc.length) {
  70.                         break;
  71.                      }
  72.                   } else if (var3 > super.appHeight) {
  73.                      break;
  74.                   }
  75.                }
  76.             }
  77.          } else {
  78.             super.g_off.drawImage(this.m_main_bgimage, 0, 0, this);
  79.          }
  80.       }
  81.  
  82.       for(int var6 = 0; var6 < this.m_maindesc.length; ++var6) {
  83.          if (this.i_pic != null && this.m_mainicon[var6] > -1 && this.i_pic.length > this.m_mainicon[var6] && this.i_pic[this.m_mainicon[var6]] != null) {
  84.             super.g_off.drawImage(this.i_pic[this.m_mainicon[var6]], this.m_main_icon_indent, this.m_main_height * var6 + this.m_top_offset + this.m_main_height / 2 - this.i_pic[this.m_mainicon[var6]].getHeight(this) / 2, this);
  85.          }
  86.  
  87.          if (this.m_main_ocolor != null) {
  88.             super.g_off.setColor(this.m_main_ocolor);
  89.             super.g_off.drawRect(0, this.m_main_height * var6 + this.m_top_offset, super.appWidth - 1, this.m_main_height);
  90.          }
  91.  
  92.          super.g_off.setColor(this.m_main_textcolor);
  93.          super.g_off.drawString(this.m_maindesc[var6], this.m_main_indent, this.m_main_height / 2 - this.fm_main_font.getHeight() / 2 + this.fm_main_font.getAscent() + this.m_main_height * var6 + this.m_top_offset);
  94.       }
  95.  
  96.       super.g_off = super.off.getGraphics();
  97.    }
  98.  
  99.    OCdgSlideM() {
  100.       this.m_bgcolor = Color.black;
  101.       this.m_main_bgfile = "-1";
  102.       this.m_main_ocolor = null;
  103.       this.m_main_textcolor = Color.white;
  104.       this.the_e = new Event(this, 960, this);
  105.    }
  106.  
  107.    public synchronized void DrawApplet() {
  108.       super.off = ((Component)this).createImage(super.appWidth, super.appHeight);
  109.       super.g_off = super.off.getGraphics();
  110.       super.g_off.setColor(this.m_bgcolor);
  111.       super.g_off.fillRect(0, 0, super.appWidth, super.appHeight);
  112.       ACutil var1 = new ACutil();
  113.       this.m_main_bgimage = var1.getImage(this.m_main_bgfile);
  114.  
  115.       for(int var2 = 0; var2 < this.num_icons; ++var2) {
  116.          this.i_pic[var2] = var1.getImage(this.m_iconfile[var2]);
  117.       }
  118.  
  119.       this.reDraw();
  120.    }
  121.  
  122.    public void initDefault() {
  123.       String var1 = ((OCdg)this).getParameterDefault("bgcolor");
  124.       if (var1 != null) {
  125.          this.m_bgcolor = occcolor.ConvertColor(var1);
  126.       }
  127.  
  128.       var1 = ((OCdg)this).getParameterDefault("mfont");
  129.       if (var1 != null) {
  130.          this.main_font = ocfontc.getFontSD(var1, ",");
  131.       } else {
  132.          this.main_font = new Font("Helvetica", 0, 12);
  133.       }
  134.  
  135.       this.fm_main_font = ((Component)this).getFontMetrics(this.main_font);
  136.       var1 = ((OCdg)this).getParameterDefault("mtextcolor");
  137.       if (var1 != null) {
  138.          this.m_main_textcolor = occcolor.ConvertColor(var1);
  139.       }
  140.  
  141.       var1 = ((OCdg)this).getParameterDefault("mindent");
  142.       if (var1 != null) {
  143.          this.m_main_indent = Integer.parseInt(var1);
  144.       }
  145.  
  146.       var1 = ((OCdg)this).getParameterDefault("moutcolor");
  147.       if (var1 != null && !var1.equalsIgnoreCase("<none>")) {
  148.          this.m_main_ocolor = occcolor.ConvertColor(var1);
  149.       } else {
  150.          this.m_main_ocolor = null;
  151.       }
  152.  
  153.       var1 = ((OCdg)this).getParameterDefault("mbgfile");
  154.       if (var1 != null) {
  155.          this.m_main_bgfile = var1;
  156.       }
  157.  
  158.       var1 = ((OCdg)this).getParameterDefault("mheight");
  159.       if (var1 != null) {
  160.          this.m_main_height = Integer.parseInt(var1);
  161.       }
  162.  
  163.       if (this.m_main_height < 1) {
  164.          this.m_main_height = this.fm_main_font.getHeight();
  165.       }
  166.  
  167.       var1 = ((OCdg)this).getParameterDefault("mtilebg");
  168.       if (var1 != null) {
  169.          this.m_tile_bg = Boolean.valueOf(var1);
  170.       }
  171.  
  172.       var1 = ((OCdg)this).getParameterDefault("topoffset");
  173.       if (var1 != null) {
  174.          this.m_top_offset = Integer.parseInt(var1);
  175.       }
  176.  
  177.       var1 = ((OCdg)this).getParameterDefault("mbgonmenusonly");
  178.       if (var1 != null) {
  179.          this.m_tile_menus_only = Boolean.valueOf(var1);
  180.       }
  181.  
  182.       var1 = ((OCdg)this).getParameterDefault("miconindent");
  183.       if (var1 != null) {
  184.          this.m_main_icon_indent = Integer.parseInt(var1);
  185.       }
  186.  
  187.    }
  188.  
  189.    public void initSpecifics() {
  190.       boolean var2 = false;
  191.       this.num_desc = super.spe_pv.size();
  192.       this.m_maindesc = new String[this.num_desc];
  193.       this.m_mainicon = new int[this.num_desc];
  194.  
  195.       for(int var4 = 0; var4 < this.num_desc; ++var4) {
  196.          String var1 = ((OCdg)this).getParameterSpecific("maindesc", var4);
  197.          if (var1 != null) {
  198.             this.m_maindesc[var4] = var1;
  199.          } else {
  200.             this.m_maindesc[var4] = "";
  201.          }
  202.  
  203.          var1 = ((OCdg)this).getParameterSpecificByTitle("icon image id", var4);
  204.          if (var1 != null) {
  205.             this.m_mainicon[var4] = Integer.parseInt(var1);
  206.          } else {
  207.             this.m_mainicon[var4] = -1;
  208.          }
  209.       }
  210.  
  211.    }
  212. }
  213.