Ejemplo n.º 1
0
  // create a new slide and return it for users to customize
  public Composite makeNewSlide() {
    DefaultSlideWithTransitionControls slide =
        new DefaultSlideWithTransitionControls(this, SWT.NONE);
    slide.setLayoutData(makeFullFormData());

    mySlides.add(slide);

    if (mySlides.size()
        == 1) // first slide is created, set the starting slide, and set others invisible
    myCurrentSlideIndex = 0;
    else slide.setVisible(false);
    myFarthestSlideIndex = Math.max(myFarthestSlideIndex, myCurrentSlideIndex);
    return slide;
  }
Ejemplo n.º 2
0
  public static void main(String[] args) {
    Shell myShell = new Shell(Display.getCurrent(), SWT.CLOSE | SWT.RESIZE);
    myShell.setLayout(new FormLayout());

    final SlideDeck sd = new SlideDeck(myShell, SWT.NONE);

    DefaultSlideWithTransitionControls comp1 = new DefaultSlideWithTransitionControls(sd, SWT.NONE);
    comp1.setLayout(new FormLayout());
    sd.addNewSlide(comp1);
    comp1.setBackground(Colors.GOLDENROD);
    Button button1 = new Button(comp1, SWT.PUSH);
    button1.setText("Button 1");
    button1.setLayoutData(
        FormDataMaker.makeFormData(0, 130, (Integer) null, 0, 0, 130, (Integer) null, 0));

    DefaultSlideWithTransitionControls comp2 = new DefaultSlideWithTransitionControls(sd, SWT.NONE);
    comp2.setLayout(new FormLayout());
    sd.addNewSlide(comp2);
    comp2.setBackground(Colors.DARK_RED);
    Button button2 = new Button(comp2, SWT.PUSH);
    button2.setText("Button 2");
    button2.setLayoutData(
        FormDataMaker.makeFormData(0, 80, (Integer) null, 0, 0, 80, (Integer) null, 0));

    Composite buttonComp = new Composite(myShell, SWT.NONE);
    buttonComp.setLayout(new FormLayout());
    buttonComp.setBackground(Colors.BLACK);
    Button nextButton = new Button(buttonComp, SWT.PUSH);
    nextButton.setText("Next");
    nextButton.setLayoutData(
        FormDataMaker.makeFormData((Integer) null, 0, 100, 0, 50, 10, (Integer) null, 0));
    Button prevButton = new Button(buttonComp, SWT.PUSH);
    prevButton.setText("Prev");
    prevButton.setLayoutData(
        FormDataMaker.makeFormData((Integer) null, 0, 100, 0, (Integer) null, 0, 50, -10));

    buttonComp.setLayoutData(FormDataMaker.makeFormData((Integer) null, 100, 0, 100));
    sd.setLayoutData(FormDataMaker.makeFormData(0, buttonComp, 0, 100));

    Composite comp3 = sd.makeNewSlide();
    comp3.setBackground(Colors.INDIGO);

    nextButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            sd.slideNext();
          }
        });

    prevButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            sd.slidePrevious();
          }
        });

    myShell.setSize(300, 300);
    myShell.open();
    while (!myShell.isDisposed()) {
      if (!Display.getCurrent().readAndDispatch()) Display.getCurrent().sleep();
    }
    if (!myShell.isDisposed()) {
      myShell.close();
      myShell.dispose();
    }
  }