/**
   * Creates an instance of a ControlExample embedded inside the supplied parent Composite.
   *
   * @param parent the container of the example
   */
  public ControlExample(Composite parent) {
    initResources();
    tabFolder = new TabFolder(parent, SWT.NONE);
    tabs = createTabs();
    for (Tab tab : tabs) {
      TabItem item = new TabItem(tabFolder, SWT.NONE);
      item.setText(tab.getTabText());
      item.setControl(tab.createTabFolderPage(tabFolder));
      item.setData(tab);
    }

    /* Workaround: if the tab folder is wider than the screen,
     * Mac platforms clip instead of somehow scrolling the tab items.
     * We try to recover some width by using shorter tab names. */
    Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Rectangle monitorArea = parent.getMonitor().getClientArea();
    boolean isMac = SWT.getPlatform().equals("cocoa");
    if (size.x > monitorArea.width && isMac) {
      TabItem[] tabItems = tabFolder.getItems();
      for (int i = 0; i < tabItems.length; i++) {
        tabItems[i].setText(tabs[i].getShortTabText());
      }
    }
    startup = false;
  }
예제 #2
0
 /** Sets the state of the "Example" widgets. */
 void setExampleWidgetState() {
   super.setExampleWidgetState();
   horizontalButton.setSelection((canvas.getStyle() & SWT.H_SCROLL) != 0);
   verticalButton.setSelection((canvas.getStyle() & SWT.V_SCROLL) != 0);
   borderButton.setSelection((canvas.getStyle() & SWT.BORDER) != 0);
   noBackgroundButton.setSelection((canvas.getStyle() & SWT.NO_BACKGROUND) != 0);
   noFocusButton.setSelection((canvas.getStyle() & SWT.NO_FOCUS) != 0);
   noMergePaintsButton.setSelection((canvas.getStyle() & SWT.NO_MERGE_PAINTS) != 0);
   noRedrawResizeButton.setSelection((canvas.getStyle() & SWT.NO_REDRAW_RESIZE) != 0);
   setCaret();
 }
예제 #3
0
  /** Creates the "Example" group. */
  void createExampleGroup() {
    super.createExampleGroup();

    /* Create a group for the canvas widget */
    canvasGroup = new Group(exampleGroup, SWT.NONE);
    canvasGroup.setLayout(new GridLayout());
    canvasGroup.setLayoutData(
        new GridData(
            GridData.GRAB_HORIZONTAL
                | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_FILL));
    canvasGroup.setText("Canvas");
  }
예제 #4
0
  /** Creates the "Example" group. */
  void createExampleGroup() {
    super.createExampleGroup();
    exampleGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    /*
     * Create a group for the text widget to display
     * the results returned by the example dialogs.
     */
    resultGroup = new Group(exampleGroup, SWT.NONE);
    resultGroup.setLayout(new GridLayout());
    resultGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    resultGroup.setText(ControlExample.getResourceString("Dialog_Result"));
  }
예제 #5
0
  /** Creates the "Other" group. */
  void createOtherGroup() {
    super.createOtherGroup();

    /* Create display controls specific to this example */
    caretButton = new Button(otherGroup, SWT.CHECK);
    caretButton.setText(ControlExample.getResourceString("Caret"));
    fillDamageButton = new Button(otherGroup, SWT.CHECK);
    fillDamageButton.setText(ControlExample.getResourceString("FillDamage"));

    /* Add the listeners */
    caretButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            setCaret();
          }
        });
  }
예제 #6
0
  /**
   * Creates the tab folder page.
   *
   * @param tabFolder org.eclipse.swt.widgets.TabFolder
   * @return the new page for the tab folder
   */
  Composite createTabFolderPage(TabFolder tabFolder) {
    super.createTabFolderPage(tabFolder);

    /*
     * Add a resize listener to the tabFolderPage so that
     * if the user types into the example widget to change
     * its preferred size, and then resizes the shell, we
     * recalculate the preferred size correctly.
     */
    tabFolderPage.addControlListener(
        new ControlAdapter() {
          public void controlResized(ControlEvent e) {
            setExampleWidgetSize();
          }
        });

    return tabFolderPage;
  }
예제 #7
0
  /** Creates the "Style" group. */
  void createStyleGroup() {
    super.createStyleGroup();

    /* Create the extra widgets */
    horizontalButton = new Button(styleGroup, SWT.CHECK);
    horizontalButton.setText("SWT.H_SCROLL");
    horizontalButton.setSelection(true);
    verticalButton = new Button(styleGroup, SWT.CHECK);
    verticalButton.setText("SWT.V_SCROLL");
    verticalButton.setSelection(true);
    borderButton = new Button(styleGroup, SWT.CHECK);
    borderButton.setText("SWT.BORDER");
    noBackgroundButton = new Button(styleGroup, SWT.CHECK);
    noBackgroundButton.setText("SWT.NO_BACKGROUND");
    noFocusButton = new Button(styleGroup, SWT.CHECK);
    noFocusButton.setText("SWT.NO_FOCUS");
    noMergePaintsButton = new Button(styleGroup, SWT.CHECK);
    noMergePaintsButton.setText("SWT.NO_MERGE_PAINTS");
    noRedrawResizeButton = new Button(styleGroup, SWT.CHECK);
    noRedrawResizeButton.setText("SWT.NO_REDRAW_RESIZE");
  }
예제 #8
0
 /** Recreates the "Example" widgets. */
 void recreateExampleWidgets() {
   if (textWidget == null) {
     super.recreateExampleWidgets();
   }
 }