Beispiel #1
0
  /**
   * The padding between the "content area" (that is, the icon rect and text rect) and the edges of
   * this button. This is a calculated value.
   */
  protected Insets getContentInsets(AbstractButton button) {
    int horizontalPosition = getHorizontalPosition(button);
    int verticalPosition = getVerticalPosition(button);

    Insets i = new Insets(0, 0, 0, 0);
    if (getFocusPainting(button) == PaintFocus.OUTSIDE
        || getFocusPainting(button) == PaintFocus.BOTH) {
      if (horizontalPosition == POS_LEFT || horizontalPosition == POS_ONLY) {
        i.left += focusSize;
      }
      if (horizontalPosition == POS_RIGHT || horizontalPosition == POS_ONLY) {
        i.right += focusSize;
      }
      if (verticalPosition == POS_TOP || verticalPosition == POS_ONLY) {
        i.top += focusSize;
      }
      if (verticalPosition == POS_BOTTOM || verticalPosition == POS_ONLY) {
        i.bottom += focusSize;
      }
    } else {
      if (fill.getShadowHighlight(button) != null
          && (verticalPosition == POS_BOTTOM || verticalPosition == POS_ONLY)) {
        i.bottom++;
      }
    }
    return i;
  }
 @Override
 public Insets getBorderInsets(Component c) {
   Dimension size = comp.getPreferredSize();
   Insets insets = border.getBorderInsets(c);
   insets.top = Math.max(insets.top, size.height);
   return insets;
 }
 public Insets getBorderInsets(Component c, Insets borderInsets) {
   borderInsets.left = insets.left;
   borderInsets.top = insets.top;
   borderInsets.right = insets.right;
   borderInsets.bottom = insets.bottom;
   return borderInsets;
 }
Beispiel #4
0
 /**
  * Reinitializes the insets parameter with this Border's current Insets.
  *
  * @param c the component for which this border insets value applies
  * @param insets the object to be reinitialized
  * @return the <code>insets</code> object
  */
 public Insets getBorderInsets(Component c, Insets insets) {
   insets.bottom = this.insets.bottom;
   insets.top = this.insets.top;
   insets.left = this.insets.left;
   insets.right = this.insets.right;
   return insets;
 }
Beispiel #5
0
 public RoundedShadowBorder() {
   insets = new Insets(0, 0, 0, 0);
   insets.bottom = bottomLeftCorner.getIconHeight() + backgroundThickness;
   insets.top = topLeftCorner.getIconHeight() + backgroundThickness;
   insets.left = topLeftCorner.getIconHeight() + backgroundThickness;
   insets.right = topRightCorner.getIconHeight() + backgroundThickness;
 }
 @Override
 public Insets getInsets() {
   Insets insets = super.getInsets();
   if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel() && isEditable) {
     insets.right += 2;
   }
   return insets;
 }
Beispiel #7
0
 @Override
 public Insets getInsets() {
   Insets insets = super.getInsets();
   if (UIUtil.isUnderGTKLookAndFeel() || UIUtil.isUnderNimbusLookAndFeel()) {
     insets.top += 1;
     insets.bottom += 2;
   }
   return insets;
 }
