001: /**
002: * L2FProd.com Common Components 7.3 License.
003: *
004: * Copyright 2005-2007 L2FProd.com
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */package com.l2fprod.common.swing.plaf.windows;
018:
019: import com.l2fprod.common.swing.border.ButtonBorder;
020: import com.l2fprod.common.swing.border.FourLineBorder;
021: import com.l2fprod.common.swing.plaf.basic.BasicOutlookBarUI;
022:
023: import java.awt.Color;
024: import java.awt.Component;
025: import java.awt.Dimension;
026: import java.awt.Graphics;
027: import java.awt.Insets;
028:
029: import javax.swing.AbstractButton;
030: import javax.swing.JComponent;
031: import javax.swing.JScrollBar;
032: import javax.swing.JScrollPane;
033: import javax.swing.UIManager;
034: import javax.swing.border.Border;
035: import javax.swing.plaf.ComponentUI;
036: import javax.swing.plaf.basic.BasicButtonUI;
037: import javax.swing.plaf.basic.BasicScrollBarUI;
038:
039: /**
040: * Implements of OutlookBarUI with the Windows look and feel. <br>
041: *
042: */
043: public class WindowsOutlookBarUI extends BasicOutlookBarUI {
044:
045: public static ComponentUI createUI(JComponent c) {
046: return new WindowsOutlookBarUI();
047: }
048:
049: private Border tabButtonBorder;
050:
051: public JScrollPane makeScrollPane(Component component) {
052: JScrollPane scroll = super .makeScrollPane(component);
053: scroll
054: .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
055: scroll.getVerticalScrollBar().setUI(new ThinScrollBarUI());
056: return scroll;
057: }
058:
059: protected void installDefaults() {
060: super .installDefaults();
061: tabButtonBorder = UIManager
062: .getBorder("OutlookBar.tabButtonBorder");
063: }
064:
065: protected TabButton createTabButton() {
066: TabButton button = new TabButton();
067: button.setUI(new BasicButtonUI());
068: button.setBorder(tabButtonBorder);
069: return button;
070: }
071:
072: public static class WindowsTabButtonBorder extends ButtonBorder {
073: FourLineBorder normalBorder;
074: FourLineBorder pressedBorder;
075:
076: public WindowsTabButtonBorder(Color color1, Color color2) {
077: normalBorder = new FourLineBorder(color1, color1, color2,
078: color2);
079: pressedBorder = new FourLineBorder(color2, color2, color1,
080: color1);
081: }
082:
083: protected void paintNormal(AbstractButton b, Graphics g, int x,
084: int y, int width, int height) {
085: normalBorder.paintBorder(b, g, x, y, width, height);
086: }
087:
088: protected void paintDisabled(AbstractButton b, Graphics g,
089: int x, int y, int width, int height) {
090: normalBorder.paintBorder(b, g, x, y, width, height);
091: }
092:
093: protected void paintRollover(AbstractButton b, Graphics g,
094: int x, int y, int width, int height) {
095: normalBorder.paintBorder(b, g, x, y, width, height);
096: }
097:
098: protected void paintPressed(AbstractButton b, Graphics g,
099: int x, int y, int width, int height) {
100: pressedBorder.paintBorder(b, g, x, y, width, height);
101: }
102:
103: public Insets getBorderInsets(Component c) {
104: return normalBorder.getBorderInsets(c);
105: }
106: }
107:
108: public static class ThinScrollBarUI extends BasicScrollBarUI {
109: public Dimension getPreferredSize(JComponent c) {
110: return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(
111: 8, 48)
112: : new Dimension(48, 8);
113: }
114: }
115:
116: }
|