Пример #1
0
  private void drawWinBorder(Component c, Graphics g, int x, int y, int w, int h) {
    if (!c.isEnabled()) {
      g.setColor(Theme.textBorderDisabledColor[Theme.style].getColor());
    } else {
      g.setColor(Theme.textBorderColor[Theme.style].getColor());
    }
    g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
    g.drawLine(x + 1, y + 2, x + 1, y + h - 3);

    if (!c.isEnabled()) {
      g.setColor(Theme.textBorderDarkDisabledColor[Theme.style].getColor());
    } else {
      g.setColor(Theme.textBorderDarkColor[Theme.style].getColor());
    }
    g.drawLine(x, y, x + w - 2, y);
    g.drawLine(x, y + 1, x, y + h - 2);

    g.setColor(Theme.backColor[Theme.style].getColor());
    g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
    g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);

    if (!c.isEnabled()) {
      g.setColor(Theme.textBorderLightDisabledColor[Theme.style].getColor());
    } else {
      g.setColor(Theme.textBorderLightColor[Theme.style].getColor());
    }
    g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
    g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
  }
Пример #2
0
 private void drawXpBorder(Component c, Graphics g, int x, int y, int w, int h) {
   if (!c.isEnabled()) {
     DrawRoutines.drawBorder(g, Theme.textBorderDisabledColor[Theme.style].getColor(), x, y, w, h);
   } else {
     DrawRoutines.drawBorder(g, Theme.textBorderColor[Theme.style].getColor(), x, y, w, h);
   }
 }
    public void paintIcon(Component c, Graphics g, int x, int y) {
      boolean enabled = c.isEnabled();

      // paint the icon
      Icon paintedIcon = enabled ? icon : disabledIcon;
      if (paintedIcon != null) paintedIcon.paintIcon(c, g, x, y);

      // backup current color
      Color oldColor = g.getColor();
      int insetx = 4;
      if (c instanceof JComponent) {
        Insets borderinset = ((JComponent) c).getBorder().getBorderInsets(c);
        insetx = borderinset.left;
      }
      if (paintedIcon != null) {
        g.translate(paintedIcon.getIconWidth() + X_GAP + insetx, 0);
      }

      arrow.paintIcon(c, g, x, y);
      if (paintedIcon != null) {
        g.translate(-paintedIcon.getIconWidth() - X_GAP - insetx, 0);
      }

      // restore previous color
      g.setColor(oldColor);
    }
Пример #4
0
  public void enableControlPanel() {
    boolean bVisible = false;

    int nmembers = buttonPane.getComponentCount();
    for (int k = 0; k < nmembers; k++) {
      Component comp = buttonPane.getComponent(k);
      if (comp != null) {
        if (comp.isVisible() || comp.isEnabled()) {
          bVisible = true;
          break;
        }
      }
    }

    if (bVisible && !buttonPane.isVisible()) {
      Dimension dim = getSize();
      Dimension dim1 = buttonPane.getPreferredSize();
      int w = dim.width;
      int h = dim.height + dim1.height;
      if (dim1.width > w) w = dim1.width;
      if (w < 300) w = 300;
      if (h < 200) h = 200;
      setSize(w, h);
    }
    buttonPane.setVisible(bVisible);
  }
    public void paintIcon(Component c, Graphics g, int x, int y) {
      Color oldColor = g.getColor();
      boolean enabled = c.isEnabled();
      boolean pressed = false;
      if (c instanceof JButton) {
        pressed = ((JButton) c).getModel().isPressed();
      }

      int i = 0;
      int j = 0;
      int w = Math.min(width, c.getWidth());
      int h = c.getHeight();
      if (h < 5 || w < 5) { // not enough space for the arrow
        g.setColor(oldColor);
        return;
      }

      int size = Math.min(h / 2, w / 2);
      size = Math.max(size, 2);
      int mid = size / 2;

      x = ((w - size) / 2); // center arrow
      y = (h - size) / 2; // center arrow
      if (pressed) {
        x++;
        y++;
      }
      g.translate(x, y); // move the x,y origin in the graphic

      if (enabled) g.setColor(UIManager.getColor("controlDkShadow")); // NOT
      // LOCALIZABLE
      else g.setColor(UIManager.getColor("controlShadow")); // NOT
      // LOCALIZABLE

      if (!enabled) {
        g.translate(1, 1);
        g.setColor(UIManager.getColor("controlLtHighlight")); // NOT
        // LOCALIZABLE
        for (i = size - 1; i >= 0; i--) {
          g.drawLine(mid - i, j, mid + i, j);
          j++;
        }
        g.translate(-1, -1);
        g.setColor(UIManager.getColor("controlShadow")); // NOT
        // LOCALIZABLE
      }

      j = 0;
      for (i = size - 1; i >= 0; i--) {
        g.drawLine(mid - i, j, mid + i, j);
        j++;
      }

      g.translate(-x, -y);
      g.setColor(oldColor);
    }
  protected Icon getIcon(Component c) {
    Icon icon;
    boolean isActive = true; // QuaquaUtilities.isOnActiveWindow(c);

    if (c instanceof JSlider) {
      JSlider slider = (JSlider) c;
      if (isActive) {
        if (c.isEnabled()) {
          if (slider.getModel().getValueIsAdjusting()) {
            icon = icons[EP];
          } else {
            icon = icons[E];
          }
        } else {
          icon = icons[D];
        }
      } else {
        if (c.isEnabled()) {
          icon = icons[I];
        } else {
          icon = icons[DI];
        }
      }
    } else {
      if (isActive) {
        if (c.isEnabled()) {
          icon = icons[E];
        } else {
          icon = icons[D];
        }
      } else {
        if (c.isEnabled()) {
          icon = icons[I];
        } else {
          icon = icons[DI];
        }
      }
    }
    return icon;
  }