Beispiel #8
0
 private Insets getSeparatorInsets(SynthContext context, Insets insets) {
   int horizPadding = 0;
   if (context.getRegion() == Region.POPUP_MENU_SEPARATOR) {
     horizPadding = getClassSpecificIntValue(context, "horizontal-padding", 3);
   }
   insets.right = insets.left = getXThickness() + horizPadding;
   insets.top = insets.bottom = getYThickness();
   return insets;
 }
 private Insets getVisualMargin(JComponent component) {
   String uid = component.getUIClassID();
   String style = null;
   if (uid == "ButtonUI" || uid == "ToggleButtonUI") {
     style = (String) component.getClientProperty("JButton.buttonType");
   } else if (uid == "ProgressBarUI") {
     style =
         (((JProgressBar) component).getOrientation() == JProgressBar.HORIZONTAL)
             ? "horizontal"
             : "vertical";
   } else if (uid == "SliderUI") {
     style =
         (((JSlider) component).getOrientation() == JProgressBar.HORIZONTAL)
             ? "horizontal"
             : "vertical";
   } else if (uid == "TabbedPaneUI") {
     switch (((JTabbedPane) component).getTabPlacement()) {
       case JTabbedPane.TOP:
         style = "top";
         break;
       case JTabbedPane.LEFT:
         style = "left";
         break;
       case JTabbedPane.BOTTOM:
         style = "bottom";
         break;
       case JTabbedPane.RIGHT:
         style = "right";
         break;
     }
   }
   Insets gap = getInsets(VISUAL_MARGINS, uid, style, 0);
   // Take into account different positions of the button icon
   if (uid == "RadioButtonUI" || uid == "CheckBoxUI") {
     switch (((AbstractButton) component).getHorizontalTextPosition()) {
       case SwingConstants.RIGHT:
         gap = new Insets(gap.top, gap.right, gap.bottom, gap.left);
         break;
       case SwingConstants.CENTER:
         gap = new Insets(gap.top, gap.right, gap.bottom, gap.right);
         break;
         /*
         case SwingConstants.LEFT :
             break;
              */
       default:
         gap = new Insets(gap.top, gap.left, gap.bottom, gap.right);
     }
     if (component.getBorder() instanceof EmptyBorder) {
       gap.left -= 2;
       gap.right -= 2;
       gap.top -= 2;
       gap.bottom -= 2;
     }
   }
   return gap;
 }
Beispiel #10
0
  private Insets getTabbedPaneTabInsets(SynthContext context, Insets insets) {
    int xThickness = getXThickness();
    int yThickness = getYThickness();
    int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
    int pad = 2;

    insets.left = insets.right = focusSize + pad + xThickness;
    insets.top = insets.bottom = focusSize + pad + yThickness;
    return insets;
  }
Beispiel #11
0
 private Insets getMenuBarInsets(SynthContext context, Insets insets) {
   // The following calculations are derived from gtkmenubar.c
   // (GTK+ version 2.8.20), gtk_menu_bar_size_allocate() method.
   int internalPadding = getClassSpecificIntValue(context, "internal-padding", 1);
   int xThickness = getXThickness();
   int yThickness = getYThickness();
   insets.left = insets.right = xThickness + internalPadding;
   insets.top = insets.bottom = yThickness + internalPadding;
   return insets;
 }
Beispiel #12
0
 private Insets getMenuItemInsets(SynthContext context, Insets insets) {
   // The following calculations are derived from gtkmenuitem.c
   // (GTK+ version 2.8.20), gtk_menu_item_size_allocate() method.
   int horizPadding = getClassSpecificIntValue(context, "horizontal-padding", 3);
   int xThickness = getXThickness();
   int yThickness = getYThickness();
   insets.left = insets.right = xThickness + horizPadding;
   insets.top = insets.bottom = yThickness;
   return insets;
 }
 /**
  * Layout the receiver. This method set insideBounds & insets according to bounds. Insets is
  * borderWidth + spacing.
  *
  * @see updateDrawableBounds
  */
 protected void layoutComponent() {
   Insets in = (Insets) getInsets().clone();
   in.top += spacing.top;
   in.left += spacing.left;
   in.bottom += spacing.bottom;
   in.right += spacing.right;
   Dimension d = getSize();
   insideBounds.setBounds(
       in.left, in.top, d.width - in.left - in.right, d.height - in.top - in.bottom);
   updateDrawableBounds();
 }
 @Override
 public Insets getBorderInsets(Component c, Insets insets) {
   if (insets == null) {
     return new Insets(
         this.insets.top, this.insets.left,
         this.insets.bottom, this.insets.right);
   }
   insets.top = this.insets.top;
   insets.bottom = this.insets.bottom;
   insets.left = this.insets.left;
   insets.right = this.insets.left;
   return insets;
 }
