home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.Panel;
- import java.awt.Scrollbar;
- import java.util.Vector;
-
- public class OCicodis extends Panel {
- int realHeight;
- boolean paint_called = false;
- public Color bgColor = new Color(153, 153, 153);
- int h_space;
- int v_space;
- Event the_e;
- private int desc_index = 0;
- // $FF: renamed from: d java.awt.Dimension
- Dimension field_0;
- // $FF: renamed from: ts java.awt.Image
- Image field_1;
- Graphics g_ts;
- Font font = new Font("Helvetica", 0, 11);
- // $FF: renamed from: fm java.awt.FontMetrics
- FontMetrics field_2;
- boolean[] simg_status;
- boolean[] icoimg_status;
- boolean[] cimg_status;
- boolean tag = false;
- boolean first_run = true;
- boolean mouse_in = false;
- private Color m_page_bgcolor;
- private String[] m_iconfile;
- private String[] m_switchfile;
- private String[] m_clickfile;
- private int[] m_pic_xcord;
- private int[] m_pic_ycord;
- private int[] m_menu_xcord;
- private int[] m_menu_ycord;
- private String[][] m_desc;
- int manip_image;
- int num_images;
- int[] pic_width;
- int[] pic_height;
- private Image[] i_picture;
- private Image[] s_picture;
- private Image[] c_picture;
- private String[] def_pn;
- private String[] def_pv;
- private String[] spe_pn;
- private Vector spe_pv;
- int sb_width;
- // $FF: renamed from: sb java.awt.Scrollbar
- Scrollbar field_3;
- int scroll_y;
- int sb_linedist;
- boolean first_sb_run;
- boolean use_sb;
- int last_scroll_y;
- int sbImgHeight;
-
- private String getParameterSpecific(String var1, int var2) {
- for(int var3 = 0; var3 < this.spe_pn.length; ++var3) {
- if (this.spe_pn[var3].equals(var1)) {
- String var4 = ((String[])this.spe_pv.elementAt(var2))[var3];
- if (var4 != null && !var4.equals("") && !var4.equalsIgnoreCase("<default>")) {
- return var4;
- }
-
- return null;
- }
- }
-
- return null;
- }
-
- private void figureSizing() {
- this.h_space = 10;
- this.v_space = 10;
- int var1 = 0;
- int var2 = 0;
-
- for(int var3 = 0; var3 < this.num_images; ++var3) {
- if (var1 < this.pic_width[var3]) {
- var1 = this.pic_width[var3];
- }
-
- if (var2 < this.pic_height[var3]) {
- var2 = this.pic_height[var3];
- }
- }
-
- this.h_space += var1;
- this.v_space += var2;
- int var6 = 0;
- int var4 = 0;
-
- for(int var5 = 0; var5 < this.num_images; ++var5) {
- this.m_pic_xcord[var5] = var6 + (this.h_space - var1) / 2;
- this.m_pic_ycord[var5] = var4 + (this.v_space - var2) / 2;
- var6 += this.h_space;
- if (var6 > this.field_0.width) {
- var6 = 0;
- var4 += this.v_space;
- this.m_pic_xcord[var5] = var6 + (this.h_space - var1) / 2;
- this.m_pic_ycord[var5] = var4 + (this.v_space - var2) / 2;
- }
- }
-
- if (var4 + this.v_space > this.field_0.height) {
- this.realHeight = var4 + this.v_space;
- } else {
- this.realHeight = this.field_0.height;
- }
- }
-
- OCicodis() {
- this.m_page_bgcolor = Color.white;
- this.manip_image = -1;
- this.num_images = 0;
- this.sb_width = 12;
- this.sb_linedist = 1;
- this.first_sb_run = true;
- this.use_sb = false;
- this.the_e = new Event(this, 960, this);
- ((Container)this).setLayout((LayoutManager)null);
- }
-
- public void paint(Graphics var1) {
- this.paint_called = true;
- this.paintIt();
- }
-
- public void reDraw() {
- boolean var1 = false;
- this.g_ts.setColor(this.m_page_bgcolor);
- this.g_ts.fillRect(0, 0, this.field_0.width, this.realHeight);
-
- for(int var2 = 0; var2 < this.num_images; ++var2) {
- if (this.icoimg_status[var2]) {
- var1 = true;
- this.g_ts.drawImage(this.i_picture[var2], this.m_pic_xcord[var2], this.m_pic_ycord[var2], this);
- }
- }
-
- if (!var1) {
- this.g_ts.setColor(Color.black);
- this.g_ts.setFont(this.font);
- this.field_2 = ((Component)this).getFontMetrics(this.font);
- String var8 = "(No icon imges are currently defined.)";
- byte var3 = 10;
- String[] var4 = ocwordw.WrapText(var8, this.field_0.width - var3, this.field_2);
- int var5 = this.field_2.getHeight() * var4.length + this.field_2.getAscent() / 2;
- int var6 = this.field_0.height / 2 - var5 / 2;
-
- for(int var7 = 0; var7 < var4.length; ++var7) {
- this.g_ts.drawString(var4[var7], this.field_0.width / 2 - this.field_2.stringWidth(var4[var7]) / 2, var6 + (var7 + 1) * this.field_2.getHeight());
- }
- }
-
- if (this.manip_image > -1 && this.manip_image <= this.num_images && this.icoimg_status[this.manip_image]) {
- this.g_ts.setColor(Color.lightGray);
- this.g_ts.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);
- }
-
- }
-
- public void addSpecifics(String[] var1, Vector var2) {
- this.spe_pn = var1;
- this.spe_pv = var2;
- this.initSpecifics();
- }
-
- private String getParameterDefault(String var1) {
- for(int var2 = 0; var2 < this.def_pn.length; ++var2) {
- if (this.def_pn[var2].equals(var1)) {
- return this.def_pv[var2];
- }
- }
-
- return null;
- }
-
- public void initDefault() {
- }
-
- private synchronized void paintIt() {
- if (this.paint_called) {
- Graphics var1 = ((Component)this).getGraphics();
- if (this.first_run) {
- ((Component)this).setBackground(this.bgColor);
- this.field_1 = ((Component)this).createImage(this.field_0.width, this.realHeight);
- this.g_ts = this.field_1.getGraphics();
- this.first_run = false;
- this.reDraw();
- this.paintIt();
- if (this.first_sb_run) {
- if (this.use_sb) {
- this.field_3 = new Scrollbar();
- this.field_3.reshape(this.field_0.width - this.sb_width, 0, this.sb_width, this.field_0.height);
- this.field_3.setBackground(Color.gray);
- ((Container)this).add(this.field_3);
- this.first_sb_run = false;
- }
- } else if (!this.use_sb) {
- ((Container)this).remove(this.field_3);
- this.field_3 = null;
- this.first_sb_run = true;
- } else {
- this.field_3.reshape(this.field_0.width - this.sb_width, 0, this.sb_width, this.field_0.height);
- }
-
- if (this.use_sb) {
- this.field_3.setValues(this.field_3.getValue(), 1, 0, this.sbImgHeight - this.field_0.height);
- return;
- }
- } else {
- var1.drawImage(this.field_1, 0, this.scroll_y, this);
- }
-
- }
- }
-
- public void LoadImages() {
- ACutil var1 = new ACutil();
-
- for(int var2 = 0; var2 < this.num_images; ++var2) {
- if ((this.i_picture[var2] = var1.getDGImage(this.m_iconfile[var2])) != null) {
- this.icoimg_status[var2] = true;
- this.pic_width[var2] = this.i_picture[var2].getWidth(this);
- this.pic_height[var2] = this.i_picture[var2].getHeight(this);
- }
- }
-
- }
-
- public void resize(Dimension var1) {
- if (var1.width * var1.height > 0) {
- this.centerAppArea();
- super.resize(var1);
- }
- }
-
- public void resize(int var1, int var2) {
- if (var1 * var2 > 0) {
- this.field_0 = new Dimension(var1, var2);
- this.centerAppArea();
- super.resize(var1, var2);
- }
- }
-
- public void initSpecifics() {
- boolean var2 = false;
- this.num_images = this.spe_pv.size();
- this.m_iconfile = new String[this.num_images];
- this.m_switchfile = new String[this.num_images];
- this.m_clickfile = new String[this.num_images];
- this.m_pic_xcord = new int[this.num_images];
- this.m_pic_ycord = new int[this.num_images];
- this.pic_width = new int[this.num_images];
- this.pic_height = new int[this.num_images];
- this.i_picture = new Image[this.num_images];
- this.s_picture = new Image[this.num_images];
- this.c_picture = new Image[this.num_images];
- this.simg_status = new boolean[this.num_images];
- this.icoimg_status = new boolean[this.num_images];
- this.cimg_status = new boolean[this.num_images];
-
- for(int var5 = 0; var5 < this.num_images; ++var5) {
- String var1 = this.getParameterSpecific("iconimage", var5);
- if (var1 != null) {
- this.m_iconfile[var5] = new String(var1);
- } else {
- this.m_iconfile[var5] = new String("-1");
- }
-
- var1 = this.getParameterSpecific("switchimage", var5);
- if (var1 != null) {
- this.m_switchfile[var5] = new String(var1);
- } else {
- this.m_switchfile[var5] = new String("-1");
- }
-
- var1 = this.getParameterSpecific("iconclickfile", var5);
- if (var1 != null) {
- this.m_clickfile[var5] = new String(var1);
- } else {
- this.m_clickfile[var5] = new String("-1");
- }
- }
-
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- ((Component)this).requestFocus();
-
- for(int var4 = 0; var4 < this.num_images; ++var4) {
- if (var3 > this.m_pic_ycord[var4] + this.scroll_y && var3 < this.m_pic_ycord[var4] + this.pic_height[var4] + this.scroll_y && var2 > this.m_pic_xcord[var4] && var2 < this.m_pic_xcord[var4] + this.pic_width[var4]) {
- if (this.manip_image != var4) {
- this.manip_image = var4;
- this.the_e.id = 9202;
- this.the_e.arg = new Integer(this.manip_image);
- super.postEvent(this.the_e);
- this.reDraw();
- this.paintIt();
- }
-
- return true;
- }
- }
-
- this.manip_image = -1;
- return true;
- }
-
- private void centerAppArea() {
- this.LoadImages();
- this.figureSizing();
- if (this.realHeight > this.field_0.height) {
- this.use_sb = true;
- this.realHeight += this.sb_width;
- } else {
- this.use_sb = false;
- }
-
- this.scroll_y = 0;
- if (this.use_sb) {
- this.scroll_y = this.last_scroll_y;
- }
-
- this.first_run = true;
- this.paintIt();
- }
-
- public void updateDisplay(int var1) {
- this.desc_index = var1;
- this.manip_image = this.desc_index;
- this.centerAppArea();
- }
-
- public void addDefaults(String[] var1, String[] var2) {
- this.def_pn = var1;
- this.def_pv = var2;
- this.initDefault();
- }
-
- public boolean handleEvent(Event var1) {
- boolean var2 = false;
- if (var1.target != this.field_3) {
- return super.handleEvent(var1);
- } else {
- if (var1.id != 602 && var1.id != 601 && var1.id != 605) {
- if (var1.id == 604 || var1.id == 603) {
- this.scroll_y = -(this.field_3.getValue() * this.sb_linedist);
- this.field_3.setValue(this.field_3.getValue());
- var2 = true;
- }
- } else {
- this.scroll_y = -(this.field_3.getValue() * this.sb_linedist);
- this.field_3.setValue(this.field_3.getValue());
- var2 = true;
- }
-
- if (var2) {
- if (this.scroll_y >= 0) {
- this.scroll_y = 0;
- } else if (this.scroll_y + this.sbImgHeight < this.field_0.height) {
- this.scroll_y = -this.sbImgHeight + this.field_0.height;
- }
-
- this.last_scroll_y = this.scroll_y;
- this.paintIt();
- var2 = false;
- }
-
- return true;
- }
- }
-
- public void reshape(int var1, int var2, int var3, int var4) {
- if (var3 * var4 > 0) {
- this.field_0 = new Dimension(var3, var4);
- this.centerAppArea();
- super.reshape(var1, var2, var3, var4);
- }
- }
- }
-