home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- 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.Panel;
- import java.awt.Rectangle;
- import java.awt.image.ImageObserver;
-
- public class JDPCustomPopup extends Panel {
- Image offscreen;
- Rectangle offscreensize;
- // $FF: renamed from: gr java.awt.Graphics
- Graphics field_0;
- Container target;
- boolean borderOn;
- Rectangle Bounds;
- // $FF: renamed from: fm java.awt.FontMetrics
- protected FontMetrics field_1;
- int[] boldWidths;
- Font thisFont;
- Font lastFont;
- int prevFontHeight;
-
- public void paint(Graphics var1) {
- this.update(var1);
- }
-
- public void setBorder(boolean var1) {
- this.borderOn = var1;
- ((Component)this).repaint();
- }
-
- public boolean getBorder() {
- return this.borderOn;
- }
-
- public Dimension minimumSize() {
- Dimension var1 = new Dimension(100, 100);
- this.StringWidth(" ");
- if (this.field_1 == null && ((Component)this).getParent() != null) {
- this.field_1 = ((Component)this).getParent().getGraphics().getFontMetrics();
- this.lastFont = ((Component)this).getParent().getGraphics().getFont();
- this.boldWidths = this.field_1.getWidths();
- }
-
- if (this.field_1 != null) {
- this.field_1 = ((Component)this).getParent().getGraphics().getFontMetrics();
- int var2 = this.field_1.getHeight();
- int var3 = this.StringWidth("2");
- var1 = new Dimension(var3 * 20, (int)((double)var2 * (double)8.5F));
- }
-
- return var1;
- }
-
- public void update(Graphics var1) {
- Rectangle var2 = ((Component)this).bounds();
- if (var2.width != 0 && var2.height != 0) {
- if (this.offscreen == null || var2.width != this.offscreensize.width || var2.height != this.offscreensize.height) {
- if (var2.width < 6) {
- var2.width = 6;
- }
-
- if (var2.height < 6) {
- var2.height = 6;
- }
-
- 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.field_0.setColor(((Component)this).getBackground());
- this.field_0.fillRect(0, 0, var2.width, var2.height);
- this.field_0.setColor(((Component)this).getForeground());
- this.field_0.setFont(((Component)this).getFont());
- this.StringWidth("");
- int var3 = 0;
- if (this.field_1 != null) {
- var3 = this.field_1.getHeight();
- if (var3 != this.prevFontHeight && this.prevFontHeight != 0 || var3 != ((Component)this).bounds().height) {
- this.prevFontHeight = var3;
- if (this.target == null) {
- this.target = ((Component)this).getParent();
- }
-
- this.target.layout();
- this.target.paintAll(this.target.getGraphics());
- }
-
- this.prevFontHeight = var3;
- }
-
- this.Bounds = ((Component)this).bounds();
- if (this.borderOn) {
- this.field_0.setColor(JDPUtils.brighter(((Component)this).getBackground()));
- this.field_0.drawLine(0, 0, this.Bounds.width - 1, 0);
- this.field_0.drawLine(0, 0, 0, this.Bounds.height - 1);
- this.field_0.setColor(JDPUtils.darker(((Component)this).getBackground()));
- this.field_0.drawLine(0, this.Bounds.height - 1, 0, this.Bounds.height - 1);
- this.field_0.drawLine(this.Bounds.width - 1, 0, this.Bounds.width - 1, 0);
- this.field_0.drawLine(1, this.Bounds.height - 2, this.Bounds.width - 2, this.Bounds.height - 2);
- this.field_0.drawLine(this.Bounds.width - 2, 1, this.Bounds.width - 2, this.Bounds.height - 2);
- this.field_0.setColor(Color.black);
- this.field_0.drawLine(1, this.Bounds.height - 1, this.Bounds.width - 1, this.Bounds.height - 1);
- this.field_0.drawLine(this.Bounds.width - 1, 1, this.Bounds.width - 1, this.Bounds.height - 1);
- }
-
- var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
- }
- }
-
- public Dimension preferredSize() {
- return this.minimumSize();
- }
-
- public JDPCustomPopup() {
- if (!JDPButton.activated) {
- System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
- } else {
- this.PanelMain();
- }
- }
-
- void PanelMain() {
- ((Container)this).setLayout(new BorderLayout());
- }
-
- public void layout() {
- ((Component)this).repaint();
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 202:
- ((Component)this).repaint();
- return false;
- case 502:
- Event var2 = new Event(this, var1.when, 1001, var1.x, var1.y, var1.key, var1.modifiers, "");
- super.postEvent(var2);
- return true;
- case 1001:
- return false;
- case 1005:
- return false;
- default:
- return false;
- }
- }
-
- int StringWidth(String var1) {
- if (this.field_0 != null && (this.field_1 == null || this.lastFont == null || this.field_0 != null && !this.field_0.getFont().equals(this.lastFont))) {
- this.field_1 = this.field_0.getFontMetrics();
- this.lastFont = this.field_0.getFont();
- this.boldWidths = this.field_1.getWidths();
- }
-
- return this.field_1 != null ? this.field_1.stringWidth(var1) : 0;
- }
- }
-