| 1 |
/* |
| 2 |
* @(#)$FileName Copyright 2002 - 2004 JIDE Software Inc. All rights reserved. |
| 3 |
*/ |
| 4 |
|
| 5 |
package com.jidesoft.plaf.office2003; |
| 6 |
|
| 7 |
import com.jidesoft.plaf.vsnet.VsnetJideTabbedPaneUI; |
| 8 |
import com.jidesoft.swing.JideTabbedPane; |
| 9 |
|
| 10 |
import javax.swing.*; |
| 11 |
import javax.swing.plaf.ComponentUI; |
| 12 |
import java.awt.*; |
| 13 |
|
| 14 |
/** |
| 15 |
* JideTabbedPane UI implementation |
| 16 |
*/ |
| 17 |
public class Office2003JideTabbedPaneUI extends VsnetJideTabbedPaneUI { |
| 18 |
@Override |
| 19 |
public void installColorTheme() { |
| 20 |
super.installColorTheme(); |
| 21 |
|
| 22 |
if (_tabPane.getColorTheme() != JideTabbedPane.COLOR_THEME_OFFICE2003) |
| 23 |
return; |
| 24 |
|
| 25 |
switch (getTabShape()) { |
| 26 |
case JideTabbedPane.SHAPE_ROUNDED_FLAT: |
| 27 |
_selectColor1 = getPainter().getControlShadow(); |
| 28 |
_selectColor2 = getPainter().getControlShadow(); |
| 29 |
_unselectColor1 = _selectColor1; |
| 30 |
_unselectColor2 = _selectColor2; |
| 31 |
break; |
| 32 |
case JideTabbedPane.SHAPE_BOX: |
| 33 |
_selectColor1 = getPainter().getControlShadow(); |
| 34 |
_selectColor2 = getPainter().getControlShadow(); |
| 35 |
_unselectColor1 = getPainter().getControlShadow(); |
| 36 |
_unselectColor2 = _lightHighlight; |
| 37 |
break; |
| 38 |
case JideTabbedPane.SHAPE_EXCEL: |
| 39 |
_selectColor1 = getPainter().getControlShadow(); |
| 40 |
_selectColor2 = null; |
| 41 |
_selectColor3 = null; |
| 42 |
_unselectColor1 = getPainter().getControlShadow(); |
| 43 |
_unselectColor2 = null; |
| 44 |
_unselectColor3 = null; |
| 45 |
break; |
| 46 |
case JideTabbedPane.SHAPE_WINDOWS: |
| 47 |
case JideTabbedPane.SHAPE_WINDOWS_SELECTED: |
| 48 |
_selectColor1 = _lightHighlight; |
| 49 |
_selectColor2 = getPainter().getControlDk(); |
| 50 |
_selectColor3 = getPainter().getControlShadow(); |
| 51 |
_unselectColor1 = _selectColor1; |
| 52 |
_unselectColor2 = _selectColor2; |
| 53 |
_unselectColor3 = _selectColor3; |
| 54 |
break; |
| 55 |
case JideTabbedPane.SHAPE_VSNET: |
| 56 |
_selectColor1 = getPainter().getControlShadow(); |
| 57 |
_selectColor2 = getPainter().getControlShadow(); |
| 58 |
_unselectColor1 = getPainter().getControlShadow(); |
| 59 |
break; |
| 60 |
case JideTabbedPane.SHAPE_OFFICE2003: |
| 61 |
default: |
| 62 |
_selectColor1 = getPainter().getControlShadow(); |
| 63 |
_unselectColor1 = getPainter().getControlShadow(); |
| 64 |
_unselectColor2 = _lightHighlight; |
| 65 |
_unselectColor3 = getPainter().getControlDk(); |
| 66 |
break; |
| 67 |
} |
| 68 |
|
| 69 |
installBackgroundColor(); |
| 70 |
} |
| 71 |
|
| 72 |
@Override |
| 73 |
protected void installBackgroundColor() { |
| 74 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_OFFICE2003) { |
| 75 |
if (_showFocusIndicator) { |
| 76 |
_backgroundSelectedColorStart = getPainter().getSelectionSelectedLt(); |
| 77 |
_backgroundSelectedColorEnd = getPainter().getSelectionSelectedDk(); |
| 78 |
} |
| 79 |
else { |
| 80 |
_backgroundSelectedColorStart = getPainter().getBackgroundLt(); |
| 81 |
_backgroundSelectedColorEnd = getPainter().getBackgroundDk(); |
| 82 |
} |
| 83 |
if (getTabShape() == JideTabbedPane.SHAPE_BOX) { |
| 84 |
_backgroundUnselectedColorStart = null; |
| 85 |
_backgroundUnselectedColorEnd = null; |
| 86 |
} |
| 87 |
else { |
| 88 |
_backgroundUnselectedColorStart = getPainter().getBackgroundLt(); |
| 89 |
_backgroundUnselectedColorEnd = getPainter().getBackgroundDk(); |
| 90 |
} |
| 91 |
} |
| 92 |
else { |
| 93 |
super.installBackgroundColor(); |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
// paint the background of the _tabScroller |
| 98 |
@Override |
| 99 |
public void paintBackground(Graphics g, Component c) { |
| 100 |
if (_tabPane.isOpaque()) { |
| 101 |
int width = c.getWidth(); |
| 102 |
int height = c.getHeight(); |
| 103 |
int h = 0; |
| 104 |
int w = 0; |
| 105 |
Graphics2D g2d = (Graphics2D) g; |
| 106 |
|
| 107 |
if (_tabPane.getTabCount() > 0) { |
| 108 |
h = _tabPane.getBoundsAt(0).height; |
| 109 |
w = _tabPane.getBoundsAt(0).width; |
| 110 |
} |
| 111 |
else { |
| 112 |
return; |
| 113 |
} |
| 114 |
|
| 115 |
int temp1 = -1; |
| 116 |
int temp2 = -1; |
| 117 |
if (isTabLeadingComponentVisible()) { |
| 118 |
if (h < _tabLeadingComponent.getSize().height) { |
| 119 |
h = _tabLeadingComponent.getSize().height; |
| 120 |
temp1 = _tabLeadingComponent.getSize().height; |
| 121 |
} |
| 122 |
if (w < _tabLeadingComponent.getSize().width) { |
| 123 |
w = _tabLeadingComponent.getSize().width; |
| 124 |
temp2 = _tabLeadingComponent.getSize().width; |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
if (isTabTrailingComponentVisible()) { |
| 129 |
if (h < _tabTrailingComponent.getSize().height && temp1 < _tabTrailingComponent.getSize().height) { |
| 130 |
h = _tabTrailingComponent.getSize().height; |
| 131 |
} |
| 132 |
if (w < _tabTrailingComponent.getSize().width && temp2 < _tabTrailingComponent.getSize().width) { |
| 133 |
w = _tabTrailingComponent.getSize().width; |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
super.paintBackground(g, c); |
| 138 |
|
| 139 |
Rectangle rect = null; |
| 140 |
if (_tabPane.getTabPlacement() == TOP) { |
| 141 |
rect = new Rectangle(0, 0, width, h + 2); |
| 142 |
|
| 143 |
} |
| 144 |
else if (_tabPane.getTabPlacement() == BOTTOM) { |
| 145 |
rect = new Rectangle(0, height - h - 2, width, h + 2); |
| 146 |
|
| 147 |
} |
| 148 |
else if (_tabPane.getTabPlacement() == LEFT) { |
| 149 |
rect = new Rectangle(0, 0, w + 2, height); |
| 150 |
|
| 151 |
} |
| 152 |
else if (_tabPane.getTabPlacement() == RIGHT) { |
| 153 |
rect = new Rectangle(width - w - 2, 0, w + 2, height); |
| 154 |
} |
| 155 |
if (rect != null) { |
| 156 |
paintTabAreaBackground(g, rect, _tabPane.getTabPlacement()); |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
public static ComponentUI createUI(JComponent c) { |
| 162 |
return new Office2003JideTabbedPaneUI(); |
| 163 |
} |
| 164 |
|
| 165 |
// paint the content top line when the tab is on the top |
| 166 |
@Override |
| 167 |
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { |
| 168 |
if (!PAINT_CONTENT_BORDER_EDGE) { |
| 169 |
return; |
| 170 |
} |
| 171 |
|
| 172 |
if (getColorTheme() != JideTabbedPane.COLOR_THEME_OFFICE2003) { |
| 173 |
super.paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 174 |
return; |
| 175 |
} |
| 176 |
|
| 177 |
if (selectedIndex < 0) { |
| 178 |
return; |
| 179 |
} |
| 180 |
|
| 181 |
Rectangle selRect = getTabBounds(selectedIndex, _calcRect); |
| 182 |
|
| 183 |
Rectangle viewRect = _tabScroller.viewport.getViewRect(); |
| 184 |
Rectangle r = _rects[selectedIndex]; |
| 185 |
|
| 186 |
int tabShape = getTabShape(); |
| 187 |
|
| 188 |
Insets contentInsets = getContentBorderInsets(tabPlacement); |
| 189 |
|
| 190 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_OFFICE2003) { |
| 191 |
if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) { |
| 192 |
g.setColor(getPainter().getControlShadow()); |
| 193 |
|
| 194 |
if (_alwaysShowLineBorder || _tabPane.hasFocusComponent()) { |
| 195 |
if (contentInsets.left > 0) { |
| 196 |
g.drawLine(x, y, x, y + h - 1);// left |
| 197 |
} |
| 198 |
if (contentInsets.right > 0) { |
| 199 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 200 |
} |
| 201 |
if (contentInsets.bottom > 0) { |
| 202 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 203 |
} |
| 204 |
|
| 205 |
if (contentInsets.top > 0 && _tabPane.isTabShown()) { |
| 206 |
if (r.x >= viewRect.x + viewRect.width) { |
| 207 |
g.drawLine(x, y, x + w - 1, y);// top |
| 208 |
} |
| 209 |
else { |
| 210 |
if (_tabPane.getComponentOrientation().isLeftToRight()) { |
| 211 |
g.drawLine(x, y, selRect.x - selRect.height + 2, y);// top left |
| 212 |
g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right |
| 213 |
} |
| 214 |
else { |
| 215 |
g.drawLine(x, y, selRect.x, y);// top left |
| 216 |
g.drawLine(selRect.x + selRect.width + selRect.height - 3, y, x + w - 1, y);// top right |
| 217 |
} |
| 218 |
} |
| 219 |
|
| 220 |
Rectangle bounds = _tabScroller.viewport.getBounds(); |
| 221 |
g.drawLine(0, y, bounds.x, y); |
| 222 |
g.drawLine(bounds.x + bounds.width, y, x + w - 1, y); |
| 223 |
} |
| 224 |
else if (contentInsets.top > 0 && !_tabPane.isTabShown()) { |
| 225 |
g.drawLine(x, y, x + w - 1, y);// bottom |
| 226 |
} |
| 227 |
} |
| 228 |
else if (_tabPane.isTabShown()) { |
| 229 |
if (r.x >= viewRect.x + viewRect.width) { |
| 230 |
g.drawLine(x, y, x + w - 1, y);// top |
| 231 |
} |
| 232 |
else { |
| 233 |
if (_tabPane.getComponentOrientation().isLeftToRight()) { |
| 234 |
g.drawLine(x, y, selRect.x - selRect.height + 2, y);// top left |
| 235 |
g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right |
| 236 |
} |
| 237 |
else { |
| 238 |
g.drawLine(x, y, selRect.x, y);// top left |
| 239 |
g.drawLine(selRect.x + selRect.width + selRect.height - 3, y, x + w - 1, y);// top right |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
Rectangle bounds = _tabScroller.viewport.getBounds(); |
| 244 |
g.drawLine(x, y, bounds.x, y); |
| 245 |
g.drawLine(bounds.x + bounds.width, y, x + w - 1, y); |
| 246 |
} |
| 247 |
|
| 248 |
} |
| 249 |
else if (tabShape == JideTabbedPane.SHAPE_EXCEL) { |
| 250 |
g.setColor(getPainter().getControlShadow()); |
| 251 |
|
| 252 |
g.drawLine(x, y, selRect.x - selRect.height / 2 + 4, y);// top left |
| 253 |
|
| 254 |
if (contentInsets.left > 0) { |
| 255 |
g.drawLine(x, y, x, y + h - 1);// left |
| 256 |
} |
| 257 |
if (contentInsets.right > 0) { |
| 258 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 259 |
} |
| 260 |
if (contentInsets.bottom > 0) { |
| 261 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 266 |
g.drawLine(x, y, x + w - 1, y);// top |
| 267 |
} |
| 268 |
else { |
| 269 |
if (!_tabPane.isShowIconsOnTab() |
| 270 |
&& !_tabPane.isUseDefaultShowIconsOnTab()) { |
| 271 |
g.drawLine(selRect.x + selRect.width + selRect.height / 2 - 4, |
| 272 |
y, x + w - 1, y);// top right |
| 273 |
} |
| 274 |
else { |
| 275 |
g.drawLine(selRect.x + selRect.width + selRect.height / 2 - 6, |
| 276 |
y, x + w - 1, y);// top right |
| 277 |
} |
| 278 |
} |
| 279 |
} |
| 280 |
else if (tabShape == JideTabbedPane.SHAPE_WINDOWS |
| 281 |
|| tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 282 |
g.setColor(getBorderEdgeColor()); |
| 283 |
|
| 284 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET |
| 285 |
|| _tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {// the color set is winxp |
| 286 |
g.drawLine(x, y, selRect.x - 2, y);// top left |
| 287 |
} |
| 288 |
else {// the color set is default or office2003 |
| 289 |
g.drawLine(x, y, selRect.x - 1, y);// top left |
| 290 |
} |
| 291 |
|
| 292 |
if (contentInsets.left > 0) { |
| 293 |
g.drawLine(x, y, x, y + h - 1);// left |
| 294 |
} |
| 295 |
|
| 296 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 297 |
g.setColor(_lightHighlight); |
| 298 |
g.drawLine(x, y, x + w - 1, y);// top |
| 299 |
} |
| 300 |
else { |
| 301 |
g.setColor(_lightHighlight); |
| 302 |
g.drawLine(selRect.x + selRect.width + 3, y, x + w - 1, y);// top right |
| 303 |
} |
| 304 |
|
| 305 |
|
| 306 |
g.setColor(getPainter().getControlDk()); |
| 307 |
if (contentInsets.right > 0) { |
| 308 |
g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);// right |
| 309 |
} |
| 310 |
if (contentInsets.bottom > 0) { |
| 311 |
g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);// bottom |
| 312 |
} |
| 313 |
|
| 314 |
g.setColor(getPainter().getControlShadow()); |
| 315 |
if (contentInsets.right > 0) { |
| 316 |
g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);// right |
| 317 |
} |
| 318 |
if (contentInsets.bottom > 0) { |
| 319 |
g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 320 |
} |
| 321 |
} |
| 322 |
else { |
| 323 |
super.paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 324 |
} |
| 325 |
} |
| 326 |
else { |
| 327 |
super.paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 328 |
} |
| 329 |
} |
| 330 |
|
| 331 |
// paint the content bottom line when the tab is on the bottom |
| 332 |
@Override |
| 333 |
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { |
| 334 |
if (!PAINT_CONTENT_BORDER_EDGE) { |
| 335 |
return; |
| 336 |
} |
| 337 |
|
| 338 |
if (getColorTheme() != JideTabbedPane.COLOR_THEME_OFFICE2003) { |
| 339 |
super.paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 340 |
return; |
| 341 |
} |
| 342 |
|
| 343 |
if (selectedIndex < 0) { |
| 344 |
return; |
| 345 |
} |
| 346 |
|
| 347 |
Rectangle selRect = getTabBounds(selectedIndex, _calcRect); |
| 348 |
|
| 349 |
Rectangle viewRect = _tabScroller.viewport.getViewRect(); |
| 350 |
Rectangle r = _rects[selectedIndex]; |
| 351 |
|
| 352 |
int tabShape = getTabShape(); |
| 353 |
|
| 354 |
Insets contentInsets = getContentBorderInsets(tabPlacement); |
| 355 |
|
| 356 |
if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) { |
| 357 |
g.setColor(getPainter().getControlShadow()); |
| 358 |
|
| 359 |
if (_alwaysShowLineBorder || _tabPane.hasFocusComponent()) { |
| 360 |
if (contentInsets.left > 0) { |
| 361 |
g.drawLine(x, y, x, y + h - 1);// left |
| 362 |
} |
| 363 |
if (contentInsets.right > 0) { |
| 364 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 365 |
} |
| 366 |
if (contentInsets.top > 0) { |
| 367 |
g.drawLine(x, y, x + w - 1, y);// top |
| 368 |
} |
| 369 |
|
| 370 |
if (contentInsets.bottom > 0 && _tabPane.isTabShown()) { |
| 371 |
if (r.x >= viewRect.x + viewRect.width) { |
| 372 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 373 |
} |
| 374 |
else { |
| 375 |
if (_tabPane.getComponentOrientation().isLeftToRight()) { |
| 376 |
g.drawLine(x, y + h - 1, selRect.x - selRect.height + 2, y + h - 1);// bottom left |
| 377 |
g.drawLine(selRect.x + selRect.width, y + h - 1, x + w - 1, y + h - 1);// bottom right |
| 378 |
} |
| 379 |
else { |
| 380 |
g.drawLine(x, y + h - 1, selRect.x, y + h - 1);// bottom left |
| 381 |
g.drawLine(selRect.x + selRect.width + selRect.height - 3, y + h - 1, x + w - 1, y + h - 1);// bottom right |
| 382 |
} |
| 383 |
} |
| 384 |
|
| 385 |
Rectangle bounds = _tabScroller.viewport.getBounds(); |
| 386 |
g.drawLine(x, y + h - 1, bounds.x, y + h - 1); |
| 387 |
g.drawLine(bounds.x + bounds.width, y + h - 1, x + w - 1, y + h - 1); |
| 388 |
} |
| 389 |
else if (contentInsets.bottom > 0 && !_tabPane.isTabShown()) { |
| 390 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 391 |
} |
| 392 |
} |
| 393 |
else if (_tabPane.isTabShown()) { |
| 394 |
if (r.x >= viewRect.x + viewRect.width) { |
| 395 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 396 |
} |
| 397 |
else { |
| 398 |
if (_tabPane.getComponentOrientation().isLeftToRight()) { |
| 399 |
g.drawLine(x, y + h - 1, selRect.x - selRect.height + 2, y + h - 1);// bottom left |
| 400 |
g.drawLine(selRect.x + selRect.width, y + h - 1, x + w - 1, y + h - 1);// bottom right |
| 401 |
} |
| 402 |
else { |
| 403 |
g.drawLine(x, y + h - 1, selRect.x, y + h - 1);// bottom left |
| 404 |
g.drawLine(selRect.x + selRect.width + selRect.height - 3, y + h - 1, x + w - 1, y + h - 1);// bottom right |
| 405 |
} |
| 406 |
} |
| 407 |
|
| 408 |
Rectangle bounds = _tabScroller.viewport.getBounds(); |
| 409 |
g.drawLine(x, y + h - 1, bounds.x, y + h - 1); |
| 410 |
g.drawLine(bounds.x + bounds.width, y + h - 1, x + w - 1, y + h - 1); |
| 411 |
} |
| 412 |
} |
| 413 |
else if (tabShape == JideTabbedPane.SHAPE_EXCEL) { |
| 414 |
g.setColor(getPainter().getControlShadow()); |
| 415 |
|
| 416 |
g.drawLine(x, y + h - 1, selRect.x - selRect.height / 2 + 4, y + h - 1);// bottom left |
| 417 |
|
| 418 |
if (contentInsets.left > 0) { |
| 419 |
g.drawLine(x, y, x, y + h - 1);// left |
| 420 |
} |
| 421 |
if (contentInsets.right > 0) { |
| 422 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 423 |
} |
| 424 |
if (contentInsets.top > 0) { |
| 425 |
g.drawLine(x, y, x + w - 1, y);// top |
| 426 |
} |
| 427 |
|
| 428 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 429 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 430 |
} |
| 431 |
else { |
| 432 |
if (!_tabPane.isShowIconsOnTab() |
| 433 |
&& !_tabPane.isUseDefaultShowIconsOnTab()) { |
| 434 |
g.drawLine(selRect.x + selRect.width + selRect.height / 2 - 4, |
| 435 |
y + h - 1, x + w - 1, y + h - 1);// bottom right |
| 436 |
} |
| 437 |
else { |
| 438 |
g.drawLine(selRect.x + selRect.width + selRect.height / 2 - 6, |
| 439 |
y + h - 1, x + w - 1, y + h - 1);// bottom right |
| 440 |
} |
| 441 |
} |
| 442 |
} |
| 443 |
else if (tabShape == JideTabbedPane.SHAPE_WINDOWS |
| 444 |
|| tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 445 |
g.setColor(getPainter().getControlShadow()); |
| 446 |
g.drawLine(x + 1, y + h - 1, selRect.x - 2, y + h - 1); |
| 447 |
if (contentInsets.right > 0) { |
| 448 |
g.drawLine(x + w - 1, y + h - 1, x + w - 1, y + 1); |
| 449 |
} |
| 450 |
|
| 451 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 452 |
g.setColor(getPainter().getControlShadow()); |
| 453 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1); |
| 454 |
} |
| 455 |
else { |
| 456 |
g.setColor(getPainter().getControlShadow()); |
| 457 |
g.drawLine(selRect.x + selRect.width, y + h - 1, x + w - 1, y + h - 1); |
| 458 |
g.setColor(getPainter().getControlDk()); |
| 459 |
g.drawLine(selRect.x + selRect.width, y + h - 2, x + w - 2, y + h - 2); |
| 460 |
|
| 461 |
g.setColor(getPainter().getControlDk()); |
| 462 |
g.drawLine(x + 1, y + h - 2, selRect.x - 2, y + h - 2); |
| 463 |
if (contentInsets.right > 0) { |
| 464 |
g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2); |
| 465 |
} |
| 466 |
g.drawLine(selRect.x + selRect.width - 1, y + h - 1, selRect.x + selRect.width - 1, y + h - 1); |
| 467 |
|
| 468 |
// g.setColor(new Color(255, 199, 115)); |
| 469 |
// g.drawLine(selRect.x, y + h - 1, selRect.x + selRect.width - 3, y + h - 1); |
| 470 |
// g.drawLine(selRect.x, y + h - 2, selRect.x + selRect.width, y + h - 2); |
| 471 |
|
| 472 |
g.setColor(new Color(255, 255, 255)); |
| 473 |
g.drawLine(selRect.x - 1, y + h - 1, selRect.x - 1, y + h - 1); |
| 474 |
g.drawLine(selRect.x - 1, y + h - 2, selRect.x - 1, y + h - 2); |
| 475 |
|
| 476 |
if (contentInsets.left > 0) { |
| 477 |
g.drawLine(x, y, x, y + h - 2); |
| 478 |
} |
| 479 |
if (contentInsets.top > 0) { |
| 480 |
g.drawLine(x, y, x + w - 2, y); |
| 481 |
} |
| 482 |
} |
| 483 |
|
| 484 |
} |
| 485 |
else { |
| 486 |
super.paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 487 |
} |
| 488 |
} |
| 489 |
|
| 490 |
// paint the content left line when the tab is on the left |
| 491 |
@Override |
| 492 |
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { |
| 493 |
|
| 494 |
if (!PAINT_CONTENT_BORDER_EDGE) { |
| 495 |
return; |
| 496 |
} |
| 497 |
|
| 498 |
if (getColorTheme() != JideTabbedPane.COLOR_THEME_OFFICE2003) { |
| 499 |
super.paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 500 |
return; |
| 501 |
} |
| 502 |
|
| 503 |
if (selectedIndex < 0) { |
| 504 |
return; |
| 505 |
} |
| 506 |
|
| 507 |
Rectangle selRect = getTabBounds(selectedIndex, _calcRect); |
| 508 |
|
| 509 |
Rectangle viewRect = _tabScroller.viewport.getViewRect(); |
| 510 |
Rectangle r = _rects[selectedIndex]; |
| 511 |
|
| 512 |
int tabShape = getTabShape(); |
| 513 |
|
| 514 |
Insets contentInsets = getContentBorderInsets(tabPlacement); |
| 515 |
|
| 516 |
if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) { |
| 517 |
g.setColor(getPainter().getControlShadow()); |
| 518 |
|
| 519 |
if (_alwaysShowLineBorder || _tabPane.hasFocusComponent()) { |
| 520 |
if (contentInsets.top > 0) { |
| 521 |
g.drawLine(x, y, x + w - 1, y);// top |
| 522 |
} |
| 523 |
if (contentInsets.right > 0) { |
| 524 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 525 |
} |
| 526 |
if (contentInsets.bottom > 0) { |
| 527 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 528 |
} |
| 529 |
|
| 530 |
if (contentInsets.left > 0 && _tabPane.isTabShown()) { |
| 531 |
if (r.y >= viewRect.y + viewRect.height) { |
| 532 |
g.drawLine(x, y, x, y + h - 1);// left |
| 533 |
} |
| 534 |
else { |
| 535 |
g.drawLine(x, y, x, selRect.y - selRect.width + 2);// left top |
| 536 |
g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left bottom |
| 537 |
} |
| 538 |
|
| 539 |
Rectangle bounds = _tabScroller.viewport.getBounds(); |
| 540 |
g.drawLine(x, 0, x, bounds.y); |
| 541 |
g.drawLine(x, bounds.y + bounds.height, x, y + h - 1); |
| 542 |
} |
| 543 |
else if (contentInsets.left > 0 && !_tabPane.isTabShown()) { |
| 544 |
g.drawLine(x, y, x, y + h - 1);// left |
| 545 |
} |
| 546 |
} |
| 547 |
else if (_tabPane.isTabShown()) { |
| 548 |
if (r.y >= viewRect.y + viewRect.height) { |
| 549 |
g.drawLine(x, y, x, y + h - 1);// left |
| 550 |
} |
| 551 |
else { |
| 552 |
g.drawLine(x, y, x, selRect.y - selRect.width + 2);// left top |
| 553 |
g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left bottom |
| 554 |
} |
| 555 |
|
| 556 |
Rectangle bounds = _tabScroller.viewport.getBounds(); |
| 557 |
g.drawLine(x, y, x, bounds.y); |
| 558 |
g.drawLine(x, bounds.y + bounds.height, x, y + h - 1); |
| 559 |
} |
| 560 |
} |
| 561 |
else if (tabShape == JideTabbedPane.SHAPE_EXCEL) { |
| 562 |
g.setColor(getPainter().getControlShadow()); |
| 563 |
|
| 564 |
g.drawLine(x, y, x, selRect.y - selRect.width / 2 + 4);// left top |
| 565 |
|
| 566 |
if (contentInsets.top > 0) { |
| 567 |
g.drawLine(x, y, x + w - 1, y);// top |
| 568 |
} |
| 569 |
if (contentInsets.right > 0) { |
| 570 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 571 |
} |
| 572 |
if (contentInsets.bottom > 0) { |
| 573 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 574 |
} |
| 575 |
|
| 576 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 577 |
g.drawLine(x, y, x, y + h - 1);// left |
| 578 |
} |
| 579 |
else { |
| 580 |
g.drawLine(x, selRect.y + selRect.height + selRect.width / 2 - 4, |
| 581 |
x, y + h - 1);// left bottom |
| 582 |
} |
| 583 |
} |
| 584 |
else if (tabShape == JideTabbedPane.SHAPE_WINDOWS |
| 585 |
|| tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 586 |
g.setColor(getPainter().getControlShadow()); |
| 587 |
if (contentInsets.right > 0) { |
| 588 |
g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);// right |
| 589 |
} |
| 590 |
if (contentInsets.bottom > 0) { |
| 591 |
g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 592 |
} |
| 593 |
|
| 594 |
g.setColor(getPainter().getControlDk()); |
| 595 |
g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2); |
| 596 |
g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); |
| 597 |
|
| 598 |
g.setColor(new Color(255, 255, 255)); |
| 599 |
if (contentInsets.top > 0) { |
| 600 |
g.drawLine(x, y, x + w - 2, y);// top |
| 601 |
} |
| 602 |
g.drawLine(x, y, x, selRect.y - 1); |
| 603 |
|
| 604 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 605 |
g.drawLine(x, y, x, y + h - 2); |
| 606 |
} |
| 607 |
else { |
| 608 |
g.drawLine(x, selRect.y + selRect.height + 1, x, y + h - 2); |
| 609 |
} |
| 610 |
} |
| 611 |
else { |
| 612 |
super.paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 613 |
} |
| 614 |
} |
| 615 |
|
| 616 |
// paint the content right line when the tab is on the right |
| 617 |
@Override |
| 618 |
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { |
| 619 |
if (!PAINT_CONTENT_BORDER_EDGE) { |
| 620 |
return; |
| 621 |
} |
| 622 |
|
| 623 |
if (getColorTheme() != JideTabbedPane.COLOR_THEME_OFFICE2003) { |
| 624 |
super.paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 625 |
return; |
| 626 |
} |
| 627 |
|
| 628 |
if (selectedIndex < 0) { |
| 629 |
return; |
| 630 |
} |
| 631 |
|
| 632 |
Rectangle selRect = getTabBounds(selectedIndex, _calcRect); |
| 633 |
|
| 634 |
Rectangle viewRect = _tabScroller.viewport.getViewRect(); |
| 635 |
Rectangle r = _rects[selectedIndex]; |
| 636 |
|
| 637 |
int tabShape = getTabShape(); |
| 638 |
|
| 639 |
Insets contentInsets = getContentBorderInsets(tabPlacement); |
| 640 |
|
| 641 |
if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) { |
| 642 |
g.setColor(getPainter().getControlShadow()); |
| 643 |
|
| 644 |
if (_alwaysShowLineBorder || _tabPane.hasFocusComponent()) { |
| 645 |
if (contentInsets.top > 0) { |
| 646 |
g.drawLine(x, y, x + w - 1, y);// top |
| 647 |
} |
| 648 |
if (contentInsets.left > 0) { |
| 649 |
g.drawLine(x, y, x, y + h - 1);// left |
| 650 |
} |
| 651 |
if (contentInsets.bottom > 0) { |
| 652 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 653 |
} |
| 654 |
|
| 655 |
if (contentInsets.right > 0 && _tabPane.isTabShown()) { |
| 656 |
if (r.y >= viewRect.y + viewRect.height) { |
| 657 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 658 |
} |
| 659 |
else { |
| 660 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y - selRect.width + 2);// right top |
| 661 |
g.drawLine(x + w - 1, selRect.y + selRect.height, x + w - 1, y + h - 1);// right bottom |
| 662 |
} |
| 663 |
|
| 664 |
Rectangle bounds = _tabScroller.viewport.getBounds(); |
| 665 |
g.drawLine(x + w - 1, 0, x + w - 1, bounds.y); |
| 666 |
g.drawLine(x + w - 1, bounds.y + bounds.height, x + w - 1, y + h - 1); |
| 667 |
} |
| 668 |
else if (contentInsets.right > 0 && !_tabPane.isTabShown()) { |
| 669 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 670 |
} |
| 671 |
} |
| 672 |
else if (_tabPane.isTabShown()) { |
| 673 |
if (r.y >= viewRect.y + viewRect.height) { |
| 674 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 675 |
} |
| 676 |
else { |
| 677 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y - selRect.width + 2);// right top |
| 678 |
g.drawLine(x + w - 1, selRect.y + selRect.height, x + w - 1, y + h - 1);// right bottom |
| 679 |
} |
| 680 |
|
| 681 |
Rectangle bounds = _tabScroller.viewport.getBounds(); |
| 682 |
g.drawLine(x + w - 1, y, x + w - 1, bounds.y); |
| 683 |
g.drawLine(x + w - 1, bounds.y + bounds.height, x + w - 1, y + h - 1); |
| 684 |
} |
| 685 |
} |
| 686 |
else if (tabShape == JideTabbedPane.SHAPE_EXCEL) { |
| 687 |
g.setColor(getPainter().getControlShadow()); |
| 688 |
|
| 689 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y - selRect.width / 2 + 4);// right top |
| 690 |
|
| 691 |
if (contentInsets.top > 0) { |
| 692 |
g.drawLine(x, y, x + w - 1, y);// top |
| 693 |
} |
| 694 |
if (contentInsets.left > 0) { |
| 695 |
g.drawLine(x, y, x, y + h - 1);// left |
| 696 |
} |
| 697 |
if (contentInsets.bottom > 0) { |
| 698 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 699 |
} |
| 700 |
|
| 701 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 702 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 703 |
} |
| 704 |
else { |
| 705 |
g.drawLine(x + w - 1, selRect.y + selRect.height + selRect.width / 2 - 4, x + w - 1, y + h - 1);// right bottom |
| 706 |
} |
| 707 |
} |
| 708 |
else if (tabShape == JideTabbedPane.SHAPE_WINDOWS |
| 709 |
|| tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 710 |
g.setColor(getPainter().getControlDk()); |
| 711 |
g.drawLine(x + w - 2, y + 1, x + w - 2, selRect.y - 2); |
| 712 |
g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); |
| 713 |
|
| 714 |
g.setColor(getPainter().getControlShadow()); |
| 715 |
g.drawLine(x + w - 1, y + 1, x + w - 1, selRect.y - 2); |
| 716 |
if (contentInsets.bottom > 0) { |
| 717 |
g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 718 |
} |
| 719 |
|
| 720 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 721 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1); |
| 722 |
g.setColor(getPainter().getControlDk()); |
| 723 |
g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2); |
| 724 |
} |
| 725 |
else { |
| 726 |
g.drawLine(x + w - 1, selRect.y + selRect.height + 1, x + w - 1, y + h - 1); |
| 727 |
g.setColor(getPainter().getControlDk()); |
| 728 |
g.drawLine(x + w - 2, selRect.y + selRect.height + 2, x + w - 2, y + h - 2); |
| 729 |
g.drawLine(x + w - 1, selRect.y + selRect.height, x + w - 1, selRect.y + selRect.height); |
| 730 |
} |
| 731 |
|
| 732 |
g.setColor(new Color(255, 255, 255)); |
| 733 |
if (contentInsets.top > 0) { |
| 734 |
g.drawLine(x, y, x + w - 1, y);// top |
| 735 |
} |
| 736 |
if (contentInsets.left > 0) { |
| 737 |
g.drawLine(x, y, x, y + h - 1);// left |
| 738 |
} |
| 739 |
} |
| 740 |
else { |
| 741 |
super.paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 742 |
} |
| 743 |
} |
| 744 |
} |