From eb0e794fda4419884135a82a033b51119479429f Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Mon, 20 Mar 2006 10:27:17 +0000 Subject: [PATCH] tab look changed --- .../tabbedPane/CloseTabPaneEnhancedUI.java | 179 ++++++++---------- .../tabbedPane/CloseTabPaneUI.java | 18 +- .../impl/gui/main/utils/Constants.java | 26 --- .../impl/gui/main/utils/ImageLoader.java | 12 ++ .../impl/gui/main/utils/images.properties | 8 +- .../impl/gui/resources/common/closableTab.png | Bin 0 -> 1153 bytes .../resources/common/closableTabSelected.png | Bin 0 -> 1414 bytes 7 files changed, 109 insertions(+), 134 deletions(-) create mode 100644 src/net/java/sip/communicator/impl/gui/resources/common/closableTab.png create mode 100644 src/net/java/sip/communicator/impl/gui/resources/common/closableTabSelected.png diff --git a/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneEnhancedUI.java b/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneEnhancedUI.java index 157a83933..55bb8db04 100644 --- a/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneEnhancedUI.java +++ b/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneEnhancedUI.java @@ -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; + } } \ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneUI.java b/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneUI.java index 40ef5cd07..bd2e5d78d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneUI.java +++ b/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneUI.java @@ -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); diff --git a/src/net/java/sip/communicator/impl/gui/main/utils/Constants.java b/src/net/java/sip/communicator/impl/gui/main/utils/Constants.java index 433b00109..8e068c117 100755 --- a/src/net/java/sip/communicator/impl/gui/main/utils/Constants.java +++ b/src/net/java/sip/communicator/impl/gui/main/utils/Constants.java @@ -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 ------------------------------- diff --git a/src/net/java/sip/communicator/impl/gui/main/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/main/utils/ImageLoader.java index bc174edde..eefb1a910 100644 --- a/src/net/java/sip/communicator/impl/gui/main/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/main/utils/ImageLoader.java @@ -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 diff --git a/src/net/java/sip/communicator/impl/gui/main/utils/images.properties b/src/net/java/sip/communicator/impl/gui/main/utils/images.properties index 2089f171b..322faa452 100644 --- a/src/net/java/sip/communicator/impl/gui/main/utils/images.properties +++ b/src/net/java/sip/communicator/impl/gui/main/utils/images.properties @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/gui/resources/common/closableTab.png b/src/net/java/sip/communicator/impl/gui/resources/common/closableTab.png new file mode 100644 index 0000000000000000000000000000000000000000..e3710a198388085c969385b730bb9fe2c1c21e4e GIT binary patch literal 1153 zcmV-{1b+L8P)MN6~00004b3#c}2nYxW zduASHfDJn{2MUV=q5(SkX5*#S)g(FfWgftwvRK0)@5@#f& zJj5Ts0f{3AE(irK9D1Y&dTNz~#_NP^?Dej8*E1Y&qQps*cW?&f+VRYHp7zbW zSkk4E zl>ppHBoddC$>fWgrsXFlCK8;{2|7CGm)^ZEQW z(=-dFX@W5}s&URVN-1+9=SSy}mab93_-Ddp!vi2K9p>OK2jCX=ZfhH;@(Dh;c7uBlWi z&~-fz;O%C!*(9RRgb=|nnmQ3B7-QGd>GUPjG;!89;KzY!ns6Ma;CbGacDsEOz>mY| z=>Xo!WHR+qsgz8mQjvv5wdBtVwOS3^+uL>5bw4Dc--QtWMAgy(%p?+tQn6SZuYv(c zrBaxlo{o8*x45yf@iBm}qH5^?p68q=6N$t)2m?~7RM2cTUud`6ZxGQ>LWp}&baVh0 zHBC##pJ5aPk0 z8aiW4=bW?gDu~Y1)D+v=+PY*})^z~i4%(k9r6gkvobz#sSWMGIHk+;Ky8b2+l?M%i z4xkI*T%Hd-E;#3?R;ya8)q1(nXnaCMUk-A}rvuns31gyDtJPpxR?TsoYmVbA1Nil% zeRTi|fa08wPwR$&bB?*WIkZ}>Mb~w25z*a~-b3sJAyPVe*8U|QM=qDc%*;&Mb=_AR zjm9ki-<+hM4nX4nlr(S@#z)-;nVp@5Wm&V1EhqqirVzI)FO*=!c|dOcN2i-X z($Jt9=Ox7%hJpF{`K+dC?>C#xa;w$4N<@DG_zS=~0B7ejmMtwUeO)e>KZ?a-1pw$> zejk7x{dOYP?~y!_Mt}Q0mk!g7QorAU6Hbbw+J#{VDJ6X0w>-~lxUOpjLC^`q(34Vb z0l2FJptZF%7r;gIHtEC0z`+;A`fQZ?r$uAux&OC)cF#l{q}@?%Ib$rRlzQ$zHUG&$ TRi7r900000NkvXXu0mjfFH9d8 literal 0 HcmV?d00001 diff --git a/src/net/java/sip/communicator/impl/gui/resources/common/closableTabSelected.png b/src/net/java/sip/communicator/impl/gui/resources/common/closableTabSelected.png new file mode 100644 index 0000000000000000000000000000000000000000..6a66107324101e821140b76f8520e8b8ca16afc4 GIT binary patch literal 1414 zcmV;11$p|3P)MN6~00004b3#c}2nYxW zd7MC{Ge#3aG%AF+$wCu^fKlQD6fwq)OCcaaxpWh<(S_g_5OT#2 z;6m^NxRdC{g-f&0Rf1?9YG#tmqaRhrMfIz0S5J5K^bnEx!}N6jU-9d_cS)21n1l# zRW5I~Ila}EXF92@v{DvQKW7tisD;L;@k9zrilcOlPPpIoWekWwAf(2S3S>YkLMr*S zZG@HxEz^}SU?Z}uMFBTOR&ez1&4Bw&AyXM% zPhrVkx7*b6XQIOk5K8JE_Z_T24_=-};*5T%!V?Z-ZSBJ$4IWEA>6 z8=sCbr2B-A_#fj>Ju>juG;W>BQm8z+nz2&T-&gATV_^6+Ns?cg14LDE&eb#J%k^e- z;nrrYvEB^FBx79gldHd|8yYjD^DRf_@D$amfAqK-@i&q1jKhtLqsyJUtM%-=!0<_u zB)_ps*zWbsW@=A9=+qk9S|{p1f_1v!y@*GHANcZa&87MWHghDr%%8&DZ7`<2Vod9` z)mr+ObME6LN!siJ);YJJ%K5g2CpK9miUKd#alv<&HcjwDt0=G5L2FN|zl89?oYU{} z`yI=@76)r#^GrR=-UYrXaXU3E@M>GblT8+DHjMMFF>Cb?H6~U6sLmrCKN(uS!{%81 zxo)~$zSde~c_BL)+va=DxgU}w`E%6Ubg;nFnbx*E!^LOB&Q@KWo{32bhfng%xAMIF93f@a4&vU-kFL4Cy8& zV~?wUs$J#TF`>m*68QxO)hVnl3Us*W85;#dDjpyR85R5xQXW_mz( z?^fL9zW+{kK+>#v!sym{;0r3klK+M>Go<)uxanK%8k4HOp!G>FBfPKP{u|2T?)&_*0L}5S_+P=imK%&SJ zhoRT+N)!@By?YT7uLc^_p94O0&Q+>9BfH!Q|7Q$HmjUSo!lh5R#48Xk9a9sX1I|^M z$B>_r{x01|Rfv!+Jcb7KQ;J-4&K;O`XqSY2%mu*$8m}y3>n{KoryXX14BbDH<^_#b z(O~hon(%^i?yYIYZJbdFK61`IKWRwsINE1no(N*Hg~ubcOD`(s zl5_5jo!*!%JrerQ=3!3e@qS;?hs@`j;-MpKpqeft=50C~MVbBLWBh1!}BG UVA;{7*8l(j07*qoM6N<$g5YnsGXMYp literal 0 HcmV?d00001