コード例 #1
0
  /**
   * 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
 /**
  * Gets the "Example" widget children's items, if any.
  *
  * @return an array containing the example widget children's items
  */
 Item[] getExampleWidgetItems() {
   return tabFolder1.getItems();
 }
コード例 #3
0
 /** Sets the state of the "Example" widgets. */
 void setExampleWidgetState() {
   super.setExampleWidgetState();
   topButton.setSelection((tabFolder1.getStyle() & SWT.TOP) != 0);
   bottomButton.setSelection((tabFolder1.getStyle() & SWT.BOTTOM) != 0);
   borderButton.setSelection((tabFolder1.getStyle() & SWT.BORDER) != 0);
 }
コード例 #4
0
 /** Grabs input focus. */
 public void setFocus() {
   tabFolder.setFocus();
 }