Пример #1
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;
  }
Пример #2
0
 /**
  * Returns the value to initialize the opacity property of the Component to. A Style should NOT
  * assume the opacity will remain this value, the developer may reset it or override it.
  *
  * @param context SynthContext identifying requestor
  * @return opaque Whether or not the JComponent is opaque.
  */
 @Override
 public boolean isOpaque(SynthContext context) {
   Region region = context.getRegion();
   if (region == Region.COMBO_BOX
       || region == Region.DESKTOP_PANE
       || region == Region.DESKTOP_ICON
       || region == Region.EDITOR_PANE
       || region == Region.FORMATTED_TEXT_FIELD
       || region == Region.INTERNAL_FRAME
       || region == Region.LIST
       || region == Region.MENU_BAR
       || region == Region.PANEL
       || region == Region.PASSWORD_FIELD
       || region == Region.POPUP_MENU
       || region == Region.PROGRESS_BAR
       || region == Region.ROOT_PANE
       || region == Region.SCROLL_PANE
       || region == Region.SPINNER
       || region == Region.SPLIT_PANE_DIVIDER
       || region == Region.TABLE
       || region == Region.TEXT_AREA
       || region == Region.TEXT_FIELD
       || region == Region.TEXT_PANE
       || region == Region.TOOL_BAR_DRAG_WINDOW
       || region == Region.TOOL_TIP
       || region == Region.TREE
       || region == Region.VIEWPORT) {
     return true;
   }
   Component c = context.getComponent();
   String name = c.getName();
   if (name == "ComboBox.renderer" || name == "ComboBox.listRenderer") {
     return true;
   }
   return false;
 }