1. /*
  2. * @(#)TabContext.java 1.6 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.gtk;
  8. import javax.swing.*;
  9. /**
  10. * @version 1.6, 01/23/03
  11. * @author Scott Violet
  12. */
  13. class TabContext extends SynthContext {
  14. private int tabIndex;
  15. public int getTabIndex() {
  16. return tabIndex;
  17. }
  18. void update(int index, boolean selected, boolean isMouseOver, boolean hasFocus) {
  19. tabIndex = index;
  20. JTabbedPane tp = (JTabbedPane)getComponent();
  21. int state = 0;
  22. if (!tp.isEnabledAt(index)) {
  23. state |= SynthConstants.DISABLED;
  24. }
  25. else if (selected) {
  26. state |= (SynthConstants.ENABLED | SynthConstants.SELECTED);
  27. }
  28. else if (isMouseOver) {
  29. state |= (SynthConstants.ENABLED | SynthConstants.MOUSE_OVER);
  30. }
  31. else {
  32. state = SynthLookAndFeel.getComponentState(tp);
  33. state &= ~SynthConstants.FOCUSED; // don't use tabbedpane focus state
  34. }
  35. if (hasFocus) {
  36. state |= SynthConstants.FOCUSED; // individual tab has focus
  37. }
  38. setComponentState(state);
  39. }
  40. }