home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- 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.Rectangle;
- import java.awt.image.ImageObserver;
- import java.util.Vector;
-
- public class JDPPopupMessage extends Panel {
- JDPUser user;
- Container targetPanel;
- Image offscreen;
- Rectangle offscreensize;
- // $FF: renamed from: gr java.awt.Graphics
- Graphics field_0;
- Panel parent;
- Rectangle Bounds;
- int[] widths;
- Font lastFont;
- // $FF: renamed from: fm java.awt.FontMetrics
- FontMetrics field_1;
- int maxXwidth;
- Vector activeAreas;
- String prevMessage;
- String prevStatusBarMessage;
- String popupMessage;
- String statusBarMessage;
- boolean firstClear = true;
-
- void createPopup(JDPUser var1, Container var2) {
- this.user = var1;
- this.targetPanel = var2;
- ((Component)this).setFont(var1.plainFont);
- ((Container)this).setLayout((LayoutManager)null);
- if (!JDPUser.classactivated) {
- System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
- } else {
- this.removeAllComponents();
- ((Component)this).hide();
- this.offscreen = ((Component)this).createImage(10, 10);
- }
- }
-
- public void setTarget(Container var1) {
- this.targetPanel = var1;
- }
-
- public void addComponent(Component var1, String var2, String var3) {
- Vector var4 = new Vector();
- var4.addElement(var1);
- var4.addElement(var2);
- var4.addElement(var3);
- this.activeAreas.addElement(var4);
- }
-
- public void paint(Graphics var1) {
- this.update(var1);
- }
-
- int[] getWidths() {
- this.field_1 = this.field_0.getFontMetrics();
- this.widths = this.field_1.getWidths();
- return this.widths;
- }
-
- public JDPPopupMessage(JDPUser var1, Panel var2) {
- this.createPopup(var1, (Container)var2);
- }
-
- public JDPPopupMessage(JDPUser var1, Container var2) {
- this.createPopup(var1, var2);
- }
-
- public void update(Graphics var1) {
- Rectangle var2 = ((Component)this).bounds();
- if (this.offscreen == null || var2.width != this.offscreensize.width || var2.height != this.offscreensize.height) {
- this.offscreen = ((Component)this).createImage(var2.width, var2.height);
- this.offscreensize = var2;
- this.field_0 = this.offscreen.getGraphics();
- this.field_0.setFont(((Component)this).getFont());
- }
-
- this.Bounds = ((Component)this).bounds();
- this.field_0.setColor(Color.white);
- this.field_0.fillRect(0, 0, this.Bounds.width, this.Bounds.height);
- this.field_0.setColor(Color.black);
- this.field_0.drawRect(0, 0, this.Bounds.width - 1, this.Bounds.height - 1);
- this.field_0.drawString(this.popupMessage, 3, this.StringHeight() - 1);
- var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
- this.firstClear = true;
- }
-
- int StringHeight() {
- if (this.field_0 == null) {
- return 0;
- } else {
- if (this.field_0.getFont() != this.lastFont) {
- this.getWidths();
- this.lastFont = this.field_0.getFont();
- }
-
- return this.field_1.getHeight();
- }
- }
-
- public void removeAllComponents() {
- this.activeAreas = null;
- this.activeAreas = new Vector();
- }
-
- public void removeComponent(Component var1) {
- for(int var2 = 0; var2 < this.activeAreas.size(); ++var2) {
- Vector var3 = (Vector)this.activeAreas.elementAt(var2);
- if (var1.equals((Component)var3.elementAt(0))) {
- this.activeAreas.removeElementAt(var2);
- return;
- }
- }
-
- }
-
- void display(int var1, int var2) {
- this.position(var1, var2);
- ((Component)this).repaint();
- ((Component)this).enable();
- this.user.mainmsg.setStatusMsg(this.statusBarMessage, 500, 5, this);
- this.prevMessage = this.popupMessage;
- this.prevStatusBarMessage = this.statusBarMessage;
- }
-
- public void layout() {
- ((Component)this).repaint();
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 501:
- case 502:
- case 506:
- if (((Component)this).isEnabled()) {
- ((Component)this).hide();
- this.user.mainmsg.clearPopupMsg();
- }
-
- return false;
- case 503:
- case 504:
- case 505:
- if (!var1.target.equals(this) && this.targetPanel != null && this.activeAreas != null && this.activeAreas.size() > 0) {
- for(int var2 = 0; var2 < this.activeAreas.size(); ++var2) {
- Vector var3 = (Vector)this.activeAreas.elementAt(var2);
- Component var4 = (Component)var3.elementAt(0);
- if (var4 != null && var4.isVisible() && var4.isShowing()) {
- Rectangle var5 = var4.bounds();
- Container var6 = var4.getParent();
- if (var6 != null && ((Component)var6).isVisible() && ((Component)var6).isShowing()) {
- Rectangle var7 = ((Component)var6).bounds();
-
- while(var6 != null && !var6.equals(this.targetPanel)) {
- var7 = ((Component)var6).bounds();
- var5.x += var7.x;
- var5.y += var7.y;
- var6 = ((Component)var6).getParent();
- if (var6 == null || !((Component)var6).isVisible()) {
- var5.x += 2000;
- }
- }
-
- var5.x -= var7.x;
- var5.y -= var7.y;
- if (var5.inside(var1.x, var1.y)) {
- var1.x += var7.x;
- var1.y += var7.y;
- this.popupMessage = (String)var3.elementAt(1);
- this.statusBarMessage = (String)var3.elementAt(2);
- if (((Component)this).isEnabled() && !((Component)this).isVisible()) {
- if (this.popupMessage.equals(this.prevMessage) && this.statusBarMessage.equals(this.prevStatusBarMessage)) {
- this.user.mainmsg.waitMore(1000);
- this.position(var1.x, var1.y);
- } else {
- this.display(var1.x, var1.y);
- }
- } else if (((Component)this).isEnabled() && ((Component)this).isVisible()) {
- if (!this.firstClear) {
- this.user.mainmsg.clearPopupMsg();
- }
-
- this.firstClear = false;
- } else if (!((Component)this).isEnabled()) {
- this.display(var1.x, var1.y);
- } else if (!this.popupMessage.equals(this.prevMessage) || !this.statusBarMessage.equals(this.prevStatusBarMessage)) {
- this.user.mainmsg.clearInfoMsg();
- this.display(var1.x, var1.y);
- this.firstClear = true;
- }
-
- return true;
- }
- }
- }
- }
- }
-
- if (((Component)this).isEnabled()) {
- this.user.mainmsg.clearPopupMsg();
- ((Component)this).hide();
- ((Component)this).disable();
- return true;
- } else {
- return true;
- }
- default:
- return false;
- }
- }
-
- void position(int var1, int var2) {
- var2 += 26;
- var1 += 10;
- if (this.offscreen == null) {
- Rectangle var3 = ((Component)this).bounds();
- this.offscreen = ((Component)this).createImage(10, 10);
- this.offscreensize = var3;
- if (this.offscreen == null) {
- return;
- }
-
- this.field_0 = this.offscreen.getGraphics();
- this.field_0.setFont(((Component)this).getFont());
- }
-
- this.parent = (Panel)((Component)this).getParent();
- this.maxXwidth = this.user.u.StringWidth(this.field_0, this.popupMessage);
- int var8 = this.StringHeight();
- if (this.parent != null) {
- Rectangle var4 = this.parent.bounds();
-
- for(int var5 = var1 - 10 + this.maxXwidth + 20; var5 > var4.width; var5 = var1 - 10 + this.maxXwidth + 20) {
- var1 -= 5;
- }
-
- if (var2 + var8 + 6 > var4.height) {
- var2 = var2 - 32 - var8;
- }
- }
-
- if (var1 < 10) {
- var1 = 10;
- }
-
- if (var2 < 10) {
- var2 = 10;
- }
-
- ((Component)this).reshape(var1, var2, this.maxXwidth + 5, var8 + 4);
- }
- }
-