tab look changed

cusax-fix
Yana Stamcheva 20 years ago
parent 55a1a98973
commit eb0e794fda

@ -15,16 +15,22 @@
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.geom.GeneralPath;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicGraphicsUtils;
import javax.swing.text.View;
import sun.security.action.GetBooleanAction;
import net.java.sip.communicator.impl.gui.main.utils.AntialiasingManager;
import net.java.sip.communicator.impl.gui.main.utils.Constants;
import net.java.sip.communicator.impl.gui.main.utils.ImageLoader;
/**
* This UI displays a different interface, which is independent from the look
@ -45,6 +51,11 @@ public class CloseTabPaneEnhancedUI extends CloseTabPaneUI {
private static final Color lightWhite = new Color(200, 200, 200, 50);
private static final Color selectedColor = new Color(20, 62, 123);
private static Image TAB_BACKGROUND = ImageLoader.getImage(ImageLoader.TAB_BG);
private static Image CLOSABLE_TAB_BACKGROUND
= ImageLoader.getImage(ImageLoader.CLOSABLE_TAB_BG);
public static ComponentUI createUI(JComponent c) {
return new CloseTabPaneEnhancedUI();
@ -55,34 +66,12 @@ protected void paintFocusIndicator(Graphics g, int tabPlacement,
Rectangle textRect, boolean isSelected) {
}
/**
* Overriden to paint nothing.
*/
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
int x, int y, int w, int h, boolean isSelected) {
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Constants.CONTACTPANEL_LINES_COLOR);
GeneralPath border = new GeneralPath();
border.moveTo(x , y + h - 1);
border.lineTo(x, y + 5);
border.curveTo(x, y + 5, x, y, x + 5, y);
border.lineTo(x + w - 7, y);
border.curveTo(x + w - 7, y, x + w - 2, y, x + w - 2, y + 5);
border.lineTo(x + w - 2, y + h - 1);
/*
border.moveTo(x , y + h - 1);
border.lineTo(x, y + 5);
border.curveTo(x, y + 5, x, y, x + 5, y);
border.lineTo(x + w - 28, y);
border.curveTo(x + w - 28, y,
x + w - 36, (y + h)/2,
x + w - 15, y + h - 2);
*/
g2.draw(border);
}
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
@ -138,79 +127,40 @@ protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
protected void paintTabBackground(Graphics g, int tabPlacement,
int tabIndex, int x, int y, int w, int h, boolean isSelected) {
if (isSelected) {
GradientPaint gradient;
if (tabPane.isEnabledAt(tabIndex)) {
gradient = new GradientPaint(w/2, y, selectedColor,
w/2, h, lightBlue);
} else {
gradient = new GradientPaint(w/2, y, Color.GRAY, w/2, h,
lightWhite);
}
Graphics2D g2 = (Graphics2D) g;
AntialiasingManager.activateAntialiasing(g2);
g2.setPaint(gradient);
GeneralPath border = new GeneralPath();
border.moveTo(x , y + h);
border.lineTo(x, y + 5);
border.curveTo(x, y + 5, x, y, x + 5, y);
border.lineTo(x + w - 7, y);
border.curveTo(x + w - 7, y, x + w - 2, y, x + w - 2, y + 5);
border.lineTo(x + w - 2, y + h);
/*
border.moveTo(x , y + h - 1);
border.lineTo(x, y + 5);
border.curveTo(x, y + 5, x, y, x + 5, y);
border.lineTo(x + w - 28, y);
border.curveTo(x + w - 28, y,
x + w - 20, (y + h)/2,
x + w - 15, y + h - 2);
*/
g2.fill(border);
}
else{
GradientPaint gradient;
gradient = new GradientPaint(w/2, y,
Constants.CONTACTPANEL_LINES_COLOR, w/2, h,
Constants.CONTACTPANEL_MOVER_END_COLOR);
Graphics2D g2 = (Graphics2D) g;
AntialiasingManager.activateAntialiasing(g2);
g2.setPaint(gradient);
GeneralPath border = new GeneralPath();
border.moveTo(x , y + h);
border.lineTo(x, y + 5);
border.curveTo(x, y + 5, x, y, x + 5, y);
border.lineTo(x + w - 7, y);
border.curveTo(x + w - 7, y, x + w - 2, y, x + w - 2, y + 5);
border.lineTo(x + w - 2, y + h);
/*
border.moveTo(x , y + h - 1);
border.lineTo(x, y + 5);
border.curveTo(x, y + 5, x, y, x + 5, y);
border.lineTo(x + w - 28, y);
border.curveTo(x + w - 28, y,
x + w - 20, (y + h)/2,
x + w - 15, y + h - 2);
*/
g2.fill(border);
Image img= null;
Graphics2D g2 = (Graphics2D) g;
AntialiasingManager.activateAntialiasing(g2);
if(!isOneActionButtonEnabled()){
if (isSelected) {
if (tabPane.isEnabledAt(tabIndex)) {
img = ImageLoader.getImage(ImageLoader.SELECTED_TAB_BG);
} else {
img = ImageLoader.getImage(ImageLoader.TAB_BG);
}
g2.drawImage(img, x, y, null);
}
else{
img = ImageLoader.getImage(ImageLoader.TAB_BG);
g2.drawImage(img, x, y, null);
}
}
else{
if(isSelected){
img = ImageLoader.getImage(ImageLoader.SELECTED_CLOSABLE_TAB_BG);
g2.drawImage(img, x, y, null);
}
else{
img = ImageLoader.getImage(ImageLoader.CLOSABLE_TAB_BG);
g2.drawImage(img, x, y, null);
}
}
}
@ -220,6 +170,28 @@ protected void paintText(Graphics g, int tabPlacement, Font font,
g.setFont(font);
int titleWidth = SwingUtilities.computeStringWidth(metrics, title);
if(isOneActionButtonEnabled()){
int preferredWidth = CLOSABLE_TAB_BACKGROUND.getWidth(null)
- 2*WIDTHDELTA - 12;
if(isCloseEnabled())
preferredWidth -= BUTTONSIZE;
if(isMaxEnabled())
preferredWidth -= BUTTONSIZE;
while(titleWidth > preferredWidth){
if(title.endsWith("..."))
title = title.substring(0, title.indexOf("...") - 1).concat("...");
else
title = title.substring(0, title.length() - 3).concat("...");
titleWidth = SwingUtilities.computeStringWidth(metrics, title);
textRect.width = titleWidth;
}
}
View v = getTextViewForTab(tabIndex);
if (v != null) {
// html
@ -352,4 +324,15 @@ protected CloseTabPaneUI.ScrollableTabButton createScrollableTabButton(
return new ScrollableTabButton(direction);
}
protected int calculateTabWidth(int tabPlacement, int tabIndex,
FontMetrics metrics) {
int width = 0;
if (!isOneActionButtonEnabled())
width = TAB_BACKGROUND.getWidth(null);
else {
width = CLOSABLE_TAB_BACKGROUND.getWidth(null);
}
return width - 14;
}
}

@ -114,9 +114,9 @@ public class CloseTabPaneUI extends BasicTabbedPaneUI {
private static final int PRESSED = 2;
protected static final int BUTTONSIZE = 15;
public static final int BUTTONSIZE = 15;
protected static final int WIDTHDELTA = 5;
public static final int WIDTHDELTA = 10;
private static final Border PRESSEDBORDER = new SoftBevelBorder(
SoftBevelBorder.LOWERED);
@ -231,9 +231,9 @@ private void setPopupMenu() {
protected int calculateTabWidth(int tabPlacement, int tabIndex,
FontMetrics metrics) {
int delta = 2;
int delta = 5;
if (!isOneActionButtonEnabled())
delta += 6;
delta += 5;
else {
if (isCloseButtonEnabled)
delta += BUTTONSIZE + WIDTHDELTA;
@ -247,7 +247,7 @@ protected int calculateTabWidth(int tabPlacement, int tabIndex,
protected int calculateTabHeight(int tabPlacement, int tabIndex,
int fontHeight) {
return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight);
return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight + 4);
}
protected void layoutLabel(int tabPlacement, FontMetrics metrics,
@ -264,12 +264,12 @@ protected void layoutLabel(int tabPlacement, FontMetrics metrics,
SwingUtilities.layoutCompoundLabel((JComponent) tabPane, metrics,
title, icon, SwingUtilities.CENTER, SwingUtilities.LEFT,
SwingUtilities.CENTER, SwingUtilities.CENTER, tabRect,
iconRect, textRect, textIconGap);
iconRect, textRect, 5);
tabPane.putClientProperty("html", null);
iconRect.x = tabRect.x + 8;
textRect.x = iconRect.x + iconRect.width + textIconGap;
iconRect.x = tabRect.x + 5;
textRect.x = iconRect.x + iconRect.width + 5;
}
protected MouseListener createMouseListener() {
@ -662,7 +662,7 @@ protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects,
} else if (isOver || isSelected) {
int dx = tabRect.x + tabRect.width - BUTTONSIZE - WIDTHDELTA;
int dy = (tabRect.y + tabRect.height) / 2 - 6;
int dy = (tabRect.y + tabRect.height) / 2 - 7;
if (isCloseButtonEnabled)
paintCloseIcon(g2, dx, dy, isOver);

@ -162,33 +162,7 @@ public class Constants {
mainStatusSet.put(Constants.INVISIBLE_STATUS,
ImageLoader.getImage(ImageLoader.USER_ONLINE_ICON));
}
/**
* Defines the priority of the statuses. The priority of statuses is used when detecting the
* current status of a MetaContact, containing more than one protocol contacts. The status
* in the table has the highest priority.
*/
public static final LinkedList statusPriorityTable = new LinkedList();
static{
statusPriorityTable.addLast(Constants.CHAT_STATUS);
statusPriorityTable.addLast(Constants.ONLINE_STATUS);
statusPriorityTable.addLast(Constants.INVISIBLE_STATUS);
statusPriorityTable.addLast(Constants.OCCUPIED_STATUS);
statusPriorityTable.addLast(Constants.DND_STATUS);
statusPriorityTable.addLast(Constants.AWAY_STATUS);
statusPriorityTable.addLast(Constants.NA_STATUS);
statusPriorityTable.addLast(Constants.OFFLINE_STATUS);
}
/**
* Returns the priority of the given status according to the statusPriorityTable.
* @param status The given status.
* @return The priority of the given status according to the statusPriorityTable.
*/
public static int getPriority(PresenceStatus status){
return Constants.statusPriorityTable.indexOf(status);
}
/*
* ====================================================
* ------------------------ PROTOCOL NAMES -------------------------------

@ -153,7 +153,19 @@ public class ImageLoader {
public static final ImageID BOTTOM_ARROW_ROLLOVER_ICON
= new ImageID("BOTTOM_ARROW_ROLLOVER_ICON");
public static final ImageID TAB_BG
= new ImageID("TAB_BG");
public static final ImageID SELECTED_TAB_BG
= new ImageID("SELECTED_TAB_BG");
public static final ImageID CLOSABLE_TAB_BG
= new ImageID("CLOSABLE_TAB_BG");
public static final ImageID SELECTED_CLOSABLE_TAB_BG
= new ImageID("SELECTED_CLOSABLE_TAB_BG");
/////////////////////// Edit Text Toolbar icons //////////////////////////
public static final ImageID ALIGN_LEFT_BUTTON

@ -137,4 +137,10 @@ USER_FFC_ICON=net/java/sip/communicator/impl/gui/resources/common/statusicons/fr
USER_OCCUPIED_ICON=net/java/sip/communicator/impl/gui/resources/common/statusicons/occupied.png
CLOSE_TAB_ICON=net/java/sip/communicator/impl/gui/resources/buttons/closeTab.png
CLOSE_TAB_SELECTED_ICON=net/java/sip/communicator/impl/gui/resources/buttons/closeTabSelected.png
CLOSE_TAB_SELECTED_ICON=net/java/sip/communicator/impl/gui/resources/buttons/closeTabSelected.png
SELECTED_TAB_BG=net/java/sip/communicator/impl/gui/resources/common/notebook3.png
TAB_BG=net/java/sip/communicator/impl/gui/resources/common/notebook2.png
SELECTED_CLOSABLE_TAB_BG=net/java/sip/communicator/impl/gui/resources/common/closableTabSelected.png
CLOSABLE_TAB_BG=net/java/sip/communicator/impl/gui/resources/common/closableTab.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Loading…
Cancel
Save