Package org.eclipse.swt.layout

Examples of org.eclipse.swt.layout.FormAttachment


   
    footer.setLayout(layout);
    FormData data;
     
    data = new FormData();
    data.left = new FormAttachment(0,45);
    data.right = new FormAttachment(turnOnButton);
    dont_ask_again.setLayoutData(data);

    data = new FormData();
    data.right = new FormAttachment(100);
    data.width = 100;
    cancelButton.setLayoutData(data);
   
    data = new FormData();
    data.right = new FormAttachment( cancelButton );
    data.width = 100;
    turnOnButton.setLayoutData(data);
   
   
   
View Full Code Here


      int percent = 0;
      String sAlign = null;
      int align = SWT.DEFAULT;

      // grab any defaults from existing attachment
      FormAttachment attachment;
      switch (i) {
        case 0:
          attachment = oldFormData.top;
          break;

        case 1:
          attachment = oldFormData.bottom;
          break;

        case 2:
          attachment = oldFormData.left;
          break;

        case 3:
          attachment = oldFormData.right;
          break;

        default:
          attachment = null;
      }

      if (attachment != null) {
        control = attachment.control;
        offset = attachment.offset;
        align = attachment.alignment;
        // XXX Assumed: Denominator is 100
        percent = attachment.numerator;
      }

      // parse skin config

      String suffix = ".attach." + sDirections[i];
      String prefix = sConfigID;
      String[] sParams;

      sParams = properties.getStringArray(sConfigID + suffix);
      if (sParams == null && templateID != null) {
        sParams = properties.getStringArray(templateID + suffix);
        prefix = templateID;
      }

      if (sParams == null) {
        if (attachment != null) {
          if (control == null) {
            attachment = new FormAttachment(percent, offset);
          } else {
            attachment = new FormAttachment(control, offset, align);
          }
        }

      } else if (sParams.length == 0
          || (sParams.length == 1 && sParams[0].length() == 0)) {
        attachment = null;
      } else {

        if (sParams[0].length() > 0 && Character.isDigit(sParams[0].charAt(0))) {
          // Percent, Offset
          try {
            percent = Integer.parseInt(sParams[0]);
          } catch (Exception e) {
          }

          if (sParams.length > 1) {
            try {
              offset = Integer.parseInt(sParams[1]);
            } catch (Exception e) {
            }
          }

          attachment = new FormAttachment(percent, offset);

        } else {
          // Object, Offset, Alignment
          String sWidget = sParams[0];

          SWTSkinObject configSkinObject = getSkinObjectByID(sWidget,
              skinObject.getParent());
          int iNextPos;
          if (configSkinObject != null) {
            control = configSkinObject.getControl();

            iNextPos = 1;
          } else {
            iNextPos = 0;

            if (sWidget.length() != 0) {
              System.err.println("ERROR: Trying to attach " + sDirections[i]
                  + " of widget '" + skinObject + "' to non-existant widget '"
                  + sWidget + "'.  Attachment Parameters: "
                  + properties.getStringValue(prefix + suffix));
            }
          }

          for (int j = iNextPos; j < sParams.length; j++) {
            if (sParams[j].length() > 0) {
              char c = sParams[j].charAt(0);
              if (Character.isDigit(c) || c == '-') {
                try {
                  offset = Integer.parseInt(sParams[j]);
                } catch (Exception e) {
                }
              } else {
                sAlign = sParams[j];
              }
            }
          }

          if (sAlign != null) {
            align = SWTSkinUtils.getAlignment(sAlign, align);
          }

          attachment = new FormAttachment(control, offset, align);
        }
      }

      if (debugControl && attachment != null) {
        if (controlToLayout instanceof Group) {
View Full Code Here

          }

          Rectangle parentArea = sash.getParent().getClientArea();

          FormData formData = (FormData) sash.getLayoutData();
          formData.left = new FormAttachment(e.x * 100 / parentArea.width);
          sash.getParent().layout();
        }
      });
    } else {
      // Widgets exist, so use a SashForm to split them
View Full Code Here

        search.setData("execAfterLoad", execAfterLoad);

        search.setUrl(url);

        FormData gd = (FormData) controlBottom.getLayoutData();
        gd.top = new FormAttachment(controlTop, 0);
        gd.height = SWT.DEFAULT;
        controlBottom.setLayoutData(gd);

        gd = (FormData) controlTop.getLayoutData();
        gd.bottom = null;
View Full Code Here

        gd.top = null;
        gd.height = 0;
        controlBottom.setLayoutData(gd);

        gd = (FormData) controlTop.getLayoutData();
        gd.bottom = new FormAttachment(controlBottom, 0);
        gd.height = SWT.DEFAULT;
        controlTop.setLayoutData(gd);

        controlBottom.getParent().layout(true);
        search.setUrl("about:blank");
View Full Code Here

      textWidget = new Text(createOn, style);
    } else {
      textWidget = new Text(cBubble, style & ~(SWT.BORDER | SWT.SEARCH));
     
      FormData fd = new FormData();
      fd.top = new FormAttachment(0, 2);
      fd.bottom = new FormAttachment(100, -2);
      fd.left = new FormAttachment(0, 17);
      fd.right = new FormAttachment(100, -14);
      textWidget.setLayoutData(fd);

      cBubble.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
          Rectangle clientArea = cBubble.getClientArea();
View Full Code Here

    if (so != null) {
      so.setTooltipID(item.getTooltipID());

      if (lastControl != null) {
        FormData fd = (FormData) so.getControl().getLayoutData();
        fd.left = new FormAttachment(lastControl);
      }

      so.setData("toolbaritem", item);
      SWTSkinButtonUtility btn = new SWTSkinButtonUtility(so,
          "toolbar-item-image");
View Full Code Here

    SWTSkinObject so = skin.createSkinObject("toolbar_sep" + Math.random(), id,
        soMain);
    if (so != null) {
      if (lastControl != null) {
        FormData fd = (FormData) so.getControl().getLayoutData();
        fd.left = new FormAttachment(lastControl, fd.left == null ? 0
            : fd.left.offset);
      }

      lastControl = so.getControl();
    }
View Full Code Here

    SWTSkinObject so = skin.createSkinObject("toolbar_d" + Math.random(),
        skinid, soMain);
    if (so != null) {
      if (lastControl != null) {
        FormData fd = (FormData) so.getControl().getLayoutData();
        fd.left = new FormAttachment(lastControl, fd.left == null ? 0
            : fd.left.offset);
      }

      lastControl = so.getControl();
    }
View Full Code Here

    canvas = new Canvas(shell, SWT.BORDER);
    canvas.setCursor(cursor);
    data = new FormData();
    data.width = displayWidth;
    data.height = displayHeight;
    data.top = new FormAttachment(title, 5);
    canvas.setLayoutData(data);

    canvas.addListener(SWT.MouseDown, moveImageListener);
    canvas.addListener(SWT.MouseUp, moveImageListener);
    canvas.addListener(SWT.MouseMove, moveImageListener);

    canvas.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent arg0) {
        drawCurrentImage();
      }
    });

    offset.x = (minWidth - currentImage.getBounds().width) / 2;
    offset.y = (minHeight - currentImage.getBounds().height) / 2;

    Label label = new Label(shell, SWT.WRAP);
    //The label text depends on the presence of the scale,
    //Thefore we delay the size computation as well as
    //Assiging any FormData (layout) to it see (1)

    //The Control to witch the Buttons OK and Cancel are going to be attached
    //Depends on the presence of the scale
    Control attach = label;

    if (minZoomRatio < 1) {
      scale = new Scale(shell, SWT.HORIZONTAL);
      data = new FormData();
      data.width = displayWidth;
      data.top = new FormAttachment(label, 5);
      scale.setLayoutData(data);
      scale.setMaximum((int) (RESIZE_STEPS * maxZoomRatio));
      scale.setMinimum((int) (RESIZE_STEPS * minZoomRatio));
      scale.setIncrement((int) ((maxZoomRatio - minZoomRatio) * RESIZE_STEPS / 10));
      scale.setPageIncrement((int) ((maxZoomRatio - minZoomRatio)
          * RESIZE_STEPS / 10));

      scale.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event arg0) {
          final long timestamp = SystemTime.getCurrentTime();
          lastUpdate = timestamp;

          final int position = scale.getSelection();

          AEThread t = new AEThread("") {
            public void runSupport() {
              try {
                Thread.sleep(150);
              } catch (Exception e) {
                e.printStackTrace();
              }

              if (timestamp == lastUpdate) {
                if (display != null && !display.isDisposed()) {
                  display.asyncExec(new Runnable() {
                    public void run() {
                      refreshCurrentImage(position);
                    }
                  });
                }
              }
            }
          };
          t.setDaemon(true);
          t.start();

        }
      });
      attach = scale;
      label.setText(MessageText.getString("ImageResizer.move.image.with.slider"));
    } else {
      label.setText(MessageText.getString("ImageResizer.move.image"));
    }

    // (1) Layout of the label, depending on the text in it
    int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
    if (width > displayWidth) {
      width = displayWidth;
    }

    data = new FormData();
    data.width = width;
    data.top = new FormAttachment(canvas, 5);
    data.left = new FormAttachment(canvas, 0, SWT.CENTER);
    label.setLayoutData(data);

    Button btnCancel = new Button(shell, SWT.PUSH);
    btnCancel.setText("Cancel");
    data = new FormData();
    data.width = 70;
    data.top = new FormAttachment(attach, 10);
    data.right = new FormAttachment(100, -10);
    btnCancel.setLayoutData(data);
    btnCancel.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event arg0) {
        result = null;
        done = true;
        dispose();
        imageResizerListener.imageResized(result);
      }
    });

    Button btnOk = new Button(shell, SWT.PUSH);
    btnOk.setText("OK");
    data = new FormData();
    data.width = 70;
    data.top = new FormAttachment(attach, 10);
    data.right = new FormAttachment(btnCancel, -10);
    btnOk.setLayoutData(data);
    btnOk.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event arg0) {
        result = computeResultImage();
        done = true;
View Full Code Here

TOP

Related Classes of org.eclipse.swt.layout.FormAttachment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.