Пример #7
0
 private static boolean isEnabled(Component c, State state) {
   if (state == null && c instanceof JMenuItem) {
     WindowsMenuItemUIAccessor accessor = getAccessor((JMenuItem) c);
     if (accessor != null) {
       state = accessor.getState((JMenuItem) c);
     }
   }
   if (state == null) {
     if (c != null) {
       return c.isEnabled();
     } else {
       return true;
     }
   } else {
     return (state != State.DISABLED)
         && (state != State.DISABLEDHOT)
         && (state != State.DISABLEDPUSHED);
   }
 }
Пример #8
0
  /**
   * Write the xml for a {@link Component}.
   *
   * @param component
   * @param contentHandler
   * @throws SAXException
   */
  protected static void generateXML(
      final String namespace,
      final Component component,
      final ContentHandler contentHandler,
      final boolean isScrPrivateFile)
      throws SAXException {
    final AttributesImpl ai = new AttributesImpl();
    IOUtils.addAttribute(ai, COMPONENT_ATTR_ENABLED, component.isEnabled());
    IOUtils.addAttribute(ai, COMPONENT_ATTR_IMMEDIATE, component.isImmediate());
    IOUtils.addAttribute(ai, COMPONENT_ATTR_NAME, component.getName());
    IOUtils.addAttribute(ai, COMPONENT_ATTR_FACTORY, component.getFactory());

    // attributes new in 1.1
    if (NAMESPACE_URI_1_1.equals(namespace) || NAMESPACE_URI_1_1_FELIX.equals(namespace)) {
      IOUtils.addAttribute(ai, COMPONENT_ATTR_POLICY, component.getConfigurationPolicy());
      IOUtils.addAttribute(ai, COMPONENT_ATTR_ACTIVATE, component.getActivate());
      IOUtils.addAttribute(ai, COMPONENT_ATTR_DEACTIVATE, component.getDeactivate());
      IOUtils.addAttribute(ai, COMPONENT_ATTR_MODIFIED, component.getModified());
    }

    IOUtils.indent(contentHandler, 1);
    contentHandler.startElement(
        namespace, ComponentDescriptorIO.COMPONENT, ComponentDescriptorIO.COMPONENT_QNAME, ai);
    IOUtils.newline(contentHandler);
    generateXML(component.getImplementation(), contentHandler);
    if (component.getService() != null) {
      generateXML(component.getService(), contentHandler);
    }
    if (component.getProperties() != null) {
      for (final Property property : component.getProperties()) {
        generateXML(property, contentHandler, isScrPrivateFile);
      }
    }
    if (component.getReferences() != null) {
      for (final Reference reference : component.getReferences()) {
        generateXML(namespace, reference, contentHandler, isScrPrivateFile);
      }
    }
    IOUtils.indent(contentHandler, 1);
    contentHandler.endElement(
        namespace, ComponentDescriptorIO.COMPONENT, ComponentDescriptorIO.COMPONENT_QNAME);
    IOUtils.newline(contentHandler);
  }
Пример #9
0
 protected void paintBackground(Graphics g, Rectangle cellRect, int col) {
   Component component = getHeaderRenderer(col);
   int x = cellRect.x;
   int y = cellRect.y;
   int w = cellRect.width;
   int h = cellRect.height;
   if (header.getBackground() instanceof ColorUIResource) {
     if ((col == rolloverCol) && (component != null) && component.isEnabled()) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getRolloverColors(), x, y, w, h);
     } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getColHeaderColors(), x, y, w, h);
     } else {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getInActiveColors(), x, y, w, h);
     }
   } else {
     g.setColor(header.getBackground());
     g.fillRect(x, y, w, h);
   }
 }
Пример #10
0
 private TitledSeparator getTitledSeparator(Component c) {
   titledSeparator.setEnabled(c.isEnabled());
   return titledSeparator;
 }
 public static boolean isFocusable(Component component) {
   return component.isFocusable()
       && component.isDisplayable()
       && component.isVisible()
       && component.isEnabled();
 }
Пример #12
0
 /**
  * Sets the help text for the specified component.
  *
  * @param cont input container
  */
 static void focus(final Component cont) {
   final GUI gui = gui(cont);
   if (gui == null) return;
   if (gui.gopts.get(GUIOptions.MOUSEFOCUS) && cont.isEnabled()) cont.requestFocusInWindow();
 }