Beispiel #15
0
  private Insets getButtonInsets(SynthContext context, Insets insets) {
    // The following calculations are derived from gtkbutton.c
    // (GTK+ version 2.8.20), gtk_button_size_allocate() method.
    int CHILD_SPACING = 1;
    int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
    int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
    int xThickness = getXThickness();
    int yThickness = getYThickness();
    int w = focusSize + focusPad + xThickness + CHILD_SPACING;
    int h = focusSize + focusPad + yThickness + CHILD_SPACING;
    insets.left = insets.right = w;
    insets.top = insets.bottom = h;

    Component component = context.getComponent();
    if ((component instanceof JButton)
        && !(component.getParent() instanceof JToolBar)
        && ((JButton) component).isDefaultCapable()) {
      // Include the default border insets, but only for JButtons
      // that are default capable.  Note that
      // JButton.getDefaultCapable() returns true by default, but
      // GtkToolButtons are never default capable, so we skip this
      // step if the button is contained in a toolbar.
      Insets defaultInsets =
          getClassSpecificInsetsValue(context, "default-border", BUTTON_DEFAULT_BORDER_INSETS);
      insets.left += defaultInsets.left;
      insets.right += defaultInsets.right;
      insets.top += defaultInsets.top;
      insets.bottom += defaultInsets.bottom;
    }

    return insets;
  }
  protected void paintBackgroundSafely(final Graphics g) {
    final JTextComponent c = getComponent();
    final int width = c.getWidth();
    final int height = c.getHeight();

    // a delegate takes precedence
    if (delegate != null) {
      delegate.paint(c, g, 0, 0, width, height);
      return;
    }

    final boolean isOpaque = c.isOpaque();
    if (!(c.getBorder() instanceof AquaTextFieldBorder)) {
      // developer must have set a custom border
      if (!isOpaque && AquaUtils.hasOpaqueBeenExplicitlySet(c)) return;

      // must fill whole region with background color if opaque
      g.setColor(c.getBackground());
      g.fillRect(0, 0, width, height);
      return;
    }

    // using our own border
    g.setColor(c.getBackground());
    if (isOpaque) {
      g.fillRect(0, 0, width, height);
      return;
    }

    final Insets margin = c.getMargin();
    Insets insets = c.getInsets();

    if (insets == null) insets = new Insets(0, 0, 0, 0);
    if (margin != null) {
      insets.top -= margin.top;
      insets.left -= margin.left;
      insets.bottom -= margin.bottom;
      insets.right -= margin.right;
    }

    // the common case
    final int shrinkage = AquaTextFieldBorder.getShrinkageFor(c, height);
    g.fillRect(
        insets.left - 2,
        insets.top - shrinkage - 1,
        width - insets.right - insets.left + 4,
        height - insets.bottom - insets.top + shrinkage * 2 + 2);
  }
Beispiel #17
0
 @Override
 public Insets getBorderInsets(Component c, final Insets insets) {
   insets.top +=
       getTitledSeparator(c).getPreferredSize().getHeight()
           - TitledSeparator.TOP_INSET
           - TitledSeparator.BOTTOM_INSET;
   insets.top += UIUtil.DEFAULT_VGAP;
   insets.top += insideInsets.top;
   insets.left += insideInsets.left;
   insets.bottom += insideInsets.bottom;
   insets.right += insideInsets.right;
   insets.top += outsideInsets.top;
   insets.left += outsideInsets.left;
   insets.bottom += outsideInsets.bottom;
   insets.right += outsideInsets.right;
   return insets;
 }
    public void configure(PropertySheetTable table, Item item) {
      isProperty = item.isProperty();
      toggleState = item.isVisible();
      showToggle = item.hasToggle();

      indentWidth = getIndent(table, item);
      insets.left = indentWidth + (showToggle ? HOTSPOT_SIZE : 0) + 2;
      ;
    }
