001: /*
002: * @(#)Office2003HeaderBoxUI.java 5/6/2006
003: *
004: * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
005: */
006:
007: package com.jidesoft.plaf.office2003;
008:
009: import com.jidesoft.plaf.HeaderBoxUI;
010: import com.jidesoft.plaf.basic.BasicHeaderBoxUI;
011: import com.jidesoft.swing.HeaderBox;
012:
013: import javax.swing.*;
014: import javax.swing.plaf.ComponentUI;
015: import java.awt.*;
016:
017: public class Office2003HeaderBoxUI extends BasicHeaderBoxUI {
018: // Shared UI object
019: private static HeaderBoxUI _headerBoxUI;
020:
021: public static ComponentUI createUI(JComponent c) {
022: if (_headerBoxUI == null) {
023: _headerBoxUI = new Office2003HeaderBoxUI();
024: }
025: return _headerBoxUI;
026: }
027:
028: @Override
029: protected void paintBorder(Graphics g, JComponent c) {
030: }
031:
032: @Override
033: public void paintBackground(Graphics g, JComponent c) {
034: HeaderBox headerBox = (HeaderBox) c;
035:
036: boolean isCellEditor = Boolean.TRUE
037: .equals(headerBox
038: .getClientProperty(HeaderBox.CLIENT_PROPERTY_TABLE_CELL_EDITOR));
039:
040: if (headerBox.getModel().isPressed()
041: || headerBox.getModel().isSelected()) {
042: if (isCellEditor) {
043: g.setColor(new Color(222, 223, 216));
044: g.fillRect(0, 0, c.getWidth(), c.getHeight());
045: } else {
046: g.setColor(new Color(222, 223, 216));
047: g
048: .fillRoundRect(0, 0, c.getWidth(), c
049: .getHeight(), 6, 6);
050:
051: g.setColor(Color.LIGHT_GRAY);
052: g.drawRoundRect(0, 0, c.getWidth() - 1,
053: c.getHeight() - 1, 4, 4);
054: }
055: } else if (headerBox.getModel().isRollover()) {
056: if (isCellEditor) {
057: g.setColor(new Color(250, 248, 243));
058: g.fillRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
059: } else {
060: g.setColor(new Color(250, 248, 243));
061: g.fillRoundRect(0, 0, c.getWidth() - 1,
062: c.getHeight() - 1, 2, 2);
063:
064: g.setColor(Color.LIGHT_GRAY);
065: g.drawRoundRect(0, 0, c.getWidth() - 1,
066: c.getHeight() - 1, 4, 4);
067: }
068:
069: g.setColor(new Color(248, 169, 0));
070: g.drawLine(1, c.getHeight() - 3, c.getWidth() - 2, c
071: .getHeight() - 3);
072: g.setColor(new Color(246, 196, 86));
073: g.drawLine(1, c.getHeight() - 2, c.getWidth() - 2, c
074: .getHeight() - 2);
075: g.setColor(new Color(249, 177, 25));
076: g.drawLine(3, c.getHeight() - 1, c.getWidth() - 3, c
077: .getHeight() - 1);
078: } else {
079: if (isCellEditor) {
080: g.setColor(new Color(235, 234, 219));
081: g.fillRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
082: } else {
083: g.setColor(new Color(235, 234, 219));
084: g.fillRoundRect(0, 0, c.getWidth() - 1,
085: c.getHeight() - 1, 2, 2);
086:
087: g.setColor(Color.LIGHT_GRAY);
088: g.drawRoundRect(0, 0, c.getWidth() - 1,
089: c.getHeight() - 1, 2, 4);
090: }
091:
092: g.setColor(new Color(226, 222, 205));
093: g.drawLine(1, c.getHeight() - 3, c.getWidth() - 2, c
094: .getHeight() - 3);
095: g.setColor(new Color(214, 210, 194));
096: g.drawLine(1, c.getHeight() - 2, c.getWidth() - 2, c
097: .getHeight() - 2);
098:
099: if (isCellEditor) {
100: g.setColor(new Color(198, 197, 178));
101: g.drawLine(c.getWidth() - 3, 4, c.getWidth() - 3, c
102: .getHeight() - 7);
103: g.setColor(Color.WHITE);
104: g.drawLine(c.getWidth() - 2, 4, c.getWidth() - 2, c
105: .getHeight() - 7);
106: }
107: }
108: }
109: }
|