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 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; }
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; }
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; }
@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; }
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; }
// 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; }
/* * 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; }
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; }
private Insets getSimpleInsets(SynthContext context, Insets insets, int n) { insets.top = insets.bottom = insets.right = insets.left = n; return insets; }
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; }
private Insets getThicknessInsets(SynthContext context, Insets insets) { insets.left = insets.right = getXThickness(); insets.top = insets.bottom = getYThickness(); return insets; }
/** * 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; }
public Insets getBorderInsets(Component c, Insets insets) { insets.set(2, 2, 2, 2); return insets; }
/** * Reinitialize 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 */ public Insets getBorderInsets(Component c, Insets insets) { Border border = getBorder(); if (border != null) { if (border instanceof AbstractBorder) { ((AbstractBorder) border).getBorderInsets(c, insets); } else { // Can't reuse border insets because the Border interface // can't be enhanced. Insets i = border.getBorderInsets(c); insets.top = i.top; insets.right = i.right; insets.bottom = i.bottom; insets.left = i.left; } } else { insets.left = insets.top = insets.right = insets.bottom = 0; } insets.left += EDGE_SPACING + TEXT_SPACING; insets.right += EDGE_SPACING + TEXT_SPACING; insets.top += EDGE_SPACING + TEXT_SPACING; insets.bottom += EDGE_SPACING + TEXT_SPACING; if (c == null || label == null) { return insets; } insets.top += label.getHeight(); return insets; }