Beispiel #19
0
 /**
  * Request the window insets from the delegate and compares it with the current one. This method
  * is mostly called by the delegate, e.g. when the window state is changed and insets should be
  * recalculated.
  *
  * <p>This method may be called on the toolkit thread.
  */
 public final boolean updateInsets(final Insets newInsets) {
   synchronized (getStateLock()) {
     if (insets.equals(newInsets)) {
       return false;
     }
     insets = newInsets;
   }
   return true;
 }
Beispiel #20
0
  // NOTE: this is called for ComboBox, and FormattedTextField also
  private Insets getTextFieldInsets(SynthContext context, Insets insets) {
    insets =
        getClassSpecificInsetsValue(context, "inner-border", getSimpleInsets(context, insets, 2));

    int xThickness = getXThickness();
    int yThickness = getYThickness();
    boolean interiorFocus = getClassSpecificBoolValue(context, "interior-focus", true);
    int focusSize = 0;

    if (!interiorFocus) {
      focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
    }

    insets.left += focusSize + xThickness;
    insets.right += focusSize + xThickness;
    insets.top += focusSize + yThickness;
    insets.bottom += focusSize + yThickness;
    return insets;
  }
  private void updateTabBorder() {
    if (!myProject.isOpen()) return;

    ToolWindowManagerEx mgr = (ToolWindowManagerEx) ToolWindowManager.getInstance(myProject);

    String[] ids = mgr.getToolWindowIds();

    Insets border = new Insets(0, 0, 0, 0);

    UISettings uiSettings = UISettings.getInstance();

    List<String> topIds = mgr.getIdsOn(ToolWindowAnchor.TOP);
    List<String> bottom = mgr.getIdsOn(ToolWindowAnchor.BOTTOM);
    List<String> rightIds = mgr.getIdsOn(ToolWindowAnchor.RIGHT);
    List<String> leftIds = mgr.getIdsOn(ToolWindowAnchor.LEFT);

    if (!uiSettings.HIDE_TOOL_STRIPES) {
      border.top = topIds.size() > 0 ? 1 : 0;
      border.bottom = bottom.size() > 0 ? 1 : 0;
      border.left = leftIds.size() > 0 ? 1 : 0;
      border.right = rightIds.size() > 0 ? 1 : 0;
    }

    for (String each : ids) {
      ToolWindow eachWnd = mgr.getToolWindow(each);
      if (!eachWnd.isAvailable()) continue;

      if (eachWnd.isVisible() && eachWnd.getType() == ToolWindowType.DOCKED) {
        ToolWindowAnchor eachAnchor = eachWnd.getAnchor();
        if (eachAnchor == ToolWindowAnchor.TOP) {
          border.top = 0;
        } else if (eachAnchor == ToolWindowAnchor.BOTTOM) {
          border.bottom = 0;
        } else if (eachAnchor == ToolWindowAnchor.LEFT) {
          border.left = 0;
        } else if (eachAnchor == ToolWindowAnchor.RIGHT) {
          border.right = 0;
        }
      }
    }

    myTabs
        .getPresentation()
        .setPaintBorder(border.top, border.left, border.right, border.bottom)
        .setTabSidePaintBorder(5);
  }
  public BlockBorder(Insets outerMargin, Insets innerMargin, Color aShade1, Color aShade2) {
    if (outerMargin == null) {
      outerMargin = EMPTY;
    }
    myOuterMargin = (Insets) outerMargin.clone();
    myInsets = (Insets) outerMargin.clone();
    myInsets.top += DEFAULT_INSETS.top;
    myInsets.left += DEFAULT_INSETS.left;
    myInsets.bottom += DEFAULT_INSETS.bottom;
    myInsets.right += DEFAULT_INSETS.right;

    if (innerMargin == null) {
      innerMargin = EMPTY;
    }
    myInsets.top += innerMargin.top;
    myInsets.left += innerMargin.left;
    myInsets.bottom += innerMargin.bottom;
    myInsets.right += innerMargin.right;

    myShade1 = aShade1;
    myShade2 = aShade2;
  }
