home *** CD-ROM | disk | FTP | other *** search
- package allaire.controls;
-
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.image.ImageObserver;
-
- class CFGRIDActionButton extends Canvas {
- int edge = 6;
- String action;
- boolean pressed;
- boolean buffered;
- Image actionimage;
- Image bufferimage;
- MediaTracker tracker;
- int width;
- int height;
-
- public boolean mouseExit(Event var1, int var2, int var3) {
- if (this.pressed) {
- this.pressed = false;
- ((Component)this).repaint();
- }
-
- return false;
- }
-
- public void paint(Graphics var1) {
- if (!this.buffered) {
- this.bufferimage = ((Component)this).createImage(this.width, this.height);
- Graphics var2 = this.bufferimage.getGraphics();
- var2.drawImage(this.actionimage, 0, 0, (ImageObserver)null);
- var2.dispose();
- this.buffered = true;
- }
-
- int var4 = this.pressed ? this.edge : 3;
- var1.drawImage(this.bufferimage, var4, var4, this.width, this.height, (ImageObserver)null);
- Dimension var3 = ((Component)this).size();
- if (this.pressed) {
- var1.drawLine(0, 0, var3.width - 1, 0);
- var1.drawLine(0, 0, 0, var3.height - 1);
- var1.setColor(Color.gray);
- var1.drawLine(1, 1, var3.width - 1, 1);
- var1.drawLine(1, 1, 1, var3.height - 1);
- var1.setColor(Color.white);
- var1.drawLine(var3.width - 1, 0, var3.width - 1, var3.height - 1);
- var1.drawLine(0, var3.height - 1, var3.width - 1, var3.height - 1);
- } else {
- var1.drawLine(var3.width - 1, 0, var3.width - 1, var3.height - 1);
- var1.drawLine(0, var3.height - 1, var3.width - 1, var3.height - 1);
- var1.setColor(Color.gray);
- var1.drawLine(var3.width - 2, 0, var3.width - 2, var3.height - 2);
- var1.drawLine(0, var3.height - 2, var3.width - 2, var3.height - 2);
- var1.setColor(Color.white);
- var1.drawLine(0, 0, var3.width - 1, 0);
- var1.drawLine(0, 0, 0, var3.height - 1);
- }
-
- var1.setColor(Color.black);
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- if (this.pressed) {
- this.pressed = false;
- ((Component)this).repaint();
- Event var4 = new Event(this, 1001, this.action);
- ((Component)this).getParent().postEvent(var4);
- return true;
- } else {
- return false;
- }
- }
-
- CFGRIDActionButton(String var1, Image var2) {
- this.actionimage = var2;
- this.action = var1;
- ((Component)this).setBackground(Color.lightGray);
- this.tracker = new MediaTracker(this);
- this.tracker.addImage(this.actionimage, 0);
-
- try {
- this.tracker.waitForID(0);
- this.width = this.actionimage.getWidth((ImageObserver)null);
- this.height = this.actionimage.getHeight((ImageObserver)null);
- } catch (InterruptedException var3) {
- }
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- this.pressed = true;
- ((Component)this).repaint();
- return true;
- }
- }
-