01: /*
02: * @(#)VsnetPopupMenuSeparatorUI.java
03: *
04: * Copyright 2002 JIDE Software Inc. All rights reserved.
05: */
06:
07: package com.jidesoft.plaf.office2003;
08:
09: import com.jidesoft.plaf.UIDefaultsLookup;
10: import com.jidesoft.plaf.basic.ThemePainter;
11: import com.jidesoft.plaf.vsnet.VsnetPopupMenuSeparatorUI;
12:
13: import javax.swing.*;
14: import javax.swing.plaf.ComponentUI;
15: import java.awt.*;
16:
17: /**
18: * PopupMenuSeparator UI implementation
19: */
20: public class Office2003PopupMenuSeparatorUI extends
21: VsnetPopupMenuSeparatorUI {
22: public static ComponentUI createUI(JComponent c) {
23: return new Office2003PopupMenuSeparatorUI();
24: }
25:
26: private ThemePainter _painter;
27:
28: @Override
29: protected void installDefaults(JSeparator s) {
30: _painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter");
31: super .installDefaults(s);
32: }
33:
34: @Override
35: protected void uninstallDefaults(JSeparator s) {
36: _painter = null;
37: super .uninstallDefaults(s);
38: }
39:
40: @Override
41: public void paint(Graphics g, JComponent c) {
42: if (!(c.getParent() instanceof JPopupMenu)) {
43: super .paint(g, c);
44: return;
45: }
46:
47: Dimension s = c.getSize();
48:
49: int defaultShadowWidth = UIDefaultsLookup
50: .getInt("MenuItem.shadowWidth");
51: int defaultTextIconGap = UIDefaultsLookup
52: .getInt("MenuItem.textIconGap");
53:
54: if (c.getComponentOrientation().isLeftToRight()) {
55: _painter.paintMenuShadow(c, g, new Rectangle(0, 0,
56: defaultShadowWidth, HEIGHT),
57: SwingConstants.HORIZONTAL,
58: ThemePainter.STATE_DEFAULT);
59:
60: g.setColor(_painter.getMenuItemBackground());
61: g.fillRect(defaultShadowWidth, 0, s.width
62: - defaultShadowWidth, HEIGHT);
63:
64: g.setColor(_painter.getSeparatorForeground());
65: g.drawLine(defaultShadowWidth + defaultTextIconGap, 1,
66: s.width, 1);
67: } else {
68: g.fillRect(s.width, 0, defaultShadowWidth, HEIGHT);
69:
70: g.setColor(_painter.getMenuItemBackground());
71: g.fillRect(0, 0, s.width - defaultShadowWidth, HEIGHT);
72:
73: g.setColor(_painter.getSeparatorForeground());
74: g.drawLine(defaultTextIconGap, 1, s.width
75: - defaultShadowWidth, 1);
76: }
77: }
78:
79: @Override
80: public Dimension getPreferredSize(JComponent c) {
81: return new Dimension(0, HEIGHT);
82: }
83:
84: }
|