gt:     GridLayout gl_grpInsets = new GridLayout(4, false);
context: /*
   * @(#)BordersComposite.java
   *
   * Copyright (c) appNativa. All rights reserved.
   *
   * Use is subject to license terms.
   */
  
  package com.appnativa.studio.composite;
  
  import java.util.EventObject;
  
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.events.ControlAdapter;
  import org.eclipse.swt.events.ControlEvent;
  import org.eclipse.swt.events.FocusAdapter;
  import org.eclipse.swt.events.FocusEvent;
  import org.eclipse.swt.events.PaintEvent;
  import org.eclipse.swt.events.PaintListener;
  import org.eclipse.swt.events.SelectionAdapter;
  import org.eclipse.swt.events.SelectionEvent;
  import org.eclipse.swt.events.TraverseEvent;
  import org.eclipse.swt.events.TraverseListener;
  import org.eclipse.swt.graphics.Point;
  import org.eclipse.swt.layout.FillLayout;
  import org.eclipse.swt.layout.GridData;
  import org.eclipse.swt.layout.GridLayout;
  import org.eclipse.swt.widgets.Button;
  import org.eclipse.swt.widgets.Combo;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Group;
  import org.eclipse.swt.widgets.Label;
  import org.eclipse.swt.widgets.List;
  import org.eclipse.swt.widgets.Spinner;
  import org.eclipse.swt.widgets.Text;
  
  import com.appnativa.studio.Utilities;
  import com.appnativa.studio.dialogs.BordersPopup;
  import com.appnativa.rare.Platform;
  import com.appnativa.rare.platform.swing.ui.util.SwingGraphics;
  import com.appnativa.rare.spot.Font;
  import com.appnativa.rare.spot.Widget.CBorder;
  import com.appnativa.rare.spot.Widget.CTitleLocation;
  import com.appnativa.rare.ui.BorderUtils;
  import com.appnativa.rare.ui.ColorUtils;
  import com.appnativa.rare.ui.FontUtils;
  import com.appnativa.rare.ui.UIColor;
  import com.appnativa.rare.ui.UIInsets;
  import com.appnativa.rare.ui.Utils;
  import com.appnativa.rare.ui.iPlatformBorder;
  import com.appnativa.rare.ui.event.ChangeEvent;
  import com.appnativa.rare.ui.event.EventListenerList;
  import com.appnativa.rare.ui.event.iChangeListener;
  import com.appnativa.rare.widget.iWidget;
  import com.appnativa.spot.SPOTEnumerated;
  import com.appnativa.spot.SPOTSet;
  import com.appnativa.spot.iSPOTElement;
  import com.appnativa.util.SNumber;
  
  public class BordersEditorComposite extends BaseEditorComposite implements iChangeListener {
    private EventListenerList   listenerList = new EventListenerList();
    private SPOTEnumerated      activeBorder;
    private Spinner             arcWidth;
    private List                bordersList;
    private SPOTSet             bordersSet;
    private Spinner             bottom;
    private Button              btnAllSides;
    private Button              btnDelete;
    private Button              btnMoveDown;
    private Button              btnMoveUp;
    private Button              btnNewBorder;
    private Composite           buttons;
    private ChangeEvent         changeEvent;
    private ColorFieldComposite colorChooser1;
    private ColorFieldComposite colorChooser2;
    private ColorFieldComposite colorChooser3;
    private ColorFieldComposite colorChooser4;
    private iWidget             contextWidget;
    private Button              flatBottom;
    private Button              flatTop;
    private Group               grpColors;
    private Group               grpGeneral;
    private Group               grpInsets;
    private Composite           grpLineOpts;
    private Composite           grpLineSizeStyle;
    private Group               grpTitle;
    private Point               initialSize;
    private Button              insetsClear;
    private Label               lblColor1;
    private Label               lblColor2;
    private Label               lblColor3;
    private Label               lblColor4;
    private Label               lblTitle;
    private Label               lblTitleColor;
    private Label               lblTitleFont;
    private Label               lblTitleLocation;
    private Spinner             left;
    private Combo               lineStyle;
    private Composite           listComposite;
    private Button              noBottom;
    private Button              noLeft;
    private Button              noRight;
    private Button              noTop;
    private Button              padForArc;
    private Composite           previewComposite;
    private Spinner             right;
    private Spinner             thickness;
    private ColorFieldComposite titleColor;
    private FontFieldComposite  titleFont;
    private Combo               titleLocation;
    private Text                titleText;
    private Spinner             top;
  
    /**
     * Create the composite.
     *
     * @param parent
     * @param style
     */
    public BordersEditorComposite(Composite parent, int style) {
      super(parent, style);
      changeEvent = new ChangeEvent(this);
  
      GridLayout gridLayout = new GridLayout(1, false);
      gridLayout.marginRight = 2;
      gridLayout.marginLeft = 2;
      gridLayout.marginBottom = 2;
  
      gridLayout.verticalSpacing = 0;
      gridLayout.marginWidth = 0;
      gridLayout.marginHeight = 0;
      gridLayout.horizontalSpacing = 0;
      setLayout(gridLayout);
      listComposite = new Composite(this, SWT.NONE);
      listComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
      GridLayout gl_listComposite = new GridLayout(1, false);
      gl_listComposite.marginBottom = 2;
      gl_listComposite.marginLeft = 2;
      gl_listComposite.horizontalSpacing = 0;
      gl_listComposite.verticalSpacing = 0;
      gl_listComposite.marginWidth = 0;
      gl_listComposite.marginHeight = 0;
      listComposite.setLayout(gl_listComposite);
      buttons = new Composite(listComposite, SWT.NONE);
      buttons.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
      buttons.setLayout(new FillLayout(SWT.HORIZONTAL));
      btnNewBorder = new Button(buttons, SWT.PUSH);
      btnNewBorder.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          addNewBorder();
        }
      });
      btnNewBorder.setText("Add...");
      btnDelete = new Button(buttons, SWT.PUSH);
      btnDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          removeSelectedBorder();
        }
      });
      btnDelete.setText("Delete");
      btnMoveUp = new Button(buttons, SWT.NONE);
      btnMoveUp.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          moveUp();
        }
      });
      btnMoveUp.setText("Move Up");
      btnMoveDown = new Button(buttons, SWT.NONE);
      btnMoveDown.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          moveDown();
        }
      });
      btnMoveDown.setText("Move Dn.");
  
      bordersList = new List(listComposite, SWT.BORDER | SWT.V_SCROLL);
      bordersList.addTraverseListener(new TraverseListener() {
        public void keyTraversed(TraverseEvent e) {
          if ((bordersList.getItemCount() == 0) && (e.detail == SWT.TRAVERSE_RETURN)) {
            addNewBorder();
          }
        }
      });
      bordersList.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          borderSelectionChanged();
        }
      });
      GridData gd_bordersList = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
      gd_bordersList.heightHint = 60;
      bordersList.setLayoutData(gd_bordersList);
  
      grpGeneral = new Group(this, SWT.NONE);
      grpGeneral.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
  
      GridLayout gl_grpGeneral = new GridLayout(1, false);
  
      gl_grpGeneral.verticalSpacing = 0;
      gl_grpGeneral.horizontalSpacing = 0;
      gl_grpGeneral.marginHeight = 0;
      gl_grpGeneral.marginWidth = 0;
      grpGeneral.setLayout(gl_grpGeneral);
      grpLineSizeStyle = new Composite(grpGeneral, SWT.NONE);
      grpLineSizeStyle.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
  
      GridLayout gl_grpLineSizeStyle = new GridLayout(5, false);
  
      gl_grpLineSizeStyle.verticalSpacing = 2;
      gl_grpLineSizeStyle.marginWidth = 2;
      gl_grpLineSizeStyle.horizontalSpacing = 2;
      gl_grpLineSizeStyle.marginHeight = 2;
      grpLineSizeStyle.setLayout(gl_grpLineSizeStyle);
  
      Label lblThickness = new Label(grpLineSizeStyle, SWT.NONE);
  
      lblThickness.setText("Thickness:");
      thickness = new Spinner(grpLineSizeStyle, SWT.BORDER);
      thickness.setMinimum(1);
      thickness.setMaximum(100);
      thickness.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
      thickness.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
  
      Label lblArcWidth = new Label(grpLineSizeStyle, SWT.NONE);
  
      lblArcWidth.setText("Corner Arc:");
      arcWidth = new Spinner(grpLineSizeStyle, SWT.BORDER);
      arcWidth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
      arcWidth.setMaximum(1000);
      padForArc = new Button(grpLineSizeStyle, SWT.CHECK);
      padForArc.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      padForArc.setText("Pad for Arc");
      arcWidth.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          padForArc.setEnabled((arcWidth.getSelection() > 0));
          // padForArc.setEnabled((arcWidth.getSelection() > 0) ||
          // (arcHeight.getSelection() > 0));
          updateBorder();
        }
      });
      grpLineOpts = new Composite(grpGeneral, SWT.NONE);
      grpLineOpts.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
  
      GridLayout gl_grpLineSegments = new GridLayout(4, false);
  
      gl_grpLineSegments.verticalSpacing = 0;
      gl_grpLineSegments.marginWidth = 0;
      gl_grpLineSegments.horizontalSpacing = 0;
      gl_grpLineSegments.marginHeight = 0;
      grpLineOpts.setLayout(gl_grpLineSegments);
      flatTop = new Button(grpLineOpts, SWT.RADIO);
      flatTop.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      flatTop.setText("Flat Top");
      flatBottom = new Button(grpLineOpts, SWT.RADIO);
      flatBottom.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      flatBottom.setText("Flat Bottom");
      noTop = new Button(grpLineOpts, SWT.RADIO);
      noTop.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      noTop.setText("No Top");
      btnAllSides = new Button(grpLineOpts, SWT.RADIO);
      btnAllSides.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      btnAllSides.setText("All Sides");
      noLeft = new Button(grpLineOpts, SWT.RADIO);
      noLeft.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      noLeft.setText("No Left");
      noRight = new Button(grpLineOpts, SWT.RADIO);
      noRight.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      noRight.setText("No Right");
      noBottom = new Button(grpLineOpts, SWT.RADIO);
      noBottom.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      noBottom.setText("No Bottom");
      lineStyle = new Combo(grpLineOpts, SWT.READ_ONLY);
      lineStyle.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      lineStyle.setItems(new String[] { "solid", "dotted", "dashed" });
      lineStyle.select(0);
      grpTitle = new Group(this, SWT.NONE);
      grpTitle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
  
      GridLayout gl_grpTitle = new GridLayout(2, false);
  
      setVisible(grpTitle, false);
      gl_grpTitle.horizontalSpacing = 0;
      gl_grpTitle.verticalSpacing = 0;
      gl_grpTitle.marginWidth = 0;
      gl_grpTitle.marginHeight = 0;
      grpTitle.setLayout(gl_grpTitle);
      lblTitle = new Label(grpTitle, SWT.NONE);
      lblTitle.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblTitle.setText("Title:");
      titleText = new Text(grpTitle, SWT.BORDER);
      titleText.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
          updateBorder();
        }
      });
      titleText.addTraverseListener(new TraverseListener() {
        public void keyTraversed(TraverseEvent e) {
          if (e.detail == SWT.TRAVERSE_RETURN) {
            updateBorder();
          } else if (e.detail == SWT.TRAVERSE_ESCAPE) {
            String s;
  
            if (activeBorder.getValue() == CBorder.custom) {
              s = activeBorder.spot_getAttribute("class");
            } else {
              s = activeBorder.spot_getAttribute("title");
            }
  
            titleText.setText((s == null) ? "" : s);
          }
        }
      });
      titleText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
      lblTitleLocation = new Label(grpTitle, SWT.NONE);
      lblTitleLocation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblTitleLocation.setText("Title Location:");
      titleLocation = new Combo(grpTitle, SWT.READ_ONLY);
      titleLocation.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          updateBorder();
        }
      });
      titleLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
      lblTitleColor = new Label(grpTitle, SWT.NONE);
      lblTitleColor.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblTitleColor.setText("Title Color:");
      titleColor = new ColorFieldComposite(grpTitle, SWT.NONE);
      titleColor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
      titleColor.setChangeListener(this);
      lblTitleFont = new Label(grpTitle, SWT.NONE);
      lblTitleFont.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblTitleFont.setText("Title Font:");
      titleFont = new FontFieldComposite(grpTitle, SWT.NONE);
      titleFont.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
      titleFont.setChangeListener(this);
      titleLocation.select(0);
      grpColors = new Group(this, SWT.NONE);
      grpColors.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
  
      GridLayout gl_grpColors = new GridLayout(2, false);
  
      gl_grpColors.horizontalSpacing = 2;
      gl_grpColors.marginHeight = 0;
      gl_grpColors.marginWidth = 0;
      gl_grpColors.verticalSpacing = 2;
      grpColors.setLayout(gl_grpColors);
      lblColor1 = new Label(grpColors, SWT.NONE);
      lblColor1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblColor1.setAlignment(SWT.RIGHT);
      lblColor1.setText("Shadow Outer:");
      colorChooser1 = new ColorFieldComposite(grpColors, SWT.NONE);
      colorChooser1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
      colorChooser1.setChangeListener(this);
      lblColor2 = new Label(grpColors, SWT.NONE);
      lblColor2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblColor2.setText("Shadow Inner:");
      colorChooser2 = new ColorFieldComposite(grpColors, SWT.NONE);
      colorChooser2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
      colorChooser2.setChangeListener(this);
      lblColor3 = new Label(grpColors, SWT.NONE);
      lblColor3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblColor3.setText("Hilight Outer:");
      colorChooser3 = new ColorFieldComposite(grpColors, SWT.NONE);
      colorChooser3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
      colorChooser3.setChangeListener(this);
      lblColor4 = new Label(grpColors, SWT.NONE);
      lblColor4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblColor4.setText("Hilight Inner:");
      colorChooser4 = new ColorFieldComposite(grpColors, SWT.NONE);
      colorChooser4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
      colorChooser4.setChangeListener(this);
      grpInsets = new Group(this, SWT.NONE);
      grpInsets.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, false, 1, 1));
      grpInsets.setText("Insets");
  
  