Beispiel #23
0
 public Insets getBorderInsets(Component c) {
   Insets insets = new Insets(2, 2, 2, 2);
   if (((JToolBar) c).isFloatable()) {
     if (((JToolBar) c).getOrientation() == HORIZONTAL) {
       if (JTattooUtilities.isLeftToRight(c)) {
         insets.left = 15;
       } else {
         insets.right = 15;
       }
     } else {
       insets.top = 15;
     }
   }
   Insets margin = ((JToolBar) c).getMargin();
   if (margin != null) {
     insets.left += margin.left;
     insets.top += margin.top;
     insets.right += margin.right;
     insets.bottom += margin.bottom;
   }
   return insets;
 }
    @Override
    public Insets getInsets(Insets insets) {
      final Insets result = super.getInsets(insets);

      if (UIUtil.isUnderNimbusLookAndFeel() && !isSmallVariant()) {
        result.top += 2;
        result.left += 8;
        result.bottom += 2;
        result.right += 4 + ARROW_ICON.getIconWidth();
      } else {
        result.right += ARROW_ICON.getIconWidth();
      }

      return result;
    }
Beispiel #25
0
  /*
   * This is used for both RADIO_BUTTON and CHECK_BOX.
   */
  private Insets getRadioInsets(SynthContext context, Insets insets) {
    // The following calculations are derived from gtkcheckbutton.c
    // (GTK+ version 2.8.20), gtk_check_button_size_allocate() method.
    int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
    int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
    int totalFocus = focusSize + focusPad;

    // Note: GTKIconFactory.DelegateIcon will have already included the
    // "indicator-spacing" value in the size of the indicator icon,
    // which explains why we use zero as the left inset (or right inset
    // in the RTL case); see 6489585 for more details.
    insets.top = totalFocus;
    insets.bottom = totalFocus;
    if (context.getComponent().getComponentOrientation().isLeftToRight()) {
      insets.left = 0;
      insets.right = totalFocus;
    } else {
      insets.left = totalFocus;
      insets.right = 0;
    }

    return insets;
  }
