From b490cf4a10aeb312b3c1e3842181cc74a728d847 Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Wed, 23 Nov 2005 16:09:55 +0000 Subject: [PATCH] Custom controls changed --- .../main/customcontrols/SIPCommButton.java | 82 +++++++++++++------ .../gui/main/customcontrols/StatusIcon.java | 29 ++----- .../customcontrols/StatusSelectorBox.java | 14 +--- 3 files changed, 62 insertions(+), 63 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/customcontrols/SIPCommButton.java b/src/net/java/sip/communicator/impl/gui/main/customcontrols/SIPCommButton.java index 85fcff726..4e59ec1f4 100755 --- a/src/net/java/sip/communicator/impl/gui/main/customcontrols/SIPCommButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/customcontrols/SIPCommButton.java @@ -23,10 +23,8 @@ public class SIPCommButton extends JButton { private Image iconImage; - private int iconRightShift = 0; - - private int iconLeftShift = 0; - + private Image pressedImage; + public SIPCommButton() { super(); @@ -61,7 +59,7 @@ public SIPCommButton(Image iconImage) { this.setIcon(new ImageIcon(this.bgImage)); } - public SIPCommButton(Image bgImage, Image rolloverImage, Image iconImage) { + public SIPCommButton (Image bgImage, Image rolloverImage, Image iconImage) { super(); this.iconImage = iconImage; @@ -74,6 +72,36 @@ public SIPCommButton(Image bgImage, Image rolloverImage, Image iconImage) { this.setIcon(new ImageIcon(this.bgImage)); } + public SIPCommButton ( Image bgImage, + Image rolloverImage, + Image pressedImage, + Image iconImage) { + super(); + + this.iconImage = iconImage; + this.bgImage = bgImage; + this.bgRolloverImage = rolloverImage; + this.pressedImage = pressedImage; + + this.setPreferredSize(new Dimension(this.bgImage.getWidth(null), + this.bgImage.getHeight(null))); + + this.setIcon(new ImageIcon(this.bgImage)); + } + + public SIPCommButton(Image bgImage, Image rolloverImage) { + super(); + + this.bgImage = bgImage; + this.bgRolloverImage = rolloverImage; + + this.setPreferredSize(new Dimension(this.bgImage.getWidth(null), + this.bgImage.getHeight(null))); + + this.setIcon(new ImageIcon(this.bgImage)); + } + + public void paint(Graphics g) { g.drawImage(this.bgImage, 0, 0, this); @@ -82,9 +110,7 @@ public void paint(Graphics g) { g.drawImage(this.iconImage, (this.bgImage.getWidth(null) - - this.iconImage.getWidth(null)) / 2 + - this.iconRightShift - - this.iconLeftShift, + this.iconImage.getWidth(null)) / 2, (this.bgImage.getHeight(null) - this.iconImage.getHeight(null)) / 2, this); } @@ -98,13 +124,31 @@ public void paint(Graphics g) { g.drawImage(this.iconImage, (this.bgImage.getWidth(null) - - this.iconImage.getWidth(null)) / 2 + - this.iconRightShift - - this.iconLeftShift, + this.iconImage.getWidth(null)) / 2, (this.bgImage.getHeight(null) - this.iconImage.getHeight(null)) / 2, this); } } + + if (this.getModel().isPressed()) { + + if(this.pressedImage != null) { + g.drawImage(this.pressedImage, 0, 0, this); + } + else { + g.setColor(LookAndFeelConstants.CONTACTPANEL_LINES_COLOR); + g.drawImage(this.bgRolloverImage, 0, 0, this); + + if (this.iconImage != null) { + + g.drawImage(this.iconImage, + (this.bgImage.getWidth(null) - + this.iconImage.getWidth(null)) / 2 + 1, + (this.bgImage.getHeight(null) - + this.iconImage.getHeight(null)) / 2 + 1, this); + } + } + } } public Image getBgImage () { @@ -130,20 +174,4 @@ public Image getIconImage() { public void setIconImage(Image iconImage) { this.iconImage = iconImage; } - - public void setIconRightShift (int iconRightShift) { - this.iconRightShift = iconRightShift; - } - - public void setIconLeftShift (int iconLeftShift) { - this.iconLeftShift = iconLeftShift; - } - - public int getIconRightShift (int iconRightShift) { - return this.iconRightShift; - } - - public int getIconLeftShift (int iconLeftShift) { - return this.iconLeftShift; - } } diff --git a/src/net/java/sip/communicator/impl/gui/main/customcontrols/StatusIcon.java b/src/net/java/sip/communicator/impl/gui/main/customcontrols/StatusIcon.java index 3e3019423..fd7c8cd91 100644 --- a/src/net/java/sip/communicator/impl/gui/main/customcontrols/StatusIcon.java +++ b/src/net/java/sip/communicator/impl/gui/main/customcontrols/StatusIcon.java @@ -9,33 +9,26 @@ public class StatusIcon extends BufferedImage { private Image bgImage; private Image iconImage; - private int rightShift = 0; - - public StatusIcon (Image bgImage, Image iconImage) { - this (bgImage, iconImage, 0); - } - + public StatusIcon ( Image bgImage, - Image iconImage, - int rightShift) { + Image iconImage) { - super( bgImage.getWidth(null) + rightShift, + super( bgImage.getWidth(null), bgImage.getHeight(null), BufferedImage.TYPE_4BYTE_ABGR); this.bgImage = bgImage; this.iconImage = iconImage; - this.rightShift = rightShift; - + this.getGraphics().drawImage (this.bgImage, 0, 0, null); if (this.iconImage != null){ int x = (this.bgImage.getWidth(null) - - this.iconImage.getWidth(null)) + rightShift; + this.iconImage.getWidth(null)) / 2; int y = (this.bgImage.getHeight(null) - - this.iconImage.getHeight(null)); + this.iconImage.getHeight(null)) / 2; this.getGraphics().drawImage ( this.iconImage, x, @@ -56,14 +49,4 @@ public StatusIcon (Image image) { this.getGraphics().drawImage (this.bgImage, 0, 0, null); } - public StatusIcon (Image image, int rightShift) { - - super( image.getWidth(null) + rightShift, - image.getHeight(null), - BufferedImage.TYPE_4BYTE_ABGR); - - this.bgImage = image; - - this.getGraphics().drawImage (this.bgImage, 0, 0, null); - } } \ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/gui/main/customcontrols/StatusSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/customcontrols/StatusSelectorBox.java index 5a45e2267..eedaa7518 100644 --- a/src/net/java/sip/communicator/impl/gui/main/customcontrols/StatusSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/customcontrols/StatusSelectorBox.java @@ -27,22 +27,10 @@ public class StatusSelectorBox extends SIPCommButton implements ActionListener{ - private SIPCommButton button; - private JPopupMenu popup; private Object[] items; - - private final Image statusSelectorBg = LookAndFeelConstants.STATUS_SELECTOR_BOX; - - private final int width = statusSelectorBg.getWidth(null); - - private final int height = statusSelectorBg.getHeight(null); - - private final int iconX = (this.width - 24) / 2; - - private final int iconY = (this.height - 16) / 2; - + public StatusSelectorBox(Object[] items, Status currentStatus) { super( LookAndFeelConstants.STATUS_SELECTOR_BOX,