56
57 /* ToolBarBorder and drag-off handle, based loosly on MetalBumps */
58 static class ToolBarBorder extends AbstractBorder implements UIResource, javax.swing.SwingConstants {
59 protected void fillHandle(final Graphics g, final int x1, final int y1, final int x2, final int y2, final boolean horizontal) {
60 g.setColor(UIManager.getColor("ToolBar.borderHandleColor"));
61 if (horizontal) {
62 final int h = y2 - y1 - 2;
63 g.fillRect(x1 + 2, y1 + 1, 1, h);
64 g.fillRect(x1 + 5, y1 + 1, 1, h);
65 } else {
66 final int w = x2 - x1 - 2;
67 g.fillRect(x1 + 1, y1 + 2, w, 1);
68 g.fillRect(x1 + 1, y1 + 5, w, 1);
69 }
70 }
71
72 public void paintBorder(final java.awt.Component c, final Graphics g, int x, int y, final int w, final int h) {
73 g.translate(x, y);
74
75 if (c.isOpaque()) {
76 final Color background = c.getBackground();
77 g.setColor(background);
78 g.fillRect(0, 0, w - 1, h - 1);
79 }
80
81 final Color oldColor = g.getColor();
82
83 final JToolBar jtb = (JToolBar)c;
84 final ComponentOrientation orient = jtb.getComponentOrientation();
85 final boolean horizontal = jtb.getOrientation() == SwingConstants.HORIZONTAL;
86
87 if (jtb.isFloatable()) {
88 if (horizontal) {
89 if (orient.isLeftToRight()) {
90 fillHandle(g, 2, 2, 10, h - 2, true);
91 } else {
92 fillHandle(g, w - 10, 2, w - 2, h - 2, true);
93 }
94 } else {
95 fillHandle(g, 2, 2, w - 2, 10, false);
96 }
97 }
98
119 } else { // vertical
120 borderInsets.top = 12;
121 }
122 }
123
124 final Insets margin = ((JToolBar)c).getMargin();
125
126 if (margin != null) {
127 borderInsets.left += margin.left;
128 borderInsets.top += margin.top;
129 borderInsets.right += margin.right;
130 borderInsets.bottom += margin.bottom;
131 }
132
133 return borderInsets;
134 }
135
136 public boolean isBorderOpaque() {
137 return true;
138 }
139 }
140 }
|
56
57 /* ToolBarBorder and drag-off handle, based loosly on MetalBumps */
58 static class ToolBarBorder extends AbstractBorder implements UIResource, javax.swing.SwingConstants {
59 protected void fillHandle(final Graphics g, final int x1, final int y1, final int x2, final int y2, final boolean horizontal) {
60 g.setColor(UIManager.getColor("ToolBar.borderHandleColor"));
61 if (horizontal) {
62 final int h = y2 - y1 - 2;
63 g.fillRect(x1 + 2, y1 + 1, 1, h);
64 g.fillRect(x1 + 5, y1 + 1, 1, h);
65 } else {
66 final int w = x2 - x1 - 2;
67 g.fillRect(x1 + 1, y1 + 2, w, 1);
68 g.fillRect(x1 + 1, y1 + 5, w, 1);
69 }
70 }
71
72 public void paintBorder(final java.awt.Component c, final Graphics g, int x, int y, final int w, final int h) {
73 g.translate(x, y);
74
75 if (c.isOpaque()) {
76 AquaUtils.fillRect(g, c, c.getBackground(), 0, 0, w - 1, h - 1);
77 }
78
79 final Color oldColor = g.getColor();
80
81 final JToolBar jtb = (JToolBar)c;
82 final ComponentOrientation orient = jtb.getComponentOrientation();
83 final boolean horizontal = jtb.getOrientation() == SwingConstants.HORIZONTAL;
84
85 if (jtb.isFloatable()) {
86 if (horizontal) {
87 if (orient.isLeftToRight()) {
88 fillHandle(g, 2, 2, 10, h - 2, true);
89 } else {
90 fillHandle(g, w - 10, 2, w - 2, h - 2, true);
91 }
92 } else {
93 fillHandle(g, 2, 2, w - 2, 10, false);
94 }
95 }
96
117 } else { // vertical
118 borderInsets.top = 12;
119 }
120 }
121
122 final Insets margin = ((JToolBar)c).getMargin();
123
124 if (margin != null) {
125 borderInsets.left += margin.left;
126 borderInsets.top += margin.top;
127 borderInsets.right += margin.right;
128 borderInsets.bottom += margin.bottom;
129 }
130
131 return borderInsets;
132 }
133
134 public boolean isBorderOpaque() {
135 return true;
136 }
137 }
138
139 @Override
140 public final void update(final Graphics g, final JComponent c) {
141 if (c.isOpaque()) {
142 AquaUtils.fillRect(g, c);
143 }
144 paint(g, c);
145 }
146 }
|