Beispiel #26
0
  /**
   * Returns the Insets. If <code>insets</code> is non-null the resulting insets will be placed in
   * it, otherwise a new Insets object will be created and returned.
   *
   * @param context SynthContext identifying requestor
   * @param insets Where to place Insets
   * @return Insets.
   */
  @Override
  public Insets getInsets(SynthContext state, Insets insets) {
    Region id = state.getRegion();
    JComponent component = state.getComponent();
    String name = (id.isSubregion()) ? null : component.getName();

    if (insets == null) {
      insets = new Insets(0, 0, 0, 0);
    } else {
      insets.top = insets.bottom = insets.left = insets.right = 0;
    }

    if (id == Region.ARROW_BUTTON || id == Region.BUTTON || id == Region.TOGGLE_BUTTON) {
      if ("Spinner.previousButton" == name || "Spinner.nextButton" == name) {
        return getSimpleInsets(state, insets, 1);
      } else {
        return getButtonInsets(state, insets);
      }
    } else if (id == Region.CHECK_BOX || id == Region.RADIO_BUTTON) {
      return getRadioInsets(state, insets);
    } else if (id == Region.MENU_BAR) {
      return getMenuBarInsets(state, insets);
    } else if (id == Region.MENU
        || id == Region.MENU_ITEM
        || id == Region.CHECK_BOX_MENU_ITEM
        || id == Region.RADIO_BUTTON_MENU_ITEM) {
      return getMenuItemInsets(state, insets);
    } else if (id == Region.FORMATTED_TEXT_FIELD) {
      return getTextFieldInsets(state, insets);
    } else if (id == Region.INTERNAL_FRAME) {
      insets = Metacity.INSTANCE.getBorderInsets(state, insets);
    } else if (id == Region.LABEL) {
      if ("TableHeader.renderer" == name) {
        return getButtonInsets(state, insets);
      } else if (component instanceof ListCellRenderer) {
        return getTextFieldInsets(state, insets);
      } else if ("Tree.cellRenderer" == name) {
        return getSimpleInsets(state, insets, 1);
      }
    } else if (id == Region.OPTION_PANE) {
      return getSimpleInsets(state, insets, 6);
    } else if (id == Region.POPUP_MENU) {
      return getSimpleInsets(state, insets, 2);
    } else if (id == Region.PROGRESS_BAR
        || id == Region.SLIDER
        || id == Region.TABBED_PANE
        || id == Region.TABBED_PANE_CONTENT
        || id == Region.TOOL_BAR
        || id == Region.TOOL_BAR_DRAG_WINDOW
        || id == Region.TOOL_TIP) {
      return getThicknessInsets(state, insets);
    } else if (id == Region.SCROLL_BAR) {
      return getScrollBarInsets(state, insets);
    } else if (id == Region.SLIDER_TRACK) {
      return getSliderTrackInsets(state, insets);
    } else if (id == Region.TABBED_PANE_TAB) {
      return getTabbedPaneTabInsets(state, insets);
    } else if (id == Region.TEXT_FIELD || id == Region.PASSWORD_FIELD) {
      if (name == "Tree.cellEditor") {
        return getSimpleInsets(state, insets, 1);
      }
      return getTextFieldInsets(state, insets);
    } else if (id == Region.SEPARATOR
        || id == Region.POPUP_MENU_SEPARATOR
        || id == Region.TOOL_BAR_SEPARATOR) {
      return getSeparatorInsets(state, insets);
    } else if (id == GTKEngine.CustomRegion.TITLED_BORDER) {
      return getThicknessInsets(state, insets);
    }
    return insets;
  }
Beispiel #27
0
 private Insets getThicknessInsets(SynthContext context, Insets insets) {
   insets.left = insets.right = getXThickness();
   insets.top = insets.bottom = getYThickness();
   return insets;
 }
Beispiel #28
0
  private Insets getScrollBarInsets(SynthContext context, Insets insets) {
    int troughBorder = getClassSpecificIntValue(context, "trough-border", 1);
    insets.left = insets.right = insets.top = insets.bottom = troughBorder;

    JComponent c = context.getComponent();
    if (c.getParent() instanceof JScrollPane) {
      // This scrollbar is part of a scrollpane; use only the
      // "scrollbar-spacing" style property to determine the padding
      // between the scrollbar and its parent scrollpane.
      int spacing = getClassSpecificIntValue(WidgetType.SCROLL_PANE, "scrollbar-spacing", 3);
      if (((JScrollBar) c).getOrientation() == JScrollBar.HORIZONTAL) {
        insets.top += spacing;
      } else {
        if (c.getComponentOrientation().isLeftToRight()) {
          insets.left += spacing;
        } else {
          insets.right += spacing;
        }
      }
    } else {
      // This is a standalone scrollbar; leave enough room for the
      // focus line in addition to the trough border.
      if (c.isFocusable()) {
        int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
        int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
        int totalFocus = focusSize + focusPad;
        insets.left += totalFocus;
        insets.right += totalFocus;
        insets.top += totalFocus;
        insets.bottom += totalFocus;
      }
    }
    return insets;
  }
Beispiel #29
0
 private Insets getSliderTrackInsets(SynthContext context, Insets insets) {
   int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
   int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
   insets.top = insets.bottom = insets.left = insets.right = focusSize + focusPad;
   return insets;
 }
Beispiel #30
0
 private Insets getSimpleInsets(SynthContext context, Insets insets, int n) {
   insets.top = insets.bottom = insets.right = insets.left = n;
   return insets;
 }