| 1 |
/* |
| 2 |
* @(#)WindowsTabbedPaneUI.java |
| 3 |
* |
| 4 |
* Copyright 2002 JIDE Software Inc. All rights reserved. |
| 5 |
*/ |
| 6 |
|
| 7 |
package com.jidesoft.plaf.vsnet; |
| 8 |
|
| 9 |
import com.jidesoft.plaf.UIDefaultsLookup; |
| 10 |
import com.jidesoft.plaf.basic.BasicJideTabbedPaneUI; |
| 11 |
import com.jidesoft.plaf.basic.ThemePainter; |
| 12 |
import com.jidesoft.swing.JideTabbedPane; |
| 13 |
import com.jidesoft.swing.TabColorProvider; |
| 14 |
import com.jidesoft.utils.ColorUtils; |
| 15 |
|
| 16 |
import javax.swing.*; |
| 17 |
import javax.swing.plaf.ComponentUI; |
| 18 |
import javax.swing.plaf.UIResource; |
| 19 |
import java.awt.*; |
| 20 |
|
| 21 |
/** |
| 22 |
* JideTabbedPane UI implementation |
| 23 |
*/ |
| 24 |
public class VsnetJideTabbedPaneUI extends BasicJideTabbedPaneUI { |
| 25 |
|
| 26 |
protected Color _backgroundSelectedColorStart; |
| 27 |
|
| 28 |
protected Color _backgroundSelectedColorEnd; |
| 29 |
|
| 30 |
protected Color _backgroundUnselectedColorStart; |
| 31 |
|
| 32 |
protected Color _backgroundUnselectedColorEnd; |
| 33 |
|
| 34 |
public static ComponentUI createUI(JComponent c) { |
| 35 |
return new VsnetJideTabbedPaneUI(); |
| 36 |
} |
| 37 |
|
| 38 |
@Override |
| 39 |
public void installColorTheme() { |
| 40 |
super.installColorTheme(); |
| 41 |
|
| 42 |
int tabStyle = getTabShape(); |
| 43 |
int colorTheme = getColorTheme(); |
| 44 |
switch (tabStyle) { |
| 45 |
case JideTabbedPane.SHAPE_BOX: |
| 46 |
if (colorTheme == JideTabbedPane.COLOR_THEME_VSNET) { |
| 47 |
_selectColor1 = _shadow; |
| 48 |
_selectColor2 = _selectColor1; |
| 49 |
} |
| 50 |
else if (colorTheme == JideTabbedPane.COLOR_THEME_WINXP) { |
| 51 |
_selectColor1 = UIDefaultsLookup.getColor("TextArea.selectionBackground"); |
| 52 |
_selectColor2 = _selectColor1; |
| 53 |
} |
| 54 |
_unselectColor1 = getPainter().getControlShadow(); |
| 55 |
|
| 56 |
_unselectColor2 = _lightHighlight; |
| 57 |
break; |
| 58 |
|
| 59 |
case JideTabbedPane.SHAPE_EXCEL: |
| 60 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) { |
| 61 |
_selectColor2 = null; |
| 62 |
_selectColor3 = null; |
| 63 |
_unselectColor2 = _lightHighlight; |
| 64 |
_unselectColor3 = _shadow; |
| 65 |
} |
| 66 |
break; |
| 67 |
case JideTabbedPane.SHAPE_WINDOWS: |
| 68 |
case JideTabbedPane.SHAPE_WINDOWS_SELECTED: |
| 69 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) { |
| 70 |
_selectColor1 = getPainter().getTabbedPaneSelectDk(); |
| 71 |
_selectColor2 = getPainter().getTabbedPaneSelectLt(); |
| 72 |
_selectColor3 = getPainter().getControlDk(); |
| 73 |
_unselectColor1 = getPainter().getControlDk(); |
| 74 |
_unselectColor2 = null; |
| 75 |
_unselectColor3 = null; |
| 76 |
} |
| 77 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) { |
| 78 |
_selectColor1 = getPainter().getTabbedPaneSelectDk(); |
| 79 |
_selectColor2 = getPainter().getTabbedPaneSelectLt(); |
| 80 |
_selectColor3 = getPainter().getControlDk(); |
| 81 |
_unselectColor1 = getPainter().getControlDk(); |
| 82 |
_unselectColor2 = null; |
| 83 |
_unselectColor3 = null; |
| 84 |
} |
| 85 |
break; |
| 86 |
} |
| 87 |
|
| 88 |
installBackgroundColor(); |
| 89 |
} |
| 90 |
|
| 91 |
protected void installBackgroundColor() { |
| 92 |
int colorTheme = getColorTheme(); |
| 93 |
|
| 94 |
switch (getTabShape()) { |
| 95 |
case JideTabbedPane.SHAPE_VSNET: |
| 96 |
_backgroundSelectedColorStart = _highlight; |
| 97 |
_backgroundSelectedColorEnd = _highlight; |
| 98 |
_backgroundUnselectedColorStart = null; |
| 99 |
_backgroundUnselectedColorEnd = null; |
| 100 |
break; |
| 101 |
case JideTabbedPane.SHAPE_ROUNDED_VSNET: |
| 102 |
if (colorTheme == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 103 |
_backgroundSelectedColorStart = _highlight; |
| 104 |
_backgroundSelectedColorEnd = _highlight; |
| 105 |
_backgroundUnselectedColorStart = null; |
| 106 |
_backgroundUnselectedColorEnd = null; |
| 107 |
} |
| 108 |
else { |
| 109 |
_backgroundSelectedColorStart = _background; |
| 110 |
_backgroundSelectedColorEnd = _highlight; |
| 111 |
_backgroundUnselectedColorStart = null; |
| 112 |
_backgroundUnselectedColorEnd = null; |
| 113 |
} |
| 114 |
break; |
| 115 |
case JideTabbedPane.SHAPE_FLAT: |
| 116 |
case JideTabbedPane.SHAPE_ROUNDED_FLAT: |
| 117 |
_backgroundSelectedColorStart = _highlight; |
| 118 |
_backgroundSelectedColorEnd = _highlight; |
| 119 |
_backgroundUnselectedColorStart = _highlight; |
| 120 |
_backgroundUnselectedColorEnd = _highlight; |
| 121 |
break; |
| 122 |
case JideTabbedPane.SHAPE_BOX: |
| 123 |
if (colorTheme == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 124 |
_backgroundSelectedColorStart = _highlight; |
| 125 |
_backgroundSelectedColorEnd = _highlight; |
| 126 |
_backgroundUnselectedColorStart = null; |
| 127 |
_backgroundUnselectedColorEnd = null; |
| 128 |
} |
| 129 |
else if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) { |
| 130 |
_backgroundSelectedColorStart = _lightHighlight; |
| 131 |
_backgroundSelectedColorEnd = _lightHighlight; |
| 132 |
_backgroundUnselectedColorStart = null; |
| 133 |
_backgroundUnselectedColorEnd = null; |
| 134 |
} |
| 135 |
else if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) { |
| 136 |
_backgroundSelectedColorStart = _lightHighlight; |
| 137 |
_backgroundSelectedColorEnd = _highlight; |
| 138 |
_backgroundUnselectedColorStart = null; |
| 139 |
_backgroundUnselectedColorEnd = null; |
| 140 |
} |
| 141 |
break; |
| 142 |
case JideTabbedPane.SHAPE_EXCEL: |
| 143 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 144 |
_backgroundSelectedColorStart = _highlight; |
| 145 |
_backgroundSelectedColorEnd = _highlight; |
| 146 |
_backgroundUnselectedColorStart = _lightHighlight; |
| 147 |
_backgroundUnselectedColorEnd = _lightHighlight; |
| 148 |
} |
| 149 |
else if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) { |
| 150 |
_backgroundSelectedColorStart = _lightHighlight; |
| 151 |
_backgroundSelectedColorEnd = _lightHighlight; |
| 152 |
_backgroundUnselectedColorStart = _highlight; |
| 153 |
_backgroundUnselectedColorEnd = _highlight; |
| 154 |
} |
| 155 |
else /*if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP)*/ { |
| 156 |
_backgroundSelectedColorStart = _lightHighlight; |
| 157 |
_backgroundSelectedColorEnd = _lightHighlight; |
| 158 |
_backgroundUnselectedColorStart = _lightHighlight; |
| 159 |
_backgroundUnselectedColorEnd = _highlight; |
| 160 |
} |
| 161 |
break; |
| 162 |
case JideTabbedPane.SHAPE_WINDOWS: |
| 163 |
case JideTabbedPane.SHAPE_WINDOWS_SELECTED: |
| 164 |
if (colorTheme == JideTabbedPane.COLOR_THEME_VSNET || colorTheme == JideTabbedPane.COLOR_THEME_WINXP) { |
| 165 |
_backgroundSelectedColorStart = _lightHighlight; |
| 166 |
_backgroundSelectedColorEnd = _lightHighlight; |
| 167 |
_backgroundUnselectedColorStart = _lightHighlight; |
| 168 |
_backgroundUnselectedColorEnd = _highlight; |
| 169 |
} |
| 170 |
else /*if (colorTheme == JideTabbedPane.COLOR_THEME_WIN2K)*/ { |
| 171 |
_backgroundSelectedColorStart = _highlight; |
| 172 |
_backgroundSelectedColorEnd = _highlight; |
| 173 |
_backgroundUnselectedColorStart = _highlight; |
| 174 |
_backgroundUnselectedColorEnd = _highlight; |
| 175 |
} |
| 176 |
break; |
| 177 |
case JideTabbedPane.SHAPE_OFFICE2003: |
| 178 |
if (colorTheme == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 179 |
_backgroundSelectedColorStart = _highlight; |
| 180 |
_backgroundSelectedColorEnd = _highlight; |
| 181 |
_backgroundUnselectedColorStart = _highlight; |
| 182 |
_backgroundUnselectedColorEnd = _highlight; |
| 183 |
} |
| 184 |
else if (colorTheme == JideTabbedPane.COLOR_THEME_WINXP) { |
| 185 |
_backgroundSelectedColorStart = _lightHighlight; |
| 186 |
_backgroundSelectedColorEnd = _lightHighlight; |
| 187 |
_backgroundUnselectedColorStart = _lightHighlight; |
| 188 |
_backgroundUnselectedColorEnd = _highlight; |
| 189 |
} |
| 190 |
else { |
| 191 |
_backgroundSelectedColorStart = _lightHighlight; |
| 192 |
_backgroundSelectedColorEnd = _lightHighlight; |
| 193 |
_backgroundUnselectedColorStart = _lightHighlight; |
| 194 |
_backgroundUnselectedColorEnd = _highlight; |
| 195 |
} |
| 196 |
break; |
| 197 |
} |
| 198 |
} |
| 199 |
|
| 200 |
@Override |
| 201 |
public void uninstallColorTheme() { |
| 202 |
super.uninstallColorTheme(); |
| 203 |
|
| 204 |
_backgroundSelectedColorStart = null; |
| 205 |
_backgroundSelectedColorEnd = null; |
| 206 |
_backgroundUnselectedColorStart = null; |
| 207 |
_backgroundUnselectedColorEnd = null; |
| 208 |
} |
| 209 |
|
| 210 |
@Override |
| 211 |
protected void paintTabBackground(Graphics g, int tabPlacement, |
| 212 |
int tabIndex, int x, int y, int w, int h, boolean isSelected) { |
| 213 |
super.paintTabBackground(g, tabPlacement, tabIndex, x, y, w, h, isSelected); |
| 214 |
|
| 215 |
if (tabRegion != null) { |
| 216 |
Color[] colors = getGradientColors(tabIndex, isSelected); |
| 217 |
if (colors != null) { |
| 218 |
getPainter().paintTabBackground(_tabPane, g, tabRegion, colors, SwingConstants.HORIZONTAL, ThemePainter.STATE_DEFAULT); |
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
if (getTabShape() == JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 223 |
if (_mouseEnter && tabIndex == _indexMouseOver && !isSelected && _tabPane.isEnabledAt(_indexMouseOver)) { |
| 224 |
paintTabBackgroundMouseOver(g, tabPlacement, tabIndex, x, y, w, h, isSelected, _backgroundUnselectedColorStart, _backgroundUnselectedColorEnd); |
| 225 |
} |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
@Override |
| 230 |
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, |
| 231 |
int selectedIndex, int x, int y, int w, int h) { |
| 232 |
|
| 233 |
if (!PAINT_CONTENT_BORDER_EDGE) { |
| 234 |
return; |
| 235 |
} |
| 236 |
|
| 237 |
if (selectedIndex < 0 || selectedIndex >= _tabPane.getTabCount()) { |
| 238 |
return; |
| 239 |
} |
| 240 |
|
| 241 |
Rectangle selRect = getTabBounds(selectedIndex, _calcRect); |
| 242 |
|
| 243 |
Rectangle viewRect = _tabScroller.viewport.getViewRect(); |
| 244 |
Rectangle r = _rects[selectedIndex]; |
| 245 |
|
| 246 |
int tabShape = getTabShape(); |
| 247 |
|
| 248 |
Insets contentInsets = getContentBorderInsets(tabPlacement); |
| 249 |
|
| 250 |
if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) { |
| 251 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {// the color set is default |
| 252 |
g.setColor(_shadow); |
| 253 |
} |
| 254 |
else {// the color set is office2003 |
| 255 |
g.setColor(_selectColor1); |
| 256 |
} |
| 257 |
|
| 258 |
if (contentInsets.left > 0) { |
| 259 |
g.drawLine(x, y, x, y + h - 1);// left |
| 260 |
} |
| 261 |
if (contentInsets.right > 0) { |
| 262 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 263 |
} |
| 264 |
if (contentInsets.bottom > 0) { |
| 265 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 266 |
} |
| 267 |
|
| 268 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 269 |
g.drawLine(x, y, x + w - 1, y);// top |
| 270 |
} |
| 271 |
else { |
| 272 |
g.drawLine(x, y, selRect.x - selRect.height + 2, y);// top left |
| 273 |
g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right |
| 274 |
} |
| 275 |
} |
| 276 |
else if (tabShape == JideTabbedPane.SHAPE_EXCEL) { |
| 277 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 278 |
g.setColor(Color.BLACK); |
| 279 |
} |
| 280 |
else {// the color set is vsnet |
| 281 |
g.setColor(getPainter().getControlShadow()); |
| 282 |
} |
| 283 |
|
| 284 |
g.drawLine(x, y, selRect.x - selRect.height / 2 + 4, y);// top left |
| 285 |
|
| 286 |
if (contentInsets.left > 0) { |
| 287 |
g.drawLine(x, y, x, y + h - 1);// left |
| 288 |
} |
| 289 |
if (contentInsets.right > 0) { |
| 290 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 291 |
} |
| 292 |
if (contentInsets.bottom > 0) { |
| 293 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 294 |
} |
| 295 |
|
| 296 |
|
| 297 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 298 |
g.drawLine(x, y, x + w - 1, y);// top |
| 299 |
} |
| 300 |
else { |
| 301 |
if (!_tabPane.isShowIconsOnTab() |
| 302 |
&& !_tabPane.isUseDefaultShowIconsOnTab()) { |
| 303 |
g.drawLine(selRect.x + selRect.width + selRect.height / 2 - 4, |
| 304 |
y, x + w - 1, y);// top right |
| 305 |
} |
| 306 |
else { |
| 307 |
g.drawLine(selRect.x + selRect.width + selRect.height / 2 - 6, |
| 308 |
y, x + w - 1, y);// top right |
| 309 |
} |
| 310 |
} |
| 311 |
} |
| 312 |
else if (tabShape == JideTabbedPane.SHAPE_WINDOWS |
| 313 |
|| tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 314 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET |
| 315 |
|| _tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {// the color set is winxp |
| 316 |
g.setColor(getPainter().getControlDk()); |
| 317 |
} |
| 318 |
else {// the color set is default or office2003 |
| 319 |
g.setColor(getBorderEdgeColor()); |
| 320 |
} |
| 321 |
|
| 322 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET |
| 323 |
|| _tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {// the color set is winxp |
| 324 |
g.drawLine(x, y, selRect.x - 1, y);// top left |
| 325 |
} |
| 326 |
else {// the color set is default or office2003 |
| 327 |
g.drawLine(x, y, selRect.x - 1, y);// top left |
| 328 |
} |
| 329 |
|
| 330 |
if (contentInsets.left > 0) { |
| 331 |
g.drawLine(x, y, x, y + h - 1);// left |
| 332 |
} |
| 333 |
|
| 334 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 335 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET |
| 336 |
|| _tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {// the color set is winxp |
| 337 |
g.setColor(getPainter().getControlDk()); |
| 338 |
} |
| 339 |
else {// the color set is default or office2003 |
| 340 |
g.setColor(_lightHighlight); |
| 341 |
} |
| 342 |
|
| 343 |
g.drawLine(x, y, x + w - 1, y);// top |
| 344 |
} |
| 345 |
else { |
| 346 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET |
| 347 |
|| _tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {// the color set is winxp |
| 348 |
g.setColor(getPainter().getControlDk()); |
| 349 |
g.drawLine(selRect.x + selRect.width + 2, y, x + w - 1, y);// top right |
| 350 |
} |
| 351 |
else {// the color set is default or office2003 |
| 352 |
g.setColor(_lightHighlight); |
| 353 |
g.drawLine(selRect.x + selRect.width + 2, y, x + w - 1, y);// top right |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 357 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 358 |
g.setColor(new Color(115, 109, 99)); |
| 359 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 360 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 361 |
} |
| 362 |
else {// the color set is winxp |
| 363 |
g.setColor(getPainter().getControlDk()); |
| 364 |
|
| 365 |
if (contentInsets.left > 0) { |
| 366 |
g.drawLine(x, y, x, y + h - 1);// left |
| 367 |
} |
| 368 |
if (contentInsets.right > 0) { |
| 369 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 370 |
} |
| 371 |
if (contentInsets.bottom > 0) { |
| 372 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 373 |
} |
| 374 |
} |
| 375 |
} |
| 376 |
else if (tabShape == JideTabbedPane.SHAPE_VSNET) { |
| 377 |
g.setColor(_selectColor1); |
| 378 |
|
| 379 |
// Break line to show visual connection to selected tab |
| 380 |
g.drawLine(x, y, selRect.x, y);// top left |
| 381 |
|
| 382 |
if (contentInsets.left > 0) { |
| 383 |
g.drawLine(x, y, x, y + h - 1);// left |
| 384 |
} |
| 385 |
|
| 386 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 387 |
g.setColor(_selectColor1); |
| 388 |
g.drawLine(x, y, x + w - 1, y);// top |
| 389 |
} |
| 390 |
else { |
| 391 |
g.setColor(_selectColor2); |
| 392 |
g.drawLine(selRect.x + selRect.width - 1, y, selRect.x + selRect.width - 1, y);// a point |
| 393 |
|
| 394 |
g.setColor(_selectColor1); |
| 395 |
g.drawLine(selRect.x, y, selRect.x, y);// a point |
| 396 |
|
| 397 |
g.setColor(_selectColor1); |
| 398 |
g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right |
| 399 |
} |
| 400 |
|
| 401 |
g.setColor(_selectColor2); |
| 402 |
if (contentInsets.right > 0) { |
| 403 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 404 |
} |
| 405 |
if (contentInsets.bottom > 0) { |
| 406 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 407 |
} |
| 408 |
|
| 409 |
} |
| 410 |
else if (tabShape == JideTabbedPane.SHAPE_ROUNDED_VSNET) { |
| 411 |
g.setColor(_selectColor1); |
| 412 |
|
| 413 |
// Break line to show visual connection to selected tab |
| 414 |
g.drawLine(x, y, selRect.x, y);// top left |
| 415 |
|
| 416 |
if (contentInsets.left > 0) { |
| 417 |
g.drawLine(x, y, x, y + h - 1);// left |
| 418 |
} |
| 419 |
|
| 420 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 421 |
g.drawLine(x, y, x + w - 1, y);// top |
| 422 |
} |
| 423 |
else { |
| 424 |
g.drawLine(selRect.x + selRect.width - 1, y, selRect.x + selRect.width - 1, y);// a point |
| 425 |
|
| 426 |
g.drawLine(selRect.x, y, selRect.x, y);// a point |
| 427 |
|
| 428 |
g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right |
| 429 |
} |
| 430 |
|
| 431 |
g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);// right |
| 432 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 433 |
} |
| 434 |
else if (tabShape == JideTabbedPane.SHAPE_FLAT || tabShape == JideTabbedPane.SHAPE_ROUNDED_FLAT) { |
| 435 |
g.setColor(_shadow); |
| 436 |
|
| 437 |
if (contentInsets.left > 0) { |
| 438 |
g.drawLine(x, y, x, y + h - 1);// left |
| 439 |
} |
| 440 |
if (contentInsets.right > 0) { |
| 441 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 442 |
} |
| 443 |
if (contentInsets.bottom > 0) { |
| 444 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 445 |
} |
| 446 |
|
| 447 |
g.drawLine(x, y, selRect.x, y);// top left |
| 448 |
|
| 449 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 450 |
g.drawLine(x, y, x + w - 1, y);// top |
| 451 |
} |
| 452 |
else { |
| 453 |
g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right |
| 454 |
} |
| 455 |
} |
| 456 |
else { |
| 457 |
super.paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 458 |
} |
| 459 |
|
| 460 |
} |
| 461 |
|
| 462 |
@Override |
| 463 |
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, |
| 464 |
int selectedIndex, int x, int y, int w, int h) { |
| 465 |
if (!PAINT_CONTENT_BORDER_EDGE) { |
| 466 |
return; |
| 467 |
} |
| 468 |
|
| 469 |
if (selectedIndex < 0 || selectedIndex >= _tabPane.getTabCount()) { |
| 470 |
return; |
| 471 |
} |
| 472 |
|
| 473 |
Rectangle selRect = getTabBounds(selectedIndex, _calcRect); |
| 474 |
|
| 475 |
Rectangle viewRect = _tabScroller.viewport.getViewRect(); |
| 476 |
Rectangle r = _rects[selectedIndex]; |
| 477 |
|
| 478 |
int tabShape = getTabShape(); |
| 479 |
|
| 480 |
Insets contentInsets = getContentBorderInsets(tabPlacement); |
| 481 |
|
| 482 |
if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) { |
| 483 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {// the color set is default |
| 484 |
g.setColor(_shadow); |
| 485 |
} |
| 486 |
else {// the color set is office2003 |
| 487 |
g.setColor(_selectColor1); |
| 488 |
} |
| 489 |
if (contentInsets.left > 0) { |
| 490 |
g.drawLine(x, y, x, y + h - 1);// left |
| 491 |
} |
| 492 |
if (contentInsets.right > 0) { |
| 493 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 494 |
} |
| 495 |
if (contentInsets.top > 0) { |
| 496 |
g.drawLine(x, y, x + w - 1, y);// top |
| 497 |
} |
| 498 |
|
| 499 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 500 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 501 |
} |
| 502 |
else { |
| 503 |
if (!_tabPane.isTabShown()) { |
| 504 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 505 |
} |
| 506 |
else { |
| 507 |
g.drawLine(x, y + h - 1, selRect.x - selRect.height + 2, y + h - 1);// bottom left |
| 508 |
g.drawLine(selRect.x + selRect.width, y + h - 1, x + w - 1, y + h - 1);// bottom right |
| 509 |
} |
| 510 |
} |
| 511 |
} |
| 512 |
else if (tabShape == JideTabbedPane.SHAPE_EXCEL) { |
| 513 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 514 |
g.setColor(Color.BLACK); |
| 515 |
} |
| 516 |
else {// the color set is vsnet |
| 517 |
g.setColor(getPainter().getControlShadow()); |
| 518 |
} |
| 519 |
|
| 520 |
g.drawLine(x, y + h - 1, selRect.x - selRect.height / 2 + 4, y + h - 1);// bottom left |
| 521 |
|
| 522 |
if (contentInsets.left > 0) { |
| 523 |
g.drawLine(x, y, x, y + h - 1);// left |
| 524 |
} |
| 525 |
if (contentInsets.right > 0) { |
| 526 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 527 |
} |
| 528 |
if (contentInsets.top > 0) { |
| 529 |
g.drawLine(x, y, x + w - 1, y);// top |
| 530 |
} |
| 531 |
|
| 532 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 533 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 534 |
} |
| 535 |
else { |
| 536 |
if (!_tabPane.isShowIconsOnTab() && !_tabPane.isUseDefaultShowIconsOnTab()) { |
| 537 |
g.drawLine(selRect.x + selRect.width + selRect.height / 2 - 4, y + h - 1, x + w - 1, y + h - 1);// bottom right |
| 538 |
} |
| 539 |
else { |
| 540 |
g.drawLine(selRect.x + selRect.width + selRect.height / 2 - 6, y + h - 1, x + w - 1, y + h - 1);// bottom right |
| 541 |
} |
| 542 |
} |
| 543 |
} |
| 544 |
else if (tabShape == JideTabbedPane.SHAPE_WINDOWS |
| 545 |
|| tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 546 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 547 |
g.setColor(new Color(113, 111, 100)); |
| 548 |
g.drawLine(x, y + h - 1, selRect.x - 2, y + h - 1); |
| 549 |
if (contentInsets.right > 0) { |
| 550 |
g.drawLine(x + w - 1, y + h - 1, x + w - 1, y); |
| 551 |
} |
| 552 |
|
| 553 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 554 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1); |
| 555 |
} |
| 556 |
else { |
| 557 |
g.drawLine(selRect.x + selRect.width, y + h - 1, x + w - 1, y + h - 1); |
| 558 |
g.setColor(UIDefaultsLookup.getColor("control")); |
| 559 |
g.drawLine(selRect.x, y + h - 1, selRect.x + selRect.width - 2, y + h - 1); |
| 560 |
g.drawLine(selRect.x, y + h - 2, selRect.x + selRect.width, y + h - 2); |
| 561 |
} |
| 562 |
|
| 563 |
g.setColor(new Color(255, 255, 255)); |
| 564 |
|
| 565 |
if (contentInsets.left > 0) { |
| 566 |
g.drawLine(x, y, x, y + h - 2); |
| 567 |
} |
| 568 |
if (contentInsets.top > 0) { |
| 569 |
g.drawLine(x, y, x + w - 2, y); |
| 570 |
} |
| 571 |
|
| 572 |
} |
| 573 |
else {// the color set is winxp |
| 574 |
g.setColor(getPainter().getControlDk()); |
| 575 |
|
| 576 |
g.drawLine(x, y + h - 1, selRect.x - 1, y + h - 1); |
| 577 |
|
| 578 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 579 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1); |
| 580 |
} |
| 581 |
else { |
| 582 |
g.drawLine(selRect.x + selRect.width + 2, y + h - 1, x + w - 1, y + h - 1); |
| 583 |
} |
| 584 |
|
| 585 |
g.drawLine(selRect.x - 1, y + h - 1, selRect.x - 1, y + h - 1); |
| 586 |
g.drawLine(selRect.x + selRect.width + 2, y + h - 1, selRect.x + selRect.width + 2, y + h - 1); |
| 587 |
|
| 588 |
if (contentInsets.left > 0) { |
| 589 |
g.drawLine(x, y, x, y + h - 2); |
| 590 |
} |
| 591 |
if (contentInsets.top > 0) { |
| 592 |
g.drawLine(x, y, x + w - 2, y); |
| 593 |
} |
| 594 |
if (contentInsets.left > 0) { |
| 595 |
g.drawLine(x + w - 1, y + h - 1, x + w - 1, y); |
| 596 |
} |
| 597 |
} |
| 598 |
} |
| 599 |
else if (tabShape == JideTabbedPane.SHAPE_VSNET) { |
| 600 |
// Break line to show visual connection to selected tab |
| 601 |
g.setColor(_selectColor2); |
| 602 |
g.drawLine(x, y + h - 1, selRect.x - 1, y + h - 1);// bottom left |
| 603 |
|
| 604 |
g.setColor(_selectColor1); |
| 605 |
g.drawLine(selRect.x, y + h - 1, selRect.x, y + h - 1); |
| 606 |
|
| 607 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 608 |
g.setColor(_selectColor2); |
| 609 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 610 |
} |
| 611 |
else { |
| 612 |
g.setColor(_selectColor2); |
| 613 |
g.drawLine(selRect.x + selRect.width - 1, y + h - 1, x + w - 2, y |
| 614 |
+ h - 1); // bottom right |
| 615 |
} |
| 616 |
|
| 617 |
g.setColor(_selectColor2); |
| 618 |
if (contentInsets.right > 0) { |
| 619 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 620 |
} |
| 621 |
|
| 622 |
g.setColor(_selectColor1); |
| 623 |
if (contentInsets.left > 0) { |
| 624 |
g.drawLine(x, y, x, y + h - 2);// left |
| 625 |
} |
| 626 |
if (contentInsets.top > 0) { |
| 627 |
g.drawLine(x, y, x + w - 2, y);// top |
| 628 |
} |
| 629 |
} |
| 630 |
else if (tabShape == JideTabbedPane.SHAPE_ROUNDED_VSNET) { |
| 631 |
// Break line to show visual connection to selected tab |
| 632 |
g.setColor(_selectColor1); |
| 633 |
g.drawLine(x, y + h - 1, selRect.x - 1, y + h - 1);// bottom left |
| 634 |
|
| 635 |
g.drawLine(selRect.x, y + h - 1, selRect.x, y + h - 1); |
| 636 |
|
| 637 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 638 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 639 |
} |
| 640 |
else { |
| 641 |
g.drawLine(selRect.x + selRect.width - 1, y + h - 1, x + w - 2, y |
| 642 |
+ h - 1); // bottom right |
| 643 |
} |
| 644 |
|
| 645 |
if (contentInsets.left > 0) { |
| 646 |
g.drawLine(x, y, x, y + h - 2);// left |
| 647 |
} |
| 648 |
if (contentInsets.right > 0) { |
| 649 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 650 |
} |
| 651 |
if (contentInsets.top > 0) { |
| 652 |
g.drawLine(x, y, x + w - 2, y);// top |
| 653 |
} |
| 654 |
} |
| 655 |
else if (tabShape == JideTabbedPane.SHAPE_FLAT |
| 656 |
|| tabShape == JideTabbedPane.SHAPE_ROUNDED_FLAT) { |
| 657 |
g.setColor(_shadow); |
| 658 |
g.drawLine(x, y + h - 1, selRect.x - 1, y + h - 1);// bottom left |
| 659 |
if (contentInsets.left > 0) { |
| 660 |
g.drawLine(x, y, x, y + h - 1);// left |
| 661 |
} |
| 662 |
if (contentInsets.right > 0) { |
| 663 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 664 |
} |
| 665 |
if (contentInsets.top > 0) { |
| 666 |
g.drawLine(x, y, x + w - 1, y);// top |
| 667 |
} |
| 668 |
g.drawLine(selRect.x, y + h - 1, selRect.x, y + h - 1);// a point |
| 669 |
|
| 670 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 671 |
g.drawLine(x, y + h - 1, x + w - 2, y + h - 1);// bottom |
| 672 |
} |
| 673 |
else { |
| 674 |
g.drawLine(selRect.x + selRect.width, y + h - 1, x + w - 2, y + h - 1);// bottom right |
| 675 |
} |
| 676 |
} |
| 677 |
else { |
| 678 |
super.paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 679 |
} |
| 680 |
} |
| 681 |
|
| 682 |
@Override |
| 683 |
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, |
| 684 |
int selectedIndex, int x, int y, int w, int h) { |
| 685 |
|
| 686 |
if (!PAINT_CONTENT_BORDER_EDGE) { |
| 687 |
return; |
| 688 |
} |
| 689 |
|
| 690 |
if (selectedIndex < 0 || selectedIndex >= _tabPane.getTabCount()) { |
| 691 |
return; |
| 692 |
} |
| 693 |
|
| 694 |
Rectangle selRect = getTabBounds(selectedIndex, _calcRect); |
| 695 |
|
| 696 |
Rectangle viewRect = _tabScroller.viewport.getViewRect(); |
| 697 |
Rectangle r = _rects[selectedIndex]; |
| 698 |
|
| 699 |
int tabShape = getTabShape(); |
| 700 |
|
| 701 |
Insets contentInsets = getContentBorderInsets(tabPlacement); |
| 702 |
|
| 703 |
if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) { |
| 704 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {// the color set is default |
| 705 |
g.setColor(_shadow); |
| 706 |
} |
| 707 |
else {// the color set is office2003 |
| 708 |
g.setColor(_selectColor1); |
| 709 |
} |
| 710 |
|
| 711 |
if (contentInsets.top > 0) { |
| 712 |
g.drawLine(x, y, x + w - 1, y);// top |
| 713 |
} |
| 714 |
if (contentInsets.right > 0) { |
| 715 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 716 |
} |
| 717 |
if (contentInsets.bottom > 0) { |
| 718 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 719 |
} |
| 720 |
|
| 721 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 722 |
g.drawLine(x, y, x, y + h - 1);// left |
| 723 |
} |
| 724 |
else { |
| 725 |
g.drawLine(x, y, x, selRect.y - selRect.width + 2);// left top |
| 726 |
g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left bottom |
| 727 |
} |
| 728 |
} |
| 729 |
else if (tabShape == JideTabbedPane.SHAPE_EXCEL) { |
| 730 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 731 |
g.setColor(Color.BLACK); |
| 732 |
} |
| 733 |
else {// the color set is vsnet |
| 734 |
g.setColor(getPainter().getControlShadow()); |
| 735 |
} |
| 736 |
|
| 737 |
g.drawLine(x, y, x, selRect.y - selRect.width / 2 + 4);// left top |
| 738 |
|
| 739 |
if (contentInsets.top > 0) { |
| 740 |
g.drawLine(x, y, x + w - 1, y);// top |
| 741 |
} |
| 742 |
if (contentInsets.right > 0) { |
| 743 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 744 |
} |
| 745 |
if (contentInsets.bottom > 0) { |
| 746 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 747 |
} |
| 748 |
|
| 749 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 750 |
g.drawLine(x, y, x, y + h - 1);// left |
| 751 |
} |
| 752 |
else { |
| 753 |
g.drawLine(x, selRect.y + selRect.height + selRect.width / 2 - 4, x, y + h - 1);// left bottom |
| 754 |
} |
| 755 |
} |
| 756 |
else if (tabShape == JideTabbedPane.SHAPE_WINDOWS |
| 757 |
|| tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 758 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 759 |
g.setColor(new Color(115, 109, 99)); |
| 760 |
if (contentInsets.right > 0) { |
| 761 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 762 |
} |
| 763 |
if (contentInsets.bottom > 0) { |
| 764 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 765 |
} |
| 766 |
|
| 767 |
g.setColor(new Color(255, 255, 255)); |
| 768 |
if (contentInsets.top > 0) { |
| 769 |
g.drawLine(x, y, x + w - 2, y); |
| 770 |
} |
| 771 |
g.drawLine(x, y, x, selRect.y - 1); |
| 772 |
|
| 773 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 774 |
g.drawLine(x, y, x, y + h - 2); |
| 775 |
} |
| 776 |
else { |
| 777 |
g.drawLine(x, selRect.y + selRect.height + 1, x, y + h - 2); |
| 778 |
} |
| 779 |
|
| 780 |
} |
| 781 |
else {// the color set is winxp |
| 782 |
g.setColor(getPainter().getControlDk()); |
| 783 |
|
| 784 |
if (contentInsets.top > 0) { |
| 785 |
g.drawLine(x, y, x + w - 1, y);// top |
| 786 |
} |
| 787 |
if (contentInsets.right > 0) { |
| 788 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 789 |
} |
| 790 |
if (contentInsets.bottom > 0) { |
| 791 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 792 |
} |
| 793 |
g.drawLine(x, y, x, selRect.y - 2); |
| 794 |
|
| 795 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 796 |
g.drawLine(x, y, x, y + h - 2); |
| 797 |
} |
| 798 |
else { |
| 799 |
g.drawLine(x, selRect.y + selRect.height + 2, x, y + h - 2); |
| 800 |
} |
| 801 |
} |
| 802 |
} |
| 803 |
else if (tabShape == JideTabbedPane.SHAPE_VSNET) { |
| 804 |
g.setColor(_selectColor1); |
| 805 |
|
| 806 |
// Break line to show visual connection to selected tab |
| 807 |
g.drawLine(x, y, x, selRect.y);// left top |
| 808 |
|
| 809 |
if (contentInsets.top > 0) { |
| 810 |
g.drawLine(x, y, x + w - 1, y);// top |
| 811 |
} |
| 812 |
|
| 813 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 814 |
g.setColor(_selectColor1); |
| 815 |
g.drawLine(x, y, x, y + h - 1);// left |
| 816 |
} |
| 817 |
else { |
| 818 |
g.setColor(_selectColor1); |
| 819 |
g.drawLine(x, selRect.y, x, selRect.y);// a point |
| 820 |
|
| 821 |
g.setColor(_selectColor2); |
| 822 |
g.drawLine(x, selRect.y + selRect.height - 1, x, selRect.y + selRect.height - 1);// a point |
| 823 |
|
| 824 |
g.setColor(_selectColor1); |
| 825 |
g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left |
| 826 |
// bottom |
| 827 |
} |
| 828 |
|
| 829 |
g.setColor(_selectColor2); |
| 830 |
if (contentInsets.right > 0) { |
| 831 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 832 |
} |
| 833 |
if (contentInsets.bottom > 0) { |
| 834 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 835 |
} |
| 836 |
} |
| 837 |
else if (tabShape == JideTabbedPane.SHAPE_ROUNDED_VSNET) { |
| 838 |
g.setColor(_selectColor1); |
| 839 |
|
| 840 |
// Break line to show visual connection to selected tab |
| 841 |
g.drawLine(x, y, x, selRect.y);// left top |
| 842 |
|
| 843 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 844 |
g.drawLine(x, y, x, y + h - 1);// left |
| 845 |
} |
| 846 |
else { |
| 847 |
g.drawLine(x, selRect.y, x, selRect.y);// a point |
| 848 |
g.drawLine(x, selRect.y + selRect.height - 1, x, selRect.y + selRect.height - 1);// a point |
| 849 |
g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left |
| 850 |
// bottom |
| 851 |
} |
| 852 |
|
| 853 |
if (contentInsets.top > 0) { |
| 854 |
g.drawLine(x, y, x + w - 1, y);// top |
| 855 |
} |
| 856 |
if (contentInsets.right > 0) { |
| 857 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 858 |
} |
| 859 |
if (contentInsets.bottom > 0) { |
| 860 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 861 |
} |
| 862 |
} |
| 863 |
else if (tabShape == JideTabbedPane.SHAPE_FLAT || tabShape == JideTabbedPane.SHAPE_ROUNDED_FLAT) { |
| 864 |
g.setColor(_shadow); |
| 865 |
if (contentInsets.top > 0) { |
| 866 |
g.drawLine(x, y, x + w - 1, y);// top |
| 867 |
} |
| 868 |
if (contentInsets.right > 0) { |
| 869 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 870 |
} |
| 871 |
if (contentInsets.bottom > 0) { |
| 872 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 873 |
} |
| 874 |
g.drawLine(x, y, x, selRect.y);// left top |
| 875 |
|
| 876 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 877 |
g.drawLine(x, y, x, y + h - 1);// left |
| 878 |
} |
| 879 |
else { |
| 880 |
g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left bottom |
| 881 |
} |
| 882 |
} |
| 883 |
else { |
| 884 |
super.paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 885 |
} |
| 886 |
} |
| 887 |
|
| 888 |
@Override |
| 889 |
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, |
| 890 |
int selectedIndex, int x, int y, int w, int h) { |
| 891 |
|
| 892 |
if (!PAINT_CONTENT_BORDER_EDGE) { |
| 893 |
return; |
| 894 |
} |
| 895 |
|
| 896 |
if (selectedIndex < 0 || selectedIndex >= _tabPane.getTabCount()) { |
| 897 |
return; |
| 898 |
} |
| 899 |
|
| 900 |
Rectangle selRect = getTabBounds(selectedIndex, _calcRect); |
| 901 |
|
| 902 |
Rectangle viewRect = _tabScroller.viewport.getViewRect(); |
| 903 |
Rectangle r = _rects[selectedIndex]; |
| 904 |
|
| 905 |
int tabShape = getTabShape(); |
| 906 |
|
| 907 |
Insets contentInsets = getContentBorderInsets(tabPlacement); |
| 908 |
|
| 909 |
if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) { |
| 910 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {// the color set is default |
| 911 |
g.setColor(_shadow); |
| 912 |
} |
| 913 |
else {// the color set is office2003 |
| 914 |
g.setColor(_selectColor1); |
| 915 |
} |
| 916 |
|
| 917 |
if (contentInsets.top > 0) { |
| 918 |
g.drawLine(x, y, x + w - 1, y);// top |
| 919 |
} |
| 920 |
if (contentInsets.left > 0) { |
| 921 |
g.drawLine(x, y, x, y + h - 1);// left |
| 922 |
} |
| 923 |
if (contentInsets.bottom > 0) { |
| 924 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 925 |
} |
| 926 |
|
| 927 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 928 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 929 |
} |
| 930 |
else { |
| 931 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y - selRect.width + 2);// right top |
| 932 |
g.drawLine(x + w - 1, selRect.y + selRect.height, x + w - 1, y + h - 1);// right bottom |
| 933 |
} |
| 934 |
} |
| 935 |
else if (tabShape == JideTabbedPane.SHAPE_EXCEL) { |
| 936 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 937 |
g.setColor(Color.BLACK); |
| 938 |
} |
| 939 |
else {// the color set is vsnet |
| 940 |
g.setColor(getPainter().getControlShadow()); |
| 941 |
} |
| 942 |
|
| 943 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y - selRect.width / 2 + 4);// right top |
| 944 |
|
| 945 |
if (contentInsets.top > 0) { |
| 946 |
g.drawLine(x, y, x + w - 1, y);// top |
| 947 |
} |
| 948 |
if (contentInsets.left > 0) { |
| 949 |
g.drawLine(x, y, x, y + h - 1);// left |
| 950 |
} |
| 951 |
if (contentInsets.bottom > 0) { |
| 952 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 953 |
} |
| 954 |
|
| 955 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 956 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 957 |
} |
| 958 |
else { |
| 959 |
g.drawLine(x + w - 1, selRect.y + selRect.height + selRect.width / 2 - 4, x + w - 1, y + h - 1);// right bottom |
| 960 |
} |
| 961 |
} |
| 962 |
else if (tabShape == JideTabbedPane.SHAPE_WINDOWS |
| 963 |
|| tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 964 |
if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 965 |
|
| 966 |
g.setColor(new Color(115, 109, 99)); |
| 967 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y - 2); |
| 968 |
if (contentInsets.bottom > 0) { |
| 969 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 970 |
} |
| 971 |
|
| 972 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 973 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1); |
| 974 |
g.setColor(new Color(173, 170, 156)); |
| 975 |
g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2); |
| 976 |
} |
| 977 |
else { |
| 978 |
g.drawLine(x + w - 1, selRect.y + selRect.height + 1, x + w - 1, y + h - 1); |
| 979 |
g.setColor(UIDefaultsLookup.getColor("control")); |
| 980 |
g.drawLine(x + w - 1, selRect.y, x + w - 1, selRect.y + selRect.height - 1); |
| 981 |
g.drawLine(x + w - 2, selRect.y, x + w - 2, selRect.y + selRect.height + 1); |
| 982 |
} |
| 983 |
|
| 984 |
g.setColor(new Color(255, 255, 255)); |
| 985 |
if (contentInsets.top > 0) { |
| 986 |
g.drawLine(x, y, x + w - 2, y);// top |
| 987 |
} |
| 988 |
if (contentInsets.left > 0) { |
| 989 |
g.drawLine(x, y, x, y + h - 2);// left |
| 990 |
} |
| 991 |
} |
| 992 |
else {// the color set is winxp |
| 993 |
g.setColor(getPainter().getControlDk()); |
| 994 |
if (contentInsets.top > 0) { |
| 995 |
g.drawLine(x, y, x + w - 1, y);// top |
| 996 |
} |
| 997 |
if (contentInsets.left > 0) { |
| 998 |
g.drawLine(x, y, x, y + h - 1);// left |
| 999 |
} |
| 1000 |
if (contentInsets.bottom > 0) { |
| 1001 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 1002 |
} |
| 1003 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y - 2); |
| 1004 |
|
| 1005 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 1006 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 2); |
| 1007 |
} |
| 1008 |
else { |
| 1009 |
g.drawLine(x + w - 1, selRect.y + selRect.height + 2, x + w - 1, y + h - 2); |
| 1010 |
} |
| 1011 |
|
| 1012 |
} |
| 1013 |
} |
| 1014 |
else if (tabShape == JideTabbedPane.SHAPE_VSNET) { |
| 1015 |
g.setColor(getBorderEdgeColor()); |
| 1016 |
|
| 1017 |
// Break line to show visual connection to selected tab |
| 1018 |
g.setColor(_selectColor2); |
| 1019 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y);// right top |
| 1020 |
if (contentInsets.bottom > 0) { |
| 1021 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 1022 |
} |
| 1023 |
|
| 1024 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 1025 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 1026 |
} |
| 1027 |
else { |
| 1028 |
g.setColor(_selectColor2); |
| 1029 |
g.drawLine(x + w - 1, selRect.y + selRect.height - 1, x + w - 1, selRect.y + selRect.height - 1);// a point |
| 1030 |
g.drawLine(x + w - 1, selRect.y + selRect.height, x + w - 1, y + h - 1);// right bottom |
| 1031 |
} |
| 1032 |
|
| 1033 |
g.setColor(_selectColor1); |
| 1034 |
if (contentInsets.top > 0) { |
| 1035 |
g.drawLine(x, y, x + w - 2, y);// top |
| 1036 |
} |
| 1037 |
if (contentInsets.left > 0) { |
| 1038 |
g.drawLine(x, y, x, y + h - 2);// left |
| 1039 |
} |
| 1040 |
} |
| 1041 |
else if (tabShape == JideTabbedPane.SHAPE_ROUNDED_VSNET) { |
| 1042 |
g.setColor(_selectColor1); |
| 1043 |
|
| 1044 |
// Break line to show visual connection to selected tab |
| 1045 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y - 1);// right top |
| 1046 |
|
| 1047 |
if (!_tabPane.isTabShown() || r.x >= viewRect.x + viewRect.width) { |
| 1048 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 1049 |
} |
| 1050 |
else { |
| 1051 |
g.drawLine(x + w - 1, selRect.y, x + w - 1, selRect.y);// a point |
| 1052 |
g.drawLine(x + w - 1, selRect.y + selRect.height - 1, x + w - 1, selRect.y + selRect.height - 1);// a point |
| 1053 |
g.drawLine(x + w - 1, selRect.y + selRect.height, x + w - 1, y + h - 1);// right bottom |
| 1054 |
} |
| 1055 |
|
| 1056 |
if (contentInsets.top > 0) { |
| 1057 |
g.drawLine(x, y, x + w - 1, y);// top |
| 1058 |
} |
| 1059 |
if (contentInsets.left > 0) { |
| 1060 |
g.drawLine(x, y, x, y + h - 2);// left |
| 1061 |
} |
| 1062 |
if (contentInsets.bottom > 0) { |
| 1063 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 1064 |
} |
| 1065 |
} |
| 1066 |
else if (tabShape == JideTabbedPane.SHAPE_FLAT |
| 1067 |
|| tabShape == JideTabbedPane.SHAPE_ROUNDED_FLAT) { |
| 1068 |
g.setColor(_shadow); |
| 1069 |
|
| 1070 |
if (contentInsets.top > 0) { |
| 1071 |
g.drawLine(x, y, x + w - 1, y);// top |
| 1072 |
} |
| 1073 |
if (contentInsets.left > 0) { |
| 1074 |
g.drawLine(x, y, x, y + h - 1);// left |
| 1075 |
} |
| 1076 |
if (contentInsets.bottom > 0) { |
| 1077 |
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom |
| 1078 |
} |
| 1079 |
g.drawLine(x + w - 1, y, x + w - 1, selRect.y);// right top |
| 1080 |
|
| 1081 |
if (!_tabPane.isTabShown() || r.y >= viewRect.y + viewRect.height) { |
| 1082 |
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right |
| 1083 |
} |
| 1084 |
else { |
| 1085 |
g.drawLine(x + w - 1, selRect.y + selRect.height, x + w - 1, y + h - 1);// right bottom |
| 1086 |
} |
| 1087 |
} |
| 1088 |
else { |
| 1089 |
super.paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h); |
| 1090 |
} |
| 1091 |
} |
| 1092 |
|
| 1093 |
@Override |
| 1094 |
protected void paintContentBorder(Graphics g, int x, int y, int w, int h) { |
| 1095 |
if (!PAINT_CONTENT_BORDER) { |
| 1096 |
return; |
| 1097 |
} |
| 1098 |
|
| 1099 |
Insets insets = getContentBorderInsets(_tabPane.getTabPlacement()); |
| 1100 |
|
| 1101 |
Color backgroundAt = null; |
| 1102 |
int selectedIndex = _tabPane.getSelectedIndex(); |
| 1103 |
if (selectedIndex < 0 || selectedIndex >= _tabPane.getTabCount()) { |
| 1104 |
return; |
| 1105 |
} |
| 1106 |
|
| 1107 |
Component comp = selectedIndex == -1 ? null : _tabPane.getComponentAt(selectedIndex); |
| 1108 |
if (comp instanceof TabColorProvider) { |
| 1109 |
backgroundAt = ((TabColorProvider) comp).getTabBackground(); |
| 1110 |
} |
| 1111 |
JideTabbedPane.ColorProvider colorProvider = _tabPane.getTabColorProvider(); |
| 1112 |
boolean useDefault = true; |
| 1113 |
if (colorProvider != null || backgroundAt != null) { |
| 1114 |
if (backgroundAt == null) { |
| 1115 |
backgroundAt = _tabPane.getBackground(); |
| 1116 |
if (selectedIndex != -1) |
| 1117 |
backgroundAt = colorProvider.getBackgroundAt(selectedIndex); |
| 1118 |
} |
| 1119 |
if (backgroundAt != null) { |
| 1120 |
g.setColor(backgroundAt); |
| 1121 |
g.fillRect(x, y, w, h); |
| 1122 |
useDefault = false; |
| 1123 |
} |
| 1124 |
} |
| 1125 |
|
| 1126 |
if (useDefault) { |
| 1127 |
Color[] colors = getGradientColors(selectedIndex, true); |
| 1128 |
if (colors != null) { |
| 1129 |
g.setColor(colors[1]); |
| 1130 |
g.fillRect(x, y, w, insets.top); // top |
| 1131 |
g.fillRect(x, y, insets.left, h); // left |
| 1132 |
g.fillRect(x, y + h - insets.bottom, w, insets.bottom); // bottom |
| 1133 |
g.fillRect(x + w - insets.right, y, insets.right, h); // right |
| 1134 |
} |
| 1135 |
} |
| 1136 |
} |
| 1137 |
|
| 1138 |
protected Color[] getGradientColors(int tabIndex, boolean isSelected) { |
| 1139 |
Color backgroundEnd = null; |
| 1140 |
Color backgroundStart = null; |
| 1141 |
|
| 1142 |
Boolean highContrast = UIManager.getBoolean("Theme.highContrast"); |
| 1143 |
if (highContrast) { |
| 1144 |
backgroundStart = isSelected ? UIDefaultsLookup.getColor("JideButton.selectedBackground") : UIDefaultsLookup.getColor("JideButton.background"); |
| 1145 |
backgroundEnd = backgroundStart; |
| 1146 |
} |
| 1147 |
else { |
| 1148 |
Color color = null; |
| 1149 |
Component comp = null; |
| 1150 |
if (tabIndex >= 0 && tabIndex < _tabPane.getTabCount()) { |
| 1151 |
comp = _tabPane.getComponentAt(tabIndex); |
| 1152 |
} |
| 1153 |
if (comp instanceof TabColorProvider) { |
| 1154 |
color = ((TabColorProvider) comp).getTabBackground(); |
| 1155 |
} |
| 1156 |
JideTabbedPane.ColorProvider colorProvider = _tabPane.getTabColorProvider(); |
| 1157 |
if (color == null && colorProvider != null) { |
| 1158 |
backgroundEnd = colorProvider.getBackgroundAt(tabIndex); |
| 1159 |
if (colorProvider instanceof JideTabbedPane.GradientColorProvider) { |
| 1160 |
backgroundStart = ((JideTabbedPane.GradientColorProvider) colorProvider).getTopBackgroundAt(tabIndex); |
| 1161 |
} |
| 1162 |
else { |
| 1163 |
backgroundStart = backgroundEnd != null ? ColorUtils.getDerivedColor(backgroundEnd, colorProvider.getGradientRatio(tabIndex)) : null; |
| 1164 |
} |
| 1165 |
} |
| 1166 |
else { |
| 1167 |
if (color == null) { |
| 1168 |
color = _tabPane.getBackground(); |
| 1169 |
if (tabIndex != -1) |
| 1170 |
color = _tabPane.getBackgroundAt(tabIndex); |
| 1171 |
} |
| 1172 |
if (!(color instanceof UIResource) && color != _tabPane.getBackground()) { |
| 1173 |
backgroundEnd = color; |
| 1174 |
if (getColorTheme() == JideTabbedPane.COLOR_THEME_OFFICE2003) { |
| 1175 |
backgroundStart = ColorUtils.getDerivedColor(color, 0.8f); |
| 1176 |
} |
| 1177 |
else { |
| 1178 |
backgroundStart = color; |
| 1179 |
} |
| 1180 |
} |
| 1181 |
} |
| 1182 |
|
| 1183 |
if (isSelected) { |
| 1184 |
if (showFocusIndicator()) { |
| 1185 |
if (backgroundEnd == null) { |
| 1186 |
backgroundEnd = _backgroundSelectedColorEnd; |
| 1187 |
} |
| 1188 |
if (backgroundStart == null) { |
| 1189 |
backgroundStart = _backgroundSelectedColorStart; |
| 1190 |
} |
| 1191 |
} |
| 1192 |
else { |
| 1193 |
if (getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) { |
| 1194 |
if (backgroundEnd == null) { |
| 1195 |
backgroundEnd = _backgroundSelectedColorEnd; |
| 1196 |
} |
| 1197 |
if (backgroundStart == null) { |
| 1198 |
backgroundStart = _backgroundSelectedColorStart; |
| 1199 |
} |
| 1200 |
} |
| 1201 |
else { |
| 1202 |
if (backgroundEnd == null) { |
| 1203 |
backgroundEnd = ColorUtils.getDerivedColor(_backgroundUnselectedColorEnd, 0.7f); |
| 1204 |
} |
| 1205 |
if (backgroundStart == null) { |
| 1206 |
backgroundStart = ColorUtils.getDerivedColor(_backgroundUnselectedColorStart, 0.8f); |
| 1207 |
} |
| 1208 |
} |
| 1209 |
} |
| 1210 |
} |
| 1211 |
else { |
| 1212 |
if (getTabShape() != JideTabbedPane.SHAPE_WINDOWS_SELECTED) { |
| 1213 |
if (backgroundEnd == null) { |
| 1214 |
backgroundEnd = _backgroundUnselectedColorEnd; |
| 1215 |
} |
| 1216 |
if (backgroundStart == null) { |
| 1217 |
backgroundStart = _backgroundUnselectedColorStart; |
| 1218 |
} |
| 1219 |
} |
| 1220 |
} |
| 1221 |
} |
| 1222 |
return new Color[]{backgroundStart, backgroundEnd}; |
| 1223 |
} |
| 1224 |
} |