home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- 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.Panel;
- import java.awt.Rectangle;
- import java.awt.image.ImageObserver;
-
- public class JDPButton extends Panel {
- static final String[] iconNames = new String[]{"", "Save", "Load", "Compile", "Build", "Search", "Go", "Undo", "Plus", "Delete", "New", "Copy", "Check", "Arrow", "Picture", "Label", "TextField", "ChiselFrame", "Button", "Checkbox", "RadioButton", "Choice", "List", "ScrollSouth", "ScrollEast", "Panel", "TabPanel", "Tree", "Grid", "HotKey", "Slider", "Progress", "Spinner", "Custom", "Chart", "Report", "Email", "Define", "Helpbook", "APIbook", "Layout", "Circular", "BuildErrors", "View", "Documents", "Pager", "NewFolder", "DebugBuild", "Printer", "SearchFwd", "SearchBack"};
- public static final int SAVE = 0;
- public static final int LOAD = 1;
- public static final int COMPILE = 2;
- public static final int BUILD = 3;
- public static final int SEARCH = 4;
- // $FF: renamed from: GO int
- public static final int field_0 = 5;
- public static final int UNDO = 6;
- public static final int PLUS = 7;
- public static final int DELETE = 8;
- public static final int NEW = 9;
- public static final int COPY = 10;
- public static final int CHECK = 11;
- public static final int ARROW = 12;
- public static final int PICTURE = 13;
- public static final int LABEL = 14;
- public static final int TEXTFIELD = 15;
- public static final int CHISELFRAME = 16;
- public static final int BUTTON = 17;
- public static final int CHECKBOX = 18;
- public static final int RADIO = 19;
- public static final int CHOICE = 20;
- public static final int LIST = 21;
- public static final int SCROLLSOUTH = 22;
- public static final int SCROLLEAST = 23;
- public static final int PANEL = 24;
- public static final int TAB = 25;
- public static final int TREE = 26;
- public static final int GRID = 27;
- public static final int HOTKEY = 28;
- public static final int SLIDER = 29;
- public static final int PROGRESS = 30;
- public static final int SPINNER = 31;
- public static final int CUSTOM = 32;
- public static final int CHART = 33;
- public static final int REPORT = 34;
- public static final int EMAIL = 35;
- public static final int DEFINE = 36;
- public static final int HELPBOOK = 37;
- public static final int APIBOOK = 38;
- public static final int LAYOUT = 39;
- public static final int CIRCULAR = 40;
- public static final int BUILDERRORS = 41;
- public static final int VIEW = 42;
- public static final int DOCUMENTS = 43;
- public static final int PAGER = 44;
- public static final int NEWFOLDER = 45;
- public static final int DEBUGBUILD = 46;
- public static final int PRINTER = 47;
- public static final int SEARCHFWD = 48;
- public static final int SEARCHBACK = 49;
- public static final int CENTER = 0;
- public static final int LEFT = 1;
- public static final int RIGHT = 2;
- // $FF: renamed from: UP int
- public static final int field_1 = 3;
- public static final int DOWN = 4;
- public static final int PULLDOWN = 5;
- static String[] alignmentValues = new String[]{"Center", "Left", "Right"};
- static boolean activated;
- static JDPUser user;
- static JDesignerPro thisJDP;
- Image offscreen;
- Rectangle offscreensize;
- // $FF: renamed from: gr java.awt.Graphics
- Graphics field_2;
- static Image defaultIconImage;
- String thisImageLoc;
- Image iconImage;
- Image iconImages;
- Graphics grI;
- Rectangle Bounds;
- JDPImageLoader imageLoader;
- String buttonText;
- int buttonIcon;
- int alignment;
- String returnValue;
- int arrowDirection;
- Color back;
- private boolean iconOnly;
- Event thisEvent;
- Event thisEvent1;
- boolean buttonPressed;
- boolean drawnPressed;
- boolean stayOn;
- Rectangle buttonRect;
- Font lastFont;
- // $FF: renamed from: fm java.awt.FontMetrics
- FontMetrics field_3;
- int[] widths;
- Button Button;
-
- int totalWidth() {
- int var1 = 0;
- if (this.buttonIcon >= 0) {
- var1 += 24;
- if (this.buttonText != null) {
- ++var1;
- }
- } else {
- var1 = 8;
- }
-
- if (this.buttonText != null) {
- var1 = var1 + this.StringWidth(this.buttonText) + 3;
- }
-
- return var1;
- }
-
- public boolean isPressed() {
- return this.buttonPressed;
- }
-
- int[] getWidths() {
- this.field_3 = this.field_2.getFontMetrics();
- this.widths = this.field_3.getWidths();
- return this.widths;
- }
-
- void setJDPUser(JDPUser var1) {
- user = var1;
- this.checkIconsLoaded();
- }
-
- public JDPButton() {
- this.drawButton((String)null, -1, 0, "", -1);
- }
-
- public JDPButton(String var1) {
- this.drawButton(var1, -1, 0, var1, -1);
- }
-
- public JDPButton(String var1, int var2) {
- this.drawButton(var1, -1, var2, var1, -1);
- }
-
- public JDPButton(String var1, int var2, int var3) {
- this.drawButton(var1, var2, var3, var1, -1);
- }
-
- public JDPButton(int var1, String var2, int var3) {
- this.drawButton((String)null, var1, var3, var2, -1);
- }
-
- public JDPButton(int var1, String var2) {
- this.drawButton((String)null, var1, 0, var2, -1);
- }
-
- public JDPButton(int var1) {
- this.drawButton((String)null, -1, -1, "", var1);
- }
-
- public void update(Graphics var1) {
- Rectangle var2 = ((Component)this).bounds();
- if (this.offscreen == null || var2.width != this.offscreensize.width || var2.height != this.offscreensize.height) {
- if (var2.width < 10) {
- var2.width = 10;
- }
-
- if (var2.height < 10) {
- var2.height = 10;
- }
-
- this.offscreen = ((Component)this).createImage(var2.width, var2.height);
- this.offscreensize = var2;
- this.field_2 = this.offscreen.getGraphics();
- }
-
- if (this.imageLoader != null && this.imageLoader.getImageReady()) {
- this.iconImage = this.imageLoader.thisImage;
- if (defaultIconImage == null) {
- defaultIconImage = this.imageLoader.thisImage;
- }
-
- this.imageLoader = null;
- }
-
- if (defaultIconImage == null) {
- this.checkIconsLoaded();
- }
-
- this.back = ((Component)this).getBackground();
- this.field_2.setFont(((Component)this).getFont());
- if (this.thisEvent != null && !this.drawnPressed) {
- this.buttonPressed = true;
- }
-
- boolean var3 = this.drawnPressed;
- boolean var4 = false;
-
- while(!var4) {
- this.Bounds = ((Component)this).bounds();
- this.field_2.setColor(this.back);
- this.field_2.fillRect(0, 0, this.Bounds.width, this.Bounds.height);
- this.buttonRect = new Rectangle(0, 0, this.Bounds.width, this.Bounds.height);
- this.field_2.setColor(((Component)this).getForeground());
- int var5 = 1;
- int var6 = this.Bounds.height / 2 + this.StringHeight() / 3;
- int var7 = (this.Bounds.height - 20) / 2;
- if (var7 < 1) {
- var7 = 1;
- }
-
- byte var8 = 0;
- if (this.buttonPressed) {
- var8 = 1;
- ++var6;
- ++var7;
- }
-
- if (this.alignment == 0) {
- var5 = (this.Bounds.width - this.totalWidth()) / 2;
- } else if (this.alignment == 2) {
- var5 = this.Bounds.width - this.totalWidth() - 3;
- }
-
- var5 += var8;
- if (this.buttonIcon >= 0) {
- this.drawIcon(this.buttonIcon, var5 + 1, var7);
- var5 += 22;
- } else if (this.alignment == 1 || this.alignment == 0) {
- var5 += 5;
- }
-
- if (this.buttonText != null) {
- if (((Component)this).isEnabled()) {
- this.field_2.drawString(this.buttonText, var5, var6);
- } else {
- this.field_2.setColor(JDPUtils.brighter(this.back));
- this.field_2.drawString(this.buttonText, var5 + 1, var6 + 1);
- this.field_2.setColor(JDPUtils.darker(this.back));
- this.field_2.drawString(this.buttonText, var5, var6);
- }
- }
-
- int var9 = (this.Bounds.width - 3) / 2 + 1;
- int var10 = (this.Bounds.height - 3) / 2 + 1;
- byte var11 = 0;
- if (this.arrowDirection == 5) {
- var11 = 1;
- }
-
- if (!this.buttonPressed) {
- this.field_2.setColor(JDPUtils.brighter(this.back));
- this.field_2.drawLine(0 + var11 * 2, 0 + var11 * 2, this.Bounds.width - 1 - var11, 0 + var11 * 2);
- this.field_2.drawLine(0 + var11 * 2, 0 + var11 * 2, 0 + var11 * 2, this.Bounds.height - 1 - var11);
- this.field_2.setColor(JDPUtils.darker(this.back));
- this.field_2.drawLine(0 + var11 * 2, this.Bounds.height - 1 - var11, 0 + var11 * 2, this.Bounds.height - 1 - var11);
- this.field_2.drawLine(this.Bounds.width - 1 - var11, 0 + var11 * 2, this.Bounds.width - 1 - var11, 0 + var11 * 2);
- this.field_2.drawLine(1 + var11 * 2, this.Bounds.height - 2 - var11, this.Bounds.width - 2 - var11, this.Bounds.height - 2 - var11);
- this.field_2.drawLine(this.Bounds.width - 2 - var11, 1 + var11 * 2, this.Bounds.width - 2 - var11, this.Bounds.height - 2 - var11);
- this.field_2.setColor(Color.black);
- this.field_2.drawLine(1 + var11 * 2, this.Bounds.height - 1 - var11, this.Bounds.width - 1 - var11, this.Bounds.height - 1 - var11);
- this.field_2.drawLine(this.Bounds.width - 1 - var11, 1 + var11 * 2, this.Bounds.width - 1 - var11, this.Bounds.height - 1 - var11);
- var3 = false;
- } else {
- this.field_2.setColor(Color.black);
- this.field_2.drawLine(0 + var11 * 2, 0 + var11 * 2, this.Bounds.width - 1 - var11, 0 + var11 * 2);
- this.field_2.drawLine(0 + var11 * 2, 0 + var11 * 2, 0 + var11 * 2, this.Bounds.height - 1 - var11);
- this.field_2.setColor(JDPUtils.darker(this.back));
- this.field_2.drawLine(1 + var11 * 2, 1 + var11 * 2, this.Bounds.width - 2 - var11, 1 + var11 * 2);
- this.field_2.drawLine(1 + var11 * 2, 1 + var11 * 2, 1 + var11 * 2, this.Bounds.height - 2 - var11);
- this.field_2.setColor(JDPUtils.brighter(this.back));
- this.field_2.drawLine(1 + var11 * 2, this.Bounds.height - 1 - var11, this.Bounds.width - 1 - var11, this.Bounds.height - 1 - var11);
- this.field_2.drawLine(this.Bounds.width - 1 - var11, 1 + var11 * 2, this.Bounds.width - 1 - var11, this.Bounds.height - 1 - var11);
- var3 = true;
- this.field_2.setColor(Color.black);
- ++var9;
- ++var10;
- }
-
- if (this.arrowDirection == 5) {
- this.field_2.setColor(JDPUtils.brighter(this.back));
- this.field_2.drawLine(0, this.Bounds.height - 1, this.Bounds.width - 1, this.Bounds.height - 1);
- this.field_2.drawLine(this.Bounds.width - 1, 1, this.Bounds.width - 1, this.Bounds.height - 1);
- this.field_2.setColor(JDPUtils.darker(this.back));
- this.field_2.drawLine(0, 0, 0, this.Bounds.height - 2);
- this.field_2.drawLine(0, 0, this.Bounds.width - 1, 0);
- this.field_2.setColor(Color.black);
- this.field_2.drawLine(1, 1, 1, this.Bounds.height - 2);
- this.field_2.drawLine(1, 1, this.Bounds.width - 2, 1);
- }
-
- int var12 = 0;
- if (((Component)this).isEnabled()) {
- this.field_2.setColor(((Component)this).getForeground());
- } else {
- this.field_2.setColor(JDPUtils.brighter(this.back));
- var12 = 1;
- }
-
- for(; var12 >= 0; --var12) {
- var9 += var12;
- var10 += var12;
- if (this.arrowDirection == 2) {
- int[] var13 = new int[]{var9 - 1, var9 + 2, var9 - 1, var9 - 1};
- int[] var14 = new int[]{var10 - 3, var10, var10 + 3, var10 - 2};
- this.field_2.fillPolygon(var13, var14, 3);
- }
-
- if (this.arrowDirection == 1) {
- int[] var20 = new int[]{var9 + 2, var9 - 1, var9 + 2, var9 + 2};
- int[] var23 = new int[]{var10 - 3, var10, var10 + 3, var10 - 3};
- this.field_2.fillPolygon(var20, var23, 3);
- }
-
- if (this.arrowDirection == 3) {
- int[] var21 = new int[]{var9 - 3, var9, var9 + 3, var9 - 3};
- int[] var24 = new int[]{var10 + 2, var10 - 2, var10 + 2, var10 + 2};
- this.field_2.fillPolygon(var21, var24, 3);
- }
-
- if (this.arrowDirection == 4 || this.arrowDirection == 5) {
- int[] var22 = new int[]{var9 - 2, var9, var9 + 3, var9 - 2};
- int[] var25 = new int[]{var10 - 1, var10 + 2, var10 - 1, var10 - 1};
- this.field_2.fillPolygon(var22, var25, 3);
- }
-
- var9 -= var12;
- var10 -= var12;
- if (var12 == 1) {
- this.field_2.setColor(JDPUtils.darker(this.back));
- }
- }
-
- var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
- if (this.thisEvent == null || !var3) {
- var4 = true;
- }
-
- if (this.stayOn) {
- var4 = true;
- } else if (this.thisEvent != null) {
- this.buttonPressed = false;
- }
- }
-
- var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
- if (this.thisEvent != null) {
- Event var16 = this.thisEvent;
- this.thisEvent = null;
- super.postEvent(var16);
- if (!this.stayOn) {
- this.buttonPressed = false;
- }
- }
-
- if (this.thisEvent1 != null) {
- Event var17 = this.thisEvent1;
- this.thisEvent1 = null;
- super.postEvent(var17);
- }
-
- this.drawnPressed = var3;
- }
-
- public Dimension preferredSize() {
- return this.minimumSize();
- }
-
- public void layout() {
- ((Component)this).repaint();
- }
-
- int StringWidth(String var1) {
- if (this.iconImages == null) {
- this.iconImages = ((Component)this).createImage(20, 20);
- if (this.iconImages == null) {
- return 0;
- }
- }
-
- if (this.field_2 == null) {
- this.field_2 = this.iconImages.getGraphics();
- if (this.field_2 == null) {
- return 0;
- }
-
- this.field_2.setFont(((Component)this).getFont());
- }
-
- if (var1 != null && var1.length() != 0) {
- if (this.field_2.getFont() != this.lastFont) {
- this.getWidths();
- this.lastFont = this.field_2.getFont();
- }
-
- return this.field_3 != null ? this.field_3.stringWidth(var1) : 0;
- } else {
- return 0;
- }
- }
-
- public boolean isIconOnly() {
- return this.iconOnly;
- }
-
- public static int getIconValue(String var0) {
- for(int var1 = 0; var1 < iconNames.length; ++var1) {
- if (var0.equals(iconNames[var1])) {
- return var1 - 1;
- }
- }
-
- return -1;
- }
-
- public void setPressed(boolean var1) {
- this.buttonPressed = var1;
- ((Component)this).repaint();
- }
-
- public void setIconImagePath(String var1) {
- this.setIconImagePath(user, var1);
- }
-
- public String getIconImagePath() {
- return this.thisImageLoc;
- }
-
- public void setIconImagePath(JDPUser var1, String var2) {
- if (this.imageLoader == null) {
- this.thisImageLoc = var2;
- this.imageLoader = new JDPImageLoader(var1, this, var2);
- (new Thread(this.imageLoader)).start();
- }
-
- }
-
- public void paint(Graphics var1) {
- this.update(var1);
- }
-
- public int getIcon() {
- return this.buttonIcon;
- }
-
- public void setIcon(int var1) {
- this.buttonIcon = var1;
- ((Component)this).repaint();
- }
-
- public void setIcon(String var1) {
- this.buttonIcon = -1;
- if (var1 != null) {
- for(int var2 = 0; var2 < iconNames.length; ++var2) {
- if (var1.equals(iconNames[var2])) {
- this.buttonIcon = var2 - 1;
- }
- }
- }
-
- ((Component)this).repaint();
- }
-
- void drawIcon(int var1, int var2, int var3) {
- if (this.iconImage == null) {
- this.iconImage = defaultIconImage;
- }
-
- if (this.iconImage != null) {
- if (this.iconImages == null) {
- this.iconImages = ((Component)this).createImage(20, 20);
- }
-
- byte var4 = 0;
- if (!((Component)this).isEnabled()) {
- var4 = 1;
- }
-
- this.grI = this.iconImages.getGraphics();
- this.grI.setColor(this.back);
- this.grI.fillRect(0, 0, this.Bounds.width, this.Bounds.height);
- this.grI.drawImage(this.iconImage, -var1 * 20, -20 * var4, (ImageObserver)null);
- this.field_2.drawImage(this.iconImages, var2, var3, (ImageObserver)null);
- }
-
- }
-
- public Dimension minimumSize() {
- int var1 = 22;
- if (this.StringHeight() > var1) {
- var1 = this.StringHeight();
- }
-
- int var2 = 21;
- if (this.totalWidth() > var2) {
- var2 = this.totalWidth();
- }
-
- Dimension var3 = new Dimension(var2, var1);
- if (this.arrowDirection >= 0) {
- var3 = new Dimension(12, 12);
- }
-
- if (this.arrowDirection >= 3) {
- var3 = new Dimension(9, 9);
- }
-
- if (this.arrowDirection == 5) {
- var3 = new Dimension(15, 9);
- }
-
- if (!((Component)this).isVisible()) {
- var3 = new Dimension(0, 0);
- }
-
- return var3;
- }
-
- public static String[] getButtonIconList() {
- return iconNames;
- }
-
- void checkIconsLoaded() {
- if (defaultIconImage == null) {
- String var1 = "JDPBUTNS.gif";
- int var2 = JDPUtils.getNumColors();
- if (System.getProperty("java.vendor").startsWith("Microsoft") && var2 <= 8) {
- var1 = "JDPBUTN1.gif";
- }
-
- this.setIconImagePath("Images/" + var1);
- }
-
- }
-
- public void setIconOnly(boolean var1) {
- if (this.iconOnly != var1) {
- if (var1) {
- this.drawButton((String)null, this.buttonIcon, this.alignment, this.returnValue, -1);
- } else {
- this.drawButton(this.returnValue, this.buttonIcon, this.alignment, this.returnValue, -1);
- }
- }
- }
-
- private void drawButton(String var1, int var2, int var3, String var4, int var5) {
- activated = JDPUser.classactivated;
- if (!activated) {
- System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
- } else {
- this.iconImage = defaultIconImage;
- this.Button = new Button();
- this.buttonText = var1;
- this.buttonIcon = var2;
- this.alignment = var3;
- this.returnValue = var4;
- this.arrowDirection = var5;
- this.iconOnly = false;
- if (var1 == null) {
- this.iconOnly = true;
- }
-
- ((Component)this).show();
- ((Component)this).repaint();
- }
- }
-
- public void setStayOn(boolean var1) {
- this.stayOn = var1;
- }
-
- public boolean getStayOn() {
- return this.stayOn;
- }
-
- int StringHeight() {
- if (this.field_2 == null) {
- return 0;
- } else {
- if (this.field_2.getFont() != this.lastFont) {
- this.getWidths();
- this.lastFont = this.field_2.getFont();
- }
-
- return this.field_3.getHeight();
- }
- }
-
- public int getAlignment() {
- return this.alignment;
- }
-
- public void setAlignment(int var1) {
- if (this.alignment != var1) {
- this.alignment = var1;
- ((Component)this).repaint();
- }
- }
-
- public static int getAlignmentValue(String var0) {
- for(int var1 = 0; var1 < alignmentValues.length; ++var1) {
- if (var0.equals(alignmentValues[var1])) {
- return var1;
- }
- }
-
- return -1;
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 202:
- case 205:
- if (this.buttonPressed) {
- if (!this.stayOn) {
- this.buttonPressed = false;
- }
-
- ((Component)this).repaint();
- return true;
- }
-
- return false;
- case 401:
- if (var1.key == 10) {
- this.thisEvent = new Event(this.Button, var1.when, 1001, var1.x, var1.y, var1.key, var1.modifiers, this.returnValue);
- this.thisEvent.target = this.Button;
- this.thisEvent1 = new Event(this, var1.when, 1001, var1.x, var1.y, var1.key, var1.modifiers, this.returnValue);
- ((Component)this).repaint();
- return true;
- }
-
- return false;
- case 501:
- case 506:
- if (this.buttonRect != null && this.buttonRect.inside(var1.x, var1.y)) {
- if (!((Component)this).isEnabled()) {
- return true;
- }
-
- this.buttonPressed = true;
- ((Component)this).requestFocus();
- ((Component)this).repaint();
- return true;
- } else {
- if (this.buttonPressed) {
- if (!this.stayOn) {
- this.buttonPressed = false;
- }
-
- ((Component)this).repaint();
- return true;
- }
-
- return false;
- }
- case 502:
- if (this.buttonRect != null && this.buttonRect.inside(var1.x, var1.y)) {
- if (!((Component)this).isEnabled()) {
- return true;
- }
-
- if (this.buttonPressed) {
- this.thisEvent = new Event(this.Button, var1.when, 1001, var1.x, var1.y, var1.key, var1.modifiers, this.returnValue);
- this.thisEvent.target = this.Button;
- this.thisEvent1 = new Event(this, var1.when, 1001, var1.x, var1.y, var1.key, var1.modifiers, this.returnValue);
- this.update(((Component)this).getGraphics());
- return true;
- }
- }
-
- return false;
- case 505:
- if (!((Component)this).isEnabled()) {
- return true;
- } else {
- if (this.buttonPressed) {
- if (!this.stayOn) {
- this.buttonPressed = false;
- }
-
- ((Component)this).repaint();
- return true;
- }
-
- return false;
- }
- case 1004:
- return false;
- case 1005:
- if (this.buttonPressed) {
- if (!this.stayOn) {
- this.buttonPressed = false;
- }
-
- ((Component)this).repaint();
- return true;
- }
-
- return false;
- default:
- if (var1.target.equals(this) && !this.stayOn) {
- this.buttonPressed = false;
- }
-
- return false;
- }
- }
-
- public String getLabel() {
- return this.buttonText;
- }
-
- public void setLabel(String var1) {
- this.returnValue = var1;
- if (!this.iconOnly) {
- this.buttonText = var1;
- }
-
- ((Component)this).repaint();
- }
- }
-