From 057a304d7998e49908b21d9eb0b7b81db84d055d Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Thu, 11 May 2006 12:02:09 +0000 Subject: [PATCH] Scrollbar thumb handle image added. --- .../gui/lookandfeel/SIPCommDefaultTheme.java | 15 +++--- .../gui/lookandfeel/SIPCommScrollBarUI.java | 51 +++++++++++++++---- .../impl/gui/utils/ImageLoader.java | 10 +++- .../impl/gui/utils/images.properties | 4 +- 4 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommDefaultTheme.java b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommDefaultTheme.java index 46f4c62da..42f840468 100644 --- a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommDefaultTheme.java +++ b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommDefaultTheme.java @@ -85,8 +85,6 @@ public void addCustomEntriesToTable(UIDefaults table) { "RadioButton.rollover", Boolean.TRUE, "RadioButtonMenuItem.gradient", buttonGradient, - - "ScrollBar.width", new Integer(12), "Slider.altTrackColor", new ColorUIResource(0xD2E2EF), "Slider.gradient", sliderGradient, @@ -95,15 +93,20 @@ public void addCustomEntriesToTable(UIDefaults table) { "SplitPane.oneTouchButtonsOpaque", Boolean.FALSE, "SplitPane.dividerFocusColor", LIGHT_BLUE_GRAY, "SplitPane.dividerSize", new Integer(5), - + + "ScrollBar.width", new Integer(12), "ScrollBar.horizontalThumbIcon", - ImageLoader.getImage(ImageLoader.SCROLLBAR_HORIZONTAL), + ImageLoader.getImage(ImageLoader.SCROLLBAR_THUMB_HORIZONTAL), "ScrollBar.verticalThumbIcon", - ImageLoader.getImage(ImageLoader.SCROLLBAR_VERTICAL), + ImageLoader.getImage(ImageLoader.SCROLLBAR_THUMB_VERTICAL), + "ScrollBar.horizontalThumbHandleIcon", + ImageLoader.getImage(ImageLoader.SCROLLBAR_THUMB_HANDLE_HORIZONTAL), + "ScrollBar.verticalThumbHandleIcon", + ImageLoader.getImage(ImageLoader.SCROLLBAR_THUMB_HANDLE_VERTICAL), "ScrollBar.trackHighlight", GRAY, "ScrollBar.highlight", LIGHT_GRAY, "ScrollBar.darkShadow", GRAY, - + "TabbedPane.borderHightlightColor", LIGHT_BLUE, "TabbedPane.contentBorderInsets", new Insets(2, 2, 3, 3), "TabbedPane.selected", LIGHT_GRAY, diff --git a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommScrollBarUI.java b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommScrollBarUI.java index 01aebecd8..379272fdc 100644 --- a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommScrollBarUI.java +++ b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommScrollBarUI.java @@ -6,6 +6,7 @@ */ package net.java.sip.communicator.impl.gui.lookandfeel; +import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; import java.awt.Rectangle; @@ -26,10 +27,18 @@ public class SIPCommScrollBarUI extends MetalScrollBarUI { private BufferedImage horizontalThumb; private BufferedImage verticalThumb; - + private BufferedImage horizontalThumbHandle; + private BufferedImage verticalThumbHandle; + public SIPCommScrollBarUI(){ - horizontalThumb = (BufferedImage)UIManager.get("ScrollBar.horizontalThumbIcon"); - verticalThumb = (BufferedImage)UIManager.get("ScrollBar.verticalThumbIcon"); + horizontalThumb = (BufferedImage)UIManager + .get("ScrollBar.horizontalThumbIcon"); + verticalThumb = (BufferedImage)UIManager + .get("ScrollBar.verticalThumbIcon"); + horizontalThumbHandle = (BufferedImage)UIManager + .get("ScrollBar.horizontalThumbHandleIcon"); + verticalThumbHandle = (BufferedImage)UIManager + .get("ScrollBar.verticalThumbHandleIcon"); } // ******************************** @@ -103,9 +112,9 @@ protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) int imgHeight; int indentWidth = 10; - if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) + if(scrollbar.getOrientation() == JScrollBar.VERTICAL) { - if ( !isFreeStanding ) { + if(!isFreeStanding) { thumbBounds.width += 2; if ( !leftToRight ) { @@ -137,16 +146,23 @@ protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) g.drawImage(bottomImage, thumbBounds.x, thumbBounds.height-indentWidth, thumbBounds.width-2, indentWidth, null); - if ( !isFreeStanding ) { + + g.drawImage(verticalThumbHandle, + thumbBounds.width/2-verticalThumbHandle.getWidth()/2, + thumbBounds.height/2-verticalThumbHandle.getHeight()/2, + verticalThumbHandle.getWidth(), + verticalThumbHandle.getHeight(), null); + + if (!isFreeStanding) { thumbBounds.width -= 2; - if ( !leftToRight ) { + if(!leftToRight) { g.translate( 1, 0 ); } } } else // HORIZONTAL { - if ( !isFreeStanding ) { + if (!isFreeStanding) { thumbBounds.height += 2; } imgWidth = horizontalThumb.getWidth(); @@ -173,10 +189,25 @@ protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) g.drawImage(rightImage, thumbBounds.width-indentWidth, thumbBounds.y, indentWidth, thumbBounds.height, null); - if ( !isFreeStanding ) { + g.drawImage(horizontalThumbHandle, + thumbBounds.width/2-horizontalThumbHandle.getWidth()/2, + thumbBounds.height/2-horizontalThumbHandle.getHeight()/2, + horizontalThumbHandle.getWidth(), + horizontalThumbHandle.getHeight(), null); + + if (!isFreeStanding) { thumbBounds.height -= 2; } } - g.translate( -thumbBounds.x, -thumbBounds.y ); + g.translate(-thumbBounds.x, -thumbBounds.y); } + + protected Dimension getMinimumThumbSize() + { + if(scrollbar.getOrientation() == JScrollBar.VERTICAL) + return new Dimension(scrollBarWidth, verticalThumbHandle.getHeight()+4); + else + return new Dimension(horizontalThumbHandle.getWidth()+4, scrollBarWidth); + } + } 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 a0e535d39..5679c6152 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -43,12 +43,18 @@ public class ImageLoader { public static final ImageID SPLITPANE_VERTICAL = new ImageID("SPLITPANE_VERTICAL"); - public static final ImageID SCROLLBAR_VERTICAL + public static final ImageID SCROLLBAR_THUMB_VERTICAL = new ImageID("SCROLLBAR_VERTICAL"); - public static final ImageID SCROLLBAR_HORIZONTAL + public static final ImageID SCROLLBAR_THUMB_HORIZONTAL = new ImageID("SCROLLBAR_HORIZONTAL"); + public static final ImageID SCROLLBAR_THUMB_HANDLE_HORIZONTAL + = new ImageID("SCROLLBAR_THUMB_HORIZONTAL"); + + public static final ImageID SCROLLBAR_THUMB_HANDLE_VERTICAL + = new ImageID("SCROLLBAR_THUMB_VERTICAL"); + /*------------------------------------------------------------------------ * ============================APPLICATION ICONS ========================= * ----------------------------------------------------------------------- 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 b77a2aef5..9dbb0aaf1 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/images.properties +++ b/src/net/java/sip/communicator/impl/gui/utils/images.properties @@ -150,4 +150,6 @@ SPLITPANE_HORIZONTAL=net/java/sip/communicator/impl/gui/resources/lookandfeel/sp SPLITPANE_VERTICAL=net/java/sip/communicator/impl/gui/resources/lookandfeel/splitpaneVertical.png SCROLLBAR_HORIZONTAL=net/java/sip/communicator/impl/gui/resources/lookandfeel/scrollbar_horiz2.png -SCROLLBAR_VERTICAL=net/java/sip/communicator/impl/gui/resources/lookandfeel/scrollbar_vert1.png \ No newline at end of file +SCROLLBAR_VERTICAL=net/java/sip/communicator/impl/gui/resources/lookandfeel/scrollbar_vert1.png +SCROLLBAR_THUMB_HORIZONTAL=net/java/sip/communicator/impl/gui/resources/lookandfeel/horizThumbHandle.png +SCROLLBAR_THUMB_VERTICAL=net/java/sip/communicator/impl/gui/resources/lookandfeel/vertThumbHandle.png