01: // @@
02: // @@
03: /*
04: * Wi.Ser Framework
05: *
06: * LGPL Version: 1.8.1, 20-September-2007
07: * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library located in LGPL.txt in the
21: * license directory; if not, write to the
22: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23: * Boston, MA 02111-1307, USA.
24: *
25: * If this agreement does not cover your requirements, please contact us
26: * via email to get detailed information about the commercial license
27: * or our service offerings!
28: *
29: */
30: // @@
31: package de.ug2t.channel.ho.client.swing.enhanced;
32:
33: import java.awt.*;
34:
35: import javax.swing.*;
36: import javax.swing.plaf.basic.*;
37:
38: public class EnhancedTabbedPaneUI extends BasicTabbedPaneUI {
39: protected void paintIcon(Graphics g, int tabPlacement,
40: int tabIndex, Icon icon, Rectangle iconRect,
41: boolean isSelected) {
42: Container l_cont = ((EnhancedTabbedPane) tabPane)
43: .pcmf_getTabComponent(tabIndex);
44: if (l_cont == null)
45: super .paintIcon(g, tabPlacement, tabIndex, icon, iconRect,
46: isSelected);
47: }
48:
49: protected void paintText(Graphics g, int tabPlacement, Font font,
50: FontMetrics metrics, int tabIndex, String title,
51: Rectangle textRect, boolean isSelected) {
52: Container l_cont = ((EnhancedTabbedPane) tabPane)
53: .pcmf_getTabComponent(tabIndex);
54: if (l_cont != null) {
55: if (l_cont instanceof JComponent)
56: this .tabPane.setToolTipTextAt(tabIndex,
57: ((JComponent) l_cont).getToolTipText());
58:
59: Rectangle l_rect = this .getTabBounds(tabPane, tabIndex);
60: Insets l_ins = this .getTabInsets(tabPlacement, tabIndex);
61: Graphics l_g = g.create();
62:
63: l_g.translate(l_rect.x + l_ins.left, l_rect.y + l_ins.top);
64: l_cont.setSize(l_cont.getPreferredSize());
65:
66: l_cont.paintAll(l_g);
67: } else
68: super .paintText(g, tabPlacement, font, metrics, tabIndex,
69: title, textRect, isSelected);
70: }
71:
72: protected int calculateTabHeight(int tabPlacement, int tabIndex,
73: int fontHeight) {
74: Container l_cont = ((EnhancedTabbedPane) tabPane)
75: .pcmf_getTabComponent(tabIndex);
76: if (l_cont != null) {
77: Insets l_ins = this .getTabInsets(tabPlacement, tabIndex);
78: return (l_cont.getPreferredSize().height + l_ins.top + l_ins.bottom);
79: } else
80: return (super .calculateTabHeight(tabPlacement, tabIndex,
81: fontHeight));
82: }
83:
84: protected int calculateTabWidth(int tabPlacement, int tabIndex,
85: FontMetrics metrics) {
86: Container l_cont = ((EnhancedTabbedPane) tabPane)
87: .pcmf_getTabComponent(tabIndex);
88: if (l_cont != null) {
89: Insets l_ins = this .getTabInsets(tabPlacement, tabIndex);
90: return (l_cont.getPreferredSize().width + l_ins.left + l_ins.right);
91: } else
92: return (super .calculateTabWidth(tabPlacement, tabIndex,
93: metrics));
94: }
95:
96: public Insets pcmf_getTabInsets(int xTab) {
97: return (this.getTabInsets(this.tabPane.getTabPlacement(), xTab));
98: }
99: }
|