コード例 #1
0
  public void paint(Graphics g, JComponent c) {
    Dimension s = c.getSize();
    if (WindowsMenuItemUI.isVistaPainting()) {
      int x = 1;
      Component parent = c.getParent();
      if (parent instanceof JComponent) {
        Object gutterOffsetObject =
            ((JComponent) parent).getClientProperty(WindowsPopupMenuUI.GUTTER_OFFSET_KEY);
        if (gutterOffsetObject instanceof Integer) {
          /*
           * gutter offset is in parent's coordinates.
           * See comment in
           * WindowsPopupMenuUI.getTextOffset(JComponent)
           */
          x = ((Integer) gutterOffsetObject).intValue() - c.getX();
          x += WindowsPopupMenuUI.getGutterWidth();
        }
      }
      Skin skin = XPStyle.getXP().getSkin(c, Part.MP_POPUPSEPARATOR);
      int skinHeight = skin.getHeight();
      int y = (s.height - skinHeight) / 2;
      skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL);
    } else {
      int y = s.height / 2;
      g.setColor(c.getForeground());
      g.drawLine(1, y - 1, s.width - 2, y - 1);

      g.setColor(c.getBackground());
      g.drawLine(1, y, s.width - 2, y);
    }
  }
コード例 #2
0
  public void installUI(JComponent c) {
    super.installUI(c);

    if (XPStyle.getXP() != null) {
      originalHeaderRenderer = header.getDefaultRenderer();
      if (originalHeaderRenderer instanceof UIResource) {
        header.setDefaultRenderer(new XPDefaultRenderer());
      }
    }
  }
コード例 #3
0
  /**
   * Renders a text String in Windows without the mnemonic. This is here because the WindowsUI
   * hiearchy doesn't match the Component heirarchy. All the overriden paintText methods of the
   * ButtonUI delegates will call this static method.
   *
   * <p>
   *
   * @param g Graphics context
   * @param b Current button to render
   * @param textRect Bounding rectangle to render the text.
   * @param text String to render
   */
  public static void paintText(
      Graphics g, AbstractButton b, Rectangle textRect, String text, int textShiftOffset) {
    ButtonModel model = b.getModel();
    FontMetrics fm = g.getFontMetrics();

    int mnemIndex = b.getDisplayedMnemonicIndex();
    // W2K Feature: Check to see if the Underscore should be rendered.
    if (WindowsLookAndFeel.isMnemonicHidden() == true) {
      mnemIndex = -1;
    }

    /* Draw the Text */
    Color color = b.getForeground();
    if (model.isEnabled()) {
      /** * paint the text normally */
      g.setColor(color);
      BasicGraphicsUtils.drawStringUnderlineCharAt(
          g,
          text,
          mnemIndex,
          textRect.x + textShiftOffset,
          textRect.y + fm.getAscent() + textShiftOffset);
    } else {
        /** * paint the text disabled ** */
      color = UIManager.getColor("Button.disabledForeground");
      Color shadow = UIManager.getColor("Button.disabledShadow");

      XPStyle xp = XPStyle.getXP();
      if (xp != null) {
        color = xp.getColor("button.pushbutton(disabled).textcolor", color);
      } else {
        // Paint shadow only if not XP
        if (shadow == null) {
          shadow = b.getBackground().darker();
        }
        g.setColor(shadow);
        BasicGraphicsUtils.drawStringUnderlineCharAt(
            g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
      }
      if (color == null) {
        color = b.getBackground().brighter();
      }
      g.setColor(color);
      BasicGraphicsUtils.drawStringUnderlineCharAt(
          g, text, mnemIndex, textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
  }
コード例 #4
0
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (table != null) {
        JTableHeader header = table.getTableHeader();
        if (header != null) {
          setFont(header.getFont());
        }
      }
      this.isSelected = isSelected;
      this.hasFocus = hasFocus;
      this.column = column;
      this.hasRollover = (column == rolloverColumn);
      if (skin == null || skin.getContentMargin() == null) {
        skin = XPStyle.getXP().getSkin(header, "header.headeritem");
      }
      setText((value == null) ? "" : value.toString());
      setBorder(new EmptyBorder(skin.getContentMargin()));

      return this;
    }
コード例 #5
0
 private static void triggerAnimation(JComponent c, Part part, State newState) {
   if (c instanceof javax.swing.JTabbedPane || part == Part.TP_BUTTON) {
     // idk: we can not handle tabs animation because
     // the same (component,part) is used to handle all the tabs
     // and we can not track the states
     // Vista theme might have transition duration for toolbar buttons
     // but native application does not seem to animate them
     return;
   }
   AnimationController controller = AnimationController.getAnimationController();
   State oldState = controller.getState(c, part);
   if (oldState != newState) {
     controller.putState(c, part, newState);
     if (newState == State.DEFAULTED) {
       // it seems for DEFAULTED button state Vista does animation from
       // HOT
       oldState = State.HOT;
     }
     if (oldState != null) {
       long duration;
       if (newState == State.DEFAULTED) {
         // Only button might have DEFAULTED state
         // idk: do not know how to get the value from Vista
         // one second seems plausible value
         duration = 1000;
       } else {
         XPStyle xp = XPStyle.getXP();
         duration =
             (xp != null)
                 ? xp.getThemeTransitionDuration(
                     c,
                     part,
                     normalizeState(oldState),
                     normalizeState(newState),
                     Prop.TRANSITIONDURATIONS)
                 : 1000;
       }
       controller.startAnimation(c, part, oldState, newState, duration);
     }
   }
 }
コード例 #6
0
  protected MouseInputListener createMouseInputListener() {
    if (XPStyle.getXP() != null) {
      return new MouseInputHandler() {
        public void mouseMoved(MouseEvent e) {
          super.mouseMoved(e);
          updateRolloverColumn(e);
        }

        public void mouseEntered(MouseEvent e) {
          super.mouseEntered(e);
          updateRolloverColumn(e);
        }

        public void mouseExited(MouseEvent e) {
          super.mouseExited(e);
          rolloverColumn = -1;
          header.repaint();
        }

        public void mousePressed(MouseEvent e) {
          super.mousePressed(e);
          if (header.getReorderingAllowed()) {
            rolloverColumn = -1;
            header.repaint();
          }
        }

        public void mouseDragged(MouseEvent e) {
          super.mouseDragged(e);
          updateRolloverColumn(e);
        }

        public void mouseReleased(MouseEvent e) {
          super.mouseReleased(e);
          updateRolloverColumn(e);
        }
      };
    } else {
      return super.createMouseInputListener();
    }
  }