diff --git a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommToggleButtonUI.java b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommToggleButtonUI.java index 541b88b50..e85eb1435 100644 --- a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommToggleButtonUI.java +++ b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommToggleButtonUI.java @@ -7,15 +7,23 @@ package net.java.sip.communicator.impl.gui.lookandfeel; import java.awt.*; +import java.awt.image.*; import javax.swing.*; import javax.swing.plaf.*; -import javax.swing.plaf.metal.*; +import javax.swing.plaf.basic.*; + +import net.java.sip.communicator.impl.gui.utils.*; public class SIPCommToggleButtonUI - extends MetalToggleButtonUI + extends BasicToggleButtonUI { - + private final static BufferedImage buttonBG + = ImageLoader.getImage(ImageLoader.BUTTON); + + private final static BufferedImage buttonPressedBG + = ImageLoader.getImage(ImageLoader.TOGGLE_BUTTON_PRESSED); + // ******************************** // Create PLAF // ******************************** @@ -31,8 +39,7 @@ public void installDefaults(AbstractButton b) { b.setOpaque(false); b.setBorderPainted(false); - b.setFocusPainted(true); - b.setRolloverEnabled(true); + b.setFocusPainted(true); } public void uninstallDefaults(AbstractButton b) { @@ -40,52 +47,49 @@ public void uninstallDefaults(AbstractButton b) { b.setBorderPainted(true); b.setFocusPainted(false); - b.setOpaque(true); - b.setRolloverEnabled(false); + b.setOpaque(true); } - protected void paintFocus(Graphics g, AbstractButton b, - Rectangle viewRect, Rectangle textRect, Rectangle iconRect){ + public void paint(Graphics g, JComponent c) + { + AntialiasingManager.activateAntialiasing(g); - Graphics2D g2 = (Graphics2D)g; + AbstractButton button = (AbstractButton)c; + ButtonModel model = button.getModel(); - Rectangle focusRect = new Rectangle(); - String text = b.getText(); - boolean isIcon = b.getIcon() != null; + BufferedImage leftImg; + BufferedImage middleImg; + BufferedImage rightImg; - // If there is text - if ( text != null && !text.equals( "" ) ) { - if ( !isIcon ) { - focusRect.setBounds( textRect ); - } - else { - focusRect.setBounds( iconRect.union( textRect ) ); - } - } - // If there is an icon and no text - else if ( isIcon ) { - focusRect.setBounds( iconRect ); + int imgWidth; + int imgHeight; + int indentWidth = 10; + + if (model.isArmed() && model.isPressed() || model.isSelected()) + { + imgWidth = buttonPressedBG.getWidth(); + imgHeight = buttonPressedBG.getHeight(); + + leftImg = buttonPressedBG.getSubimage(0, 0, 10, imgHeight); + middleImg = buttonPressedBG.getSubimage(10, 0, imgWidth-20, imgHeight); + rightImg = buttonPressedBG.getSubimage(imgWidth-10, 0, 10, imgHeight); } - - g2.setStroke(new BasicStroke(0.5f,// Width - BasicStroke.CAP_ROUND, // End cap - BasicStroke.JOIN_ROUND, // Join style - 10.0f, // Miter limit - new float[] {1.0f,1.0f},// Dash pattern - 2.0f)); - g2.setColor(Color.GRAY); - g2.drawRoundRect((focusRect.x-3), (focusRect.y-3), - focusRect.width+4, focusRect.height+4, 5, 5); - } - - /** - * Overriden to draw a round rectangle. - */ - protected void paintButtonPressed(Graphics g, AbstractButton b){ - if ( b.isContentAreaFilled() ) { - Dimension size = b.getSize(); - g.setColor(getSelectColor()); - g.fillRoundRect(0, 0, size.width, size.height, 5, 5); + else + { + imgWidth = buttonBG.getWidth(); + imgHeight = buttonBG.getHeight(); + + leftImg = buttonBG.getSubimage(0, 0, 10, imgHeight); + middleImg = buttonBG.getSubimage(10, 0, imgWidth-20, imgHeight); + rightImg = buttonBG.getSubimage(imgWidth-10, 0, 10, imgHeight); } - } + + g.drawImage(leftImg, 0, 0, indentWidth, c.getHeight(), null); + g.drawImage(middleImg, indentWidth, 0, + c.getWidth()-2*indentWidth, c.getHeight(), null); + g.drawImage(rightImg, c.getWidth()-indentWidth, 0, + indentWidth, c.getHeight(), null); + + super.paint(g, c); + } } diff --git a/src/net/java/sip/communicator/impl/gui/resources/lookandfeel/button3.png b/src/net/java/sip/communicator/impl/gui/resources/lookandfeel/button3.png new file mode 100644 index 000000000..f31ceafb3 Binary files /dev/null and b/src/net/java/sip/communicator/impl/gui/resources/lookandfeel/button3.png differ diff --git a/src/net/java/sip/communicator/impl/gui/resources/lookandfeel/button4.png b/src/net/java/sip/communicator/impl/gui/resources/lookandfeel/button4.png new file mode 100644 index 000000000..80a1fe983 Binary files /dev/null and b/src/net/java/sip/communicator/impl/gui/resources/lookandfeel/button4.png differ diff --git a/src/net/java/sip/communicator/impl/gui/resources/lookandfeel/src/button.svg b/src/net/java/sip/communicator/impl/gui/resources/lookandfeel/src/button.svg new file mode 100755 index 000000000..10ffcef8f --- /dev/null +++ b/src/net/java/sip/communicator/impl/gui/resources/lookandfeel/src/button.svg @@ -0,0 +1,923 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java index 7fa0cf8bd..977446d17 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -52,6 +52,18 @@ public class ImageLoader { public static final ImageID BUTTON_ROLLOVER = new ImageID("BUTTON_ROLLOVER"); + /** + * The pressed toggle button background image. + */ + public static final ImageID TOGGLE_BUTTON_PRESSED + = new ImageID("TOGGLE_BUTTON_PRESSED"); + + /** + * The toggle button background image. + */ + public static final ImageID TOGGLE_BUTTON + = new ImageID("TOGGLE_BUTTON"); + /** * The image used for a horizontal split. */ diff --git a/src/net/java/sip/communicator/impl/gui/utils/images.properties b/src/net/java/sip/communicator/impl/gui/utils/images.properties index 865209da3..f579b0309 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/images.properties +++ b/src/net/java/sip/communicator/impl/gui/utils/images.properties @@ -167,6 +167,8 @@ CLOSABLE_TAB_BG=net/java/sip/communicator/impl/gui/resources/lookandfeel/closabl BUTTON=net/java/sip/communicator/impl/gui/resources/lookandfeel/button1.png BUTTON_ROLLOVER=net/java/sip/communicator/impl/gui/resources/lookandfeel/button2.png +TOGGLE_BUTTON_PRESSED=net/java/sip/communicator/impl/gui/resources/lookandfeel/button3.png +TOGGLE_BUTTON=net/java/sip/communicator/impl/gui/resources/lookandfeel/button4.png SPLITPANE_HORIZONTAL=net/java/sip/communicator/impl/gui/resources/lookandfeel/splitpaneHorizontal.png SPLITPANE_VERTICAL=net/java/sip/communicator/impl/gui/resources/lookandfeel/splitpaneVertical.png